diff --git a/www/common/common-interface.js b/www/common/common-interface.js index d4b3059b4..9cc1c1efb 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -55,6 +55,10 @@ define([ return $('button.ok').last(); }; + UI.removeModals = function () { + $('div.alertify').remove(); + }; + var listenForKeys = UI.listenForKeys = function (yes, no, el) { var handler = function (e) { e.stopPropagation(); @@ -375,6 +379,7 @@ define([ dialog.getButtons = function (buttons, onClose) { if (!Array.isArray(buttons)) { return void console.error('Not an array'); } + if (!buttons.length) { return; } var navs = []; buttons.forEach(function (b) { if (!b.name || !b.onClick) { return; } diff --git a/www/common/onlyoffice/app-oo.less b/www/common/onlyoffice/app-oo.less index c7bd64e01..aa4bd4f8f 100644 --- a/www/common/onlyoffice/app-oo.less +++ b/www/common/onlyoffice/app-oo.less @@ -27,6 +27,16 @@ body.cp-app-sheet, body.cp-app-oodoc, body.cp-app-ooslide { ); } + .cp-oo-x2tXls { + display: flex; + align-items: center; + justify-content: center; + .fa { + font-size: 30px; + margin-right: 10px; + } + } + #cp-fileupload { display: none !important; } diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index f0d7d3d20..8db20bb4e 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -8,6 +8,7 @@ define([ '/common/common-hash.js', '/common/common-util.js', '/common/common-ui-elements.js', + '/common/hyperscript.js', '/api/config', '/customize/messages.js', '/customize/application_config.js', @@ -33,6 +34,7 @@ define([ Hash, Util, UIElements, + h, ApiConfig, Messages, AppConfig, @@ -65,6 +67,7 @@ define([ var toolbar; + var andThen = function (common) { var Title; var sframeChan = common.getSframeChannel(); @@ -898,6 +901,8 @@ define([ result = x2t.FS.readFile('/working/' + fileName + "." + outputFormat); } catch (e) { debug("Failed reading converted file"); + UI.removeModals(); + UI.warn(Messages.error); return ""; } return result; @@ -919,6 +924,7 @@ define([ xlsData = x2tConvertDataInternal(x2t, data, filename, extension); if (xlsData) { var blob = new Blob([xlsData], {type: "application/bin;charset=utf-8"}); + UI.removeModals(); saveAs(blob, finalFilename); } }; @@ -957,7 +963,7 @@ define([ if (typeof(Atomics) === "undefined") { ext = ['.bin']; - warning = 'Use chrome'; // XXX tell the user they can export as Office format with Chrome? + warning = '
'+Messages.oo_exportChrome+'
'; } var types = ext.map(function (val) { @@ -980,8 +986,7 @@ define([ }; var $select = UIElements.createDropdown(dropdownConfig); - var warningText = warning ? ('
' + warning) : ''; - UI.prompt(Messages.exportPrompt+warningText, Util.fixFileName(suggestion), function (filename) { + UI.prompt(Messages.exportPrompt+warning, Util.fixFileName(suggestion), function (filename) { // $select.getValue() if (!(typeof(filename) === 'string' && filename)) { return; } var ext = ($select.getValue() || '').slice(1); @@ -991,7 +996,15 @@ define([ return; } - x2tSaveAndConvertData(text, "filename.bin", ext, filename+'.'+ext); + var content = h('div.cp-oo-x2tXls', [ + h('span.fa.fa-spin.fa-spinner'), + h('span', Messages.oo_exportInProgress) + ]); + var modal = UI.openCustomModal(UI.dialog.customModal(content, {buttons: []})); + + setTimeout(function () { + x2tSaveAndConvertData(text, "filename.bin", ext, filename+'.'+ext); + }, 100); }, { typeInput: $select[0] }, true); @@ -1092,15 +1105,18 @@ define([ return nId.length === 32; }); if (m.length > 1) { + UI.removeModals(); return void UI.alert(Messages.oo_cantUpload); } if (!content) { - return void UI.alert(Messages.error); // XXX? + UI.removeModals(); + return void UI.alert(Messages.oo_invalidFormat);    } var blob = new Blob([content], {type: 'plain/text'}); var file = getFileType(); blob.name = (metadataMgr.getMetadataLazy().title || file.doc) + '.' + file.type; var uploadedCallback = function() { + UI.removeModals(); UI.confirm(Messages.oo_uploaded, function (yes) { try { window.frames[0].editor.setViewModeDisconnect(); @@ -1124,25 +1140,32 @@ define([ if (ext === "bin") { return void importFile(content); } - require(['/common/onlyoffice/x2t/x2t.js'], function() { - var x2t = window.Module; - x2t.run(); - if (x2tInitialized) { - debug("x2t runtime already initialized"); - x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) { - importFile(convertedContent); - }); - } + var div = h('div.cp-oo-x2tXls', [ + h('span.fa.fa-spin.fa-spinner'), + h('span', Messages.oo_importInProgress) + ]); + var modal = UI.openCustomModal(UI.dialog.customModal(div, {buttons: []})); + setTimeout(function () { + require(['/common/onlyoffice/x2t/x2t.js'], function() { + var x2t = window.Module; + x2t.run(); + if (x2tInitialized) { + debug("x2t runtime already initialized"); + x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) { + importFile(convertedContent); + }); + } - x2t.onRuntimeInitialized = function() { - debug("x2t in runtime initialized"); - // Init x2t js module - x2tInit(x2t); - x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) { - importFile(convertedContent); - }); - }; - }); + x2t.onRuntimeInitialized = function() { + debug("x2t in runtime initialized"); + // Init x2t js module + x2tInit(x2t); + x2tConvertData(x2t, new Uint8Array(content), filename.name, "bin", function(convertedContent) { + importFile(convertedContent); + }); + }; + }); + }, 100); }; var loadLastDocument = function () { diff --git a/www/common/onlyoffice/x2t/x2t.js b/www/common/onlyoffice/x2t/x2t.js index 032979075..1bfa08870 100644 --- a/www/common/onlyoffice/x2t/x2t.js +++ b/www/common/onlyoffice/x2t/x2t.js @@ -5067,7 +5067,7 @@ function _emscripten_asm_const_iii(code, sigPtr, argbuf) { node.stream_ops = stream_ops; return node; },createPreloadedFile:function(parent, name, url, canRead, canWrite, onload, onerror, dontCreateFile, canOwn, preFinish) { - Browser.init(); // XXX perhaps this method should move onto Browser? + Browser.init(); // perhaps this method should move onto Browser? // TODO we should allow people to just pass in a complete filename instead // of parent and name being that we just join them anyways var fullname = name ? PATH_FS.resolve(PATH.join2(parent, name)) : parent;