diff --git a/apps/documenteditor/main/app/controller/RightMenu.js b/apps/documenteditor/main/app/controller/RightMenu.js index d03610264..55eb561d7 100644 --- a/apps/documenteditor/main/app/controller/RightMenu.js +++ b/apps/documenteditor/main/app/controller/RightMenu.js @@ -71,7 +71,7 @@ define([ }, onRightMenuAfterRender: function(rightMenu) { - rightMenu.shapeSettings.application = rightMenu.textartSettings.application = this.getApplication(); + rightMenu.imageSettings.application = rightMenu.shapeSettings.application = rightMenu.textartSettings.application = this.getApplication(); this._settings = []; this._settings[Common.Utils.documentSettingsType.Paragraph] = {panelId: "id-paragraph-settings", panel: rightMenu.paragraphSettings,btn: rightMenu.btnText, hidden: 1, locked: false}; diff --git a/apps/documenteditor/main/app/view/ImageSettings.js b/apps/documenteditor/main/app/view/ImageSettings.js index 86e1bb314..f5e7e0ff0 100644 --- a/apps/documenteditor/main/app/view/ImageSettings.js +++ b/apps/documenteditor/main/app/view/ImageSettings.js @@ -258,6 +258,15 @@ define([ checked: this._state.cropMode, value: 0 }, + { + caption: this.textCropToShape, + menu: new Common.UI.Menu({ + menuAlign: 'tr-br', + cls: 'menu-shapes menu-change-shape', + items: [] + }), + value: 3 + }, { caption: this.textCropFill, value: 1 @@ -275,6 +284,8 @@ define([ this.btnCrop.menu.on('item:click', _.bind(this.onCropMenu, this)); this.lockedControls.push(this.btnCrop); + this.btnChangeShape= this.btnCrop.menu.items[1]; + this.btnSelectImage = new Common.UI.Button({ parentEl: $('#image-button-replace'), cls: 'btn-text-menu-default', @@ -312,9 +323,52 @@ define([ createDelayedElements: function() { this.createDelayedControls(); this.updateMetricUnit(); + this.onApiAutoShapes(); this._initSettings = false; }, + onApiAutoShapes: function() { + var me = this; + var onShowBefore = function(menu) { + me.fillAutoShapes(); + menu.off('show:before', onShowBefore); + }; + me.btnChangeShape.menu.on('show:before', onShowBefore); + }, + fillAutoShapes: function() { + var me = this, + recents = Common.localStorage.getItem('de-recent-shapes'); + + for (var i = 0; i < 2; i++) { + var menuitem = new Common.UI.MenuItem({ + template: _.template('
'), + index: i + }); + me.btnChangeShape.menu.addItem(menuitem); + + var shapePicker = new Common.UI.DataViewShape({ + el: $('#id-change-shape-menu-' + i), + itemTemplate: _.template(''), + groups: me.application.getCollection('ShapeGroups'), + parentMenu: me.btnChangeShape.menu, + restoreHeight: 640, + textRecentlyUsed: me.textRecentlyUsed, + recentShapes: recents ? JSON.parse(recents) : null, + isFromImage: i === 0 + }); + shapePicker.on('item:click', function(picker, item, record, e) { + if (me.api) { + me.api.ChangeShapeType(record.get('data').shapeType); + me.fireEvent('editcomplete', me); + } + if (e.type !== 'click') + me.btnChangeShape.menu.hide(); + }); + } + /*me.btnChangeShape.menu.items[0].setVisible(me._state.isFromImage); + me.btnChangeShape.menu.items[1].setVisible(!me._state.isFromImage);*/ + }, + ChangeSettings: function(props) { if (this._initSettings) this.createDelayedElements(); @@ -372,6 +426,7 @@ define([ this._state.isOleObject=value; } + if (this._state.isOleObject) { var plugin = DE.getCollection('Common.Collections.Plugins').findWhere({guid: pluginGuid}); this.btnEditObject.setDisabled(plugin===null || plugin ===undefined || this._locked); @@ -653,6 +708,8 @@ define([ textCrop: 'Crop', textCropFill: 'Fill', textCropFit: 'Fit', - textFromStorage: 'From Storage' + textCropToShape: 'Crop to shape', + textFromStorage: 'From Storage', + textRecentlyUsed: 'Recently Used' }, DE.Views.ImageSettings || {})); }); \ No newline at end of file