[PE] Refactoring disable editing
This commit is contained in:
parent
6506146eab
commit
c55886f6e3
|
@ -768,21 +768,28 @@ define([
|
||||||
Common.Gateway.requestHistory();
|
Common.Gateway.requestHistory();
|
||||||
},
|
},
|
||||||
|
|
||||||
SetDisabled: function(disable, disableFileMenu) {
|
SetDisabled: function(disable, options) {
|
||||||
this.mode.isEdit = !disable;
|
if (this.leftMenu._state.disabled !== disable) {
|
||||||
|
this.leftMenu._state.disabled = disable;
|
||||||
|
if (disable) {
|
||||||
|
this.previsEdit = this.mode.isEdit;
|
||||||
|
this.prevcanEdit = this.mode.canEdit;
|
||||||
|
this.mode.isEdit = this.mode.canEdit = !disable;
|
||||||
|
} else {
|
||||||
|
this.mode.isEdit = this.previsEdit;
|
||||||
|
this.mode.canEdit = this.prevcanEdit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (disable) this.leftMenu.close();
|
if (disable) this.leftMenu.close();
|
||||||
|
|
||||||
/** coauthoring begin **/
|
if (!options || options.comments && options.comments.disable)
|
||||||
this.leftMenu.btnComments.setDisabled(disable);
|
this.leftMenu.btnComments.setDisabled(disable);
|
||||||
var comments = this.getApplication().getController('Common.Controllers.Comments');
|
if (!options || options.chat)
|
||||||
if (comments)
|
this.leftMenu.btnChat.setDisabled(disable);
|
||||||
comments.setPreviewMode(disable);
|
|
||||||
this.setPreviewMode(disable);
|
|
||||||
this.leftMenu.btnChat.setDisabled(disable);
|
|
||||||
/** coauthoring end **/
|
|
||||||
this.leftMenu.btnPlugins.setDisabled(disable);
|
this.leftMenu.btnPlugins.setDisabled(disable);
|
||||||
this.leftMenu.btnThumbs.setDisabled(disable);
|
this.leftMenu.btnThumbs.setDisabled(disable);
|
||||||
if (disableFileMenu) this.leftMenu.getMenu('file').SetDisabled(disable);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
textNoTextFound : 'Text not found',
|
textNoTextFound : 'Text not found',
|
||||||
|
|
|
@ -145,7 +145,10 @@ define([
|
||||||
strongCompare : function(obj1, obj2){return obj1.id === obj2.id && obj1.type === obj2.type;},
|
strongCompare : function(obj1, obj2){return obj1.id === obj2.id && obj1.type === obj2.type;},
|
||||||
weakCompare : function(obj1, obj2){return obj1.type === obj2.type;}
|
weakCompare : function(obj1, obj2){return obj1.type === obj2.type;}
|
||||||
});
|
});
|
||||||
|
this.stackDisableActions = new Common.IrregularStack({
|
||||||
|
strongCompare : function(obj1, obj2){return obj1.type === obj2.type;},
|
||||||
|
weakCompare : function(obj1, obj2){return obj1.type === obj2.type;}
|
||||||
|
});
|
||||||
// Initialize viewport
|
// Initialize viewport
|
||||||
|
|
||||||
if (!Common.Utils.isBrowserSupported()){
|
if (!Common.Utils.isBrowserSupported()){
|
||||||
|
@ -190,6 +193,7 @@ define([
|
||||||
Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this));
|
Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this));
|
||||||
Common.NotificationCenter.on('showerror', _.bind(this.onError, this));
|
Common.NotificationCenter.on('showerror', _.bind(this.onError, this));
|
||||||
Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this));
|
Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this));
|
||||||
|
Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this));
|
||||||
|
|
||||||
this.isShowOpenDialog = false;
|
this.isShowOpenDialog = false;
|
||||||
|
|
||||||
|
@ -604,7 +608,11 @@ define([
|
||||||
if (this.appOptions.isEdit && (id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) && (!this._state.fastCoauth || this._state.usersCount<2))
|
if (this.appOptions.isEdit && (id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) && (!this._state.fastCoauth || this._state.usersCount<2))
|
||||||
this.synchronizeChanges();
|
this.synchronizeChanges();
|
||||||
|
|
||||||
if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || Common.Utils.ModalWindow.isVisible() || this.inFormControl))) {
|
if ( id == Asc.c_oAscAsyncAction['Disconnect']) {
|
||||||
|
this.disableEditing(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == Asc.c_oAscAsyncActionType.BlockInteraction && !((id == Asc.c_oAscAsyncAction['LoadDocumentFonts'] || id == Asc.c_oAscAsyncAction['ApplyChanges']) && (this.dontCloseDummyComment || this.inTextareaControl || Common.Utils.ModalWindow.isVisible() || this.inFormControl))) {
|
||||||
this.onEditComplete(this.loadMask);
|
this.onEditComplete(this.loadMask);
|
||||||
this.api.asc_enableKeyEvents(true);
|
this.api.asc_enableKeyEvents(true);
|
||||||
}
|
}
|
||||||
|
@ -694,6 +702,12 @@ define([
|
||||||
title = this.loadingDocumentTitleText + ' ';
|
title = this.loadingDocumentTitleText + ' ';
|
||||||
text = this.loadingDocumentTextText;
|
text = this.loadingDocumentTextText;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Asc.c_oAscAsyncAction['Disconnect']:
|
||||||
|
text = this.textDisconnect;
|
||||||
|
this.disableEditing(true, true);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (typeof action.id == 'string'){
|
if (typeof action.id == 'string'){
|
||||||
title = action.id;
|
title = action.id;
|
||||||
|
@ -965,17 +979,71 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
disableEditing: function(disable) {
|
disableEditing: function(disable, temp) {
|
||||||
|
Common.NotificationCenter.trigger('editing:disable', disable, {
|
||||||
|
viewMode: disable,
|
||||||
|
allowSignature: false,
|
||||||
|
rightMenu: {clear: true, disable: true},
|
||||||
|
statusBar: true,
|
||||||
|
leftMenu: {disable: true, previewMode: true},
|
||||||
|
fileMenu: {protect: true, history: temp},
|
||||||
|
comments: {disable: !temp, previewMode: true},
|
||||||
|
chat: true,
|
||||||
|
review: true,
|
||||||
|
viewport: true,
|
||||||
|
documentHolder: true,
|
||||||
|
toolbar: true
|
||||||
|
}, temp ? 'reconnect' : 'disconnect');
|
||||||
|
},
|
||||||
|
|
||||||
|
onEditingDisable: function(disable, options, type) {
|
||||||
var app = this.getApplication();
|
var app = this.getApplication();
|
||||||
if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') {
|
|
||||||
app.getController('RightMenu').getView('RightMenu').clearSelection();
|
var action = {type: type, disable: disable, options: options};
|
||||||
app.getController('RightMenu').SetDisabled(disable, false);
|
if (disable && !this.stackDisableActions.get({type: type}))
|
||||||
|
this.stackDisableActions.push(action);
|
||||||
|
!disable && this.stackDisableActions.pop({type: type});
|
||||||
|
var prev_options = !disable && (this.stackDisableActions.length()>0) ? this.stackDisableActions.get(this.stackDisableActions.length()-1) : null;
|
||||||
|
|
||||||
|
if (options.rightMenu && app.getController('RightMenu')) {
|
||||||
|
options.rightMenu.clear && app.getController('RightMenu').getView('RightMenu').clearSelection();
|
||||||
|
options.rightMenu.disable && app.getController('RightMenu').SetDisabled(disable, options.allowSignature);
|
||||||
|
}
|
||||||
|
if (options.statusBar) {
|
||||||
app.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
|
app.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
|
||||||
}
|
}
|
||||||
app.getController('LeftMenu').SetDisabled(disable, true);
|
if (options.review) {
|
||||||
app.getController('Toolbar').DisableToolbar(disable);
|
app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
||||||
app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
}
|
||||||
app.getController('Viewport').SetDisabled(disable);
|
if (options.viewport) {
|
||||||
|
app.getController('Viewport').SetDisabled(disable);
|
||||||
|
}
|
||||||
|
if (options.toolbar) {
|
||||||
|
app.getController('Toolbar').DisableToolbar(disable, options.viewMode);
|
||||||
|
}
|
||||||
|
if (options.documentHolder) {
|
||||||
|
app.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable);
|
||||||
|
}
|
||||||
|
if (options.leftMenu) {
|
||||||
|
if (options.leftMenu.disable)
|
||||||
|
app.getController('LeftMenu').SetDisabled(disable, options);
|
||||||
|
if (options.leftMenu.previewMode)
|
||||||
|
app.getController('LeftMenu').setPreviewMode(disable);
|
||||||
|
}
|
||||||
|
if (options.fileMenu) {
|
||||||
|
app.getController('LeftMenu').leftMenu.getMenu('file').SetDisabled(disable, options.fileMenu);
|
||||||
|
if (options.leftMenu.disable)
|
||||||
|
app.getController('LeftMenu').leftMenu.getMenu('file').applyMode();
|
||||||
|
}
|
||||||
|
if (options.comments) {
|
||||||
|
var comments = this.getApplication().getController('Common.Controllers.Comments');
|
||||||
|
if (comments && options.comments.previewMode)
|
||||||
|
comments.setPreviewMode(disable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prev_options) {
|
||||||
|
this.onEditingDisable(prev_options.disable, prev_options.options, prev_options.type);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onOpenDocument: function(progress) {
|
onOpenDocument: function(progress) {
|
||||||
|
@ -2072,16 +2140,7 @@ define([
|
||||||
var me = this;
|
var me = this;
|
||||||
Common.Utils.warningDocumentIsLocked({
|
Common.Utils.warningDocumentIsLocked({
|
||||||
disablefunc: function (disable) {
|
disablefunc: function (disable) {
|
||||||
var app = me.getApplication();
|
me.disableEditing(disable, true);
|
||||||
me.disableEditing(disable);
|
|
||||||
app.getController('RightMenu').SetDisabled(disable, true);
|
|
||||||
app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
|
||||||
app.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable);
|
|
||||||
var leftMenu = app.getController('LeftMenu');
|
|
||||||
leftMenu.leftMenu.getMenu('file').getButton('protect').setDisabled(disable);
|
|
||||||
leftMenu.setPreviewMode(disable);
|
|
||||||
var comments = app.getController('Common.Controllers.Comments');
|
|
||||||
if (comments) comments.setPreviewMode(disable);
|
|
||||||
}});
|
}});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -2712,7 +2771,8 @@ define([
|
||||||
txtErrorLoadHistory: 'Loading history failed',
|
txtErrorLoadHistory: 'Loading history failed',
|
||||||
leavePageTextOnClose: 'All unsaved changes in this document will be lost.<br> Click \'Cancel\' then \'Save\' to save them. Click \'OK\' to discard all the unsaved changes.',
|
leavePageTextOnClose: 'All unsaved changes in this document will be lost.<br> Click \'Cancel\' then \'Save\' to save them. Click \'OK\' to discard all the unsaved changes.',
|
||||||
textTryUndoRedoWarn: 'The Undo/Redo functions are disabled for the Fast co-editing mode.',
|
textTryUndoRedoWarn: 'The Undo/Redo functions are disabled for the Fast co-editing mode.',
|
||||||
txtNone: 'None'
|
txtNone: 'None',
|
||||||
|
textDisconnect: 'Connection is lost'
|
||||||
}
|
}
|
||||||
})(), PE.Controllers.Main || {}))
|
})(), PE.Controllers.Main || {}))
|
||||||
});
|
});
|
||||||
|
|
|
@ -190,6 +190,10 @@ define([
|
||||||
caption : this.btnHistoryCaption,
|
caption : this.btnHistoryCaption,
|
||||||
canFocused: false
|
canFocused: false
|
||||||
});
|
});
|
||||||
|
if ( !!this.options.miHistory ) {
|
||||||
|
this.miHistory.setDisabled(this.options.miHistory.isDisabled());
|
||||||
|
delete this.options.miHistory;
|
||||||
|
}
|
||||||
|
|
||||||
this.items = [];
|
this.items = [];
|
||||||
this.items.push(
|
this.items.push(
|
||||||
|
@ -271,6 +275,8 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
applyMode: function() {
|
applyMode: function() {
|
||||||
|
if (!this.rendered) return;
|
||||||
|
|
||||||
if (!this.panels) {
|
if (!this.panels) {
|
||||||
this.panels = {
|
this.panels = {
|
||||||
'opts' : (new PE.Views.FileMenuPanels.Settings({menu:this})).render(this.$el.find('#panel-settings')),
|
'opts' : (new PE.Views.FileMenuPanels.Settings({menu:this})).render(this.$el.find('#panel-settings')),
|
||||||
|
@ -361,8 +367,7 @@ define([
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!delay) {
|
if (!delay) {
|
||||||
if ( this.rendered )
|
this.applyMode();
|
||||||
this.applyMode();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -437,6 +442,9 @@ define([
|
||||||
} else
|
} else
|
||||||
if (type == 'protect') {
|
if (type == 'protect') {
|
||||||
return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({}));
|
return this.options.miProtect ? this.options.miProtect : (this.options.miProtect = new Common.UI.MenuItem({}));
|
||||||
|
} else
|
||||||
|
if (type == 'history') {
|
||||||
|
return this.options.miHistory ? this.options.miHistory : (this.options.miHistory = new Common.UI.MenuItem({}));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (type == 'save') {
|
if (type == 'save') {
|
||||||
|
@ -447,18 +455,19 @@ define([
|
||||||
} else
|
} else
|
||||||
if (type == 'protect') {
|
if (type == 'protect') {
|
||||||
return this.miProtect;
|
return this.miProtect;
|
||||||
|
}else
|
||||||
|
if (type == 'history') {
|
||||||
|
return this.miHistory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
SetDisabled: function(disable) {
|
SetDisabled: function(disable, options) {
|
||||||
var _btn_save = this.getButton('save'),
|
var _btn_protect = this.getButton('protect'),
|
||||||
_btn_rename = this.getButton('rename'),
|
_btn_history = this.getButton('history');
|
||||||
_btn_protect = this.getButton('protect');
|
|
||||||
|
|
||||||
_btn_save.setDisabled(disable || !this.mode.isEdit);
|
options && options.protect && _btn_protect.setDisabled(disable);
|
||||||
_btn_protect.setDisabled(disable || !this.mode.isEdit);
|
options && options.history && _btn_history.setDisabled(disable);
|
||||||
_btn_rename.setDisabled(disable || !this.mode.canRename || this.mode.isDesktopApp);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
btnSaveCaption : 'Save',
|
btnSaveCaption : 'Save',
|
||||||
|
|
|
@ -83,7 +83,7 @@ define([
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.minimizedMode = true;
|
this.minimizedMode = true;
|
||||||
this._state = {};
|
this._state = {disabled: false};
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
|
|
@ -347,21 +347,20 @@ define([
|
||||||
if (this._state.DisabledEditing != disable) {
|
if (this._state.DisabledEditing != disable) {
|
||||||
this._state.DisabledEditing = disable;
|
this._state.DisabledEditing = disable;
|
||||||
|
|
||||||
var rightMenuController = PE.getController('RightMenu');
|
Common.NotificationCenter.trigger('editing:disable', disable, {
|
||||||
if (disable && rightMenuController.rightmenu.GetActivePane() !== 'id-signature-settings')
|
viewMode: disable,
|
||||||
rightMenuController.rightmenu.clearSelection();
|
allowSignature: true,
|
||||||
rightMenuController.SetDisabled(disable, true);
|
rightMenu: {clear: disable && (PE.getController('RightMenu').rightmenu.GetActivePane() !== 'id-signature-settings'), disable: true},
|
||||||
PE.getController('Toolbar').DisableToolbar(disable, disable);
|
statusBar: true,
|
||||||
PE.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
|
leftMenu: {disable: false, previewMode: true},
|
||||||
PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
fileMenu: false,
|
||||||
PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable);
|
comments: {disable: false, previewMode: true},
|
||||||
|
chat: false,
|
||||||
// var leftMenu = PE.getController('LeftMenu').leftMenu;
|
review: true,
|
||||||
// leftMenu.btnComments.setDisabled(disable);
|
viewport: false,
|
||||||
PE.getController('LeftMenu').setPreviewMode(disable);
|
documentHolder: true,
|
||||||
var comments = PE.getController('Common.Controllers.Comments');
|
toolbar: true
|
||||||
if (comments)
|
}, 'signature');
|
||||||
comments.setPreviewMode(disable);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -365,7 +365,6 @@ define([
|
||||||
SetDisabled: function(disable) {
|
SetDisabled: function(disable) {
|
||||||
var langs = this.langMenu.items.length>0;
|
var langs = this.langMenu.items.length>0;
|
||||||
this.btnLanguage.setDisabled(disable || !langs || this._state.no_paragraph);
|
this.btnLanguage.setDisabled(disable || !langs || this._state.no_paragraph);
|
||||||
this.mode.isEdit = !disable;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onApiFocusObject: function(selectedObjects) {
|
onApiFocusObject: function(selectedObjects) {
|
||||||
|
|
Loading…
Reference in a new issue