From 1f9548bc3b8c581a9f823967c66de119b59b3019 Mon Sep 17 00:00:00 2001 From: "DESKTOP-TFD2FE1\\JiyeonPark" Date: Mon, 16 Sep 2019 16:52:26 +0900 Subject: [PATCH 1/3] fixed allowEmpty error Fixed allowEmpty error. --- spectrum.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/spectrum.js b/spectrum.js index e129e184..38863bf2 100644 --- a/spectrum.js +++ b/spectrum.js @@ -137,18 +137,14 @@ if(current) { var tiny = tinycolor(current); var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light"; - c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : ""; + c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : ""; var formattedString = tiny.toString(opts.preferredFormat || "rgb"); var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter(); html.push(''); } else { - var cls = 'sp-clear-display'; - html.push($('
') - .append($('') - .attr('title', opts.noColorSelectedText) - ) - .html() - ); + var c = 'sp-thumb-el sp-clear-display' + var cls = 'sp-clear-palette-only' + html.push(''); } } return "
" + html.join('') + "
"; @@ -237,7 +233,7 @@ currentPreferredFormat = opts.preferredFormat, clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, isEmpty = !initialColor, - allowEmpty = opts.allowEmpty && !isInputTypeColor; + allowEmpty = opts.allowEmpty; function applyOptions() { @@ -257,6 +253,12 @@ paletteLookup[rgb] = true; } } + + // if showPaletteOnly and didn't set initialcolor + // set initialcolor to first palette + if (opts.showPaletteOnly && !opts.color) { + initialColor = (palette[0][0] == "") ? palette[0][0] : Object.keys(paletteLookup)[0] + } } container.toggleClass("sp-flat", flat); @@ -445,8 +447,10 @@ currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; addColorToSelectionPalette(initialColor); - } - else { + } else if (initialColor == "") { + set(initialColor); + updateUI(); + } else { updateUI(); } @@ -460,6 +464,7 @@ move(); } else { + console.log("--------------", $(e.target).closest(".sp-thumb-el").data("color")) set($(e.target).closest(".sp-thumb-el").data("color")); move(); @@ -697,7 +702,7 @@ } var newColor, newHsv; - if (!color && allowEmpty) { + if ((!color || color === undefined) && allowEmpty) { isEmpty = true; } else { isEmpty = false; From ff29828e4fcb6a0c1a4c2310e00d66e1bebde264 Mon Sep 17 00:00:00 2001 From: "DESKTOP-TFD2FE1\\JiyeonPark" Date: Tue, 17 Sep 2019 14:29:10 +0900 Subject: [PATCH 2/3] fixed Travis CI Error. W004: 'c' is already defined. W033: Missing semicolon. W041: Use '===' to compare with ''. --- spectrum.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/spectrum.js b/spectrum.js index 38863bf2..9cafe9c4 100644 --- a/spectrum.js +++ b/spectrum.js @@ -142,9 +142,7 @@ var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter(); html.push(''); } else { - var c = 'sp-thumb-el sp-clear-display' - var cls = 'sp-clear-palette-only' - html.push(''); + html.push(''); } } return "
" + html.join('') + "
"; @@ -257,7 +255,7 @@ // if showPaletteOnly and didn't set initialcolor // set initialcolor to first palette if (opts.showPaletteOnly && !opts.color) { - initialColor = (palette[0][0] == "") ? palette[0][0] : Object.keys(paletteLookup)[0] + initialColor = (palette[0][0] == '') ? palette[0][0] : Object.keys(paletteLookup)[0]; } } @@ -447,7 +445,7 @@ currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; addColorToSelectionPalette(initialColor); - } else if (initialColor == "") { + } else if (initialColor == '') { set(initialColor); updateUI(); } else { From 95dc02ae6c7e6a26b3b97cdbfd9819fcda952ea1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-TFD2FE1\\JiyeonPark" Date: Tue, 17 Sep 2019 16:17:17 +0900 Subject: [PATCH 3/3] fixed Travis CI Error. W041: Use '===' to compare with ''. W033: Missing semicolon. --- spectrum.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spectrum.js b/spectrum.js index 9cafe9c4..090b0ab3 100644 --- a/spectrum.js +++ b/spectrum.js @@ -255,7 +255,7 @@ // if showPaletteOnly and didn't set initialcolor // set initialcolor to first palette if (opts.showPaletteOnly && !opts.color) { - initialColor = (palette[0][0] == '') ? palette[0][0] : Object.keys(paletteLookup)[0]; + initialColor = (palette[0][0] === '') ? palette[0][0] : Object.keys(paletteLookup)[0]; } } @@ -445,7 +445,7 @@ currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; addColorToSelectionPalette(initialColor); - } else if (initialColor == '') { + } else if (initialColor === '') { set(initialColor); updateUI(); } else { @@ -462,7 +462,6 @@ move(); } else { - console.log("--------------", $(e.target).closest(".sp-thumb-el").data("color")) set($(e.target).closest(".sp-thumb-el").data("color")); move();