|
|
|
@ -5,17 +5,21 @@ const $ = Backbone.$; |
|
|
|
|
|
|
|
module.exports = Input.extend({ |
|
|
|
|
|
|
|
template: _.template(` |
|
|
|
<div class='<%= ppfx %>input-holder'></div> |
|
|
|
<div class="<%= ppfx %>field-colorp"> |
|
|
|
<div class="<%= ppfx %>field-colorp-c"> |
|
|
|
<div class="<%= ppfx %>checker-bg"></div> |
|
|
|
</div> |
|
|
|
</div>`), |
|
|
|
template() { |
|
|
|
const ppfx = this.ppfx; |
|
|
|
return ` |
|
|
|
<div class="${ppfx}input-holder"></div> |
|
|
|
<div class="${ppfx}field-colorp"> |
|
|
|
<div class="${ppfx}field-colorp-c"> |
|
|
|
<div class="${ppfx}checker-bg"></div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
`;
|
|
|
|
}, |
|
|
|
|
|
|
|
initialize(opts) { |
|
|
|
Input.prototype.initialize.apply(this, arguments); |
|
|
|
var ppfx = this.ppfx; |
|
|
|
const ppfx = this.ppfx; |
|
|
|
this.colorCls = `${ppfx}field-color-picker`; |
|
|
|
this.inputClass = `${ppfx}field ${ppfx}field-color`; |
|
|
|
this.colorHolderClass = `${ppfx}field-colorp-c`; |
|
|
|
@ -57,14 +61,10 @@ module.exports = Input.extend({ |
|
|
|
const self = this; |
|
|
|
var model = this.model; |
|
|
|
|
|
|
|
var colorEl = $(`<div class="${this.colorCls}">`); |
|
|
|
var colorEl = $(`<div class="${this.colorCls}"></div>`); |
|
|
|
var cpStyle = colorEl.get(0).style; |
|
|
|
var elToAppend = this.target && this.target.config ? this.target.config.el : ''; |
|
|
|
|
|
|
|
if (typeof colorEl.spectrum == 'undefined') { |
|
|
|
throw 'Spectrum missing, probably you load jQuery twice'; |
|
|
|
} |
|
|
|
|
|
|
|
const getColor = color => { |
|
|
|
let cl = color.getAlpha() == 1 ? color.toHexString() : color.toRgbString(); |
|
|
|
return cl.replace(/ /g, ''); |
|
|
|
@ -113,9 +113,9 @@ module.exports = Input.extend({ |
|
|
|
return this.colorEl; |
|
|
|
}, |
|
|
|
|
|
|
|
render(...args) { |
|
|
|
Input.prototype.render.apply(this, args); |
|
|
|
this.$el.find('.' + this.colorHolderClass).html(this.getColorEl()); |
|
|
|
render() { |
|
|
|
Input.prototype.render.apply(this, arguments); |
|
|
|
this.$el.find(`.${this.colorHolderClass}`).append(this.getColorEl()); |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
|