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