Browse Source
Merge pull request #652 from ryandeba/color-picker-config Closes #616
Add colorPicker config options
pull/663/head
Artur Arseniev
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
8 additions and
2 deletions
-
src/domain_abstract/ui/Input.js
-
src/domain_abstract/ui/InputColor.js
-
src/trait_manager/view/TraitColorView.js
|
|
|
@ -25,7 +25,7 @@ module.exports = Backbone.View.extend({ |
|
|
|
const ppfx = opts.ppfx || ''; |
|
|
|
this.opts = opts; |
|
|
|
this.ppfx = ppfx; |
|
|
|
this.target = opts.target || {}; |
|
|
|
this.em = opts.target || {}; |
|
|
|
this.listenTo(this.model, 'change:value', this.handleModelChange); |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
@ -58,7 +58,8 @@ module.exports = Input.extend({ |
|
|
|
|
|
|
|
var colorEl = $(`<div class="${this.ppfx}field-color-picker"></div>`); |
|
|
|
var cpStyle = colorEl.get(0).style; |
|
|
|
var elToAppend = this.target && this.target.config ? this.target.config.el : ''; |
|
|
|
var elToAppend = this.em && this.em.config ? this.em.config.el : ''; |
|
|
|
var colorPickerConfig = this.em && this.em.getConfig && this.em.getConfig("colorPicker") || {}; |
|
|
|
const getColor = color => { |
|
|
|
let cl = color.getAlpha() == 1 ? color.toHexString() : color.toRgbString(); |
|
|
|
return cl.replace(/ /g, ''); |
|
|
|
@ -76,6 +77,10 @@ module.exports = Input.extend({ |
|
|
|
chooseText: 'Ok', |
|
|
|
cancelText: '⨯', |
|
|
|
palette: [], |
|
|
|
|
|
|
|
// config expanded here so that the functions below are not overridden
|
|
|
|
...colorPickerConfig, |
|
|
|
|
|
|
|
move(color) { |
|
|
|
const cl = getColor(color); |
|
|
|
cpStyle.backgroundColor = cl; |
|
|
|
|
|
|
|
@ -11,6 +11,7 @@ module.exports = TraitView.extend({ |
|
|
|
if (!this.$input) { |
|
|
|
var value = this.getModelValue(); |
|
|
|
var inputNumber = new InputColor({ |
|
|
|
target: this.config.em, |
|
|
|
contClass: this.ppfx + 'field-color', |
|
|
|
model: this.model, |
|
|
|
ppfx: this.ppfx |
|
|
|
|