]> git.wh0rd.org - tt-rss.git/blame - lib/dojo/_base/NodeList.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / _base / NodeList.js
CommitLineData
2f01fe57
AD
1/*
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
5*/
6
7
8if(!dojo._hasResource["dojo._base.NodeList"]){
9dojo._hasResource["dojo._base.NodeList"]=true;
10dojo.provide("dojo._base.NodeList");
11dojo.require("dojo._base.lang");
12dojo.require("dojo._base.array");
13(function(){
14var d=dojo;
15var ap=Array.prototype,_1=ap.slice,_2=ap.concat;
16var _3=function(a,_4,_5){
17if(!a.sort){
18a=_1.call(a,0);
19}
20var _6=_5||this._NodeListCtor||d._NodeListCtor;
21a.constructor=_6;
22dojo._mixin(a,_6.prototype);
23a._NodeListCtor=_6;
24return _4?a._stash(_4):a;
25};
26var _7=function(f,a,o){
27a=[0].concat(_1.call(a,0));
28o=o||d.global;
29return function(_8){
30a[0]=_8;
31return f.apply(o,a);
32};
33};
34var _9=function(f,o){
35return function(){
36this.forEach(_7(f,arguments,o));
37return this;
38};
39};
40var _a=function(f,o){
41return function(){
42return this.map(_7(f,arguments,o));
43};
44};
45var _b=function(f,o){
46return function(){
47return this.filter(_7(f,arguments,o));
48};
49};
50var _c=function(f,g,o){
51return function(){
52var a=arguments,_d=_7(f,a,o);
53if(g.call(o||d.global,a)){
54return this.map(_d);
55}
56this.forEach(_d);
57return this;
58};
59};
60var _e=function(a){
61return a.length==1&&(typeof a[0]=="string");
62};
63var _f=function(_10){
64var p=_10.parentNode;
65if(p){
66p.removeChild(_10);
67}
68};
69dojo.NodeList=function(){
70return _3(Array.apply(null,arguments));
71};
72d._NodeListCtor=d.NodeList;
73var nl=d.NodeList,nlp=nl.prototype;
74nl._wrap=nlp._wrap=_3;
75nl._adaptAsMap=_a;
76nl._adaptAsForEach=_9;
77nl._adaptAsFilter=_b;
78nl._adaptWithCondition=_c;
79d.forEach(["slice","splice"],function(_11){
80var f=ap[_11];
81nlp[_11]=function(){
82return this._wrap(f.apply(this,arguments),_11=="slice"?this:null);
83};
84});
85d.forEach(["indexOf","lastIndexOf","every","some"],function(_12){
86var f=d[_12];
87nlp[_12]=function(){
88return f.apply(d,[this].concat(_1.call(arguments,0)));
89};
90});
91d.forEach(["attr","style"],function(_13){
92nlp[_13]=_c(d[_13],_e);
93});
94d.forEach(["connect","addClass","removeClass","toggleClass","empty","removeAttr"],function(_14){
95nlp[_14]=_9(d[_14]);
96});
97dojo.extend(dojo.NodeList,{_normalize:function(_15,_16){
98var _17=_15.parse===true?true:false;
99if(typeof _15.template=="string"){
100var _18=_15.templateFunc||(dojo.string&&dojo.string.substitute);
101_15=_18?_18(_15.template,_15):_15;
102}
103var _19=(typeof _15);
104if(_19=="string"||_19=="number"){
105_15=dojo._toDom(_15,(_16&&_16.ownerDocument));
106if(_15.nodeType==11){
107_15=dojo._toArray(_15.childNodes);
108}else{
109_15=[_15];
110}
111}else{
112if(!dojo.isArrayLike(_15)){
113_15=[_15];
114}else{
115if(!dojo.isArray(_15)){
116_15=dojo._toArray(_15);
117}
118}
119}
120if(_17){
121_15._runParse=true;
122}
123return _15;
124},_cloneNode:function(_1a){
125return _1a.cloneNode(true);
126},_place:function(ary,_1b,_1c,_1d){
127if(_1b.nodeType!=1&&_1c=="only"){
128return;
129}
130var _1e=_1b,_1f;
131var _20=ary.length;
132for(var i=_20-1;i>=0;i--){
133var _21=(_1d?this._cloneNode(ary[i]):ary[i]);
134if(ary._runParse&&dojo.parser&&dojo.parser.parse){
135if(!_1f){
136_1f=_1e.ownerDocument.createElement("div");
137}
138_1f.appendChild(_21);
139dojo.parser.parse(_1f);
140_21=_1f.firstChild;
141while(_1f.firstChild){
142_1f.removeChild(_1f.firstChild);
143}
144}
145if(i==_20-1){
146dojo.place(_21,_1e,_1c);
147}else{
148_1e.parentNode.insertBefore(_21,_1e);
149}
150_1e=_21;
151}
152},_stash:function(_22){
153this._parent=_22;
154return this;
155},end:function(){
156if(this._parent){
157return this._parent;
158}else{
159return new this._NodeListCtor();
160}
161},concat:function(_23){
162var t=d.isArray(this)?this:_1.call(this,0),m=d.map(arguments,function(a){
163return a&&!d.isArray(a)&&(typeof NodeList!="undefined"&&a.constructor===NodeList||a.constructor===this._NodeListCtor)?_1.call(a,0):a;
164});
165return this._wrap(_2.apply(t,m),this);
166},map:function(_24,obj){
167return this._wrap(d.map(this,_24,obj),this);
168},forEach:function(_25,_26){
169d.forEach(this,_25,_26);
170return this;
171},coords:_a(d.coords),position:_a(d.position),place:function(_27,_28){
172var _29=d.query(_27)[0];
173return this.forEach(function(_2a){
174d.place(_2a,_29,_28);
175});
176},orphan:function(_2b){
177return (_2b?d._filterQueryResult(this,_2b):this).forEach(_f);
178},adopt:function(_2c,_2d){
179return d.query(_2c).place(this[0],_2d)._stash(this);
180},query:function(_2e){
181if(!_2e){
182return this;
183}
184var ret=this.map(function(_2f){
185return d.query(_2e,_2f).filter(function(_30){
186return _30!==undefined;
187});
188});
189return this._wrap(_2.apply([],ret),this);
190},filter:function(_31){
191var a=arguments,_32=this,_33=0;
192if(typeof _31=="string"){
193_32=d._filterQueryResult(this,a[0]);
194if(a.length==1){
195return _32._stash(this);
196}
197_33=1;
198}
199return this._wrap(d.filter(_32,a[_33],a[_33+1]),this);
200},addContent:function(_34,_35){
201_34=this._normalize(_34,this[0]);
202for(var i=0,_36;_36=this[i];i++){
203this._place(_34,_36,_35,i>0);
204}
205return this;
206},instantiate:function(_37,_38){
207var c=d.isFunction(_37)?_37:d.getObject(_37);
208_38=_38||{};
209return this.forEach(function(_39){
210new c(_38,_39);
211});
212},at:function(){
213var t=new this._NodeListCtor();
214d.forEach(arguments,function(i){
215if(i<0){
216i=this.length+i;
217}
218if(this[i]){
219t.push(this[i]);
220}
221},this);
222return t._stash(this);
223}});
224nl.events=["blur","focus","change","click","error","keydown","keypress","keyup","load","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","submit"];
225d.forEach(nl.events,function(evt){
226var _3a="on"+evt;
227nlp[_3a]=function(a,b){
228return this.connect(_3a,a,b);
229};
230});
231})();
232}