[Mobile] Using app mode options for hiding items in the Settings menu (download, edit).

This commit is contained in:
Julia Radzhabova 2017-05-25 12:55:29 +03:00
parent 72219ab52d
commit a4a97a1877
23 changed files with 54 additions and 43 deletions

View file

@ -92,7 +92,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
// When our application is ready, lets get started // When our application is ready, lets get started

View file

@ -229,11 +229,11 @@ define([
setMode: function(mode){ setMode: function(mode){
var me = this; var me = this;
Common.SharedSettings.set('mode', mode); Common.SharedSettings.set('mode', mode.isEdit ? 'edit' : 'view');
if (me.api) { if (me.api) {
me.api.asc_enableKeyEvents(mode == 'edit'); me.api.asc_enableKeyEvents(mode.isEdit);
me.api.asc_setViewMode(mode != 'edit'); me.api.asc_setViewMode(!mode.isEdit);
} }
}, },
@ -637,7 +637,7 @@ define([
_.each(me.getApplication().controllers, function(controller) { _.each(me.getApplication().controllers, function(controller) {
if (controller && _.isFunction(controller.setMode)) { if (controller && _.isFunction(controller.setMode)) {
controller.setMode(me.editorConfig.mode); controller.setMode(me.appOptions);
} }
}); });

View file

@ -84,7 +84,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = (mode === 'edit'); _isEdit = mode.isEdit;
this.render(); this.render();
}, },

View file

@ -50,7 +50,9 @@ define([
DE.Views.Settings = Backbone.View.extend(_.extend((function() { DE.Views.Settings = Backbone.View.extend(_.extend((function() {
// private // private
var _isEdit = false; var _isEdit = false,
_canEdit = false,
_canDownload = false;
return { return {
// el: '.view-main', // el: '.view-main',
@ -86,7 +88,9 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = (mode === 'edit') _isEdit = mode.isEdit;
_canEdit = !mode.isEdit && mode.canEdit && mode.canRequestEditRights;
_canDownload = mode.canDownload || mode.canDownloadOrigin;
}, },
rootLayout: function () { rootLayout: function () {
@ -99,10 +103,12 @@ define([
$layour.find('#settings-readermode').hide(); $layour.find('#settings-readermode').hide();
$layour.find('#settings-search .item-title').text(this.textFindAndReplace) $layour.find('#settings-search .item-title').text(this.textFindAndReplace)
} else { } else {
if (!_canEdit) $layour.find('#settings-edit-document').hide();
$layour.find('#settings-document').hide(); $layour.find('#settings-document').hide();
$layour.find('#settings-readermode input:checkbox') $layour.find('#settings-readermode input:checkbox')
.prop('checked', Common.SharedSettings.get('readerMode')); .prop('checked', Common.SharedSettings.get('readerMode'));
} }
if (!_canDownload) $layour.find('#settings-download').hide();
return $layour.html(); return $layour.html();
} }

View file

@ -97,9 +97,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
var isEdit = (mode === 'edit'); if (mode.isEdit) {
if (isEdit) {
$('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show(); $('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show();
} }
}, },

View file

@ -84,7 +84,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
// When our application is ready, lets get started // When our application is ready, lets get started

View file

@ -226,11 +226,11 @@ define([
setMode: function(mode){ setMode: function(mode){
var me = this; var me = this;
Common.SharedSettings.set('mode', mode); Common.SharedSettings.set('mode', mode.isEdit ? 'edit' : 'view');
if (me.api) { if (me.api) {
me.api.asc_enableKeyEvents(mode == 'edit'); me.api.asc_enableKeyEvents(mode.isEdit);
me.api.asc_setViewMode(mode != 'edit'); me.api.asc_setViewMode(!mode.isEdit);
} }
}, },
@ -593,7 +593,7 @@ define([
_.each(me.getApplication().controllers, function(controller) { _.each(me.getApplication().controllers, function(controller) {
if (controller && _.isFunction(controller.setMode)) { if (controller && _.isFunction(controller.setMode)) {
controller.setMode(me.editorConfig.mode); controller.setMode(me.appOptions);
} }
}); });

View file

@ -84,7 +84,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = (mode === 'edit'); _isEdit = mode.isEdit;
this.render(); this.render();
}, },

View file

@ -50,7 +50,9 @@ define([
PE.Views.Settings = Backbone.View.extend(_.extend((function() { PE.Views.Settings = Backbone.View.extend(_.extend((function() {
// private // private
var isEdit; var isEdit,
canEdit = false,
canDownload = false;
return { return {
// el: '.view-main', // el: '.view-main',
@ -91,7 +93,9 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
isEdit = (mode === 'edit') isEdit = mode.isEdit;
canEdit = !mode.isEdit && mode.canEdit && mode.canRequestEditRights;
canDownload = mode.canDownload || mode.canDownloadOrigin;
}, },
rootLayout: function () { rootLayout: function () {
@ -104,11 +108,13 @@ define([
$layour.find('#settings-readermode').hide(); $layour.find('#settings-readermode').hide();
$layour.find('#settings-search .item-title').text(this.textFindAndReplace) $layour.find('#settings-search .item-title').text(this.textFindAndReplace)
} else { } else {
if (!canEdit) $layour.find('#settings-edit-presentation').hide();
$layour.find('#settings-presentation-setup').hide(); $layour.find('#settings-presentation-setup').hide();
$layour.find('#settings-readermode input:checkbox') $layour.find('#settings-readermode input:checkbox')
.attr('checked', Common.SharedSettings.get('readerMode')) .attr('checked', Common.SharedSettings.get('readerMode'))
.prop('checked', Common.SharedSettings.get('readerMode')); .prop('checked', Common.SharedSettings.get('readerMode'));
} }
if (!canDownload) $layour.find('#settings-download').hide();
return $layour.html(); return $layour.html();
} }

View file

@ -98,9 +98,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
var isEdit = (mode === 'edit'); if (mode.isEdit) {
if (isEdit) {
$('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show(); $('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show();
} }
}, },

View file

@ -177,7 +177,7 @@ define([
}, },
onInsertFunction: function() { onInsertFunction: function() {
if (this.mode == 'edit') { if (this.mode.isEdit) {
SSE.getController('AddContainer').showModal({ SSE.getController('AddContainer').showModal({
panel: 'function', panel: 'function',
button: '#ce-function' button: '#ce-function'

View file

@ -85,7 +85,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
// When our application is ready, lets get started // When our application is ready, lets get started

View file

@ -228,11 +228,11 @@ define([
setMode: function(mode){ setMode: function(mode){
var me = this; var me = this;
Common.SharedSettings.set('mode', mode); Common.SharedSettings.set('mode', mode.isEdit ? 'edit' : 'view');
if ( me.api ) { if ( me.api ) {
me.api.asc_enableKeyEvents(mode == 'edit'); me.api.asc_enableKeyEvents(mode.isEdit);
me.api.asc_setViewMode(mode != 'edit'); me.api.asc_setViewMode(!mode.isEdit);
} }
}, },
@ -614,7 +614,7 @@ define([
_.each(me.getApplication().controllers, function(controller) { _.each(me.getApplication().controllers, function(controller) {
if (controller && _.isFunction(controller.setMode)) { if (controller && _.isFunction(controller.setMode)) {
controller.setMode(me.editorConfig.mode); controller.setMode(me.appOptions);
} }
}); });

View file

@ -112,7 +112,7 @@ define([
setMode: function(mode) { setMode: function(mode) {
this.statusbar.setMode(mode); this.statusbar.setMode(mode);
this.isEdit = mode == 'edit'; this.isEdit = mode.isEdit;
}, },
/* /*

View file

@ -107,7 +107,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
onLaunch: function () { onLaunch: function () {

View file

@ -117,7 +117,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
onLaunch: function () { onLaunch: function () {

View file

@ -81,7 +81,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
onPageShow: function (view, pageId) { onPageShow: function (view, pageId) {

View file

@ -110,7 +110,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
onPageShow: function (view, pageId) { onPageShow: function (view, pageId) {

View file

@ -85,7 +85,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = ('edit' === mode); _isEdit = mode.isEdit;
}, },
onPageShow: function (view, pageId) { onPageShow: function (view, pageId) {

View file

@ -84,7 +84,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = (mode === 'edit'); _isEdit = mode.isEdit;
this.render(); this.render();
}, },

View file

@ -49,7 +49,9 @@ define([
SSE.Views.Settings = Backbone.View.extend(_.extend((function() { SSE.Views.Settings = Backbone.View.extend(_.extend((function() {
// private // private
var isEdit; var isEdit,
canEdit = false,
canDownload = false;
return { return {
// el: '.view-main', // el: '.view-main',
@ -96,7 +98,9 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
isEdit = (mode === 'edit') isEdit = mode.isEdit;
canEdit = !mode.isEdit && mode.canEdit && mode.canRequestEditRights;
canDownload = mode.canDownload || mode.canDownloadOrigin;
}, },
rootLayout: function () { rootLayout: function () {
@ -108,7 +112,9 @@ define([
$layout.find('#settings-edit-document').hide(); $layout.find('#settings-edit-document').hide();
$layout.find('#settings-search .item-title').text(this.textFindAndReplace) $layout.find('#settings-search .item-title').text(this.textFindAndReplace)
} else { } else {
if (!canEdit) $layout.find('#settings-edit-document').hide();
} }
if (!canDownload) $layout.find('#settings-download').hide();
return $layout.html(); return $layout.html();
} }

View file

@ -205,11 +205,10 @@ define([
}, },
setMode: function(mode) { setMode: function(mode) {
if ('edit' == mode) {
this.$btnAddTab.show();
} else
if ('disconnect' == mode) { if ('disconnect' == mode) {
this.$btnAddTab.toggleClass('disabled', true); this.$btnAddTab.toggleClass('disabled', true);
} else if (mode.isEdit) {
this.$btnAddTab.show();
} }
}, },

View file

@ -90,9 +90,7 @@ define([
}, },
setMode: function (mode) { setMode: function (mode) {
var isEdit = (mode === 'edit'); if (mode.isEdit) {
if (isEdit) {
$('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show(); $('#toolbar-edit, #toolbar-add, #toolbar-undo, #toolbar-redo').show();
} }
}, },