[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) {
_isEdit = ('edit' === mode);
_isEdit = mode.isEdit;
},
// When our application is ready, lets get started

View file

@ -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);
}
});

View file

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

View file

@ -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();
}

View file

@ -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();
}
},

View file

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

View file

@ -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);
}
});

View file

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

View file

@ -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();
}

View file

@ -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();
}
},

View file

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

View file

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

View file

@ -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);
}
});

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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();
}

View file

@ -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();
}
},

View file

@ -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();
}
},