[PE] Refactoring disable editing
This commit is contained in:
parent
6506146eab
commit
c55886f6e3
|
@ -768,21 +768,28 @@ define([
|
|||
Common.Gateway.requestHistory();
|
||||
},
|
||||
|
||||
SetDisabled: function(disable, disableFileMenu) {
|
||||
this.mode.isEdit = !disable;
|
||||
SetDisabled: function(disable, options) {
|
||||
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();
|
||||
|
||||
/** coauthoring begin **/
|
||||
this.leftMenu.btnComments.setDisabled(disable);
|
||||
var comments = this.getApplication().getController('Common.Controllers.Comments');
|
||||
if (comments)
|
||||
comments.setPreviewMode(disable);
|
||||
this.setPreviewMode(disable);
|
||||
this.leftMenu.btnChat.setDisabled(disable);
|
||||
/** coauthoring end **/
|
||||
if (!options || options.comments && options.comments.disable)
|
||||
this.leftMenu.btnComments.setDisabled(disable);
|
||||
if (!options || options.chat)
|
||||
this.leftMenu.btnChat.setDisabled(disable);
|
||||
|
||||
this.leftMenu.btnPlugins.setDisabled(disable);
|
||||
this.leftMenu.btnThumbs.setDisabled(disable);
|
||||
if (disableFileMenu) this.leftMenu.getMenu('file').SetDisabled(disable);
|
||||
},
|
||||
|
||||
textNoTextFound : 'Text not found',
|
||||
|
|
|
@ -145,7 +145,10 @@ define([
|
|||
strongCompare : function(obj1, obj2){return obj1.id === obj2.id && 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
|
||||
|
||||
if (!Common.Utils.isBrowserSupported()){
|
||||
|
@ -190,6 +193,7 @@ define([
|
|||
Common.NotificationCenter.on('showmessage', _.bind(this.onExternalMessage, this));
|
||||
Common.NotificationCenter.on('showerror', _.bind(this.onError, this));
|
||||
Common.NotificationCenter.on('markfavorite', _.bind(this.markFavorite, this));
|
||||
Common.NotificationCenter.on('editing:disable', _.bind(this.onEditingDisable, this));
|
||||
|
||||
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))
|
||||
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.api.asc_enableKeyEvents(true);
|
||||
}
|
||||
|
@ -694,6 +702,12 @@ define([
|
|||
title = this.loadingDocumentTitleText + ' ';
|
||||
text = this.loadingDocumentTextText;
|
||||
break;
|
||||
|
||||
case Asc.c_oAscAsyncAction['Disconnect']:
|
||||
text = this.textDisconnect;
|
||||
this.disableEditing(true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (typeof action.id == 'string'){
|
||||
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();
|
||||
if (this.appOptions.canEdit && this.editorConfig.mode !== 'view') {
|
||||
app.getController('RightMenu').getView('RightMenu').clearSelection();
|
||||
app.getController('RightMenu').SetDisabled(disable, false);
|
||||
|
||||
var action = {type: type, disable: disable, options: options};
|
||||
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('LeftMenu').SetDisabled(disable, true);
|
||||
app.getController('Toolbar').DisableToolbar(disable);
|
||||
app.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
||||
app.getController('Viewport').SetDisabled(disable);
|
||||
if (options.review) {
|
||||
app.getController('Common.Controllers.ReviewChanges').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) {
|
||||
|
@ -2072,16 +2140,7 @@ define([
|
|||
var me = this;
|
||||
Common.Utils.warningDocumentIsLocked({
|
||||
disablefunc: function (disable) {
|
||||
var app = me.getApplication();
|
||||
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);
|
||||
me.disableEditing(disable, true);
|
||||
}});
|
||||
},
|
||||
|
||||
|
@ -2712,7 +2771,8 @@ define([
|
|||
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.',
|
||||
textTryUndoRedoWarn: 'The Undo/Redo functions are disabled for the Fast co-editing mode.',
|
||||
txtNone: 'None'
|
||||
txtNone: 'None',
|
||||
textDisconnect: 'Connection is lost'
|
||||
}
|
||||
})(), PE.Controllers.Main || {}))
|
||||
});
|
||||
|
|
|
@ -190,6 +190,10 @@ define([
|
|||
caption : this.btnHistoryCaption,
|
||||
canFocused: false
|
||||
});
|
||||
if ( !!this.options.miHistory ) {
|
||||
this.miHistory.setDisabled(this.options.miHistory.isDisabled());
|
||||
delete this.options.miHistory;
|
||||
}
|
||||
|
||||
this.items = [];
|
||||
this.items.push(
|
||||
|
@ -271,6 +275,8 @@ define([
|
|||
},
|
||||
|
||||
applyMode: function() {
|
||||
if (!this.rendered) return;
|
||||
|
||||
if (!this.panels) {
|
||||
this.panels = {
|
||||
'opts' : (new PE.Views.FileMenuPanels.Settings({menu:this})).render(this.$el.find('#panel-settings')),
|
||||
|
@ -361,8 +367,7 @@ define([
|
|||
}
|
||||
|
||||
if (!delay) {
|
||||
if ( this.rendered )
|
||||
this.applyMode();
|
||||
this.applyMode();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -437,6 +442,9 @@ define([
|
|||
} else
|
||||
if (type == 'protect') {
|
||||
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 {
|
||||
if (type == 'save') {
|
||||
|
@ -447,18 +455,19 @@ define([
|
|||
} else
|
||||
if (type == 'protect') {
|
||||
return this.miProtect;
|
||||
}else
|
||||
if (type == 'history') {
|
||||
return this.miHistory;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
SetDisabled: function(disable) {
|
||||
var _btn_save = this.getButton('save'),
|
||||
_btn_rename = this.getButton('rename'),
|
||||
_btn_protect = this.getButton('protect');
|
||||
SetDisabled: function(disable, options) {
|
||||
var _btn_protect = this.getButton('protect'),
|
||||
_btn_history = this.getButton('history');
|
||||
|
||||
_btn_save.setDisabled(disable || !this.mode.isEdit);
|
||||
_btn_protect.setDisabled(disable || !this.mode.isEdit);
|
||||
_btn_rename.setDisabled(disable || !this.mode.canRename || this.mode.isDesktopApp);
|
||||
options && options.protect && _btn_protect.setDisabled(disable);
|
||||
options && options.history && _btn_history.setDisabled(disable);
|
||||
},
|
||||
|
||||
btnSaveCaption : 'Save',
|
||||
|
|
|
@ -83,7 +83,7 @@ define([
|
|||
|
||||
initialize: function () {
|
||||
this.minimizedMode = true;
|
||||
this._state = {};
|
||||
this._state = {disabled: false};
|
||||
},
|
||||
|
||||
render: function () {
|
||||
|
|
|
@ -347,21 +347,20 @@ define([
|
|||
if (this._state.DisabledEditing != disable) {
|
||||
this._state.DisabledEditing = disable;
|
||||
|
||||
var rightMenuController = PE.getController('RightMenu');
|
||||
if (disable && rightMenuController.rightmenu.GetActivePane() !== 'id-signature-settings')
|
||||
rightMenuController.rightmenu.clearSelection();
|
||||
rightMenuController.SetDisabled(disable, true);
|
||||
PE.getController('Toolbar').DisableToolbar(disable, disable);
|
||||
PE.getController('Statusbar').getView('Statusbar').SetDisabled(disable);
|
||||
PE.getController('Common.Controllers.ReviewChanges').SetDisabled(disable);
|
||||
PE.getController('DocumentHolder').getView('DocumentHolder').SetDisabled(disable);
|
||||
|
||||
// var leftMenu = PE.getController('LeftMenu').leftMenu;
|
||||
// leftMenu.btnComments.setDisabled(disable);
|
||||
PE.getController('LeftMenu').setPreviewMode(disable);
|
||||
var comments = PE.getController('Common.Controllers.Comments');
|
||||
if (comments)
|
||||
comments.setPreviewMode(disable);
|
||||
Common.NotificationCenter.trigger('editing:disable', disable, {
|
||||
viewMode: disable,
|
||||
allowSignature: true,
|
||||
rightMenu: {clear: disable && (PE.getController('RightMenu').rightmenu.GetActivePane() !== 'id-signature-settings'), disable: true},
|
||||
statusBar: true,
|
||||
leftMenu: {disable: false, previewMode: true},
|
||||
fileMenu: false,
|
||||
comments: {disable: false, previewMode: true},
|
||||
chat: false,
|
||||
review: true,
|
||||
viewport: false,
|
||||
documentHolder: true,
|
||||
toolbar: true
|
||||
}, 'signature');
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -365,7 +365,6 @@ define([
|
|||
SetDisabled: function(disable) {
|
||||
var langs = this.langMenu.items.length>0;
|
||||
this.btnLanguage.setDisabled(disable || !langs || this._state.no_paragraph);
|
||||
this.mode.isEdit = !disable;
|
||||
},
|
||||
|
||||
onApiFocusObject: function(selectedObjects) {
|
||||
|
|
Loading…
Reference in a new issue