From 08ccff10aba9df0296aaaf1f4d39badc93121bc4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 3 Dec 2021 11:07:31 +0300 Subject: [PATCH] Refactoring ComboDataView --- .../main/app/view/ChartSettings.js | 14 ++++----- .../main/app/view/ImageSettings.js | 14 ++++----- .../main/app/view/ShapeSettings.js | 30 ++++++++++--------- apps/documenteditor/main/app/view/Toolbar.js | 29 ++++++++---------- .../main/app/view/Transitions.js | 20 ++++++------- 5 files changed, 53 insertions(+), 54 deletions(-) diff --git a/apps/documenteditor/main/app/view/ChartSettings.js b/apps/documenteditor/main/app/view/ChartSettings.js index 1470e4092..d95285e1c 100644 --- a/apps/documenteditor/main/app/view/ChartSettings.js +++ b/apps/documenteditor/main/app/view/ChartSettings.js @@ -236,14 +236,14 @@ define([ dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'big', - delayRenderTips: true + delayRenderTips: true, + itemTemplate: _.template([ + '
', + '' + ].join('')) }); - this.cmbWrapType.menuPicker.itemTemplate = this.cmbWrapType.fieldPicker.itemTemplate = _.template([ - '
', - '' - ].join('')); this.cmbWrapType.render($('#chart-combo-wrap')); this.cmbWrapType.openButton.menu.cmpEl.css({ 'min-width': 178, diff --git a/apps/documenteditor/main/app/view/ImageSettings.js b/apps/documenteditor/main/app/view/ImageSettings.js index 3e763c838..5379ffd4d 100644 --- a/apps/documenteditor/main/app/view/ImageSettings.js +++ b/apps/documenteditor/main/app/view/ImageSettings.js @@ -140,14 +140,14 @@ define([ dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: '-10, 0', - delayRenderTips: true + delayRenderTips: true, + itemTemplate: _.template([ + '
', + '' + ].join('')) }); - this.cmbWrapType.menuPicker.itemTemplate = this.cmbWrapType.fieldPicker.itemTemplate = _.template([ - '
', - '' - ].join('')); this.cmbWrapType.render($('#image-combo-wrap')); this.cmbWrapType.openButton.menu.cmpEl.css({ 'min-width': 178, diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js index 8b7cc35d2..fb9213b78 100644 --- a/apps/documenteditor/main/app/view/ShapeSettings.js +++ b/apps/documenteditor/main/app/view/ShapeSettings.js @@ -1265,23 +1265,25 @@ define([ this.cmbFillSrc.on('selected', _.bind(this.onFillSrcSelect, this)); this.fillControls.push(this.cmbFillSrc); + var itemWidth = 28, + itemHeight = 28; this.cmbPattern = new Common.UI.ComboDataView({ - itemWidth: 28, - itemHeight: 28, + itemWidth: itemWidth, + itemHeight: itemHeight, menuMaxHeight: 300, enableKeyEvents: true, cls: 'combo-pattern', dataHint: '1', dataHintDirection: 'bottom', - dataHintOffset: 'big' - }); - this.cmbPattern.menuPicker.itemTemplate = this.cmbPattern.fieldPicker.itemTemplate = _.template([ + dataHintOffset: 'big', + itemTemplate: _.template([ '
', '', '
' - ].join('')); + ].join('')) + }); this.cmbPattern.render($('#shape-combo-pattern')); this.cmbPattern.openButton.menu.cmpEl.css({ 'min-width': 178, @@ -1637,14 +1639,14 @@ define([ dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: 'big', - delayRenderTips: true + delayRenderTips: true, + itemTemplate: _.template([ + '
', + '' + ].join('')) }); - this.cmbWrapType.menuPicker.itemTemplate = this.cmbWrapType.fieldPicker.itemTemplate = _.template([ - '
', - '' - ].join('')); this.cmbWrapType.render($('#shape-combo-wrap')); this.cmbWrapType.openButton.menu.cmpEl.css({ 'min-width': 178, diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index 5c91c58cd..b791faebc 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -1303,16 +1303,23 @@ define([ caption: me.textStyleMenuNew }); + var itemWidth = 104, + itemHeight = 40; this.listStyles = new Common.UI.ComboDataView({ cls: 'combo-styles', - itemWidth: 104, - itemHeight: 40, + itemWidth: itemWidth, + itemHeight: itemHeight, // hint : this.tipParagraphStyle, dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: '-16, -4', enableKeyEvents: true, additionalMenuItems: [this.listStylesAdditionalMenuItem], + itemTemplate: _.template([ + '
', + '
', + '
' + ].join('')), beforeOpenHandler: function (e) { var cmp = this, menu = cmp.openButton.menu, @@ -1322,22 +1329,22 @@ define([ var itemEl = $(cmp.cmpEl.find('.dataview.inner .style').get(0)).parent(); var itemMargin = /*parseInt($(itemEl.get(0)).parent().css('margin-right'))*/-1; Common.Utils.applicationPixelRatio() > 1 && Common.Utils.applicationPixelRatio() < 2 && (itemMargin = -1 / Common.Utils.applicationPixelRatio()); - var itemWidth = itemEl.is(':visible') ? parseFloat(itemEl.css('width')) : + var _width = itemEl.is(':visible') ? parseFloat(itemEl.css('width')) : (cmp.itemWidth + parseFloat(itemEl.css('padding-left')) + parseFloat(itemEl.css('padding-right')) + parseFloat(itemEl.css('border-left-width')) + parseFloat(itemEl.css('border-right-width'))); var minCount = cmp.menuPicker.store.length >= minMenuColumn ? minMenuColumn : cmp.menuPicker.store.length, - columnCount = Math.min(cmp.menuPicker.store.length, Math.round($('.dataview', $(cmp.fieldPicker.el)).width() / (itemMargin + itemWidth) + 0.5)); + columnCount = Math.min(cmp.menuPicker.store.length, Math.round($('.dataview', $(cmp.fieldPicker.el)).width() / (itemMargin + _width) + 0.5)); columnCount = columnCount < minCount ? minCount : columnCount; menu.menuAlignEl = cmp.cmpEl; menu.menuAlign = 'tl-tl'; - var offset = cmp.cmpEl.width() - cmp.openButton.$el.width() - columnCount * (itemMargin + itemWidth) - 1; + var offset = cmp.cmpEl.width() - cmp.openButton.$el.width() - columnCount * (itemMargin + _width) - 1; menu.setOffset(Math.min(offset, 0)); menu.cmpEl.css({ - 'width': columnCount * (itemWidth + itemMargin), + 'width': columnCount * (_width + itemMargin), 'min-height': cmp.cmpEl.height() }); } @@ -1353,16 +1360,6 @@ define([ } }); - this.listStyles.fieldPicker.itemTemplate = _.template([ - '
', - '
', - '
' - ].join('')); - this.listStyles.menuPicker.itemTemplate = _.template([ - '
', - '
', - '
' - ].join('')); this.paragraphControls.push(this.listStyles); this.textOnlyControls.push(this.listStyles); diff --git a/apps/presentationeditor/main/app/view/Transitions.js b/apps/presentationeditor/main/app/view/Transitions.js index 07a57cc83..a2278dc40 100644 --- a/apps/presentationeditor/main/app/view/Transitions.js +++ b/apps/presentationeditor/main/app/view/Transitions.js @@ -133,10 +133,18 @@ define([ {title: this.textZoom, imageUrl: "transition-zoom", value: Asc.c_oAscSlideTransitionTypes.Zoom, id: Common.UI.getId()} ]; + var itemWidth = 87, + itemHeight = 40; this.listEffects = new Common.UI.ComboDataView({ cls: 'combo-styles', - itemWidth: 87, - itemHeight: 40, + itemWidth: itemWidth, + itemHeight: itemHeight, + itemTemplate: _.template([ + '
', + '
', + '
<%= title %>
', + '
' + ].join('')), enableKeyEvents: true, lock: [_set.slideDeleted, _set.noSlides, _set.disableOnStart, _set.transitLock], dataHint: '1', @@ -169,14 +177,6 @@ define([ this.lockedControls.push(this.listEffects); this.listEffects.menuPicker.store.add(this._arrEffectName); - this.listEffects.fieldPicker.itemTemplate = _.template([ - '
', - '
', - '
<%= title %>
', - '
' - ].join('')); - this.listEffects.menuPicker.itemTemplate = this.listEffects.fieldPicker.itemTemplate; - this.btnPreview = new Common.UI.Button({ cls: 'btn-toolbar', // x-huge icon-top', caption: this.txtPreview,