3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js"><div id="cls-Ext.LoadMask"></div>/**
10 * A simple utility class for generically masking elements while loading data. If the {@link #store}
11 * config option is specified, the masking will be automatically synchronized with the store's loading
12 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
13 * element's Updater load indicator and will be destroyed after the initial load.
14 * <p>Example usage:</p>
17 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
21 * Create a new LoadMask
22 * @param {Mixed} el The element or DOM node, or its id
23 * @param {Object} config The config object
25 Ext.LoadMask = function(el, config){
26 this.el = Ext.get(el);
27 Ext.apply(this, config);
29 this.store.on('beforeload', this.onBeforeLoad, this);
30 this.store.on('load', this.onLoad, this);
31 this.store.on('exception', this.onLoad, this);
32 this.removeMask = Ext.value(this.removeMask, false);
34 var um = this.el.getUpdater();
35 um.showLoadIndicator = false; // disable the default indicator
36 um.on('beforeupdate', this.onBeforeLoad, this);
37 um.on('update', this.onLoad, this);
38 um.on('failure', this.onLoad, this);
39 this.removeMask = Ext.value(this.removeMask, true);
43 Ext.LoadMask.prototype = {
44 <div id="cfg-Ext.LoadMask-store"></div>/**
45 * @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 sucess, or load fail.
49 <div id="cfg-Ext.LoadMask-removeMask"></div>/**
50 * @cfg {Boolean} removeMask
51 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
52 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
54 <div id="cfg-Ext.LoadMask-msg"></div>/**
56 * The text to display in a centered loading message box (defaults to 'Loading...')
59 <div id="cfg-Ext.LoadMask-msgCls"></div>/**
60 * @cfg {String} msgCls
61 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
63 msgCls : 'x-mask-loading',
65 <div id="prop-Ext.LoadMask-disabled"></div>/**
66 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
71 <div id="method-Ext.LoadMask-disable"></div>/**
72 * Disables the mask to prevent it from being displayed
78 <div id="method-Ext.LoadMask-enable"></div>/**
79 * Enables the mask so that it can be displayed
82 this.disabled = false;
87 this.el.unmask(this.removeMask);
91 onBeforeLoad : function(){
93 this.el.mask(this.msg, this.msgCls);
97 <div id="method-Ext.LoadMask-show"></div>/**
98 * Show this LoadMask over the configured Element.
104 <div id="method-Ext.LoadMask-hide"></div>/**
105 * Hide this LoadMask.
112 destroy : function(){
114 this.store.un('beforeload', this.onBeforeLoad, this);
115 this.store.un('load', this.onLoad, this);
116 this.store.un('exception', this.onLoad, this);
118 var um = this.el.getUpdater();
119 um.un('beforeupdate', this.onBeforeLoad, this);
120 um.un('update', this.onLoad, this);
121 um.un('failure', this.onLoad, this);