diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 080d7adab..429455e52 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -212,8 +212,10 @@ define([ if (this.toolbar.btnInsertShape.pressed) this.toolbar.btnInsertShape.toggle(false, true); - if (this.toolbar.btnInsertText.pressed) + if (this.toolbar.btnInsertText.pressed) { this.toolbar.btnInsertText.toggle(false, true); + this.toolbar.btnInsertText.menu.clearAll(); + } $(document.body).off('mouseup', checkInsertAutoshape); }; @@ -334,11 +336,8 @@ define([ toolbar.mnuInsertTable.on('item:click', _.bind(this.onInsertTableClick, this)); toolbar.mnuInsertTable.on('show:after', _.bind(this.onInsertTableShow, this)); toolbar.mnuInsertImage.on('item:click', _.bind(this.onInsertImageClick, this)); - toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this, 'textRect')); - toolbar.btnInsertText.menu.on('item:click', _.bind(function(btn, e) { - this.toolbar.btnInsertText.toggle(true); - this.onBtnInsertTextClick(e.value, btn, e); - }, this)); + toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this)); + toolbar.btnInsertText.menu.on('item:click', _.bind(this.onMenuInsertTextClick, this)); toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this)); toolbar.btnDropCap.menu.on('item:click', _.bind(this.onDropCapSelect, this)); toolbar.btnContentControls.menu.on('item:click', _.bind(this.onControlsSelect, this)); @@ -1652,10 +1651,36 @@ define([ Common.NotificationCenter.trigger('storage:image-insert', data); }, - onBtnInsertTextClick: function(type, btn, e) { - if (this.api){ - this._addAutoshape(this.toolbar.btnInsertText.pressed, type); + onBtnInsertTextClick: function(btn, e) { + btn.menu.items.forEach(function(item) { + if(item.value == btn.options.textboxType) + item.setChecked(true); + }); + if(!this.toolbar.btnInsertText.pressed) { + this.toolbar.btnInsertText.menu.clearAll(); + } + this.onInsertText(btn.options.textboxType, btn, e); + }, + + onMenuInsertTextClick: function(btn, e) { + var oldType = this.toolbar.btnInsertText.options.textboxType; + var newType = e.value; + this.toolbar.btnInsertText.toggle(true); + + if(newType != oldType){ + this.toolbar.btnInsertText.changeIcon({ + next: e.options.iconClsForMainBtn, + curr: this.toolbar.btnInsertText.menu.items.filter(function(item){return item.value == oldType})[0].options.iconClsForMainBtn + }); + this.toolbar.btnInsertText.updateHint([e.caption, this.views.Toolbar.prototype.tipInsertText]); + this.toolbar.btnInsertText.options.textboxType = newType; } + this.onInsertText(newType, btn, e); + }, + + onInsertText: function(type, btn, e) { + if (this.api) + this._addAutoshape(this.toolbar.btnInsertText.pressed, type); if (this.toolbar.btnInsertShape.pressed) this.toolbar.btnInsertShape.toggle(false, true); @@ -1664,8 +1689,6 @@ define([ Common.component.Analytics.trackEvent('ToolBar', 'Add Text'); }, - - onInsertShapeHide: function(btn, e) { if (this.toolbar.btnInsertShape.pressed && !this._isAddingShape) { this.toolbar.btnInsertShape.toggle(false, true); diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index a8f08ac2c..0d3fdbcf8 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -677,7 +677,7 @@ define([ this.btnInsertText = new Common.UI.Button({ id: 'tlbtn-inserttext', cls: 'btn-toolbar x-huge icon-top', - iconCls: 'toolbar__icon btn-text', + iconCls: 'toolbar__icon btn-review-prev', lock: [_set.paragraphLock, _set.headerLock, _set.inEquation, _set.controlPlain, _set.contentLock, _set.inFootnote, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart], caption: me.capBtnInsTextbox, @@ -685,7 +685,8 @@ define([ split: true, dataHint: '1', dataHintDirection: 'bottom', - dataHintOffset: 'small' + dataHintOffset: 'small', + textboxType: 'textRect' }); this.paragraphControls.push(this.btnInsertText); @@ -2224,8 +2225,24 @@ define([ this.btnInsertText.setMenu(new Common.UI.Menu({ items: [ - {caption: this.tipInsertHorizontalText, value: 'textRect'}, - {caption: this.tipInsertVerticalText, value: 'textRectVertical'}, + { + caption: this.tipInsertHorizontalText, + checkable: true, + checkmark: false, + iconCls : 'menu__icon text-orient-hor', + toggleGroup: 'textbox', + value: 'textRect', + iconClsForMainBtn: 'btn-review-prev' + }, + { + caption: this.tipInsertVerticalText, + checkable: true, + checkmark: false, + iconCls : 'menu__icon text-orient-rup', + toggleGroup: 'textbox', + value: 'textRectVertical', + iconClsForMainBtn: 'btn-review-next' + }, ] })); diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index ca8cadd8b..56673b5c7 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -127,7 +127,8 @@ define([ this.addListeners({ 'Toolbar': { 'insert:image' : this.onInsertImageClick.bind(this), - 'insert:text' : this.onInsertText.bind(this), + 'insert:text-btn' : this.onBtnInsertTextClick.bind(this), + 'insert:text-menu' : this.onMenuInsertTextClick.bind(this), 'insert:textart' : this.onInsertTextart.bind(this), 'insert:shape' : this.onInsertShape.bind(this), 'add:slide' : this.onAddSlide.bind(this), @@ -226,8 +227,12 @@ define([ if ( this.toolbar.btnsInsertShape.pressed() ) this.toolbar.btnsInsertShape.toggle(false, true); - if ( this.toolbar.btnsInsertText.pressed() ) + if ( this.toolbar.btnsInsertText.pressed() ) { this.toolbar.btnsInsertText.toggle(false, true); + this.toolbar.btnsInsertText.forEach(function(button) { + button.menu.clearAll(); + }); + } if ( this.toolbar.cmbInsertShape.isComboViewRecActive() ) this.toolbar.cmbInsertShape.deactivateRecords(); @@ -1784,14 +1789,39 @@ define([ Common.NotificationCenter.trigger('storage:image-insert', data); }, - onInsertText: function(status, type) { - if ( status == 'begin' ) { - this._addAutoshape(true, type); + onBtnInsertTextClick: function(btn, e) { + btn.menu.items.forEach(function(item) { + if(item.value == btn.options.textboxType) + item.setChecked(true); + }); + if(!btn.pressed) { + btn.menu.clearAll(); + } + this.onInsertText(btn.options.textboxType, btn, e); + }, - if ( !this.toolbar.btnsInsertText.pressed() ) - this.toolbar.btnsInsertText.toggle(true, true); - } else - this._addAutoshape(false, type); + onMenuInsertTextClick: function(btn, e) { + var self = this; + var oldType = btn.options.textboxType; + var newType = e.value; + + btn.toggle(true); + if(newType != oldType){ + this.toolbar.btnsInsertText.forEach(function(button) { + button.updateHint([e.caption, self.views.Toolbar.prototype.tipInsertText]); + button.changeIcon({ + next: e.options.iconClsForMainBtn, + curr: button.menu.items.filter(function(item){return item.value == oldType})[0].options.iconClsForMainBtn + }); + button.options.textboxType = newType; + }); + } + this.onInsertText(newType, btn, e); + }, + + onInsertText: function(type, btn, e) { + if (this.api) + this._addAutoshape(btn.pressed, type); if ( this.toolbar.btnsInsertShape.pressed() ) this.toolbar.btnsInsertShape.toggle(false, true); diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 1bf0a9d73..57e98f7e3 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1282,7 +1282,7 @@ define([ this.btnsInsertImage = Common.Utils.injectButtons($host.find('.slot-insertimg'), 'tlbtn-insertimage-', 'toolbar__icon btn-insertimage', this.capInsertImage, [Common.enumLock.slideDeleted, Common.enumLock.lostConnect, Common.enumLock.noSlides, Common.enumLock.disableOnStart], false, true, undefined, '1', 'bottom', 'small'); - this.btnsInsertText = Common.Utils.injectButtons($host.find('.slot-instext'), 'tlbtn-inserttext-', 'toolbar__icon btn-text', this.capInsertText, + this.btnsInsertText = Common.Utils.injectButtons($host.find('.slot-instext'), 'tlbtn-inserttext-', 'toolbar__icon btn-datetime', this.capInsertText, [Common.enumLock.slideDeleted, Common.enumLock.lostConnect, Common.enumLock.noSlides, Common.enumLock.disableOnStart], true, false, true, '1', 'bottom', 'small'); this.btnsInsertShape = Common.Utils.injectButtons($host.find('.slot-insertshape'), 'tlbtn-insertshape-', 'toolbar__icon btn-insertshape', this.capInsertShape, [Common.enumLock.slideDeleted, Common.enumLock.lostConnect, Common.enumLock.noSlides, Common.enumLock.disableOnStart], false, true, true, '1', 'bottom', 'small'); @@ -1320,18 +1320,35 @@ define([ me.btnsInsertText.forEach(function (button) { button.updateHint([me.tipInsertHorizontalText, me.tipInsertText]); + button.options.textboxType = 'textRect'; button.setMenu(new Common.UI.Menu({ items: [ - {caption: me.tipInsertHorizontalText, value: 'textRect'}, - {caption: me.tipInsertVerticalText, value: 'textRectVertical'}, + { + caption: me.tipInsertHorizontalText, + checkable: true, + checkmark: false, + iconCls : 'menu__icon text-orient-hor', + toggleGroup: 'textbox', + value: 'textRect', + iconClsForMainBtn: 'btn-datetime' + }, + { + caption: me.tipInsertVerticalText, + checkable: true, + checkmark: false, + iconCls : 'menu__icon text-orient-rup', + toggleGroup: 'textbox', + value: 'textRectVertical', + iconClsForMainBtn: 'btn-pagenum' + }, ] })); button.on('click', function (btn, e) { - me.fireEvent('insert:text', [btn.pressed ? 'begin' : 'end', 'textRect']); + me.fireEvent('insert:text-btn', [btn, e]); }); button.menu.on('item:click', function(btn, e) { button.toggle(true); - me.fireEvent('insert:text', ['begin', e.value]); + me.fireEvent('insert:text-menu', [button, e]); }); });