[Pkg-javascript-commits] [jquery-minicolors] 27/46: Fallback to default value when hex isn't valid
David Prévot
taffit at moszumanska.debian.org
Sun Oct 25 17:18:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository jquery-minicolors.
commit 971e7b14b9e55766d179fe405d0f3dd81da7d81a
Author: Cory LaViska <cory at abeautifulsite.net>
Date: Thu Sep 17 16:45:30 2015 -0400
Fallback to default value when hex isn't valid
---
jquery.minicolors.js | 8 ++++++--
jquery.minicolors.min.js | 2 +-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/jquery.minicolors.js b/jquery.minicolors.js
index c06f882..3f2afe2 100644
--- a/jquery.minicolors.js
+++ b/jquery.minicolors.js
@@ -942,6 +942,7 @@
var input = $(this),
keywords = input.attr('data-keywords'),
settings = input.data('minicolors-settings'),
+ hex,
rgba,
swatchOpacity;
@@ -961,11 +962,14 @@
if( isRgb(input.val()) ) {
rgba = parseRgb(input.val(), true);
} else {
- rgba = hex2rgb(parseHex(input.val(), true));
+ hex = parseHex(input.val(), true);
+ rgba = hex ? hex2rgb(hex) : null;
}
// Convert to format
- if( settings.format === 'rgb' ) {
+ if( rgba === null ) {
+ value = settings.defaultValue;
+ } else if( settings.format === 'rgb' ) {
value = settings.opacity ?
parseRgb('rgba(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ',' + input.attr('data-opacity') + ')') :
parseRgb('rgb(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ')');
diff --git a/jquery.minicolors.min.js b/jquery.minicolors.min.js
index 5f961f8..c70a4ec 100644
--- a/jquery.minicolors.min.js
+++ b/jquery.minicolors.min.js
@@ -8,4 +8,4 @@
* @license: http://opensource.org/licenses/MIT
*
*/
-!function(i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function($){function i(i,t){var a=$('<div class="minicolors" />'),o=$.minicolors.defaults,s=i.attr("data-format"),n=i.attr("data-keywords"),e=i.attr("data-opacity");i.data("minicolors-initialized")||(t=$.extend(!0,{},o,t),a.addClass("minicolors-theme-"+t.theme).toggleClass("minicolors-with-opacity",t.opacity).toggleClass("minicolors-no-data-uris" [...]
\ No newline at end of file
+!function(i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function($){function i(i,t){var a=$('<div class="minicolors" />'),o=$.minicolors.defaults,s=i.attr("data-format"),n=i.attr("data-keywords"),e=i.attr("data-opacity");i.data("minicolors-initialized")||(t=$.extend(!0,{},o,t),a.addClass("minicolors-theme-"+t.theme).toggleClass("minicolors-with-opacity",t.opacity).toggleClass("minicolors-no-data-uris" [...]
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/jquery-minicolors.git
More information about the Pkg-javascript-commits
mailing list