Change color on click, add history to color picker [MAILPOET-1087]

This commit is contained in:
stoletniy
2017-09-07 13:17:57 +03:00
parent e42db162aa
commit 513181ff47

View File

@@ -13,14 +13,29 @@ define([
BL.ColorPickerBehavior = Marionette.Behavior.extend({ BL.ColorPickerBehavior = Marionette.Behavior.extend({
onRender: function() { onRender: function() {
this.view.$('.mailpoet_color').spectrum({ var that = this,
preferredFormat = 'hex6';
this.view.$('.mailpoet_color').each(function () {
var $input = that.view.$(this);
var updateColorInput = function(color) {
$input.val(color.toString(preferredFormat));
$input.trigger('change');
};
$input.spectrum({
clickoutFiresChange: true, clickoutFiresChange: true,
showInput: true, showInput: true,
showInitial: true, showInitial: true,
preferredFormat: 'hex6', showPalette: true,
showSelectionPalette: true,
palette: [],
localStorageKey: 'newsletter_editor.spectrum.palette',
preferredFormat: preferredFormat,
allowEmpty: true, allowEmpty: true,
chooseText: MailPoet.I18n.t('selectColor'), chooseText: MailPoet.I18n.t('selectColor'),
cancelText: MailPoet.I18n.t('cancelColorSelection') cancelText: MailPoet.I18n.t('cancelColorSelection'),
move: updateColorInput,
hide: updateColorInput
});
}); });
} }
}); });