Browse Source

code cosmetic updates

pull/32/head
peterd 6 years ago
parent
commit
6ee05825b4
  1. 4
      colors.js
  2. 4
      index.js
  3. 38
      jqColorPicker.js
  4. 2
      jqColorPicker.js.map
  5. 4
      jqColorPicker.min.js
  6. 5
      package.json

4
colors.js

@ -54,7 +54,7 @@
return setColor(this.colors, newCol, type, undefined, alpha);
} else {
if (alpha !== undefined) {
this.colors.alpha = alpha;
this.colors.alpha = limitValue(alpha, 0, 1);
}
return convertColors(type);
}
@ -89,7 +89,7 @@
}
}
if (alpha !== undefined) {
colors.alpha = +alpha;
colors.alpha = limitValue(+alpha, 0, 1);
}
return convertColors(type, save ? colors : undefined);
}

4
index.js

@ -1,4 +1,4 @@
(function(window, undefined){
(function(window, $, undefined){
'use strict';
var plugin = {},
@ -495,4 +495,4 @@
);
$('.trigger').colorPicker();
$('pre').colorPicker({doRender: false});
})(window);
})(window, jQuery);

38
jqColorPicker.js

@ -49,7 +49,7 @@
ColorPicker.prototype = {
render: preRender,
toggle: toggle
}
};
function extractValue(elm) {
return elm.value || elm.getAttribute('value') ||
@ -105,7 +105,7 @@
preRender(false);
});
}
};
}
function build() {
$('head').append('<style type="text/css">' +
@ -142,14 +142,17 @@
e.returnValue = false;
_$trigger._offset = $(this).offset();
(action = action === 'xy_slider' ? xy_slider :
action === 'z_slider' ? z_slider : alpha)(e);
preRender();
$document.on(_pointerup, pointerup).on(_pointermove, action);
}
function pointerup(e) {
$document.off('.a');
$document.on(_pointerup, function(e) {
$document.off('.a');
}).on(_pointermove, function(e) {
action(e);
preRender();
});
}
function xy_slider(event) {
@ -161,23 +164,19 @@
s: x / _$xy_slider._width * 100,
v: 100 - (y / _$xy_slider._height * 100)
}, 'hsv');
preRender();
}
function z_slider(event) {
var z = resolveEventType(event).pageY - _$trigger._offset.top,
hsv = _color.colors.hsv;
var z = resolveEventType(event).pageY - _$trigger._offset.top;
_color.setColor({h: 360 - (z / _$xy_slider._height * 360)}, 'hsv');
preRender();
}
function alpha(event) {
var x = resolveEventType(event).pageX - _$trigger._offset.left,
alpha = x / _$alpha._width;
_color.setColor({}, 'rgb', alpha > 1 ? 1 : alpha < 0 ? 0 : alpha);
preRender();
_color.setColor({}, 'rgb', alpha);
}
function preRender(toggled) {
@ -295,9 +294,8 @@
on(_pointerdown, function(e) {
var $target = $(e.target);
if ($.inArray($target.closest(_selector)[0],
_instance) === -1 &&
!$target.closest(_$UI).length) {
if ($.inArray($target.closest(_selector)[0], _instance) === -1 &&
!$target.closest(_$UI).length) {
toggle();
}
}).
@ -313,9 +311,9 @@
$elm = findElement($(this));
$elm.data('colorMode', mode[1] ? mode[0].substr(0, 3) : 'HEX').
attr('readonly', _options.preventFocus);
options.doRender && $elm.
css({'background-color': value,
attr('readonly', _options.preventFocus);
options.doRender &&
$elm.css({'background-color': value,
'color': function() {
return _color.setColor(value).
rgbaMixBGMixCustom.luminance > 0.22 ? '#222' : '#ddd'
@ -329,6 +327,6 @@
_colorPicker.toggle(false);
_instance = null;
_selector = '';
}
};
})(jQuery, Colors);

2
jqColorPicker.js.map
File diff suppressed because it is too large
View File

4
jqColorPicker.min.js
File diff suppressed because it is too large
View File

5
package.json

@ -1,5 +1,5 @@
{
"name": "tiny colorPicker",
"name": "tinyColorPicker",
"version": "1.0.0",
"repository": {
"type": "git",
@ -7,6 +7,7 @@
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-uglify": "^0.5.1"
"grunt-contrib-uglify": "^0.5.1",
"grunt-smushit": "^1.3.0"
}
}
Loading…
Cancel
Save