Web UI for ARGUS server
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.

123 lines
4.0 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>The source code</title>
  5. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  6. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  7. </head>
  8. <body onload="prettyPrint();">
  9. <pre class="prettyprint lang-js">/*!
  10. * Ext JS Library 3.3.1
  11. * Copyright(c) 2006-2010 Sencha Inc.
  12. * licensing@sencha.com
  13. * http://www.sencha.com/license
  14. */
  15. <div id="cls-Ext.tree.AsyncTreeNode"></div>/**
  16. * @class Ext.tree.AsyncTreeNode
  17. * @extends Ext.tree.TreeNode
  18. * @cfg {TreeLoader} loader A TreeLoader to be used by this node (defaults to the loader defined on the tree)
  19. * @constructor
  20. * @param {Object/String} attributes The attributes/config for the node or just a string with the text for the node
  21. */
  22. Ext.tree.AsyncTreeNode = function(config){
  23. this.loaded = config && config.loaded === true;
  24. this.loading = false;
  25. Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
  26. /**
  27. * @event beforeload
  28. * Fires before this node is loaded, return false to cancel
  29. * @param {Node} this This node
  30. */
  31. this.addEvents('beforeload', 'load');
  32. /**
  33. * @event load
  34. * Fires when this node is loaded
  35. * @param {Node} this This node
  36. */
  37. /**
  38. * The loader used by this node (defaults to using the tree's defined loader)
  39. * @type TreeLoader
  40. * @property loader
  41. */
  42. };
  43. Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
  44. expand : function(deep, anim, callback, scope){
  45. if(this.loading){ // if an async load is already running, waiting til it's done
  46. var timer;
  47. var f = function(){
  48. if(!this.loading){ // done loading
  49. clearInterval(timer);
  50. this.expand(deep, anim, callback, scope);
  51. }
  52. }.createDelegate(this);
  53. timer = setInterval(f, 200);
  54. return;
  55. }
  56. if(!this.loaded){
  57. if(this.fireEvent("beforeload", this) === false){
  58. return;
  59. }
  60. this.loading = true;
  61. this.ui.beforeLoad(this);
  62. var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
  63. if(loader){
  64. loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback, scope]), this);
  65. return;
  66. }
  67. }
  68. Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback, scope);
  69. },
  70. /**
  71. * Returns true if this node is currently loading
  72. * @return {Boolean}
  73. */
  74. isLoading : function(){
  75. return this.loading;
  76. },
  77. loadComplete : function(deep, anim, callback, scope){
  78. this.loading = false;
  79. this.loaded = true;
  80. this.ui.afterLoad(this);
  81. this.fireEvent("load", this);
  82. this.expand(deep, anim, callback, scope);
  83. },
  84. /**
  85. * Returns true if this node has been loaded
  86. * @return {Boolean}
  87. */
  88. isLoaded : function(){
  89. return this.loaded;
  90. },
  91. hasChildNodes : function(){
  92. if(!this.isLeaf() && !this.loaded){
  93. return true;
  94. }else{
  95. return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
  96. }
  97. },
  98. /**
  99. * Trigger a reload for this node
  100. * @param {Function} callback
  101. * @param {Object} scope (optional) The scope (<code>this</code> reference) in which the callback is executed. Defaults to this Node.
  102. */
  103. reload : function(callback, scope){
  104. this.collapse(false, false);
  105. while(this.firstChild){
  106. this.removeChild(this.firstChild).destroy();
  107. }
  108. this.childrenRendered = false;
  109. this.loaded = false;
  110. if(this.isHiddenRoot()){
  111. this.expanded = false;
  112. }
  113. this.expand(false, false, callback, scope);
  114. }
  115. });
  116. Ext.tree.TreePanel.nodeTypes.async = Ext.tree.AsyncTreeNode;</pre>
  117. </body>
  118. </html>