[SSE] Refactoring format rules

This commit is contained in:
Julia Radzhabova 2021-07-11 12:03:01 +03:00
parent 1a055fcbcc
commit b5e9e4943f

View file

@ -377,19 +377,11 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template',
}); });
this.btnStrikeout.on('click',_.bind(this.onStrikeoutClick, this)); this.btnStrikeout.on('click',_.bind(this.onStrikeoutClick, this));
var initNewColor = function(btn, picker_el, transparent) { var initNewColor = function(btn) {
if (btn && btn.cmpEl) { btn.setMenu();
btn.currentColor = '#000000'; btn.currentColor = '000000';
btn.setColor(btn.currentColor); var picker = btn.getPicker();
var picker = new Common.UI.ThemeColorPalette({ picker.currentColor = btn.currentColor;
el: $(picker_el),
transparent: transparent
});
picker.currentColor = btn.currentColor;
}
btn.menu.cmpEl.on('click', picker_el+'-new', _.bind(function() {
picker.addNewColor((typeof(btn.color) == 'object') ? btn.color.color : btn.color);
}, me));
return picker; return picker;
}; };
@ -399,17 +391,13 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template',
iconCls : 'toolbar__icon btn-fontcolor', iconCls : 'toolbar__icon btn-fontcolor',
hint : this.textColor, hint : this.textColor,
split : true, split : true,
menu : new Common.UI.Menu({ additionalAlign: this.menuAddAlign,
additionalAlign: this.menuAddAlign, color: '000000',
items: [ menu : true
{ template: _.template('<div id="format-rules-menu-fontcolor" style="width: 169px; height: 220px; margin: 10px;"></div>') },
{ template: _.template('<a id="format-rules-menu-fontcolor-new" style="padding-left:12px;">' + this.textNewColor + '</a>') }
]
})
}); });
this.mnuTextColorPicker = initNewColor(this.btnTextColor, "#format-rules-menu-fontcolor"); this.mnuTextColorPicker = initNewColor(this.btnTextColor);
this.mnuTextColorPicker.on('select', _.bind(me.onFormatTextColorSelect, me)); this.btnTextColor.on('color:select', _.bind(this.onFormatTextColorSelect, this));
this.btnTextColor.on('click', _.bind(me.onFormatTextColor, me)); this.btnTextColor.on('click', _.bind(this.onFormatTextColor, this));
this.btnFillColor = new Common.UI.ButtonColored({ this.btnFillColor = new Common.UI.ButtonColored({
parentEl: $('#format-rules-fillcolor'), parentEl: $('#format-rules-fillcolor'),
@ -417,17 +405,14 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template',
iconCls : 'toolbar__icon btn-paracolor', iconCls : 'toolbar__icon btn-paracolor',
hint : this.fillColor, hint : this.fillColor,
split : true, split : true,
menu : new Common.UI.Menu({ additionalAlign: this.menuAddAlign,
additionalAlign: this.menuAddAlign, color: '000000',
items: [ transparent: true,
{ template: _.template('<div id="format-rules-menu-fillcolor" style="width: 169px; height: 220px; margin: 10px;"></div>') }, menu : true
{ template: _.template('<a id="format-rules-menu-fillcolor-new" style="padding-left:12px;">' + this.textNewColor + '</a>') }
]
})
}); });
this.mnuFillColorPicker = initNewColor(this.btnFillColor, "#format-rules-menu-fillcolor", true); this.mnuFillColorPicker = initNewColor(this.btnFillColor);
this.mnuFillColorPicker.on('select', _.bind(me.onFormatFillColorSelect, me)); this.btnFillColor.on('color:select', _.bind(this.onFormatFillColorSelect, this));
this.btnFillColor.on('click', _.bind(me.onFormatFillColor, me)); this.btnFillColor.on('click', _.bind(this.onFormatFillColor, this));
this.btnBorders = new Common.UI.Button({ this.btnBorders = new Common.UI.Button({
parentEl : $('#format-rules-borders'), parentEl : $('#format-rules-borders'),
@ -1293,17 +1278,8 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template',
this.btnUnderline.toggle(xfs.asc_getFontUnderline() === true, true); this.btnUnderline.toggle(xfs.asc_getFontUnderline() === true, true);
this.btnStrikeout.toggle(xfs.asc_getFontStrikeout() === true, true); this.btnStrikeout.toggle(xfs.asc_getFontStrikeout() === true, true);
var color = this.setColor(xfs.asc_getFontColor(), null, this.mnuTextColorPicker); var color = this.setColor(xfs.asc_getFontColor(), this.btnTextColor, this.mnuTextColorPicker);
this.btnTextColor.currentColor = color; color = this.setColor(xfs.asc_getFillColor(), this.btnFillColor, this.mnuFillColorPicker);
this.mnuTextColorPicker.currentColor = color;
color = (typeof(color) == 'object') ? color.color : color;
$('.btn-color-value-line', this.btnTextColor.cmpEl).css('background-color', '#' + color);
color = this.setColor(xfs.asc_getFillColor(), null, this.mnuFillColorPicker);
this.btnFillColor.currentColor = color;
this.mnuFillColorPicker.currentColor = color;
color = (typeof(color) == 'object') ? color.color : color;
$('.btn-color-value-line', this.btnFillColor.cmpEl).css('background-color', color=='transparent' ? 'transparent' : '#' + color);
var val = xfs.asc_getNumFormatInfo(); var val = xfs.asc_getNumFormatInfo();
val && this.cmbNumberFormat.setValue(val.asc_getType(), this.textCustom); val && this.cmbNumberFormat.setValue(val.asc_getType(), this.textCustom);
@ -1697,11 +1673,9 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template',
} }
}, },
onFormatTextColorSelect: function(picker, color, fromBtn) { onFormatTextColorSelect: function(btn, color, fromBtn) {
var clr = (typeof(color) == 'object') ? color.color : color;
this.btnTextColor.currentColor = color; this.btnTextColor.currentColor = color;
$('.btn-color-value-line', this.btnTextColor.cmpEl).css('background-color', '#' + clr); this.mnuTextColorPicker.currentColor = color;
picker.currentColor = color;
!this.xfsFormat && (this.xfsFormat = new Asc.asc_CellXfs()); !this.xfsFormat && (this.xfsFormat = new Asc.asc_CellXfs());
this.xfsFormat.asc_setFontColor(Common.Utils.ThemeColor.getRgbColor(this.mnuTextColorPicker.currentColor)); this.xfsFormat.asc_setFontColor(Common.Utils.ThemeColor.getRgbColor(this.mnuTextColorPicker.currentColor));
@ -1712,11 +1686,9 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesEditDlg.template',
this.mnuTextColorPicker.trigger('select', this.mnuTextColorPicker, this.mnuTextColorPicker.currentColor, true); this.mnuTextColorPicker.trigger('select', this.mnuTextColorPicker, this.mnuTextColorPicker.currentColor, true);
}, },
onFormatFillColorSelect: function(picker, color, fromBtn) { onFormatFillColorSelect: function(btn, color, fromBtn) {
var clr = (typeof(color) == 'object') ? color.color : color;
this.btnFillColor.currentColor = color; this.btnFillColor.currentColor = color;
$('.btn-color-value-line', this.btnFillColor.cmpEl).css('background-color', clr=='transparent' ? 'transparent' : '#' + clr); this.mnuFillColorPicker.currentColor = color;
picker.currentColor = color;
!this.xfsFormat && (this.xfsFormat = new Asc.asc_CellXfs()); !this.xfsFormat && (this.xfsFormat = new Asc.asc_CellXfs());
this.xfsFormat.asc_setFillColor(this.mnuFillColorPicker.currentColor == 'transparent' ? null : Common.Utils.ThemeColor.getRgbColor(this.mnuFillColorPicker.currentColor)); this.xfsFormat.asc_setFillColor(this.mnuFillColorPicker.currentColor == 'transparent' ? null : Common.Utils.ThemeColor.getRgbColor(this.mnuFillColorPicker.currentColor));