From 82e05fb8599b5417af88f5516693ecc61daa4738 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 26 Aug 2021 00:35:09 +0300 Subject: [PATCH 01/26] Add test editors --- apps/api/documents/api.js | 17 ++++++++++++++++- test/apps/documenteditor/main/index.html | 8 ++++++++ test/apps/presentationeditor/main/index.html | 8 ++++++++ test/apps/spreadsheeteditor/main/index.html | 8 ++++++++ test/{ => unit-tests}/common.js | 0 test/{ => unit-tests}/common/index.html | 0 .../common/main/lib/component/Button.js | 0 .../common/main/lib/util/utils.js | 0 8 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/apps/documenteditor/main/index.html create mode 100644 test/apps/presentationeditor/main/index.html create mode 100644 test/apps/spreadsheeteditor/main/index.html rename test/{ => unit-tests}/common.js (100%) rename test/{ => unit-tests}/common/index.html (100%) rename test/{ => unit-tests}/common/main/lib/component/Button.js (100%) rename test/{ => unit-tests}/common/main/lib/util/utils.js (100%) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index 8876075ac..f41d99d47 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -838,9 +838,24 @@ return extensionParams["url"] + "apps/"; } + + function getTestPath() { + var scripts = document.getElementsByTagName('script'), + match; + + for (var i = scripts.length - 1; i >= 0; i--) { + match = scripts[i].src.match(/(.*)apps\/api\/documents\/api.js/i); + if (match) { + return match[1] + "test/apps/"; + } + } + + return ""; + } + function getAppPath(config) { var extensionPath = getExtensionPath(), - path = extensionPath ? extensionPath : getBasePath(), + path = extensionPath ? extensionPath : (config.type=="test" ? getTestPath() : getBasePath()), appMap = { 'text': 'documenteditor', 'text-pdf': 'documenteditor', diff --git a/test/apps/documenteditor/main/index.html b/test/apps/documenteditor/main/index.html new file mode 100644 index 000000000..15f14fe94 --- /dev/null +++ b/test/apps/documenteditor/main/index.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/test/apps/presentationeditor/main/index.html b/test/apps/presentationeditor/main/index.html new file mode 100644 index 000000000..15f14fe94 --- /dev/null +++ b/test/apps/presentationeditor/main/index.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/test/apps/spreadsheeteditor/main/index.html b/test/apps/spreadsheeteditor/main/index.html new file mode 100644 index 000000000..15f14fe94 --- /dev/null +++ b/test/apps/spreadsheeteditor/main/index.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/test/common.js b/test/unit-tests/common.js similarity index 100% rename from test/common.js rename to test/unit-tests/common.js diff --git a/test/common/index.html b/test/unit-tests/common/index.html similarity index 100% rename from test/common/index.html rename to test/unit-tests/common/index.html diff --git a/test/common/main/lib/component/Button.js b/test/unit-tests/common/main/lib/component/Button.js similarity index 100% rename from test/common/main/lib/component/Button.js rename to test/unit-tests/common/main/lib/component/Button.js diff --git a/test/common/main/lib/util/utils.js b/test/unit-tests/common/main/lib/util/utils.js similarity index 100% rename from test/common/main/lib/util/utils.js rename to test/unit-tests/common/main/lib/util/utils.js From 478802ec8219473270d59632e36de2a7514fdddc Mon Sep 17 00:00:00 2001 From: OVSharova Date: Sun, 29 Aug 2021 02:46:21 +0300 Subject: [PATCH 02/26] First step --- test/apps/documenteditor/main/index.html | 37 + .../main/js/ApplicationController.js | 937 ++++++++++++++++++ .../documenteditor/main/js/ApplicationView.js | 94 ++ .../documenteditor/main/js/application.js | 38 + test/apps/documenteditor/main/locale/en.json | 0 test/unit-tests/common/Gateway.js | 363 +++++++ test/unit-tests/common/locale.js | 159 +++ .../common/main/lib/util/LocalStorage.js | 137 +++ 8 files changed, 1765 insertions(+) create mode 100644 test/apps/documenteditor/main/js/ApplicationController.js create mode 100644 test/apps/documenteditor/main/js/ApplicationView.js create mode 100644 test/apps/documenteditor/main/js/application.js create mode 100644 test/apps/documenteditor/main/locale/en.json create mode 100644 test/unit-tests/common/Gateway.js create mode 100644 test/unit-tests/common/locale.js create mode 100644 test/unit-tests/common/main/lib/util/LocalStorage.js diff --git a/test/apps/documenteditor/main/index.html b/test/apps/documenteditor/main/index.html index 15f14fe94..776e74a16 100644 --- a/test/apps/documenteditor/main/index.html +++ b/test/apps/documenteditor/main/index.html @@ -2,7 +2,44 @@ + Documents + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/apps/documenteditor/main/js/ApplicationController.js b/test/apps/documenteditor/main/js/ApplicationController.js new file mode 100644 index 000000000..99076fefd --- /dev/null +++ b/test/apps/documenteditor/main/js/ApplicationController.js @@ -0,0 +1,937 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +DE.ApplicationController = new(function(){ + var me, + api, + config = {}, + docConfig = {}, + embedConfig = {}, + permissions = {}, + maxPages = 0, + created = false, + ttOffset = [0, -10], + labelDocName, + appOptions = {}, + btnSubmit, + _submitFail, $submitedTooltip, $requiredTooltip, + $listControlMenu, listControlItems = [], listObj, + bodyWidth = 0; + + var LoadingDocument = -256; + + // Initialize analytics + // ------------------------- + +// Common.Analytics.initialize('UA-12442749-13', 'Embedded Document Editor'); + + + // Check browser + // ------------------------- + + if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ + Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + return; + } + + common.localStorage.setId('text'); + common.localStorage.setKeysFilter('de-,asc.text'); + common.localStorage.sync(); + + // Handlers + // ------------------------- + + function loadConfig(data) { + config = $.extend(config, data.config); + embedConfig = $.extend(embedConfig, data.config.embedded); + + common.controller.modals.init(embedConfig); + + // Docked toolbar + if (embedConfig.toolbarDocked === 'bottom') { + //$('#toolbar').addClass('bottom'); + $('#editor_sdk').addClass('bottom'); + //$('#box-tools').removeClass('dropdown').addClass('dropup'); + ttOffset[1] = -40; + } else { + //$('#toolbar').addClass('top'); + $('#editor_sdk').addClass('top'); + ttOffset[1] = 40; + } + + config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && + (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose); + } + + function loadDocument(data) { + docConfig = data.doc; + + if (docConfig) { + permissions = $.extend(permissions, docConfig.permissions); + + var _permissions = $.extend({}, docConfig.permissions), + docInfo = new Asc.asc_CDocInfo(), + _user = new Asc.asc_CUserInfo(); + + var canRenameAnonymous = !((typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (config.customization.anonymous.request===false)), + guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && + (typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ? + common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest, + value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null, + user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous, + common.localStorage.getItem("guest-id") || ('uid-' + Date.now())); + user.anonymous && common.localStorage.setItem("guest-id", user.id); + + _user.put_Id(user.id); + _user.put_FullName(user.fullname); + _user.put_IsAnonymousUser(user.anonymous); + + docInfo.put_Id(docConfig.key); + docInfo.put_Url(docConfig.url); + docInfo.put_Title(docConfig.title); + docInfo.put_Format(docConfig.fileType); + docInfo.put_VKey(docConfig.vkey); + docInfo.put_UserInfo(_user); + docInfo.put_Token(docConfig.token); + docInfo.put_Permissions(_permissions); + docInfo.put_EncryptedInfo(config.encryptionKeys); + + var enable = !config.customization || (config.customization.macros!==false); + docInfo.asc_putIsEnabledMacroses(!!enable); + enable = !config.customization || (config.customization.plugins!==false); + docInfo.asc_putIsEnabledPlugins(!!enable); + + var type = /^(?:(pdf|djvu|xps))$/.exec(docConfig.fileType); + if (type && typeof type[1] === 'string') { + permissions.edit = permissions.review = false; + } + + if (api) { + api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); + api.asc_registerCallback('asc_onRunAutostartMacroses', onRunAutostartMacroses); + api.asc_setDocInfo(docInfo); + api.asc_getEditorPermissions(config.licenseUrl, config.customerId); + api.asc_enableKeyEvents(true); + + Common.Analytics.trackEvent('Load', 'Start'); + } + + embedConfig.docTitle = docConfig.title; + labelDocName = $('#title-doc-name'); + labelDocName.text(embedConfig.docTitle || '') + } + } + + function onCountPages(count) { + maxPages = count; + $('#pages').text(me.textOf + " " + count); + } + + function onCurrentPage(number) { + $('#page-number').val(number + 1); + } + + function onLongActionBegin(type, id) { + var text = ''; + switch (id) + { + case Asc.c_oAscAsyncAction['Print']: + text = me.downloadTextText; + break; + case Asc.c_oAscAsyncAction['Submit']: + _submitFail = false; + $submitedTooltip && $submitedTooltip.hide(); + 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']) { + if (!me.loadMask) + me.loadMask = new common.view.LoadMask(); + me.loadMask.setTitle(text); + me.loadMask.show(); + } + } + + function onLongActionEnd(type, id){ + if (id==Asc.c_oAscAsyncAction['Submit']) { + btnSubmit.removeAttr('disabled'); + btnSubmit.css("pointer-events", "auto"); + if (!_submitFail) { + if (!$submitedTooltip) { + $submitedTooltip = $(''); + $(document.body).append($submitedTooltip); + $submitedTooltip.on('click', function() {$submitedTooltip.hide();}); + } + $submitedTooltip.show(); + } + } + me.loadMask && me.loadMask.hide(); + } + + function onDocMouseMoveStart() { + me.isHideBodyTip = true; + } + + function onDocMouseMoveEnd() { + if (me.isHideBodyTip) { + if ( $tooltip ) { + $tooltip.tooltip('hide'); + $tooltip = false; + } + } + } + + var $ttEl, $tooltip; + function onDocMouseMove(data) { + if (data) { + var type = data.get_Type(); + if (type == Asc.c_oAscMouseMoveDataTypes.Hyperlink || type==Asc.c_oAscMouseMoveDataTypes.Form) { // hyperlink + me.isHideBodyTip = false; + + var str = (type == Asc.c_oAscMouseMoveDataTypes.Hyperlink) ? me.txtPressLink : data.get_FormHelpText(); + if (str.length>500) + str = str.substr(0, 500) + '...'; + str = common.utils.htmlEncode(str); + + if ( !$ttEl ) { + $ttEl = $('.hyperlink-tooltip'); + $ttEl.tooltip({'container':'body', 'trigger':'manual'}); + } + $ttEl.ttpos = [data.get_X(), data.get_Y()]; + if ( !$tooltip) + $tooltip = $ttEl.data('bs.tooltip').tip(); + + if (!$tooltip.is(':visible')) { + var tip = $ttEl.data('bs.tooltip'); + tip.options.title = str; + tip.show([-1000, -1000]); + } else + $tooltip.find('.tooltip-inner')['text'](str); + + var ttHeight = $tooltip.height(), + ttWidth = $tooltip.width(); + !bodyWidth && (bodyWidth = $('body').width()); + + $ttEl.ttpos[1] -= (ttHeight - ttOffset[1] + 20); + if ($ttEl.ttpos[0] + ttWidth + 10 >bodyWidth) { + $ttEl.ttpos[0] = bodyWidth - ttWidth - 5; + if ($ttEl.ttpos[1] < 0) + $ttEl.ttpos[1] += ttHeight + ttOffset[1] + 20; + } else if ($ttEl.ttpos[1] < 0) { + $ttEl.ttpos[1] = 0; + $ttEl.ttpos[0] += 20; + } + $tooltip.css({ + left: $ttEl.ttpos[0], + top: $ttEl.ttpos[1] + }); + } + } + } + + function onDownloadUrl(url, fileType) { + Common.Gateway.downloadAs(url, fileType); + } + + function onPrint() { + if ( permissions.print!==false ) + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + } + + function onPrintUrl(url) { + common.utils.dialogPrint(url, api); + } + + function onFillRequiredFields(isFilled) { + if (isFilled) { + btnSubmit.removeAttr('disabled'); + btnSubmit.css("pointer-events", "auto"); + // $requiredTooltip && $requiredTooltip.hide(); + } else { + btnSubmit.attr({disabled: true}); + btnSubmit.css("pointer-events", "none"); + } + } + + function onShowContentControlsActions(obj, x, y) { + switch (obj.type) { + case Asc.c_oAscContentControlSpecificType.Picture: + if (obj.pr && obj.pr.get_Lock) { + var lock = obj.pr.get_Lock(); + if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked) + return; + } + api.asc_addImage(obj); + setTimeout(function(){ + api.asc_UncheckContentControlButtons(); + }, 500); + break; + case Asc.c_oAscContentControlSpecificType.DropDownList: + case Asc.c_oAscContentControlSpecificType.ComboBox: + onShowListActions(obj, x, y); + break; + } + } + + function onHideContentControlsActions() { + $listControlMenu && $listControlMenu.hide(); + api.asc_UncheckContentControlButtons(); + } + + function onShowListActions(obj, x, y) { + var type = obj.type, + props = obj.pr, + specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(), + isForm = !!props.get_FormPr(); + + var menuContainer = DE.ApplicationView.getMenuForm(); + + if (!$listControlMenu) { + $listControlMenu = menuContainer.find('ul'); + $listControlMenu.on('click', 'li', function(e) { + var value = $(e.target).attr('value'); + if (value) { + value = parseInt(value); + setTimeout(function(){ + (value!==-1) && api.asc_SelectContentControlListItem(listControlItems[value], listObj.get_InternalId()); + }, 1); + } + }); + $('#editor_sdk').on('click', function(e){ + if (e.target.localName == 'canvas') { + if (me._preventClick) + me._preventClick = false; + else { + $listControlMenu && $listControlMenu.hide(); + api.asc_UncheckContentControlButtons(); + } + } + }); + } + $listControlMenu.find('li').remove(); + listControlItems = []; + listObj = props; + + if (specProps) { + var k = 0; + if (isForm){ // for dropdown and combobox form control always add placeholder item + var text = props.get_PlaceholderText(); + $listControlMenu.append('
  • ' + + ((text.trim()!=='') ? text : me.txtEmpty) + + '
  • '); + listControlItems.push(''); + } + var count = specProps.get_ItemsCount(); + k = listControlItems.length; + for (var i=0; i' + + common.utils.htmlEncode(specProps.get_ItemDisplayText(i)) + + ''); + listControlItems.push(specProps.get_ItemValue(i)); + } + } + if (!isForm && listControlItems.length<1) { + $listControlMenu.append('
  • ' + + me.txtEmpty + + '
  • '); + listControlItems.push(-1); + } + } + + menuContainer.css({left: x, top : y}); + me._preventClick = true; + $listControlMenu.show(); + } + + function hidePreloader() { + $('#loading-mask').fadeOut('slow'); + } + + 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)); + + var dividers = $('#box-tools .divider'); + var itemsCount = $('#box-tools a').length; + + /*if ( permissions.print === false) { + $('#idt-print').hide(); + $(dividers[0]).hide(); + itemsCount--; + } + + if ( !embedConfig.saveUrl && permissions.print === false || appOptions.canFillForms) { + $('#idt-download').hide(); + itemsCount--; + } + + if ( !appOptions.canFillForms || permissions.download === false) { + $('#idt-download-docx').hide(); + $('#idt-download-pdf').hide(); + $(dividers[0]).hide(); + $(dividers[1]).hide(); + itemsCount -= 2; + } + + if ( !embedConfig.shareUrl || appOptions.canFillForms) { + $('#idt-share').hide(); + itemsCount--; + } + + if (!config.canBackToFolder) { + $('#idt-close').hide(); + itemsCount--; + } + + if (itemsCount<3) + $(dividers[2]).hide(); + + if ( !embedConfig.embedUrl || appOptions.canFillForms) { + $('#idt-embed').hide(); + itemsCount--; + } + + if ( !embedConfig.fullscreenUrl ) { + $('#idt-fullscreen').hide(); + itemsCount--; + } + + // if ( !embedConfig.saveUrl && permissions.print === false && (!embedConfig.shareUrl || appOptions.canFillForms) && (!embedConfig.embedUrl || appOptions.canFillForms) && !embedConfig.fullscreenUrl && !config.canBackToFolder) + if (itemsCount<1) + $('#box-tools').addClass('hidden'); + else if ((!embedConfig.embedUrl || appOptions.canFillForms) && !embedConfig.fullscreenUrl) + $(dividers[2]).hide(); + + common.controller.modals.attach({ + share: '#idt-share', + embed: '#idt-embed' + });*/ + + api.asc_registerCallback('asc_onStartAction', onLongActionBegin); + api.asc_registerCallback('asc_onEndAction', onLongActionEnd); + api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart); + api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd); + api.asc_registerCallback('asc_onMouseMove', onDocMouseMove); + /* api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); + api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); + api.asc_registerCallback('asc_onPrint', onPrint); + api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); + api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields);*/ + if (appOptions.canFillForms) { + api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions); + api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions); + api.asc_SetHighlightRequiredFields(true); + } + + Common.Gateway.on('processmouse', onProcessMouse); + Common.Gateway.on('downloadas', onDownloadAs); + Common.Gateway.on('requestclose', onRequestClose); + + DE.ApplicationView.tools.get('#idt-fullscreen') + .on('click', function(){ + common.utils.openLink(embedConfig.fullscreenUrl); + }); + + DE.ApplicationView.tools.get('#idt-download') + .on('click', function(){ + if ( !!embedConfig.saveUrl ){ + common.utils.openLink(embedConfig.saveUrl); + } else + if (api && permissions.print!==false){ + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + } + + Common.Analytics.trackEvent('Save'); + }); + + DE.ApplicationView.tools.get('#idt-print') + .on('click', function(){ + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + Common.Analytics.trackEvent('Print'); + }); + + DE.ApplicationView.tools.get('#idt-close') + .on('click', function(){ + if (config.customization && config.customization.goback) { + if (config.customization.goback.requestClose && config.canRequestClose) + Common.Gateway.requestClose(); + else if (config.customization.goback.url) + window.parent.location.href = config.customization.goback.url; + } + }); + + var downloadAs = function(format){ + api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); + Common.Analytics.trackEvent('Save'); + }; + + DE.ApplicationView.tools.get('#idt-download-docx') + .on('click', function(){ + downloadAs(Asc.c_oAscFileType.DOCX); + }); + DE.ApplicationView.tools.get('#idt-download-pdf') + .on('click', function(){ + downloadAs(Asc.c_oAscFileType.PDF); + }); + + $('#id-btn-zoom-in').on('click', api.zoomIn.bind(this)); + $('#id-btn-zoom-out').on('click', api.zoomOut.bind(this)); + + var $pagenum = $('#page-number'); + $pagenum.on({ + 'keyup': function(e){ + if ( e.keyCode == 13 ){ + var newPage = parseInt($('#page-number').val()); + + if ( newPage > maxPages ) newPage = maxPages; + if (newPage < 2 || isNaN(newPage)) newPage = 1; + + api.goToPage(newPage-1); + $pagenum.blur(); + } + } + , 'focusin' : function(e) { + $pagenum.removeClass('masked'); + } + , 'focusout': function(e){ + !$pagenum.hasClass('masked') && $pagenum.addClass('masked'); + } + }); + + $('#pages').on('click', function(e) { + $pagenum.focus(); + }); + + // TODO: add asc_hasRequiredFields to sdk + + if (appOptions.canSubmitForms && !api.asc_IsAllRequiredFormsFilled()) { + var sgroup = $('#id-submit-group'); + btnSubmit.attr({disabled: true}); + btnSubmit.css("pointer-events", "none"); + if (!common.localStorage.getItem("de-embed-hide-submittip")) { + var offset = btnSubmit.offset(); + $requiredTooltip = $(''); + $(document.body).append($requiredTooltip); + $requiredTooltip.css({top : offset.top + btnSubmit.height() + 'px', left: offset.left + btnSubmit.outerWidth()/2 - $requiredTooltip.outerWidth() + 'px'}); + $requiredTooltip.find('.close-div').on('click', function() { + $requiredTooltip.hide(); + api.asc_MoveToFillingForm(true, true, true); + common.localStorage.setItem("de-embed-hide-submittip", 1); + sgroup.attr('data-toggle', 'tooltip'); + sgroup.tooltip({ + title : me.textRequired, + placement : 'bottom' + }); + }); + $requiredTooltip.show(); + } else { + sgroup.attr('data-toggle', 'tooltip'); + sgroup.tooltip({ + title : me.textRequired, + placement : 'bottom' + }); + } + } + + var documentMoveTimer; + var ismoved = false; + $(document).mousemove(function(event){ + $('#id-btn-zoom-in').fadeIn(); + $('#id-btn-zoom-out').fadeIn(); + + ismoved = true; + if ( !documentMoveTimer ) { + documentMoveTimer = setInterval(function(){ + if ( !ismoved ) { + $('#id-btn-zoom-in').fadeOut(); + $('#id-btn-zoom-out').fadeOut(); + clearInterval(documentMoveTimer); + documentMoveTimer = undefined; + } + + ismoved = false; + }, 2000); + } + }); + Common.Gateway.documentReady(); + Common.Analytics.trackEvent('Load', 'Complete'); + } + + function onEditorPermissions(params) { + if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && + config.customization && config.customization.logo ) { + + var logo = $('#header-logo'); + if (config.customization.logo.imageEmbedded) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + } + + if (config.customization.logo.url) { + logo.attr('href', config.customization.logo.url); + } + } + var licType = params.asc_getLicenseType(); + appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); + appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); + appOptions.canSubmitForms = appOptions.canLicense && (typeof (config.customization) == 'object') && !!config.customization.submitForm; + + api.asc_setViewMode(!appOptions.canFillForms); + + btnSubmit = $('#id-btn-submit'); + + if (!appOptions.canFillForms) { + $('#id-btn-prev-field').hide(); + $('#id-btn-next-field').hide(); + $('#id-btn-clear-fields').hide(); + btnSubmit.hide(); + } else { + $('#id-btn-next-field .caption').text(me.textNext); + $('#id-btn-clear-fields .caption').text(me.textClear); + + $('#id-btn-prev-field').on('click', function(){ + api.asc_MoveToFillingForm(false); + }); + $('#id-btn-next-field').on('click', function(){ + api.asc_MoveToFillingForm(true); + }); + $('#id-btn-clear-fields').on('click', function(){ + api.asc_ClearAllSpecialForms(); + }); + + if (appOptions.canSubmitForms) { + btnSubmit.find('.caption').text(me.textSubmit); + btnSubmit.on('click', function(){ + api.asc_SendForm(); + }); + } else + btnSubmit.hide(); + + api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms); + api.asc_SetFastCollaborative(true); + api.asc_setAutoSaveGap(1); + } + + var $parent = labelDocName.parent(); + var _left_width = $parent.position().left, + _right_width = $parent.next().outerWidth(); + + if ( _left_width < _right_width ) + $parent.css('padding-left', _right_width - _left_width); + else + $parent.css('padding-right', _left_width - _right_width); + + onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + + api.asc_LoadDocument(); + api.Resize(); + } + + function onOpenDocument(progress) { + var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); + me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); + } + + function onError(id, level, errData) { + if (id == Asc.c_oAscError.ID.LoadingScriptError) { + $('#id-critical-error-title').text(me.criticalErrorTitle); + $('#id-critical-error-message').text(me.scriptLoadError); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + window.location.reload(); + }); + $('#id-critical-error-dialog').css('z-index', 20002).modal('show'); + return; + } + + hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + + var message; + + switch (id) + { + case Asc.c_oAscError.ID.Unknown: + message = me.unknownErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationTimeout: + message = me.convertationTimeoutText; + break; + + case Asc.c_oAscError.ID.ConvertationError: + message = me.convertationErrorText; + break; + + case Asc.c_oAscError.ID.DownloadError: + message = me.downloadErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationPassword: + message = me.errorFilePassProtect; + break; + + case Asc.c_oAscError.ID.UserDrop: + message = me.errorUserDrop; + break; + + case Asc.c_oAscError.ID.ConvertationOpenLimitError: + message = me.errorFileSizeExceed; + break; + + case Asc.c_oAscError.ID.UpdateVersion: + message = me.errorUpdateVersionOnDisconnect; + break; + + case Asc.c_oAscError.ID.AccessDeny: + message = me.errorAccessDeny; + break; + + case Asc.c_oAscError.ID.Submit: + message = me.errorSubmit; + _submitFail = true; + $submitedTooltip && $submitedTooltip.hide(); + break; + + case Asc.c_oAscError.ID.EditingError: + message = me.errorEditingDownloadas; + break; + + case Asc.c_oAscError.ID.ForceSaveButton: + case Asc.c_oAscError.ID.ForceSaveTimeout: + message = me.errorForceSave; + break; + + case Asc.c_oAscError.ID.LoadingFontError: + message = me.errorLoadingFont; + break; + + default: + message = me.errorDefaultMessage.replace('%1', id); + break; + } + + if (level == Asc.c_oAscError.Level.Critical) { + + // report only critical errors + Common.Gateway.reportError(id, message); + + $('#id-critical-error-title').text(me.criticalErrorTitle); + $('#id-critical-error-message').html(message); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + window.location.reload(); + }); + } + else { + Common.Gateway.reportWarning(id, message); + + $('#id-critical-error-title').text(me.notcriticalErrorTitle); + $('#id-critical-error-message').html(message); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + $('#id-critical-error-dialog').modal('hide'); + }); + } + + $('#id-critical-error-dialog').modal('show'); + + Common.Analytics.trackEvent('Internal Error', id.toString()); + } + + function onExternalMessage(error) { + if (error) { + hidePreloader(); + $('#id-error-mask-title').text(me.criticalErrorTitle); + $('#id-error-mask-text').text(error.msg); + $('#id-error-mask').css('display', 'block'); + + Common.Analytics.trackEvent('External Error'); + } + } + + function onProcessMouse(data) { + if (data.type == 'mouseup') { + var e = document.getElementById('editor_sdk'); + if (e) { + var r = e.getBoundingClientRect(); + api.OnMouseUp( + data.x - r.left, + data.y - r.top + ); + } + } + } + + function onRequestClose() { + Common.Gateway.requestClose(); + } + + function onDownloadAs() { + if ( permissions.download === false) { + Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); + return; + } + if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true)); + } + + function onRunAutostartMacroses() { + if (!config.customization || (config.customization.macros!==false)) + if (api) api.asc_runAutostartMacroses(); + } + + function onBeforeUnload () { + common.localStorage.save(); + } + // Helpers + // ------------------------- + + function onDocumentResize() { + api && api.Resize(); + bodyWidth = $('body').width(); + } + + function createController(){ + if (created) + return me; + + me = this; + created = true; + + $(window).resize(function(){ + onDocumentResize(); + }); + window.onbeforeunload = onBeforeUnload; + + var ismodalshown = false; + $(document.body).on('show.bs.modal', '.modal', + function(e) { + ismodalshown = true; + api.asc_enableKeyEvents(false); + } + ).on('hidden.bs.modal', '.modal', + function(e) { + ismodalshown = false; + api.asc_enableKeyEvents(true); + } + ).on('hidden.bs.dropdown', '.dropdown', + function(e) { + if ( !ismodalshown ) + api.asc_enableKeyEvents(true); + } + ).on('blur', 'input, textarea', + function(e) { + if ( !ismodalshown ) { + if (!/area_id/.test(e.target.id) ) { + api.asc_enableKeyEvents(true); + } + } + } + ); + + $('#editor_sdk').on('click', function(e) { + if ( e.target.localName == 'canvas' ) { + e.currentTarget.focus(); + } + }); + + window["flat_desine"] = true; + api = new Asc.asc_docs_api({ + 'id-view' : 'editor_sdk', + 'embedded' : true + }); + + if (api){ + api.asc_registerCallback('asc_onError', onError); + api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); + api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); + + api.asc_registerCallback('asc_onCountPages', onCountPages); +// api.asc_registerCallback('OnCurrentVisiblePage', onCurrentPage); + api.asc_registerCallback('asc_onCurrentPage', onCurrentPage); + + // Initialize api gateway + Common.Gateway.on('init', loadConfig); + Common.Gateway.on('opendocument', loadDocument); + Common.Gateway.on('showmessage', onExternalMessage); + Common.Gateway.appReady(); + } + + return me; + } + + return { + create : createController, + errorDefaultMessage : 'Error code: %1', + unknownErrorText : 'Unknown error.', + convertationTimeoutText : 'Conversion timeout exceeded.', + convertationErrorText : 'Conversion failed.', + downloadErrorText : 'Download failed.', + criticalErrorTitle : 'Error', + notcriticalErrorTitle : 'Warning', + scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.', + errorFilePassProtect: 'The file is password protected and cannot be opened.', + errorAccessDeny: 'You are trying to perform an action you do not have rights for.
    Please contact your Document Server administrator.', + errorUserDrop: 'The file cannot be accessed right now.', + unsupportedBrowserErrorText: 'Your browser is not supported.', + textOf: 'of', + downloadTextText: 'Downloading document...', + waitText: 'Please, wait...', + textLoadingDocument: 'Loading document', + txtClose: 'Close', + errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
    Please contact your Document Server administrator for details.', + errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
    Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', + textNext: 'Next Field', + textClear: 'Clear All Fields', + textSubmit: 'Submit', + textSubmited: 'Form submitted successfully
    Click to close the tip.', + errorSubmit: 'Submit failed.', + errorEditingDownloadas: 'An error occurred during the work with the document.
    Use the \'Download as...\' option to save the file backup copy to your computer hard drive.', + textGuest: 'Guest', + textAnonymous: 'Anonymous', + textRequired: 'Fill all required fields to send form.', + textGotIt: 'Got it', + errorForceSave: "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.", + txtEmpty: '(Empty)', + txtPressLink: 'Press Ctrl and click link', + errorLoadingFont: 'Fonts are not loaded.
    Please contact your Document Server administrator.' + } +})(); \ No newline at end of file diff --git a/test/apps/documenteditor/main/js/ApplicationView.js b/test/apps/documenteditor/main/js/ApplicationView.js new file mode 100644 index 000000000..647e63d0a --- /dev/null +++ b/test/apps/documenteditor/main/js/ApplicationView.js @@ -0,0 +1,94 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +if (DE === undefined) { + var DE = {}; +} + +DE.ApplicationView = new(function(){ + var $btnTools; + var $menuForm; + + // Initialize view + + function createView(){ + $btnTools = $('#box-tools button'); + + $btnTools.addClass('dropdown-toggle').attr('data-toggle', 'dropdown').attr('aria-expanded', 'true'); + $btnTools.parent().append( + ''); + } + + function getTools(name) { + return $btnTools.parent().find(name); + } + + function getMenuForm() { + if (!$menuForm) { + $menuForm = $(''); + $('#editor_sdk').append($menuForm); + } + return $menuForm; + } + + return { + create: createView + , tools: { + get: getTools + }, + getMenuForm: getMenuForm, + + txtDownload: 'Download', + txtPrint: 'Print', + txtShare: 'Share', + txtEmbed: 'Embed', + txtFullScreen: 'Full Screen', + txtFileLocation: 'Open file location', + txtDownloadDocx: 'Download as docx', + txtDownloadPdf: 'Download as pdf' + } +})(); diff --git a/test/apps/documenteditor/main/js/application.js b/test/apps/documenteditor/main/js/application.js new file mode 100644 index 000000000..63d642fb2 --- /dev/null +++ b/test/apps/documenteditor/main/js/application.js @@ -0,0 +1,38 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ ++function ($) { + Common.Locale.apply(function() { + DE.ApplicationView.create(); + DE.ApplicationController.create(); + }); +}(); diff --git a/test/apps/documenteditor/main/locale/en.json b/test/apps/documenteditor/main/locale/en.json new file mode 100644 index 000000000..e69de29bb diff --git a/test/unit-tests/common/Gateway.js b/test/unit-tests/common/Gateway.js new file mode 100644 index 000000000..675a7421a --- /dev/null +++ b/test/unit-tests/common/Gateway.js @@ -0,0 +1,363 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ + +if (window.Common === undefined) { + window.Common = {}; +} + + Common.Gateway = new(function() { + var me = this, + $me = $(me); + + var commandMap = { + 'init': function(data) { + $me.trigger('init', data); + }, + + 'openDocument': function(data) { + $me.trigger('opendocument', data); + }, + + 'showMessage': function(data) { + $me.trigger('showmessage', data); + }, + + 'applyEditRights': function(data) { + $me.trigger('applyeditrights', data); + }, + + 'processSaveResult': function(data) { + $me.trigger('processsaveresult', data); + }, + + 'processRightsChange': function(data) { + $me.trigger('processrightschange', data); + }, + + 'refreshHistory': function(data) { + $me.trigger('refreshhistory', data); + }, + + 'setHistoryData': function(data) { + $me.trigger('sethistorydata', data); + }, + + 'setEmailAddresses': function(data) { + $me.trigger('setemailaddresses', data); + }, + + 'setActionLink': function (data) { + $me.trigger('setactionlink', data.url); + }, + + 'processMailMerge': function(data) { + $me.trigger('processmailmerge', data); + }, + + 'downloadAs': function(data) { + $me.trigger('downloadas', data); + }, + + 'processMouse': function(data) { + $me.trigger('processmouse', data); + }, + + 'internalCommand': function(data) { + $me.trigger('internalcommand', data); + }, + + 'resetFocus': function(data) { + $me.trigger('resetfocus', data); + }, + + 'setUsers': function(data) { + $me.trigger('setusers', data); + }, + + 'showSharingSettings': function(data) { + $me.trigger('showsharingsettings', data); + }, + + 'setSharingSettings': function(data) { + $me.trigger('setsharingsettings', data); + }, + + 'insertImage': function(data) { + $me.trigger('insertimage', data); + }, + + 'setMailMergeRecipients': function(data) { + $me.trigger('setmailmergerecipients', data); + }, + + 'setRevisedFile': function(data) { + $me.trigger('setrevisedfile', data); + }, + + 'setFavorite': function(data) { + $me.trigger('setfavorite', data); + }, + + 'requestClose': function(data) { + $me.trigger('requestclose', data); + }, + + 'blurFocus': function(data) { + $me.trigger('blurfocus', data); + }, + + 'grabFocus': function(data) { + $me.trigger('grabfocus', data); + } + }; + + var _postMessage = function(msg) { + // TODO: specify explicit origin + if (window.parent && window.JSON) { + msg.frameEditorId = window.frameEditorId; + window.parent.postMessage(window.JSON.stringify(msg), "*"); + } + }; + + var _onMessage = function(msg) { + // TODO: check message origin + if (msg.origin !== window.parentOrigin && msg.origin !== window.location.origin && !(msg.origin==="null" && (window.parentOrigin==="file://" || window.location.origin==="file://"))) return; + + var data = msg.data; + if (Object.prototype.toString.apply(data) !== '[object String]' || !window.JSON) { + return; + } + + var cmd, handler; + + try { + cmd = window.JSON.parse(data) + } catch(e) { + cmd = ''; + } + + if (cmd) { + handler = commandMap[cmd.command]; + if (handler) { + handler.call(this, cmd.data); + } + } + }; + + var fn = function(e) { _onMessage(e); }; + + if (window.attachEvent) { + window.attachEvent('onmessage', fn); + } else { + window.addEventListener('message', fn, false); + } + + return { + + appReady: function() { + _postMessage({ event: 'onAppReady' }); + }, + + requestEditRights: function() { + _postMessage({ event: 'onRequestEditRights' }); + }, + + requestHistory: function() { + _postMessage({ event: 'onRequestHistory' }); + }, + + requestHistoryData: function(revision) { + _postMessage({ + event: 'onRequestHistoryData', + data: revision + }); + }, + + requestRestore: function(version, url, fileType) { + _postMessage({ + event: 'onRequestRestore', + data: { + version: version, + url: url, + fileType: fileType + } + }); + }, + + requestEmailAddresses: function() { + _postMessage({ event: 'onRequestEmailAddresses' }); + }, + + requestStartMailMerge: function() { + _postMessage({event: 'onRequestStartMailMerge'}); + }, + + requestHistoryClose: function(revision) { + _postMessage({event: 'onRequestHistoryClose'}); + }, + + reportError: function(code, description) { + _postMessage({ + event: 'onError', + data: { + errorCode: code, + errorDescription: description + } + }); + }, + + reportWarning: function(code, description) { + _postMessage({ + event: 'onWarning', + data: { + warningCode: code, + warningDescription: description + } + }); + }, + + sendInfo: function(info) { + _postMessage({ + event: 'onInfo', + data: info + }); + }, + + setDocumentModified: function(modified) { + _postMessage({ + event: 'onDocumentStateChange', + data: modified + }); + }, + + internalMessage: function(type, data) { + _postMessage({ + event: 'onInternalMessage', + data: { + type: type, + data: data + } + }); + }, + + updateVersion: function() { + _postMessage({ event: 'onOutdatedVersion' }); + }, + + downloadAs: function(url, fileType) { + _postMessage({ + event: 'onDownloadAs', + data: { + url: url, + fileType: fileType + } + }); + }, + + requestSaveAs: function(url, title, fileType) { + _postMessage({ + event: 'onRequestSaveAs', + data: { + url: url, + title: title, + fileType: fileType + } + }); + }, + + collaborativeChanges: function() { + _postMessage({event: 'onCollaborativeChanges'}); + }, + + requestRename: function(title) { + _postMessage({event: 'onRequestRename', data: title}); + }, + + metaChange: function(meta) { + _postMessage({event: 'onMetaChange', data: meta}); + }, + + documentReady: function() { + _postMessage({ event: 'onDocumentReady' }); + }, + + requestClose: function() { + _postMessage({event: 'onRequestClose'}); + }, + + requestMakeActionLink: function (config) { + _postMessage({event:'onMakeActionLink', data: config}); + }, + + requestUsers: function () { + _postMessage({event:'onRequestUsers'}); + }, + + requestSendNotify: function (emails) { + _postMessage({event:'onRequestSendNotify', data: emails}); + }, + + requestInsertImage: function (command) { + _postMessage({event:'onRequestInsertImage', data: {c: command}}); + }, + + requestMailMergeRecipients: function () { + _postMessage({event:'onRequestMailMergeRecipients'}); + }, + + requestCompareFile: function () { + _postMessage({event:'onRequestCompareFile'}); + }, + + requestSharingSettings: function () { + _postMessage({event:'onRequestSharingSettings'}); + }, + + requestCreateNew: function () { + _postMessage({event:'onRequestCreateNew'}); + }, + + pluginsReady: function() { + _postMessage({ event: 'onPluginsReady' }); + }, + + on: function(event, handler){ + var localHandler = function(event, data){ + handler.call(me, data) + }; + + $me.on(event, localHandler); + } + } + + })(); diff --git a/test/unit-tests/common/locale.js b/test/unit-tests/common/locale.js new file mode 100644 index 000000000..abed04e94 --- /dev/null +++ b/test/unit-tests/common/locale.js @@ -0,0 +1,159 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +if (Common === undefined) { + var Common = {}; +} + +Common.Locale = new(function() { + "use strict"; + var l10n = null; + var loadcallback, + apply = false, + defLang = '{{DEFAULT_LANG}}', + currentLang = defLang; + + var _applyLocalization = function(callback) { + try { + callback && (loadcallback = callback); + if (l10n) { + for (var prop in l10n) { + var p = prop.split('.'); + if (p && p.length > 2) { + + var obj = window; + for (var i = 0; i < p.length - 1; ++i) { + if (obj[p[i]] === undefined) { + obj[p[i]] = new Object(); + } + obj = obj[p[i]]; + } + + if (obj) { + obj[p[p.length - 1]] = l10n[prop]; + } + } + } + loadcallback && loadcallback(); + } else + apply = true; + } + catch (e) { + } + }; + + var _get = function(prop, scope) { + var res = ''; + if (l10n && scope && scope.name) { + res = l10n[scope.name + '.' + prop]; + + if ( !res && scope.default ) + res = scope.default; + } + + return res || (scope ? eval(scope.name).prototype[prop] : ''); + }; + + var _getCurrentLanguage = function() { + return currentLang; + }; + + var _getLoadedLanguage = function() { + return loadedLang; + }; + + var _getUrlParameterByName = function(name) { + name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + }; + + var _requireLang = function () { + var lang = (_getUrlParameterByName('lang') || defLang).split(/[\-_]/)[0]; + currentLang = lang; + fetch('locale/' + lang + '.json') + .then(function(response) { + if (!response.ok) { + currentLang = defLang; + if (lang != defLang) + /* load default lang if fetch failed */ + return fetch('locale/' + defLang + '.json'); + + throw new Error('server error'); + } + return response.json(); + }).then(function(response) { + if ( response.json ) { + if (!response.ok) + throw new Error('server error'); + + return response.json(); + } else { + l10n = response; + /* to break promises chain */ + throw new Error('loaded'); + } + }).then(function(json) { + l10n = json || {}; + apply && _applyLocalization(); + }).catch(function(e) { + l10n = l10n || {}; + apply && _applyLocalization(); + if ( e.message == 'loaded' ) { + } else { + currentLang = null; + console.log('fetch error: ' + e); + } + }); + }; + + if ( !window.fetch ) { + /* use fetch polifill if native method isn't supported */ + var polyfills = ['../vendor/fetch/fetch.umd']; + if ( !window.Promise ) { + require(['../vendor/es6-promise/es6-promise.auto.min'], + function () { + require(polyfills, _requireLang); + }); + } else require(polyfills, _requireLang); + } else _requireLang(); + + return { + apply: _applyLocalization, + get: _get, + getCurrentLanguage: _getCurrentLanguage + }; + +})(); + + diff --git a/test/unit-tests/common/main/lib/util/LocalStorage.js b/test/unit-tests/common/main/lib/util/LocalStorage.js new file mode 100644 index 000000000..be30d339c --- /dev/null +++ b/test/unit-tests/common/main/lib/util/LocalStorage.js @@ -0,0 +1,137 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2021 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ + +!window.common && (window.common = {}); + +common.localStorage = new (function() { + var _storeName, _filter; + var _store = {}; + + var ongetstore = function(data) { + if (data.type == 'localstorage') { + _store = data.keys; + } + }; + + Common.Gateway.on('internalcommand', ongetstore); + + var _refresh = function() { + if (!_lsAllowed) + Common.Gateway.internalMessage('localstorage', {cmd:'get', keys:_filter}); + }; + + var _save = function() { + if (!_lsAllowed) + Common.Gateway.internalMessage('localstorage', {cmd:'set', keys:_store}); + }; + + var _setItem = function(name, value, just) { + if (_lsAllowed) { + try + { + localStorage.setItem(name, value); + } + catch (error){} + + } else { + _store[name] = value; + + if (just===true) { + Common.Gateway.internalMessage('localstorage', { + cmd:'set', + keys: { + name: value + } + }); + } + } + }; + + var _setItemAsBool = function(name, value, just) { + _setItem(name, value ? 1 : 0, just); + }; + + var _getItem = function(name) { + if (_lsAllowed) + return localStorage.getItem(name); + else + return _store[name]===undefined ? null : _store[name]; + }; + + var _getItemAsBool = function (name, defValue) { + var value = _getItem(name); + defValue = defValue || false; + return (value!==null) ? (parseInt(value) != 0) : defValue; + }; + + var _getItemExists = function (name) { + var value = _getItem(name); + return value !== null; + }; + + var _removeItem = function(name) { + if (_lsAllowed) + localStorage.removeItem(name); + else + delete _store[name]; + }; + + try { + var _lsAllowed = !!window.localStorage; + } catch (e) { + _lsAllowed = false; + } + + return { + getId: function() { + return _storeName; + }, + setId: function(name) { + _storeName = name; + }, + getItem: _getItem, + getBool: _getItemAsBool, + setBool: _setItemAsBool, + setItem: _setItem, + removeItem: _removeItem, + setKeysFilter: function(value) { + _filter = value; + }, + getKeysFilter: function() { + return _filter; + }, + itemExists: _getItemExists, + sync: _refresh, + save: _save + }; +})(); From a0280ed55b739e8a984da02c8e0f523c6ffe4619 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Mon, 30 Aug 2021 04:49:25 +0300 Subject: [PATCH 03/26] index documenteditor --- apps/api/documents/api.js | 2 +- test/apps/documenteditor/main/index.html | 45 - .../documenteditor/main/js/ApplicationView.js | 94 --- test/apps/documenteditor/main/locale/en.json | 0 test/documenteditor/main/index.html | 158 ++++ test/documenteditor/main/index1.html | 45 + .../main/js/ApplicationController.js | 252 +----- .../documenteditor/main/js/ApplicationView.js | 50 ++ .../documenteditor/main/js/application.js | 0 test/documenteditor/main/locale/en.json | 1 + .../main/resources/less/application.less | 2 + .../presentationeditor/main/index.html | 0 .../spreadsheeteditor/main/index.html | 0 .../common/main/lib/controller/modals.js | 143 ++++ test/unit-tests/common/main/lib/util/utils.js | 123 ++- .../unit-tests/common/main/lib/util/utils1.js | 33 + .../common/main/lib/view/LoadMask.js | 101 +++ .../unit-tests/common/main/lib/view/modals.js | 102 +++ .../main/resources/img/icon-menu-sprite.svg | 152 ++++ .../main/resources/img/icon-social-sprite.svg | 1 + .../common/main/resources/img/logo.svg | 1 + .../common/main/resources/img/next-field.png | Bin 0 -> 323 bytes .../main/resources/img/previous-field.png | Bin 0 -> 323 bytes .../common/main/resources/less/common.less | 788 ++++++++++++++++++ .../common/main/resources/less/loadmask.less | 74 ++ 25 files changed, 1768 insertions(+), 399 deletions(-) delete mode 100644 test/apps/documenteditor/main/index.html delete mode 100644 test/apps/documenteditor/main/js/ApplicationView.js delete mode 100644 test/apps/documenteditor/main/locale/en.json create mode 100644 test/documenteditor/main/index.html create mode 100644 test/documenteditor/main/index1.html rename test/{apps => }/documenteditor/main/js/ApplicationController.js (73%) create mode 100644 test/documenteditor/main/js/ApplicationView.js rename test/{apps => }/documenteditor/main/js/application.js (100%) create mode 100644 test/documenteditor/main/locale/en.json create mode 100644 test/documenteditor/main/resources/less/application.less rename test/{apps => }/presentationeditor/main/index.html (100%) rename test/{apps => }/spreadsheeteditor/main/index.html (100%) create mode 100644 test/unit-tests/common/main/lib/controller/modals.js create mode 100644 test/unit-tests/common/main/lib/util/utils1.js create mode 100644 test/unit-tests/common/main/lib/view/LoadMask.js create mode 100644 test/unit-tests/common/main/lib/view/modals.js create mode 100644 test/unit-tests/common/main/resources/img/icon-menu-sprite.svg create mode 100644 test/unit-tests/common/main/resources/img/icon-social-sprite.svg create mode 100644 test/unit-tests/common/main/resources/img/logo.svg create mode 100644 test/unit-tests/common/main/resources/img/next-field.png create mode 100644 test/unit-tests/common/main/resources/img/previous-field.png create mode 100644 test/unit-tests/common/main/resources/less/common.less create mode 100644 test/unit-tests/common/main/resources/less/loadmask.less diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index f41d99d47..5d49a6f6c 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -846,7 +846,7 @@ for (var i = scripts.length - 1; i >= 0; i--) { match = scripts[i].src.match(/(.*)apps\/api\/documents\/api.js/i); if (match) { - return match[1] + "test/apps/"; + return match[1] + "test/"; } } diff --git a/test/apps/documenteditor/main/index.html b/test/apps/documenteditor/main/index.html deleted file mode 100644 index 776e74a16..000000000 --- a/test/apps/documenteditor/main/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - Documents - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/apps/documenteditor/main/js/ApplicationView.js b/test/apps/documenteditor/main/js/ApplicationView.js deleted file mode 100644 index 647e63d0a..000000000 --- a/test/apps/documenteditor/main/js/ApplicationView.js +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * -*/ -if (DE === undefined) { - var DE = {}; -} - -DE.ApplicationView = new(function(){ - var $btnTools; - var $menuForm; - - // Initialize view - - function createView(){ - $btnTools = $('#box-tools button'); - - $btnTools.addClass('dropdown-toggle').attr('data-toggle', 'dropdown').attr('aria-expanded', 'true'); - $btnTools.parent().append( - ''); - } - - function getTools(name) { - return $btnTools.parent().find(name); - } - - function getMenuForm() { - if (!$menuForm) { - $menuForm = $(''); - $('#editor_sdk').append($menuForm); - } - return $menuForm; - } - - return { - create: createView - , tools: { - get: getTools - }, - getMenuForm: getMenuForm, - - txtDownload: 'Download', - txtPrint: 'Print', - txtShare: 'Share', - txtEmbed: 'Embed', - txtFullScreen: 'Full Screen', - txtFileLocation: 'Open file location', - txtDownloadDocx: 'Download as docx', - txtDownloadPdf: 'Download as pdf' - } -})(); diff --git a/test/apps/documenteditor/main/locale/en.json b/test/apps/documenteditor/main/locale/en.json deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/documenteditor/main/index.html b/test/documenteditor/main/index.html new file mode 100644 index 000000000..a203ed37c --- /dev/null +++ b/test/documenteditor/main/index.html @@ -0,0 +1,158 @@ + + + + + Documents + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/documenteditor/main/index1.html b/test/documenteditor/main/index1.html new file mode 100644 index 000000000..6f0c305df --- /dev/null +++ b/test/documenteditor/main/index1.html @@ -0,0 +1,45 @@ + + + + + Documents + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/apps/documenteditor/main/js/ApplicationController.js b/test/documenteditor/main/js/ApplicationController.js similarity index 73% rename from test/apps/documenteditor/main/js/ApplicationController.js rename to test/documenteditor/main/js/ApplicationController.js index 99076fefd..9ad6f906f 100644 --- a/test/apps/documenteditor/main/js/ApplicationController.js +++ b/test/documenteditor/main/js/ApplicationController.js @@ -40,7 +40,6 @@ DE.ApplicationController = new(function(){ maxPages = 0, created = false, ttOffset = [0, -10], - labelDocName, appOptions = {}, btnSubmit, _submitFail, $submitedTooltip, $requiredTooltip, @@ -49,10 +48,6 @@ DE.ApplicationController = new(function(){ var LoadingDocument = -256; - // Initialize analytics - // ------------------------- - -// Common.Analytics.initialize('UA-12442749-13', 'Embedded Document Editor'); // Check browser @@ -77,15 +72,10 @@ DE.ApplicationController = new(function(){ common.controller.modals.init(embedConfig); // Docked toolbar - if (embedConfig.toolbarDocked === 'bottom') { - //$('#toolbar').addClass('bottom'); + if (embedConfig.toolbarDocked === 'bottom') { $('#editor_sdk').addClass('bottom'); - //$('#box-tools').removeClass('dropdown').addClass('dropup'); - ttOffset[1] = -40; } else { - //$('#toolbar').addClass('top'); $('#editor_sdk').addClass('top'); - ttOffset[1] = 40; } config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && @@ -106,7 +96,7 @@ DE.ApplicationController = new(function(){ guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ? common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest, - value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null, + value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null;//, user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous, common.localStorage.getItem("guest-id") || ('uid-' + Date.now())); user.anonymous && common.localStorage.setItem("guest-id", user.id); @@ -141,13 +131,7 @@ DE.ApplicationController = new(function(){ api.asc_setDocInfo(docInfo); api.asc_getEditorPermissions(config.licenseUrl, config.customerId); api.asc_enableKeyEvents(true); - - Common.Analytics.trackEvent('Load', 'Start'); } - - embedConfig.docTitle = docConfig.title; - labelDocName = $('#title-doc-name'); - labelDocName.text(embedConfig.docTitle || '') } } @@ -157,7 +141,7 @@ DE.ApplicationController = new(function(){ } function onCurrentPage(number) { - $('#page-number').val(number + 1); + //$('#page-number').val(number + 1); } function onLongActionBegin(type, id) { @@ -170,8 +154,8 @@ DE.ApplicationController = new(function(){ case Asc.c_oAscAsyncAction['Submit']: _submitFail = false; $submitedTooltip && $submitedTooltip.hide(); - btnSubmit.attr({disabled: true}); - btnSubmit.css("pointer-events", "none"); + /*btnSubmit.attr({disabled: true}); + btnSubmit.css("pointer-events", "none");*/ break; case LoadingDocument: text = me.textLoadingDocument + ' '; @@ -191,8 +175,8 @@ DE.ApplicationController = new(function(){ function onLongActionEnd(type, id){ if (id==Asc.c_oAscAsyncAction['Submit']) { - btnSubmit.removeAttr('disabled'); - btnSubmit.css("pointer-events", "auto"); + /*btnSubmit.removeAttr('disabled'); + btnSubmit.css("pointer-events", "auto");*/ if (!_submitFail) { if (!$submitedTooltip) { $submitedTooltip = $(''); @@ -280,14 +264,14 @@ DE.ApplicationController = new(function(){ } function onFillRequiredFields(isFilled) { - if (isFilled) { + /*if (isFilled) { btnSubmit.removeAttr('disabled'); btnSubmit.css("pointer-events", "auto"); // $requiredTooltip && $requiredTooltip.hide(); } else { btnSubmit.attr({disabled: true}); btnSubmit.css("pointer-events", "none"); - } + }*/ } function onShowContentControlsActions(obj, x, y) { @@ -392,72 +376,18 @@ DE.ApplicationController = new(function(){ 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)); - var dividers = $('#box-tools .divider'); - var itemsCount = $('#box-tools a').length; - /*if ( permissions.print === false) { - $('#idt-print').hide(); - $(dividers[0]).hide(); - itemsCount--; - } - - if ( !embedConfig.saveUrl && permissions.print === false || appOptions.canFillForms) { - $('#idt-download').hide(); - itemsCount--; - } - - if ( !appOptions.canFillForms || permissions.download === false) { - $('#idt-download-docx').hide(); - $('#idt-download-pdf').hide(); - $(dividers[0]).hide(); - $(dividers[1]).hide(); - itemsCount -= 2; - } - - if ( !embedConfig.shareUrl || appOptions.canFillForms) { - $('#idt-share').hide(); - itemsCount--; - } - - if (!config.canBackToFolder) { - $('#idt-close').hide(); - itemsCount--; - } - - if (itemsCount<3) - $(dividers[2]).hide(); - - if ( !embedConfig.embedUrl || appOptions.canFillForms) { - $('#idt-embed').hide(); - itemsCount--; - } - - if ( !embedConfig.fullscreenUrl ) { - $('#idt-fullscreen').hide(); - itemsCount--; - } - - // if ( !embedConfig.saveUrl && permissions.print === false && (!embedConfig.shareUrl || appOptions.canFillForms) && (!embedConfig.embedUrl || appOptions.canFillForms) && !embedConfig.fullscreenUrl && !config.canBackToFolder) - if (itemsCount<1) - $('#box-tools').addClass('hidden'); - else if ((!embedConfig.embedUrl || appOptions.canFillForms) && !embedConfig.fullscreenUrl) - $(dividers[2]).hide(); - - common.controller.modals.attach({ - share: '#idt-share', - embed: '#idt-embed' - });*/ api.asc_registerCallback('asc_onStartAction', onLongActionBegin); api.asc_registerCallback('asc_onEndAction', onLongActionEnd); api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart); api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd); api.asc_registerCallback('asc_onMouseMove', onDocMouseMove); - /* api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); + api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); api.asc_registerCallback('asc_onPrint', onPrint); api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); - api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields);*/ + api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields); if (appOptions.canFillForms) { api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions); api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions); @@ -468,124 +398,32 @@ DE.ApplicationController = new(function(){ Common.Gateway.on('downloadas', onDownloadAs); Common.Gateway.on('requestclose', onRequestClose); - DE.ApplicationView.tools.get('#idt-fullscreen') - .on('click', function(){ - common.utils.openLink(embedConfig.fullscreenUrl); - }); - DE.ApplicationView.tools.get('#idt-download') - .on('click', function(){ - if ( !!embedConfig.saveUrl ){ - common.utils.openLink(embedConfig.saveUrl); - } else - if (api && permissions.print!==false){ - api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); - } - - Common.Analytics.trackEvent('Save'); - }); - - DE.ApplicationView.tools.get('#idt-print') - .on('click', function(){ - api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); - Common.Analytics.trackEvent('Print'); - }); - - DE.ApplicationView.tools.get('#idt-close') - .on('click', function(){ - if (config.customization && config.customization.goback) { - if (config.customization.goback.requestClose && config.canRequestClose) - Common.Gateway.requestClose(); - else if (config.customization.goback.url) - window.parent.location.href = config.customization.goback.url; - } - }); var downloadAs = function(format){ api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); - Common.Analytics.trackEvent('Save'); }; - DE.ApplicationView.tools.get('#idt-download-docx') - .on('click', function(){ - downloadAs(Asc.c_oAscFileType.DOCX); - }); - DE.ApplicationView.tools.get('#idt-download-pdf') - .on('click', function(){ - downloadAs(Asc.c_oAscFileType.PDF); - }); - $('#id-btn-zoom-in').on('click', api.zoomIn.bind(this)); - $('#id-btn-zoom-out').on('click', api.zoomOut.bind(this)); - var $pagenum = $('#page-number'); - $pagenum.on({ - 'keyup': function(e){ - if ( e.keyCode == 13 ){ - var newPage = parseInt($('#page-number').val()); - if ( newPage > maxPages ) newPage = maxPages; - if (newPage < 2 || isNaN(newPage)) newPage = 1; - - api.goToPage(newPage-1); - $pagenum.blur(); - } - } - , 'focusin' : function(e) { - $pagenum.removeClass('masked'); - } - , 'focusout': function(e){ - !$pagenum.hasClass('masked') && $pagenum.addClass('masked'); - } - }); - - $('#pages').on('click', function(e) { - $pagenum.focus(); - }); // TODO: add asc_hasRequiredFields to sdk - if (appOptions.canSubmitForms && !api.asc_IsAllRequiredFormsFilled()) { - var sgroup = $('#id-submit-group'); - btnSubmit.attr({disabled: true}); - btnSubmit.css("pointer-events", "none"); - if (!common.localStorage.getItem("de-embed-hide-submittip")) { - var offset = btnSubmit.offset(); - $requiredTooltip = $(''); - $(document.body).append($requiredTooltip); - $requiredTooltip.css({top : offset.top + btnSubmit.height() + 'px', left: offset.left + btnSubmit.outerWidth()/2 - $requiredTooltip.outerWidth() + 'px'}); - $requiredTooltip.find('.close-div').on('click', function() { - $requiredTooltip.hide(); - api.asc_MoveToFillingForm(true, true, true); - common.localStorage.setItem("de-embed-hide-submittip", 1); - sgroup.attr('data-toggle', 'tooltip'); - sgroup.tooltip({ - title : me.textRequired, - placement : 'bottom' - }); - }); - $requiredTooltip.show(); - } else { - sgroup.attr('data-toggle', 'tooltip'); - sgroup.tooltip({ - title : me.textRequired, - placement : 'bottom' - }); - } - } + var documentMoveTimer; var ismoved = false; $(document).mousemove(function(event){ - $('#id-btn-zoom-in').fadeIn(); - $('#id-btn-zoom-out').fadeIn(); + /*$('#id-btn-zoom-in').fadeIn(); + $('#id-btn-zoom-out').fadeIn();*/ ismoved = true; if ( !documentMoveTimer ) { documentMoveTimer = setInterval(function(){ if ( !ismoved ) { - $('#id-btn-zoom-in').fadeOut(); - $('#id-btn-zoom-out').fadeOut(); + /* $('#id-btn-zoom-in').fadeOut(); + $('#id-btn-zoom-out').fadeOut();*/ clearInterval(documentMoveTimer); documentMoveTimer = undefined; } @@ -595,23 +433,10 @@ DE.ApplicationController = new(function(){ } }); Common.Gateway.documentReady(); - Common.Analytics.trackEvent('Load', 'Complete'); } function onEditorPermissions(params) { - if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && - config.customization && config.customization.logo ) { - var logo = $('#header-logo'); - if (config.customization.logo.imageEmbedded) { - logo.html(''); - logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); - } - - if (config.customization.logo.url) { - logo.attr('href', config.customization.logo.url); - } - } var licType = params.asc_getLicenseType(); appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); @@ -619,49 +444,12 @@ DE.ApplicationController = new(function(){ api.asc_setViewMode(!appOptions.canFillForms); - btnSubmit = $('#id-btn-submit'); - - if (!appOptions.canFillForms) { - $('#id-btn-prev-field').hide(); - $('#id-btn-next-field').hide(); - $('#id-btn-clear-fields').hide(); - btnSubmit.hide(); - } else { - $('#id-btn-next-field .caption').text(me.textNext); - $('#id-btn-clear-fields .caption').text(me.textClear); - - $('#id-btn-prev-field').on('click', function(){ - api.asc_MoveToFillingForm(false); - }); - $('#id-btn-next-field').on('click', function(){ - api.asc_MoveToFillingForm(true); - }); - $('#id-btn-clear-fields').on('click', function(){ - api.asc_ClearAllSpecialForms(); - }); - - if (appOptions.canSubmitForms) { - btnSubmit.find('.caption').text(me.textSubmit); - btnSubmit.on('click', function(){ - api.asc_SendForm(); - }); - } else - btnSubmit.hide(); + if (appOptions.canFillForms) { api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms); api.asc_SetFastCollaborative(true); api.asc_setAutoSaveGap(1); } - - var $parent = labelDocName.parent(); - var _left_width = $parent.position().left, - _right_width = $parent.next().outerWidth(); - - if ( _left_width < _right_width ) - $parent.css('padding-left', _right_width - _left_width); - else - $parent.css('padding-right', _left_width - _right_width); - onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); api.asc_LoadDocument(); @@ -773,8 +561,6 @@ DE.ApplicationController = new(function(){ } $('#id-critical-error-dialog').modal('show'); - - Common.Analytics.trackEvent('Internal Error', id.toString()); } function onExternalMessage(error) { @@ -783,8 +569,6 @@ DE.ApplicationController = new(function(){ $('#id-error-mask-title').text(me.criticalErrorTitle); $('#id-error-mask-text').text(error.msg); $('#id-error-mask').css('display', 'block'); - - Common.Analytics.trackEvent('External Error'); } } @@ -873,7 +657,7 @@ DE.ApplicationController = new(function(){ } }); - window["flat_desine"] = true; + window["flat_desine"] = true; api = new Asc.asc_docs_api({ 'id-view' : 'editor_sdk', 'embedded' : true diff --git a/test/documenteditor/main/js/ApplicationView.js b/test/documenteditor/main/js/ApplicationView.js new file mode 100644 index 000000000..9285bd802 --- /dev/null +++ b/test/documenteditor/main/js/ApplicationView.js @@ -0,0 +1,50 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +if (DE === undefined) { + var DE = {}; +} + +DE.ApplicationView = new(function(){ + + + // Initialize view + + function createView(){ + + } + + return { + create: createView + + } +})(); diff --git a/test/apps/documenteditor/main/js/application.js b/test/documenteditor/main/js/application.js similarity index 100% rename from test/apps/documenteditor/main/js/application.js rename to test/documenteditor/main/js/application.js diff --git a/test/documenteditor/main/locale/en.json b/test/documenteditor/main/locale/en.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/documenteditor/main/locale/en.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/documenteditor/main/resources/less/application.less b/test/documenteditor/main/resources/less/application.less new file mode 100644 index 000000000..07eafc900 --- /dev/null +++ b/test/documenteditor/main/resources/less/application.less @@ -0,0 +1,2 @@ +// Common styles +@import "../../../../unit-tests/common/main/resources/less/common.less"; \ No newline at end of file diff --git a/test/apps/presentationeditor/main/index.html b/test/presentationeditor/main/index.html similarity index 100% rename from test/apps/presentationeditor/main/index.html rename to test/presentationeditor/main/index.html diff --git a/test/apps/spreadsheeteditor/main/index.html b/test/spreadsheeteditor/main/index.html similarity index 100% rename from test/apps/spreadsheeteditor/main/index.html rename to test/spreadsheeteditor/main/index.html diff --git a/test/unit-tests/common/main/lib/controller/modals.js b/test/unit-tests/common/main/lib/controller/modals.js new file mode 100644 index 000000000..d8802955a --- /dev/null +++ b/test/unit-tests/common/main/lib/controller/modals.js @@ -0,0 +1,143 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + ++function () { + !window.common && (window.common = {}); + !common.controller && (common.controller = {}); + + common.controller.modals = new(function() { + var $dlgShare, $dlgEmbed; + var appConfig; + var embedCode = '', + minEmbedWidth = 400, + minEmbedHeight = 600; + + function copytext(el, event) { + el.select(); + if ( !document.execCommand('copy') ) { + window.alert('Browser\'s error! Use keyboard shortcut [Ctrl] + [C]'); + } + } + + var createDlgShare = function () { + $dlgShare = common.view.modals.create('share'); + + var _encoded = encodeURIComponent(appConfig.shareUrl); + var _mailto = 'mailto:?subject=I have shared a document with you: ' + appConfig.docTitle + '&body=I have shared a document with you: ' + _encoded; + + $dlgShare.find('#btn-copyshort').on('click', copytext.bind(this, $dlgShare.find('#id-short-url'))); + $dlgShare.find('.share-buttons > span').on('click', function(e){ + var _url; + switch ($(e.target).attr('data-name')) { + case 'facebook': + _url = 'https://www.facebook.com/sharer/sharer.php?u=' + appConfig.shareUrl + '&t=' + encodeURI(appConfig.docTitle); + window.open(_url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600'); + break; + case 'twitter': + _url = 'https://twitter.com/share?url='+ _encoded; + !!appConfig.docTitle && (_url += encodeURIComponent('&text=' + appConfig.docTitle)); + window.open(_url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600'); + break; + case 'email': + window.open(_mailto, '_self'); + break; + } + }); + + $dlgShare.find('#id-short-url').val(appConfig.shareUrl); + $dlgShare.find('.share-buttons > #email.autotest').attr('data-test', _mailto); + }; + + var createDlgEmbed =function () { + $dlgEmbed = common.view.modals.create('embed'); + + var txtembed = $dlgEmbed.find('#txt-embed-url'); + txtembed.text(embedCode.replace('{embed-url}', appConfig.embedUrl).replace('{width}', minEmbedWidth).replace('{height}', minEmbedHeight)); + $dlgEmbed.find('#btn-copyembed').on('click', copytext.bind(this, txtembed)); + $dlgEmbed.find('#txt-embed-width, #txt-embed-height').on({ + 'keypress': function(e){ + if (e.keyCode == 13) + updateEmbedCode(); + } + , 'focusout': function(e){ + updateEmbedCode(); + } + }); + }; + + function updateEmbedCode(){ + var $txtwidth = $dlgEmbed.find('#txt-embed-width'); + var $txtheight = $dlgEmbed.find('#txt-embed-height'); + var newWidth = parseInt($txtwidth.val()), + newHeight = parseInt($txtheight.val()); + + if (newWidth < minEmbedWidth) + newWidth = minEmbedWidth; + + if (newHeight < minEmbedHeight) + newHeight = minEmbedHeight; + + $dlgEmbed.find('#txt-embed-url').text(embedCode.replace('{embed-url}', appConfig.embedUrl).replace('{width}', newWidth).replace('{height}', newHeight)); + + $txtwidth.val(newWidth + 'px'); + $txtheight.val(newHeight + 'px'); + } + + var attachToView = function(config) { + if ( config.share && !!appConfig.shareUrl ) { + if ( !$dlgShare ) { + createDlgShare(); + } + + $(config.share).on('click', function(e){ + $dlgShare.modal('show'); + }); + } + + if ( config.embed && !!appConfig.embedUrl ) { + if ( !$dlgEmbed ) { + createDlgEmbed(); + } + + $(config.embed).on('click', function(e) { + $dlgEmbed.modal('show'); + }) + } + }; + + return { + init: function(config) { appConfig = config; } + , attach: attachToView + }; + }); +}(); \ No newline at end of file diff --git a/test/unit-tests/common/main/lib/util/utils.js b/test/unit-tests/common/main/lib/util/utils.js index d9b9b3c97..2d275b85e 100644 --- a/test/unit-tests/common/main/lib/util/utils.js +++ b/test/unit-tests/common/main/lib/util/utils.js @@ -1,33 +1,106 @@ -/** - * utils.js +/* * - * Unit test + * (c) Copyright Ascensio System SIA 2010-2019 * - * Created by Alexander Yuzhin on 5/7/14 - * Copyright (c) 2018 Ascensio System SIA. All rights reserved. + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -define([ - '../../../../../apps/common/main/lib/util/utils.js' -],function() { - describe('Common.Utils.String', function(){ - it('Test format', function(){ - assert.equal('successively: first, second', Common.Utils.String.format('successively: {0}, {1}', 'first', 'second')); - assert.equal('revers: second, first', Common.Utils.String.format('revers: {1}, {0}', 'first', 'second')); - }); ++function () { + !window.common && (window.common = {}); + !common.utils && (common.utils = {}); - it('Test htmlEncode', function(){ - assert.equal('Curly, Larry & Moe', Common.Utils.String.htmlEncode('Curly, Larry & Moe')); - }); + common.utils = new(function(){ + return { + openLink: function(url) { + if (url) { + var newDocumentPage = window.open(url, '_blank'); + if (newDocumentPage) + newDocumentPage.focus(); + } + } + , dialogPrint: function(url, api) { + $('#id-print-frame').remove(); - it('Test htmlDecode', function(){ - assert.equal('Curly, Larry & Moe', Common.Utils.String.htmlDecode('Curly, Larry & Moe')); - }); + if ( !!url ) { + var iframePrint = document.createElement("iframe"); - it('Test ellipsis', function(){ - assert.equal('Truncate a s...', Common.Utils.String.ellipsis('Truncate a string and add an ellipsis', 15)); - assert.equal('Truncate a string and add...', Common.Utils.String.ellipsis('Truncate a string and add an ellipsis', 30, true)); - }); - }); -}); \ No newline at end of file + iframePrint.id = "id-print-frame"; + iframePrint.style.display = 'none'; + iframePrint.style.visibility = "hidden"; + iframePrint.style.position = "fixed"; + iframePrint.style.right = "0"; + iframePrint.style.bottom = "0"; + document.body.appendChild(iframePrint); + + iframePrint.onload = function () { + try { + iframePrint.contentWindow.focus(); + iframePrint.contentWindow.print(); + iframePrint.contentWindow.blur(); + window.focus(); + } catch (e) { + api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF)); + } + }; + + iframePrint.src = url; + } + }, + htmlEncode: function(value) { + return $('
    ').text(value).html(); + }, + + fillUserInfo: function(info, lang, defname, defid) { + var _user = info || {}; + _user.anonymous = !_user.id; + !_user.id && (_user.id = defid); + _user.fullname = !_user.name ? defname : _user.name; + _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/test/unit-tests/common/main/lib/view/modals.js b/test/unit-tests/common/main/lib/view/modals.js new file mode 100644 index 000000000..8f9c9760d --- /dev/null +++ b/test/unit-tests/common/main/lib/view/modals.js @@ -0,0 +1,102 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ + +!window.common && (window.common = {}); +!common.view && (common.view = {}); +common.view.modals = new(function() { + var tplDialog = ''; + + var _tplbody_share = '' + + ''; + + var _tplbody_embed = '
    ' + + '{width}:' + + '' + + '' + + '{height}:' + + '
    ' + + ''; + + return { + create: function(name, parent) { + !parent && (parent = 'body'); + + var _$dlg; + if (name == 'share') { + _$dlg = $(tplDialog + .replace(/\{title}/, this.txtShare) + .replace(/\{body}/, _tplbody_share) + .replace(/\{footer}/, '')) + .appendTo(parent) + .attr('id', 'dlg-share'); + } else + if (name == 'embed') { + _$dlg = $(tplDialog + .replace(/\{title}/, this.txtEmbed) + .replace(/\{body}/, _tplbody_embed) + .replace(/\{width}/, this.txtWidth) + .replace(/\{height}/, this.txtHeight) + .replace(/\{footer}/, '')) + .appendTo(parent) + .attr('id', 'dlg-embed'); + } + + return _$dlg; + }, + txtWidth: 'Width', + txtHeight: 'Height', + txtShare: 'Share Link', + txtCopy: 'Copy to clipboard', + txtEmbed: 'Embed' + }; +})(); diff --git a/test/unit-tests/common/main/resources/img/icon-menu-sprite.svg b/test/unit-tests/common/main/resources/img/icon-menu-sprite.svg new file mode 100644 index 000000000..97b51fd3e --- /dev/null +++ b/test/unit-tests/common/main/resources/img/icon-menu-sprite.svg @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/unit-tests/common/main/resources/img/icon-social-sprite.svg b/test/unit-tests/common/main/resources/img/icon-social-sprite.svg new file mode 100644 index 000000000..500662ae7 --- /dev/null +++ b/test/unit-tests/common/main/resources/img/icon-social-sprite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/unit-tests/common/main/resources/img/logo.svg b/test/unit-tests/common/main/resources/img/logo.svg new file mode 100644 index 000000000..0d3cb18e7 --- /dev/null +++ b/test/unit-tests/common/main/resources/img/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/unit-tests/common/main/resources/img/next-field.png b/test/unit-tests/common/main/resources/img/next-field.png new file mode 100644 index 0000000000000000000000000000000000000000..ee043c87821f62d56be8c8fee0602c00486bb31b GIT binary patch literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^7C z9OUlAu=X{Nfl8?MbtTeT}odeyI7+ly_hYCqXKGuyo_ zKJcLB!G7T;dPCAAC=nVgB=#KJOJMR|t5 zpFHD1os;txG)yR&vtYxddDa>RURLiFRCi8yeP12EZvCWPlU?W61V-6 SKfN31M+Q$ z9OUlAu6F7R)Lt=yzi2M$G+dd>JZ1*)DB#_Hb`Pt7)d=)C3Jmz07J*>k1+ z^tj|=MfNnYzqztI`5wpF%4v6JY&f$?&}`L#KQ$p~k2sif9S@~H@Gn0-Ta-QQ>5e;B zD`z#eyf0#re!1ZOG-U}7ZlRh}XJ?+3x0tG(ZTgvGSMiJLT#0jwW*7OE3cif|!Y9vc zC1v!+;lpp2**5lpyoXr5-%0-Pl}kR-p9X>T#)66)&zx Sxoigdk-^i|&t;ucLK6Uyr+q8{ literal 0 HcmV?d00001 diff --git a/test/unit-tests/common/main/resources/less/common.less b/test/unit-tests/common/main/resources/less/common.less new file mode 100644 index 000000000..e9ac9315e --- /dev/null +++ b/test/unit-tests/common/main/resources/less/common.less @@ -0,0 +1,788 @@ +// Core variables and mixins +@import "../../../../../../vendor/bootstrap/less/variables.less"; + +@icon-font-path: "../../../../../../vendor/bootstrap/dist/fonts/"; + +@import "../../../../../../vendor/bootstrap/less/mixins.less"; + +// Reset +@import "../../../../../../vendor/bootstrap/less/normalize.less"; +@import "../../../../../../vendor/bootstrap/less/print.less"; + +// Core CSS +@import "../../../../../../vendor/bootstrap/less/scaffolding.less"; +@import "../../../../../../vendor/bootstrap/less/type.less"; +//@import "code.less"; +//@import "grid.less"; +//@import "tables.less"; +@import "../../../../../../vendor/bootstrap/less/forms.less"; +@import "../../../../../../vendor/bootstrap/less/buttons.less"; + +// Components +@import "../../../../../../vendor/bootstrap/less/component-animations.less"; +//@import "../../../../../../vendor/bootstrap/less/glyphicons.less"; +//@import "dropdowns.less"; +//@import "button-groups.less"; +//@import "input-groups.less"; +//@import "navs.less"; +//@import "navbar.less"; +//@import "breadcrumbs.less"; +//@import "pagination.less"; +//@import "pager.less"; +@import "../../../../../../vendor/bootstrap/less/labels.less"; +//@import "badges.less"; +//@import "jumbotron.less"; +//@import "thumbnails.less"; +@import "../../../../../../vendor/bootstrap/less/alerts.less"; +//@import "progress-bars.less"; +//@import "media.less"; +//@import "list-group.less"; +//@import "panels.less"; +//@import "wells.less"; +@import "../../../../../../vendor/bootstrap/less/close.less"; + +// Components w/ JavaScript +@import "../../../../../../vendor/bootstrap/less/modals.less"; +@import "../../../../../../vendor/bootstrap/less/tooltip.less"; +//@import "../../../../../../vendor/bootstrap/less/popovers.less"; +@import "../../../../../../vendor/bootstrap/less/dropdowns.less"; +//@import "carousel.less"; + +// Utility classes +@import "../../../../../../vendor/bootstrap/less/utilities.less"; +@import "../../../../../../vendor/bootstrap/less/responsive-utilities.less"; + + +@import "loadmask.less"; + +@toolbarBorderColor: #dbdbdb; +@toolbarBorderShadowColor: #FAFAFA; +@toolbarTopColor: #F7F7F7; +@toolbarBottomColor: #CCCCCC; +@toolbarHoverColor: #7698DE; +@toolbarFontSize: 12px; +@buttonFontSize: 11px; +@controlBtnHoverTopColor: #6180C4; +@controlBtnHoverBottomColor: #8AACF1; +@btnColor: #d8dadc; +@btnActiveColor: #7d858c; +@btnColored: #446995; +@btnActiveColored: #293F59; +@btnHoverColored: #375478; +@notificationColor: #fcfed7; + +@iconSpriteCommonPath: "../../../../unit-tests/common/main/resources/img/glyphicons.png"; +@icon-socnet-size: 40px; + +.input-xs { + .input-size(@input-height-small - 8px; @padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small); +} + +.embed-body { + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + + font-size: @toolbarFontSize; + overflow: hidden; +} + +// Document Viewer +// ------------------------- +.viewer { + position: absolute; + margin: 0; + padding: 0; + left: 0; + right: 0; + + &.top { + top: 48px; + bottom: 0; + } + + &.bottom { + top: 0; + bottom: 46px; + } +} + +// Toolbar +// ------------------------- +.toolbar { + position: fixed; + font-size: @toolbarFontSize; + min-width: 340px; + z-index: 100; + background-color: @toolbarTopColor; + + display: flex; + align-items: center; + white-space: nowrap; + + &.top { + top: 0; + left: 0; + width: 100%; + height: 48px; + + -webkit-box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor; + //-moz-box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor; + box-shadow: inset 0 -1px 0 @toolbarBorderColor, inset 0 1px 0 @toolbarBorderShadowColor; + } + + &.bottom { + bottom: 0; + left: 0; + width: 100%; + height: 46px; + + -webkit-box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor; + //-moz-box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor; + box-shadow: inset 0 1px 0 @toolbarBorderColor, inset 0 2px 0 @toolbarBorderShadowColor; + } + + .group { + margin: 0; + padding: 0; + + .item { + input { + display: inline-block; + width: 35px; + padding: 0; + text-align: right; + } + + .text { + cursor: default; + } + } + + &.left { + left: 0; + padding-left: 10px; + + .item { + float: left; + } + + & > div { + display: inline-block; + vertical-align: middle; + } + } + + &.right { + right: 0; + padding-right: 10px; + + .item { + display: inline-block; + } + } + + &.center { + display: flex; + justify-content: center; + flex-grow: 1; + overflow: hidden; + padding: 0 20px; + + #title-doc-name { + overflow: hidden; + text-overflow: ellipsis; + } + } + + .separator { + height: 22px; + margin: 0 9px; + border-right: 1px solid @toolbarBorderShadowColor; + border-left: 1px solid @toolbarBorderColor; + } + } + + .close { + font-size: 28px; + font-family: Arial, sans-serif; + color: #666666; + opacity: 0.8; + display: block; + line-height: 22px; + + &:hover { + opacity: 1; + color: #666666; + } + } + + .margin-right-small { + margin-right: 8px; + } + .margin-right-large { + margin-right: 12px; + } + .margin-left-small { + margin-left: 8px; + } + .margin-left-large { + margin-left: 12px; + } +} + +// Logo +// ------------------------- +.brand-logo { + display: block; + width: 100px; + height: 24px; + background: data-uri('../../../../unit-tests/common/main/resources/img/logo.svg') no-repeat; +} + +// Control buttons +// ------------------------- +.control-btn { + display: inline-block; + vertical-align: middle; + cursor: pointer; + background-color: transparent; + border: 1px solid transparent; + border-radius: 2px; + + width: 22px; + height: 22px; + background-origin: content-box; + padding: 0 1px; + font-size: @buttonFontSize; + + &.has-caption { + width: auto; + padding-right: 5px; + } + + &.colored { + padding: 0 16px; + height: 28px; + background-color: @btnColored; + border-radius: 3px; + color: #ffffff; + font-weight: 700; + } + + // Hover state + &:hover:not(:disabled) { + text-decoration: none; + background-color: @btnColor; + + &.colored { + background-color: @btnHoverColored; + } + } + + &:active:not(:disabled) { + &, .btn-icon { + background-position-y: -@icon-height !important; + } + + &.has-caption { + color: #ffffff + } + + &.colored { + background-color: @btnActiveColored; + } + } + +// Focus state for keyboard and accessibility + &:focus { + .tab-focus(); + outline: none; + } + +// Active state + &.active:not(:disabled), + &:active:not(:disabled) { + outline: none; + border: 1px solid @btnActiveColor; + background-color: @btnActiveColor; + } + + &[disabled] { + opacity: 0.4; + } +} + +// Overlay control +// ------------------------- +.overlay-controls { + position: absolute; + bottom: 55px; + z-index: 10; + left: 50%; + + ul { + padding: 0; + list-style-type: none; + margin: 0 auto; + + li { + display: inline-block; + + &:first-child { + margin-right: 5px; + } + + &:last-child { + margin-left: 5px; + } + } + } + + .overlay { + width: 32px; + height: 32px; + + display: inline-block; + cursor: pointer; + background-color: black; + border: 5px solid black; + border-radius: 50%; + outline: none; + opacity: 0.3; + + background-origin: content-box; + padding: 1px 0 0 1px; + + -webkit-box-shadow: 0 0 0 2px rgba(255,255,255,0.3); + -moz-box-shadow: 0 0 0 2px rgba(255,255,255,0.3); + box-shadow: 0 0 0 2px rgba(255,255,255,0.3); + + &:hover { + opacity: .6; + } + + &.active, &:active { + opacity: .8; + } + } +} + +// Error mask +// ------------------------- +.errormask { + position: absolute; + left: 0; + top: 0; + height: 100%; + width: 100%; + overflow: hidden; + border: none; + background-color: #f4f4f4; + z-index: 30002; + + .error-body { + position: relative; + top: 40%; + width: 400px; + margin: 0 auto; + padding: 20px; + background-color: #FFFFFF; + border: 1px solid #C0C0C0; + + .title { + font-weight: bold; + font-size: 1.6em; + padding-bottom: 10px; + } + } +} + +// Modals +// ------------------------- +.modal { + .modal-header { + //padding: 5px 15px; + } + + .modal-footer { + //border-top: none; + } + + //&.in .modal-dialog { .translate(0, 100%)} +} + +.share-buttons { + ul { + width: 244px; + //height: 25px; + list-style-type: none; + margin: 5px 0 0; + overflow: hidden; + + li { + display: inline-block; + float: left; + margin: 1px 5px 0 0; + vertical-align: middle; + + &.share-mail { + float: right; + padding-right: 1px; + margin: 0; + + a { + min-width: 64px; + } + + .glyphicon { + margin-right: 4px; + } + } + + &.share-twitter { + max-width: 93px; + } + } + } +} + +.size-manual { + margin-bottom: 10px; + + .right { + float: right; + } + + .caption { + margin-top: 2px; + margin-right: 8px; + } + + input { + display: inline-block; + font-size: 1em; + padding: 0 4px; + //border-radius: 0; + margin: 0; + margin-top: -1px; + + &.input-xs { + width: 50px; + } + } +} + +.socnet-btn(@index) { + background-position: -@icon-socnet-size*@index 0; + + &:hover { + background-position: -@icon-socnet-size*@index -@icon-socnet-size; + } +} + +.svg { + background: data-uri('../../../../unit-tests/common/main/resources/img/icon-social-sprite.svg'); + + width: 40px; + height: 40px; + background-size: @icon-socnet-size*4 @icon-socnet-size*2; + + &.big-facebook:hover { + background-position: 0 -@icon-socnet-size; + } + + &.big-twitter { .socnet-btn(1); } + &.big-gplus { .socnet-btn(2); } + &.big-email { .socnet-btn(3); } +} + +@icon-width: 20px; +@icon-height: 20px; +.svg-icon { + background: data-uri('../../../../unit-tests/common/main/resources/img/icon-menu-sprite.svg') no-repeat; + background-size: @icon-width*19 @icon-height*2; + + &.download { + background-position: -@icon-width 0; + } + &.share { + background-position: -@icon-width*2 0; + } + &.embed { + background-position: -@icon-width*3 0; + } + &.fullscr { + background-position: -@icon-width*4 0; + } + &.zoom-up { + background-position: -@icon-width*5 -@icon-height; + } + &.zoom-down { + background-position: -@icon-width*6 -@icon-height; + } + &.slide-prev { + background-position: -@icon-width*7 -@icon-height; + } + &.slide-next { + background-position: -@icon-width*8 -@icon-height; + } + + &.play { + background-position: -@icon-width*9 -@icon-height; + } + + &.pause { + background-position: -@icon-width*10 -@icon-height; + } + + &.print { + background-position: -@icon-width*11 0; + } + + &.arrow-up { + background-position: -@icon-width*17 0; + } + &.arrow-down { + background-position: -@icon-width*16 0; + } + &.clear-style { + background-position: -@icon-width*12 0; + } + &.go-to-location { + background-position: -@icon-width*15 0; + } + &.more-vertical { + background-position: -@icon-width*14 0; + } +} + +.mi-icon { + width: @icon-width; + height: @icon-height; + float: left; + margin: -3px 4px 0 -24px; +} +.btn-icon { + width: 22px; + height: 22px; + display: inline-block; + vertical-align: middle; +} + +.btn, button { + &:focus, &:active:focus { + outline: 0 none; + } + + background-color: @btnColor; +} + +.modal-dialog { + margin-top: 100px; + .share-buttons { + height: 40px; + text-align: center; + + span { + display: inline-block; + margin: 0 7px; + cursor: pointer; + } + } + + .share-link { + margin: 0 0 15px 0; + } +} + +.modal-header { + padding-bottom: 10px; + text-align: center; + + .close { + margin-top: 0; + opacity: 0.5; + + &:hover { + opacity: 0.7; + } + } +} + +.modal-body { + padding: 20px; +} + +.modal-footer { + text-align: center; +} + +#dlg-share, #dlg-embed { + .modal-dialog { + width: 330px; + } + + textarea { + width: 288px; + resize: none; + cursor: auto; + font-size: 1em; + border-radius: 0; + } +} + +.dropdown-menu { + > li > a { + padding: 8px 20px 8px 28px; + &:hover, &:focus { + background-color: @btnColor; + outline: 0 none; + } + font-size: @buttonFontSize; + } + + .divider { + margin: 4px 0; + } +} + +.dropdown { + &.open { + > button { + background-color: @btnActiveColor !important; + background-position: -@icon-width*14 -@icon-height; + } + } +} + +#box-tools { + display: inline-block; + a { + cursor: pointer; + } +} + +.masked { + background-color: transparent; + border-color: transparent; + -webkit-box-shadow: none; + box-shadow: none; +} + +#pages { + cursor: pointer; + display: inline-block; + line-height: 22px; + padding: 0 0 0 3px; +} + +#page-number { + &.masked { + cursor: pointer; + } +} + +.tooltip { + .tooltip-inner { + background-color: #fff; + border: 1px solid rgba(0,0,0,0.15); + color: #333; + font-weight: bold; + font-size: 11px; + box-shadow: 0 6px 12px rgba(0,0,0,0.175); + max-width: 350px; + + padding: 5px 12px; + white-space: pre-wrap; + text-align: left; + word-wrap: break-word; + } + + .tooltip-arrow { + display: none; + } +} + +.form-control { + &:focus { + -webkit-box-shadow: none; + box-shadow: none; + } +} + +.submit-tooltip { + position: absolute; + z-index: 1000; + top: 58px; + right: 15px; + + padding: 7px 15px; + border-radius: 5px; + background-color: @notificationColor; + -webkit-box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.5); + box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.5); + font-size: 11px; +} + +.required-tooltip { + position: absolute; + z-index: 1000; + + padding: 15px; + border-radius: 5px; + background-color: @btnColored; + color: #fff; + -webkit-box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.5); + box-shadow: 0 4px 15px -2px rgba(0, 0, 0, 0.5); + font-size: 11px; + + &.bottom-left { + border-top-right-radius: 0; + margin: 15px 0 0 0; + + .tip-arrow { + position: absolute; + overflow: hidden; + right: 0; + top: -15px; + width: 15px; + height: 15px; + .box-shadow(8px 5px 8px -5px rgba(0, 0, 0, 0.2)); + + &:after { + content: ''; + position: absolute; + top: 8px; + left: 8px; + background-color: @btnColored; + width: 15px; + height: 15px; + + -moz-transform: rotate(45deg); + -ms-transform: rotate(45deg); + -webkit-transform: rotate(45deg); + -o-transform: rotate(45deg); + transform: rotate(45deg); + .box-shadow(0 0 8px -1px rgba(0, 0, 0, 0.2)); + } + } + } + .close-div { + display: inline-block; + border: 1px solid #fff; + border-radius: 2px; + padding: 3px 12px; + margin-top: 10px; + } +} + +.tooltip { + .tooltip-inner { + .toolbar & { + font-weight: normal; + } + } +} \ No newline at end of file diff --git a/test/unit-tests/common/main/resources/less/loadmask.less b/test/unit-tests/common/main/resources/less/loadmask.less new file mode 100644 index 000000000..26d068654 --- /dev/null +++ b/test/unit-tests/common/main/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; +} From 8c723396125691f532756e3b31b64069940f36f3 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Thu, 2 Sep 2021 02:26:43 +0300 Subject: [PATCH 04/26] unlock edit-function --- test/documenteditor/main/index.html | 2 - .../main/js/ApplicationController.js | 49 +++--- .../common/main/lib/controller/modals.js | 143 ------------------ .../unit-tests/common/main/lib/view/modals.js | 102 ------------- 4 files changed, 18 insertions(+), 278 deletions(-) delete mode 100644 test/unit-tests/common/main/lib/controller/modals.js delete mode 100644 test/unit-tests/common/main/lib/view/modals.js diff --git a/test/documenteditor/main/index.html b/test/documenteditor/main/index.html index a203ed37c..9e591c035 100644 --- a/test/documenteditor/main/index.html +++ b/test/documenteditor/main/index.html @@ -129,8 +129,6 @@ - - diff --git a/test/documenteditor/main/js/ApplicationController.js b/test/documenteditor/main/js/ApplicationController.js index 9ad6f906f..4ff7a740f 100644 --- a/test/documenteditor/main/js/ApplicationController.js +++ b/test/documenteditor/main/js/ApplicationController.js @@ -42,7 +42,7 @@ DE.ApplicationController = new(function(){ ttOffset = [0, -10], appOptions = {}, btnSubmit, - _submitFail, $submitedTooltip, $requiredTooltip, + _submitFail, $submitedTooltip, $listControlMenu, listControlItems = [], listObj, bodyWidth = 0; @@ -67,19 +67,11 @@ DE.ApplicationController = new(function(){ function loadConfig(data) { config = $.extend(config, data.config); - embedConfig = $.extend(embedConfig, data.config.embedded); - common.controller.modals.init(embedConfig); - - // Docked toolbar - if (embedConfig.toolbarDocked === 'bottom') { - $('#editor_sdk').addClass('bottom'); - } else { $('#editor_sdk').addClass('top'); - } - config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && - (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose); + /*config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && + (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose);*/ } function loadDocument(data) { @@ -115,10 +107,11 @@ DE.ApplicationController = new(function(){ docInfo.put_Permissions(_permissions); docInfo.put_EncryptedInfo(config.encryptionKeys); - var enable = !config.customization || (config.customization.macros!==false); + /*var enable = !config.customization || (config.customization.macros!==false); docInfo.asc_putIsEnabledMacroses(!!enable); enable = !config.customization || (config.customization.plugins!==false); - docInfo.asc_putIsEnabledPlugins(!!enable); + docInfo.asc_putIsEnabledPlugins(!!enable);*/ + var type = /^(?:(pdf|djvu|xps))$/.exec(docConfig.fileType); if (type && typeof type[1] === 'string') { @@ -137,11 +130,6 @@ DE.ApplicationController = new(function(){ function onCountPages(count) { maxPages = count; - $('#pages').text(me.textOf + " " + count); - } - - function onCurrentPage(number) { - //$('#page-number').val(number + 1); } function onLongActionBegin(type, id) { @@ -388,11 +376,11 @@ DE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onPrint', onPrint); api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields); - if (appOptions.canFillForms) { + /*if (appOptions.canFillForms) { api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions); api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions); api.asc_SetHighlightRequiredFields(true); - } + }*/ Common.Gateway.on('processmouse', onProcessMouse); Common.Gateway.on('downloadas', onDownloadAs); @@ -439,17 +427,17 @@ DE.ApplicationController = new(function(){ var licType = params.asc_getLicenseType(); appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit); - appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); + //appOptions.canFillForms = appOptions.canLicense && (permissions.fillForms===true) && (config.mode !== 'view'); appOptions.canSubmitForms = appOptions.canLicense && (typeof (config.customization) == 'object') && !!config.customization.submitForm; - api.asc_setViewMode(!appOptions.canFillForms); + //api.asc_setViewMode(!appOptions.canFillForms); + //api.asc_setViewMode(false); + /*if (appOptions.canFillForms) {*/ - if (appOptions.canFillForms) { - - api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms); - api.asc_SetFastCollaborative(true); + //api.asc_setRestriction(Asc.c_oAscRestrictionType.OnlyForms); + //api.asc_SetFastCollaborative(true); api.asc_setAutoSaveGap(1); - } + /*}*/ onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); api.asc_LoadDocument(); @@ -468,7 +456,7 @@ DE.ApplicationController = new(function(){ $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ window.location.reload(); }); - $('#id-critical-error-dialog').css('z-index', 20002).modal('show'); + //$('#id-critical-error-dialog').css('z-index', 20002).modal('show'); return; } @@ -660,7 +648,7 @@ DE.ApplicationController = new(function(){ window["flat_desine"] = true; api = new Asc.asc_docs_api({ 'id-view' : 'editor_sdk', - 'embedded' : true + 'embedded' : true/**/ }); if (api){ @@ -669,8 +657,7 @@ DE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); api.asc_registerCallback('asc_onCountPages', onCountPages); -// api.asc_registerCallback('OnCurrentVisiblePage', onCurrentPage); - api.asc_registerCallback('asc_onCurrentPage', onCurrentPage); + // Initialize api gateway Common.Gateway.on('init', loadConfig); diff --git a/test/unit-tests/common/main/lib/controller/modals.js b/test/unit-tests/common/main/lib/controller/modals.js deleted file mode 100644 index d8802955a..000000000 --- a/test/unit-tests/common/main/lib/controller/modals.js +++ /dev/null @@ -1,143 +0,0 @@ -/* - * - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ - -+function () { - !window.common && (window.common = {}); - !common.controller && (common.controller = {}); - - common.controller.modals = new(function() { - var $dlgShare, $dlgEmbed; - var appConfig; - var embedCode = '', - minEmbedWidth = 400, - minEmbedHeight = 600; - - function copytext(el, event) { - el.select(); - if ( !document.execCommand('copy') ) { - window.alert('Browser\'s error! Use keyboard shortcut [Ctrl] + [C]'); - } - } - - var createDlgShare = function () { - $dlgShare = common.view.modals.create('share'); - - var _encoded = encodeURIComponent(appConfig.shareUrl); - var _mailto = 'mailto:?subject=I have shared a document with you: ' + appConfig.docTitle + '&body=I have shared a document with you: ' + _encoded; - - $dlgShare.find('#btn-copyshort').on('click', copytext.bind(this, $dlgShare.find('#id-short-url'))); - $dlgShare.find('.share-buttons > span').on('click', function(e){ - var _url; - switch ($(e.target).attr('data-name')) { - case 'facebook': - _url = 'https://www.facebook.com/sharer/sharer.php?u=' + appConfig.shareUrl + '&t=' + encodeURI(appConfig.docTitle); - window.open(_url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600'); - break; - case 'twitter': - _url = 'https://twitter.com/share?url='+ _encoded; - !!appConfig.docTitle && (_url += encodeURIComponent('&text=' + appConfig.docTitle)); - window.open(_url, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600'); - break; - case 'email': - window.open(_mailto, '_self'); - break; - } - }); - - $dlgShare.find('#id-short-url').val(appConfig.shareUrl); - $dlgShare.find('.share-buttons > #email.autotest').attr('data-test', _mailto); - }; - - var createDlgEmbed =function () { - $dlgEmbed = common.view.modals.create('embed'); - - var txtembed = $dlgEmbed.find('#txt-embed-url'); - txtembed.text(embedCode.replace('{embed-url}', appConfig.embedUrl).replace('{width}', minEmbedWidth).replace('{height}', minEmbedHeight)); - $dlgEmbed.find('#btn-copyembed').on('click', copytext.bind(this, txtembed)); - $dlgEmbed.find('#txt-embed-width, #txt-embed-height').on({ - 'keypress': function(e){ - if (e.keyCode == 13) - updateEmbedCode(); - } - , 'focusout': function(e){ - updateEmbedCode(); - } - }); - }; - - function updateEmbedCode(){ - var $txtwidth = $dlgEmbed.find('#txt-embed-width'); - var $txtheight = $dlgEmbed.find('#txt-embed-height'); - var newWidth = parseInt($txtwidth.val()), - newHeight = parseInt($txtheight.val()); - - if (newWidth < minEmbedWidth) - newWidth = minEmbedWidth; - - if (newHeight < minEmbedHeight) - newHeight = minEmbedHeight; - - $dlgEmbed.find('#txt-embed-url').text(embedCode.replace('{embed-url}', appConfig.embedUrl).replace('{width}', newWidth).replace('{height}', newHeight)); - - $txtwidth.val(newWidth + 'px'); - $txtheight.val(newHeight + 'px'); - } - - var attachToView = function(config) { - if ( config.share && !!appConfig.shareUrl ) { - if ( !$dlgShare ) { - createDlgShare(); - } - - $(config.share).on('click', function(e){ - $dlgShare.modal('show'); - }); - } - - if ( config.embed && !!appConfig.embedUrl ) { - if ( !$dlgEmbed ) { - createDlgEmbed(); - } - - $(config.embed).on('click', function(e) { - $dlgEmbed.modal('show'); - }) - } - }; - - return { - init: function(config) { appConfig = config; } - , attach: attachToView - }; - }); -}(); \ No newline at end of file diff --git a/test/unit-tests/common/main/lib/view/modals.js b/test/unit-tests/common/main/lib/view/modals.js deleted file mode 100644 index 8f9c9760d..000000000 --- a/test/unit-tests/common/main/lib/view/modals.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * (c) Copyright Ascensio System SIA 2010-2019 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * -*/ - -!window.common && (window.common = {}); -!common.view && (common.view = {}); -common.view.modals = new(function() { - var tplDialog = ''; - - var _tplbody_share = '' + - ''; - - var _tplbody_embed = '
    ' + - '{width}:' + - '' + - '' + - '{height}:' + - '
    ' + - ''; - - return { - create: function(name, parent) { - !parent && (parent = 'body'); - - var _$dlg; - if (name == 'share') { - _$dlg = $(tplDialog - .replace(/\{title}/, this.txtShare) - .replace(/\{body}/, _tplbody_share) - .replace(/\{footer}/, '')) - .appendTo(parent) - .attr('id', 'dlg-share'); - } else - if (name == 'embed') { - _$dlg = $(tplDialog - .replace(/\{title}/, this.txtEmbed) - .replace(/\{body}/, _tplbody_embed) - .replace(/\{width}/, this.txtWidth) - .replace(/\{height}/, this.txtHeight) - .replace(/\{footer}/, '')) - .appendTo(parent) - .attr('id', 'dlg-embed'); - } - - return _$dlg; - }, - txtWidth: 'Width', - txtHeight: 'Height', - txtShare: 'Share Link', - txtCopy: 'Copy to clipboard', - txtEmbed: 'Embed' - }; -})(); From 7e70f650ca3d59a78f80b7121c30a96234534ad2 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Thu, 2 Sep 2021 04:02:25 +0300 Subject: [PATCH 05/26] cleaning1 --- test/documenteditor/main/index.html | 2 +- .../main/js/ApplicationController.js | 290 +----------------- .../common/main/lib/component/Button.js | 115 ------- 3 files changed, 16 insertions(+), 391 deletions(-) delete mode 100644 test/unit-tests/common/main/lib/component/Button.js diff --git a/test/documenteditor/main/index.html b/test/documenteditor/main/index.html index 9e591c035..78a7bb84b 100644 --- a/test/documenteditor/main/index.html +++ b/test/documenteditor/main/index.html @@ -79,7 +79,7 @@ } -
    +
    diff --git a/test/documenteditor/main/js/ApplicationController.js b/test/documenteditor/main/js/ApplicationController.js index 4ff7a740f..47a798ab5 100644 --- a/test/documenteditor/main/js/ApplicationController.js +++ b/test/documenteditor/main/js/ApplicationController.js @@ -35,28 +35,22 @@ DE.ApplicationController = new(function(){ api, config = {}, docConfig = {}, - embedConfig = {}, permissions = {}, maxPages = 0, created = false, - ttOffset = [0, -10], appOptions = {}, - btnSubmit, _submitFail, $submitedTooltip, - $listControlMenu, listControlItems = [], listObj, bodyWidth = 0; var LoadingDocument = -256; - - // Check browser // ------------------------- - if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ + /*if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); return; - } + }*/ common.localStorage.setId('text'); common.localStorage.setKeysFilter('de-,asc.text'); @@ -68,7 +62,7 @@ DE.ApplicationController = new(function(){ function loadConfig(data) { config = $.extend(config, data.config); - $('#editor_sdk').addClass('top'); + //$('#editor_sdk').addClass('top'); /*config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose);*/ @@ -133,226 +127,23 @@ DE.ApplicationController = new(function(){ } function onLongActionBegin(type, id) { - var text = ''; - switch (id) - { - case Asc.c_oAscAsyncAction['Print']: - text = me.downloadTextText; - break; - case Asc.c_oAscAsyncAction['Submit']: - _submitFail = false; - $submitedTooltip && $submitedTooltip.hide(); - /*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']) { if (!me.loadMask) me.loadMask = new common.view.LoadMask(); - me.loadMask.setTitle(text); me.loadMask.show(); } } function onLongActionEnd(type, id){ - if (id==Asc.c_oAscAsyncAction['Submit']) { - /*btnSubmit.removeAttr('disabled'); - btnSubmit.css("pointer-events", "auto");*/ - if (!_submitFail) { - if (!$submitedTooltip) { - $submitedTooltip = $(''); - $(document.body).append($submitedTooltip); - $submitedTooltip.on('click', function() {$submitedTooltip.hide();}); - } - $submitedTooltip.show(); - } - } me.loadMask && me.loadMask.hide(); } - function onDocMouseMoveStart() { - me.isHideBodyTip = true; - } - - function onDocMouseMoveEnd() { - if (me.isHideBodyTip) { - if ( $tooltip ) { - $tooltip.tooltip('hide'); - $tooltip = false; - } - } - } - - var $ttEl, $tooltip; - function onDocMouseMove(data) { - if (data) { - var type = data.get_Type(); - if (type == Asc.c_oAscMouseMoveDataTypes.Hyperlink || type==Asc.c_oAscMouseMoveDataTypes.Form) { // hyperlink - me.isHideBodyTip = false; - - var str = (type == Asc.c_oAscMouseMoveDataTypes.Hyperlink) ? me.txtPressLink : data.get_FormHelpText(); - if (str.length>500) - str = str.substr(0, 500) + '...'; - str = common.utils.htmlEncode(str); - - if ( !$ttEl ) { - $ttEl = $('.hyperlink-tooltip'); - $ttEl.tooltip({'container':'body', 'trigger':'manual'}); - } - $ttEl.ttpos = [data.get_X(), data.get_Y()]; - if ( !$tooltip) - $tooltip = $ttEl.data('bs.tooltip').tip(); - - if (!$tooltip.is(':visible')) { - var tip = $ttEl.data('bs.tooltip'); - tip.options.title = str; - tip.show([-1000, -1000]); - } else - $tooltip.find('.tooltip-inner')['text'](str); - - var ttHeight = $tooltip.height(), - ttWidth = $tooltip.width(); - !bodyWidth && (bodyWidth = $('body').width()); - - $ttEl.ttpos[1] -= (ttHeight - ttOffset[1] + 20); - if ($ttEl.ttpos[0] + ttWidth + 10 >bodyWidth) { - $ttEl.ttpos[0] = bodyWidth - ttWidth - 5; - if ($ttEl.ttpos[1] < 0) - $ttEl.ttpos[1] += ttHeight + ttOffset[1] + 20; - } else if ($ttEl.ttpos[1] < 0) { - $ttEl.ttpos[1] = 0; - $ttEl.ttpos[0] += 20; - } - $tooltip.css({ - left: $ttEl.ttpos[0], - top: $ttEl.ttpos[1] - }); - } - } - } function onDownloadUrl(url, fileType) { Common.Gateway.downloadAs(url, fileType); } - function onPrint() { - if ( permissions.print!==false ) - api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); - } - - function onPrintUrl(url) { - common.utils.dialogPrint(url, api); - } - - function onFillRequiredFields(isFilled) { - /*if (isFilled) { - btnSubmit.removeAttr('disabled'); - btnSubmit.css("pointer-events", "auto"); - // $requiredTooltip && $requiredTooltip.hide(); - } else { - btnSubmit.attr({disabled: true}); - btnSubmit.css("pointer-events", "none"); - }*/ - } - - function onShowContentControlsActions(obj, x, y) { - switch (obj.type) { - case Asc.c_oAscContentControlSpecificType.Picture: - if (obj.pr && obj.pr.get_Lock) { - var lock = obj.pr.get_Lock(); - if (lock == Asc.c_oAscSdtLockType.SdtContentLocked || lock==Asc.c_oAscSdtLockType.ContentLocked) - return; - } - api.asc_addImage(obj); - setTimeout(function(){ - api.asc_UncheckContentControlButtons(); - }, 500); - break; - case Asc.c_oAscContentControlSpecificType.DropDownList: - case Asc.c_oAscContentControlSpecificType.ComboBox: - onShowListActions(obj, x, y); - break; - } - } - - function onHideContentControlsActions() { - $listControlMenu && $listControlMenu.hide(); - api.asc_UncheckContentControlButtons(); - } - - function onShowListActions(obj, x, y) { - var type = obj.type, - props = obj.pr, - specProps = (type == Asc.c_oAscContentControlSpecificType.ComboBox) ? props.get_ComboBoxPr() : props.get_DropDownListPr(), - isForm = !!props.get_FormPr(); - - var menuContainer = DE.ApplicationView.getMenuForm(); - - if (!$listControlMenu) { - $listControlMenu = menuContainer.find('ul'); - $listControlMenu.on('click', 'li', function(e) { - var value = $(e.target).attr('value'); - if (value) { - value = parseInt(value); - setTimeout(function(){ - (value!==-1) && api.asc_SelectContentControlListItem(listControlItems[value], listObj.get_InternalId()); - }, 1); - } - }); - $('#editor_sdk').on('click', function(e){ - if (e.target.localName == 'canvas') { - if (me._preventClick) - me._preventClick = false; - else { - $listControlMenu && $listControlMenu.hide(); - api.asc_UncheckContentControlButtons(); - } - } - }); - } - $listControlMenu.find('li').remove(); - listControlItems = []; - listObj = props; - - if (specProps) { - var k = 0; - if (isForm){ // for dropdown and combobox form control always add placeholder item - var text = props.get_PlaceholderText(); - $listControlMenu.append('
  • ' + - ((text.trim()!=='') ? text : me.txtEmpty) + - '
  • '); - listControlItems.push(''); - } - var count = specProps.get_ItemsCount(); - k = listControlItems.length; - for (var i=0; i' + - common.utils.htmlEncode(specProps.get_ItemDisplayText(i)) + - ''); - listControlItems.push(specProps.get_ItemValue(i)); - } - } - if (!isForm && listControlItems.length<1) { - $listControlMenu.append('
  • ' + - me.txtEmpty + - '
  • '); - listControlItems.push(-1); - } - } - - menuContainer.css({left: x, top : y}); - me._preventClick = true; - $listControlMenu.show(); - } - function hidePreloader() { $('#loading-mask').fadeOut('slow'); } @@ -368,58 +159,19 @@ DE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onStartAction', onLongActionBegin); api.asc_registerCallback('asc_onEndAction', onLongActionEnd); - api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart); - api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd); - api.asc_registerCallback('asc_onMouseMove', onDocMouseMove); api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); - api.asc_registerCallback('asc_onPrint', onPrint); - api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); - api.asc_registerCallback('sync_onAllRequiredFormsFilled', onFillRequiredFields); - /*if (appOptions.canFillForms) { - api.asc_registerCallback('asc_onShowContentControlsActions', onShowContentControlsActions); - api.asc_registerCallback('asc_onHideContentControlsActions', onHideContentControlsActions); - api.asc_SetHighlightRequiredFields(true); - }*/ + + Common.Gateway.on('processmouse', onProcessMouse); - Common.Gateway.on('downloadas', onDownloadAs); + //Common.Gateway.on('downloadas', onDownloadAs); Common.Gateway.on('requestclose', onRequestClose); - - - - var downloadAs = function(format){ + /*var downloadAs = function(format){ api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); - }; - - - - + };*/ // TODO: add asc_hasRequiredFields to sdk - - - - var documentMoveTimer; - var ismoved = false; - $(document).mousemove(function(event){ - /*$('#id-btn-zoom-in').fadeIn(); - $('#id-btn-zoom-out').fadeIn();*/ - - ismoved = true; - if ( !documentMoveTimer ) { - documentMoveTimer = setInterval(function(){ - if ( !ismoved ) { - /* $('#id-btn-zoom-in').fadeOut(); - $('#id-btn-zoom-out').fadeOut();*/ - clearInterval(documentMoveTimer); - documentMoveTimer = undefined; - } - - ismoved = false; - }, 2000); - } - }); Common.Gateway.documentReady(); } @@ -449,7 +201,7 @@ DE.ApplicationController = new(function(){ me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); } - function onError(id, level, errData) { + /*function onError(id, level, errData) { if (id == Asc.c_oAscError.ID.LoadingScriptError) { $('#id-critical-error-title').text(me.criticalErrorTitle); $('#id-critical-error-message').text(me.scriptLoadError); @@ -558,7 +310,7 @@ DE.ApplicationController = new(function(){ $('#id-error-mask-text').text(error.msg); $('#id-error-mask').css('display', 'block'); } - } + }*/ function onProcessMouse(data) { if (data.type == 'mouseup') { @@ -624,7 +376,7 @@ DE.ApplicationController = new(function(){ ismodalshown = false; api.asc_enableKeyEvents(true); } - ).on('hidden.bs.dropdown', '.dropdown', + )/*.on('hidden.bs.dropdown', '.dropdown', function(e) { if ( !ismodalshown ) api.asc_enableKeyEvents(true); @@ -637,7 +389,7 @@ DE.ApplicationController = new(function(){ } } } - ); + )*/; $('#editor_sdk').on('click', function(e) { if ( e.target.localName == 'canvas' ) { @@ -647,12 +399,11 @@ DE.ApplicationController = new(function(){ window["flat_desine"] = true; api = new Asc.asc_docs_api({ - 'id-view' : 'editor_sdk', - 'embedded' : true/**/ + 'id-view' : 'editor_sdk' }); if (api){ - api.asc_registerCallback('asc_onError', onError); + //api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); @@ -662,7 +413,7 @@ DE.ApplicationController = new(function(){ // Initialize api gateway Common.Gateway.on('init', loadConfig); Common.Gateway.on('opendocument', loadDocument); - Common.Gateway.on('showmessage', onExternalMessage); + //Common.Gateway.on('showmessage', onExternalMessage); Common.Gateway.appReady(); } @@ -683,26 +434,15 @@ DE.ApplicationController = new(function(){ errorAccessDeny: 'You are trying to perform an action you do not have rights for.
    Please contact your Document Server administrator.', errorUserDrop: 'The file cannot be accessed right now.', unsupportedBrowserErrorText: 'Your browser is not supported.', - textOf: 'of', - downloadTextText: 'Downloading document...', - waitText: 'Please, wait...', textLoadingDocument: 'Loading document', txtClose: 'Close', errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
    Please contact your Document Server administrator for details.', errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
    Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', - textNext: 'Next Field', - textClear: 'Clear All Fields', - textSubmit: 'Submit', - textSubmited: 'Form submitted successfully
    Click to close the tip.', errorSubmit: 'Submit failed.', errorEditingDownloadas: 'An error occurred during the work with the document.
    Use the \'Download as...\' option to save the file backup copy to your computer hard drive.', textGuest: 'Guest', textAnonymous: 'Anonymous', - textRequired: 'Fill all required fields to send form.', - textGotIt: 'Got it', errorForceSave: "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.", - txtEmpty: '(Empty)', - txtPressLink: 'Press Ctrl and click link', errorLoadingFont: 'Fonts are not loaded.
    Please contact your Document Server administrator.' } })(); \ No newline at end of file diff --git a/test/unit-tests/common/main/lib/component/Button.js b/test/unit-tests/common/main/lib/component/Button.js deleted file mode 100644 index b50308ae8..000000000 --- a/test/unit-tests/common/main/lib/component/Button.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Button.js - * - * Unit test - * - * Created by Alexander Yuzhin on 6/20/14 - * Copyright (c) 2018 Ascensio System SIA. All rights reserved. - * - */ - -define([ - 'backbone', - '../../../../../apps/common/main/lib/component/Button.js', - '../../../../../apps/common/main/lib/component/Menu.js' -],function() { - var chai = require('chai'), - should = chai.should(); - - describe('Common.UI.Button', function(){ - var button, - domPlaceholder = document.createElement('div'); - - it('Create simple button', function(){ - $('body').append(domPlaceholder); - - button = new Common.UI.Button({ - id: 'id-btn-simple', - caption: 'test' - }); - - button.render($(domPlaceholder)); - - should.exist(button); - $('#id-btn-simple').should.have.length(1); - }); - - it('Button caption', function(){ - button.caption.should.equal('test'); - }); - - it('Button update caption', function(){ - button.setCaption('update caption'); - - // object - button.caption.should.equal('update caption'); - - // dom - assert.equal(button.cmpEl.find('button:first').andSelf().filter('button').text(), 'update caption', 'dom caption'); - }); - - it('Button toggle', function(){ - button.toggle(); - assert.equal(button.isActive(), true, 'should by active'); - button.toggle(); - assert.equal(button.isActive(), false, 'should NOT by active'); - - button.toggle(false); - assert.equal(button.isActive(), false, 'should NOT by active'); - button.toggle(true); - assert.equal(button.isActive(), true, 'should by active'); - - button.toggle(false); - }); - - it('Button disable', function(){ - assert.equal(button.isDisabled(), false, 'should NOT by disable'); - - button.setDisabled(true); - assert.equal(button.isDisabled(), true, 'should by disable'); - - button.setDisabled(false); - assert.equal(button.isDisabled(), false, 'should NOT by disable'); - }); - - it('Remove simple button', function(){ - button.remove(); - $('#id-btn-simple').should.have.length(0); - - button = null; -// domPlaceholder.remove(); - }); - - it('Create split button', function(){ - $('body').append(domPlaceholder); - - button = new Common.UI.Button({ - id : 'id-btn-split', - caption : 'split', - split : true, - menu : new Common.UI.Menu({ - items: [ - { - caption: 'print', - value: 'print' - } - ] - }) - }); - - button.render($(domPlaceholder)); - - should.exist(button); - $('#id-btn-split').should.have.length(1); - $('#id-btn-split button').should.have.length(2); - }); - - it('Remove split button', function(){ - button.remove(); - $('#id-btn-split').should.have.length(0); - - button = null; -// domPlaceholder.remove(); - }); - }); -}); \ No newline at end of file From e3af6125dd1cf11e5d4e1bc99848fd9de7d25a3e Mon Sep 17 00:00:00 2001 From: OVSharova Date: Fri, 3 Sep 2021 06:46:59 +0300 Subject: [PATCH 06/26] Fix error message --- .../main/js/ApplicationController.js | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/test/documenteditor/main/js/ApplicationController.js b/test/documenteditor/main/js/ApplicationController.js index 47a798ab5..d35f68d6b 100644 --- a/test/documenteditor/main/js/ApplicationController.js +++ b/test/documenteditor/main/js/ApplicationController.js @@ -47,10 +47,11 @@ DE.ApplicationController = new(function(){ // Check browser // ------------------------- - /*if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ - Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ + //Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + console.error(this.unsupportedBrowserErrorText); return; - }*/ + } common.localStorage.setId('text'); common.localStorage.setKeysFilter('de-,asc.text'); @@ -61,11 +62,6 @@ DE.ApplicationController = new(function(){ function loadConfig(data) { config = $.extend(config, data.config); - - //$('#editor_sdk').addClass('top'); - - /*config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && - (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose);*/ } function loadDocument(data) { @@ -101,10 +97,10 @@ DE.ApplicationController = new(function(){ docInfo.put_Permissions(_permissions); docInfo.put_EncryptedInfo(config.encryptionKeys); - /*var enable = !config.customization || (config.customization.macros!==false); + var enable = !config.customization || (config.customization.macros!==false); docInfo.asc_putIsEnabledMacroses(!!enable); enable = !config.customization || (config.customization.plugins!==false); - docInfo.asc_putIsEnabledPlugins(!!enable);*/ + docInfo.asc_putIsEnabledPlugins(!!enable); var type = /^(?:(pdf|djvu|xps))$/.exec(docConfig.fileType); @@ -122,11 +118,7 @@ DE.ApplicationController = new(function(){ } } - function onCountPages(count) { - maxPages = count; - } - - function onLongActionBegin(type, id) { + function onLongActionBegin(type, id) { if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { if (!me.loadMask) @@ -139,7 +131,13 @@ DE.ApplicationController = new(function(){ me.loadMask && me.loadMask.hide(); } - + function onPrint() { + if ( permissions.print!==false ) + api.asc_Print(new Asc.asc_CDownloadOptions(null, false)); + } + function onPrintUrl(url) { + common.utils.dialogPrint(url, api); + } function onDownloadUrl(url, fileType) { Common.Gateway.downloadAs(url, fileType); } @@ -161,15 +159,17 @@ DE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onEndAction', onLongActionEnd); api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); + api.asc_registerCallback('asc_onPrint', onPrint); + api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); Common.Gateway.on('processmouse', onProcessMouse); - //Common.Gateway.on('downloadas', onDownloadAs); + Common.Gateway.on('downloadas', onDownloadAs); Common.Gateway.on('requestclose', onRequestClose); - /*var downloadAs = function(format){ + var downloadAs = function(format){ api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); - };*/ + }; // TODO: add asc_hasRequiredFields to sdk Common.Gateway.documentReady(); @@ -201,14 +201,14 @@ DE.ApplicationController = new(function(){ me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); } - /*function onError(id, level, errData) { + function onError(id, level, errData) { if (id == Asc.c_oAscError.ID.LoadingScriptError) { $('#id-critical-error-title').text(me.criticalErrorTitle); $('#id-critical-error-message').text(me.scriptLoadError); $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ window.location.reload(); }); - //$('#id-critical-error-dialog').css('z-index', 20002).modal('show'); + $('#id-critical-error-dialog').css('z-index', 20002).modal('show'); return; } @@ -282,8 +282,8 @@ DE.ApplicationController = new(function(){ if (level == Asc.c_oAscError.Level.Critical) { // report only critical errors - Common.Gateway.reportError(id, message); - + //Common.Gateway.reportError(id, message); + console.error(id,message); $('#id-critical-error-title').text(me.criticalErrorTitle); $('#id-critical-error-message').html(message); $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ @@ -291,7 +291,8 @@ DE.ApplicationController = new(function(){ }); } else { - Common.Gateway.reportWarning(id, message); + //Common.Gateway.reportWarning(id, message); + console.warn(id, message); $('#id-critical-error-title').text(me.notcriticalErrorTitle); $('#id-critical-error-message').html(message); @@ -310,7 +311,8 @@ DE.ApplicationController = new(function(){ $('#id-error-mask-text').text(error.msg); $('#id-error-mask').css('display', 'block'); } - }*/ + } + function onProcessMouse(data) { if (data.type == 'mouseup') { @@ -331,10 +333,11 @@ DE.ApplicationController = new(function(){ function onDownloadAs() { if ( permissions.download === false) { - Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); + //Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); + console.error(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); return; } - if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, true)); + if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, false)); } function onRunAutostartMacroses() { @@ -376,7 +379,7 @@ DE.ApplicationController = new(function(){ ismodalshown = false; api.asc_enableKeyEvents(true); } - )/*.on('hidden.bs.dropdown', '.dropdown', + ).on('hidden.bs.dropdown', '.dropdown', function(e) { if ( !ismodalshown ) api.asc_enableKeyEvents(true); @@ -389,7 +392,7 @@ DE.ApplicationController = new(function(){ } } } - )*/; + ); $('#editor_sdk').on('click', function(e) { if ( e.target.localName == 'canvas' ) { @@ -403,17 +406,14 @@ DE.ApplicationController = new(function(){ }); if (api){ - //api.asc_registerCallback('asc_onError', onError); + api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); - api.asc_registerCallback('asc_onCountPages', onCountPages); - - // Initialize api gateway Common.Gateway.on('init', loadConfig); Common.Gateway.on('opendocument', loadDocument); - //Common.Gateway.on('showmessage', onExternalMessage); + Common.Gateway.on('showmessage', onExternalMessage); Common.Gateway.appReady(); } From 4fbedc3b7b4a376835f596dedc483d1b0a9c111e Mon Sep 17 00:00:00 2001 From: OVSharova Date: Sun, 5 Sep 2021 01:40:13 +0300 Subject: [PATCH 07/26] Presentationeditor --- test/presentationeditor/main/index.html | 193 ++++- .../main/js/ApplicationController.js | 729 ++++++++++++++++++ .../main/js/ApplicationView.js | 75 ++ .../presentationeditor/main/js/application.js | 38 + test/presentationeditor/main/locale/en.json | 1 + .../main/resources/less/application.less | 34 + .../main/resources/less/instaltools.bat | 2 + .../main/resources/less/watch.js | 75 ++ 8 files changed, 1145 insertions(+), 2 deletions(-) create mode 100644 test/presentationeditor/main/js/ApplicationController.js create mode 100644 test/presentationeditor/main/js/ApplicationView.js create mode 100644 test/presentationeditor/main/js/application.js create mode 100644 test/presentationeditor/main/locale/en.json create mode 100644 test/presentationeditor/main/resources/less/application.less create mode 100644 test/presentationeditor/main/resources/less/instaltools.bat create mode 100644 test/presentationeditor/main/resources/less/watch.js diff --git a/test/presentationeditor/main/index.html b/test/presentationeditor/main/index.html index 15f14fe94..aaa36cb3a 100644 --- a/test/presentationeditor/main/index.html +++ b/test/presentationeditor/main/index.html @@ -2,7 +2,196 @@ + Documents + + + + + + + + - + + +
    +
    +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + +
    +
    +
    +
    + +
    +
      +
    • +
    • +
    • +
    +
    + +
    +
    +
    +
    +
    + +
    +
    +
    of 0
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + - \ No newline at end of file + diff --git a/test/presentationeditor/main/js/ApplicationController.js b/test/presentationeditor/main/js/ApplicationController.js new file mode 100644 index 000000000..61e2bd235 --- /dev/null +++ b/test/presentationeditor/main/js/ApplicationController.js @@ -0,0 +1,729 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +PE.ApplicationController = new(function(){ + var me, + api, + config = {}, + docConfig = {}, + embedConfig = {}, + permissions = {}, + maxPages = 0, + created = false, + currentPage = 0, + ttOffset = [0, -10], + labelDocName; + + var LoadingDocument = -256; + + // Initialize analytics + // ------------------------- + +// Common.Analytics.initialize('UA-12442749-13', 'Embedded Presentation Editor'); + + + // Check browser + // ------------------------- + + if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ + Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + return; + } + + common.localStorage.setId('text'); + common.localStorage.setKeysFilter('pe-,asc.presentation'); + common.localStorage.sync(); + + // Handlers + // ------------------------- + + function loadConfig(data) { + config = $.extend(config, data.config); + embedConfig = $.extend(embedConfig, data.config.embedded); + + //common.controller.modals.init(embedConfig); + + // Docked toolbar + /*if (embedConfig.toolbarDocked === 'bottom') { + $('#toolbar').addClass('bottom'); + $('#editor_sdk').addClass('bottom'); + $('#box-tools').removeClass('dropdown').addClass('dropup'); + ttOffset[1] = -40; + } else { + $('#toolbar').addClass('top'); + $('#editor_sdk').addClass('top'); + }*/ + + config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && + (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose); + } + + function loadDocument(data) { + docConfig = data.doc; + + if (docConfig) { + permissions = $.extend(permissions, docConfig.permissions); + + var _permissions = $.extend({}, docConfig.permissions), + docInfo = new Asc.asc_CDocInfo(), + _user = new Asc.asc_CUserInfo(); + + var canRenameAnonymous = !((typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && (config.customization.anonymous.request===false)), + guestName = (typeof (config.customization) == 'object') && (typeof (config.customization.anonymous) == 'object') && + (typeof (config.customization.anonymous.label) == 'string') && config.customization.anonymous.label.trim()!=='' ? + common.utils.htmlEncode(config.customization.anonymous.label) : me.textGuest, + value = canRenameAnonymous ? common.localStorage.getItem("guest-username") : null, + user = common.utils.fillUserInfo(config.user, config.lang, value ? (value + ' (' + guestName + ')' ) : me.textAnonymous, + common.localStorage.getItem("guest-id") || ('uid-' + Date.now())); + user.anonymous && common.localStorage.setItem("guest-id", user.id); + + _user.put_Id(user.id); + _user.put_FullName(user.fullname); + _user.put_IsAnonymousUser(user.anonymous); + + docInfo.put_Id(docConfig.key); + docInfo.put_Url(docConfig.url); + docInfo.put_Title(docConfig.title); + docInfo.put_Format(docConfig.fileType); + docInfo.put_VKey(docConfig.vkey); + docInfo.put_UserInfo(_user); + docInfo.put_Token(docConfig.token); + docInfo.put_Permissions(_permissions); + docInfo.put_EncryptedInfo(config.encryptionKeys); + + var enable = !config.customization || (config.customization.macros!==false); + docInfo.asc_putIsEnabledMacroses(!!enable); + enable = !config.customization || (config.customization.plugins!==false); + docInfo.asc_putIsEnabledPlugins(!!enable); + + if (api) { + api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); + api.asc_registerCallback('asc_onRunAutostartMacroses', onRunAutostartMacroses); + api.asc_setDocInfo(docInfo); + api.asc_getEditorPermissions(config.licenseUrl, config.customerId); + api.asc_enableKeyEvents(true); + + //Common.Analytics.trackEvent('Load', 'Start'); + } + + embedConfig.docTitle = docConfig.title; + labelDocName = $('#title-doc-name'); + labelDocName.text(embedConfig.docTitle || '') + } + } + + function onCountPages(count) { + maxPages = count; + $('#pages').text(me.textOf + " " + count); + } + + function onCurrentPage(number) { + $('#page-number').val(number + 1); + currentPage = number; + } + + function onLongActionBegin(type, id) { + var text = ''; + switch (id) + { + 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']) { + if (!me.loadMask) + me.loadMask = new common.view.LoadMask(); + me.loadMask.setTitle(text); + me.loadMask.show(); + } + } + + function onLongActionEnd(){ + me.loadMask && me.loadMask.hide(); + } + + function onDocMouseMoveStart() { + me.isHideBodyTip = true; + } + + var $ttEl, $tooltip; + function onDocMouseMoveEnd() { + if (me.isHideBodyTip) { + if ( $tooltip ) { + $tooltip.tooltip('hide'); + $tooltip = false; + } + } + } + + function onDocMouseMove(data) { + if (data) { + if (data.get_Type() == 1) { // hyperlink + me.isHideBodyTip = false; + + if ( !$ttEl ) { + $ttEl = $('.hyperlink-tooltip'); + $ttEl.tooltip({'container':'body', 'trigger':'manual'}); + $ttEl.on('shown.bs.tooltip', function(e) { + $tooltip = $ttEl.data('bs.tooltip').tip(); + + $tooltip.css({ + left: $ttEl.ttpos[0] + ttOffset[0], + top: $ttEl.ttpos[1] + ttOffset[1] + }); + + $tooltip.find('.tooltip-arrow').css({left: 10}); + }); + } + + if ( !$tooltip ) { + $ttEl.ttpos = [data.get_X(), data.get_Y()]; + $ttEl.tooltip('show'); + } else { + $tooltip.css({ + left:data.get_X() + ttOffset[0], + top:data.get_Y() + ttOffset[1] + }); + } + } + } + } + + function onDownloadUrl(url, fileType) { + Common.Gateway.downloadAs(url, fileType); + } + + function onPrint() { + if (permissions.print!==false) + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + } + + function onPrintUrl(url) { + common.utils.dialogPrint(url, api); + } + + function hidePreloader() { + $('#loading-mask').fadeOut('slow'); + } + + function onDocumentContentReady() { + api.ShowThumbnails(true); + //api.asc_DeleteVerticalScroll(); + + /*if (!embedConfig.autostart || embedConfig.autostart == 'player') { + api.SetDemonstrationModeOnly(); + 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)); + + if ( permissions.print === false) + $('#idt-print').hide(); + + if (!embedConfig.saveUrl && permissions.print === false) + $('#idt-download').hide(); + + if ( !embedConfig.shareUrl ) + $('#idt-share').hide(); + + if (!config.canBackToFolder) + $('#idt-close').hide(); + + if ( !embedConfig.embedUrl ) + $('#idt-embed').hide(); + + if ( !embedConfig.fullscreenUrl ) + $('#idt-fullscreen').hide(); + + if ( !embedConfig.saveUrl && permissions.print === false && !embedConfig.shareUrl && !embedConfig.embedUrl && !embedConfig.fullscreenUrl && !config.canBackToFolder) + $('#box-tools').addClass('hidden'); + else if (!embedConfig.embedUrl && !embedConfig.fullscreenUrl) + $('#box-tools .divider').hide(); + + /*common.controller.modals.attach({ + share: '#idt-share', + embed: '#idt-embed' + });*/ + + api.asc_registerCallback('asc_onMouseMoveStart', onDocMouseMoveStart); + api.asc_registerCallback('asc_onMouseMoveEnd', onDocMouseMoveEnd); + api.asc_registerCallback('asc_onMouseMove', onDocMouseMove); + + api.asc_registerCallback('asc_onDownloadUrl', onDownloadUrl); + api.asc_registerCallback('asc_onPrint', onPrint); + api.asc_registerCallback('asc_onPrintUrl', onPrintUrl); + api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); + api.asc_registerCallback('asc_onStartAction', onLongActionBegin); + api.asc_registerCallback('asc_onEndAction', onLongActionEnd); + + api.asc_registerCallback('asc_onEndDemonstration', onPlayStop); + api.asc_registerCallback('asc_onDemonstrationSlideChanged', onPlaySlideChanged); + + Common.Gateway.on('processmouse', onProcessMouse); + Common.Gateway.on('downloadas', onDownloadAs); + Common.Gateway.on('requestclose', onRequestClose); + + PE.ApplicationView.tools.get('#idt-fullscreen') + .on('click', function(){ + common.utils.openLink(embedConfig.fullscreenUrl); + }); + + PE.ApplicationView.tools.get('#idt-download') + .on('click', function(){ + if ( !!embedConfig.saveUrl ){ + common.utils.openLink(embedConfig.saveUrl); + } else + if (api && permissions.print!==false){ + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + } + + //Common.Analytics.trackEvent('Save'); + }); + + PE.ApplicationView.tools.get('#idt-print') + .on('click', function(){ + api.asc_Print(new Asc.asc_CDownloadOptions(null, $.browser.chrome || $.browser.safari || $.browser.opera || $.browser.mozilla && $.browser.versionNumber>86)); + //Common.Analytics.trackEvent('Print'); + }); + + PE.ApplicationView.tools.get('#idt-close') + .on('click', function(){ + if (config.customization && config.customization.goback) { + if (config.customization.goback.requestClose && config.canRequestClose) + Common.Gateway.requestClose(); + else if (config.customization.goback.url) + window.parent.location.href = config.customization.goback.url; + } + }); + + var $pagenum = $('#page-number'); + $pagenum.on({ + 'keyup': function(e){ + if ( e.keyCode == 13 ){ + var newPage = parseInt($('#page-number').val()); + + if ( isNaN(newPage) ) { + $('#page-number').val(currentPage + 1); + } else { + if ( newPage > maxPages ) newPage = maxPages; else + if ( newPage < 2 ) newPage = 1; + + if ( newPage == currentPage + 1 ) { + $('#page-number').val( newPage ); + } else + if (isplaymode) { + currentPage = newPage - 1; + api.DemonstrationGoToSlide(newPage - 1); + } else api.goToPage(newPage - 1); + } + + $pagenum.blur(); + } + } + , 'focusin' : function(e) { + $pagenum.removeClass('masked'); + } + , 'focusout': function(e){ + !$pagenum.hasClass('masked') && $pagenum.addClass('masked'); + } + }); + + $('#pages').on('click', function(e) { + $pagenum.focus(); + }); + + $('#btn-left').on('click', function(){ + if ( isplaymode ) { + api.DemonstrationPrevSlide(); + } else + if (currentPage > 0) { + api.goToPage(currentPage - 1); + } + }); + + $('#btn-right').on('click', function(){ + if ( isplaymode ) { + api.DemonstrationNextSlide(); + } else + if (currentPage < maxPages - 1) { + api.goToPage(currentPage + 1); + } + }); + + var documentMoveTimer; + var ismoved = false; + $(document).on({ + 'click': function(e) { + clearTimeout(documentMoveTimer); + documentMoveTimer = undefined; + }, + 'mousemove': function (e) { + $('#btn-left').fadeIn(); + $('#btn-right').fadeIn(); + + ismoved = true; + if ( !documentMoveTimer ) { + documentMoveTimer = setInterval(function(){ + if ( !ismoved ) { + // $('#btn-left').fadeOut(); + // $('#btn-right').fadeOut(); + clearInterval(documentMoveTimer); + documentMoveTimer = undefined; + } + + ismoved = false; + }, 2000); + } + } + }); + + var ismodalshown = false; + $(document.body).on('show.bs.modal', '.modal', + function(e) { + ismodalshown = true; + api.asc_enableKeyEvents(false); + } + ).on('hidden.bs.modal', '.modal', + function(e) { + ismodalshown = false; + api.asc_enableKeyEvents(true); + } + ).on('hidden.bs.dropdown', '.dropdown', + function(e) { + if ( !ismodalshown ) + api.asc_enableKeyEvents(true); + } + ).on('blur', 'input, textarea', + function(e) { + if ( !ismodalshown ) { + if (!/area_id/.test(e.target.id) ) { + api.asc_enableKeyEvents(true); + } + } + } + ); + + $('#editor_sdk').on('click', function(e) { + if ( e.target.localName == 'canvas' ) { + e.currentTarget.focus(); + } + }); + + $('#btn-play').on('click', onPlayStart); + Common.Gateway.documentReady(); + //Common.Analytics.trackEvent('Load', 'Complete'); + } + + function onEditorPermissions(params) { + if ( (params.asc_getLicenseType() === Asc.c_oLicenseResult.Success) && (typeof config.customization == 'object') && + config.customization && config.customization.logo ) { + + var logo = $('#header-logo'); + if (config.customization.logo.imageEmbedded) { + logo.html(''); + logo.css({'background-image': 'none', width: 'auto', height: 'auto'}); + } + + if (config.customization.logo.url) { + logo.attr('href', config.customization.logo.url); + } + } + + var $parent = labelDocName.parent(); + var _left_width = $parent.position().left, + _right_width = $parent.next().outerWidth(); + + if ( _left_width < _right_width ) + $parent.css('padding-left', _right_width - _left_width); + else + $parent.css('padding-right', _left_width - _right_width); + + onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + api.asc_setViewMode(false); + + api.asc_LoadDocument(); + api.Resize(); + } + + function onOpenDocument(progress) { + var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); + me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); + } + + var isplaymode; + function onPlayStart(e) { + if ( !isplaymode ) { + $('#box-preview').show(); + api.StartDemonstration('id-preview', currentPage); + } else { + isplaymode == 'play' ? + api.DemonstrationPause() : api.DemonstrationPlay(); + } + + isplaymode != 'play' ? ($('#btn-play button').addClass('pause'), isplaymode = 'play') : + ($('#btn-play button').removeClass('pause'), isplaymode = 'pause'); + } + + function onPlayStop() { + isplaymode = undefined; + $('#page-number').val(currentPage + 1); + $('#btn-play button').removeClass('pause'); + $('#box-preview').hide(); + } + + function onPlaySlideChanged(number) { + if ( number++ < maxPages) + $('#page-number').val(number); + } + + function onError(id, level, errData) { + if (id == Asc.c_oAscError.ID.LoadingScriptError) { + $('#id-critical-error-title').text(me.criticalErrorTitle); + $('#id-critical-error-message').text(me.scriptLoadError); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + window.location.reload(); + }); + $('#id-critical-error-dialog').css('z-index', 20002).modal('show'); + return; + } + + hidePreloader(); + onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); + + var message; + + switch (id) + { + case Asc.c_oAscError.ID.Unknown: + message = me.unknownErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationTimeout: + message = me.convertationTimeoutText; + break; + + case Asc.c_oAscError.ID.ConvertationError: + message = me.convertationErrorText; + break; + + case Asc.c_oAscError.ID.DownloadError: + message = me.downloadErrorText; + break; + + case Asc.c_oAscError.ID.ConvertationPassword: + message = me.errorFilePassProtect; + break; + + case Asc.c_oAscError.ID.UserDrop: + message = me.errorUserDrop; + break; + + case Asc.c_oAscError.ID.ConvertationOpenLimitError: + message = me.errorFileSizeExceed; + break; + + case Asc.c_oAscError.ID.UpdateVersion: + message = me.errorUpdateVersionOnDisconnect; + break; + + case Asc.c_oAscError.ID.AccessDeny: + message = me.errorAccessDeny; + break; + + case Asc.c_oAscError.ID.ForceSaveButton: + case Asc.c_oAscError.ID.ForceSaveTimeout: + message = me.errorForceSave; + break; + + case Asc.c_oAscError.ID.LoadingFontError: + message = me.errorLoadingFont; + break; + + default: + message = me.errorDefaultMessage.replace('%1', id); + break; + } + + if (level == Asc.c_oAscError.Level.Critical) { + + // report only critical errors + Common.Gateway.reportError(id, message); + + $('#id-critical-error-title').text(me.criticalErrorTitle); + $('#id-critical-error-message').html(message); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + window.location.reload(); + }); + } + else { + Common.Gateway.reportWarning(id, message); + + $('#id-critical-error-title').text(me.notcriticalErrorTitle); + $('#id-critical-error-message').html(message); + $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ + $('#id-critical-error-dialog').modal('hide'); + }); + } + + $('#id-critical-error-dialog').modal('show'); + + //Common.Analytics.trackEvent('Internal Error', id.toString()); + } + + function onExternalMessage(error) { + if (error) { + hidePreloader(); + $('#id-error-mask-title').text(me.criticalErrorTitle); + $('#id-error-mask-text').text(error.msg); + $('#id-error-mask').css('display', 'block'); + + //Common.Analytics.trackEvent('External Error'); + } + } + + function onProcessMouse(data) { + if (data.type == 'mouseup') { + var e = document.getElementById('editor_sdk'); + if (e) { + var r = e.getBoundingClientRect(); + api.OnMouseUp( + data.x - r.left, + data.y - r.top + ); + } + } + } + + function onRequestClose() { + Common.Gateway.requestClose(); + } + + function onDownloadAs() { + if ( permissions.download === false) { + Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); + return; + } + if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, true)); + } + + function onRunAutostartMacroses() { + if (!config.customization || (config.customization.macros!==false)) + if (api) api.asc_runAutostartMacroses(); + } + + function onBeforeUnload () { + common.localStorage.save(); + } + // Helpers + // ------------------------- + + function onDocumentResize() { + if (api) { + api.Resize(); + } + } + + function createController(){ + if (created) + return me; + + me = this; + created = true; + + // popover ui handlers + + $(window).resize(function(){ + onDocumentResize(); + }); + window.onbeforeunload = onBeforeUnload; + + api = new Asc.asc_docs_api({ + 'id-view' : 'editor_sdk', + 'embedded' : true + }); + + if (api){ + api.SetThemesPath("../../../../sdkjs/slide/themes/"); + + api.asc_registerCallback('asc_onError', onError); + api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); + api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); + api.asc_registerCallback('asc_onCountPages', onCountPages); + api.asc_registerCallback('asc_onCurrentPage', onCurrentPage); + + // Initialize api gateway + Common.Gateway.on('init', loadConfig); + Common.Gateway.on('opendocument', loadDocument); + Common.Gateway.on('showmessage', onExternalMessage); + Common.Gateway.appReady(); + } + + return me; + } + + return { + create : createController, + errorDefaultMessage : 'Error code: %1', + unknownErrorText : 'Unknown error.', + convertationTimeoutText : 'Conversion timeout exceeded.', + convertationErrorText : 'Conversion failed.', + downloadErrorText : 'Download failed.', + criticalErrorTitle : 'Error', + notcriticalErrorTitle : 'Warning', + scriptLoadError: 'The connection is too slow, some of the components could not be loaded. Please reload the page.', + errorFilePassProtect: 'The file is password protected and cannot be opened.', + errorAccessDeny: 'You are trying to perform an action you do not have rights for.
    Please contact your Document Server administrator.', + errorUserDrop: 'The file cannot be accessed right now.', + unsupportedBrowserErrorText: 'Your browser is not supported.', + textOf: 'of', + downloadTextText: 'Downloading presentation...', + waitText: 'Please, wait...', + textLoadingDocument: 'Loading presentation', + txtClose: 'Close', + errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
    Please contact your Document Server administrator for details.', + errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
    Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', + textGuest: 'Guest', + textAnonymous: 'Anonymous', + errorForceSave: "An error occurred while saving the file. Please use the 'Download as' option to save the file to your computer hard drive or try again later.", + errorLoadingFont: 'Fonts are not loaded.
    Please contact your Document Server administrator.' + } +})(); diff --git a/test/presentationeditor/main/js/ApplicationView.js b/test/presentationeditor/main/js/ApplicationView.js new file mode 100644 index 000000000..613087c00 --- /dev/null +++ b/test/presentationeditor/main/js/ApplicationView.js @@ -0,0 +1,75 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +if (PE === undefined) { + var PE = {}; +} + +PE.ApplicationView = new(function(){ + var $btnTools; + + // Initialize view + + function createView(){ + $btnTools = $('#box-tools button'); + + $btnTools.addClass('dropdown-toggle').attr('data-toggle', 'dropdown').attr('aria-expanded', 'true'); + $btnTools.parent().append( + ''); + } + + function getTools(name) { + return $btnTools.parent().find(name); + } + + return { + create: createView + , tools: { + get: getTools + }, + + txtDownload: 'Download', + txtPrint: 'Print', + txtShare: 'Share', + txtEmbed: 'Embed', + txtFullScreen: 'Full Screen', + txtFileLocation: 'Open file location' + } +})(); diff --git a/test/presentationeditor/main/js/application.js b/test/presentationeditor/main/js/application.js new file mode 100644 index 000000000..bbff1ddfe --- /dev/null +++ b/test/presentationeditor/main/js/application.js @@ -0,0 +1,38 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +(function ($) { + Common.Locale.apply(function() { + PE.ApplicationView.create(); + PE.ApplicationController.create(); + }); +})(window.jQuery); diff --git a/test/presentationeditor/main/locale/en.json b/test/presentationeditor/main/locale/en.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/presentationeditor/main/locale/en.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/presentationeditor/main/resources/less/application.less b/test/presentationeditor/main/resources/less/application.less new file mode 100644 index 000000000..fce4297db --- /dev/null +++ b/test/presentationeditor/main/resources/less/application.less @@ -0,0 +1,34 @@ +// Bootstrap core variables and mixins +@import "../../../../unit-tests/common/main/resources/less/common.less"; + +.overlay-controls { + /*bottom: 15px;*/ +} + +.overlay-icon-move-left { background-position: -64px -120px; } +.overlay-icon-move-right { background-position: -96px -120px; } + +#box-preview { + position:absolute; + left: 0; + top: 0; + display:none; + width:100%; + height:100%; + z-index: 10; + padding: 48px 0 0 0; +} + +#id-preview { + width:100%; + height:100%; + position: relative; +} + +.svg-icon { + &.play { + &.pause { + background-position: -20px*10 -20px; + } + } +} diff --git a/test/presentationeditor/main/resources/less/instaltools.bat b/test/presentationeditor/main/resources/less/instaltools.bat new file mode 100644 index 000000000..40a405873 --- /dev/null +++ b/test/presentationeditor/main/resources/less/instaltools.bat @@ -0,0 +1,2 @@ +call npm install less +call npm install watchr \ No newline at end of file diff --git a/test/presentationeditor/main/resources/less/watch.js b/test/presentationeditor/main/resources/less/watch.js new file mode 100644 index 000000000..3dfb91b93 --- /dev/null +++ b/test/presentationeditor/main/resources/less/watch.js @@ -0,0 +1,75 @@ +(function() { + var path = require('path'), + util = require('util'), + fs = require('fs'), + watchr = require('watchr'), + less = require('less'), + cwd = process.cwd(), + watchPath = process.argv.length === 3 ? path.resolve(cwd, process.argv[2]) : cwd; + + var options = { + compress: false, + yuicompress: false, + optimization: 1, + silent: false, + paths: [], + color: true, + strictImports: false + }; + + var parseLessFile = function(input, output){ + return function (e, data) { + if (e) { + console.log('lessc:', e.message); + } + + new(less.Parser)({ + paths: [path.dirname(input)], + optimization: options.optimization, + filename: input + }).parse(data, function (err, tree) { + if (err) { + less.writeError(err, options); + } else { + try { + var css = tree.toCSS({ compress: options.compress }); + if (output) { + var fd = fs.openSync(output, "w"); + fs.writeSync(fd, css, 0, "utf8"); + } else { + console.log('WARNING: output is undefined'); + util.print(css); + } + } catch (e) { + less.writeError(e, options); + } + } + }); + }; + }; + + console.log('>>> Script is polling for changes. Press Ctrl-C to Stop.'); + + watchr.watch({ + path: watchPath, + listener: function(eventName, filePath, fileCurrentStat, filePreviousStat) { + if (eventName == 'change' || eventName == 'update') { + console.log('>>> Change detected at', new Date().toLocaleTimeString(), 'to:', path.basename(filePath)); + + var baseFilePath = path.basename(filePath, '.less'); + fs.readFile(filePath, 'utf-8', parseLessFile(filePath, '../css/' + baseFilePath + '.css')); + + console.log('overwrite', baseFilePath + '.css'); + } + }, + next: function(err, watcher) { + if (err) { + console.log('!!! epic fail'); + throw err; + } + + console.log('Now watching:', watchPath); + } + }); + +})(); From 028b9e5ed7822dcad21db515c97fb3152f6e792d Mon Sep 17 00:00:00 2001 From: OVSharova Date: Sun, 5 Sep 2021 03:28:25 +0300 Subject: [PATCH 08/26] cleaning --- test/documenteditor/main/index.html | 8 +- test/presentationeditor/main/index.html | 26 +- .../main/js/ApplicationController.js | 501 +++++------------- .../main/js/ApplicationView.js | 29 - .../main/resources/less/instaltools.bat | 2 - .../main/resources/less/watch.js | 75 --- 6 files changed, 144 insertions(+), 497 deletions(-) delete mode 100644 test/presentationeditor/main/resources/less/instaltools.bat delete mode 100644 test/presentationeditor/main/resources/less/watch.js diff --git a/test/documenteditor/main/index.html b/test/documenteditor/main/index.html index 78a7bb84b..0fb8c859b 100644 --- a/test/documenteditor/main/index.html +++ b/test/documenteditor/main/index.html @@ -11,8 +11,6 @@ - - @@ -65,9 +63,9 @@ var params = getUrlParams(), lang = (params["lang"] || 'en').split(/[\-\_]/)[0], - logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null; + //logo = params["headerlogo"] ? encodeUrlParam(params["headerlogo"]) : null; - window.frameEditorId = params["frameEditorId"]; + /*window.frameEditorId = params["frameEditorId"]; window.parentOrigin = params["parentOrigin"]; var elem = document.querySelector('.loading-logo'); @@ -76,7 +74,7 @@ var img = document.querySelector('.loading-logo img'); img && img.setAttribute('src', logo); img.style.opacity = 1; - } + }*/
    diff --git a/test/presentationeditor/main/index.html b/test/presentationeditor/main/index.html index aaa36cb3a..67cb141d7 100644 --- a/test/presentationeditor/main/index.html +++ b/test/presentationeditor/main/index.html @@ -17,7 +17,7 @@
    -
    +
    @@ -97,35 +97,35 @@ } -
    +
    -
    + -
    -
    + - -
    -
      -
    • -
    • -
    -
    -
    -
    -
    -
    -
    - -
    -
    - -
    -
    - + - - - - + + + + + - + - + - diff --git a/test/apps/presentationeditor/main/js/ApplicationController.js b/test/presentationeditor/main/js/ApplicationController.js similarity index 100% rename from test/apps/presentationeditor/main/js/ApplicationController.js rename to test/presentationeditor/main/js/ApplicationController.js diff --git a/test/apps/presentationeditor/main/js/ApplicationView.js b/test/presentationeditor/main/js/ApplicationView.js similarity index 100% rename from test/apps/presentationeditor/main/js/ApplicationView.js rename to test/presentationeditor/main/js/ApplicationView.js diff --git a/test/apps/presentationeditor/main/js/application.js b/test/presentationeditor/main/js/application.js similarity index 100% rename from test/apps/presentationeditor/main/js/application.js rename to test/presentationeditor/main/js/application.js diff --git a/test/apps/presentationeditor/main/resources/less/application.less b/test/presentationeditor/main/resources/less/application.less similarity index 100% rename from test/apps/presentationeditor/main/resources/less/application.less rename to test/presentationeditor/main/resources/less/application.less diff --git a/test/apps/spreadsheeteditor/main/index.html b/test/spreadsheeteditor/main/index.html similarity index 82% rename from test/apps/spreadsheeteditor/main/index.html rename to test/spreadsheeteditor/main/index.html index dd48f2302..2d0e93d7b 100644 --- a/test/apps/spreadsheeteditor/main/index.html +++ b/test/spreadsheeteditor/main/index.html @@ -9,7 +9,7 @@ - + @@ -42,7 +42,7 @@ - + - - + + + - - - - - + + + + + - + - + - - - + + diff --git a/test/apps/spreadsheeteditor/main/js/ApplicationController.js b/test/spreadsheeteditor/main/js/ApplicationController.js similarity index 100% rename from test/apps/spreadsheeteditor/main/js/ApplicationController.js rename to test/spreadsheeteditor/main/js/ApplicationController.js diff --git a/test/apps/spreadsheeteditor/main/js/ApplicationView.js b/test/spreadsheeteditor/main/js/ApplicationView.js similarity index 100% rename from test/apps/spreadsheeteditor/main/js/ApplicationView.js rename to test/spreadsheeteditor/main/js/ApplicationView.js diff --git a/test/apps/common/main/lib/controller/CellEditor.js b/test/spreadsheeteditor/main/js/CellEditorController.js similarity index 100% rename from test/apps/common/main/lib/controller/CellEditor.js rename to test/spreadsheeteditor/main/js/CellEditorController.js diff --git a/test/apps/common/main/lib/view/CellEditor.js b/test/spreadsheeteditor/main/js/CellEditorView.js similarity index 100% rename from test/apps/common/main/lib/view/CellEditor.js rename to test/spreadsheeteditor/main/js/CellEditorView.js diff --git a/test/apps/spreadsheeteditor/main/js/application.js b/test/spreadsheeteditor/main/js/application.js similarity index 91% rename from test/apps/spreadsheeteditor/main/js/application.js rename to test/spreadsheeteditor/main/js/application.js index 4d4a37bf3..00e21c9f8 100644 --- a/test/apps/spreadsheeteditor/main/js/application.js +++ b/test/spreadsheeteditor/main/js/application.js @@ -33,10 +33,8 @@ (function ($) { $(function(){ - Common.Locale.apply(function() { - SSE.ApplicationView.create(); - SSE.ApplicationController.create(); - }); + SSE.ApplicationView.create(); + SSE.ApplicationController.create(); }) })(window.jQuery); diff --git a/test/apps/spreadsheeteditor/main/resources/less/application.less b/test/spreadsheeteditor/main/resources/less/application.less similarity index 100% rename from test/apps/spreadsheeteditor/main/resources/less/application.less rename to test/spreadsheeteditor/main/resources/less/application.less diff --git a/test/apps/spreadsheeteditor/main/resources/less/celleditor.less b/test/spreadsheeteditor/main/resources/less/celleditor.less similarity index 100% rename from test/apps/spreadsheeteditor/main/resources/less/celleditor.less rename to test/spreadsheeteditor/main/resources/less/celleditor.less diff --git a/test/unit-tests/common.js b/test/unit-tests/common.js new file mode 100644 index 000000000..7261f02bc --- /dev/null +++ b/test/unit-tests/common.js @@ -0,0 +1,15 @@ +/** + * common.js + * + * Created by Alexander Yuzhin on 5/7/14 + * Copyright (c) 2018 Ascensio System SIA. All rights reserved. + * + */ + +// Include and setup all the stuff for testing +define([ + 'chai' +],function(chai) { + window.expect = chai.expect; + window.assert = chai.assert; +}); \ No newline at end of file diff --git a/test/apps/common/index.html b/test/unit-tests/common/index.html similarity index 82% rename from test/apps/common/index.html rename to test/unit-tests/common/index.html index 2b05f078f..71de33810 100644 --- a/test/apps/common/index.html +++ b/test/unit-tests/common/index.html @@ -3,12 +3,12 @@ Unit Tests - +
    - - + + diff --git a/test/unit-tests/common/main/lib/component/Button.js b/test/unit-tests/common/main/lib/component/Button.js new file mode 100644 index 000000000..69c06ed07 --- /dev/null +++ b/test/unit-tests/common/main/lib/component/Button.js @@ -0,0 +1,115 @@ +/** + * Button.js + * + * Unit test + * + * Created by Alexander Yuzhin on 6/20/14 + * Copyright (c) 2018 Ascensio System SIA. All rights reserved. + * + */ + +define([ + 'backbone', + '../../../../../../../web-apps — копиÑ/apps/common/main/lib/component/Button.js', + '../../../../../apps/common/main/lib/component/Menu.js' +],function() { + var chai = require('chai'), + should = chai.should(); + + describe('Common.UI.Button', function(){ + var button, + domPlaceholder = document.createElement('div'); + + it('Create simple button', function(){ + $('body').append(domPlaceholder); + + button = new Common.UI.Button({ + id: 'id-btn-simple', + caption: 'test' + }); + + button.render($(domPlaceholder)); + + should.exist(button); + $('#id-btn-simple').should.have.length(1); + }); + + it('Button caption', function(){ + button.caption.should.equal('test'); + }); + + it('Button update caption', function(){ + button.setCaption('update caption'); + + // object + button.caption.should.equal('update caption'); + + // dom + assert.equal(button.cmpEl.find('button:first').andSelf().filter('button').text(), 'update caption', 'dom caption'); + }); + + it('Button toggle', function(){ + button.toggle(); + assert.equal(button.isActive(), true, 'should by active'); + button.toggle(); + assert.equal(button.isActive(), false, 'should NOT by active'); + + button.toggle(false); + assert.equal(button.isActive(), false, 'should NOT by active'); + button.toggle(true); + assert.equal(button.isActive(), true, 'should by active'); + + button.toggle(false); + }); + + it('Button disable', function(){ + assert.equal(button.isDisabled(), false, 'should NOT by disable'); + + button.setDisabled(true); + assert.equal(button.isDisabled(), true, 'should by disable'); + + button.setDisabled(false); + assert.equal(button.isDisabled(), false, 'should NOT by disable'); + }); + + it('Remove simple button', function(){ + button.remove(); + $('#id-btn-simple').should.have.length(0); + + button = null; +// domPlaceholder.remove(); + }); + + it('Create split button', function(){ + $('body').append(domPlaceholder); + + button = new Common.UI.Button({ + id : 'id-btn-split', + caption : 'split', + split : true, + menu : new Common.UI.Menu({ + items: [ + { + caption: 'print', + value: 'print' + } + ] + }) + }); + + button.render($(domPlaceholder)); + + should.exist(button); + $('#id-btn-split').should.have.length(1); + $('#id-btn-split button').should.have.length(2); + }); + + it('Remove split button', function(){ + button.remove(); + $('#id-btn-split').should.have.length(0); + + button = null; +// domPlaceholder.remove(); + }); + }); +}); \ No newline at end of file diff --git a/test/unit-tests/common/main/lib/util/utils.js b/test/unit-tests/common/main/lib/util/utils.js new file mode 100644 index 000000000..082a4536a --- /dev/null +++ b/test/unit-tests/common/main/lib/util/utils.js @@ -0,0 +1,33 @@ +/** + * utils.js + * + * Unit test + * + * Created by Alexander Yuzhin on 5/7/14 + * Copyright (c) 2018 Ascensio System SIA. All rights reserved. + * + */ + +define([ + '../../../../../../../web-apps — копиÑ/apps/common/main/lib/util/utils.js' +],function() { + describe('Common.Utils.String', function(){ + it('Test format', function(){ + assert.equal('successively: first, second', Common.Utils.String.format('successively: {0}, {1}', 'first', 'second')); + assert.equal('revers: second, first', Common.Utils.String.format('revers: {1}, {0}', 'first', 'second')); + }); + + it('Test htmlEncode', function(){ + assert.equal('Curly, Larry & Moe', Common.Utils.String.htmlEncode('Curly, Larry & Moe')); + }); + + it('Test htmlDecode', function(){ + assert.equal('Curly, Larry & Moe', Common.Utils.String.htmlDecode('Curly, Larry & Moe')); + }); + + it('Test ellipsis', function(){ + assert.equal('Truncate a s...', Common.Utils.String.ellipsis('Truncate a string and add an ellipsis', 15)); + assert.equal('Truncate a string and add...', Common.Utils.String.ellipsis('Truncate a string and add an ellipsis', 30, true)); + }); + }); +}); \ No newline at end of file From cb4e35774c17fc0d8e677bb7037d7017fbe5b239 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Thu, 16 Sep 2021 00:32:19 +0300 Subject: [PATCH 22/26] Move files --- test/common/main/lib/util/utils.js | 28 ---- test/common/main/lib/view/LoadMask.js | 101 ------------ .../main/resources/img/icon-menu-sprite.svg | 152 ------------------ .../main/resources/img/icon-social-sprite.svg | 1 - test/common/main/resources/img/logo.svg | 1 - test/common/main/resources/img/next-field.png | Bin 323 -> 0 bytes .../main/resources/img/previous-field.png | Bin 323 -> 0 bytes test/common/main/resources/less/common.less | 12 +- test/common/main/resources/less/loadmask.less | 4 +- test/documenteditor/main/index.html | 1 - .../main/js/ApplicationController.js | 24 +-- .../main/resources/less/asc-mixins.less | 0 .../main/resources/less/buttons.less | 0 .../resources/less/colors-table-ie-fix.less | 0 .../main/resources/less/colors-table.less | 0 .../main/resources/less/variables.less | 0 test/presentationeditor/main/index.html | 1 - .../main/js/ApplicationController.js | 22 +-- test/spreadsheeteditor/main/index.html | 1 - .../main/js/ApplicationController.js | 117 +++----------- .../main/js/ApplicationView.js | 13 +- .../main/js/CellEditorController.js | 79 ++------- .../main/js/CellEditorView.js | 9 +- .../main/resources/less/celleditor.less | 10 +- 24 files changed, 81 insertions(+), 495 deletions(-) delete mode 100644 test/common/main/lib/view/LoadMask.js delete mode 100644 test/common/main/resources/img/icon-menu-sprite.svg delete mode 100644 test/common/main/resources/img/icon-social-sprite.svg delete mode 100644 test/common/main/resources/img/logo.svg delete mode 100644 test/common/main/resources/img/next-field.png delete mode 100644 test/common/main/resources/img/previous-field.png rename test/{common => documenteditor}/main/resources/less/asc-mixins.less (100%) rename test/{common => documenteditor}/main/resources/less/buttons.less (100%) rename test/{common => documenteditor}/main/resources/less/colors-table-ie-fix.less (100%) rename test/{common => documenteditor}/main/resources/less/colors-table.less (100%) rename test/{common => documenteditor}/main/resources/less/variables.less (100%) diff --git a/test/common/main/lib/util/utils.js b/test/common/main/lib/util/utils.js index 2d275b85e..f43316d6f 100644 --- a/test/common/main/lib/util/utils.js +++ b/test/common/main/lib/util/utils.js @@ -43,34 +43,6 @@ if (newDocumentPage) newDocumentPage.focus(); } - } - , dialogPrint: function(url, api) { - $('#id-print-frame').remove(); - - if ( !!url ) { - var iframePrint = document.createElement("iframe"); - - iframePrint.id = "id-print-frame"; - iframePrint.style.display = 'none'; - iframePrint.style.visibility = "hidden"; - iframePrint.style.position = "fixed"; - iframePrint.style.right = "0"; - iframePrint.style.bottom = "0"; - document.body.appendChild(iframePrint); - - iframePrint.onload = function () { - try { - iframePrint.contentWindow.focus(); - iframePrint.contentWindow.print(); - iframePrint.contentWindow.blur(); - window.focus(); - } catch (e) { - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF)); - } - }; - - iframePrint.src = url; - } }, htmlEncode: function(value) { return $('
    ').text(value).html(); diff --git a/test/common/main/lib/view/LoadMask.js b/test/common/main/lib/view/LoadMask.js deleted file mode 100644 index 87f15409b..000000000 --- a/test/common/main/lib/view/LoadMask.js +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * (c) Copyright Ascensio System SIA 2010-2021 - * - * This program is a free software product. You can redistribute it and/or - * modify it under the terms of the GNU Affero General Public License (AGPL) - * version 3 as published by the Free Software Foundation. In accordance with - * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect - * that Ascensio System SIA expressly excludes the warranty of non-infringement - * of any third-party rights. - * - * This program is distributed WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For - * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html - * - * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha - * street, Riga, Latvia, EU, LV-1050. - * - * The interactive user interfaces in modified source and object code versions - * of the Program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU AGPL version 3. - * - * Pursuant to Section 7(b) of the License you must retain the original Product - * logo when distributing the program. Pursuant to Section 7(e) we decline to - * grant you any rights under trademark law for use of our trademarks. - * - * All the Product's GUI elements, including illustrations and icon sets, as - * well as technical writing content are licensed under the terms of the - * Creative Commons Attribution-ShareAlike 4.0 International. See the License - * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode - * - */ -/** - * LoadMask.js - * - * Displays loading mask over selected element(s) or component. Accepts both single and multiple selectors. - * - * Created by Julia Radzhabova 24.06.2021 - * Copyright (c) 2021 Ascensio System SIA. All rights reserved. - * - */ - -!window.common && (window.common = {}); -!common.view && (common.view = {}); - -common.view.LoadMask = function(owner) { - var tpl = ''; - 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/test/common/main/resources/img/icon-menu-sprite.svg b/test/common/main/resources/img/icon-menu-sprite.svg deleted file mode 100644 index 97b51fd3e..000000000 --- a/test/common/main/resources/img/icon-menu-sprite.svg +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/test/common/main/resources/img/icon-social-sprite.svg b/test/common/main/resources/img/icon-social-sprite.svg deleted file mode 100644 index 500662ae7..000000000 --- a/test/common/main/resources/img/icon-social-sprite.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/common/main/resources/img/logo.svg b/test/common/main/resources/img/logo.svg deleted file mode 100644 index 0d3cb18e7..000000000 --- a/test/common/main/resources/img/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/test/common/main/resources/img/next-field.png b/test/common/main/resources/img/next-field.png deleted file mode 100644 index ee043c87821f62d56be8c8fee0602c00486bb31b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^7C z9OUlAu=X{Nfl8?MbtTeT}odeyI7+ly_hYCqXKGuyo_ zKJcLB!G7T;dPCAAC=nVgB=#KJOJMR|t5 zpFHD1os;txG)yR&vtYxddDa>RURLiFRCi8yeP12EZvCWPlU?W61V-6 SKfN31M+Q$ z9OUlAu6F7R)Lt=yzi2M$G+dd>JZ1*)DB#_Hb`Pt7)d=)C3Jmz07J*>k1+ z^tj|=MfNnYzqztI`5wpF%4v6JY&f$?&}`L#KQ$p~k2sif9S@~H@Gn0-Ta-QQ>5e;B zD`z#eyf0#re!1ZOG-U}7ZlRh}XJ?+3x0tG(ZTgvGSMiJLT#0jwW*7OE3cif|!Y9vc zC1v!+;lpp2**5lpyoXr5-%0-Pl}kR-p9X>T#)66)&zx Sxoigdk-^i|&t;ucLK6Uyr+q8{ diff --git a/test/common/main/resources/less/common.less b/test/common/main/resources/less/common.less index 64f80cea2..a63781e39 100644 --- a/test/common/main/resources/less/common.less +++ b/test/common/main/resources/less/common.less @@ -236,12 +236,12 @@ // Logo // ------------------------- -.brand-logo { +/*.brand-logo { display: block; width: 100px; height: 24px; background: data-uri('../../../../unit-tests/common/main/resources/img/logo.svg') no-repeat; -} +}*/ // Control buttons // ------------------------- @@ -484,7 +484,7 @@ } } -.svg { +/*.svg { background: data-uri('../../../../unit-tests/common/main/resources/img/icon-social-sprite.svg'); width: 40px; @@ -498,11 +498,11 @@ &.big-twitter { .socnet-btn(1); } &.big-gplus { .socnet-btn(2); } &.big-email { .socnet-btn(3); } -} +}*/ @icon-width: 20px; @icon-height: 20px; -.svg-icon { +/*.svg-icon { background: data-uri('../../../../unit-tests/common/main/resources/img/icon-menu-sprite.svg') no-repeat; background-size: @icon-width*19 @icon-height*2; @@ -565,7 +565,7 @@ height: @icon-height; float: left; margin: -3px 4px 0 -24px; -} +}*/ .btn-icon { width: 22px; height: 22px; diff --git a/test/common/main/resources/less/loadmask.less b/test/common/main/resources/less/loadmask.less index 26d068654..6803024ad 100644 --- a/test/common/main/resources/less/loadmask.less +++ b/test/common/main/resources/less/loadmask.less @@ -41,13 +41,13 @@ vertical-align: middle; } - .asc-loadmask-image { + /* .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; diff --git a/test/documenteditor/main/index.html b/test/documenteditor/main/index.html index 70f363d91..b1ef1a729 100644 --- a/test/documenteditor/main/index.html +++ b/test/documenteditor/main/index.html @@ -96,7 +96,6 @@ - diff --git a/test/documenteditor/main/js/ApplicationController.js b/test/documenteditor/main/js/ApplicationController.js index 6bf17e21f..da590884f 100644 --- a/test/documenteditor/main/js/ApplicationController.js +++ b/test/documenteditor/main/js/ApplicationController.js @@ -122,14 +122,16 @@ DE.ApplicationController = new(function(){ function onLongActionBegin(type, id) { if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - if (!me.loadMask) + /*if (!me.loadMask) me.loadMask = new common.view.LoadMask(); - me.loadMask.show(); + me.loadMask.show();*/ + console.log('Action begin'); } } function onLongActionEnd(type, id){ - me.loadMask && me.loadMask.hide(); + //me.loadMask && me.loadMask.hide(); + console.log('Action end'); } function hidePreloader() { @@ -137,7 +139,7 @@ DE.ApplicationController = new(function(){ } function onDocumentContentReady() { - hidePreloader(); + //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var zf = (config.customization && config.customization.zoom ? parseInt(config.customization.zoom) : -2); @@ -177,7 +179,8 @@ DE.ApplicationController = new(function(){ function onOpenDocument(progress) { var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); + //me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); + //console.log('onOpenDocument'); } function onError(id, level, errData) { @@ -192,7 +195,7 @@ DE.ApplicationController = new(function(){ return; } - hidePreloader(); + //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; @@ -286,10 +289,11 @@ DE.ApplicationController = new(function(){ function onExternalMessage(error) { if (error) { - hidePreloader(); - $('#id-error-mask-title').text(me.criticalErrorTitle); + //hidePreloader(); + /*$('#id-error-mask-title').text(me.criticalErrorTitle); $('#id-error-mask-text').text(error.msg); - $('#id-error-mask').css('display', 'block'); + $('#id-error-mask').css('display', 'block');*/ + console.error(error.msg); } } @@ -363,7 +367,7 @@ DE.ApplicationController = new(function(){ if (api){ api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); - api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); + //api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); // Initialize api gateway Common.Gateway.on('init', loadConfig); diff --git a/test/common/main/resources/less/asc-mixins.less b/test/documenteditor/main/resources/less/asc-mixins.less similarity index 100% rename from test/common/main/resources/less/asc-mixins.less rename to test/documenteditor/main/resources/less/asc-mixins.less diff --git a/test/common/main/resources/less/buttons.less b/test/documenteditor/main/resources/less/buttons.less similarity index 100% rename from test/common/main/resources/less/buttons.less rename to test/documenteditor/main/resources/less/buttons.less diff --git a/test/common/main/resources/less/colors-table-ie-fix.less b/test/documenteditor/main/resources/less/colors-table-ie-fix.less similarity index 100% rename from test/common/main/resources/less/colors-table-ie-fix.less rename to test/documenteditor/main/resources/less/colors-table-ie-fix.less diff --git a/test/common/main/resources/less/colors-table.less b/test/documenteditor/main/resources/less/colors-table.less similarity index 100% rename from test/common/main/resources/less/colors-table.less rename to test/documenteditor/main/resources/less/colors-table.less diff --git a/test/common/main/resources/less/variables.less b/test/documenteditor/main/resources/less/variables.less similarity index 100% rename from test/common/main/resources/less/variables.less rename to test/documenteditor/main/resources/less/variables.less diff --git a/test/presentationeditor/main/index.html b/test/presentationeditor/main/index.html index 94734d7d7..4ee99595f 100644 --- a/test/presentationeditor/main/index.html +++ b/test/presentationeditor/main/index.html @@ -168,7 +168,6 @@ - diff --git a/test/presentationeditor/main/js/ApplicationController.js b/test/presentationeditor/main/js/ApplicationController.js index f181f58b4..b0194e02e 100644 --- a/test/presentationeditor/main/js/ApplicationController.js +++ b/test/presentationeditor/main/js/ApplicationController.js @@ -114,7 +114,7 @@ PE.ApplicationController = new(function(){ } function onLongActionBegin(type, id) { - var text = ''; + /* var text = ''; switch (id) { case LoadingDocument: @@ -123,18 +123,20 @@ PE.ApplicationController = new(function(){ default: text = me.waitText; break; - } + }*/ if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - if (!me.loadMask) + /*if (!me.loadMask) me.loadMask = new common.view.LoadMask(); me.loadMask.setTitle(text); - me.loadMask.show(); + me.loadMask.show();*/ + console.log('Action begin'); } } function onLongActionEnd(){ - me.loadMask && me.loadMask.hide(); + //me.loadMask && me.loadMask.hide(); + console.log('Action end'); } function hidePreloader() { @@ -144,7 +146,7 @@ PE.ApplicationController = new(function(){ function onDocumentContentReady() { api.ShowThumbnails(true); - hidePreloader(); + //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); @@ -176,7 +178,7 @@ PE.ApplicationController = new(function(){ function onOpenDocument(progress) { var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); + //me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); } /* var isplaymode; @@ -217,7 +219,7 @@ PE.ApplicationController = new(function(){ return; } - hidePreloader(); + //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; @@ -304,7 +306,7 @@ PE.ApplicationController = new(function(){ function onExternalMessage(error) { if (error) { - hidePreloader(); + //hidePreloader(); /*$('#id-error-mask-title').text(me.criticalErrorTitle); $('#id-error-mask-text').text(error.msg); $('#id-error-mask').css('display', 'block');*/ @@ -381,7 +383,7 @@ PE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); - api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); + //api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); // Initialize api gateway Common.Gateway.on('init', loadConfig); diff --git a/test/spreadsheeteditor/main/index.html b/test/spreadsheeteditor/main/index.html index 2d0e93d7b..dc77c9c73 100644 --- a/test/spreadsheeteditor/main/index.html +++ b/test/spreadsheeteditor/main/index.html @@ -155,7 +155,6 @@ - diff --git a/test/spreadsheeteditor/main/js/ApplicationController.js b/test/spreadsheeteditor/main/js/ApplicationController.js index ca4383c4c..05b6c6213 100644 --- a/test/spreadsheeteditor/main/js/ApplicationController.js +++ b/test/spreadsheeteditor/main/js/ApplicationController.js @@ -51,7 +51,6 @@ SSE.ApplicationController = new(function(){ // ------------------------- if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ - //Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); console.error( this.unsupportedBrowserErrorText); return; } @@ -65,8 +64,8 @@ SSE.ApplicationController = new(function(){ function loadConfig(data) { config = $.extend(config, data.config); - config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && - (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose); + /*config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && + (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose);*/ } function loadDocument(data) { @@ -104,16 +103,8 @@ SSE.ApplicationController = new(function(){ docInfo.put_Lang(config.lang); docInfo.put_Mode(config.mode); - docInfo.asc_putIsEnabledMacroses(false); - docInfo.asc_putIsEnabledPlugins(false); - /*var enable = !config.customization || (config.customization.macros!==false); - docInfo.asc_putIsEnabledMacroses(!!enable); - enable = !config.customization || (config.customization.plugins!==false); - docInfo.asc_putIsEnabledPlugins(!!enable);*/ - if (api) { api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); - // api.asc_registerCallback('asc_onRunAutostartMacroses', onRunAutostartMacroses); api.asc_setDocInfo(docInfo); api.asc_getEditorPermissions(config.licenseUrl, config.customerId); api.asc_enableKeyEvents(false); @@ -157,18 +148,12 @@ SSE.ApplicationController = new(function(){ setActiveWorkSheet(api.asc_getActiveWorksheetIndex()); } - function hidePreloader() { - $('#loading-mask').fadeOut('slow'); - } - function onDocumentContentReady() { - hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); - api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); api.asc_registerCallback('asc_onStartAction', onLongActionBegin); - Common.Gateway.on('processmouse', onProcessMouse); - Common.Gateway.on('downloadas', onDownloadAs); + //Common.Gateway.on('processmouse', onProcessMouse); + //Common.Gateway.on('downloadas', onDownloadAs); Common.Gateway.on('requestclose', onRequestClose); @@ -189,36 +174,17 @@ SSE.ApplicationController = new(function(){ } function onEditorPermissions(params) { + api.asc_SetFastCollaborative(true); api.asc_setAutoSaveGap(1); onLongActionBegin(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); - - //api.asc_setViewMode(true); api.asc_LoadDocument(); } - - function onOpenDocument(progress) { - var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); - } function onLongActionBegin(type, id){ - var text = ''; - switch (id) - { - case LoadingDocument: - text = me.textLoadingDocument + ' '; - break; - default: - text = me.waitText; - break; - } if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - if (!me.loadMask) - me.loadMask = new common.view.LoadMask(); - me.loadMask.setTitle(text); - me.loadMask.show(); + console.log('Action begin'); } } @@ -237,23 +203,16 @@ SSE.ApplicationController = new(function(){ break; } - me.loadMask && me.loadMask.hide(); + console.log('Action end'); } } function onError(id, level, errData) { if (id == Asc.c_oAscError.ID.LoadingScriptError) { - /*$('#id-critical-error-title').text(me.criticalErrorTitle); - $('#id-critical-error-message').text(me.scriptLoadError); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - window.location.reload(); - }); - $('#id-critical-error-dialog').css('z-index', 20002).modal('show');*/ - console.error(me.scriptLoadError); + console.error(id,me.scriptLoadError); return; } - hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; @@ -311,41 +270,18 @@ SSE.ApplicationController = new(function(){ } if (level == Asc.c_oAscError.Level.Critical) { - - // report only critical errors - //Common.Gateway.reportError(id, message); console.error(id,message); - - /* $('#id-critical-error-title').text(me.criticalErrorTitle); - $('#id-critical-error-message').html(message); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - window.location.reload(); - });*/ } else { - // Common.Gateway.reportWarning(id, message); console.warn(id,message); - - /*$('#id-critical-error-title').text(me.notcriticalErrorTitle); - $('#id-critical-error-message').html(message); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - $('#id-critical-error-dialog').modal('hide'); - });*/ } - - //$('#id-critical-error-dialog').modal('show'); - - //Common.Analytics.trackEvent('Internal Error', id.toString()); } function onExternalMessage(error) { if (error) { - hidePreloader(); $('#id-error-mask-title').text(me.criticalErrorTitle); $('#id-error-mask-text').text(error.msg); $('#id-error-mask').css('display', 'block'); - - //Common.Analytics.trackEvent('External Error'); } } @@ -364,26 +300,9 @@ SSE.ApplicationController = new(function(){ Common.Gateway.requestClose(); } - function onDownloadAs() { - if ( permissions.download === false) { - //Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); - console.error(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); - return; - } - api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.XLSX, true)); - } - - - function onRunAutostartMacroses() { - if (!config.customization || (config.customization.macros!==false)) - if (api) api.asc_runAutostartMacroses(); - } - function onBeforeUnload () { common.localStorage.save(); } - // Helpers - // ------------------------- function onDocumentResize() { if (api) api.asc_Resize(); @@ -412,14 +331,12 @@ SSE.ApplicationController = new(function(){ if (api){ api.asc_registerCallback('asc_onEndAction', onLongActionEnd); api.asc_registerCallback('asc_onError', onError); - api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); api.asc_registerCallback('asc_onSheetsChanged', onSheetsChanged); api.asc_registerCallback('asc_onActiveSheetChanged', setActiveWorkSheet); - if(common.controller.CellEditor ) { - common.controller.CellEditor.create(); - common.controller.CellEditor.setApi(api) - common.controller.CellEditor.setMode(config); + if(SSE.CellEditorController ) { + SSE.CellEditorController.create(); + SSE.CellEditorController.setApi(api); } // Initialize api gateway Common.Gateway.on('init', loadConfig); @@ -428,6 +345,18 @@ SSE.ApplicationController = new(function(){ Common.Gateway.appReady(); } + api.asc_enableKeyEvents(true); + var ismodalshown = false; + $(document.body).on('blur', 'input, textarea', + function(e) { + if ( !ismodalshown ) { + if (!/area_id/.test(e.target.id) ) { + api.asc_enableKeyEvents(true); + } + } + } + ); + return me; } diff --git a/test/spreadsheeteditor/main/js/ApplicationView.js b/test/spreadsheeteditor/main/js/ApplicationView.js index 1f03ca6ac..fed4273c7 100644 --- a/test/spreadsheeteditor/main/js/ApplicationView.js +++ b/test/spreadsheeteditor/main/js/ApplicationView.js @@ -41,24 +41,19 @@ SSE.ApplicationView = new(function(){ // Initialize view function createView(){ - $btnTools = $('#box-tools button'); + /*$btnTools = $('#box-tools button'); $btnTools.addClass('dropdown-toggle').attr('data-toggle', 'dropdown').attr('aria-expanded', 'true'); $btnTools.parent().append( ''); + '');*/ } - function getTools(name) { - return $btnTools.parent().find(name); - } + return { - create: createView - , tools: { - get: getTools - }, + create: createView, txtDownload: 'Download', txtPrint: 'Print', diff --git a/test/spreadsheeteditor/main/js/CellEditorController.js b/test/spreadsheeteditor/main/js/CellEditorController.js index ad2b29953..64d3d524b 100644 --- a/test/spreadsheeteditor/main/js/CellEditorController.js +++ b/test/spreadsheeteditor/main/js/CellEditorController.js @@ -1,47 +1,11 @@ !window.common && (window.common = {}); !common.controller && (common.controller = {}); +if (SSE === undefined) { + var SSE = {}; +} +SSE.Keys={RETURN: 13}; -common.ui = _.extend(common.ui || {}, { - Keys : { - BACKSPACE: 8, - TAB: 9, - RETURN: 13, - SHIFT: 16, - CTRL: 17, - ALT: 18, - ESC: 27, - LEFT: 37, - UP: 38, - RIGHT: 39, - DOWN: 40, - DELETE: 46, - HOME: 36, - END: 35, - SPACE: 32, - PAGEUP: 33, - PAGEDOWN: 34, - INSERT: 45, - EQUALITY_FF:61, - NUM_PLUS: 107, - NUM_MINUS: 109, - F1: 112, - F2: 113, - F3: 114, - F4: 115, - F5: 116, - F6: 117, - F7: 118, - F8: 119, - F9: 120, - F10: 121, - F11: 122, - F12: 123, - MINUS_FF: 173, - EQUALITY: 187, - MINUS: 189 - }}); - -common.controller.CellEditor = new(function(){ +SSE.CellEditorController = new(function(){ var me, api, editor, @@ -49,7 +13,7 @@ common.controller.CellEditor = new(function(){ created=false; function onCellName(e){ - if (e.keyCode == common.ui.Keys.RETURN){ + if (e.keyCode == SSE.Keys.RETURN){ var name = editor.$cellname.val(); if (name && name.length) { api.asc_findCell(name); @@ -58,7 +22,7 @@ common.controller.CellEditor = new(function(){ } function onKeyupCellEditor(e) { - if(e.keyCode == common.ui.Keys.RETURN && !e.altKey){ + if(e.keyCode == SSE.Keys.RETURN && !e.altKey){ api.isCEditorFocused = 'clear'; } } @@ -70,11 +34,7 @@ common.controller.CellEditor = new(function(){ api.isCEditorFocused = true; } - function onLayoutResize(o, r) { - if (r == 'cell:edit') { - o && common.localStorage.setBool('sse-celleditor-expand', false); - } - } + function events() { editor.$el.find('#ce-cell-name').on( 'keyup', onCellName); @@ -83,17 +43,16 @@ common.controller.CellEditor = new(function(){ } function onLaunch(){ - common.view.CellEditor.create(); - editor = common.view.CellEditor; + SSE.CellEditorView.create(); + editor = SSE.CellEditorView; events(); editor.$el.parent().find('.after').css({zIndex: '4'}); // for spreadsheets - bug 23127 var val = common.localStorage.getItem('sse-celleditor-height'); - editor.keep_height = (val!==null && parseInt(val)>0) ? parseInt(val) : 19; + editor.keep_height = 19;//(val!==null && parseInt(val)>0) ? parseInt(val) : 19; if (common.localStorage.getBool('sse-celleditor-expand')) { editor.$el.height(editor.keep_height); - onLayoutResize(undefined, 'cell:edit'); } this.namedrange_locked = false; } @@ -126,10 +85,6 @@ common.controller.CellEditor = new(function(){ } } - function onLockDefNameManager(state) { - this.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager); - } - function onApiDisconnect() { mode.isEdit = false; } @@ -141,20 +96,9 @@ common.controller.CellEditor = new(function(){ api.asc_registerCallback('asc_onSelectionNameChanged', onApiCellSelection); api.asc_registerCallback('asc_onEditCell', onApiEditCell); api.asc_registerCallback('asc_onCoAuthoringDisconnect', onApiDisconnect); - api.asc_registerCallback('asc_onLockDefNameManager', onLockDefNameManager); } - function onApiSelectionChanged(info) { - if (this.viewmode) return; // signed file - } - function setMode(modeF) { - mode = modeF; - - if ( mode.isEdit ) { - api.asc_registerCallback('asc_onSelectionChanged', onApiSelectionChanged); - } - } function setPreviewMode(mode) { if (this.viewmode === mode) return; @@ -165,7 +109,6 @@ common.controller.CellEditor = new(function(){ return { create: createController, setApi: setApi, - setMode: setMode, setPreviewMode: setPreviewMode } diff --git a/test/spreadsheeteditor/main/js/CellEditorView.js b/test/spreadsheeteditor/main/js/CellEditorView.js index 413eaf523..9ee6e016e 100644 --- a/test/spreadsheeteditor/main/js/CellEditorView.js +++ b/test/spreadsheeteditor/main/js/CellEditorView.js @@ -30,12 +30,11 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ +if (SSE === undefined) { + var SSE = {}; +} - -!window.common && (window.common = {}); -!common.view && (common.view = {}); - -common.view.CellEditor = new(function (){ +SSE.CellEditorView = new(function (){ var me; function createView() diff --git a/test/spreadsheeteditor/main/resources/less/celleditor.less b/test/spreadsheeteditor/main/resources/less/celleditor.less index 35da90ec2..077b81e60 100644 --- a/test/spreadsheeteditor/main/resources/less/celleditor.less +++ b/test/spreadsheeteditor/main/resources/less/celleditor.less @@ -1,9 +1,9 @@ // Common styles -@import "../../../../common/main/resources/less/colors-table-ie-fix.less"; -@import "../../../../common/main/resources/less/variables.less"; -@import "../../../../common/main/resources/less/colors-table.less"; -@import "../../../../common/main/resources/less/asc-mixins.less"; -@import "../../../../common/main/resources/less/buttons.less"; +@import "../../../../documenteditor/main/resources/less/colors-table-ie-fix.less"; +@import "../../../../documenteditor/main/resources/less/variables.less"; +@import "../../../../documenteditor/main/resources/less/colors-table.less"; +@import "../../../../documenteditor/main/resources/less/asc-mixins.less"; +@import "../../../../documenteditor/main/resources/less/buttons.less"; #cell-editing-box { border-bottom: solid @scaled-one-px-value-ie @border-toolbar-ie; border-bottom: solid @scaled-one-px-value @border-toolbar; From bef78882d0bc80648d62495bede2739b0cb23172 Mon Sep 17 00:00:00 2001 From: OVSharova Date: Thu, 16 Sep 2021 01:35:51 +0300 Subject: [PATCH 23/26] Refactoring --- .../main/resources/less/app.less | 1 - .../main/resources/less/app.less | 1 - .../main/resources/less/app.less | 1 - test/common/main/lib/util/utils.js | 23 -- test/common/main/resources/less/common.less | 3 - test/common/main/resources/less/loadmask.less | 74 ----- .../main/js/ApplicationController.js | 61 +--- .../main/js/ApplicationController.js | 108 +------ test/spreadsheeteditor/main/index.html | 304 ++++++++---------- .../main/js/ApplicationController.js | 1 - .../main/js/ApplicationView.js | 22 +- .../main/js/CellEditorController.js | 9 +- 12 files changed, 152 insertions(+), 456 deletions(-) delete mode 100644 test/common/main/resources/less/loadmask.less diff --git a/apps/documenteditor/main/resources/less/app.less b/apps/documenteditor/main/resources/less/app.less index 54e4f6f2a..04cf4099b 100644 --- a/apps/documenteditor/main/resources/less/app.less +++ b/apps/documenteditor/main/resources/less/app.less @@ -86,7 +86,6 @@ @import "../../../../common/main/resources/less/combobox.less"; @import "../../../../common/main/resources/less/window.less"; @import "../../../../common/main/resources/less/spinner.less"; -@import "../../../../common/main/resources/less/loadmask.less"; @import "../../../../common/main/resources/less/checkbox.less"; @import "../../../../common/main/resources/less/radiobox.less"; @import "../../../../common/main/resources/less/dataview.less"; diff --git a/apps/presentationeditor/main/resources/less/app.less b/apps/presentationeditor/main/resources/less/app.less index 8a80c847c..aa030154a 100644 --- a/apps/presentationeditor/main/resources/less/app.less +++ b/apps/presentationeditor/main/resources/less/app.less @@ -86,7 +86,6 @@ @import "../../../../common/main/resources/less/combobox.less"; @import "../../../../common/main/resources/less/window.less"; @import "../../../../common/main/resources/less/spinner.less"; -@import "../../../../common/main/resources/less/loadmask.less"; @import "../../../../common/main/resources/less/checkbox.less"; @import "../../../../common/main/resources/less/radiobox.less"; @import "../../../../common/main/resources/less/dataview.less"; diff --git a/apps/spreadsheeteditor/main/resources/less/app.less b/apps/spreadsheeteditor/main/resources/less/app.less index 8244ff99a..9d4fc911f 100644 --- a/apps/spreadsheeteditor/main/resources/less/app.less +++ b/apps/spreadsheeteditor/main/resources/less/app.less @@ -86,7 +86,6 @@ @import "../../../../common/main/resources/less/combobox.less"; @import "../../../../common/main/resources/less/window.less"; @import "../../../../common/main/resources/less/spinner.less"; -@import "../../../../common/main/resources/less/loadmask.less"; @import "../../../../common/main/resources/less/checkbox.less"; @import "../../../../common/main/resources/less/radiobox.less"; @import "../../../../common/main/resources/less/dataview.less"; diff --git a/test/common/main/lib/util/utils.js b/test/common/main/lib/util/utils.js index f43316d6f..89ca68344 100644 --- a/test/common/main/lib/util/utils.js +++ b/test/common/main/lib/util/utils.js @@ -37,13 +37,6 @@ common.utils = new(function(){ return { - openLink: function(url) { - if (url) { - var newDocumentPage = window.open(url, '_blank'); - if (newDocumentPage) - newDocumentPage.focus(); - } - }, htmlEncode: function(value) { return $('
    ').text(value).html(); }, @@ -56,22 +49,6 @@ _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 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/test/documenteditor/main/js/ApplicationController.js b/test/documenteditor/main/js/ApplicationController.js index da590884f..718bbd6d5 100644 --- a/test/documenteditor/main/js/ApplicationController.js +++ b/test/documenteditor/main/js/ApplicationController.js @@ -38,7 +38,6 @@ DE.ApplicationController = new(function(){ permissions = {}, created = false, appOptions = {}, - _submitFail, $submitedTooltip, bodyWidth = 0; var LoadingDocument = -256; @@ -47,7 +46,6 @@ DE.ApplicationController = new(function(){ // ------------------------- if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ - //Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); console.error(this.unsupportedBrowserErrorText); return; } @@ -122,24 +120,15 @@ DE.ApplicationController = new(function(){ function onLongActionBegin(type, id) { if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - /*if (!me.loadMask) - me.loadMask = new common.view.LoadMask(); - me.loadMask.show();*/ console.log('Action begin'); } } function onLongActionEnd(type, id){ - //me.loadMask && me.loadMask.hide(); console.log('Action end'); } - function hidePreloader() { - $('#loading-mask').fadeOut('slow'); - } - function onDocumentContentReady() { - //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var zf = (config.customization && config.customization.zoom ? parseInt(config.customization.zoom) : -2); @@ -147,15 +136,13 @@ DE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onStartAction', onLongActionBegin); api.asc_registerCallback('asc_onEndAction', onLongActionEnd); - api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); - - Common.Gateway.on('processmouse', onProcessMouse); - Common.Gateway.on('downloadas', onDownloadAs); + //Common.Gateway.on('processmouse', onProcessMouse); + //Common.Gateway.on('downloadas', onDownloadAs); Common.Gateway.on('requestclose', onRequestClose); - var downloadAs = function(format){ + /*var downloadAs = function(format){ api.asc_DownloadAs(new Asc.asc_CDownloadOptions(format)); - }; + };*/ // TODO: add asc_hasRequiredFields to sdk Common.Gateway.documentReady(); @@ -177,25 +164,12 @@ DE.ApplicationController = new(function(){ api.Resize(); } - function onOpenDocument(progress) { - var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - //me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); - //console.log('onOpenDocument'); - } - function onError(id, level, errData) { if (id == Asc.c_oAscError.ID.LoadingScriptError) { - /*$('#id-critical-error-title').text(me.criticalErrorTitle); - $('#id-critical-error-message').text(me.scriptLoadError); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - window.location.reload(); - }); - $('#id-critical-error-dialog').css('z-index', 20002).modal('show');*/ console.error(me.criticalErrorTitle,me.scriptLoadError); return; } - //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; @@ -240,8 +214,6 @@ DE.ApplicationController = new(function(){ case Asc.c_oAscError.ID.Submit: message = me.errorSubmit; - /*_submitFail = true; - $submitedTooltip && $submitedTooltip.hide();*/ break; case Asc.c_oAscError.ID.EditingError: @@ -263,36 +235,16 @@ DE.ApplicationController = new(function(){ } if (level == Asc.c_oAscError.Level.Critical) { - - // report only critical errors - //Common.Gateway.reportError(id, message); console.error(id,message); - /*$('#id-critical-error-title').text(me.criticalErrorTitle); - $('#id-critical-error-message').html(message); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - window.location.reload(); - });*/ } else { - //Common.Gateway.reportWarning(id, message); console.warn(id, message); - /*$('#id-critical-error-title').text(me.notcriticalErrorTitle); - $('#id-critical-error-message').html(message); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - $('#id-critical-error-dialog').modal('hide'); - });*/ } - - //$('#id-critical-error-dialog').modal('show'); } function onExternalMessage(error) { if (error) { - //hidePreloader(); - /*$('#id-error-mask-title').text(me.criticalErrorTitle); - $('#id-error-mask-text').text(error.msg); - $('#id-error-mask').css('display', 'block');*/ console.error(error.msg); } } @@ -324,11 +276,6 @@ DE.ApplicationController = new(function(){ if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.DOCX, false)); } - function onRunAutostartMacroses() { - if (!config.customization || (config.customization.macros!==false)) - if (api) api.asc_runAutostartMacroses(); - } - function onBeforeUnload () { common.localStorage.save(); } diff --git a/test/presentationeditor/main/js/ApplicationController.js b/test/presentationeditor/main/js/ApplicationController.js index b0194e02e..38bf3bf32 100644 --- a/test/presentationeditor/main/js/ApplicationController.js +++ b/test/presentationeditor/main/js/ApplicationController.js @@ -44,7 +44,6 @@ PE.ApplicationController = new(function(){ // ------------------------- if (typeof isBrowserSupported !== 'undefined' && !isBrowserSupported()){ - //Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); console.error(this.unsupportedBrowserErrorText); return; } @@ -58,8 +57,6 @@ PE.ApplicationController = new(function(){ function loadConfig(data) { config = $.extend(config, data.config); - config.canBackToFolder = (config.canBackToFolder!==false) && config.customization && config.customization.goback && - (config.customization.goback.url || config.customization.goback.requestClose && config.canRequestClose); } function loadDocument(data) { @@ -95,16 +92,8 @@ PE.ApplicationController = new(function(){ docInfo.put_Permissions(_permissions); docInfo.put_EncryptedInfo(config.encryptionKeys); - docInfo.asc_putIsEnabledMacroses(false); - docInfo.asc_putIsEnabledPlugins(false); - /* var enable = !config.customization || (config.customization.macros!==false); - docInfo.asc_putIsEnabledMacroses(!!enable); - enable = !config.customization || (config.customization.plugins!==false); - docInfo.asc_putIsEnabledPlugins(!!enable);*/ - if (api) { api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions); - //api.asc_registerCallback('asc_onRunAutostartMacroses', onRunAutostartMacroses); api.asc_setDocInfo(docInfo); api.asc_getEditorPermissions(config.licenseUrl, config.customerId); api.asc_enableKeyEvents(true); @@ -114,50 +103,27 @@ PE.ApplicationController = new(function(){ } function onLongActionBegin(type, id) { - /* var text = ''; - switch (id) - { - case LoadingDocument: - text = me.textLoadingDocument + ' '; - break; - default: - text = me.waitText; - break; - }*/ if (type == Asc.c_oAscAsyncActionType['BlockInteraction']) { - /*if (!me.loadMask) - me.loadMask = new common.view.LoadMask(); - me.loadMask.setTitle(text); - me.loadMask.show();*/ + console.log('Action begin'); } } function onLongActionEnd(){ - //me.loadMask && me.loadMask.hide(); console.log('Action end'); } - function hidePreloader() { - $('#loading-mask').fadeOut('slow'); - } - function onDocumentContentReady() { api.ShowThumbnails(true); - //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); - api.asc_registerCallback('asc_onHyperlinkClick', common.utils.openLink); api.asc_registerCallback('asc_onStartAction', onLongActionBegin); api.asc_registerCallback('asc_onEndAction', onLongActionEnd); - // api.asc_registerCallback('asc_onEndDemonstration', onPlayStop); - //.asc_registerCallback('asc_onDemonstrationSlideChanged', onPlaySlideChanged); - - Common.Gateway.on('processmouse', onProcessMouse); - Common.Gateway.on('downloadas', onDownloadAs); + //Common.Gateway.on('processmouse', onProcessMouse); + //Common.Gateway.on('downloadas', onDownloadAs); Common.Gateway.on('requestclose', onRequestClose); $('#editor_sdk').on('click', function(e) { @@ -176,50 +142,12 @@ PE.ApplicationController = new(function(){ api.Resize(); } - function onOpenDocument(progress) { - var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); - //me.loadMask && me.loadMask.setTitle(me.textLoadingDocument + ': ' + common.utils.fixedDigits(Math.min(Math.round(proc*100), 100), 3, " ") + '%'); - } - - /* var isplaymode; - function onPlayStart(e) { - if ( !isplaymode ) { - $('#box-preview').show(); - api.StartDemonstration('id-preview', currentPage); - } else { - isplaymode == 'play' ? - api.DemonstrationPause() : api.DemonstrationPlay(); - } - - isplaymode != 'play' ? ($('#btn-play button').addClass('pause'), isplaymode = 'play') : - ($('#btn-play button').removeClass('pause'), isplaymode = 'pause'); - } - - function onPlayStop() { - isplaymode = undefined; - $('#page-number').val(currentPage + 1); - //$('#btn-play button').removeClass('pause'); - $('#box-preview').hide(); - } - - function onPlaySlideChanged(number) { - if ( number++ < maxPages) - $('#page-number').val(number); - }*/ - function onError(id, level, errData) { if (id == Asc.c_oAscError.ID.LoadingScriptError) { - /*$('#id-critical-error-title').text(me.criticalErrorTitle); - $('#id-critical-error-message').text(me.scriptLoadError); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - window.location.reload(); - }); - $('#id-critical-error-dialog').css('z-index', 20002).modal('show');*/ console.error(me.scriptLoadError); return; } - //hidePreloader(); onLongActionEnd(Asc.c_oAscAsyncActionType['BlockInteraction'], LoadingDocument); var message; @@ -280,39 +208,16 @@ PE.ApplicationController = new(function(){ // report only critical errors console.error(id,message); - /*Common.Gateway.reportError(id, message); - - $('#id-crical-error-title').text(me.criticalErrorTitle); - $('#id-critical-error-message').html(message); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - window.location.reload(); - });*/ } else { console.warn(id,message); - /*Common.Gateway.reportWarning(id, message); - - $('#id-critical-error-title').text(me.notcriticalErrorTitle); - $('#id-critical-error-message').html(message); - $('#id-critical-error-close').text(me.txtClose).off().on('click', function(){ - $('#id-critical-error-dialog').modal('hide'); - });*/ } - //$('#id-critical-error-dialog').modal('show'); - - //Common.Analytics.trackEvent('Internal Error', id.toString()); } function onExternalMessage(error) { if (error) { - //hidePreloader(); - /*$('#id-error-mask-title').text(me.criticalErrorTitle); - $('#id-error-mask-text').text(error.msg); - $('#id-error-mask').css('display', 'block');*/ console.error(error.msg); - - //Common.Analytics.trackEvent('External Error'); } } @@ -335,18 +240,12 @@ PE.ApplicationController = new(function(){ function onDownloadAs() { if ( permissions.download === false) { - //Common.Gateway.reportError(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); console.error(Asc.c_oAscError.ID.AccessDeny, me.errorAccessDeny); return; } if (api) api.asc_DownloadAs(new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PPTX, false)); } - function onRunAutostartMacroses() { - if (!config.customization || (config.customization.macros!==false)) - if (api) api.asc_runAutostartMacroses(); - } - function onBeforeUnload () { common.localStorage.save(); } @@ -383,7 +282,6 @@ PE.ApplicationController = new(function(){ api.asc_registerCallback('asc_onError', onError); api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady); - //api.asc_registerCallback('asc_onOpenDocumentProgress', onOpenDocument); // Initialize api gateway Common.Gateway.on('init', loadConfig); diff --git a/test/spreadsheeteditor/main/index.html b/test/spreadsheeteditor/main/index.html index dc77c9c73..f36a0cf78 100644 --- a/test/spreadsheeteditor/main/index.html +++ b/test/spreadsheeteditor/main/index.html @@ -1,185 +1,167 @@ - - - Documents - - - + + + Documents + + + - + - - - - - - + + + + + + - - + - - + + + + + + +
    +
    +
    +
    + +
    +
    +
    + +
    -
    -
    +
    +
    +
      -
      -
      -
      -
      -
      -
      --> - - - - - - - - -
      -
      -
      -
      - -
      -
      -
      - -
      -
      -
      -
      -
        -
        -