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-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.
23 * <p>Example usage:</p>
24 * <pre><code>
26 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
28 </code></pre>
31 * Create a new LoadMask
32 * @param {Mixed} el The element, element ID, or DOM node you wish to mask. Also, may be a Component who's element you wish to mask.
33 * @param {Object} config The config object
36 Ext.define('Ext.LoadMask', {
38 /* Begin Definitions */
41 observable: 'Ext.util.Observable'
44 requires: ['Ext.data.StoreManager'],
48 <span id='Ext-LoadMask-cfg-store'> /**
49 </span> * @cfg {Ext.data.Store} store
50 * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
51 * hidden on either load success, or load fail.
54 <span id='Ext-LoadMask-cfg-msg'> /**
55 </span> * @cfg {String} msg
56 * The text to display in a centered loading message box (defaults to 'Loading...')
59 <span id='Ext-LoadMask-cfg-msgCls'> /**
60 </span> * @cfg {String} msgCls
61 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
63 msgCls : Ext.baseCSSPrefix + 'mask-loading',
65 <span id='Ext-LoadMask-cfg-useMsg'> /**
66 </span> * @cfg {Boolean} useMsg
67 * Whether or not to use a loading message class or simply mask the bound element.
71 <span id='Ext-LoadMask-property-disabled'> /**
72 </span> * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
77 constructor : function(el, config) {
85 Ext.apply(me, config);
87 me.addEvents('beforeshow', 'show', 'hide');
89 me.bindStore(me.store, true);
91 me.mixins.observable.constructor.call(me, config);
94 bindComponent: function(comp) {
97 resize: me.onComponentResize,
102 me.onComponentRender(comp);
105 fn: me.onComponentRender,
110 me.mon(comp, listeners);
113 <span id='Ext-LoadMask-method-onComponentRender'> /**
115 * Called if we were configured with a Component, and that Component was not yet rendered. Collects the element to mask.
117 onComponentRender: function(comp) {
118 this.el = comp.getContentTarget();
121 <span id='Ext-LoadMask-method-onComponentResize'> /**
123 * Called when this LoadMask's Component is resized. The isMasked method also re-centers any displayed message.
125 onComponentResize: function(comp, w, h) {
129 <span id='Ext-LoadMask-method-bindStore'> /**
130 </span> * Changes the data store bound to this LoadMask.
131 * @param {Store} store The store to bind to this LoadMask
133 bindStore : function(store, initial) {
136 if (!initial && me.store) {
139 beforeload: me.onBeforeLoad,
148 store = Ext.data.StoreManager.lookup(store);
151 beforeload: me.onBeforeLoad,
158 if (store && store.isLoading()) {
163 <span id='Ext-LoadMask-method-disable'> /**
164 </span> * Disables the mask to prevent it from being displayed
166 disable : function() {
175 <span id='Ext-LoadMask-method-enable'> /**
176 </span> * Enables the mask so that it can be displayed
178 enable : function() {
179 this.disabled = false;
182 <span id='Ext-LoadMask-method-isDisabled'> /**
183 </span> * Method to determine whether this LoadMask is currently disabled.
184 * @return {Boolean} the disabled state of this LoadMask.
186 isDisabled : function() {
187 return this.disabled;
191 onLoad : function() {
196 me.fireEvent('hide', me, me.el, me.store);
200 onBeforeLoad : function() {
203 if (!me.disabled && !me.loading && me.fireEvent('beforeshow', me, me.el, me.store) !== false) {
205 me.el.mask(me.msg, me.msgCls, false);
210 me.fireEvent('show', me, me.el, me.store);
215 <span id='Ext-LoadMask-method-show'> /**
216 </span> * Show this LoadMask over the configured Element.
222 <span id='Ext-LoadMask-method-hide'> /**
223 </span> * Hide this LoadMask.
230 destroy : function() {
232 this.clearListeners();