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