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