4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-LoadMask'>/**
19 </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.
23 * <p>Example usage:</p>
24 * <pre><code>
26 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
28 </code></pre>
32 Ext.define('Ext.LoadMask', {
34 /* Begin Definitions */
37 observable: 'Ext.util.Observable'
40 requires: ['Ext.data.StoreManager'],
44 <span id='Ext-LoadMask-cfg-store'> /**
45 </span> * @cfg {Ext.data.Store} store
46 * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
47 * hidden on either load success, or load fail.
50 <span id='Ext-LoadMask-cfg-msg'> /**
51 </span> * @cfg {String} msg
52 * The text to display in a centered loading message box (defaults to 'Loading...')
55 <span id='Ext-LoadMask-cfg-msgCls'> /**
56 </span> * @cfg {String} msgCls
57 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
59 msgCls : Ext.baseCSSPrefix + 'mask-loading',
61 <span id='Ext-LoadMask-cfg-useMsg'> /**
62 </span> * @cfg {Boolean} useMsg
63 * Whether or not to use a loading message class or simply mask the bound element.
67 <span id='Ext-LoadMask-property-disabled'> /**
68 </span> * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
73 <span id='Ext-LoadMask-method-constructor'> /**
74 </span> * Creates new LoadMask.
75 * @param {Mixed} el The element, element ID, or DOM node you wish to mask.
76 * Also, may be a Component who's element you wish to mask.
77 * @param {Object} config (optional) The config object
79 constructor : function(el, config) {
87 Ext.apply(me, config);
89 me.addEvents('beforeshow', 'show', 'hide');
91 me.bindStore(me.store, true);
93 me.mixins.observable.constructor.call(me, config);
96 bindComponent: function(comp) {
99 resize: me.onComponentResize,
104 me.onComponentRender(comp);
107 fn: me.onComponentRender,
112 me.mon(comp, listeners);
115 <span id='Ext-LoadMask-method-onComponentRender'> /**
117 * Called if we were configured with a Component, and that Component was not yet rendered. Collects the element to mask.
119 onComponentRender: function(comp) {
120 this.el = comp.getContentTarget();
123 <span id='Ext-LoadMask-method-onComponentResize'> /**
125 * Called when this LoadMask's Component is resized. The isMasked method also re-centers any displayed message.
127 onComponentResize: function(comp, w, h) {
131 <span id='Ext-LoadMask-method-bindStore'> /**
132 </span> * Changes the data store bound to this LoadMask.
133 * @param {Store} store The store to bind to this LoadMask
135 bindStore : function(store, initial) {
138 if (!initial && me.store) {
141 beforeload: me.onBeforeLoad,
150 store = Ext.data.StoreManager.lookup(store);
153 beforeload: me.onBeforeLoad,
160 if (store && store.isLoading()) {
165 <span id='Ext-LoadMask-method-disable'> /**
166 </span> * Disables the mask to prevent it from being displayed
168 disable : function() {
177 <span id='Ext-LoadMask-method-enable'> /**
178 </span> * Enables the mask so that it can be displayed
180 enable : function() {
181 this.disabled = false;
184 <span id='Ext-LoadMask-method-isDisabled'> /**
185 </span> * Method to determine whether this LoadMask is currently disabled.
186 * @return {Boolean} the disabled state of this LoadMask.
188 isDisabled : function() {
189 return this.disabled;
193 onLoad : function() {
198 me.fireEvent('hide', me, me.el, me.store);
202 onBeforeLoad : function() {
205 if (!me.disabled && !me.loading && me.fireEvent('beforeshow', me, me.el, me.store) !== false) {
207 me.el.mask(me.msg, me.msgCls, false);
212 me.fireEvent('show', me, me.el, me.store);
217 <span id='Ext-LoadMask-method-show'> /**
218 </span> * Show this LoadMask over the configured Element.
224 <span id='Ext-LoadMask-method-hide'> /**
225 </span> * Hide this LoadMask.
232 destroy : function() {
234 this.clearListeners();