diff --git a/apps/common/embed/lib/util/utils.js b/apps/common/embed/lib/util/utils.js index 8676bb859..7cddcafc7 100644 --- a/apps/common/embed/lib/util/utils.js +++ b/apps/common/embed/lib/util/utils.js @@ -84,6 +84,14 @@ _user.group && (_user.fullname = (_user.group).toString() + AscCommon.UserInfoParser.getSeparator() + _user.fullname); _user.guest = !_user.name; return _user; + }, + + fixedDigits: function(num, digits, fill) { + (fill===undefined) && (fill = '0'); + var strfill = "", + str = num.toString(); + for (var i=str.length; i' + + '
' + + ''; + var ownerEl = owner || $(document.body), + loaderEl, + maskedEl, + title = '', + timerId = 0, + rendered = false; + return { + + show: function(){ + if (!loaderEl || !maskedEl) { + loaderEl = $(tpl); + maskedEl = $('
'); + } + + $('.asc-loadmask-title', loaderEl).html(title); + + // show mask after 500 ms if it wont be hided + if (!rendered) { + rendered = true; + timerId = setTimeout(function () { + ownerEl.append(maskedEl); + ownerEl.append(loaderEl); + + loaderEl.css('min-width', $('.asc-loadmask-title', loaderEl).width() + 105); + },500); + } + }, + + hide: function() { + if (timerId) { + clearTimeout(timerId); + timerId = 0; + } + maskedEl && maskedEl.remove(); + loaderEl && loaderEl.remove(); + maskedEl = loaderEl = null; + rendered = false; + }, + + setTitle: function(text) { + title = text; + + if (ownerEl && loaderEl){ + var el = $('.asc-loadmask-title', loaderEl); + el.html(title); + loaderEl.css('min-width', el.width() + 105); + } + } + } +}; + diff --git a/apps/common/embed/resources/less/common.less b/apps/common/embed/resources/less/common.less index 54012b65b..006c2f810 100644 --- a/apps/common/embed/resources/less/common.less +++ b/apps/common/embed/resources/less/common.less @@ -53,6 +53,8 @@ @import "../../../../../vendor/bootstrap/less/responsive-utilities.less"; +@import "loadmask.less"; + @toolbarBorderColor: #dbdbdb; @toolbarBorderShadowColor: #FAFAFA; @toolbarTopColor: #F7F7F7; diff --git a/apps/common/embed/resources/less/loadmask.less b/apps/common/embed/resources/less/loadmask.less new file mode 100644 index 000000000..26d068654 --- /dev/null +++ b/apps/common/embed/resources/less/loadmask.less @@ -0,0 +1,74 @@ +@loadmask-zindex: 10000; +@loadmask-image-height: 28px; +@loadmask-image-width: 28px; +@loadmask-small-image-height: 20px; +@loadmask-small-image-width: 20px; +@background-loader-ie: fade(#000, 65%); +@background-loader: fade(#181818, 90%); +@text-contrast-background-ie: #fff; +@text-contrast-background: #fff; + +.asc-loadmask { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + zoom: 1; + background-color: transparent; + z-index: @loadmask-zindex; +} + +.asc-loadmask-body { + position: absolute; + z-index: @loadmask-zindex + 1; + padding: 24px; + line-height: @loadmask-image-height; + border: none; + background-image: none; + background-color: @background-loader-ie; + background-color: @background-loader; + color: @text-contrast-background-ie; + color: @text-contrast-background; + border-radius: 6px; + + left: 50%; + top: 50%; + transform: translate(-50%); + + & > div { + display: inline-block; + vertical-align: middle; + } + + .asc-loadmask-image { + background-image: ~"url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyOCAyOCI+PGNpcmNsZSBjeD0iMTQiIGN5PSIxNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjEuNSIgcj0iMTAuMjUiIHN0cm9rZS1kYXNoYXJyYXk9IjE2MCUsIDQwJSIgLz48L3N2Zz4=)"; + height: 28px; + width: 28px; + float: left; + margin-left: 8px; + } + + .asc-loadmask-title { + font-size: 13px; + margin: 0 8px 0 12px; + white-space: pre-wrap; + } +} + +@keyframes rotation { + from { + transform: rotate(0); + } + + to { + transform: rotate(360deg); + } +} + +#loadmask-spinner { + animation-duration: .8s; + animation-name: rotation; + animation-iteration-count: infinite; + animation-timing-function: linear; +} diff --git a/apps/documenteditor/embed/index.html b/apps/documenteditor/embed/index.html index bd9ab347c..ab20ccc1f 100644 --- a/apps/documenteditor/embed/index.html +++ b/apps/documenteditor/embed/index.html @@ -222,11 +222,6 @@ - - @@ -257,6 +252,7 @@ + diff --git a/apps/documenteditor/embed/index.html.deploy b/apps/documenteditor/embed/index.html.deploy index b2bfd8c2b..c6c09db65 100644 --- a/apps/documenteditor/embed/index.html.deploy +++ b/apps/documenteditor/embed/index.html.deploy @@ -214,11 +214,6 @@ - - diff --git a/apps/documenteditor/embed/index_loader.html b/apps/documenteditor/embed/index_loader.html index 75cf5466f..938ddb42f 100644 --- a/apps/documenteditor/embed/index_loader.html +++ b/apps/documenteditor/embed/index_loader.html @@ -323,11 +323,6 @@ - - @@ -351,6 +346,7 @@ + diff --git a/apps/documenteditor/embed/index_loader.html.deploy b/apps/documenteditor/embed/index_loader.html.deploy index 6222ab1b2..29f7ab10c 100644 --- a/apps/documenteditor/embed/index_loader.html.deploy +++ b/apps/documenteditor/embed/index_loader.html.deploy @@ -315,11 +315,6 @@ - - diff --git a/apps/documenteditor/embed/js/ApplicationController.js b/apps/documenteditor/embed/js/ApplicationController.js index bab462149..ddc3b7363 100644 --- a/apps/documenteditor/embed/js/ApplicationController.js +++ b/apps/documenteditor/embed/js/ApplicationController.js @@ -45,6 +45,8 @@ DE.ApplicationController = new(function(){ btnSubmit, _submitFail, $submitedTooltip, $requiredTooltip; + var LoadingDocument = -256; + // Initialize analytics // ------------------------- @@ -168,14 +170,19 @@ DE.ApplicationController = new(function(){ btnSubmit.attr({disabled: true}); btnSubmit.css("pointer-events", "none"); break; + case LoadingDocument: + text = me.textLoadingDocument + ' '; + break; default: text = me.waitText; break; } if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - $('#id-loadmask .cmd-loader-title').html(text); - showMask(); + if (!me.loadMask) + me.loadMask = new common.view.LoadMask(); + me.loadMask.setTitle(text); + me.loadMask.show(); } } @@ -192,7 +199,7 @@ DE.ApplicationController = new(function(){ $submitedTooltip.show(); } } - hideMask(); + me.loadMask && me.loadMask.hide(); } function onDocMouseMoveStart() { @@ -272,6 +279,7 @@ DE.ApplicationController = new(function(){ function onDocumentContentReady() { hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var zf = (config.customization && config.customization.zoom ? parseInt(config.customization.zoom) : -2); (zf == -1) ? api.zoomFitToPage() : ((zf == -2) ? api.zoomFitToWidth() : api.zoom(zf>0 ? zf : 100)); @@ -542,24 +550,15 @@ DE.ApplicationController = new(function(){ else $parent.css('padding-right', _left_width - _right_width); + onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + api.asc_LoadDocument(); api.Resize(); } - function showMask() { - $('#id-loadmask').modal({ - backdrop: 'static', - keyboard: false - }); - } - - function hideMask() { - $('#id-loadmask').modal('hide'); - } - function onOpenDocument(progress) { var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - $('#loadmask-text').html(me.textLoadingDocument + ': ' + Math.min(Math.round(proc * 100), 100) + '%'); + me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); } function onError(id, level, errData) { @@ -574,6 +573,7 @@ DE.ApplicationController = new(function(){ } hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; diff --git a/apps/presentationeditor/embed/index.html b/apps/presentationeditor/embed/index.html index b0baf0920..991f9b627 100644 --- a/apps/presentationeditor/embed/index.html +++ b/apps/presentationeditor/embed/index.html @@ -273,11 +273,6 @@ - - @@ -307,6 +302,7 @@ + diff --git a/apps/presentationeditor/embed/index.html.deploy b/apps/presentationeditor/embed/index.html.deploy index 5db22646c..a3a0347ab 100644 --- a/apps/presentationeditor/embed/index.html.deploy +++ b/apps/presentationeditor/embed/index.html.deploy @@ -267,11 +267,6 @@ - - diff --git a/apps/presentationeditor/embed/index_loader.html b/apps/presentationeditor/embed/index_loader.html index 5d725ac73..e90de1d35 100644 --- a/apps/presentationeditor/embed/index_loader.html +++ b/apps/presentationeditor/embed/index_loader.html @@ -322,11 +322,6 @@ - - @@ -349,6 +344,7 @@ + diff --git a/apps/presentationeditor/embed/index_loader.html.deploy b/apps/presentationeditor/embed/index_loader.html.deploy index cb929d1b1..ee5f914c6 100644 --- a/apps/presentationeditor/embed/index_loader.html.deploy +++ b/apps/presentationeditor/embed/index_loader.html.deploy @@ -315,11 +315,6 @@ - - diff --git a/apps/presentationeditor/embed/js/ApplicationController.js b/apps/presentationeditor/embed/js/ApplicationController.js index 6f4ca8d87..78df5f6a2 100644 --- a/apps/presentationeditor/embed/js/ApplicationController.js +++ b/apps/presentationeditor/embed/js/ApplicationController.js @@ -43,6 +43,8 @@ PE.ApplicationController = new(function(){ ttOffset = [0, -10], labelDocName; + var LoadingDocument = -256; + // Initialize analytics // ------------------------- @@ -156,19 +158,24 @@ PE.ApplicationController = new(function(){ case Asc.c_oAscAsyncAction['Print']: text = me.downloadTextText; break; + case LoadingDocument: + text = me.textLoadingDocument + ' '; + break; default: text = me.waitText; break; } if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - $('#id-loadmask .cmd-loader-title').html(text); - showMask(); + if (!me.loadMask) + me.loadMask = new common.view.LoadMask(); + me.loadMask.setTitle(text); + me.loadMask.show(); } } function onLongActionEnd(){ - hideMask(); + me.loadMask && me.loadMask.hide(); } function onDocMouseMoveStart() { @@ -244,6 +251,7 @@ PE.ApplicationController = new(function(){ onPlayStart(); } hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var zf = (config.customization && config.customization.zoom ? parseInt(config.customization.zoom) : -1); (zf == -1) ? api.zoomFitToPage() : ((zf == -2) ? api.zoomFitToWidth() : api.zoom(zf>0 ? zf : 100)); @@ -469,6 +477,7 @@ PE.ApplicationController = new(function(){ else $parent.css('padding-right', _left_width - _right_width); + onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); api.asc_setViewMode(true); api.asc_LoadDocument(); api.Resize(); @@ -476,7 +485,7 @@ PE.ApplicationController = new(function(){ function onOpenDocument(progress) { var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - $('#loadmask-text').html(me.textLoadingDocument + ': ' + Math.min(Math.round(proc * 100), 100) + '%'); + me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); } var isplaymode; @@ -505,17 +514,6 @@ PE.ApplicationController = new(function(){ $('#page-number').val(number); } - function showMask() { - $('#id-loadmask').modal({ - backdrop: 'static', - keyboard: false - }); - } - - function hideMask() { - $('#id-loadmask').modal('hide'); - } - function onError(id, level, errData) { if (id == Asc.c_oAscError.ID.LoadingScriptError) { $('#id-critical-error-title').text(me.criticalErrorTitle); @@ -528,7 +526,8 @@ PE.ApplicationController = new(function(){ } hidePreloader(); - + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + var message; switch (id) diff --git a/apps/spreadsheeteditor/embed/index.html b/apps/spreadsheeteditor/embed/index.html index a7eb4880a..c21511fc4 100644 --- a/apps/spreadsheeteditor/embed/index.html +++ b/apps/spreadsheeteditor/embed/index.html @@ -246,11 +246,6 @@ - - @@ -283,6 +278,7 @@ + diff --git a/apps/spreadsheeteditor/embed/index.html.deploy b/apps/spreadsheeteditor/embed/index.html.deploy index 13573b703..50678b73f 100644 --- a/apps/spreadsheeteditor/embed/index.html.deploy +++ b/apps/spreadsheeteditor/embed/index.html.deploy @@ -238,11 +238,6 @@ - - diff --git a/apps/spreadsheeteditor/embed/index_loader.html b/apps/spreadsheeteditor/embed/index_loader.html index f703fe302..dffe44305 100644 --- a/apps/spreadsheeteditor/embed/index_loader.html +++ b/apps/spreadsheeteditor/embed/index_loader.html @@ -321,11 +321,6 @@ - - @@ -351,6 +346,7 @@ + diff --git a/apps/spreadsheeteditor/embed/index_loader.html.deploy b/apps/spreadsheeteditor/embed/index_loader.html.deploy index 56166bc85..097125983 100644 --- a/apps/spreadsheeteditor/embed/index_loader.html.deploy +++ b/apps/spreadsheeteditor/embed/index_loader.html.deploy @@ -313,11 +313,6 @@ - - diff --git a/apps/spreadsheeteditor/embed/js/ApplicationController.js b/apps/spreadsheeteditor/embed/js/ApplicationController.js index e2a5a7031..c2dd584da 100644 --- a/apps/spreadsheeteditor/embed/js/ApplicationController.js +++ b/apps/spreadsheeteditor/embed/js/ApplicationController.js @@ -45,6 +45,8 @@ SSE.ApplicationController = new(function(){ ttOffset = [6, -15], labelDocName; + var LoadingDocument = -256; + // Initialize analytics // ------------------------- @@ -196,6 +198,7 @@ SSE.ApplicationController = new(function(){ function onDocumentContentReady() { hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); if ( permissions.print === false) $('#idt-print').hide(); @@ -230,6 +233,7 @@ SSE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); api.asc_registerCallback('asc_onPrint', onPrint); api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); + api.asc_registerCallback('asc_onStartAction', onLongActionBegin); Common.Gateway.on('processmouse', onProcessMouse); Common.Gateway.on('downloadas', onDownloadAs); @@ -371,24 +375,14 @@ SSE.ApplicationController = new(function(){ else $parent.css('padding-right', _left_width - _right_width); + onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); api.asc_setViewMode(true); api.asc_LoadDocument(); } - function showMask() { - $('#id-loadmask').modal({ - backdrop: 'static', - keyboard: false - }); - } - - function hideMask() { - $('#id-loadmask').modal('hide'); - } - function onOpenDocument(progress) { var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - $('#loadmask-text').html(me.textLoadingDocument + ': ' + Math.min(Math.round(proc * 100), 100) + '%'); + me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); } function onLongActionBegin(type, id){ @@ -398,14 +392,19 @@ SSE.ApplicationController = new(function(){ case Asc.c_oAscAsyncAction['Print']: text = me.downloadTextText; break; + case LoadingDocument: + text = me.textLoadingDocument + ' '; + break; default: text = me.waitText; break; } if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - $('#id-loadmask .cmd-loader-title').html(text); - showMask(); + if (!me.loadMask) + me.loadMask = new common.view.LoadMask(); + me.loadMask.setTitle(text); + me.loadMask.show(); } } @@ -424,7 +423,7 @@ SSE.ApplicationController = new(function(){ break; } - hideMask(); + me.loadMask && me.loadMask.hide(); } } @@ -440,6 +439,7 @@ SSE.ApplicationController = new(function(){ } hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; @@ -625,7 +625,6 @@ SSE.ApplicationController = new(function(){ }); if (api){ - api.asc_registerCallback('asc_onStartAction', onLongActionBegin); api.asc_registerCallback('asc_onEndAction', onLongActionEnd); api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); diff --git a/build/documenteditor.json b/build/documenteditor.json index a220200a8..4af60d759 100644 --- a/build/documenteditor.json +++ b/build/documenteditor.json @@ -412,6 +412,7 @@ "../apps/common/Analytics.js", "../apps/common/embed/lib/util/LocalStorage.js", "../apps/common/embed/lib/util/utils.js", + "../apps/common/embed/lib/view/LoadMask.js", "../apps/common/embed/lib/view/modals.js", "../apps/common/embed/lib/controller/modals.js", "../apps/documenteditor/embed/js/ApplicationView.js", diff --git a/build/presentationeditor.json b/build/presentationeditor.json index ccddf34cd..14f0dd739 100644 --- a/build/presentationeditor.json +++ b/build/presentationeditor.json @@ -416,6 +416,7 @@ "../apps/common/Analytics.js", "../apps/common/embed/lib/util/LocalStorage.js", "../apps/common/embed/lib/util/utils.js", + "../apps/common/embed/lib/view/LoadMask.js", "../apps/common/embed/lib/view/modals.js", "../apps/common/embed/lib/controller/modals.js", "../apps/presentationeditor/embed/js/ApplicationView.js", diff --git a/build/spreadsheeteditor.json b/build/spreadsheeteditor.json index 8d3be3fb9..67a466ff3 100644 --- a/build/spreadsheeteditor.json +++ b/build/spreadsheeteditor.json @@ -429,6 +429,7 @@ "../apps/common/Analytics.js", "../apps/common/embed/lib/util/LocalStorage.js", "../apps/common/embed/lib/util/utils.js", + "../apps/common/embed/lib/view/LoadMask.js", "../apps/common/embed/lib/view/modals.js", "../apps/common/embed/lib/controller/modals.js", "../apps/spreadsheeteditor/embed/js/ApplicationView.js",