Fix loading mask on document opening

This commit is contained in:
Julia Radzhabova 2021-06-18 16:53:50 +03:00
parent 1fd322493f
commit 41d95920a7
5 changed files with 15 additions and 6 deletions

View file

@ -641,6 +641,14 @@ Common.Utils.String = new (function() {
var nTrailingChar = 0xDC00 | (nUnicode & 0x3FF); var nTrailingChar = 0xDC00 | (nUnicode & 0x3FF);
return String.fromCharCode(nLeadingChar) + String.fromCharCode(nTrailingChar); return String.fromCharCode(nLeadingChar) + String.fromCharCode(nTrailingChar);
} }
},
fixedDigits: function(num, digits, fill) {
(fill===undefined) && (fill = '0');
var strfill = "",
str = num.toString();
for (var i=str.length; i<digits; i++) strfill += fill;
return strfill + str;
} }
} }
})(); })();

View file

@ -49,6 +49,7 @@
.asc-loadmask-title { .asc-loadmask-title {
.fontsize(@font-size-large); .fontsize(@font-size-large);
margin: 0 8px 0 12px; margin: 0 8px 0 12px;
white-space: pre-wrap;
} }
.left-panel & { .left-panel & {

View file

@ -942,7 +942,7 @@ define([
break; break;
case LoadingDocument: case LoadingDocument:
title = this.loadingDocumentTitleText; title = this.loadingDocumentTitleText + ' ';
text = this.loadingDocumentTextText; text = this.loadingDocumentTextText;
break; break;
default: default:
@ -1246,7 +1246,7 @@ define([
onOpenDocument: function(progress) { onOpenDocument: function(progress) {
var elem = document.getElementById('loadmask-text'); var elem = document.getElementById('loadmask-text');
var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount());
proc = this.textLoadingDocument + ': ' + Math.min(Math.round(proc*100), 100) + '%'; proc = this.textLoadingDocument + ': ' + Common.Utils.String.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + "%";
elem ? elem.innerHTML = proc : this.loadMask && this.loadMask.setTitle(proc); elem ? elem.innerHTML = proc : this.loadMask && this.loadMask.setTitle(proc);
}, },

View file

@ -691,7 +691,7 @@ define([
break; break;
case LoadingDocument: case LoadingDocument:
title = this.loadingDocumentTitleText; title = this.loadingDocumentTitleText + ' ';
text = this.loadingDocumentTextText; text = this.loadingDocumentTextText;
break; break;
default: default:
@ -981,7 +981,7 @@ define([
onOpenDocument: function(progress) { onOpenDocument: function(progress) {
var elem = document.getElementById('loadmask-text'); var elem = document.getElementById('loadmask-text');
var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount());
proc = this.textLoadingDocument + ': ' + Math.min(Math.round(proc*100), 100) + '%'; proc = this.textLoadingDocument + ': ' + Common.Utils.String.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + "%";
elem ? elem.innerHTML = proc : this.loadMask && this.loadMask.setTitle(proc); elem ? elem.innerHTML = proc : this.loadMask && this.loadMask.setTitle(proc);
}, },

View file

@ -739,7 +739,7 @@ define([
break; break;
case LoadingDocument: case LoadingDocument:
title = this.loadingDocumentTitleText; title = this.loadingDocumentTitleText + ' ';
break; break;
default: default:
if (typeof action.id == 'string'){ if (typeof action.id == 'string'){
@ -1043,7 +1043,7 @@ define([
onOpenDocument: function(progress) { onOpenDocument: function(progress) {
var elem = document.getElementById('loadmask-text'); var elem = document.getElementById('loadmask-text');
var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount());
proc = this.textLoadingDocument + ': ' + Math.min(Math.round(proc*100), 100) + '%'; proc = this.textLoadingDocument + ': ' + Common.Utils.String.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + "%";
elem ? elem.innerHTML = proc : this.loadMask && this.loadMask.setTitle(proc); elem ? elem.innerHTML = proc : this.loadMask && this.loadMask.setTitle(proc);
}, },