Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addendum to #2426 - Adminhtml loader #2475

Merged
merged 3 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@

function displayLoadingMask()
{
var loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page
Position.clone($(loaderArea), $('loading-mask'), {offsetLeft:-2});
toggleSelectsUnderBlock($('loading-mask'), false);
Element.show('loading-mask');
showLoader();
}
//]]>
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@
});
}

// show mask, temporary set new target and submit form
var loadingMask = $('loading-mask');
// show mask
showLoader();

// temporary set new target and submit form
var formElem = $(this.formId);
var oldTarget = formElem.target;
var oldAction = formElem.action;

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

if (newActionUrl) {
Expand All @@ -74,10 +72,8 @@
*/
varienForm.prototype.postToFrameComplete = function(response)
{
var loadingMask = $('loading-mask');
$(this.ifrElemName).remove();
toggleSelectsUnderBlock(loadingMask, true);
loadingMask.hide();
hideLoader();
this.postToFrameProcessResponse(response);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@
<?php echo $this->getChildHtml('preview_form'); ?>
</div>
<div id="loading-mask" style="display:none">
<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>
<div class="backdrop"></div>
<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>
</div>

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

function preview() {
Expand All @@ -59,22 +61,11 @@ function preview() {
}

function blockPreview() {
var cumulativeOffset = $('preview').cumulativeOffset();
$('loading-mask').setStyle({
top: ( cumulativeOffset.top ) + 'px',
left: ( cumulativeOffset.left ) + 'px',
width: $('preview').getWidth() + 'px',
height: $('preview').getHeight() + 'px'
});

toggleSelectsUnderBlock($('loading-mask'), false);
Element.show('loading-mask');
setLoaderPosition();
showLoader($('preview'));
}

function unBlockPreview() {
toggleSelectsUnderBlock(loadingMask, true);
Element.hide(loadingMask);
hideLoader();
}

Event.observe(window, 'load', preview);
Expand Down
4 changes: 2 additions & 2 deletions app/design/adminhtml/default/default/template/page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
<?php echo $this->getChildHtml('js') ?>
<?php echo $this->getChildHtml('profiler') ?>
<div id="loading-mask" style="display:none">
<div class="backdrop" style="display:none"></div>
<p class="loader" id="loading_mask_loader" style="display:none">
<div class="backdrop"></div>
<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>
</div>
Expand Down
5 changes: 4 additions & 1 deletion app/design/adminhtml/default/default/template/popup.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@
<?php echo $this->getChildHtml('js') ?>
<?php echo $this->getChildHtml('profiler') ?>
<div id="loading-mask" style="display:none;">
<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>
<div class="backdrop"></div>
<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>
</div>
</div>
<?php echo $this->getChildHtml('before_body_end') ?>
Expand Down
55 changes: 31 additions & 24 deletions js/mage/adminhtml/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,37 +187,44 @@ varienLoaderHandler.handler = {
if(request.options.loaderArea===false){
return;
}

request.options.loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page

if(request && request.options.loaderArea){
Element.clonePosition($('loading-mask'), $(request.options.loaderArea), {offsetLeft:-2});
toggleSelectsUnderBlock($('loading-mask'), false);
Element.show('loading-mask');
Element.childElements('loading-mask').invoke('hide');
setLoaderPosition();
if(this.timeout) {
clearTimeout(this.timeout);
}
this.timeout = setTimeout(function() {
Element.childElements('loading-mask').invoke('show');
}, typeof window.LOADING_TIMEOUT === 'undefined' ? 200 : window.LOADING_TIMEOUT);
}
showLoader();
},

onComplete: function(transport) {
if(Ajax.activeRequestCount == 0) {
toggleSelectsUnderBlock($('loading-mask'), true);
Element.hide('loading-mask');
Element.childElements('loading-mask').invoke('hide');
if(this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
hideLoader();
}
}
};

var loaderTimeout = null;

function showLoader(loaderArea) {
if($(loaderArea) === undefined) {
loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page
}
var loadingMask = $('loading-mask');
if(Element.visible(loadingMask)) {
return;
}
Element.clonePosition(loadingMask, loaderArea, {offsetLeft:-2});
toggleSelectsUnderBlock(loadingMask, false);
Element.show(loadingMask);
Element.childElements(loadingMask).invoke('hide');
setLoaderPosition();
loaderTimeout = setTimeout(function() {
Element.childElements(loadingMask).invoke('show');
}, typeof window.LOADING_TIMEOUT === 'undefined' ? 200 : window.LOADING_TIMEOUT);
}

function hideLoader() {
toggleSelectsUnderBlock($('loading-mask'), true);
Element.hide('loading-mask');
if(loaderTimeout) {
clearTimeout(loaderTimeout);
loaderTimeout = null;
}
}

/**
* @todo need calculate middle of visible area and scroll bind
*/
Expand Down
10 changes: 3 additions & 7 deletions js/mage/directpost.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ directPost.prototype = {
this.returnQuote();
} else {
this.changeInputOptions('disabled', false);
toggleSelectsUnderBlock($('loading-mask'), true);
$('loading-mask').hide();
hideLoader();
enableElements('save');
}
}
Expand Down Expand Up @@ -164,8 +163,7 @@ directPost.prototype = {
case 'sales_order_edit':
case 'sales_order_create':
this.changeInputOptions('disabled', false);
toggleSelectsUnderBlock($('loading-mask'), true);
$('loading-mask').hide();
hideLoader();
enableElements('save');
break;
}
Expand Down Expand Up @@ -252,9 +250,7 @@ directPost.prototype = {
});
this.hasError = false;
if (paymentMethodEl.value == this.code) {
toggleSelectsUnderBlock($('loading-mask'), false);
$('loading-mask').show();
setLoaderPosition();
showLoader();
this.changeInputOptions('disabled', 'disabled');
this.paymentRequestSent = true;
this.orderRequestSent = true;
Expand Down
4 changes: 4 additions & 0 deletions skin/adminhtml/default/default/boxes.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
#loading-mask {
background:url(images/blank.gif) repeat;
position:absolute;
top:0;
right:0;
bottom:0;
left:0;
color:#d85909;
font-size:1.1em;
font-weight:bold;
Expand Down