From 72d4d76172a79f2f4dcccce17ea049cde7593684 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Sat, 11 Dec 2021 19:16:03 +0300 Subject: [PATCH] Refactoring ComboDataView --- .../main/app/view/ShapeSettings.js | 16 ++++++++------ .../main/app/view/SlideSettings.js | 22 ++++++++++--------- .../main/app/view/TextArtSettings.js | 16 ++++++++------ .../main/app/view/Toolbar.js | 16 +++++--------- .../main/app/view/CellSettings.js | 22 ++++++++++--------- .../main/app/view/ShapeSettings.js | 16 ++++++++------ .../main/app/view/TextArtSettings.js | 16 ++++++++------ 7 files changed, 65 insertions(+), 59 deletions(-) diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index c9183dd01..5035236f8 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -1171,23 +1171,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, diff --git a/apps/presentationeditor/main/app/view/SlideSettings.js b/apps/presentationeditor/main/app/view/SlideSettings.js index f7a7e23da..2b4005fdc 100644 --- a/apps/presentationeditor/main/app/view/SlideSettings.js +++ b/apps/presentationeditor/main/app/view/SlideSettings.js @@ -702,23 +702,25 @@ define([ createDelayedControls: function() { var me = this; + 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' + dataHintOffset: 'big', + itemTemplate: _.template([ + '
', + '', + '
' + ].join('')) }); - this.cmbPattern.menuPicker.itemTemplate = this.cmbPattern.fieldPicker.itemTemplate = _.template([ - '
', - '', - '
' - ].join('')); this.cmbPattern.render($('#slide-combo-pattern')); this.cmbPattern.openButton.menu.cmpEl.css({ 'min-width': 178, diff --git a/apps/presentationeditor/main/app/view/TextArtSettings.js b/apps/presentationeditor/main/app/view/TextArtSettings.js index 611f8cbd8..3819358a7 100644 --- a/apps/presentationeditor/main/app/view/TextArtSettings.js +++ b/apps/presentationeditor/main/app/view/TextArtSettings.js @@ -1102,23 +1102,25 @@ define([ this.cmbFillSrc.on('selected', _.bind(this.onFillSrcSelect, this)); this.lockedControls.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($('#textart-combo-pattern')); this.cmbPattern.openButton.menu.cmpEl.css({ 'min-width': 178, diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index 7ddb05a46..9ab8a6952 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1017,6 +1017,11 @@ define([ dataHint: '1', dataHintDirection: 'bottom', dataHintOffset: '-16, -4', + itemTemplate: _.template([ + '
', + '
' + 'background-image: url(<%= imageUrl %>);' + '<% } %> background-position: 0 -<%= offsety %>px;">
', + '
' + ].join('')), beforeOpenHandler: function (e) { var cmp = this, menu = cmp.openButton.menu, @@ -1055,17 +1060,6 @@ define([ } }); - me.listTheme.fieldPicker.itemTemplate = _.template([ - '
', - '
' + 'background-image: url(<%= imageUrl %>);' + '<% } %> background-position: 0 -<%= offsety %>px;">
', - '
' - ].join('')); - me.listTheme.menuPicker.itemTemplate = _.template([ - '
', - '
' + 'background-image: url(<%= imageUrl %>);' + '<% } %> background-position: 0 -<%= offsety %>px;">
', - '
' - ].join('')); - this.cmbInsertShape = new Common.UI.ComboDataViewShape({ cls: 'combo-styles shapes', itemWidth: 20, diff --git a/apps/spreadsheeteditor/main/app/view/CellSettings.js b/apps/spreadsheeteditor/main/app/view/CellSettings.js index f9a587fcb..12106c690 100644 --- a/apps/spreadsheeteditor/main/app/view/CellSettings.js +++ b/apps/spreadsheeteditor/main/app/view/CellSettings.js @@ -320,23 +320,25 @@ define([ }); this.fillControls.push(this.sldrGradient); + 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' + dataHintOffset: 'big', + itemTemplate: _.template([ + '
', + '', + '
' + ].join('')) }); - this.cmbPattern.menuPicker.itemTemplate = this.cmbPattern.fieldPicker.itemTemplate = _.template([ - '
', - '', - '
' - ].join('')); this.cmbPattern.render($('#cell-combo-pattern')); this.cmbPattern.openButton.menu.cmpEl.css({ 'min-width': 178, diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index b67072029..4b6658650 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -1188,23 +1188,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, diff --git a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js index 87d413834..651d4fcbc 100644 --- a/apps/spreadsheeteditor/main/app/view/TextArtSettings.js +++ b/apps/spreadsheeteditor/main/app/view/TextArtSettings.js @@ -1106,23 +1106,25 @@ define([ this.cmbFillSrc.on('selected', _.bind(this.onFillSrcSelect, this)); this.lockedControls.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($('#textart-combo-pattern')); this.cmbPattern.openButton.menu.cmpEl.css({ 'min-width': 178,