()
| 791 | } |
| 792 | |
| 793 | function updateUI() { |
| 794 | textInput.removeClass('sp-validation-error'); |
| 795 | |
| 796 | updateHelperLocations(); |
| 797 | |
| 798 | // Update dragger background color (gradients take care of saturation and value). |
| 799 | var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 }); |
| 800 | dragger.css('background-color', flatColor.toHexString()); |
| 801 | |
| 802 | // Get a format that alpha will be included in (hex and names ignore alpha) |
| 803 | var format = currentPreferredFormat; |
| 804 | if (currentAlpha < 1 && !(currentAlpha === 0 && format === 'name')) { |
| 805 | if (format === 'hex' || format === 'hex3' || format === 'hex6' || format === 'name') { |
| 806 | format = 'rgb'; |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | var realColor = get({ format: format }), |
| 811 | displayColor = ''; |
| 812 | |
| 813 | //reset background info for preview element |
| 814 | previewElement.removeClass('sp-clear-display'); |
| 815 | previewElement.css('background-color', 'transparent'); |
| 816 | |
| 817 | if (!realColor && allowEmpty) { |
| 818 | // Update the replaced elements background with icon indicating no color selection |
| 819 | previewElement.addClass('sp-clear-display'); |
| 820 | } else { |
| 821 | var realHex = realColor.toHexString(), |
| 822 | realRgb = realColor.toRgbString(); |
| 823 | |
| 824 | // Update the replaced elements background color (with actual selected color) |
| 825 | if (rgbaSupport || realColor.alpha === 1) { |
| 826 | previewElement.css('background-color', realRgb); |
| 827 | } else { |
| 828 | previewElement.css('background-color', 'transparent'); |
| 829 | previewElement.css('filter', realColor.toFilter()); |
| 830 | } |
| 831 | |
| 832 | if (opts.showAlpha) { |
| 833 | var rgb = realColor.toRgb(); |
| 834 | rgb.a = 0; |
| 835 | var realAlpha = tinycolor(rgb).toRgbString(); |
| 836 | var gradient = 'linear-gradient(left, ' + realAlpha + ', ' + realHex + ')'; |
| 837 | |
| 838 | if (IE) { |
| 839 | alphaSliderInner.css('filter', tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex)); |
| 840 | } else { |
| 841 | alphaSliderInner.css('background', '-webkit-' + gradient); |
| 842 | alphaSliderInner.css('background', '-moz-' + gradient); |
| 843 | alphaSliderInner.css('background', '-ms-' + gradient); |
| 844 | // Use current syntax gradient on unprefixed property. |
| 845 | alphaSliderInner.css('background', 'linear-gradient(to right, ' + realAlpha + ', ' + realHex + ')'); |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | displayColor = realColor.toString(format); |
| 850 | } |
no test coverage detected