diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 661c4f4a3..5bbf9c766 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -295,6 +295,7 @@ define([ $('#id-toolbar-menu-new-fontcolor').on('click', _.bind(this.onNewFontColor, this)); toolbar.btnLineSpace.menu.on('item:toggle', _.bind(this.onLineSpaceToggle, this)); toolbar.btnShapeAlign.menu.on('item:click', _.bind(this.onShapeAlign, this)); + toolbar.btnShapeAlign.menu.on('show:before', _.bind(this.onBeforeShapeAlign, this)); toolbar.btnShapeArrange.menu.on('item:click', _.bind(this.onShapeArrange, this)); toolbar.btnInsertHyperlink.on('click', _.bind(this.onHyperlinkClick, this)); toolbar.mnuTablePicker.on('select', _.bind(this.onTablePickerSelect, this)); @@ -1209,16 +1210,25 @@ define([ } }, + onBeforeShapeAlign: function() { + var value = this.api.asc_getSelectedDrawingObjectsCount(), + slide_checked = Common.Utils.InternalSettings.get("pe-align-to-slide") || false; + this.toolbar.mniAlignObjects.setDisabled(value<2); + this.toolbar.mniAlignObjects.setChecked(value>1 && !slide_checked, true); + this.toolbar.mniAlignToSlide.setChecked(value<2 || slide_checked, true); + }, + onShapeAlign: function(menu, item) { if (this.api) { - if (item.value < 6) { - this.api.put_ShapesAlign(item.value); + var value = this.toolbar.mniAlignToSlide.isChecked() ? Asc.c_oAscObjectsAlignType.Slide : Asc.c_oAscObjectsAlignType.Selected; + if (item.value>-1 && item.value < 6) { + this.api.put_ShapesAlign(item.value, value); Common.component.Analytics.trackEvent('ToolBar', 'Shape Align'); } else if (item.value == 6) { - this.api.DistributeHorizontally(); + this.api.DistributeHorizontally(value); Common.component.Analytics.trackEvent('ToolBar', 'Distribute'); - } else { - this.api.DistributeVertically(); + } else if (item.value == 7){ + this.api.DistributeVertically(value); Common.component.Analytics.trackEvent('ToolBar', 'Distribute'); } Common.NotificationCenter.trigger('edit:complete', this.toolbar); diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index a91cff719..3ea28f179 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -590,6 +590,23 @@ define([ }); me.slideOnlyControls.push(me.btnColorSchemas); + me.mniAlignToSlide = new Common.UI.MenuItem({ + caption: me.txtSlideAlign, + checkable: true, + toggleGroup: 'slidealign', + value: -1 + }).on('click', function (mnu) { + Common.Utils.InternalSettings.set("pe-align-to-slide", true); + }); + me.mniAlignObjects = new Common.UI.MenuItem({ + caption: me.txtObjectsAlign, + checkable: true, + toggleGroup: 'slidealign', + value: -1 + }).on('click', function (mnu) { + Common.Utils.InternalSettings.set("pe-align-to-slide", false); + }); + me.btnShapeAlign = new Common.UI.Button({ id: 'id-toolbar-btn-shape-align', cls: 'btn-toolbar', @@ -637,7 +654,10 @@ define([ caption: me.txtDistribVert, iconCls: 'mnu-distrib-vert', value: 7 - } + }, + {caption: '--'}, + me.mniAlignToSlide, + me.mniAlignObjects ] }) }); @@ -1738,7 +1758,9 @@ define([ textShowPresenterView: 'Show presenter view', textTabCollaboration: 'Collaboration', textTabProtect: 'Protection', - mniImageFromStorage: 'Image from Storage' + mniImageFromStorage: 'Image from Storage', + txtSlideAlign: 'Align to slide', + txtObjectsAlign: 'Align selected objects' } }()), PE.Views.Toolbar || {})); }); \ No newline at end of file diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index d09e2c269..d37510ab8 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -1746,5 +1746,8 @@ "PE.Views.Toolbar.txtScheme7": "Equity", "PE.Views.Toolbar.txtScheme8": "Flow", "PE.Views.Toolbar.txtScheme9": "Foundry", - "PE.Views.Toolbar.txtUngroup": "Ungroup" + "PE.Views.Toolbar.txtUngroup": "Ungroup", + "PE.Views.Toolbar.txtSlideAlign": "Align to slide", + "PE.Views.Toolbar.txtObjectsAlign": "Align selected objects" + } \ No newline at end of file