]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/NodeList-manipulate.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.NodeList-manipulate"]){
9 dojo
._hasResource
["dojo.NodeList-manipulate"]=true;
10 dojo
.provide("dojo.NodeList-manipulate");
13 var _3
="",ch
=_2
.childNodes
;
14 for(var i
=0,n
;n
=ch
[i
];i
++){
26 while(_5
.childNodes
[0]&&_5
.childNodes
[0].nodeType
==1){
32 if(typeof _7
=="string"){
33 _7
=dojo
._toDom(_7
,(_8
&&_8
.ownerDocument
));
38 if(_7
.nodeType
==1&&_7
.parentNode
){
39 _7
=_7
.cloneNode(false);
44 dojo
.extend(dojo
.NodeList
,{_placeMultiple:function(_9
,_a
){
45 var _b
=typeof _9
=="string"||_9
.nodeType
?dojo
.query(_9
):_9
;
47 for(var i
=0;i
<_b
.length
;i
++){
50 for(var j
=_e
-1,_f
;_f
=this[j
];j
--){
52 _f
=this._cloneNode(_f
);
58 _d
.parentNode
.insertBefore(_f
,_d
);
65 _c
.unshift(this.length
-1);
66 Array
.prototype.splice
.apply(this,_c
);
69 },innerHTML:function(_10
){
71 return this.addContent(_10
,"only");
73 return this[0].innerHTML
;
77 for(var i
=0,_12
;_12
=this[i
];i
++){
80 _12
.appendChild(_12
.ownerDocument
.createTextNode(_11
));
86 for(i
=0;_12
=this[i
];i
++){
93 var _15
=dojo
.isArray(_14
);
94 for(var _16
=0,_17
;_17
=this[_16
];_16
++){
95 var _18
=_17
.nodeName
.toUpperCase();
97 var _1a
=_15
?_14
[_16
]:_14
;
100 for(var i
=0;i
<_1b
.length
;i
++){
103 opt
.selected
=(dojo
.indexOf(_14
,opt
.value
)!=-1);
105 opt
.selected
=(opt
.value
==_1a
);
109 if(_19
=="checkbox"||_19
=="radio"){
110 _17
.checked
=(_17
.value
==_1a
);
119 if(!_17
||_17
.nodeType
!=1){
123 if(_17
.nodeName
.toUpperCase()=="SELECT"&&_17
.multiple
){
126 for(i
=0;i
<_1b
.length
;i
++){
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
){
157 for(var i
=0,_25
;_25
=this[i
];i
++){
158 var _26
=this._cloneNode(_24
);
160 _25
.parentNode
.replaceChild(_26
,_25
);
163 _27
.appendChild(_25
);
167 },wrapAll:function(_28
){
170 this[0].parentNode
.replaceChild(_28
,this[0]);
172 for(var i
=0,_2a
;_2a
=this[i
];i
++){
173 _29
.appendChild(_2a
);
177 },wrapInner:function(_2b
){
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
);
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
);
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
);
203 for(var i
=0;i
<this.length
;i
++){
204 ary
.push(this._cloneNode(this[i
]));
206 return this._wrap(ary
,this,this._NodeListCtor
);
208 if(!dojo
.NodeList
.prototype.html
){
209 dojo
.NodeList
.prototype.html
=dojo
.NodeList
.prototype.innerHTML
;