[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_onAuthParticipantsChanged',_.bind(me.onApiUsersChanged, me));
|
||||||
me.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(me.onApiUserConnection, me));
|
me.api.asc_registerCallback('asc_onConnectionStateChanged', _.bind(me.onApiUserConnection, me));
|
||||||
me.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(me.onApiDocumentContentReady, me));
|
me.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(me.onApiDocumentContentReady, me));
|
||||||
|
Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me));
|
||||||
me.api.asc_coAuthoringGetUsers();
|
me.api.asc_coAuthoringGetUsers();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -344,7 +345,7 @@ define([
|
||||||
items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0];
|
items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!objectLocked && _isEdit) {
|
if (!objectLocked && _isEdit && !me.isDisconnected) {
|
||||||
if (canCopy) {
|
if (canCopy) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
caption: me.menuCut,
|
caption: me.menuCut,
|
||||||
|
@ -399,6 +400,10 @@ define([
|
||||||
return menuItems;
|
return menuItems;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onCoAuthoringDisconnect: function() {
|
||||||
|
this.isDisconnected = true;
|
||||||
|
},
|
||||||
|
|
||||||
textGuest: 'Guest',
|
textGuest: 'Guest',
|
||||||
menuCut: 'Cut',
|
menuCut: 'Cut',
|
||||||
menuCopy: 'Copy',
|
menuCopy: 'Copy',
|
||||||
|
|
|
@ -568,7 +568,8 @@ define([
|
||||||
applyLicense: function() {
|
applyLicense: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (me._state.licenseWarning) {
|
if (me._state.licenseWarning) {
|
||||||
DE.getController('Toolbar').deactivateControls();
|
DE.getController('Toolbar').activateViewControls();
|
||||||
|
DE.getController('Toolbar').deactivateEditControls();
|
||||||
Common.NotificationCenter.trigger('api:disconnect');
|
Common.NotificationCenter.trigger('api:disconnect');
|
||||||
|
|
||||||
var value = Common.localStorage.getItem("de-license-warning");
|
var value = Common.localStorage.getItem("de-license-warning");
|
||||||
|
@ -579,7 +580,7 @@ define([
|
||||||
Common.localStorage.setItem("de-license-warning", now);
|
Common.localStorage.setItem("de-license-warning", now);
|
||||||
uiApp.modal({
|
uiApp.modal({
|
||||||
title: me.textNoLicenseTitle,
|
title: me.textNoLicenseTitle,
|
||||||
text : me.warnNoLicense,
|
text : me._state.licenseWarning,
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
text: me.textBuyNow,
|
text: me.textBuyNow,
|
||||||
|
@ -1274,7 +1275,8 @@ define([
|
||||||
txtStyle_Subtitle: 'Subtitle',
|
txtStyle_Subtitle: 'Subtitle',
|
||||||
txtStyle_Quote: 'Quote',
|
txtStyle_Quote: 'Quote',
|
||||||
txtStyle_Intense_Quote: 'Intense 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 || {}))
|
})(), DE.Controllers.Main || {}))
|
||||||
});
|
});
|
|
@ -166,8 +166,12 @@ define([
|
||||||
$('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').removeClass('disabled');
|
$('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').removeClass('disabled');
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivateControls: function() {
|
activateViewControls: function() {
|
||||||
$('#toolbar-edit, #toolbar-add, #toolbar-settings, #toolbar-search, #document-back').addClass('disabled');
|
$('#toolbar-search, #document-back').removeClass('disabled');
|
||||||
|
},
|
||||||
|
|
||||||
|
deactivateEditControls: function() {
|
||||||
|
$('#toolbar-edit, #toolbar-add, #toolbar-settings').addClass('disabled');
|
||||||
},
|
},
|
||||||
|
|
||||||
onCoAuthoringDisconnect: function() {
|
onCoAuthoringDisconnect: function() {
|
||||||
|
|
|
@ -81,6 +81,7 @@ define([
|
||||||
me.api.asc_registerCallback('asc_onShowPopMenu', _.bind(me.onApiShowPopMenu, me));
|
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_onHidePopMenu', _.bind(me.onApiHidePopMenu, me));
|
||||||
me.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(me.onApiDocumentContentReady, me));
|
me.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(me.onApiDocumentContentReady, me));
|
||||||
|
Common.NotificationCenter.on('api:disconnect', _.bind(me.onCoAuthoringDisconnect, me));
|
||||||
},
|
},
|
||||||
|
|
||||||
setMode: function (mode) {
|
setMode: function (mode) {
|
||||||
|
@ -253,7 +254,7 @@ define([
|
||||||
items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0];
|
items[indexAfter] = items.splice(indexBefore, 1, items[indexAfter])[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!objectLocked && _isEdit) {
|
if (!objectLocked && _isEdit && !me.isDisconnected) {
|
||||||
if (canCopy && isObject) {
|
if (canCopy && isObject) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
caption: me.menuCut,
|
caption: me.menuCut,
|
||||||
|
@ -309,6 +310,10 @@ define([
|
||||||
return menuItems;
|
return menuItems;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onCoAuthoringDisconnect: function() {
|
||||||
|
this.isDisconnected = true;
|
||||||
|
},
|
||||||
|
|
||||||
menuCut: 'Cut',
|
menuCut: 'Cut',
|
||||||
menuCopy: 'Copy',
|
menuCopy: 'Copy',
|
||||||
menuPaste: 'Paste',
|
menuPaste: 'Paste',
|
||||||
|
|
|
@ -236,6 +236,7 @@ define([
|
||||||
}
|
}
|
||||||
|
|
||||||
this.api.asc_registerCallback('asc_onGetEditorPermissions', _.bind(this.onEditorPermissions, this));
|
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_setDocInfo(docInfo);
|
||||||
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
|
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
|
||||||
|
|
||||||
|
@ -511,18 +512,35 @@ define([
|
||||||
me.api.zoomFitToPage();
|
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) {
|
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;
|
value = (value!==null) ? parseInt(value) : 0;
|
||||||
var now = (new Date).getTime();
|
var now = (new Date).getTime();
|
||||||
|
|
||||||
if (now - value > 86400000) {
|
if (now - value > 86400000) {
|
||||||
Common.localStorage.setItem("de-license-warning", now);
|
Common.localStorage.setItem("pe-license-warning", now);
|
||||||
uiApp.modal({
|
uiApp.modal({
|
||||||
title: me.textNoLicenseTitle,
|
title: me.textNoLicenseTitle,
|
||||||
text : me.warnNoLicense,
|
text : me._state.licenseWarning,
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
{
|
||||||
text: me.textBuyNow,
|
text: me.textBuyNow,
|
||||||
|
@ -537,10 +555,11 @@ define([
|
||||||
window.open('mailto:sales@onlyoffice.com', "_blank");
|
window.open('mailto:sales@onlyoffice.com', "_blank");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
PE.getController('Toolbar').activateControls();
|
||||||
},
|
},
|
||||||
|
|
||||||
onOpenDocument: function(progress) {
|
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.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.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.canBranding = (licType === Asc.c_oLicenseResult.Success) && (typeof me.editorConfig.customization == 'object');
|
||||||
me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object');
|
me.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof me.editorConfig.customization == 'object');
|
||||||
|
|
||||||
|
@ -1259,7 +1276,8 @@ define([
|
||||||
txtImage: 'Image',
|
txtImage: 'Image',
|
||||||
txtSlideNumber: 'Slide number',
|
txtSlideNumber: 'Slide number',
|
||||||
txtSlideSubtitle: 'Slide subtitle',
|
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 || {}))
|
})(), PE.Controllers.Main || {}))
|
||||||
});
|
});
|
|
@ -79,6 +79,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo'));
|
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_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo'));
|
||||||
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
|
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
|
||||||
|
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
setMode: function (mode) {
|
setMode: function (mode) {
|
||||||
|
@ -138,6 +139,8 @@ define([
|
||||||
// API handlers
|
// API handlers
|
||||||
|
|
||||||
onApiCanRevert: function(which, can) {
|
onApiCanRevert: function(which, can) {
|
||||||
|
if (this.isDisconnected) return;
|
||||||
|
|
||||||
if (which == 'undo') {
|
if (which == 'undo') {
|
||||||
$('#toolbar-undo').toggleClass('disabled', !can);
|
$('#toolbar-undo').toggleClass('disabled', !can);
|
||||||
} else {
|
} else {
|
||||||
|
@ -146,6 +149,8 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiFocusObject: function (objects) {
|
onApiFocusObject: function (objects) {
|
||||||
|
if (this.isDisconnected) return;
|
||||||
|
|
||||||
if (objects.length > 0) {
|
if (objects.length > 0) {
|
||||||
var slide_deleted = false,
|
var slide_deleted = false,
|
||||||
slide_lock = false,
|
slide_lock = false,
|
||||||
|
@ -172,6 +177,18 @@ define([
|
||||||
$('#toolbar-preview, #toolbar-settings, #toolbar-search, #document-back').removeClass('disabled');
|
$('#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',
|
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.',
|
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',
|
leaveButtonText : 'Leave this Page',
|
||||||
|
|
Loading…
Reference in a new issue