1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-LoadMask-method-constructor'><span id='Ext-LoadMask'>/**
2 </span></span> * @class Ext.LoadMask
3 * A simple utility class for generically masking elements while loading data. If the {@link #store}
4 * config option is specified, the masking will be automatically synchronized with the store's loading
5 * process and the mask element will be cached for reuse.
6 * <p>Example usage:</p>
7 * <pre><code>
9 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
11 </code></pre>
14 * Create a new LoadMask
15 * @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.
16 * @param {Object} config The config object
19 Ext.define('Ext.LoadMask', {
21 /* Begin Definitions */
24 observable: 'Ext.util.Observable'
27 requires: ['Ext.data.StoreManager'],
31 <span id='Ext-LoadMask-cfg-store'> /**
32 </span> * @cfg {Ext.data.Store} store
33 * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
34 * hidden on either load success, or load fail.
37 <span id='Ext-LoadMask-cfg-msg'> /**
38 </span> * @cfg {String} msg
39 * The text to display in a centered loading message box (defaults to 'Loading...')
42 <span id='Ext-LoadMask-cfg-msgCls'> /**
43 </span> * @cfg {String} msgCls
44 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
46 msgCls : Ext.baseCSSPrefix + 'mask-loading',
48 <span id='Ext-LoadMask-cfg-useMsg'> /**
49 </span> * @cfg {Boolean} useMsg
50 * Whether or not to use a loading message class or simply mask the bound element.
54 <span id='Ext-LoadMask-property-disabled'> /**
55 </span> * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
60 constructor : function(el, config) {
68 Ext.apply(me, config);
70 me.addEvents('beforeshow', 'show', 'hide');
72 me.bindStore(me.store, true);
74 me.mixins.observable.constructor.call(me, config);
77 bindComponent: function(comp) {
80 resize: me.onComponentResize,
85 me.onComponentRender(comp);
88 fn: me.onComponentRender,
93 me.mon(comp, listeners);
96 <span id='Ext-LoadMask-method-onComponentRender'> /**
98 * Called if we were configured with a Component, and that Component was not yet rendered. Collects the element to mask.
100 onComponentRender: function(comp) {
101 this.el = comp.getContentTarget();
104 <span id='Ext-LoadMask-method-onComponentResize'> /**
106 * Called when this LoadMask's Component is resized. The isMasked method also re-centers any displayed message.
108 onComponentResize: function(comp, w, h) {
112 <span id='Ext-LoadMask-method-bindStore'> /**
113 </span> * Changes the data store bound to this LoadMask.
114 * @param {Store} store The store to bind to this LoadMask
116 bindStore : function(store, initial) {
119 if (!initial && me.store) {
122 beforeload: me.onBeforeLoad,
131 store = Ext.data.StoreManager.lookup(store);
134 beforeload: me.onBeforeLoad,
141 if (store && store.isLoading()) {
146 <span id='Ext-LoadMask-method-disable'> /**
147 </span> * Disables the mask to prevent it from being displayed
149 disable : function() {
158 <span id='Ext-LoadMask-method-enable'> /**
159 </span> * Enables the mask so that it can be displayed
161 enable : function() {
162 this.disabled = false;
165 <span id='Ext-LoadMask-method-isDisabled'> /**
166 </span> * Method to determine whether this LoadMask is currently disabled.
167 * @return {Boolean} the disabled state of this LoadMask.
169 isDisabled : function() {
170 return this.disabled;
174 onLoad : function() {
179 me.fireEvent('hide', me, me.el, me.store);
183 onBeforeLoad : function() {
186 if (!me.disabled && !me.loading && me.fireEvent('beforeshow', me, me.el, me.store) !== false) {
188 me.el.mask(me.msg, me.msgCls, false);
193 me.fireEvent('show', me, me.el, me.store);
198 <span id='Ext-LoadMask-method-show'> /**
199 </span> * Show this LoadMask over the configured Element.
205 <span id='Ext-LoadMask-method-hide'> /**
206 </span> * Hide this LoadMask.
213 destroy : function() {
215 this.clearListeners();
218 </pre></pre></body></html>