2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 * @class Ext.LoadMask
\r
11 * A simple utility class for generically masking elements while loading data. If the {@link #store}
\r
12 * config option is specified, the masking will be automatically synchronized with the store's loading
\r
13 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
\r
14 * element's Updater load indicator and will be destroyed after the initial load.
\r
15 * <p>Example usage:</p>
\r
18 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
\r
22 * Create a new LoadMask
\r
23 * @param {Mixed} el The element or DOM node, or its id
\r
24 * @param {Object} config The config object
\r
26 Ext.LoadMask = function(el, config){
\r
27 this.el = Ext.get(el);
\r
28 Ext.apply(this, config);
\r
30 this.store.on('beforeload', this.onBeforeLoad, this);
\r
31 this.store.on('load', this.onLoad, this);
\r
32 this.store.on('loadexception', this.onLoad, this);
\r
33 this.removeMask = Ext.value(this.removeMask, false);
\r
35 var um = this.el.getUpdater();
\r
36 um.showLoadIndicator = false; // disable the default indicator
\r
37 um.on('beforeupdate', this.onBeforeLoad, this);
\r
38 um.on('update', this.onLoad, this);
\r
39 um.on('failure', this.onLoad, this);
\r
40 this.removeMask = Ext.value(this.removeMask, true);
\r
44 Ext.LoadMask.prototype = {
\r
46 * @cfg {Ext.data.Store} store
\r
47 * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
\r
48 * hidden on either load sucess, or load fail.
\r
51 * @cfg {Boolean} removeMask
\r
52 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
\r
53 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
\r
57 * The text to display in a centered loading message box (defaults to 'Loading...')
\r
61 * @cfg {String} msgCls
\r
62 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
\r
64 msgCls : 'x-mask-loading',
\r
67 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
\r
73 * Disables the mask to prevent it from being displayed
\r
75 disable : function(){
\r
76 this.disabled = true;
\r
80 * Enables the mask so that it can be displayed
\r
82 enable : function(){
\r
83 this.disabled = false;
\r
87 onLoad : function(){
\r
88 this.el.unmask(this.removeMask);
\r
92 onBeforeLoad : function(){
\r
94 this.el.mask(this.msg, this.msgCls);
\r
99 * Show this LoadMask over the configured Element.
\r
102 this.onBeforeLoad();
\r
106 * Hide this LoadMask.
\r
113 destroy : function(){
\r
115 this.store.un('beforeload', this.onBeforeLoad, this);
\r
116 this.store.un('load', this.onLoad, this);
\r
117 this.store.un('loadexception', this.onLoad, this);
\r
119 var um = this.el.getUpdater();
\r
120 um.un('beforeupdate', this.onBeforeLoad, this);
\r
121 um.un('update', this.onLoad, this);
\r
122 um.un('failure', this.onLoad, this);
\r