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);