2
0
mirror of https://github.com/PitPik/colorPicker.git synced 2025-09-22 07:32:38 -06:00

enables empty input in implementations

This commit is contained in:
peterd 2015-11-14 13:38:58 +01:00
parent b494b622f7
commit 887e481a38
6 changed files with 24 additions and 16 deletions

2
color.all.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -32,6 +32,9 @@
options.displayCallback(colors, mode, options);
}
},
extractValue = function(elm) {
return elm.value || elm.getAttribute('value') || elm.style.backgroundColor || '#FFFFFF';
},
actionCallback = function(event, action) {
var options = this,
colorPicker = colorPickers.current;
@ -75,7 +78,7 @@
customBG: '#FFFFFF',
// displayCallback: displayCallback,
/* --- regular colorPicker options from this point --- */
color: elm.value,
color: extractValue(elm),
initStyle: 'display: none',
mode: $.docCookies('colorPickerMode') || 'hsv-h',
// memoryColors: (function(colors, config) {
@ -108,7 +111,7 @@
{cancel: '.' + options.CSSPrefix + 'app div'}
) : $(colorPicker.nodes.colorPicker);
options.color = elm.value; // brings color to default on reset
options.color = extractValue(elm); // brings color to default on reset
$colorPicker.css({
'position': 'absolute',
'left': position.left + options.margin.left,
@ -117,7 +120,7 @@
if (!multiple) {
options.input = elm;
options.patch = elm; // check again???
colorPicker.setColor(elm.value, undefined, undefined, true);
colorPicker.setColor(extractValue(elm), undefined, undefined, true);
colorPicker.saveAsBackground();
}
colorPickers.current = colorPickers[index];
@ -163,13 +166,14 @@
$(elm).off('.colorPicker');
$(window).off('.colorPicker');
if (config !== 'destroy') {
var value = elm.value.split('(');
var color = extractValue(elm),
value = color.split('(');
$(elm).data('colorMode', value[1] ? value[0].substr(0, 3) : 'HEX');
doEventListeners(elm, (config && config.multipleInstances), false);
if (config && config.readOnly) {
elm.readOnly = true;
}
testColors.setColor(elm.value);
testColors.setColor(color);
if (config && config.init) {
config.init(elm, testColors.colors);
}

View File

@ -30,6 +30,9 @@
options.displayCallback(colors, mode, options);
}
},
extractValue = function(elm) {
return elm.value || elm.getAttribute('value') || elm.style.backgroundColor || '#FFFFFF';
},
actionCallback = function(event, action) {
var options = this,
colorPicker = colorPickers.current;
@ -72,7 +75,7 @@
customBG: '#FFFFFF',
// displayCallback: displayCallback,
/* --- regular colorPicker options from this point --- */
color: elm.value,
color: extractValue(elm),
initStyle: 'display: none',
mode: ColorPicker.docCookies('colorPickerMode') || 'hsv-h',
// memoryColors: (function(colors, config) {
@ -102,7 +105,7 @@
options = colorPicker.color.options,
colorPickerUI = colorPicker.nodes.colorPicker;
options.color = elm.value; // brings color to default on reset
options.color = extractValue(elm); // brings color to default on reset
colorPickerUI.style.cssText =
'position: absolute;' +
'left:' + (position.left + options.margin.left) + 'px;' +
@ -111,7 +114,7 @@
if (!multiple) {
options.input = elm;
options.patch = elm; // check again???
colorPicker.setColor(elm.value, undefined, undefined, true);
colorPicker.setColor(extractValue(elm), undefined, undefined, true);
colorPicker.saveAsBackground();
}
colorPickers.current = colorPickers[index];
@ -171,9 +174,10 @@
colorPickers[n].destroyAll();
}
} else {
var value = elm.value.split('(');
var color = extractValue(elm);
var value = color.split('(');
testColors.setColor(elm.value);
testColors.setColor(color);
if (config && config.init) {
config.init(elm, testColors.colors);
}

File diff suppressed because one or more lines are too long