]> git.wh0rd.org - tt-rss.git/blame - lib/dojo/NodeList-manipulate.js
add dijit/dojo stuff; initial ui mockup
[tt-rss.git] / lib / dojo / NodeList-manipulate.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.NodeList-manipulate"]){
9dojo._hasResource["dojo.NodeList-manipulate"]=true;
10dojo.provide("dojo.NodeList-manipulate");
11(function(){
12function _1(_2){
13var _3="",ch=_2.childNodes;
14for(var i=0,n;n=ch[i];i++){
15if(n.nodeType!=8){
16if(n.nodeType==1){
17_3+=_1(n);
18}else{
19_3+=n.nodeValue;
20}
21}
22}
23return _3;
24};
25function _4(_5){
26while(_5.childNodes[0]&&_5.childNodes[0].nodeType==1){
27_5=_5.childNodes[0];
28}
29return _5;
30};
31function _6(_7,_8){
32if(typeof _7=="string"){
33_7=dojo._toDom(_7,(_8&&_8.ownerDocument));
34if(_7.nodeType==11){
35_7=_7.childNodes[0];
36}
37}else{
38if(_7.nodeType==1&&_7.parentNode){
39_7=_7.cloneNode(false);
40}
41}
42return _7;
43};
44dojo.extend(dojo.NodeList,{_placeMultiple:function(_9,_a){
45var _b=typeof _9=="string"||_9.nodeType?dojo.query(_9):_9;
46var _c=[];
47for(var i=0;i<_b.length;i++){
48var _d=_b[i];
49var _e=this.length;
50for(var j=_e-1,_f;_f=this[j];j--){
51if(i>0){
52_f=this._cloneNode(_f);
53_c.unshift(_f);
54}
55if(j==_e-1){
56dojo.place(_f,_d,_a);
57}else{
58_d.parentNode.insertBefore(_f,_d);
59}
60_d=_f;
61}
62}
63if(_c.length){
64_c.unshift(0);
65_c.unshift(this.length-1);
66Array.prototype.splice.apply(this,_c);
67}
68return this;
69},innerHTML:function(_10){
70if(arguments.length){
71return this.addContent(_10,"only");
72}else{
73return this[0].innerHTML;
74}
75},text:function(_11){
76if(arguments.length){
77for(var i=0,_12;_12=this[i];i++){
78if(_12.nodeType==1){
79dojo.empty(_12);
80_12.appendChild(_12.ownerDocument.createTextNode(_11));
81}
82}
83return this;
84}else{
85var _13="";
86for(i=0;_12=this[i];i++){
87_13+=_1(_12);
88}
89return _13;
90}
91},val:function(_14){
92if(arguments.length){
93var _15=dojo.isArray(_14);
94for(var _16=0,_17;_17=this[_16];_16++){
95var _18=_17.nodeName.toUpperCase();
96var _19=_17.type;
97var _1a=_15?_14[_16]:_14;
98if(_18=="SELECT"){
99var _1b=_17.options;
100for(var i=0;i<_1b.length;i++){
101var opt=_1b[i];
102if(_17.multiple){
103opt.selected=(dojo.indexOf(_14,opt.value)!=-1);
104}else{
105opt.selected=(opt.value==_1a);
106}
107}
108}else{
109if(_19=="checkbox"||_19=="radio"){
110_17.checked=(_17.value==_1a);
111}else{
112_17.value=_1a;
113}
114}
115}
116return this;
117}else{
118_17=this[0];
119if(!_17||_17.nodeType!=1){
120return undefined;
121}
122_14=_17.value||"";
123if(_17.nodeName.toUpperCase()=="SELECT"&&_17.multiple){
124_14=[];
125_1b=_17.options;
126for(i=0;i<_1b.length;i++){
127opt=_1b[i];
128if(opt.selected){
129_14.push(opt.value);
130}
131}
132if(!_14.length){
133_14=null;
134}
135}
136return _14;
137}
138},append:function(_1c){
139return this.addContent(_1c,"last");
140},appendTo:function(_1d){
141return this._placeMultiple(_1d,"last");
142},prepend:function(_1e){
143return this.addContent(_1e,"first");
144},prependTo:function(_1f){
145return this._placeMultiple(_1f,"first");
146},after:function(_20){
147return this.addContent(_20,"after");
148},insertAfter:function(_21){
149return this._placeMultiple(_21,"after");
150},before:function(_22){
151return this.addContent(_22,"before");
152},insertBefore:function(_23){
153return this._placeMultiple(_23,"before");
154},remove:dojo.NodeList.prototype.orphan,wrap:function(_24){
155if(this[0]){
156_24=_6(_24,this[0]);
157for(var i=0,_25;_25=this[i];i++){
158var _26=this._cloneNode(_24);
159if(_25.parentNode){
160_25.parentNode.replaceChild(_26,_25);
161}
162var _27=_4(_26);
163_27.appendChild(_25);
164}
165}
166return this;
167},wrapAll:function(_28){
168if(this[0]){
169_28=_6(_28,this[0]);
170this[0].parentNode.replaceChild(_28,this[0]);
171var _29=_4(_28);
172for(var i=0,_2a;_2a=this[i];i++){
173_29.appendChild(_2a);
174}
175}
176return this;
177},wrapInner:function(_2b){
178if(this[0]){
179_2b=_6(_2b,this[0]);
180for(var i=0;i<this.length;i++){
181var _2c=this._cloneNode(_2b);
182this._wrap(dojo._toArray(this[i].childNodes),null,this._NodeListCtor).wrapAll(_2c);
183}
184}
185return this;
186},replaceWith:function(_2d){
187_2d=this._normalize(_2d,this[0]);
188for(var i=0,_2e;_2e=this[i];i++){
189this._place(_2d,_2e,"before",i>0);
190_2e.parentNode.removeChild(_2e);
191}
192return this;
193},replaceAll:function(_2f){
194var nl=dojo.query(_2f);
195var _30=this._normalize(this,this[0]);
196for(var i=0,_31;_31=nl[i];i++){
197this._place(_30,_31,"before",i>0);
198_31.parentNode.removeChild(_31);
199}
200return this;
201},clone:function(){
202var ary=[];
203for(var i=0;i<this.length;i++){
204ary.push(this._cloneNode(this[i]));
205}
206return this._wrap(ary,this,this._NodeListCtor);
207}});
208if(!dojo.NodeList.prototype.html){
209dojo.NodeList.prototype.html=dojo.NodeList.prototype.innerHTML;
210}
211})();
212}