diff --git a/addon/mixins/col-pick.js b/addon/mixins/col-pick.js index 6a0e81e..4fc072e 100644 --- a/addon/mixins/col-pick.js +++ b/addon/mixins/col-pick.js @@ -1,3 +1,5 @@ +/* eslint-disable ember/closure-actions */ + import $ from 'jquery'; import { isPresent } from '@ember/utils'; import Mixin from '@ember/object/mixin'; @@ -49,6 +51,7 @@ export default Mixin.create( { }), _setupColpick: function() { + var instance = this; var layout = this.get('colpickLayout'); var colorScheme = this.get('colorScheme'); @@ -58,19 +61,18 @@ export default Mixin.create( { colorScheme: colorScheme, submit: 0, flat: this.get('flat'), - onChange: bind(this, function(hsb, hex) { + onChange: bind(this, function(hsb, hex, rgb, el, bySetColor) { if (this.get('useHashtag')) { hex = '#' + hex; } this.set('previewValue', hex); - if (this._isValidPreviewValue()) { - this.set('value', hex); + if (this._isValidPreviewValue() && !bySetColor) { + this._setColpickValue(hex); } }), onHide: bind(this, function(){ - // eslint-disable-next-line ember/closure-actions this.sendAction('onHide'); }) }); @@ -79,6 +81,7 @@ export default Mixin.create( { var hexInputVal = this.value; if (hexInputVal.length === 6) { colpick.colpickSetColor(hexInputVal); + instance._setColpickValue(hexInputVal); } }); @@ -106,6 +109,11 @@ export default Mixin.create( { this._setupColpick(); }, + _setColpickValue: function(value) { + this.set('value', value); + this.sendAction('onChange', value); + }, + _tearDownColpick: function() { if (this._colpick) { if (!this.isDestroying) { diff --git a/package-lock.json b/package-lock.json index fb8914b..c3bc14e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ember-colpick", - "version": "0.6.2", + "version": "1.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 356a423..571b405 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dependencies": { "ember-cli-babel": "^6.6.0", "ember-cli-version-checker": "^2.1.0", - "jquery-colpick": "^3.1.0" + "jquery-colpick": "https://github.com/jdurand/colpick" }, "devDependencies": { "broccoli-asset-rev": "^2.4.5",