[PE][SSE] Add crop for images and shapes to context menu

This commit is contained in:
Julia Radzhabova 2019-04-09 14:29:51 +03:00
parent 3fbf4713e8
commit 2bbfec1e18
8 changed files with 124 additions and 15 deletions

View file

@ -2387,17 +2387,17 @@ define([
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
items: [ items: [
new Common.UI.MenuItem({ new Common.UI.MenuItem({
caption: this.textCrop, caption: me.textCrop,
checkable: true, checkable: true,
allowDepress: true, allowDepress: true,
value : 0 value : 0
}).on('click', _.bind(me.onImgCrop, me)), }).on('click', _.bind(me.onImgCrop, me)),
new Common.UI.MenuItem({ new Common.UI.MenuItem({
caption: this.textCropFill, caption: me.textCropFill,
value : 1 value : 1
}).on('click', _.bind(me.onImgCrop, me)), }).on('click', _.bind(me.onImgCrop, me)),
new Common.UI.MenuItem({ new Common.UI.MenuItem({
caption: this.textCropFit, caption: me.textCropFit,
value : 2 value : 2
}).on('click', _.bind(me.onImgCrop, me)) }).on('click', _.bind(me.onImgCrop, me))
] ]

View file

@ -1568,6 +1568,10 @@ define([
pasteContainer.hide(); pasteContainer.hide();
}; };
var onChangeCropState = function(state) {
this.menuImgCrop.menu.items[0].setChecked(state, true);
};
this.setApi = function(o) { this.setApi = function(o) {
me.api = o; me.api = o;
@ -1591,6 +1595,7 @@ define([
me.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, me)); me.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, me));
me.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(onShowSpecialPasteOptions, me)); me.api.asc_registerCallback('asc_onShowSpecialPasteOptions', _.bind(onShowSpecialPasteOptions, me));
me.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(onHideSpecialPasteOptions, me)); me.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(onHideSpecialPasteOptions, me));
me.api.asc_registerCallback('asc_ChangeCropState', _.bind(onChangeCropState, me));
} }
me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(onCoAuthoringDisconnect, me)); me.api.asc_registerCallback('asc_onCoAuthoringDisconnect', _.bind(onCoAuthoringDisconnect, me));
@ -1612,12 +1617,6 @@ define([
this.mode = {}; this.mode = {};
this.setMode = function(mode) { this.setMode = function(mode) {
if (me.api && mode.isEdit) {
me.api.asc_registerCallback('asc_onDialogAddHyperlink', _.bind(onDialogAddHyperlink, me));
me.api.asc_registerCallback('asc_doubleClickOnChart', onDoubleClickOnChart);
me.api.asc_registerCallback('asc_onSpellCheckVariantsFound', _.bind(onSpellCheckVariantsFound, me));
}
me.mode = mode; me.mode = mode;
/** coauthoring begin **/ /** coauthoring begin **/
!(me.mode.canCoAuthoring && me.mode.canComments) !(me.mode.canCoAuthoring && me.mode.canComments)
@ -2820,6 +2819,40 @@ define([
}) })
}); });
var onImgCrop = function(item) {
if (item.value == 1) {
me.api.asc_cropFill();
} else if (item.value == 2) {
me.api.asc_cropFit();
} else {
item.checked ? me.api.asc_startEditCrop() : me.api.asc_endEditCrop();
}
me.fireEvent('editcomplete', me);
};
me.menuImgCrop = new Common.UI.MenuItem({
caption : me.textCrop,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
new Common.UI.MenuItem({
caption: me.textCrop,
checkable: true,
allowDepress: true,
value : 0
}).on('click', _.bind(onImgCrop, me)),
new Common.UI.MenuItem({
caption: me.textCropFill,
value : 1
}).on('click', _.bind(onImgCrop, me)),
new Common.UI.MenuItem({
caption: me.textCropFit,
value : 2
}).on('click', _.bind(onImgCrop, me))
]
})
});
/** coauthoring begin **/ /** coauthoring begin **/
var menuAddCommentPara = new Common.UI.MenuItem({ var menuAddCommentPara = new Common.UI.MenuItem({
caption : me.addCommentText caption : me.addCommentText
@ -3234,6 +3267,10 @@ define([
if (menuImgReplace.isVisible()) if (menuImgReplace.isVisible())
menuImgReplace.setDisabled(disabled || pluginGuid===null); menuImgReplace.setDisabled(disabled || pluginGuid===null);
me.menuImgCrop.setVisible(me.api.asc_canEditCrop());
if (me.menuImgCrop.isVisible())
me.menuImgCrop.setDisabled(disabled);
menuImageAdvanced.setVisible(isimage); menuImageAdvanced.setVisible(isimage);
menuShapeAdvanced.setVisible(_.isUndefined(value.imgProps) && _.isUndefined(value.chartProps)); menuShapeAdvanced.setVisible(_.isUndefined(value.imgProps) && _.isUndefined(value.chartProps));
menuChartEdit.setVisible(_.isUndefined(value.imgProps) && !_.isUndefined(value.chartProps) && (_.isUndefined(value.shapeProps) || value.shapeProps.isChart)); menuChartEdit.setVisible(_.isUndefined(value.imgProps) && !_.isUndefined(value.chartProps) && (_.isUndefined(value.shapeProps) || value.shapeProps.isChart));
@ -3267,6 +3304,7 @@ define([
menuImgShapeAlign, menuImgShapeAlign,
menuImgShapeRotate, menuImgShapeRotate,
menuImgShapeSeparator, menuImgShapeSeparator,
me.menuImgCrop,
menuImgOriginalSize, menuImgOriginalSize,
menuImgReplace, menuImgReplace,
menuImageAdvanced, menuImageAdvanced,
@ -3534,7 +3572,10 @@ define([
textRotate90: 'Rotate 90° Clockwise', textRotate90: 'Rotate 90° Clockwise',
textFlipV: 'Flip Vertically', textFlipV: 'Flip Vertically',
textFlipH: 'Flip Horizontally', textFlipH: 'Flip Horizontally',
textRotate: 'Rotate' textRotate: 'Rotate',
textCrop: 'Crop',
textCropFill: 'Fill',
textCropFit: 'Fit'
}, PE.Views.DocumentHolder || {})); }, PE.Views.DocumentHolder || {}));
}); });

View file

@ -70,7 +70,8 @@ define([
Width: 0, Width: 0,
Height: 0, Height: 0,
DisabledControls: false, DisabledControls: false,
isOleObject: false isOleObject: false,
cropMode: false
}; };
this.lockedControls = []; this.lockedControls = [];
this._locked = false; this._locked = false;
@ -148,6 +149,7 @@ define([
split: true, split: true,
enableToggle: true, enableToggle: true,
allowDepress: true, allowDepress: true,
pressed: this._state.cropMode,
width: 100, width: 100,
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
style : 'min-width: 100px;', style : 'min-width: 100px;',
@ -156,6 +158,7 @@ define([
caption: this.textCrop, caption: this.textCrop,
checkable: true, checkable: true,
allowDepress: true, allowDepress: true,
checked: this._state.cropMode,
value: 0 value: 0
}, },
{ {
@ -347,6 +350,9 @@ define([
}, },
_changeCropState: function(state) { _changeCropState: function(state) {
this._state.cropMode = state;
if (!this.btnCrop) return;
this.btnCrop.toggle(state, true); this.btnCrop.toggle(state, true);
this.btnCrop.menu.items[0].setChecked(state, true); this.btnCrop.menu.items[0].setChecked(state, true);
}, },

View file

@ -1110,6 +1110,9 @@
"PE.Views.DocumentHolder.txtUnderbar": "Bar under text", "PE.Views.DocumentHolder.txtUnderbar": "Bar under text",
"PE.Views.DocumentHolder.txtUngroup": "Ungroup", "PE.Views.DocumentHolder.txtUngroup": "Ungroup",
"PE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", "PE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"PE.Views.DocumentHolder.textCrop": "Crop",
"PE.Views.DocumentHolder.textCropFill": "Fill",
"PE.Views.DocumentHolder.textCropFit": "Fit",
"PE.Views.DocumentPreview.goToSlideText": "Go to Slide", "PE.Views.DocumentPreview.goToSlideText": "Go to Slide",
"PE.Views.DocumentPreview.slideIndexText": "Slide {0} of {1}", "PE.Views.DocumentPreview.slideIndexText": "Slide {0} of {1}",
"PE.Views.DocumentPreview.txtClose": "Close slideshow", "PE.Views.DocumentPreview.txtClose": "Close slideshow",

View file

@ -186,6 +186,7 @@ define([
view.pmiAddNamedRange.on('click', _.bind(me.onAddNamedRange, me)); view.pmiAddNamedRange.on('click', _.bind(me.onAddNamedRange, me));
view.menuImageArrange.menu.on('item:click', _.bind(me.onImgMenu, me)); view.menuImageArrange.menu.on('item:click', _.bind(me.onImgMenu, me));
view.menuImgRotate.menu.on('item:click', _.bind(me.onImgMenu, me)); view.menuImgRotate.menu.on('item:click', _.bind(me.onImgMenu, me));
view.menuImgCrop.menu.on('item:click', _.bind(me.onImgCrop, me));
view.menuImageAlign.menu.on('item:click', _.bind(me.onImgMenuAlign, me)); view.menuImageAlign.menu.on('item:click', _.bind(me.onImgMenuAlign, me));
view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me)); view.menuParagraphVAlign.menu.on('item:click', _.bind(me.onParagraphVAlign, me));
view.menuParagraphDirection.menu.on('item:click', _.bind(me.onParagraphDirection, me)); view.menuParagraphDirection.menu.on('item:click', _.bind(me.onParagraphDirection, me));
@ -283,6 +284,7 @@ define([
this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this)); this.api.asc_registerCallback('asc_onHideSpecialPasteOptions', _.bind(this.onHideSpecialPasteOptions, this));
this.api.asc_registerCallback('asc_onToggleAutoCorrectOptions', _.bind(this.onToggleAutoCorrectOptions, this)); this.api.asc_registerCallback('asc_onToggleAutoCorrectOptions', _.bind(this.onToggleAutoCorrectOptions, this));
this.api.asc_registerCallback('asc_onFormulaInfo', _.bind(this.onFormulaInfo, this)); this.api.asc_registerCallback('asc_onFormulaInfo', _.bind(this.onFormulaInfo, this));
this.api.asc_registerCallback('asc_ChangeCropState', _.bind(this.onChangeCropState, this));
} }
return this; return this;
}, },
@ -663,6 +665,19 @@ define([
} }
}, },
onImgCrop: function(menu, item) {
if (this.api) {
if (item.value == 1) {
this.api.asc_cropFill();
} else if (item.value == 2) {
this.api.asc_cropFit();
} else {
item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop();
}
}
Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
},
onImgMenuAlign: function(menu, item) { onImgMenuAlign: function(menu, item) {
if (this.api) { if (this.api) {
if (item.value>-1 && item.value < 6) { if (item.value>-1 && item.value < 6) {
@ -1563,6 +1578,10 @@ define([
documentHolder.menuImgRotate.setVisible(!ischartmenu && (pluginGuid===null || pluginGuid===undefined)); documentHolder.menuImgRotate.setVisible(!ischartmenu && (pluginGuid===null || pluginGuid===undefined));
documentHolder.menuImgRotate.setDisabled(isObjLocked); documentHolder.menuImgRotate.setDisabled(isObjLocked);
documentHolder.menuImgCrop.setVisible(this.api.asc_canEditCrop());
if (documentHolder.menuImgCrop.isVisible())
documentHolder.menuImgCrop.setDisabled(isObjLocked);
var isInSign = !!signGuid; var isInSign = !!signGuid;
documentHolder.menuSignatureEditSign.setVisible(isInSign); documentHolder.menuSignatureEditSign.setVisible(isInSign);
documentHolder.menuSignatureEditSetup.setVisible(isInSign); documentHolder.menuSignatureEditSetup.setVisible(isInSign);
@ -2288,6 +2307,10 @@ define([
this.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager); this.namedrange_locked = (state == Asc.c_oAscDefinedNameReason.LockDefNameManager);
}, },
onChangeCropState: function(state) {
this.documentHolder.menuImgCrop.menu.items[0].setChecked(state, true);
},
initEquationMenu: function() { initEquationMenu: function() {
if (!this._currentMathObj) return; if (!this._currentMathObj) return;
var me = this, var me = this,

View file

@ -605,6 +605,29 @@ define([
}) })
}); });
me.menuImgCrop = new Common.UI.MenuItem({
caption : me.textCrop,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
new Common.UI.MenuItem({
caption: me.textCrop,
checkable: true,
allowDepress: true,
value : 0
}),
new Common.UI.MenuItem({
caption: me.textCropFill,
value : 1
}),
new Common.UI.MenuItem({
caption: me.textCropFit,
value : 2
})
]
})
});
me.mnuBringToFront = new Common.UI.MenuItem({ me.mnuBringToFront = new Common.UI.MenuItem({
caption : this.textArrangeFront, caption : this.textArrangeFront,
iconCls : 'mnu-arrange-front', iconCls : 'mnu-arrange-front',
@ -732,6 +755,7 @@ define([
me.menuImageAlign, me.menuImageAlign,
me.menuImgRotate, me.menuImgRotate,
me.mnuShapeSeparator, me.mnuShapeSeparator,
me.menuImgCrop,
me.mnuChartEdit, me.mnuChartEdit,
me.mnuShapeAdvanced, me.mnuShapeAdvanced,
me.menuImgOriginalSize, me.menuImgOriginalSize,
@ -1053,7 +1077,10 @@ define([
textFlipH: 'Flip Horizontally', textFlipH: 'Flip Horizontally',
textRotate: 'Rotate', textRotate: 'Rotate',
textArrange: 'Arrange', textArrange: 'Arrange',
textAlign: 'Align' textAlign: 'Align',
textCrop: 'Crop',
textCropFill: 'Fill',
textCropFit: 'Fit'
}, SSE.Views.DocumentHolder || {})); }, SSE.Views.DocumentHolder || {}));
}); });

View file

@ -73,7 +73,8 @@ define([
Height: 0, Height: 0,
DisabledControls: false, DisabledControls: false,
keepRatio: false, keepRatio: false,
isOleObject: false isOleObject: false,
cropMode: false
}; };
this.spinners = []; this.spinners = [];
this.lockedControls = []; this.lockedControls = [];
@ -204,6 +205,7 @@ define([
split: true, split: true,
enableToggle: true, enableToggle: true,
allowDepress: true, allowDepress: true,
pressed: this._state.cropMode,
width: 100, width: 100,
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
style : 'min-width: 100px;', style : 'min-width: 100px;',
@ -212,6 +214,7 @@ define([
caption: this.textCrop, caption: this.textCrop,
checkable: true, checkable: true,
allowDepress: true, allowDepress: true,
checked: this._state.cropMode,
value: 0 value: 0
}, },
{ {
@ -445,6 +448,9 @@ define([
}, },
_changeCropState: function(state) { _changeCropState: function(state) {
this._state.cropMode = state;
if (!this.btnCrop) return;
this.btnCrop.toggle(state, true); this.btnCrop.toggle(state, true);
this.btnCrop.menu.items[0].setChecked(state, true); this.btnCrop.menu.items[0].setChecked(state, true);
}, },
@ -453,7 +459,7 @@ define([
if (this.api) { if (this.api) {
btn.pressed ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); btn.pressed ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop();
} }
Common.NotificationCenter.trigger('edit:complete', me); Common.NotificationCenter.trigger('edit:complete', this);
}, },
onCropMenu: function(menu, item) { onCropMenu: function(menu, item) {
@ -466,7 +472,7 @@ define([
item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop(); item.checked ? this.api.asc_startEditCrop() : this.api.asc_endEditCrop();
} }
} }
Common.NotificationCenter.trigger('edit:complete', me); Common.NotificationCenter.trigger('edit:complete', this);
}, },
onBtnRotateClick: function(btn) { onBtnRotateClick: function(btn) {

View file

@ -1449,6 +1449,9 @@
"SSE.Views.DocumentHolder.txtUngroup": "Ungroup", "SSE.Views.DocumentHolder.txtUngroup": "Ungroup",
"SSE.Views.DocumentHolder.txtWidth": "Width", "SSE.Views.DocumentHolder.txtWidth": "Width",
"SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", "SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"SSE.Views.DocumentHolder.textCrop": "Crop",
"SSE.Views.DocumentHolder.textCropFill": "Fill",
"SSE.Views.DocumentHolder.textCropFit": "Fit",
"SSE.Views.FileMenu.btnBackCaption": "Open file location", "SSE.Views.FileMenu.btnBackCaption": "Open file location",
"SSE.Views.FileMenu.btnCloseMenuCaption": "Close Menu", "SSE.Views.FileMenu.btnCloseMenuCaption": "Close Menu",
"SSE.Views.FileMenu.btnCreateNewCaption": "Create New", "SSE.Views.FileMenu.btnCreateNewCaption": "Create New",