You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.6 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-Element'>/**
  19. </span> * @class Ext.Element
  20. */
  21. Ext.apply(Ext.Element.prototype, function() {
  22. var GETDOM = Ext.getDom,
  23. GET = Ext.get,
  24. DH = Ext.DomHelper;
  25. return {
  26. <span id='Ext-Element-method-insertSibling'> /**
  27. </span> * Inserts (or creates) the passed element (or DomHelper config) as a sibling of this element
  28. * @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.
  29. * @param {String} where (optional) 'before' or 'after' defaults to before
  30. * @param {Boolean} returnDom (optional) True to return the raw DOM element instead of Ext.Element
  31. * @return {Ext.Element} The inserted Element. If an array is passed, the last inserted element is returned.
  32. */
  33. insertSibling: function(el, where, returnDom){
  34. var me = this,
  35. rt,
  36. isAfter = (where || 'before').toLowerCase() == 'after',
  37. insertEl;
  38. if(Ext.isArray(el)){
  39. insertEl = me;
  40. Ext.each(el, function(e) {
  41. rt = Ext.fly(insertEl, '_internal').insertSibling(e, where, returnDom);
  42. if(isAfter){
  43. insertEl = rt;
  44. }
  45. });
  46. return rt;
  47. }
  48. el = el || {};
  49. if(el.nodeType || el.dom){
  50. rt = me.dom.parentNode.insertBefore(GETDOM(el), isAfter ? me.dom.nextSibling : me.dom);
  51. if (!returnDom) {
  52. rt = GET(rt);
  53. }
  54. }else{
  55. if (isAfter &amp;&amp; !me.dom.nextSibling) {
  56. rt = DH.append(me.dom.parentNode, el, !returnDom);
  57. } else {
  58. rt = DH[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
  59. }
  60. }
  61. return rt;
  62. }
  63. };
  64. }());</pre>
  65. </body>
  66. </html>