Fix Bug 46551

This commit is contained in:
Julia Radzhabova 2020-09-11 19:28:03 +03:00
parent 3b61ce2011
commit 64e7123c7a

View file

@ -68,12 +68,6 @@ define([
'use strict'; 'use strict';
Common.UI.LoadMask = Common.UI.BaseView.extend((function() { Common.UI.LoadMask = Common.UI.BaseView.extend((function() {
var ownerEl,
maskeEl,
loaderEl;
var timerId = 0;
maskeEl = $('<div class="asc-loadmask"></div>');
return { return {
options : { options : {
cls : '', cls : '',
@ -95,13 +89,15 @@ define([
this.template = this.options.template || this.template; this.template = this.options.template || this.template;
this.title = this.options.title; this.title = this.options.title;
ownerEl = (this.options.owner instanceof Common.UI.BaseView) ? $(this.options.owner.el) : $(this.options.owner); this.ownerEl = (this.options.owner instanceof Common.UI.BaseView) ? $(this.options.owner.el) : $(this.options.owner);
loaderEl = $(this.template({ this.loaderEl = $(this.template({
id : this.id, id : this.id,
cls : this.options.cls, cls : this.options.cls,
style : this.options.style, style : this.options.style,
title : this.title title : this.title
})); }));
this.maskeEl = $('<div class="asc-loadmask"></div>');
this.timerId = 0;
}, },
render: function() { render: function() {
@ -113,6 +109,9 @@ define([
// return; // return;
// The owner is already masked // The owner is already masked
var ownerEl = this.ownerEl,
loaderEl = this.loaderEl,
maskeEl = this.maskeEl;
if (!!ownerEl.ismasked) if (!!ownerEl.ismasked)
return this; return this;
@ -125,7 +124,7 @@ define([
} }
// show mask after 500 ms if it wont be hided // show mask after 500 ms if it wont be hided
timerId = setTimeout(function () { me.timerId = setTimeout(function () {
ownerEl.append(maskeEl); ownerEl.append(maskeEl);
ownerEl.append(loaderEl); ownerEl.append(loaderEl);
@ -144,16 +143,17 @@ define([
}, },
hide: function() { hide: function() {
if (timerId) { var ownerEl = this.ownerEl;
clearTimeout(timerId); if (this.timerId) {
timerId = 0; clearTimeout(this.timerId);
this.timerId = 0;
} }
if (ownerEl && ownerEl.ismasked) { if (ownerEl && ownerEl.ismasked) {
if (ownerEl.closest('.asc-window.modal').length==0 && !Common.Utils.ModalWindow.isVisible()) if (ownerEl.closest('.asc-window.modal').length==0 && !Common.Utils.ModalWindow.isVisible())
Common.util.Shortcuts.resumeEvents(); Common.util.Shortcuts.resumeEvents();
maskeEl && maskeEl.remove(); this.maskeEl && this.maskeEl.remove();
loaderEl && loaderEl.remove(); this.loaderEl && this.loaderEl.remove();
} }
delete ownerEl.ismasked; delete ownerEl.ismasked;
}, },
@ -161,16 +161,18 @@ define([
setTitle: function(title) { setTitle: function(title) {
this.title = title; this.title = title;
if (ownerEl && ownerEl.ismasked && loaderEl){ if (this.ownerEl && this.ownerEl.ismasked && this.loaderEl){
$('.asc-loadmask-title', loaderEl).html(title); $('.asc-loadmask-title', this.loaderEl).html(title);
} }
}, },
isVisible: function() { isVisible: function() {
return !!ownerEl.ismasked; return !!this.ownerEl.ismasked;
}, },
updatePosition: function() { updatePosition: function() {
var ownerEl = this.ownerEl,
loaderEl = this.loaderEl;
if (ownerEl && ownerEl.ismasked && loaderEl){ if (ownerEl && ownerEl.ismasked && loaderEl){
loaderEl.css({ loaderEl.css({
top : Math.round(ownerEl.height() / 2 - (loaderEl.height() + parseInt(loaderEl.css('padding-top')) + parseInt(loaderEl.css('padding-bottom'))) / 2) + 'px', top : Math.round(ownerEl.height() / 2 - (loaderEl.height() + parseInt(loaderEl.css('padding-top')) + parseInt(loaderEl.css('padding-bottom'))) / 2) + 'px',