From a90f108209ab0fdbb9d306bd5084a05fa8f8da02 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Nov 2017 15:20:51 +0300 Subject: [PATCH 1/8] [DE] Change applying the license (disable editing when connections are over the limitations). --- .../main/lib/controller/ReviewChanges.js | 8 ++- .../main/app/controller/Main.js | 18 +++++-- .../main/app/controller/Toolbar.js | 1 + .../documenteditor/main/app/view/Statusbar.js | 46 +++++++++-------- apps/documenteditor/main/app/view/Toolbar.js | 51 ------------------- 5 files changed, 46 insertions(+), 78 deletions(-) diff --git a/apps/common/main/lib/controller/ReviewChanges.js b/apps/common/main/lib/controller/ReviewChanges.js index 42df2d3f3..fd09c572d 100644 --- a/apps/common/main/lib/controller/ReviewChanges.js +++ b/apps/common/main/lib/controller/ReviewChanges.js @@ -94,7 +94,7 @@ define([ Common.NotificationCenter.on('reviewchanges:turn', this.onTurnPreview.bind(this)); Common.NotificationCenter.on('spelling:turn', this.onTurnSpelling.bind(this)); Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); - Common.NotificationCenter.on('api:disconnect', _.bind(this.SetDisabled, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiServerDisconnect, this)); }, setConfig: function (data, api) { this.setApi(api); @@ -111,7 +111,7 @@ define([ this.api.asc_registerCallback('asc_onShowRevisionsChange', _.bind(this.onApiShowChange, this)); this.api.asc_registerCallback('asc_onUpdateRevisionsChangesPosition', _.bind(this.onApiUpdateChangePosition, this)); } - this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.SetDisabled, this)); + this.api.asc_registerCallback('asc_onCoAuthoringDisconnect',_.bind(this.onApiServerDisconnect, this)); } }, @@ -624,6 +624,10 @@ define([ })).show(); }, + onApiServerDisconnect: function() { + this.SetDisabled(true); + }, + textInserted: 'Inserted:', textDeleted: 'Deleted:', textParaInserted: 'Paragraph Inserted ', diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index d0fe09077..f9fabd06c 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -331,6 +331,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); @@ -934,6 +935,9 @@ define([ $(document).on('contextmenu', _.bind(me.onContextMenu, me)); if (this._state.licenseWarning) { + this.disableEditing(true); + Common.NotificationCenter.trigger('api:disconnect'); + value = Common.localStorage.getItem("de-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); @@ -942,7 +946,7 @@ define([ Common.UI.info({ width: 500, title: this.textNoLicenseTitle, - msg : this.warnNoLicense, + msg : this._state.licenseWarning, buttons: [ {value: 'buynow', caption: this.textBuyNow}, {value: 'contact', caption: this.textContactUs} @@ -959,6 +963,13 @@ define([ } }, + onLicenseChanged: function(params) { + var licType = params.asc_getLicenseType(); + if ((licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + }, + onOpenDocument: function(progress) { var elem = document.getElementById('loadmask-text'); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); @@ -1030,8 +1041,6 @@ define([ this.appOptions.canDownloadOrigin = this.permissions.download !== false && (type && typeof type[1] === 'string'); this.appOptions.canDownload = this.permissions.download !== false && (!type || typeof type[1] !== 'string'); - this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; - this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object'); if (this.appOptions.canBranding) appHeader.setBranding(this.editorConfig.customization); @@ -2121,7 +2130,8 @@ define([ txtStyle_Intense_Quote: 'Intense Quote', txtStyle_List_Paragraph: 'List Paragraph', saveTextText: 'Saving document...', - saveTitleText: 'Saving Document' + saveTitleText: 'Saving Document', + warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' } })(), DE.Controllers.Main || {})) diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index f28badea1..9b0958798 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2761,6 +2761,7 @@ define([ onApiCoAuthoringDisconnect: function(disableDownload) { this.toolbar.setMode({isDisconnected:true, disableDownload: !!disableDownload}); this.editMode = false; + this.DisableToolbar(true, true); }, DisableToolbar: function(disable, viewMode, reviewmode) { diff --git a/apps/documenteditor/main/app/view/Statusbar.js b/apps/documenteditor/main/app/view/Statusbar.js index 40a3cbb23..ccfbdae51 100644 --- a/apps/documenteditor/main/app/view/Statusbar.js +++ b/apps/documenteditor/main/app/view/Statusbar.js @@ -86,27 +86,25 @@ define([ me.btnZoomDown.updateHint(me.tipZoomOut + Common.Utils.String.platformKey('Ctrl+-')); me.btnZoomUp.updateHint(me.tipZoomIn + Common.Utils.String.platformKey('Ctrl++')); - if ( config.isEdit ) { - me.btnLanguage.updateHint(me.tipSetLang); - me.btnLanguage.cmpEl.on({ - 'show.bs.dropdown': function () { - _.defer(function () { - me.btnLanguage.cmpEl.find('ul').focus(); - }, 100); - }, - 'hide.bs.dropdown': function () { - _.defer(function () { - me.api.asc_enableKeyEvents(true); - }, 100); - }, - 'click': function (e) { - if (me.btnLanguage.isDisabled()) { - return false; - } + me.btnLanguage.updateHint(me.tipSetLang); + me.btnLanguage.cmpEl.on({ + 'show.bs.dropdown': function () { + _.defer(function () { + me.btnLanguage.cmpEl.find('ul').focus(); + }, 100); + }, + 'hide.bs.dropdown': function () { + _.defer(function () { + me.api.asc_enableKeyEvents(true); + }, 100); + }, + 'click': function (e) { + if (me.btnLanguage.isDisabled()) { + return false; } - }); - me.langMenu.on('item:click', _.bind(_clickLanguage, this)); - } + } + }); + me.langMenu.on('item:click', _.bind(_clickLanguage, this)); me.cntZoom.updateHint(me.tipZoomFactor); me.cntZoom.cmpEl.on({ @@ -325,6 +323,7 @@ define([ if (this.api) { this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this)); this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); } return this; @@ -356,7 +355,7 @@ define([ this.langMenu.doLayout(); if (this.langMenu.items.length>0) { - this.btnLanguage.setDisabled(false); + this.btnLanguage.setDisabled(!!this.mode.isDisconnected); } }, @@ -390,6 +389,11 @@ define([ this.btnLanguage.setDisabled(disable || !langs); }, + onApiCoAuthoringDisconnect: function() { + this.setMode({isDisconnected:true}); + this.SetDisabled(true); + }, + pageIndexText : 'Page {0} of {1}', goToPageText : 'Go to Page', tipFitPage : 'Fit to Page', diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 7f63b5438..8a6ee001a 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -2089,59 +2089,8 @@ define([ button.setDisabled(true); } }); - this.btnCopy.setDisabled(true); - this.btnPaste.setDisabled(true); - this.btnUndo.setDisabled(true); - this.btnRedo.setDisabled(true); - this.btnIncFontSize.setDisabled(true); - this.btnDecFontSize.setDisabled(true); - this.btnBold.setDisabled(true); - this.btnItalic.setDisabled(true); - this.btnUnderline.setDisabled(true); - this.btnStrikeout.setDisabled(true); - this.btnSuperscript.setDisabled(true); - this.btnSubscript.setDisabled(true); - this.btnHighlightColor.setDisabled(true); - this.btnFontColor.setDisabled(true); - this.btnParagraphColor.setDisabled(true); - this.btnMarkers.setDisabled(true); - this.btnNumbers.setDisabled(true); - this.btnMultilevels.setDisabled(true); - this.btnAlignLeft.setDisabled(true); - this.btnAlignCenter.setDisabled(true); - this.btnAlignRight.setDisabled(true); - this.btnAlignJust.setDisabled(true); - this.btnDecLeftOffset.setDisabled(true); - this.btnIncLeftOffset.setDisabled(true); - this.btnLineSpace.setDisabled(true); - this.btnShowHidenChars.setDisabled(true); - this.btnInsertTable.setDisabled(true); - this.btnInsertImage.setDisabled(true); - this.btnInsertChart.setDisabled(true); - this.btnInsertText.setDisabled(true); - this.btnInsertTextArt.setDisabled(true); - this.btnDropCap.setDisabled(true); - this.btnColumns.setDisabled(true); - this.btnInsertHyperlink.setDisabled(true); - this.btnEditHeader.setDisabled(true); - this.btnInsertShape.setDisabled(true); - this.btnInsertEquation.setDisabled(true); - this.btnPageOrient.setDisabled(true); - this.btnPageMargins.setDisabled(true); - this.btnPageSize.setDisabled(true); - this.btnClearStyle.setDisabled(true); - this.btnCopyStyle.setDisabled(true); - this.btnColorSchemas.setDisabled(true); - this.btnMailRecepients.setDisabled(true); - this.btnHorizontalAlign.setDisabled(true); - this.cmbFontName.setDisabled(true); - this.cmbFontSize.setDisabled(true); - this.listStyles.setDisabled(true); - this.btnNotes.setDisabled(true); if (mode.disableDownload) this.btnPrint.setDisabled(true); - - this.btnsPageBreak.disable(true); } this.mode = mode; From 82be9521264d0917bb5ca7fc0c09c37acc2f575f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Nov 2017 16:32:43 +0300 Subject: [PATCH 2/8] [DE] Change applying license. --- .../main/app/controller/Main.js | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index f9fabd06c..0101869a9 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -912,6 +912,8 @@ define([ if (me.appOptions.canBrandingExt) Common.NotificationCenter.trigger('document:ready', 'main'); + + me.applyLicense(); } }, 50); } else { @@ -933,12 +935,24 @@ define([ Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'}); $(document).on('contextmenu', _.bind(me.onContextMenu, me)); + }, + onLicenseChanged: function(params) { + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady) + this.applyLicense(); + }, + + applyLicense: function() { if (this._state.licenseWarning) { this.disableEditing(true); Common.NotificationCenter.trigger('api:disconnect'); - value = Common.localStorage.getItem("de-license-warning"); + var value = Common.localStorage.getItem("de-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { @@ -963,13 +977,6 @@ define([ } }, - onLicenseChanged: function(params) { - var licType = params.asc_getLicenseType(); - if ((licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { - this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; - } - }, - onOpenDocument: function(progress) { var elem = document.getElementById('loadmask-text'); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); From 20cc14ae5cb9c7e57c14a26fea9ae00e6c61b22a Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Nov 2017 16:34:00 +0300 Subject: [PATCH 3/8] [DE mobile] Change applying the license (disable editing when connections are over the limitations). --- .../mobile/app/controller/Main.js | 28 +++++++++++++++---- .../mobile/app/controller/Toolbar.js | 13 +++++++++ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 3aa2febc6..021255431 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -237,6 +237,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); @@ -551,10 +552,26 @@ define([ me.api.zoomFitToWidth(); } - DE.getController('Toolbar').activateControls(); + me.applyLicense(); + }, + onLicenseChanged: function(params) { + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady && this._state.licenseWarning) + this.applyLicense(); + }, + + applyLicense: function() { + var me = this; if (me._state.licenseWarning) { - value = Common.localStorage.getItem("de-license-warning"); + DE.getController('Toolbar').deactivateControls(); + Common.NotificationCenter.trigger('api:disconnect'); + + var value = Common.localStorage.getItem("de-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); @@ -577,10 +594,11 @@ define([ window.open('mailto:sales@onlyoffice.com', "_blank"); } } - ], + ] }); } - } + } else + DE.getController('Toolbar').activateControls(); }, onOpenDocument: function(progress) { @@ -638,8 +656,6 @@ define([ me.appOptions.canDownload = me.permissions.download !== false && (!type || typeof type[1] !== 'string'); me.appOptions.canReader = (!type || typeof type[1] !== 'string'); - me._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && me.appOptions.canEdit && me.editorConfig.mode !== 'view'; - me.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof me.editorConfig.customization == 'object'); me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object'); diff --git a/apps/documenteditor/mobile/app/controller/Toolbar.js b/apps/documenteditor/mobile/app/controller/Toolbar.js index 2da2aca06..e295d2e64 100644 --- a/apps/documenteditor/mobile/app/controller/Toolbar.js +++ b/apps/documenteditor/mobile/app/controller/Toolbar.js @@ -79,6 +79,7 @@ define([ this.api.asc_registerCallback('asc_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo')); this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo')); this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); }, setMode: function (mode) { @@ -138,6 +139,8 @@ define([ // API handlers onApiCanRevert: function(which, can) { + if (this.isDisconnected) return; + if (which == 'undo') { $('#toolbar-undo').toggleClass('disabled', !can); } else { @@ -146,6 +149,8 @@ define([ }, onApiFocusObject: function (objects) { + if (this.isDisconnected) return; + if (objects.length > 0) { var topObject = _.find(objects.reverse(), function (obj) { return obj.get_ObjectType() != Asc.c_oAscTypeSelectElement.SpellCheck; @@ -161,6 +166,14 @@ define([ $('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').removeClass('disabled'); }, + deactivateControls: function() { + $('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').addClass('disabled'); + }, + + onCoAuthoringDisconnect: function() { + this.isDisconnected = true; + }, + dlgLeaveTitleText : 'You leave the application', dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', leaveButtonText : 'Leave this Page', From 620c4ab5c2eda1882c337eec610faec9a77d4e74 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Nov 2017 17:41:40 +0300 Subject: [PATCH 4/8] [PE] Change applying the license (disable editing when connections are over the limitations). --- .../main/app/controller/Main.js | 36 ++++++++++++++++--- .../main/app/view/DocumentHolder.js | 3 +- .../main/app/view/Statusbar.js | 8 ++++- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 9412332c1..22a587dd6 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -319,6 +319,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); @@ -695,6 +696,8 @@ define([ if (me.appOptions.canBrandingExt) Common.NotificationCenter.trigger('document:ready', 'main'); + + me.applyLicense(); } }, 50); } else { @@ -715,9 +718,24 @@ define([ Common.Gateway.sendInfo({mode:me.appOptions.isEdit?'edit':'view'}); $(document).on('contextmenu', _.bind(me.onContextMenu, me)); + }, + onLicenseChanged: function(params) { + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady) + this.applyLicense(); + }, + + applyLicense: function() { if (this._state.licenseWarning) { - value = Common.localStorage.getItem("pe-license-warning"); + this.disableEditing(true); + Common.NotificationCenter.trigger('api:disconnect'); + + var value = Common.localStorage.getItem("pe-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { @@ -725,7 +743,7 @@ define([ Common.UI.info({ width: 500, title: this.textNoLicenseTitle, - msg : this.warnNoLicense, + msg : this._state.licenseWarning, buttons: [ {value: 'buynow', caption: this.textBuyNow}, {value: 'contact', caption: this.textContactUs} @@ -742,6 +760,15 @@ define([ } }, + disableEditing: function(disable) { + var app = this.getApplication(); + if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + app.getController('RightMenu').getView('RightMenu').clearSelection(); + app.getController('Toolbar').DisableToolbar(disable); + app.getController('Statusbar').getView('Statusbar').SetDisabled(disable); + } + }, + onOpenDocument: function(progress) { var elem = document.getElementById('loadmask-text'); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); @@ -788,8 +815,6 @@ define([ this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly); this.appOptions.trialMode = params.asc_getLicenseMode(); - this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; - this.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof this.editorConfig.customization == 'object'); if (this.appOptions.canBranding) appHeader.setBranding(this.editorConfig.customization); @@ -1910,7 +1935,8 @@ define([ textChangesSaved: 'All changes saved', saveTitleText: 'Saving Document', saveTextText: 'Saving document...', - txtLoading: 'Loading...' + txtLoading: 'Loading...', + warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' } })(), PE.Controllers.Main || {})) }); diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index af797dd8c..297ea9580 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -217,7 +217,8 @@ define([ var onContextMenu = function(event){ _.delay(function(){ if (event.get_Type() == Asc.c_oAscContextMenuTypes.Thumbnails) { - showPopupMenu.call(me, me.slideMenu, {isSlideSelect: event.get_IsSlideSelect(), isSlideHidden: event.get_IsSlideHidden(), fromThumbs: true}, event); + if (me.mode.isEdit) + showPopupMenu.call(me, me.slideMenu, {isSlideSelect: event.get_IsSlideSelect(), isSlideHidden: event.get_IsSlideHidden(), fromThumbs: true}, event); } else { showObjectMenu.call(me, event); } diff --git a/apps/presentationeditor/main/app/view/Statusbar.js b/apps/presentationeditor/main/app/view/Statusbar.js index 13a9ad775..e4eb65355 100644 --- a/apps/presentationeditor/main/app/view/Statusbar.js +++ b/apps/presentationeditor/main/app/view/Statusbar.js @@ -303,6 +303,7 @@ define([ this.api.asc_registerCallback('asc_onCountPages', _.bind(_onCountPages, this)); this.api.asc_registerCallback('asc_onCurrentPage', _.bind(_onCurrentPage, this)); this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onApiCoAuthoringDisconnect, this)); } return this; @@ -344,7 +345,7 @@ define([ this.langMenu.doLayout(); if (this.langMenu.items.length>0) { this.btnLanguage.setDisabled(false || this._state.no_paragraph); - this.btnDocLanguage.setDisabled(false); + this.btnDocLanguage.setDisabled(!!this.mode.isDisconnected); } }, @@ -388,6 +389,11 @@ define([ this.btnLanguage.setDisabled(this._state.no_paragraph); }, + onApiCoAuthoringDisconnect: function() { + this.setMode({isDisconnected:true}); + this.SetDisabled(true); + }, + pageIndexText : 'Slide {0} of {1}', goToPageText : 'Go to Slide', tipFitPage : 'Fit to Slide', From c31fad7d91b00078757d71fa93c546032cb7a2ec Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Nov 2017 12:01:27 +0300 Subject: [PATCH 5/8] [PE mobile] Change applying the license (disable editing when connections are over the limitations). [DE mobile] Refactoring. --- .../mobile/app/controller/DocumentHolder.js | 7 +++- .../mobile/app/controller/Main.js | 8 +++-- .../mobile/app/controller/Toolbar.js | 8 +++-- .../mobile/app/controller/DocumentHolder.js | 7 +++- .../mobile/app/controller/Main.js | 36 ++++++++++++++----- .../mobile/app/controller/Toolbar.js | 17 +++++++++ 6 files changed, 67 insertions(+), 16 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/DocumentHolder.js b/apps/documenteditor/mobile/app/controller/DocumentHolder.js index 127777c59..99df18990 100644 --- a/apps/documenteditor/mobile/app/controller/DocumentHolder.js +++ b/apps/documenteditor/mobile/app/controller/DocumentHolder.js @@ -88,6 +88,7 @@ define([ me.api.asc_registerCallback('asc_onAuthParticipantsChanged',_.bind(me.onApiUsersChanged, me)); me.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(me.onApiUserConnection, me)); me.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(me.onApiDocumentContentReady, me)); + Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me)); me.api.asc_coAuthoringGetUsers(); }, @@ -344,7 +345,7 @@ define([ items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0]; }; - if (!objectLocked && _isEdit) { + if (!objectLocked && _isEdit && !me.isDisconnected) { if (canCopy) { menuItems.push({ caption: me.menuCut, @@ -399,6 +400,10 @@ define([ return menuItems; }, + onCoAuthoringDisconnect: function() { + this.isDisconnected = true; + }, + textGuest: 'Guest', menuCut: 'Cut', menuCopy: 'Copy', diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 021255431..d7ecec52d 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -568,7 +568,8 @@ define([ applyLicense: function() { var me = this; if (me._state.licenseWarning) { - DE.getController('Toolbar').deactivateControls(); + DE.getController('Toolbar').activateViewControls(); + DE.getController('Toolbar').deactivateEditControls(); Common.NotificationCenter.trigger('api:disconnect'); var value = Common.localStorage.getItem("de-license-warning"); @@ -579,7 +580,7 @@ define([ Common.localStorage.setItem("de-license-warning", now); uiApp.modal({ title: me.textNoLicenseTitle, - text : me.warnNoLicense, + text : me._state.licenseWarning, buttons: [ { text: me.textBuyNow, @@ -1274,7 +1275,8 @@ define([ txtStyle_Subtitle: 'Subtitle', txtStyle_Quote: 'Quote', txtStyle_Intense_Quote: 'Intense Quote', - txtStyle_List_Paragraph: 'List Paragraph' + txtStyle_List_Paragraph: 'List Paragraph', + warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/mobile/app/controller/Toolbar.js b/apps/documenteditor/mobile/app/controller/Toolbar.js index e295d2e64..3c124346a 100644 --- a/apps/documenteditor/mobile/app/controller/Toolbar.js +++ b/apps/documenteditor/mobile/app/controller/Toolbar.js @@ -166,8 +166,12 @@ define([ $('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').removeClass('disabled'); }, - deactivateControls: function() { - $('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').addClass('disabled'); + activateViewControls: function() { + $('#toolbar-search, #document-back').removeClass('disabled'); + }, + + deactivateEditControls: function() { + $('#toolbar-edit, #toolbar-add, #toolbar-settings').addClass('disabled'); }, onCoAuthoringDisconnect: function() { diff --git a/apps/presentationeditor/mobile/app/controller/DocumentHolder.js b/apps/presentationeditor/mobile/app/controller/DocumentHolder.js index 0bfa294c7..4f34bb20a 100644 --- a/apps/presentationeditor/mobile/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/mobile/app/controller/DocumentHolder.js @@ -81,6 +81,7 @@ define([ me.api.asc_registerCallback('asc_onShowPopMenu', _.bind(me.onApiShowPopMenu, me)); me.api.asc_registerCallback('asc_onHidePopMenu', _.bind(me.onApiHidePopMenu, me)); me.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(me.onApiDocumentContentReady, me)); + Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me)); }, setMode: function (mode) { @@ -253,7 +254,7 @@ define([ items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0]; }; - if (!objectLocked && _isEdit) { + if (!objectLocked && _isEdit && !me.isDisconnected) { if (canCopy && isObject) { menuItems.push({ caption: me.menuCut, @@ -309,6 +310,10 @@ define([ return menuItems; }, + onCoAuthoringDisconnect: function() { + this.isDisconnected = true; + }, + menuCut: 'Cut', menuCopy: 'Copy', menuPaste: 'Paste', diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 121372001..6492323f9 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -236,6 +236,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); @@ -511,18 +512,35 @@ define([ me.api.zoomFitToPage(); } - PE.getController('Toolbar').activateControls(); + me.applyLicense(); + }, + onLicenseChanged: function(params) { + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady && this._state.licenseWarning) + this.applyLicense(); + }, + + applyLicense: function() { + var me = this; if (me._state.licenseWarning) { - value = Common.localStorage.getItem("de-license-warning"); + PE.getController('Toolbar').activateViewControls(); + PE.getController('Toolbar').deactivateEditControls(); + Common.NotificationCenter.trigger('api:disconnect'); + + var value = Common.localStorage.getItem("pe-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { - Common.localStorage.setItem("de-license-warning", now); + Common.localStorage.setItem("pe-license-warning", now); uiApp.modal({ title: me.textNoLicenseTitle, - text : me.warnNoLicense, + text : me._state.licenseWarning, buttons: [ { text: me.textBuyNow, @@ -537,10 +555,11 @@ define([ window.open('mailto:sales@onlyoffice.com', "_blank"); } } - ], + ] }); } - } + } else + PE.getController('Toolbar').activateControls(); }, onOpenDocument: function(progress) { @@ -597,8 +616,6 @@ define([ me.appOptions.canDownloadOrigin = !me.appOptions.nativeApp && me.permissions.download !== false && (type && typeof type[1] === 'string'); me.appOptions.canDownload = !me.appOptions.nativeApp && me.permissions.download !== false && (!type || typeof type[1] !== 'string'); - me._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) && me.appOptions.canEdit && me.editorConfig.mode !== 'view'; - me.appOptions.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof me.editorConfig.customization == 'object'); me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object'); @@ -1259,7 +1276,8 @@ define([ txtImage: 'Image', txtSlideNumber: 'Slide number', txtSlideSubtitle: 'Slide subtitle', - txtSlideTitle: 'Slide title' + txtSlideTitle: 'Slide title', + warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' } })(), PE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/presentationeditor/mobile/app/controller/Toolbar.js b/apps/presentationeditor/mobile/app/controller/Toolbar.js index f9e5c197d..38fe181cc 100644 --- a/apps/presentationeditor/mobile/app/controller/Toolbar.js +++ b/apps/presentationeditor/mobile/app/controller/Toolbar.js @@ -79,6 +79,7 @@ define([ this.api.asc_registerCallback('asc_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo')); this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo')); this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); }, setMode: function (mode) { @@ -138,6 +139,8 @@ define([ // API handlers onApiCanRevert: function(which, can) { + if (this.isDisconnected) return; + if (which == 'undo') { $('#toolbar-undo').toggleClass('disabled', !can); } else { @@ -146,6 +149,8 @@ define([ }, onApiFocusObject: function (objects) { + if (this.isDisconnected) return; + if (objects.length > 0) { var slide_deleted = false, slide_lock = false, @@ -172,6 +177,18 @@ define([ $('#toolbar-preview, #toolbar-settings, #toolbar-search, #document-back').removeClass('disabled'); }, + activateViewControls: function() { + $('#toolbar-preview, #toolbar-search, #document-back').removeClass('disabled'); + }, + + deactivateEditControls: function() { + $('#toolbar-edit, #toolbar-add, #toolbar-settings').addClass('disabled'); + }, + + onCoAuthoringDisconnect: function() { + this.isDisconnected = true; + }, + dlgLeaveTitleText : 'You leave the application', dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', leaveButtonText : 'Leave this Page', From 85b8c5702a3eca2700d95758922a7dbfcc3e7ae4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Nov 2017 12:16:04 +0300 Subject: [PATCH 6/8] [SSE mobile] Change applying the license (disable editing when connections are over the limitations). --- .../mobile/app/controller/DocumentHolder.js | 7 ++- .../mobile/app/controller/Main.js | 44 ++++++++++++++----- .../mobile/app/controller/Toolbar.js | 17 +++++++ 3 files changed, 55 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js index 6651aaaf3..0690b9cf9 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js @@ -82,6 +82,7 @@ define([ this.api.asc_registerCallback('asc_onShowPopMenu', _.bind(this.onApiShowPopMenu, this)); this.api.asc_registerCallback('asc_onHidePopMenu', _.bind(this.onApiHidePopMenu, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); }, setMode: function (mode) { @@ -180,7 +181,7 @@ define([ }, onApiShowPopMenu: function(posX, posY) { - if ( !_isEdit ) return; + if ( !_isEdit || this.isDisconnected) return; if ($('.popover.settings, .popup.settings, .picker-modal.settings, .modal-in, .actions-modal').length > 0) { return; @@ -334,6 +335,10 @@ define([ return menuItems; }, + onCoAuthoringDisconnect: function() { + this.isDisconnected = true; + }, + warnMergeLostData: 'Operation can destroy data in the selected cells.
Continue?', menuCopy: 'Copy', menuCut: 'Cut', diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index aeeae8a11..c5335d8d6 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -239,6 +239,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); @@ -534,10 +535,33 @@ define([ mode: me.appOptions.isEdit ? 'edit' : 'view' }); - SSE.getController('Toolbar').activateControls(); + me.applyLicense(); + $('.view-main').on('click', function (e) { + uiApp.closeModal('.document-menu.modal-in'); + }) + }, + + onLicenseChanged: function(params) { + if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) return; + + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady && this._state.licenseWarning) + this.applyLicense(); + }, + + applyLicense: function() { + var me = this; if (me._state.licenseWarning) { - value = Common.localStorage.getItem("sse-license-warning"); + SSE.getController('Toolbar').activateViewControls(); + SSE.getController('Toolbar').deactivateEditControls(); + Common.NotificationCenter.trigger('api:disconnect'); + + var value = Common.localStorage.getItem("sse-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); @@ -545,7 +569,7 @@ define([ Common.localStorage.setItem("sse-license-warning", now); uiApp.modal({ title: me.textNoLicenseTitle, - text : me.warnNoLicense, + text : me._state.licenseWarning, buttons: [ { text: me.textBuyNow, @@ -560,14 +584,11 @@ define([ window.open('mailto:sales@onlyoffice.com', "_blank"); } } - ], + ] }); } - } - - $('.view-main').on('click', function (e) { - uiApp.closeModal('.document-menu.modal-in'); - }) + } else + SSE.getController('Toolbar').activateControls(); }, onOpenDocument: function(progress) { @@ -624,8 +645,6 @@ define([ me.appOptions.canDownload = !me.appOptions.nativeApp && (me.permissions.download !== false); me.appOptions.canPrint = (me.permissions.print !== false); - me._state.licenseWarning = !(me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && me.appOptions.canEdit && me.editorConfig.mode !== 'view'; - me.applyModeCommonElements(); me.applyModeEditorElements(); @@ -1417,7 +1436,8 @@ define([ txtStyle_Total: 'Total', txtStyle_Currency: 'Currency', txtStyle_Percent: 'Percent', - txtStyle_Comma: 'Comma' + txtStyle_Comma: 'Comma', + warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' } })(), SSE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js b/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js index 5ed1c7c18..53479d170 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Toolbar.js @@ -86,6 +86,7 @@ define([ this.api.asc_registerCallback('asc_onWorkbookLocked', _.bind(this.onApiWorkbookLocked, this)); this.api.asc_registerCallback('asc_onWorksheetLocked', _.bind(this.onApiWorksheetLocked, this)); this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onApiActiveSheetChanged, this)); + Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this)); Common.NotificationCenter.on('sheet:active', this.onApiActiveSheetChanged.bind(this)); }, @@ -159,6 +160,8 @@ define([ }, onApiCanRevert: function(which, can) { + if (this.isDisconnected) return; + if (which == 'undo') { $('#toolbar-undo').toggleClass('disabled', !can); } else { @@ -167,6 +170,8 @@ define([ }, onApiSelectionChanged: function(info) { + if (this.isDisconnected) return; + if ( !info ) info = this.api.asc_getCellInfo(); var islocked = false; @@ -195,6 +200,18 @@ define([ $('#toolbar-settings, #toolbar-search, #document-back').removeClass('disabled'); }, + activateViewControls: function() { + $('#toolbar-search, #document-back').removeClass('disabled'); + }, + + deactivateEditControls: function() { + $('#toolbar-edit, #toolbar-add, #toolbar-settings').addClass('disabled'); + }, + + onCoAuthoringDisconnect: function() { + this.isDisconnected = true; + }, + dlgLeaveTitleText : 'You leave the application', dlgLeaveMsgText : 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', leaveButtonText : 'Leave this Page', From b664680915967eac1d5df02c7d77b59f4cdf87f9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Nov 2017 13:40:45 +0300 Subject: [PATCH 7/8] [SSE] Change applying the license (disable editing when connections are over the limitations). [PE] Refactoring. --- .../main/app/controller/Main.js | 2 +- .../main/app/view/DocumentHolder.js | 3 ++ .../main/app/controller/DocumentHolder.js | 3 ++ .../main/app/controller/Main.js | 39 ++++++++++++++++--- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 22a587dd6..15e6badc4 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -739,7 +739,7 @@ define([ value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { - Common.localStorage.setItem("de-license-warning", now); + Common.localStorage.setItem("pe-license-warning", now); Common.UI.info({ width: 500, title: this.textNoLicenseTitle, diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index 297ea9580..df4466f13 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -186,6 +186,9 @@ define([ var fillViewMenuProps = function(selectedElements) { if (!selectedElements || !_.isArray(selectedElements)) return; + if (!me.viewModeMenu) + me.createDelayedElementsViewer(); + var menu_props = {}, menu_to_show = null; _.each(selectedElements, function(element, index) { diff --git a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js index 1ca136c2b..18be70765 100644 --- a/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/main/app/controller/DocumentHolder.js @@ -1492,6 +1492,9 @@ define([ iscellmenu = (seltype==Asc.c_oAscSelectionType.RangeCells) && !this.permissions.isEditMailMerge && !this.permissions.isEditDiagram, iscelledit = this.api.isCellEdited; + if (!documentHolder.viewModeMenu) + documentHolder.createDelayedElementsViewer(); + if (!showMenu && !documentHolder.viewModeMenu.isVisible()) return; documentHolder.menuViewUndo.setVisible(this.permissions.canCoAuthoring && this.permissions.canComments); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 9bf081dbd..381c47285 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -355,6 +355,7 @@ define([ } this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this)); + this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this)); this.api.asc_setDocInfo(docInfo); this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId); }, @@ -707,6 +708,8 @@ define([ if (me.appOptions.canBrandingExt) Common.NotificationCenter.trigger('document:ready', 'main'); + + me.applyLicense(); } }, 50); } else { @@ -741,17 +744,34 @@ define([ if (typeof document.hidden !== 'undefined' && document.hidden) { document.addEventListener('visibilitychange', checkWarns); } else checkWarns(); + }, + onLicenseChanged: function(params) { + if (this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) return; + + var licType = params.asc_getLicenseType(); + if (licType !== undefined && (licType===Asc.c_oLicenseResult.Connections || licType===Asc.c_oLicenseResult.Users) && this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + this._state.licenseWarning = (licType===Asc.c_oLicenseResult.Connections) ? this.warnNoLicense : this.warnNoLicenseUsers; + } + + if (this._isDocReady) + this.applyLicense(); + }, + + applyLicense: function() { if (this._state.licenseWarning) { - value = Common.localStorage.getItem("de-license-warning"); + this.disableEditing(true); + Common.NotificationCenter.trigger('api:disconnect'); + + var value = Common.localStorage.getItem("sse-license-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); if (now - value > 86400000) { - Common.localStorage.setItem("de-license-warning", now); + Common.localStorage.setItem("sse-license-warning", now); Common.UI.info({ width: 500, title: this.textNoLicenseTitle, - msg : this.warnNoLicense, + msg : this._state.licenseWarning, buttons: [ {value: 'buynow', caption: this.textBuyNow}, {value: 'contact', caption: this.textContactUs} @@ -768,6 +788,14 @@ define([ } }, + disableEditing: function(disable) { + var app = this.getApplication(); + if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') { + app.getController('RightMenu').getView('RightMenu').clearSelection(); + app.getController('Toolbar').DisableToolbar(disable); + } + }, + onOpenDocument: function(progress) { var elem = document.getElementById('loadmask-text'); var proc = (progress.asc_getCurrentFont() + progress.asc_getCurrentImage())/(progress.asc_getFontsCount() + progress.asc_getImagesCount()); @@ -831,8 +859,6 @@ define([ this.appOptions.forcesave = this.appOptions.canForcesave; this.appOptions.canEditComments= this.appOptions.isOffline || !(typeof (this.editorConfig.customization) == 'object' && this.editorConfig.customization.commentAuthorOnly); - this._state.licenseWarning = !(this.appOptions.isEditDiagram || this.appOptions.isEditMailMerge) && (licType===Asc.c_oLicenseResult.Connections) && this.appOptions.canEdit && this.editorConfig.mode !== 'view'; - this.applyModeCommonElements(); this.applyModeEditorElements(); @@ -2103,7 +2129,8 @@ define([ txtStyle_Total: 'Total', txtStyle_Currency: 'Currency', txtStyle_Percent: 'Percent', - txtStyle_Comma: 'Comma' + txtStyle_Comma: 'Comma', + warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' } })(), SSE.Controllers.Main || {})) }); From b9f90aa91c773d3aed945f3f586ff194732b4c3d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Nov 2017 14:00:02 +0300 Subject: [PATCH 8/8] Update translations. --- apps/documenteditor/main/app/controller/Main.js | 5 ++--- apps/documenteditor/main/locale/en.json | 1 + apps/documenteditor/mobile/app/controller/Main.js | 4 ++-- apps/documenteditor/mobile/locale/en.json | 1 + apps/presentationeditor/main/app/controller/Main.js | 4 ++-- apps/presentationeditor/main/locale/en.json | 1 + apps/presentationeditor/mobile/app/controller/Main.js | 4 ++-- apps/presentationeditor/mobile/locale/en.json | 1 + apps/spreadsheeteditor/main/app/controller/Main.js | 4 ++-- apps/spreadsheeteditor/main/locale/en.json | 1 + apps/spreadsheeteditor/mobile/app/controller/Main.js | 4 ++-- apps/spreadsheeteditor/mobile/locale/en.json | 1 + 12 files changed, 18 insertions(+), 13 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 0101869a9..bd90c68a7 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -2103,7 +2103,7 @@ define([ txtErrorLoadHistory: 'Loading history failed', textBuyNow: 'Visit website', textNoLicenseTitle: 'ONLYOFFICE open source version', - warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', + warnNoLicense: 'This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.', textContactUs: 'Contact sales', errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.', warnLicenseExp: 'Your license has expired.
Please update your license and refresh the page.', @@ -2138,8 +2138,7 @@ define([ txtStyle_List_Paragraph: 'List Paragraph', saveTextText: 'Saving document...', saveTitleText: 'Saving Document', - warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' - + warnNoLicenseUsers: 'This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 630f89fa0..c7f0fa98f 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -361,6 +361,7 @@ "DE.Controllers.Main.warnBrowserZoom": "Your browser current zoom setting is not fully supported. Please reset to the default zoom by pressing Ctrl+0.", "DE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "DE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.", + "DE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.", "DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "DE.Controllers.Statusbar.textHasChanges": "New changes have been tracked", "DE.Controllers.Statusbar.textTrackChanges": "The document is opened with the Track Changes mode enabled", diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index d7ecec52d..51bc65ef3 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -1238,7 +1238,7 @@ define([ textTryUndoRedo: 'The Undo/Redo functions are disabled for the Fast co-editing mode.', textBuyNow: 'Visit website', textNoLicenseTitle: 'ONLYOFFICE open source version', - warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', + warnNoLicense: 'This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.', textContactUs: 'Contact sales', errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download until the connection is restored.', warnLicenseExp: 'Your license has expired.
Please update your license and refresh the page.', @@ -1276,7 +1276,7 @@ define([ txtStyle_Quote: 'Quote', txtStyle_Intense_Quote: 'Intense Quote', txtStyle_List_Paragraph: 'List Paragraph', - warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' + warnNoLicenseUsers: 'This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 856671908..e335735a9 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -147,6 +147,7 @@ "DE.Controllers.Main.uploadImageTitleText": "Uploading Image", "DE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "DE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.", + "DE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.", "DE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "DE.Controllers.Search.textNoTextFound": "Text not Found", "DE.Controllers.Search.textReplaceAll": "Replace All", diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 15e6badc4..ff14f4917 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1904,7 +1904,7 @@ define([ textStrict: 'Strict mode', textBuyNow: 'Visit website', textNoLicenseTitle: 'ONLYOFFICE open source version', - warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', + warnNoLicense: 'This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.', textContactUs: 'Contact sales', errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.', warnLicenseExp: 'Your license has expired.
Please update your license and refresh the page.', @@ -1936,7 +1936,7 @@ define([ saveTitleText: 'Saving Document', saveTextText: 'Saving document...', txtLoading: 'Loading...', - warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' + warnNoLicenseUsers: 'This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.' } })(), PE.Controllers.Main || {})) }); diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 30ef68240..7e0fd0111 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -278,6 +278,7 @@ "PE.Controllers.Main.warnBrowserZoom": "Your browser current zoom setting is not fully supported. Please reset to the default zoom by pressing Ctrl+0.", "PE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "PE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.", + "PE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.", "PE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "PE.Controllers.Statusbar.zoomText": "Zoom {0}%", "PE.Controllers.Toolbar.confirmAddFontName": "The font you are going to save is not available on the current device.
The text style will be displayed using one of the system fonts, the saved font will be used when it is available.
Do you want to continue?", diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 6492323f9..cfbedce4a 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -1244,7 +1244,7 @@ define([ textTryUndoRedo: 'The Undo/Redo functions are disabled for the Fast co-editing mode.', textBuyNow: 'Visit website', textNoLicenseTitle: 'ONLYOFFICE open source version', - warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', + warnNoLicense: 'This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.', textContactUs: 'Contact sales', errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.', warnLicenseExp: 'Your license has expired.
Please update your license and refresh the page.', @@ -1277,7 +1277,7 @@ define([ txtSlideNumber: 'Slide number', txtSlideSubtitle: 'Slide subtitle', txtSlideTitle: 'Slide title', - warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' + warnNoLicenseUsers: 'This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.' } })(), PE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/presentationeditor/mobile/locale/en.json b/apps/presentationeditor/mobile/locale/en.json index f3a5064cc..ef5060bc6 100644 --- a/apps/presentationeditor/mobile/locale/en.json +++ b/apps/presentationeditor/mobile/locale/en.json @@ -204,6 +204,7 @@ "PE.Controllers.Main.uploadImageTitleText": "Uploading Image", "PE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "PE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.", + "PE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.", "PE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "PE.Controllers.Search.textNoTextFound": "Text not Found", "PE.Controllers.Settings.notcriticalErrorTitle": "Warning", diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 381c47285..066914cd7 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -2089,7 +2089,7 @@ define([ errorFrmlWrongReferences: 'The function refers to a sheet that does not exist.
Please check the data and try again.', textBuyNow: 'Visit website', textNoLicenseTitle: 'ONLYOFFICE open source version', - warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', + warnNoLicense: 'This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.', textContactUs: 'Contact sales', confirmPutMergeRange: 'The source data contains merged cells.
They will be unmerged before they are pasted into the table.', errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download or print until the connection is restored.', @@ -2130,7 +2130,7 @@ define([ txtStyle_Currency: 'Currency', txtStyle_Percent: 'Percent', txtStyle_Comma: 'Comma', - warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' + warnNoLicenseUsers: 'This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.' } })(), SSE.Controllers.Main || {})) }); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 63c2602d6..75138eb95 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -393,6 +393,7 @@ "SSE.Controllers.Main.warnBrowserZoom": "Your browser current zoom setting is not fully supported. Please reset to the default zoom by pressing Ctrl+0.", "SSE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "SSE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.", + "SSE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.", "SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "SSE.Controllers.Print.strAllSheets": "All Sheets", "SSE.Controllers.Print.textWarning": "Warning", diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index c5335d8d6..873d242a0 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -1384,7 +1384,7 @@ define([ txtErrorLoadHistory: 'Loading history failed', textBuyNow: 'Visit website', textNoLicenseTitle: 'ONLYOFFICE open source version', - warnNoLicense: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.', + warnNoLicense: 'This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.', textContactUs: 'Contact sales', errorViewerDisconnect: 'Connection is lost. You can still view the document,
but will not be able to download until the connection is restored.', warnLicenseExp: 'Your license has expired.
Please update your license and refresh the page.', @@ -1437,7 +1437,7 @@ define([ txtStyle_Currency: 'Currency', txtStyle_Percent: 'Percent', txtStyle_Comma: 'Comma', - warnNoLicenseUsers: 'You are using an open source version of ONLYOFFICE. The version has limitations for concurrent connections to the document server (20 connections at a time).
If you need more please consider purchasing a commercial license.' + warnNoLicenseUsers: 'This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.' } })(), SSE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/locale/en.json b/apps/spreadsheeteditor/mobile/locale/en.json index a556627fc..9fc71c590 100644 --- a/apps/spreadsheeteditor/mobile/locale/en.json +++ b/apps/spreadsheeteditor/mobile/locale/en.json @@ -256,6 +256,7 @@ "SSE.Controllers.Main.uploadImageTitleText": "Uploading Image", "SSE.Controllers.Main.warnLicenseExp": "Your license has expired.
Please update your license and refresh the page.", "SSE.Controllers.Main.warnNoLicense": "This version of ONLYOFFICE Editors has certain limitations for concurrent connections to the document server.
If you need more please consider upgrading your current license or purchasing a commercial one.", + "SSE.Controllers.Main.warnNoLicenseUsers": "This version of ONLYOFFICE Editors has certain limitations for concurrent users.
If you need more please consider upgrading your current license or purchasing a commercial one.", "SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "SSE.Controllers.Search.textNoTextFound": "Text not found", "SSE.Controllers.Search.textReplaceAll": "Replace All",