4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/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'>/**
19 </span> * @class Ext.LoadMask
20 * <p>A modal, floating Component which may be shown above a specified {@link Ext.core.Element Element}, or a specified
21 * {@link Ext.Component Component} while loading data. When shown, the configured owning Element or Component will
22 * be covered with a modality mask, and the LoadMask's {@link #msg} will be displayed centered, accompanied by a spinner image.</p>
23 * <p>If the {@link #store} config option is specified, the masking will be automatically shown and then hidden synchronized with
24 * the Store's loading process.</p>
25 * <p>Because this is a floating Component, its z-index will be managed by the global {@link Ext.WindowManager ZIndexManager}
26 * object, and upon show, it will place itsef at the top of the hierarchy.</p>
27 * <p>Example usage:</p>
28 * <pre><code>
30 var myMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});
32 </code></pre>
36 Ext.define('Ext.LoadMask', {
38 extend: 'Ext.Component',
40 alias: 'widget.loadmask',
42 /* Begin Definitions */
45 floating: 'Ext.util.Floating'
48 uses: ['Ext.data.StoreManager'],
52 <span id='Ext-LoadMask-cfg-store'> /**
53 </span> * @cfg {Ext.data.Store} store
54 * Optional Store to which the mask is bound. The mask is displayed when a load request is issued, and
55 * hidden on either load success, or load fail.
58 <span id='Ext-LoadMask-cfg-msg'> /**
59 </span> * @cfg {String} msg
60 * The text to display in a centered loading message box.
63 <span id='Ext-LoadMask-cfg-msgCls'> /**
64 </span> * @cfg {String} [msgCls="x-mask-loading"]
65 * The CSS class to apply to the loading message element.
67 msgCls : Ext.baseCSSPrefix + 'mask-loading',
69 <span id='Ext-LoadMask-cfg-useMsg'> /**
70 </span> * @cfg {Boolean} useMsg
71 * Whether or not to use a loading message class or simply mask the bound element.
75 <span id='Ext-LoadMask-property-disabled'> /**
76 </span> * Read-only. True if the mask is currently disabled so that it will not be displayed
81 baseCls: Ext.baseCSSPrefix + 'mask-msg',
83 renderTpl: '<div style="position:relative" class="{msgCls}"></div>',
85 // Private. The whole point is that there's a mask.
88 // Private. Obviously, it's floating.
93 // Private. Masks are not focusable
94 focusOnToFront: false,
96 <span id='Ext-LoadMask-method-constructor'> /**
97 </span> * Creates new LoadMask.
98 * @param {String/HTMLElement/Ext.Element} el The element, element ID, or DOM node you wish to mask.
99 * <p>Also, may be a {@link Ext.Component Component} who's element you wish to mask. If a Component is specified, then
100 * the mask will be automatically sized upon Component resize, the message box will be kept centered,
101 * and the mask only be visible when the Component is.</p>
102 * @param {Object} [config] The config object
104 constructor : function(el, config) {
107 // If a Component passed, bind to it.
108 if (el.isComponent) {
110 me.bindComponent(el);
112 // Create a dumy Component encapsulating the specified Element
114 me.ownerCt = new Ext.Component({
117 componentLayoutCounter: 1
121 me.callParent([config]);
124 me.bindStore(me.store, true);
129 me.renderSelectors = {
134 bindComponent: function(comp) {
136 resize: this.onComponentResize,
141 afterRender: function() {
142 this.callParent(arguments);
143 this.container = this.floatParent.getContentTarget();
146 <span id='Ext-LoadMask-method-onComponentResize'> /**
148 * Called when this LoadMask's Component is resized. The toFront method rebases and resizes the modal mask.
150 onComponentResize: function() {
152 if (me.rendered && me.isVisible()) {
158 <span id='Ext-LoadMask-method-bindStore'> /**
159 </span> * Changes the data store bound to this LoadMask.
160 * @param {Ext.data.Store} store The store to bind to this LoadMask
162 bindStore : function(store, initial) {
165 if (!initial && me.store) {
168 beforeload: me.onBeforeLoad,
177 store = Ext.data.StoreManager.lookup(store);
180 beforeload: me.onBeforeLoad,
187 if (store && store.isLoading()) {
192 onDisable : function() {
193 this.callParent(arguments);
200 onBeforeLoad : function() {
202 owner = me.ownerCt || me.floatParent,
204 if (!this.disabled) {
205 // If the owning Component has not been layed out, defer so that the ZIndexManager
206 // gets to read its layed out size when sizing the modal mask
207 if (owner.componentLayoutCounter) {
208 Ext.Component.prototype.show.call(me);
210 // The code below is a 'run-once' interceptor.
211 origin = owner.afterComponentLayout;
212 owner.afterComponentLayout = function() {
213 owner.afterComponentLayout = origin;
214 origin.apply(owner, arguments);
216 Ext.Component.prototype.show.call(me);
225 me.callParent(arguments);
226 me.showOnParentShow = true;
233 me.callParent(arguments);
236 msgEl.show().update(me.msg);
238 msgEl.parent().hide();
242 afterShow: function() {
243 this.callParent(arguments);
248 onLoad : function() {
249 this.loading = false;
250 Ext.Component.prototype.hide.call(this);