]> git.wh0rd.org - tt-rss.git/blob - lib/dijit/_Templated.js.uncompressed.js
add prototype simple remover of baaaad tags based on domdocument
[tt-rss.git] / lib / dijit / _Templated.js.uncompressed.js
1 define("dijit/_Templated", [
2 "./_WidgetBase",
3 "./_TemplatedMixin",
4 "./_WidgetsInTemplateMixin",
5 "dojo/_base/array", // array.forEach
6 "dojo/_base/declare", // declare
7 "dojo/_base/lang", // lang.extend lang.isArray
8 "dojo/_base/kernel" // kernel.deprecated
9 ], function(_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, array, declare, lang, kernel){
10
11 // module:
12 // dijit/_Templated
13
14 // These arguments can be specified for widgets which are used in templates.
15 // Since any widget can be specified as sub widgets in template, mix it
16 // into the base widget class. (This is a hack, but it's effective.)
17 // Remove for 2.0. Also, hide from API doc parser.
18 lang.extend(_WidgetBase, /*===== {} || =====*/ {
19 waiRole: "",
20 waiState:""
21 });
22
23 return declare("dijit._Templated", [_TemplatedMixin, _WidgetsInTemplateMixin], {
24 // summary:
25 // Deprecated mixin for widgets that are instantiated from a template.
26 // Widgets should use _TemplatedMixin plus if necessary _WidgetsInTemplateMixin instead.
27
28 // widgetsInTemplate: [protected] Boolean
29 // Should we parse the template to find widgets that might be
30 // declared in markup inside it? False by default.
31 widgetsInTemplate: false,
32
33 constructor: function(){
34 kernel.deprecated(this.declaredClass + ": dijit._Templated deprecated, use dijit._TemplatedMixin and if necessary dijit._WidgetsInTemplateMixin", "", "2.0");
35 },
36
37 _attachTemplateNodes: function(rootNode, getAttrFunc){
38
39 this.inherited(arguments);
40
41 // Do deprecated waiRole and waiState
42 var nodes = lang.isArray(rootNode) ? rootNode : (rootNode.all || rootNode.getElementsByTagName("*"));
43 var x = lang.isArray(rootNode) ? 0 : -1;
44 for(; x<nodes.length; x++){
45 var baseNode = (x == -1) ? rootNode : nodes[x];
46
47 // waiRole, waiState
48 var role = getAttrFunc(baseNode, "waiRole");
49 if(role){
50 baseNode.setAttribute("role", role);
51 }
52 var values = getAttrFunc(baseNode, "waiState");
53 if(values){
54 array.forEach(values.split(/\s*,\s*/), function(stateValue){
55 if(stateValue.indexOf('-') != -1){
56 var pair = stateValue.split('-');
57 baseNode.setAttribute("aria-"+pair[0], pair[1]);
58 }
59 });
60 }
61 }
62 }
63 });
64 });