(color, ignoreFormatChange)
| 733 | } |
| 734 | |
| 735 | function set(color, ignoreFormatChange) { |
| 736 | if (tinycolor.equals(color, get())) { |
| 737 | // Update UI just in case a validation error needs |
| 738 | // to be cleared. |
| 739 | updateUI(); |
| 740 | return; |
| 741 | } |
| 742 | |
| 743 | var newColor, newHsv; |
| 744 | if (!color && allowEmpty) { |
| 745 | isEmpty = true; |
| 746 | } else { |
| 747 | isEmpty = false; |
| 748 | isDefault = !color; // if no color is available an empty string will be passed. tinycolor will then set it to #000 |
| 749 | newColor = tinycolor(color); |
| 750 | newHsv = newColor.toHsv(); |
| 751 | |
| 752 | currentHue = (newHsv.h % 360) / 360; |
| 753 | currentSaturation = newHsv.s; |
| 754 | currentValue = newHsv.v; |
| 755 | currentAlpha = newHsv.a; |
| 756 | } |
| 757 | updateUI(); |
| 758 | |
| 759 | if (newColor && newColor.isValid() && !ignoreFormatChange) { |
| 760 | currentPreferredFormat = opts.preferredFormat || newColor.getFormat(); |
| 761 | } |
| 762 | } |
| 763 | |
| 764 | function get(opts) { |
| 765 | opts = opts || {}; |
no test coverage detected