3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.LoadMask"></div>/**
16 * A simple utility class for generically masking elements while loading data. If the {@link #store}
17 * config option is specified, the masking will be automatically synchronized with the store's loading
18 * process and the mask element will be cached for reuse. For all other elements, this mask will replace the
19 * element's Updater load indicator and will be destroyed after the initial load.
20 * <p>Example usage:</p>
23 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
27 * Create a new LoadMask
28 * @param {Mixed} el The element or DOM node, or its id
29 * @param {Object} config The config object
31 Ext.LoadMask = function(el, config){
32 this.el = Ext.get(el);
33 Ext.apply(this, config);
35 this.store.on('beforeload', this.onBeforeLoad, this);
36 this.store.on('load', this.onLoad, this);
37 this.store.on('exception', this.onLoad, this);
38 this.removeMask = Ext.value(this.removeMask, false);
40 var um = this.el.getUpdater();
41 um.showLoadIndicator = false; // disable the default indicator
42 um.on('beforeupdate', this.onBeforeLoad, this);
43 um.on('update', this.onLoad, this);
44 um.on('failure', this.onLoad, this);
45 this.removeMask = Ext.value(this.removeMask, true);
49 Ext.LoadMask.prototype = {
50 <div id="cfg-Ext.LoadMask-store"></div>/**
51 * @cfg {Ext.data.Store} store
52 * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
53 * hidden on either load sucess, or load fail.
55 <div id="cfg-Ext.LoadMask-removeMask"></div>/**
56 * @cfg {Boolean} removeMask
57 * True to create a single-use mask that is automatically destroyed after loading (useful for page loads),
58 * False to persist the mask element reference for multiple uses (e.g., for paged data widgets). Defaults to false.
60 <div id="cfg-Ext.LoadMask-msg"></div>/**
62 * The text to display in a centered loading message box (defaults to 'Loading...')
65 <div id="cfg-Ext.LoadMask-msgCls"></div>/**
66 * @cfg {String} msgCls
67 * The CSS class to apply to the loading message element (defaults to "x-mask-loading")
69 msgCls : 'x-mask-loading',
71 <div id="prop-Ext.LoadMask-disabled"></div>/**
72 * Read-only. True if the mask is currently disabled so that it will not be displayed (defaults to false)
77 <div id="method-Ext.LoadMask-disable"></div>/**
78 * Disables the mask to prevent it from being displayed
84 <div id="method-Ext.LoadMask-enable"></div>/**
85 * Enables the mask so that it can be displayed
88 this.disabled = false;
93 this.el.unmask(this.removeMask);
97 onBeforeLoad : function(){
99 this.el.mask(this.msg, this.msgCls);
103 <div id="method-Ext.LoadMask-show"></div>/**
104 * Show this LoadMask over the configured Element.
110 <div id="method-Ext.LoadMask-hide"></div>/**
111 * Hide this LoadMask.
118 destroy : function(){
120 this.store.un('beforeload', this.onBeforeLoad, this);
121 this.store.un('load', this.onLoad, this);
122 this.store.un('exception', this.onLoad, this);
124 var um = this.el.getUpdater();
125 um.un('beforeupdate', this.onBeforeLoad, this);
126 um.un('update', this.onLoad, this);
127 um.un('failure', this.onLoad, this);