[PE mobile] Disable editing for locked objects and slides, disable adding objects to deleted slides.
This commit is contained in:
parent
a55e031b41
commit
993017e082
|
@ -78,6 +78,7 @@ define([
|
|||
|
||||
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,29 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onApiFocusObject: function (objects) {
|
||||
if (objects.length > 0) {
|
||||
var slide_deleted = false,
|
||||
slide_lock = false,
|
||||
no_object = true,
|
||||
objectLocked = false;
|
||||
_.each(objects, function(object) {
|
||||
var type = object.get_ObjectType(),
|
||||
objectValue = object.get_ObjectValue();
|
||||
if (type == Asc.c_oAscTypeSelectElement.Slide) {
|
||||
slide_deleted = objectValue.get_LockDelete();
|
||||
slide_lock = objectValue.get_LockLayout() || objectValue.get_LockBackground() || objectValue.get_LockTranzition() || objectValue.get_LockTiming();
|
||||
} else if (objectValue && _.isFunction(objectValue.get_Locked)) {
|
||||
no_object = false;
|
||||
objectLocked = objectLocked || objectValue.get_Locked();
|
||||
}
|
||||
});
|
||||
|
||||
$('#toolbar-add').toggleClass('disabled', slide_deleted);
|
||||
$('#toolbar-edit').toggleClass('disabled', slide_deleted || (objectLocked || no_object) && slide_lock );
|
||||
}
|
||||
},
|
||||
|
||||
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',
|
||||
|
|
|
@ -47,7 +47,8 @@ define([
|
|||
|
||||
PE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() {
|
||||
// private
|
||||
var _canAddHyperlink = false;
|
||||
var _canAddHyperlink = false,
|
||||
_paragraphLocked = false;
|
||||
|
||||
return {
|
||||
models: [],
|
||||
|
@ -61,6 +62,7 @@ define([
|
|||
setApi: function(api) {
|
||||
this.api = api;
|
||||
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
|
||||
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
|
||||
},
|
||||
|
||||
onLaunch: function() {
|
||||
|
@ -123,7 +125,7 @@ define([
|
|||
.rootLayout()
|
||||
});
|
||||
|
||||
if (_canAddHyperlink)
|
||||
if (_canAddHyperlink && !_paragraphLocked)
|
||||
addViews.push({
|
||||
caption: me.textLink,
|
||||
id: 'add-link',
|
||||
|
@ -272,6 +274,15 @@ define([
|
|||
_canAddHyperlink = value;
|
||||
},
|
||||
|
||||
onApiFocusObject: function (objects) {
|
||||
_paragraphLocked = false;
|
||||
_.each(objects, function(object) {
|
||||
if (Asc.c_oAscTypeSelectElement.Paragraph == object.get_ObjectType()) {
|
||||
_paragraphLocked = object.get_ObjectValue().get_Locked();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
textSlide: 'Slide',
|
||||
textTable: 'Table',
|
||||
textShape: 'Shape',
|
||||
|
|
|
@ -319,23 +319,31 @@ define([
|
|||
|
||||
var no_text = true;
|
||||
_.each(objects, function(object) {
|
||||
var type = object.get_ObjectType();
|
||||
var type = object.get_ObjectType(),
|
||||
objectValue = object.get_ObjectValue();
|
||||
|
||||
if (Asc.c_oAscTypeSelectElement.Paragraph == type) {
|
||||
no_text = false;
|
||||
if ( !objectValue.get_Locked() )
|
||||
no_text = false;
|
||||
} else if (Asc.c_oAscTypeSelectElement.Table == type) {
|
||||
_settings.push('table');
|
||||
no_text = false;
|
||||
if ( !objectValue.get_Locked() ) {
|
||||
_settings.push('table');
|
||||
no_text = false;
|
||||
}
|
||||
} else if (Asc.c_oAscTypeSelectElement.Slide == type) {
|
||||
_settings.push('slide');
|
||||
if ( !(objectValue.get_LockLayout() || objectValue.get_LockBackground() || objectValue.get_LockTranzition() || objectValue.get_LockTiming() ))
|
||||
_settings.push('slide');
|
||||
} else if (Asc.c_oAscTypeSelectElement.Image == type) {
|
||||
_settings.push('image');
|
||||
if ( !objectValue.get_Locked() )
|
||||
_settings.push('image');
|
||||
} else if (Asc.c_oAscTypeSelectElement.Chart == type) {
|
||||
_settings.push('chart');
|
||||
// no_text = false;
|
||||
} else if (Asc.c_oAscTypeSelectElement.Shape == type && !object.get_ObjectValue().get_FromChart()) {
|
||||
_settings.push('shape');
|
||||
no_text = false;
|
||||
if ( !objectValue.get_Locked() )
|
||||
_settings.push('chart');
|
||||
} else if (Asc.c_oAscTypeSelectElement.Shape == type && !objectValue.get_FromChart()) {
|
||||
if ( !objectValue.get_Locked() ) {
|
||||
_settings.push('shape');
|
||||
no_text = false;
|
||||
}
|
||||
} else if (Asc.c_oAscTypeSelectElement.Hyperlink == type) {
|
||||
_settings.push('hyperlink');
|
||||
}
|
||||
|
@ -343,6 +351,11 @@ define([
|
|||
if (!no_text)
|
||||
_settings.unshift('text');
|
||||
|
||||
// Exclude hyperlink if text is locked
|
||||
if (_settings.indexOf('hyperlink') > -1 && _settings.indexOf('text')<0) {
|
||||
_settings = _.without(_settings, 'hyperlink');
|
||||
}
|
||||
|
||||
// Exclude shapes if chart exist
|
||||
if (_settings.indexOf('chart') > -1) {
|
||||
_settings = _.without(_settings, 'shape');
|
||||
|
|
Loading…
Reference in a new issue