From 62f1f3de1393cae0ee9196c75166e85fc51d337c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 23 Jul 2018 17:39:53 +0300 Subject: [PATCH 1/4] [DE] Set highlight settings for all content controls --- .../main/app/controller/Toolbar.js | 25 +++++++++++++++++ apps/documenteditor/main/app/view/Toolbar.js | 27 ++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index f062fd10a..77e47b742 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -315,6 +315,9 @@ define([ toolbar.listStyles.on('contextmenu', _.bind(this.onListStyleContextMenu, this)); toolbar.styleMenu.on('hide:before', _.bind(this.onListStyleBeforeHide, this)); toolbar.btnInsertEquation.on('click', _.bind(this.onInsertEquationClick, this)); + toolbar.mnuNoControlsColor.on('click', _.bind(this.onNoControlsColor, this)); + toolbar.mnuControlsColorPicker.on('select', _.bind(this.onSelectControlsColor, this)); + $('#id-toolbar-menu-new-control-color').on('click', _.bind(this.onNewControlsColor, this)); $('#id-save-style-plus, #id-save-style-link', toolbar.$el).on('click', this.onMenuSaveStyle.bind(this)); @@ -1645,6 +1648,26 @@ define([ Common.NotificationCenter.trigger('edit:complete', this.toolbar); }, + onNewControlsColor: function(picker, color) { + this.toolbar.mnuControlsColorPicker.addNewColor(); + }, + + onNoControlsColor: function(item) { + this.api.asc_SetGlobalContentControlShowHighlight(!item.isChecked()); + this.toolbar.mnuControlsColorPicker.clearSelection(); + }, + + onSelectControlsColor: function(picker, color) { + var clr = Common.Utils.ThemeColor.getRgbColor(color); + if (this.api) { + this.toolbar.mnuNoControlsColor.setChecked(true, true); + this.api.asc_SetGlobalContentControlShowHighlight(true); + this.api.asc_SetGlobalContentControlHighlightColor(clr.get_r(), clr.get_g(), clr.get_b()); + } + + Common.component.Analytics.trackEvent('ToolBar', 'Content Controls Color'); + }, + onColumnsSelect: function(menu, item) { if (_.isUndefined(item.value)) return; @@ -2516,6 +2539,8 @@ define([ this.onParagraphColor(this._state.clrshd_asccolor); } this._state.clrshd_asccolor = undefined; + + updateColors(this.toolbar.mnuControlsColorPicker, 1); }, _onInitEditorStyles: function(styles) { diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index cd80ec182..5d85a06bd 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -643,6 +643,23 @@ define([ { caption: this.mniEditControls, value: 'settings' + }, + { + caption: this.mniHighlightControls, + value: 'highlight', + menu: new Common.UI.Menu({ + menuAlign : 'tl-tr', + items: [ + this.mnuNoControlsColor = new Common.UI.MenuItem({ + id: 'id-toolbar-menu-no-highlight-controls', + caption: this.textNoHighlight, + checkable: true + }), + {caption: '--'}, + {template: _.template('
')}, + {template: _.template('' + this.textNewColor + '')} + ] + }) } ] }) @@ -1949,6 +1966,12 @@ define([ transparent: true }); } + + if (this.btnContentControls.cmpEl) { + this.mnuControlsColorPicker = new Common.UI.ThemeColorPalette({ + el: $('#id-toolbar-menu-controls-color') + }); + } }, updateMetricUnit: function () { @@ -2358,7 +2381,9 @@ define([ textPlainControl: 'Plain text', textRemoveControl: 'Remove', mniEditControls: 'Settings', - tipControls: 'Insert content control' + tipControls: 'Insert content control', + mniHighlightControls: 'Highlight settings', + textNoHighlight: 'No highlighting' } })(), DE.Views.Toolbar || {})); }); From ef7a2da5fd914992da46ab27bc5b5210091ed115 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 8 Aug 2018 16:51:02 +0300 Subject: [PATCH 2/4] [DE] Fix content controls highlighting --- .../main/lib/component/ThemeColorPalette.js | 27 +++++++++++++++++++ .../main/app/controller/Toolbar.js | 18 +++++++++++-- .../main/app/view/ControlSettingsDialog.js | 2 +- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/component/ThemeColorPalette.js b/apps/common/main/lib/component/ThemeColorPalette.js index 73c761b19..64a532739 100644 --- a/apps/common/main/lib/component/ThemeColorPalette.js +++ b/apps/common/main/lib/component/ThemeColorPalette.js @@ -320,6 +320,33 @@ define([ } }, + selectByRGB: function(rgb, suppressEvent) { + var el = $(this.el); + el.find('a.' + this.selectedCls).removeClass(this.selectedCls); + + var color = (typeof(rgb) == 'object') ? rgb.color : rgb; + if (/#?[a-fA-F0-9]{6}/.test(color)) { + color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase(); + } + + if (/^[a-fA-F0-9]{6}|transparent$/.test(color)) { + if (color != this.value || this.options.allowReselect) { + var co = (color == 'transparent') ? el.find('a.color-transparent') : el.find('a.color-' + color).first(); + if (co.length==0) + co = el.find('#'+color).first(); + if (co.length==0) + co = el.find('a[color="'+color+'"]').first(); + if (co.length>0) { + co.addClass(this.selectedCls); + this.value = color; + } + if (suppressEvent !== true) { + this.fireEvent('select', this, color); + } + } + } + }, + updateColors: function(effectcolors, standartcolors, value) { if (effectcolors===undefined || standartcolors===undefined) return; diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 77e47b742..6b357e495 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -365,6 +365,7 @@ define([ this.api.asc_registerCallback('asc_onSectionProps', _.bind(this.onSectionProps, this)); this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); this.api.asc_registerCallback('asc_onShowParaMarks', _.bind(this.onShowParaMarks, this)); + this.api.asc_registerCallback('asc_onChangeSdtGlobalSettings',_.bind(this.onChangeSdtGlobalSettings, this)); }, onChangeCompactView: function(view, compact) { @@ -887,6 +888,19 @@ define([ this._onInitEditorStyles(styles); }, + onChangeSdtGlobalSettings: function() { + var show = this.api.asc_GetGlobalContentControlShowHighlight(); + this.toolbar.mnuNoControlsColor.setChecked(!show, true); + this.toolbar.mnuControlsColorPicker.clearSelection(); + if (show){ + var clr = this.api.asc_GetGlobalContentControlHighlightColor(); + if (clr) { + clr = Common.Utils.ThemeColor.getHexColor(clr.r, clr.g, clr.b); + this.toolbar.mnuControlsColorPicker.selectByRGB(clr, true); + } + } + }, + onNewDocument: function(btn, e) { if (this.api) this.api.OpenNewDocument(); @@ -1654,13 +1668,13 @@ define([ onNoControlsColor: function(item) { this.api.asc_SetGlobalContentControlShowHighlight(!item.isChecked()); - this.toolbar.mnuControlsColorPicker.clearSelection(); + if (!item.isChecked()) + this.api.asc_SetGlobalContentControlHighlightColor(220, 220, 220); }, onSelectControlsColor: function(picker, color) { var clr = Common.Utils.ThemeColor.getRgbColor(color); if (this.api) { - this.toolbar.mnuNoControlsColor.setChecked(true, true); this.api.asc_SetGlobalContentControlShowHighlight(true); this.api.asc_SetGlobalContentControlHighlightColor(clr.get_r(), clr.get_g(), clr.get_b()); } diff --git a/apps/documenteditor/main/app/view/ControlSettingsDialog.js b/apps/documenteditor/main/app/view/ControlSettingsDialog.js index d108990d2..079b6bab5 100644 --- a/apps/documenteditor/main/app/view/ControlSettingsDialog.js +++ b/apps/documenteditor/main/app/view/ControlSettingsDialog.js @@ -228,7 +228,7 @@ define([ val = props.get_Color(); val = (val) ? Common.Utils.ThemeColor.getHexColor(val.r, val.g, val.b) : '#000000'; this.btnColor.setColor(val); - this.colors.select(val,true); + this.colors.selectByRGB(val,true); val = props.get_Lock(); (val===undefined) && (val = Asc.c_oAscSdtLockType.Unlocked); From 0fa132143c2e0c0accd95e62114f969b742b44a7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 9 Aug 2018 12:26:50 +0300 Subject: [PATCH 3/4] [DE] Update content controls color --- apps/documenteditor/main/app/controller/Toolbar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 6b357e495..e6f11ca2c 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2555,6 +2555,7 @@ define([ this._state.clrshd_asccolor = undefined; updateColors(this.toolbar.mnuControlsColorPicker, 1); + this.onChangeSdtGlobalSettings(); }, _onInitEditorStyles: function(styles) { From 63ea7d41597181c0416967ededafe1c45ff19d4f Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 9 Aug 2018 12:31:30 +0300 Subject: [PATCH 4/4] [DE] Update translations --- apps/documenteditor/main/locale/en.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 4e20642b9..97556de4d 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1937,5 +1937,8 @@ "DE.Views.Toolbar.txtScheme6": "Concourse", "DE.Views.Toolbar.txtScheme7": "Equity", "DE.Views.Toolbar.txtScheme8": "Flow", - "DE.Views.Toolbar.txtScheme9": "Foundry" + "DE.Views.Toolbar.txtScheme9": "Foundry", + "DE.Views.Toolbar.mniHighlightControls": "Highlight settings", + "DE.Views.Toolbar.textNoHighlight": "No highlighting" + } \ No newline at end of file