1- import * as jsColorPicker from 'colorPicker/colorPicker .js' ;
1+ import ColorPicker from '../colorpicker .js' ;
22import Word from '../components/word.js' ;
33
44module . exports = ( function ( ) {
@@ -169,46 +169,10 @@ module.exports = (function() {
169169 // bind events to data
170170 attachHandlers ( ) {
171171 // initialize colorpicker
172- let self = this ;
173- jsColorPicker ( 'input.colorpicker' , {
174- customBG : '#000' ,
175- init : function ( elm , colors ) {
176- elm . style . backgroundColor = elm . value || '#000' ;
177- elm . style . color = colors . rgbaMixCustom . luminance > 0.22 ? '#222' : '#ddd' ;
178- } ,
179- renderCallback : function ( colors , mode ) {
180- /* ---- code taken from jsColor.js ---- */
181- var options = this ,
182- input = options . input ,
183- patch = options . patch ,
184- RGB = colors . RND . rgb ,
185- HSL = colors . RND . hsl ,
186- AHEX = options . isIE8 ? ( colors . alpha < 0.16 ? '0' : '' ) +
187- ( Math . round ( colors . alpha * 100 ) ) . toString ( 16 ) . toUpperCase ( ) + colors . HEX : '' ,
188- RGBInnerText = RGB . r + ', ' + RGB . g + ', ' + RGB . b ,
189- RGBAText = 'rgba(' + RGBInnerText + ', ' + colors . alpha + ')' ,
190- isAlpha = colors . alpha !== 1 && ! options . isIE8 ,
191- colorMode = input . getAttribute ( 'data-colorMode' ) ;
192-
193- patch . style . cssText =
194- 'color:' + ( colors . rgbaMixCustom . luminance > 0.22 ? '#222' : '#ddd' ) + ';' + // Black...???
195- 'background-color:' + RGBAText + ';' +
196- 'filter:' + ( options . isIE8 ? 'progid:DXImageTransform.Microsoft.gradient(' + // IE<9
197- 'startColorstr=#' + AHEX + ',' + 'endColorstr=#' + AHEX + ')' : '' ) ;
198-
199- input . value = ( colorMode === 'HEX' && ! isAlpha ? '#' + ( options . isIE8 ? AHEX : colors . HEX ) :
200- colorMode === 'rgb' || ( colorMode === 'HEX' && isAlpha ) ?
201- ( ! isAlpha ? 'rgb(' + RGBInnerText + ')' : RGBAText ) :
202- ( 'hsl' + ( isAlpha ? 'a(' : '(' ) + HSL . h + ', ' + HSL . s + '%, ' + HSL . l + '%' +
203- ( isAlpha ? ', ' + colors . alpha : '' ) + ')' )
204- ) ;
205-
206- if ( options . displayCallback ) {
207- options . displayCallback ( colors , mode , options ) ;
208- }
209-
210- /* -- manually invoke callback -- */
211- self . setColor ( this . input . node ) ;
172+ this . colorpicker = new ColorPicker ( 'colorpicker' , {
173+ initialColor : '#000000' ,
174+ changeCallback : ( input ) => {
175+ this . setColor ( input . node ) ;
212176 }
213177 } ) ;
214178
@@ -253,10 +217,7 @@ module.exports = (function() {
253217
254218 // manually set color
255219 if ( color ) {
256- const c = new Colors ( { color : color } ) ;
257- const labelColor = c . colors . RGBLuminance > 0.22 ? '#222' : '#ddd' ;
258- picker . value = color ;
259- picker . style . cssText = `color:${ labelColor } ; background-color:${ color } ;` ;
220+ this . colorpicker . setColor ( picker , color ) ;
260221 }
261222
262223 if ( tagTypes [ node . val ] ) {
@@ -286,7 +247,7 @@ module.exports = (function() {
286247 }
287248
288249 remove ( object ) {
289- // TODO: fix the fuck out of this
250+ // FIXME
290251 return ;
291252 let tag = object . val ;
292253 let entity = object . entity ;
@@ -302,7 +263,7 @@ module.exports = (function() {
302263 }
303264
304265 getColor ( label , object ) {
305- //FIXME: fix me the fuck up
266+ //FIXME
306267 return ;
307268 let keys = Object . keys ( tagTypes ) ;
308269 if ( tagTypes [ label ] ) {
0 commit comments