Skip to content

Commit d175ad7

Browse files
authored
Addendum to #2426 - Adminhtml loader (#2475)
1 parent 269f0f9 commit d175ad7

File tree

8 files changed

+56
-62
lines changed

8 files changed

+56
-62
lines changed

app/design/adminhtml/default/default/template/catalog/category/edit.phtml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,7 @@
183183

184184
function displayLoadingMask()
185185
{
186-
var loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page
187-
Position.clone($(loaderArea), $('loading-mask'), {offsetLeft:-2});
188-
toggleSelectsUnderBlock($('loading-mask'), false);
189-
Element.show('loading-mask');
186+
showLoader();
190187
}
191188
//]]>
192189
</script>

app/design/adminhtml/default/default/template/importexport/import/form/before.phtml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,14 @@
4343
});
4444
}
4545

46-
// show mask, temporary set new target and submit form
47-
var loadingMask = $('loading-mask');
46+
// show mask
47+
showLoader();
48+
49+
// temporary set new target and submit form
4850
var formElem = $(this.formId);
4951
var oldTarget = formElem.target;
5052
var oldAction = formElem.action;
5153

52-
Element.clonePosition(loadingMask, $$('#html-body .wrapper')[0], {offsetLeft:-2})
53-
toggleSelectsUnderBlock(loadingMask, false);
54-
loadingMask.show();
55-
setLoaderPosition();
5654
formElem.target = this.ifrElemName;
5755

5856
if (newActionUrl) {
@@ -74,10 +72,8 @@
7472
*/
7573
varienForm.prototype.postToFrameComplete = function(response)
7674
{
77-
var loadingMask = $('loading-mask');
7875
$(this.ifrElemName).remove();
79-
toggleSelectsUnderBlock(loadingMask, true);
80-
loadingMask.hide();
76+
hideLoader();
8177
this.postToFrameProcessResponse(response);
8278
};
8379

app/design/adminhtml/default/default/template/newsletter/preview/iframeswitcher.phtml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@
4343
<?php echo $this->getChildHtml('preview_form'); ?>
4444
</div>
4545
<div id="loading-mask" style="display:none">
46-
<p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('adminhtml')->__('Loading...')) ?>"/><br/><?php echo Mage::helper('adminhtml')->__('Please wait...') ?></p>
46+
<div class="backdrop"></div>
47+
<p class="loader" id="loading_mask_loader">
48+
<img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('adminhtml')->__('Loading...')) ?>"/><br/><?php echo Mage::helper('adminhtml')->__('Please wait...') ?>
49+
</p>
4750
</div>
4851

4952
<script type="text/javascript">
5053
//<![CDATA[
5154
var previewForm = $('preview_form');
52-
var loadingMask = $('loading-mask');
5355
var previewIframe = $('preview_iframe');
5456

5557
function preview() {
@@ -59,22 +61,11 @@ function preview() {
5961
}
6062

6163
function blockPreview() {
62-
var cumulativeOffset = $('preview').cumulativeOffset();
63-
$('loading-mask').setStyle({
64-
top: ( cumulativeOffset.top ) + 'px',
65-
left: ( cumulativeOffset.left ) + 'px',
66-
width: $('preview').getWidth() + 'px',
67-
height: $('preview').getHeight() + 'px'
68-
});
69-
70-
toggleSelectsUnderBlock($('loading-mask'), false);
71-
Element.show('loading-mask');
72-
setLoaderPosition();
64+
showLoader($('preview'));
7365
}
7466

7567
function unBlockPreview() {
76-
toggleSelectsUnderBlock(loadingMask, true);
77-
Element.hide(loadingMask);
68+
hideLoader();
7869
}
7970

8071
Event.observe(window, 'load', preview);

app/design/adminhtml/default/default/template/page.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@
7676
<?php echo $this->getChildHtml('js') ?>
7777
<?php echo $this->getChildHtml('profiler') ?>
7878
<div id="loading-mask" style="display:none">
79-
<div class="backdrop" style="display:none"></div>
80-
<p class="loader" id="loading_mask_loader" style="display:none">
79+
<div class="backdrop"></div>
80+
<p class="loader" id="loading_mask_loader">
8181
<img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('adminhtml')->__('Loading...')) ?>"/><br/><?php echo Mage::helper('adminhtml')->__('Please wait...') ?>
8282
</p>
8383
</div>

app/design/adminhtml/default/default/template/popup.phtml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
<?php echo $this->getChildHtml('js') ?>
6767
<?php echo $this->getChildHtml('profiler') ?>
6868
<div id="loading-mask" style="display:none;">
69-
<p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('adminhtml')->__('Loading...')) ?>" /><br /><?php echo Mage::helper('adminhtml')->__('Please wait...') ?></p>
69+
<div class="backdrop"></div>
70+
<p class="loader" id="loading_mask_loader">
71+
<img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('adminhtml')->__('Loading...')) ?>"/><br/><?php echo Mage::helper('adminhtml')->__('Please wait...') ?>
72+
</p>
7073
</div>
7174
</div>
7275
<?php echo $this->getChildHtml('before_body_end') ?>

js/mage/adminhtml/loader.js

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -187,37 +187,44 @@ varienLoaderHandler.handler = {
187187
if(request.options.loaderArea===false){
188188
return;
189189
}
190-
191-
request.options.loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page
192-
193-
if(request && request.options.loaderArea){
194-
Element.clonePosition($('loading-mask'), $(request.options.loaderArea), {offsetLeft:-2});
195-
toggleSelectsUnderBlock($('loading-mask'), false);
196-
Element.show('loading-mask');
197-
Element.childElements('loading-mask').invoke('hide');
198-
setLoaderPosition();
199-
if(this.timeout) {
200-
clearTimeout(this.timeout);
201-
}
202-
this.timeout = setTimeout(function() {
203-
Element.childElements('loading-mask').invoke('show');
204-
}, typeof window.LOADING_TIMEOUT === 'undefined' ? 200 : window.LOADING_TIMEOUT);
205-
}
190+
showLoader();
206191
},
207-
208192
onComplete: function(transport) {
209193
if(Ajax.activeRequestCount == 0) {
210-
toggleSelectsUnderBlock($('loading-mask'), true);
211-
Element.hide('loading-mask');
212-
Element.childElements('loading-mask').invoke('hide');
213-
if(this.timeout) {
214-
clearTimeout(this.timeout);
215-
this.timeout = null;
216-
}
194+
hideLoader();
217195
}
218196
}
219197
};
220198

199+
var loaderTimeout = null;
200+
201+
function showLoader(loaderArea) {
202+
if($(loaderArea) === undefined) {
203+
loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page
204+
}
205+
var loadingMask = $('loading-mask');
206+
if(Element.visible(loadingMask)) {
207+
return;
208+
}
209+
Element.clonePosition(loadingMask, loaderArea, {offsetLeft:-2});
210+
toggleSelectsUnderBlock(loadingMask, false);
211+
Element.show(loadingMask);
212+
Element.childElements(loadingMask).invoke('hide');
213+
setLoaderPosition();
214+
loaderTimeout = setTimeout(function() {
215+
Element.childElements(loadingMask).invoke('show');
216+
}, typeof window.LOADING_TIMEOUT === 'undefined' ? 200 : window.LOADING_TIMEOUT);
217+
}
218+
219+
function hideLoader() {
220+
toggleSelectsUnderBlock($('loading-mask'), true);
221+
Element.hide('loading-mask');
222+
if(loaderTimeout) {
223+
clearTimeout(loaderTimeout);
224+
loaderTimeout = null;
225+
}
226+
}
227+
221228
/**
222229
* @todo need calculate middle of visible area and scroll bind
223230
*/

js/mage/directpost.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ directPost.prototype = {
116116
this.returnQuote();
117117
} else {
118118
this.changeInputOptions('disabled', false);
119-
toggleSelectsUnderBlock($('loading-mask'), true);
120-
$('loading-mask').hide();
119+
hideLoader();
121120
enableElements('save');
122121
}
123122
}
@@ -164,8 +163,7 @@ directPost.prototype = {
164163
case 'sales_order_edit':
165164
case 'sales_order_create':
166165
this.changeInputOptions('disabled', false);
167-
toggleSelectsUnderBlock($('loading-mask'), true);
168-
$('loading-mask').hide();
166+
hideLoader();
169167
enableElements('save');
170168
break;
171169
}
@@ -252,9 +250,7 @@ directPost.prototype = {
252250
});
253251
this.hasError = false;
254252
if (paymentMethodEl.value == this.code) {
255-
toggleSelectsUnderBlock($('loading-mask'), false);
256-
$('loading-mask').show();
257-
setLoaderPosition();
253+
showLoader();
258254
this.changeInputOptions('disabled', 'disabled');
259255
this.paymentRequestSent = true;
260256
this.orderRequestSent = true;

skin/adminhtml/default/default/boxes.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
#loading-mask {
7575
background:url(images/blank.gif) repeat;
7676
position:absolute;
77+
top:0;
78+
right:0;
79+
bottom:0;
80+
left:0;
7781
color:#d85909;
7882
font-size:1.1em;
7983
font-weight:bold;

0 commit comments

Comments
 (0)