mirror of
https://github.com/PitPik/tinyColorPicker
synced 2025-07-05 09:04:29 -06:00
AMD support
Added 2 AMD wrapper; modified clors.js and jqColorPicker.js for easy usage in AMD wrapper. Colors con now also be exported more flexible.
This commit is contained in:
parent
c0847d644d
commit
3bbd372a7b
13
colors-amd-wrapper.js
Normal file
13
colors-amd-wrapper.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(function (factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define([], function () {
|
||||||
|
return factory(window);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
window.Colors = factory(window);
|
||||||
|
}
|
||||||
|
}(
|
||||||
|
// paste colors.js without self invoking part:
|
||||||
|
// beginning: drop 'window.Colors = ('
|
||||||
|
// end: drop ')(window);'
|
||||||
|
));
|
@ -1,4 +1,4 @@
|
|||||||
;(function(window, undefined){
|
window.Colors = (function(window, undefined){
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
var _valueRanges = {
|
var _valueRanges = {
|
||||||
@ -15,7 +15,7 @@
|
|||||||
grey = {r: 0.298954, g: 0.586434, b: 0.114612}, // CIE-XYZ 1931
|
grey = {r: 0.298954, g: 0.586434, b: 0.114612}, // CIE-XYZ 1931
|
||||||
luminance = {r: 0.2126, g: 0.7152, b: 0.0722}, // W3C 2.0
|
luminance = {r: 0.2126, g: 0.7152, b: 0.0722}, // W3C 2.0
|
||||||
|
|
||||||
Colors = window.Colors = function(options) {
|
Colors = function(options) {
|
||||||
this.colors = {RND: {}};
|
this.colors = {RND: {}};
|
||||||
this.options = {
|
this.options = {
|
||||||
color: 'rgba(204, 82, 37, 0.8)', // init value(s)...
|
color: 'rgba(204, 82, 37, 0.8)', // init value(s)...
|
||||||
@ -415,4 +415,6 @@
|
|||||||
// return Math.max(min, Math.min(max, value)); // faster??
|
// return Math.max(min, Math.min(max, value)); // faster??
|
||||||
return (value > max ? max : value < min ? min : value);
|
return (value > max ? max : value < min ? min : value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Colors;
|
||||||
})(window);
|
})(window);
|
13
jqColorPicker-amd-wrapper.js
Normal file
13
jqColorPicker-amd-wrapper.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
(function (factory) {
|
||||||
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
define(['jquery', './colors'], function (jQuery, Colors) {
|
||||||
|
return factory(window, jQuery, Colors);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
factory(window, jQuery, Colors);
|
||||||
|
}
|
||||||
|
}(
|
||||||
|
// jqColorPicker without self invoking part:
|
||||||
|
// beginning: drop first '('
|
||||||
|
// end: drop ')(window, jQuery, Colors);'
|
||||||
|
));
|
@ -1,4 +1,4 @@
|
|||||||
;(function(window, $, Colors, undefined){
|
(function(window, $, Colors, undefined){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var $document = $(document),
|
var $document = $(document),
|
||||||
@ -332,4 +332,6 @@
|
|||||||
_selector = '';
|
_selector = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $;
|
||||||
|
|
||||||
})(window, jQuery, Colors);
|
})(window, jQuery, Colors);
|
File diff suppressed because one or more lines are too long
4
jqColorPicker.min.js
vendored
4
jqColorPicker.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user