@@ -15,7 +15,7 @@ const ColorModule = (() => {
15
15
// Binding events to callbacks
16
16
document . getElementById ( 'jscolor-hex-input' ) . addEventListener ( 'change' , colorChanged , false ) ;
17
17
document . getElementById ( 'jscolor-hex-input' ) . addEventListener ( 'input' , colorChanged , false ) ;
18
- document . getElementById ( 'add-color-button' ) . addEventListener ( 'click' , addColorButtonEvent , false ) ;
18
+ document . getElementById ( 'add-color-button' ) . addEventListener ( 'click' , addColorButtonEvent ) ;
19
19
20
20
Events . on ( "wheel" , "colors-menu" , resizeSquares ) ;
21
21
Events . on ( "click" , document . getElementById ( "cm-add" ) , addColorButtonEvent ) ;
@@ -152,11 +152,6 @@ const ColorModule = (() => {
152
152
*
153
153
*/
154
154
function addColorButtonEvent ( ) {
155
- if ( EditorState . getCurrentMode ( ) == "Advanced" ) {
156
- Dialogue . showDialogue ( "palette-block" ) ;
157
- return ;
158
- }
159
-
160
155
//generate random color
161
156
const newColor = new Color ( "hsv" , Math . floor ( Math . random ( ) * 360 ) , Math . floor ( Math . random ( ) * 100 ) , Math . floor ( Math . random ( ) * 100 ) ) . hex ;
162
157
@@ -172,11 +167,6 @@ const ColorModule = (() => {
172
167
173
168
//add history state
174
169
new HistoryState ( ) . AddColor ( addedColor . firstElementChild . jscolor . toString ( ) ) ;
175
-
176
- //show color picker
177
- addedColor . firstElementChild . jscolor . show ( ) ;
178
- //hide edit button
179
- addedColor . lastChild . classList . add ( 'hidden' ) ;
180
170
}
181
171
182
172
/** Adds the colors that have been added through the advanced-mode color picker to the
@@ -271,7 +261,8 @@ const ColorModule = (() => {
271
261
Dialogue . showDialogue ( "palette-block" , false ) ;
272
262
} ) ;
273
263
274
- colorsMenu . children [ 0 ] . classList . add ( 'selected' ) ;
264
+ if ( ! document . querySelector ( '#colors-menu li.selected' ) )
265
+ colorsMenu . children [ 0 ] . classList . add ( 'selected' ) ;
275
266
return listItem ;
276
267
}
277
268
@@ -492,9 +483,7 @@ const ColorModule = (() => {
492
483
}
493
484
}
494
485
495
- //create palette from colors array
496
- createColorPalette ( colorPaletteArray ) ;
497
-
486
+ return colorPaletteArray ;
498
487
}
499
488
500
489
function updateCurrentColor ( color , refLayer ) {
0 commit comments