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.

142 lines
4.7 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-LoadMask-method-constructor'><span id='Ext-LoadMask'>/**
  19. </span></span> * @class Ext.LoadMask
  20. * A simple utility class for generically masking elements while loading data. If the {@link #store}
  21. * config option is specified, the masking will be automatically synchronized with the store's loading
  22. * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
  23. * element's Updater load indicator and will be destroyed after the initial load.
  24. * &lt;p&gt;Example usage:&lt;/p&gt;
  25. *&lt;pre&gt;&lt;code&gt;
  26. // Basic mask:
  27. var myMask = new Ext.LoadMask(Ext.getBody(), {msg:&quot;Please wait...&quot;});
  28. myMask.show();
  29. &lt;/code&gt;&lt;/pre&gt;
  30. * @constructor
  31. * Create a new LoadMask
  32. * @param {Mixed} el The element or DOM node, or its id
  33. * @param {Object} config The config object
  34. */
  35. Ext.LoadMask = function(el, config){
  36. this.el = Ext.get(el);
  37. Ext.apply(this, config);
  38. if(this.store){
  39. this.store.on({
  40. scope: this,
  41. beforeload: this.onBeforeLoad,
  42. load: this.onLoad,
  43. exception: this.onLoad
  44. });
  45. this.removeMask = Ext.value(this.removeMask, false);
  46. }else{
  47. var um = this.el.getUpdater();
  48. um.showLoadIndicator = false; // disable the default indicator
  49. um.on({
  50. scope: this,
  51. beforeupdate: this.onBeforeLoad,
  52. update: this.onLoad,
  53. failure: this.onLoad
  54. });
  55. this.removeMask = Ext.value(this.removeMask, true);
  56. }
  57. };
  58. Ext.LoadMask.prototype = {
  59. <span id='Ext-LoadMask-cfg-store'> /**
  60. </span> * @cfg {Ext.data.Store} store
  61. * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
  62. * hidden on either load sucess, or load fail.
  63. */
  64. <span id='Ext-LoadMask-cfg-removeMask'> /**
  65. </span> * @cfg {Boolean} removeMask
  66. * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
  67. * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
  68. */
  69. <span id='Ext-LoadMask-cfg-msg'> /**
  70. </span> * @cfg {String} msg
  71. * The text to display in a centered loading message box (defaults to 'Loading...')
  72. */
  73. msg : 'Loading...',
  74. <span id='Ext-LoadMask-cfg-msgCls'> /**
  75. </span> * @cfg {String} msgCls
  76. * The CSS class to apply to the loading message element (defaults to &quot;x-mask-loading&quot;)
  77. */
  78. msgCls : 'x-mask-loading',
  79. <span id='Ext-LoadMask-property-disabled'> /**
  80. </span> * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
  81. * @type Boolean
  82. */
  83. disabled: false,
  84. <span id='Ext-LoadMask-method-disable'> /**
  85. </span> * Disables the mask to prevent it from being displayed
  86. */
  87. disable : function(){
  88. this.disabled = true;
  89. },
  90. <span id='Ext-LoadMask-method-enable'> /**
  91. </span> * Enables the mask so that it can be displayed
  92. */
  93. enable : function(){
  94. this.disabled = false;
  95. },
  96. // private
  97. onLoad : function(){
  98. this.el.unmask(this.removeMask);
  99. },
  100. // private
  101. onBeforeLoad : function(){
  102. if(!this.disabled){
  103. this.el.mask(this.msg, this.msgCls);
  104. }
  105. },
  106. <span id='Ext-LoadMask-method-show'> /**
  107. </span> * Show this LoadMask over the configured Element.
  108. */
  109. show: function(){
  110. this.onBeforeLoad();
  111. },
  112. <span id='Ext-LoadMask-method-hide'> /**
  113. </span> * Hide this LoadMask.
  114. */
  115. hide: function(){
  116. this.onLoad();
  117. },
  118. // private
  119. destroy : function(){
  120. if(this.store){
  121. this.store.un('beforeload', this.onBeforeLoad, this);
  122. this.store.un('load', this.onLoad, this);
  123. this.store.un('exception', this.onLoad, this);
  124. }else{
  125. var um = this.el.getUpdater();
  126. um.un('beforeupdate', this.onBeforeLoad, this);
  127. um.un('update', this.onLoad, this);
  128. um.un('failure', this.onLoad, this);
  129. }
  130. }
  131. };</pre>
  132. </body>
  133. </html>