/hippo/src/main/webapp/ext/src/core/Element.insertion-more.js

http://hdbc.googlecode.com/ · JavaScript · 52 lines · 32 code · 4 blank · 16 comment · 12 complexity · 2a31586315765ed59fe060d75c40b80e MD5 · raw file

  1. /*!
  2. * Ext JS Library 3.0.0
  3. * Copyright(c) 2006-2009 Ext JS, LLC
  4. * licensing@extjs.com
  5. * http://www.extjs.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. return {
  15. /**
  16. * Inserts (or creates) the passed element (or DomHelper config) as a sibling of this element
  17. * @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.
  18. * @param {String} where (optional) 'before' or 'after' defaults to before
  19. * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
  20. * @return {Ext.Element} the inserted Element
  21. */
  22. insertSibling: function(el, where, returnDom){
  23. var me = this,
  24. rt;
  25. if(Ext.isArray(el)){
  26. Ext.each(el, function(e) {
  27. rt = me.insertSibling(e, where, returnDom);
  28. });
  29. return rt;
  30. }
  31. where = (where || 'before').toLowerCase();
  32. el = el || {};
  33. if(el.nodeType || el.dom){
  34. rt = me.dom.parentNode.insertBefore(GETDOM(el), where == 'before' ? me.dom : me.dom.nextSibling);
  35. if (!returnDom) {
  36. rt = GET(rt);
  37. }
  38. }else{
  39. if (where == 'after' && !me.dom.nextSibling) {
  40. rt = DH.append(me.dom.parentNode, el, !returnDom);
  41. } else {
  42. rt = DH[where == 'after' ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
  43. }
  44. }
  45. return rt;
  46. }
  47. };
  48. }());