From 0ee22bffc471671a4d2f7629bbfb606c41908e7c Mon Sep 17 00:00:00 2001 From: Alexander Yuzhin Date: Wed, 28 Dec 2016 12:55:37 +0300 Subject: [PATCH] [DE mobile] Disable toolbar buttons if object is locked. --- .../mobile/app/controller/DocumentHolder.js | 3 +-- .../mobile/app/controller/Toolbar.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/DocumentHolder.js b/apps/documenteditor/mobile/app/controller/DocumentHolder.js index 45b6d6495..e5b9039a6 100644 --- a/apps/documenteditor/mobile/app/controller/DocumentHolder.js +++ b/apps/documenteditor/mobile/app/controller/DocumentHolder.js @@ -204,8 +204,7 @@ define([ }); if (stack.length > 0) { - var topObject = stack[stack.length - 1], - topObjectType = topObject.get_ObjectType(), + var topObject = _.find(stack.reverse(), function(obj){ return obj.get_ObjectType() != Asc.c_oAscTypeSelectElement.SpellCheck; }), topObjectValue = topObject.get_ObjectValue(), objectLocked = _.isFunction(topObjectValue.get_Locked) ? topObjectValue.get_Locked() : false; diff --git a/apps/documenteditor/mobile/app/controller/Toolbar.js b/apps/documenteditor/mobile/app/controller/Toolbar.js index 38ca931e0..b93b32a7b 100644 --- a/apps/documenteditor/mobile/app/controller/Toolbar.js +++ b/apps/documenteditor/mobile/app/controller/Toolbar.js @@ -76,8 +76,9 @@ define([ setApi: function(api) { this.api = api; - 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_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)); }, setMode: function (mode) { @@ -144,6 +145,18 @@ define([ } }, + onApiFocusObject: function (objects) { + if (objects.length > 0) { + var topObject = _.find(objects.reverse(), function (obj) { + return obj.get_ObjectType() != Asc.c_oAscTypeSelectElement.SpellCheck; + }), + topObjectValue = topObject.get_ObjectValue(), + objectLocked = _.isFunction(topObjectValue.get_Locked) ? topObjectValue.get_Locked() : false; + + $('#toolbar-add, #toolbar-edit').toggleClass('disabled', objectLocked); + } + }, + 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',