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

Add loading delay adminhtml #2426

Merged
merged 9 commits into from
Aug 22, 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
10 changes: 10 additions & 0 deletions app/code/core/Mage/Adminhtml/Block/Page/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,14 @@ public function getFormKey()
{
return Mage::getSingleton('core/session')->getFormKey();
}

/**
* Retrieve Timeout Delay from Config
*
* @return string
*/
public function getLoadingTimeout()
{
return (int)Mage::getStoreConfig('admin/design/loading_timeout');
}
}
3 changes: 3 additions & 0 deletions app/code/core/Mage/Core/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,9 @@
</browser_capabilities>
</web>
<admin>
<design>
<loading_timeout>200</loading_timeout>
</design>
<startup>
<page>dashboard</page>
</startup>
Expand Down
9 changes: 9 additions & 0 deletions app/code/core/Mage/Core/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,15 @@
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</use_legacy_theme>
<loading_timeout translate="label comment">
<label>Loading Indicator Timeout</label>
<comment>Number of milliseconds to delay showing the loading indicator. The default value is "200". An empty value disables the delay.</comment>
<validate>validate-number validate-zero-or-greater</validate>
<sort_order>2</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</loading_timeout>
</fields>
</design>

Expand Down
5 changes: 4 additions & 1 deletion app/design/adminhtml/default/default/template/page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,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" style="display:none"></div>
<p class="loader" id="loading_mask_loader" style="display:none">
<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>

<?php echo $this->getChildHtml('before_body_end') ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
var BASE_URL = '<?php echo $this->getUrl('*') ?>';
var SKIN_URL = '<?php echo $this->jsQuoteEscape($this->getSkinUrl()) ?>';
var FORM_KEY = '<?php echo $this->getFormKey() ?>';
var LOADING_TIMEOUT = <?php echo $this->getLoadingTimeout() ?>;
</script>

<?php echo $this->getCssJsHtml() ?>
Expand Down
2 changes: 2 additions & 0 deletions app/locale/en_US/Mage_Core.csv
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,5 @@
"Admin","Admin"
"Frontend","Frontend"
"The store view #%d is disabled.","The store view #%d is disabled."
"Loading Indicator Timeout","Loading Indicator Timeout"
"Number of milliseconds to delay showing the loading indicator. The default value is ""200"". An empty value disables the delay.","Number of milliseconds to delay showing the loading indicator. The default value is ""200"". An empty value disables the delay."
17 changes: 11 additions & 6 deletions js/mage/adminhtml/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,26 @@ varienLoaderHandler.handler = {
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(request.options.loaderArea=='html-body'){
//Element.show('loading-process');
if(this.timeout) {
clearTimeout(this.timeout);
}
}
else{
//Element.show('loading-process');
this.timeout = setTimeout(function() {
Element.childElements('loading-mask').invoke('show');
}, typeof window.LOADING_TIMEOUT === 'undefined' ? 200 : window.LOADING_TIMEOUT);
}
},

onComplete: function(transport) {
if(Ajax.activeRequestCount == 0) {
//Element.hide('loading-process');
toggleSelectsUnderBlock($('loading-mask'), true);
Element.hide('loading-mask');
Element.childElements('loading-mask').invoke('hide');
if(this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
}
}
};
Expand Down
10 changes: 8 additions & 2 deletions skin/adminhtml/default/openmage/override.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion skin/adminhtml/default/openmage/override.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions skin/adminhtml/default/openmage/scss/override.scss
Original file line number Diff line number Diff line change
Expand Up @@ -690,11 +690,16 @@ div {
}

#loading-mask {
background: $black_40;
z-index: 1000;
color: $color_dark_grey;
opacity: 1;

.backdrop {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: $black_40;
color: $color_dark_grey;
}
.loader {
width: 160px;
height: 100px;
Expand Down Expand Up @@ -1135,4 +1140,4 @@ img[src$='grid-cal.gif'] {

.emph, .accent {
color: $color_action !important;
}
}