source:
trunk/workshop-routing-foss4g/web/ext/src/core/Element.insertion-more.js
@
76
Revision 76, 2.0 KB checked in by djay, 12 years ago (diff) | |
---|---|
|
Line | |
---|---|
1 | /*! |
2 | * Ext JS Library 3.4.0 |
3 | * Copyright(c) 2006-2011 Sencha Inc. |
4 | * licensing@sencha.com |
5 | * http://www.sencha.com/license |
6 | */ |
7 | /** |
8 | * @class Ext.Element |
9 | */ |
10 | Ext.apply(Ext.Element.prototype, function() { |
11 | var GETDOM = Ext.getDom, |
12 | GET = Ext.get, |
13 | DH = Ext.DomHelper; |
14 | |
15 | return { |
16 | /** |
17 | * Inserts (or creates) the passed element (or DomHelper config) as a sibling of this element |
18 | * @param {Mixed/Object/Array} el The id, element to insert or a DomHelper config to create and insert *or* an array of any of those. |
19 | * @param {String} where (optional) 'before' or 'after' defaults to before |
20 | * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element |
21 | * @return {Ext.Element} The inserted Element. If an array is passed, the last inserted element is returned. |
22 | */ |
23 | insertSibling: function(el, where, returnDom){ |
24 | var me = this, |
25 | rt, |
26 | isAfter = (where || 'before').toLowerCase() == 'after', |
27 | insertEl; |
28 | |
29 | if(Ext.isArray(el)){ |
30 | insertEl = me; |
31 | Ext.each(el, function(e) { |
32 | rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom); |
33 | if(isAfter){ |
34 | insertEl = rt; |
35 | } |
36 | }); |
37 | return rt; |
38 | } |
39 | |
40 | el = el || {}; |
41 | |
42 | if(el.nodeType || el.dom){ |
43 | rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom); |
44 | if (!returnDom) { |
45 | rt = GET(rt); |
46 | } |
47 | }else{ |
48 | if (isAfter && !me.dom.nextSibling) { |
49 | rt = DH.append(me.dom.parentNode, el, !returnDom); |
50 | } else { |
51 | rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom); |
52 | } |
53 | } |
54 | return rt; |
55 | } |
56 | }; |
57 | }()); |
Note: See TracBrowser
for help on using the repository browser.