|
1 | | -// Spectrum Colorpicker v1.7.1 |
| 1 | +// Spectrum Colorpicker v1.8.0 |
2 | 2 | // https://github.com/bgrins/spectrum |
3 | 3 | // Author: Brian Grinstead |
4 | 4 | // License: MIT |
|
10 | 10 | define(['jquery'], factory); |
11 | 11 | } |
12 | 12 | else if (typeof exports == "object" && typeof module == "object") { // CommonJS |
13 | | - module.exports = factory; |
| 13 | + module.exports = factory(require('jquery')); |
14 | 14 | } |
15 | 15 | else { // Browser |
16 | 16 | factory(jQuery); |
|
234 | 234 | previewElement = replacer.find(".sp-preview-inner"), |
235 | 235 | initialColor = opts.color || (isInput && boundElement.val()), |
236 | 236 | colorOnShow = false, |
237 | | - preferredFormat = opts.preferredFormat, |
238 | | - currentPreferredFormat = preferredFormat, |
| 237 | + currentPreferredFormat = opts.preferredFormat, |
239 | 238 | clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange, |
240 | 239 | isEmpty = !initialColor, |
241 | 240 | allowEmpty = opts.allowEmpty && !isInputTypeColor; |
|
443 | 442 | // In case color was black - update the preview UI and set the format |
444 | 443 | // since the set function will not run (default color is black). |
445 | 444 | updateUI(); |
446 | | - currentPreferredFormat = preferredFormat || tinycolor(initialColor).format; |
| 445 | + currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format; |
447 | 446 |
|
448 | 447 | addColorToSelectionPalette(initialColor); |
449 | 448 | } |
|
705 | 704 | updateUI(); |
706 | 705 |
|
707 | 706 | if (newColor && newColor.isValid() && !ignoreFormatChange) { |
708 | | - currentPreferredFormat = preferredFormat || newColor.getFormat(); |
| 707 | + currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); |
709 | 708 | } |
710 | 709 | } |
711 | 710 |
|
|
878 | 877 | } |
879 | 878 |
|
880 | 879 | function reflow() { |
| 880 | + if (!visible) { |
| 881 | + return; // Calculations would be useless and wouldn't be reliable anyways |
| 882 | + } |
881 | 883 | dragWidth = dragger.width(); |
882 | 884 | dragHeight = dragger.height(); |
883 | 885 | dragHelperHeight = dragHelper.height(); |
|
922 | 924 | } |
923 | 925 |
|
924 | 926 | opts[optionName] = optionValue; |
| 927 | + |
| 928 | + if (optionName === "preferredFormat") { |
| 929 | + currentPreferredFormat = opts.preferredFormat; |
| 930 | + } |
925 | 931 | applyOptions(); |
926 | 932 | } |
927 | 933 |
|
|
0 commit comments