[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_onCanUndo', _.bind(this.onApiCanRevert, this, 'undo'));
|
||||||
this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo'));
|
this.api.asc_registerCallback('asc_onCanRedo', _.bind(this.onApiCanRevert, this, 'redo'));
|
||||||
|
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
setMode: function (mode) {
|
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',
|
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.',
|
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',
|
leaveButtonText : 'Leave this Page',
|
||||||
|
|
|
@ -47,7 +47,8 @@ define([
|
||||||
|
|
||||||
PE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() {
|
PE.Controllers.AddContainer = Backbone.Controller.extend(_.extend((function() {
|
||||||
// private
|
// private
|
||||||
var _canAddHyperlink = false;
|
var _canAddHyperlink = false,
|
||||||
|
_paragraphLocked = false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
models: [],
|
models: [],
|
||||||
|
@ -61,6 +62,7 @@ define([
|
||||||
setApi: function(api) {
|
setApi: function(api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
|
this.api.asc_registerCallback('asc_onCanAddHyperlink', _.bind(this.onApiCanAddHyperlink, this));
|
||||||
|
this.api.asc_registerCallback('asc_onFocusObject', _.bind(this.onApiFocusObject, this));
|
||||||
},
|
},
|
||||||
|
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
|
@ -123,7 +125,7 @@ define([
|
||||||
.rootLayout()
|
.rootLayout()
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_canAddHyperlink)
|
if (_canAddHyperlink && !_paragraphLocked)
|
||||||
addViews.push({
|
addViews.push({
|
||||||
caption: me.textLink,
|
caption: me.textLink,
|
||||||
id: 'add-link',
|
id: 'add-link',
|
||||||
|
@ -272,6 +274,15 @@ define([
|
||||||
_canAddHyperlink = value;
|
_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',
|
textSlide: 'Slide',
|
||||||
textTable: 'Table',
|
textTable: 'Table',
|
||||||
textShape: 'Shape',
|
textShape: 'Shape',
|
||||||
|
|
|
@ -319,23 +319,31 @@ define([
|
||||||
|
|
||||||
var no_text = true;
|
var no_text = true;
|
||||||
_.each(objects, function(object) {
|
_.each(objects, function(object) {
|
||||||
var type = object.get_ObjectType();
|
var type = object.get_ObjectType(),
|
||||||
|
objectValue = object.get_ObjectValue();
|
||||||
|
|
||||||
if (Asc.c_oAscTypeSelectElement.Paragraph == type) {
|
if (Asc.c_oAscTypeSelectElement.Paragraph == type) {
|
||||||
no_text = false;
|
if ( !objectValue.get_Locked() )
|
||||||
|
no_text = false;
|
||||||
} else if (Asc.c_oAscTypeSelectElement.Table == type) {
|
} else if (Asc.c_oAscTypeSelectElement.Table == type) {
|
||||||
_settings.push('table');
|
if ( !objectValue.get_Locked() ) {
|
||||||
no_text = false;
|
_settings.push('table');
|
||||||
|
no_text = false;
|
||||||
|
}
|
||||||
} else if (Asc.c_oAscTypeSelectElement.Slide == type) {
|
} 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) {
|
} else if (Asc.c_oAscTypeSelectElement.Image == type) {
|
||||||
_settings.push('image');
|
if ( !objectValue.get_Locked() )
|
||||||
|
_settings.push('image');
|
||||||
} else if (Asc.c_oAscTypeSelectElement.Chart == type) {
|
} else if (Asc.c_oAscTypeSelectElement.Chart == type) {
|
||||||
_settings.push('chart');
|
if ( !objectValue.get_Locked() )
|
||||||
// no_text = false;
|
_settings.push('chart');
|
||||||
} else if (Asc.c_oAscTypeSelectElement.Shape == type && !object.get_ObjectValue().get_FromChart()) {
|
} else if (Asc.c_oAscTypeSelectElement.Shape == type && !objectValue.get_FromChart()) {
|
||||||
_settings.push('shape');
|
if ( !objectValue.get_Locked() ) {
|
||||||
no_text = false;
|
_settings.push('shape');
|
||||||
|
no_text = false;
|
||||||
|
}
|
||||||
} else if (Asc.c_oAscTypeSelectElement.Hyperlink == type) {
|
} else if (Asc.c_oAscTypeSelectElement.Hyperlink == type) {
|
||||||
_settings.push('hyperlink');
|
_settings.push('hyperlink');
|
||||||
}
|
}
|
||||||
|
@ -343,6 +351,11 @@ define([
|
||||||
if (!no_text)
|
if (!no_text)
|
||||||
_settings.unshift('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
|
// Exclude shapes if chart exist
|
||||||
if (_settings.indexOf('chart') > -1) {
|
if (_settings.indexOf('chart') > -1) {
|
||||||
_settings = _.without(_settings, 'shape');
|
_settings = _.without(_settings, 'shape');
|
||||||
|
|
Loading…
Reference in a new issue