diff --git a/apps/documenteditor/mobile/app/controller/DocumentHolder.js b/apps/documenteditor/mobile/app/controller/DocumentHolder.js index 73973ca18..127777c59 100644 --- a/apps/documenteditor/mobile/app/controller/DocumentHolder.js +++ b/apps/documenteditor/mobile/app/controller/DocumentHolder.js @@ -92,7 +92,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, // When our application is ready, lets get started diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index d4d81dd2c..5af21f701 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -229,11 +229,11 @@ define([ setMode: function(mode){ var me = this; - Common.SharedSettings.set('mode', mode); + Common.SharedSettings.set('mode', mode.isEdit ? 'edit' : 'view'); if (me.api) { - me.api.asc_enableKeyEvents(mode == 'edit'); - me.api.asc_setViewMode(mode != 'edit'); + me.api.asc_enableKeyEvents(mode.isEdit); + me.api.asc_setViewMode(!mode.isEdit); } }, @@ -637,7 +637,7 @@ define([ _.each(me.getApplication().controllers, function(controller) { if (controller && _.isFunction(controller.setMode)) { - controller.setMode(me.editorConfig.mode); + controller.setMode(me.appOptions); } }); diff --git a/apps/documenteditor/mobile/app/view/Search.js b/apps/documenteditor/mobile/app/view/Search.js index f03d7de25..5cc6ade1e 100644 --- a/apps/documenteditor/mobile/app/view/Search.js +++ b/apps/documenteditor/mobile/app/view/Search.js @@ -84,7 +84,7 @@ define([ }, setMode: function (mode) { - _isEdit = (mode === 'edit'); + _isEdit = mode.isEdit; this.render(); }, diff --git a/apps/documenteditor/mobile/app/view/Settings.js b/apps/documenteditor/mobile/app/view/Settings.js index 34d0ef01a..085a7138f 100644 --- a/apps/documenteditor/mobile/app/view/Settings.js +++ b/apps/documenteditor/mobile/app/view/Settings.js @@ -50,7 +50,9 @@ define([ DE.Views.Settings = Backbone.View.extend(_.extend((function() { // private - var _isEdit = false; + var _isEdit = false, + _canEdit = false, + _canDownload = false; return { // el: '.view-main', @@ -86,7 +88,9 @@ define([ }, setMode: function (mode) { - _isEdit = (mode === 'edit') + _isEdit = mode.isEdit; + _canEdit = !mode.isEdit && mode.canEdit && mode.canRequestEditRights; + _canDownload = mode.canDownload || mode.canDownloadOrigin; }, rootLayout: function () { @@ -99,10 +103,12 @@ define([ $layour.find('#settings-readermode').hide(); $layour.find('#settings-search .item-title').text(this.textFindAndReplace) } else { + if (!_canEdit) $layour.find('#settings-edit-document').hide(); $layour.find('#settings-document').hide(); $layour.find('#settings-readermode input:checkbox') .prop('checked', Common.SharedSettings.get('readerMode')); } + if (!_canDownload) $layour.find('#settings-download').hide(); return $layour.html(); } diff --git a/apps/documenteditor/mobile/app/view/Toolbar.js b/apps/documenteditor/mobile/app/view/Toolbar.js index 58ec40f41..36d32df7a 100644 --- a/apps/documenteditor/mobile/app/view/Toolbar.js +++ b/apps/documenteditor/mobile/app/view/Toolbar.js @@ -97,9 +97,7 @@ define([ }, setMode: function (mode) { - var isEdit = (mode === 'edit'); - - if (isEdit) { + if (mode.isEdit) { $('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show(); } }, diff --git a/apps/presentationeditor/mobile/app/controller/DocumentHolder.js b/apps/presentationeditor/mobile/app/controller/DocumentHolder.js index 865df8e42..0bfa294c7 100644 --- a/apps/presentationeditor/mobile/app/controller/DocumentHolder.js +++ b/apps/presentationeditor/mobile/app/controller/DocumentHolder.js @@ -84,7 +84,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, // When our application is ready, lets get started diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 90c46b3f0..aee1637de 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -226,11 +226,11 @@ define([ setMode: function(mode){ var me = this; - Common.SharedSettings.set('mode', mode); + Common.SharedSettings.set('mode', mode.isEdit ? 'edit' : 'view'); if (me.api) { - me.api.asc_enableKeyEvents(mode == 'edit'); - me.api.asc_setViewMode(mode != 'edit'); + me.api.asc_enableKeyEvents(mode.isEdit); + me.api.asc_setViewMode(!mode.isEdit); } }, @@ -593,7 +593,7 @@ define([ _.each(me.getApplication().controllers, function(controller) { if (controller && _.isFunction(controller.setMode)) { - controller.setMode(me.editorConfig.mode); + controller.setMode(me.appOptions); } }); diff --git a/apps/presentationeditor/mobile/app/view/Search.js b/apps/presentationeditor/mobile/app/view/Search.js index 41155dd1b..9b9c89cdc 100644 --- a/apps/presentationeditor/mobile/app/view/Search.js +++ b/apps/presentationeditor/mobile/app/view/Search.js @@ -84,7 +84,7 @@ define([ }, setMode: function (mode) { - _isEdit = (mode === 'edit'); + _isEdit = mode.isEdit; this.render(); }, diff --git a/apps/presentationeditor/mobile/app/view/Settings.js b/apps/presentationeditor/mobile/app/view/Settings.js index cc9b3ce1a..ec71b1ab7 100644 --- a/apps/presentationeditor/mobile/app/view/Settings.js +++ b/apps/presentationeditor/mobile/app/view/Settings.js @@ -50,7 +50,9 @@ define([ PE.Views.Settings = Backbone.View.extend(_.extend((function() { // private - var isEdit; + var isEdit, + canEdit = false, + canDownload = false; return { // el: '.view-main', @@ -91,7 +93,9 @@ define([ }, setMode: function (mode) { - isEdit = (mode === 'edit') + isEdit = mode.isEdit; + canEdit = !mode.isEdit && mode.canEdit && mode.canRequestEditRights; + canDownload = mode.canDownload || mode.canDownloadOrigin; }, rootLayout: function () { @@ -104,11 +108,13 @@ define([ $layour.find('#settings-readermode').hide(); $layour.find('#settings-search .item-title').text(this.textFindAndReplace) } else { + if (!canEdit) $layour.find('#settings-edit-presentation').hide(); $layour.find('#settings-presentation-setup').hide(); $layour.find('#settings-readermode input:checkbox') .attr('checked', Common.SharedSettings.get('readerMode')) .prop('checked', Common.SharedSettings.get('readerMode')); } + if (!canDownload) $layour.find('#settings-download').hide(); return $layour.html(); } diff --git a/apps/presentationeditor/mobile/app/view/Toolbar.js b/apps/presentationeditor/mobile/app/view/Toolbar.js index f7f8d4fde..bc73e504a 100644 --- a/apps/presentationeditor/mobile/app/view/Toolbar.js +++ b/apps/presentationeditor/mobile/app/view/Toolbar.js @@ -98,9 +98,7 @@ define([ }, setMode: function (mode) { - var isEdit = (mode === 'edit'); - - if (isEdit) { + if (mode.isEdit) { $('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show(); } }, diff --git a/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js b/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js index 8fa9593c4..08fad6980 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js +++ b/apps/spreadsheeteditor/mobile/app/controller/CellEditor.js @@ -177,7 +177,7 @@ define([ }, onInsertFunction: function() { - if (this.mode == 'edit') { + if (this.mode.isEdit) { SSE.getController('AddContainer').showModal({ panel: 'function', button: '#ce-function' diff --git a/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js b/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js index 02fdd98dd..6651aaaf3 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js +++ b/apps/spreadsheeteditor/mobile/app/controller/DocumentHolder.js @@ -85,7 +85,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, // When our application is ready, lets get started diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 8ff651fba..df8b16ecf 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -228,11 +228,11 @@ define([ setMode: function(mode){ var me = this; - Common.SharedSettings.set('mode', mode); + Common.SharedSettings.set('mode', mode.isEdit ? 'edit' : 'view'); if ( me.api ) { - me.api.asc_enableKeyEvents(mode == 'edit'); - me.api.asc_setViewMode(mode != 'edit'); + me.api.asc_enableKeyEvents(mode.isEdit); + me.api.asc_setViewMode(!mode.isEdit); } }, @@ -614,7 +614,7 @@ define([ _.each(me.getApplication().controllers, function(controller) { if (controller && _.isFunction(controller.setMode)) { - controller.setMode(me.editorConfig.mode); + controller.setMode(me.appOptions); } }); diff --git a/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js b/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js index 28da2f85a..57e605ddd 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Statusbar.js @@ -112,7 +112,7 @@ define([ setMode: function(mode) { this.statusbar.setMode(mode); - this.isEdit = mode == 'edit'; + this.isEdit = mode.isEdit; }, /* diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js index 14e829717..c643f8edb 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js @@ -107,7 +107,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, onLaunch: function () { diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js index 09371e246..ffd5e4606 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js @@ -117,7 +117,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, onLaunch: function () { diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditImage.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditImage.js index f96c0454d..7892bc0c6 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditImage.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditImage.js @@ -81,7 +81,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, onPageShow: function (view, pageId) { diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js index 824564a7d..6fba05b2c 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js @@ -110,7 +110,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, onPageShow: function (view, pageId) { diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditText.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditText.js index 0b9dfd6b5..08f41ec1b 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditText.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditText.js @@ -85,7 +85,7 @@ define([ }, setMode: function (mode) { - _isEdit = ('edit' === mode); + _isEdit = mode.isEdit; }, onPageShow: function (view, pageId) { diff --git a/apps/spreadsheeteditor/mobile/app/view/Search.js b/apps/spreadsheeteditor/mobile/app/view/Search.js index 1e197625c..ab62d536a 100644 --- a/apps/spreadsheeteditor/mobile/app/view/Search.js +++ b/apps/spreadsheeteditor/mobile/app/view/Search.js @@ -84,7 +84,7 @@ define([ }, setMode: function (mode) { - _isEdit = (mode === 'edit'); + _isEdit = mode.isEdit; this.render(); }, diff --git a/apps/spreadsheeteditor/mobile/app/view/Settings.js b/apps/spreadsheeteditor/mobile/app/view/Settings.js index 934f8363a..133ad23b5 100644 --- a/apps/spreadsheeteditor/mobile/app/view/Settings.js +++ b/apps/spreadsheeteditor/mobile/app/view/Settings.js @@ -49,7 +49,9 @@ define([ SSE.Views.Settings = Backbone.View.extend(_.extend((function() { // private - var isEdit; + var isEdit, + canEdit = false, + canDownload = false; return { // el: '.view-main', @@ -96,7 +98,9 @@ define([ }, setMode: function (mode) { - isEdit = (mode === 'edit') + isEdit = mode.isEdit; + canEdit = !mode.isEdit && mode.canEdit && mode.canRequestEditRights; + canDownload = mode.canDownload || mode.canDownloadOrigin; }, rootLayout: function () { @@ -108,7 +112,9 @@ define([ $layout.find('#settings-edit-document').hide(); $layout.find('#settings-search .item-title').text(this.textFindAndReplace) } else { + if (!canEdit) $layout.find('#settings-edit-document').hide(); } + if (!canDownload) $layout.find('#settings-download').hide(); return $layout.html(); } diff --git a/apps/spreadsheeteditor/mobile/app/view/Statusbar.js b/apps/spreadsheeteditor/mobile/app/view/Statusbar.js index 837f54ca0..2ac121216 100644 --- a/apps/spreadsheeteditor/mobile/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/mobile/app/view/Statusbar.js @@ -205,11 +205,10 @@ define([ }, setMode: function(mode) { - if ('edit' == mode) { - this.$btnAddTab.show(); - } else if ('disconnect' == mode) { this.$btnAddTab.toggleClass('disabled', true); + } else if (mode.isEdit) { + this.$btnAddTab.show(); } }, diff --git a/apps/spreadsheeteditor/mobile/app/view/Toolbar.js b/apps/spreadsheeteditor/mobile/app/view/Toolbar.js index 740a33db4..aff1c023f 100644 --- a/apps/spreadsheeteditor/mobile/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/mobile/app/view/Toolbar.js @@ -90,9 +90,7 @@ define([ }, setMode: function (mode) { - var isEdit = (mode === 'edit'); - - if (isEdit) { + if (mode.isEdit) { $('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show(); } },