11/*!
2- * angularjs-color-picker v3.4.5
2+ * angularjs-color-picker v3.4.6
33 * https://github.com/ruhley/angular-color-picker/
44 *
55 * Copyright 2017 ruhley
66 *
7- * 2017-09-19 08:53:31
7+ * 2017-09-22 11:38:10
88 *
99 */
1010
@@ -26,7 +26,118 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
2626
2727
2828
29+ var asyncGenerator = function ( ) {
30+ function AwaitValue ( value ) {
31+ this . value = value ;
32+ }
33+
34+ function AsyncGenerator ( gen ) {
35+ var front , back ;
36+
37+ function send ( key , arg ) {
38+ return new Promise ( function ( resolve , reject ) {
39+ var request = {
40+ key : key ,
41+ arg : arg ,
42+ resolve : resolve ,
43+ reject : reject ,
44+ next : null
45+ } ;
46+
47+ if ( back ) {
48+ back = back . next = request ;
49+ } else {
50+ front = back = request ;
51+ resume ( key , arg ) ;
52+ }
53+ } ) ;
54+ }
55+
56+ function resume ( key , arg ) {
57+ try {
58+ var result = gen [ key ] ( arg ) ;
59+ var value = result . value ;
60+
61+ if ( value instanceof AwaitValue ) {
62+ Promise . resolve ( value . value ) . then ( function ( arg ) {
63+ resume ( "next" , arg ) ;
64+ } , function ( arg ) {
65+ resume ( "throw" , arg ) ;
66+ } ) ;
67+ } else {
68+ settle ( result . done ? "return" : "normal" , result . value ) ;
69+ }
70+ } catch ( err ) {
71+ settle ( "throw" , err ) ;
72+ }
73+ }
74+
75+ function settle ( type , value ) {
76+ switch ( type ) {
77+ case "return" :
78+ front . resolve ( {
79+ value : value ,
80+ done : true
81+ } ) ;
82+ break ;
83+
84+ case "throw" :
85+ front . reject ( value ) ;
86+ break ;
87+
88+ default :
89+ front . resolve ( {
90+ value : value ,
91+ done : false
92+ } ) ;
93+ break ;
94+ }
95+
96+ front = front . next ;
97+
98+ if ( front ) {
99+ resume ( front . key , front . arg ) ;
100+ } else {
101+ back = null ;
102+ }
103+ }
104+
105+ this . _invoke = send ;
106+
107+ if ( typeof gen . return !== "function" ) {
108+ this . return = undefined ;
109+ }
110+ }
111+
112+ if ( typeof Symbol === "function" && Symbol . asyncIterator ) {
113+ AsyncGenerator . prototype [ Symbol . asyncIterator ] = function ( ) {
114+ return this ;
115+ } ;
116+ }
117+
118+ AsyncGenerator . prototype . next = function ( arg ) {
119+ return this . _invoke ( "next" , arg ) ;
120+ } ;
121+
122+ AsyncGenerator . prototype . throw = function ( arg ) {
123+ return this . _invoke ( "throw" , arg ) ;
124+ } ;
125+
126+ AsyncGenerator . prototype . return = function ( arg ) {
127+ return this . _invoke ( "return" , arg ) ;
128+ } ;
29129
130+ return {
131+ wrap : function ( fn ) {
132+ return function ( ) {
133+ return new AsyncGenerator ( fn . apply ( this , arguments ) ) ;
134+ } ;
135+ } ,
136+ await : function ( value ) {
137+ return new AwaitValue ( value ) ;
138+ }
139+ } ;
140+ } ( ) ;
30141
31142
32143
@@ -94,8 +205,6 @@ var AngularColorPickerController = function () {
94205 this . ngModelOptions = this . $scope . control [ 0 ] . $options . $$options ;
95206 }
96207
97- this . internalNgModel = this . ngModelOptions . getterSetter ? this . ngModel ( ) : this . ngModel ;
98-
99208 // browser variables
100209 this . chrome = Boolean ( window . chrome ) ;
101210 var _android_version = window . navigator . userAgent . match ( / A n d r o i d \s ( [ 0 - 9 \. ] * ) / i) ;
@@ -163,7 +272,7 @@ var AngularColorPickerController = function () {
163272
164273 // ngModel
165274
166- this . $scope . $watch ( 'AngularColorPickerController.internalNgModel' , this . watchNgModel . bind ( this ) ) ;
275+ this . $scope . $watch ( 'AngularColorPickerController.internalNgModel' , this . watchInternalNgModel . bind ( this ) ) ;
167276 this . $scope . $watch ( 'AngularColorPickerController.ngModel' , this . watchNgModel . bind ( this ) ) ;
168277
169278 // options
@@ -215,6 +324,17 @@ var AngularColorPickerController = function () {
215324 _this . valueUpdate ( 'opacity' ) ;
216325 } ) ;
217326 }
327+ } , {
328+ key : 'watchInternalNgModel' ,
329+ value : function watchInternalNgModel ( newValue , oldValue ) {
330+ // the mouse is still moving so don't do anything yet
331+ if ( this . colorMouse ) {
332+ return ;
333+ }
334+
335+ // calculate and set color values
336+ this . watchNgModelSet ( newValue ) ;
337+ }
218338
219339 /** Triggered on change to internal or external ngModel value */
220340
@@ -229,6 +349,9 @@ var AngularColorPickerController = function () {
229349 // sets the field to pristine or dirty for angular
230350 this . checkDirty ( newValue ) ;
231351
352+ // update the internal model from external model
353+ this . internalNgModel = this . ngModelOptions . getterSetter ? this . ngModel ( ) : this . ngModel ;
354+
232355 // the mouse is still moving so don't do anything yet
233356 if ( this . colorMouse ) {
234357 return ;
@@ -974,7 +1097,6 @@ var AngularColorPickerController = function () {
9741097 var isValid = color . isValid ( ) ;
9751098
9761099 if ( isValid && this . options . restrictToFormat ) {
977- var format = this . options . format ;
9781100 isValid = color . getFormat ( ) === this . getTinyColorFormat ( ) ;
9791101 }
9801102
0 commit comments