[PE mobile] Change applying the license (disable editing when connections are over the limitations).
[DE mobile] Refactoring.
This commit is contained in:
parent
620c4ab5c2
commit
c31fad7d91
|
@ -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',
|
||||
|
|
|
@ -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).<br>If you need more please consider purchasing a commercial license.'
|
||||
}
|
||||
})(), DE.Controllers.Main || {}))
|
||||
});
|
|
@ -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() {
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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).<br>If you need more please consider purchasing a commercial license.'
|
||||
}
|
||||
})(), PE.Controllers.Main || {}))
|
||||
});
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue