Skip to content

Commit 19a7ca1

Browse files
committed
Bumping to v2.1.2
1 parent 1e6d679 commit 19a7ca1

9 files changed

+108
-97
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## v2.1.2
4+
5+
#### Breaking Chnages
6+
* None
7+
8+
#### New Features
9+
* None
10+
11+
#### Bug Fixes
12+
* Delaying init until directive link function, to fix a bug in complex multi color picker pages
13+
14+
# Changelog
15+
316
## v2.1.1
417

518
#### Breaking Chnages

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-color-picker",
33
"description": "Color Picker Directive For AngularJS",
4-
"version": "2.1.1",
4+
"version": "2.1.2",
55
"homepage": "https://github.com/ruhley/angular-color-picker",
66
"repository": {
77
"type": "git",

dist/angularjs-color-picker.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angularjs-color-picker.js

Lines changed: 82 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*!
2-
* angularjs-color-picker v2.1.1
2+
* angularjs-color-picker v2.1.2
33
* https://github.com/ruhley/angular-color-picker/
44
*
55
* Copyright 2016 ruhley
66
*
7-
* 2016-07-14 08:05:35
7+
* 2016-07-15 10:26:38
88
*
99
*/
1010

@@ -40,8 +40,6 @@
4040

4141
var AngularColorPickerController = function () {
4242
function AngularColorPickerController(_$scope, _$element, _$document, _$timeout) {
43-
var _this = this;
44-
4543
classCallCheck(this, AngularColorPickerController);
4644

4745
// set angular injected variables
@@ -50,70 +48,13 @@
5048
this.$document = _$document;
5149
this.$timeout = _$timeout;
5250

53-
// browser variables
54-
this.chrome = Boolean(window.chrome);
55-
var _android_version = window.navigator.userAgent.match(/Android\s([0-9\.]*)/i);
56-
this.android_version = _android_version && _android_version.length > 1 ? parseFloat(_android_version[1]) : NaN;
57-
58-
// needed variables
59-
this.onChangeValue = null;
60-
this.updateModel = true;
61-
62-
//---------------------------
63-
// watchers
64-
//---------------------------
65-
66-
// ngModel
67-
68-
this.$scope.$watch('AngularColorPickerController.ngModel', this.watchNgModel.bind(this));
69-
70-
// options
71-
72-
this.$scope.$watch('AngularColorPickerController.options.swatchPos', this.watchSwatchPos.bind(this));
73-
74-
this.$scope.$watchGroup(['AngularColorPickerController.options.format', 'AngularColorPickerController.options.alpha', 'AngularColorPickerController.options.case'], this.reInitAndUpdate.bind(this));
75-
76-
this.$scope.$watchGroup(['AngularColorPickerController.options.disabled', 'AngularColorPickerController.options.swatchBootstrap', 'AngularColorPickerController.options.swatchOnly', 'AngularColorPickerController.options.swatch', 'AngularColorPickerController.options.pos', 'AngularColorPickerController.options.inline'], this.reInit.bind(this));
77-
78-
// api
79-
80-
this.$scope.$watch('AngularColorPickerController.api', this.watchApi.bind(this));
81-
82-
// internal
83-
84-
this.$scope.$watch('AngularColorPickerController.swatchColor', this.updateSwatchBackground.bind(this));
85-
86-
this.$scope.$watch('AngularColorPickerController.hue', this.hueUpdate.bind(this));
87-
88-
this.$scope.$watch('AngularColorPickerController.saturation', this.saturationUpdate.bind(this));
89-
90-
this.$scope.$watch('AngularColorPickerController.lightness', this.lightnessUpdate.bind(this));
91-
92-
this.$scope.$watch('AngularColorPickerController.opacity', this.opacityUpdate.bind(this));
93-
94-
//---------------------------
95-
// destroy
96-
//---------------------------
97-
98-
this.$scope.$on('$destroy', function () {
99-
_this.$document.off('mousedown', _this.onMouseDown);
100-
_this.$document.off('mouseup', _this.onMouseUp);
101-
_this.$document.off('mousemove', _this.onMouseMove);
102-
103-
_this.eventApiDispatch('onDestroy');
104-
});
105-
106-
//---------------------------
107-
// Init
108-
//---------------------------
109-
110-
this.init();
51+
this.$scope.init = this.init.bind(this);
11152
}
11253

11354
createClass(AngularColorPickerController, [{
11455
key: 'watchNgModel',
11556
value: function watchNgModel(newValue, oldValue) {
116-
var _this2 = this;
57+
var _this = this;
11758

11859
if (this.colorMouse) {
11960
return;
@@ -136,7 +77,7 @@
13677
}
13778

13879
this.$timeout(function () {
139-
_this2.updateModel = true;
80+
_this.updateModel = true;
14081
});
14182

14283
this.isValid = true;
@@ -163,57 +104,57 @@
163104
}, {
164105
key: 'watchSwatchPos',
165106
value: function watchSwatchPos(newValue) {
166-
var _this3 = this;
107+
var _this2 = this;
167108

168109
if (newValue !== undefined) {
169110
this.initConfig();
170111

171112
this.$timeout(function () {
172-
_this3.updateSwatchBackground();
113+
_this2.updateSwatchBackground();
173114
});
174115
}
175116
}
176117
}, {
177-
key: 'watchApi',
178-
value: function watchApi() {
179-
var _this4 = this;
118+
key: 'setupApi',
119+
value: function setupApi() {
120+
var _this3 = this;
180121

181122
if (!this.api) {
182123
this.api = {};
183124
}
184125

185126
this.api.open = function (event) {
186127
// if already visible then don't run show again
187-
if (_this4.visible) {
128+
if (_this3.visible) {
188129
return true;
189130
}
190131

191-
_this4.visible = true;
192-
_this4.hueMouse = false;
193-
_this4.opacityMouse = false;
194-
_this4.colorMouse = false;
132+
_this3.visible = true;
133+
_this3.hueMouse = false;
134+
_this3.opacityMouse = false;
135+
_this3.colorMouse = false;
195136

196137
// force the sliders to re-caculate their position
197-
_this4.hueUpdate();
198-
_this4.saturationUpdate();
199-
_this4.lightnessUpdate();
200-
_this4.opacityUpdate();
138+
_this3.hueUpdate();
139+
_this3.saturationUpdate();
140+
_this3.lightnessUpdate();
141+
_this3.opacityUpdate();
201142

202-
_this4.eventApiDispatch('onOpen', [event]);
143+
_this3.eventApiDispatch('onOpen', [event]);
203144
};
204145

205146
this.api.close = function (event) {
206-
if (!_this4.options.inline && (_this4.visible || _this4.$element[0].querySelector('.color-picker-panel').offsetParent !== null)) {
147+
if (!_this3.options.inline && (_this3.visible || _this3.$element[0].querySelector('.color-picker-panel').offsetParent !== null)) {
207148

208-
_this4.visible = false;
209-
_this4.$scope.$apply();
149+
_this3.visible = false;
150+
_this3.$scope.$apply();
210151

211-
_this4.eventApiDispatch('onClose', [event]);
152+
_this3.eventApiDispatch('onClose', [event]);
212153
}
213154
};
214155

215156
this.api.getElement = function () {
216-
return _this4.$element;
157+
return _this3.$element;
217158
};
218159
}
219160
}, {
@@ -234,6 +175,61 @@
234175
}, {
235176
key: 'init',
236177
value: function init() {
178+
var _this4 = this;
179+
180+
// browser variables
181+
this.chrome = Boolean(window.chrome);
182+
var _android_version = window.navigator.userAgent.match(/Android\s([0-9\.]*)/i);
183+
this.android_version = _android_version && _android_version.length > 1 ? parseFloat(_android_version[1]) : NaN;
184+
185+
// needed variables
186+
this.onChangeValue = null;
187+
this.updateModel = true;
188+
189+
//---------------------------
190+
// watchers
191+
//---------------------------
192+
193+
// ngModel
194+
195+
this.$scope.$watch('AngularColorPickerController.ngModel', this.watchNgModel.bind(this));
196+
197+
// options
198+
199+
this.$scope.$watch('AngularColorPickerController.options.swatchPos', this.watchSwatchPos.bind(this));
200+
201+
this.$scope.$watchGroup(['AngularColorPickerController.options.format', 'AngularColorPickerController.options.alpha', 'AngularColorPickerController.options.case'], this.reInitAndUpdate.bind(this));
202+
203+
this.$scope.$watchGroup(['AngularColorPickerController.options.disabled', 'AngularColorPickerController.options.swatchBootstrap', 'AngularColorPickerController.options.swatchOnly', 'AngularColorPickerController.options.swatch', 'AngularColorPickerController.options.pos', 'AngularColorPickerController.options.inline'], this.reInit.bind(this));
204+
205+
// api
206+
207+
this.$scope.$watch('AngularColorPickerController.api', this.setupApi.bind(this));
208+
209+
// internal
210+
211+
this.$scope.$watch('AngularColorPickerController.swatchColor', this.updateSwatchBackground.bind(this));
212+
213+
this.$scope.$watch('AngularColorPickerController.hue', this.hueUpdate.bind(this));
214+
215+
this.$scope.$watch('AngularColorPickerController.saturation', this.saturationUpdate.bind(this));
216+
217+
this.$scope.$watch('AngularColorPickerController.lightness', this.lightnessUpdate.bind(this));
218+
219+
this.$scope.$watch('AngularColorPickerController.opacity', this.opacityUpdate.bind(this));
220+
221+
//---------------------------
222+
// destroy
223+
//---------------------------
224+
225+
this.$scope.$on('$destroy', function () {
226+
_this4.$document.off('mousedown', _this4.onMouseDown);
227+
_this4.$document.off('mouseup', _this4.onMouseUp);
228+
_this4.$document.off('mousemove', _this4.onMouseMove);
229+
230+
_this4.eventApiDispatch('onDestroy');
231+
});
232+
237233
// if no color provided
238234
if (this.ngModel === undefined) {
239235
this.setDefaults();
@@ -286,6 +282,7 @@
286282
value: function onMouseUp(event) {
287283
// no current mouse events and not an element in the picker
288284
if (!this.colorMouse && !this.hueMouse && !this.opacityMouse && this.find(event.target).length === 0) {
285+
this.setupApi(); // TODO - there are some weird times when this is needed to call close. Need to figure out why.
289286
this.api.close(event);
290287
// mouse event on color grid
291288
} else if (this.colorMouse) {
@@ -843,6 +840,7 @@
843840
controllerAs: 'AngularColorPickerController',
844841
link: function link($scope, element, attrs, control) {
845842
$scope.control = control;
843+
$scope.init();
846844
}
847845
};
848846
}

dist/angularjs-color-picker.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angularjs-color-picker.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/themes/angularjs-color-picker-bootstrap.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*!
2-
* angularjs-color-picker v2.1.1
2+
* angularjs-color-picker v2.1.2
33
* https://github.com/ruhley/angular-color-picker/
44
*
55
* Copyright 2016 ruhley
66
*
7-
* 2016-07-14 08:05:37
7+
* 2016-07-15 10:26:41
88
*
99
*/
1010
.color-picker-wrapper .color-picker-input-wrapper {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*!
2-
* angularjs-color-picker v2.1.1
2+
* angularjs-color-picker v2.1.2
33
* https://github.com/ruhley/angular-color-picker/
44
*
55
* Copyright 2016 ruhley
66
*
7-
* 2016-07-14 08:05:37
7+
* 2016-07-15 10:26:41
88
*
99
*/.color-picker-wrapper .color-picker-input-wrapper{width:100%}.color-picker-wrapper .color-picker-swatch:not(.input-group-addon){height:28px}.color-picker-wrapper.color-picker-swatch-only .input-group .input-group-addon{border-radius:4px}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angularjs-color-picker",
33
"description": "Color Picker Directive For AngularJS",
4-
"version": "2.1.1",
4+
"version": "2.1.2",
55
"license": "MIT",
66
"main": "dist/angularjs-color-picker.min.js",
77
"dependencies": {

0 commit comments

Comments
 (0)