]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/parser.js
2 Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3 Available via Academic Free License >= 2.1 OR the modified BSD license.
4 see: http://dojotoolkit.org/license for details
8 if(!dojo
._hasResource
["dojo.parser"]){
9 dojo
._hasResource
["dojo.parser"]=true;
10 dojo
.provide("dojo.parser");
11 dojo
.require("dojo.date.stamp");
13 dojo
.parser
=new function(){
15 this._attrName
=d
._scopeName
+"Type";
16 this._query
="["+this._attrName
+"]";
21 if(typeof _2
=="number"){
24 if(typeof _2
=="boolean"){
33 if(_2
instanceof Date
){
36 if(_2
instanceof d
._Url
){
46 return _4
.length
?Number(_4
):NaN
;
48 return typeof _4
=="boolean"?_4
:!(_4
.toLowerCase()=="false");
52 _4
=d
.trim(_4
.substring(_4
.indexOf("{")+1,_4
.length
-1));
55 if(_4
===""||_4
.search(/[^\w\.]+/i)!=-1){
56 return new Function(_4
);
58 return d
.getObject(_4
,false)||new Function(_4
);
62 return new Function();
65 return _4
?_4
.split(/\s*,\s*/):[];
73 return d
.date
.stamp
.fromISOString(_4
);
78 return d
.fromJson(_4
);
82 dojo
.connect(dojo
,"extend",function(){
87 var _9
=d
.getObject(_8
);
94 if(_d
.charAt(0)=="_"){
103 _6
[_8
]={cls
:_9
,params
:_b
};
107 this._functionFromScript=function(_f
){
110 var _12
=_f
.getAttribute("args");
112 d
.forEach(_12
.split(/\s*,\s*/),function(_13
,idx
){
113 _10
+="var "+_13
+" = arguments["+idx
+"]; ";
116 var _14
=_f
.getAttribute("with");
118 d
.forEach(_14
.split(/\s*,\s*/),function(_15
){
119 _10
+="with("+_15
+"){";
123 return new Function(_10
+_f
.innerHTML
+_11
);
125 this.instantiate=function(_16
,_17
,_18
){
126 var _19
=[],dp
=dojo
.parser
;
129 d
.forEach(_16
,function(obj
){
133 var _1a
,_1b
,_1c
,_1d
,_1e
;
137 _1c
=obj
.clsInfo
||(_1b
&&_7(_1b
));
142 _1b
=dp
._attrName
in _17
?_17
[dp
._attrName
]:_1a
.getAttribute(dp
._attrName
);
145 _1e
=(_1d
&&(_1d
._noScript
||_1d
.prototype._noScript
)?[]:d
.query("> script[type^='dojo/']",_1a
));
148 throw new Error("Could not load class '"+_1b
);
150 var _1f
={},_20
=_1a
.attributes
;
152 dojo
.mixin(_1f
,_18
.defaults
);
155 dojo
.mixin(_1f
,obj
.inherited
);
157 for(var _21
in _1c
.params
){
158 var _22
=_21
in _17
?{value
:_17
[_21
],specified
:true}:_20
.getNamedItem(_21
);
159 if(!_22
||(!_22
.specified
&&(!dojo
.isIE
||_21
.toLowerCase()!="value"))){
165 _23
="className" in _17
?_17
.className
:_1a
.className
;
168 _23
="style" in _17
?_17
.style
:(_1a
.style
&&_1a
.style
.cssText
);
170 var _24
=_1c
.params
[_21
];
171 if(typeof _23
=="string"){
172 _1f
[_21
]=_3(_23
,_24
);
178 d
.forEach(_1e
,function(_27
){
179 _1a
.removeChild(_27
);
180 var _28
=_27
.getAttribute("event"),_1b
=_27
.getAttribute("type"),nf
=d
.parser
._functionFromScript(_27
);
182 if(_1b
=="dojo/connect"){
183 _25
.push({event
:_28
,func
:nf
});
191 var _29
=_1d
.markupFactory
||_1d
.prototype&&_1d
.prototype.markupFactory
;
192 var _2a
=_29
?_29(_1f
,_1a
,_1d
):new _1d(_1f
,_1a
);
194 var _2b
=_1a
.getAttribute("jsId");
196 d
.setObject(_2b
,_2a
);
198 d
.forEach(_25
,function(_2c
){
199 d
.connect(_2a
,_2c
.event
,null,_2c
.func
);
201 d
.forEach(_26
,function(_2d
){
206 d
.forEach(_19
,function(_2e
){
207 if(!_18
.noStart
&&_2e
&&_2e
.startup
&&!_2e
._started
&&(!_2e
.getParent
||!_2e
.getParent())){
214 this.parse=function(_2f
,_30
){
216 if(!_30
&&_2f
&&_2f
.rootNode
){
222 var _32
=this._attrName
;
223 function _33(_34
,_35
){
224 var _36
=dojo
.clone(_34
.inherited
);
225 dojo
.forEach(["dir","lang"],function(_37
){
226 var val
=_34
.node
.getAttribute(_37
);
232 var _39
=!_34
.clsInfo
||!_34
.clsInfo
.cls
.prototype.stopParser
;
233 for(var _3a
=_34
.node
.firstChild
;_3a
;_3a
=_3a
.nextSibling
){
235 var _3b
=_39
&&_3a
.getAttribute(_32
);
237 var _3c
={"type":_3b
,clsInfo
:_7(_3b
),node
:_3a
,scripts
:[],inherited
:_36
};
241 if(_38
&&_3a
.nodeName
.toLowerCase()=="script"){
242 _3b
=_3a
.getAttribute("type");
243 if(_3b
&&/^dojo\//i.test(_3b
)){
248 _33({node
:_3a
,inherited
:_36
},_35
);
256 _33({node
:_31
?dojo
.byId(_31
):dojo
.body(),inherited
:(_30
&&_30
.inherited
)||{dir
:dojo
._isBodyLtr()?"ltr":"rtl"}},_3d
);
257 return this.instantiate(_3d
,null,_30
);
262 if(dojo
.config
.parseOnLoad
){
266 if(dojo
.exists("dijit.wai.onload")&&(dijit
.wai
.onload
===dojo
._loaders
[0])){
267 dojo
._loaders
.splice(1,0,_3e
);
269 dojo
._loaders
.unshift(_3e
);