AMD / CommonJS / bower

pull/53/head 1.0.1
peterd 8 years ago
parent 046c0c5619
commit 10ee8931e0

@ -24,21 +24,14 @@ Supported color spaces are: rgb, hsv(b), hsl, HEX
</script> </script>
``` ```
## AMD wrapper ## AMD / CommonJS wrapper
tinyColorPicker now supports AMD (thanks to [Munawwar](https://github.com/Munawwar)). Both files colors.js and jqColorPicker.js return their constructors so that it is easy to wrap them inside colors-amd-wrapper.js and jqColorPicker-amd-wrapper.js. So, if you want to use require.js or other module loaders just follow the instructions inside those 2 files. (Maybe someone of you wants to write a grunt task to automate this ;o) tinyColorPicker now supports AMD and CommonJS import (thanks to [Munawwar](https://github.com/Munawwar)).
If you don't want to use AMD but would like to store the constructor `Colors` on a different name space you can change this in color.js where you find: ## bower support
```javascript tinyColorPicker can be received by bower:
window.Colors = (function...
// change this to what you want
window.myNameSpace.ColorTool = (function...
```
If you do so you also need to change this reference in jqColorPicker.js at the very end:
```javascript ```javascript
})(window, jQuery, Colors); bower install tinyColorPicker
// changes to
})(window, jQuery, myNameSpace.ColorTool);
``` ```
##jqColorPicker.js ##jqColorPicker.js

@ -3,7 +3,7 @@
"description": "Tiny jQuery color picker for mobile and desktop with alpha channel", "description": "Tiny jQuery color picker for mobile and desktop with alpha channel",
"main": "jqColorPicker.min.js", "main": "jqColorPicker.min.js",
"authors": [ "authors": [
"peterd <peter@dematte.at>" "Peter Dematté <peter@dematte.at>"
], ],
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@ -18,7 +18,9 @@
], ],
"homepage": "https://github.com/PitPik/tinyColorPicker", "homepage": "https://github.com/PitPik/tinyColorPicker",
"moduleType": [ "moduleType": [
"globals" "amd",
"globals",
"node"
], ],
"ignore": [ "ignore": [
"**/.*", "**/.*",

@ -1,4 +1,14 @@
window.Colors = (function(window, undefined){ (function (root, factory) {
if (typeof exports === 'object') {
module.exports = factory(root);
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return factory(root);
});
} else {
root.Colors = factory(root);
}
}(this, function(window, undefined) {
"use strict" "use strict"
var _valueRanges = { var _valueRanges = {
@ -417,4 +427,4 @@ window.Colors = (function(window, undefined){
} }
return Colors; return Colors;
})(window); }));

@ -1,4 +1,14 @@
(function(window, $, Colors, undefined){ (function (root, factory) {
if (typeof exports === 'object') {
module.exports = factory(root, require('jquery'), require('colors'));
} else if (typeof define === 'function' && define.amd) {
define(['jquery', 'colors'], function (jQuery, Colors) {
return factory(root, jQuery, Colors);
});
} else {
factory(root, root.jQuery, root.Colors);
}
}(this, function(window, $, Colors, undefined){
'use strict'; 'use strict';
var $document = $(document), var $document = $(document),
@ -328,4 +338,4 @@
return $; return $;
})(window, jQuery, Colors); }));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{ {
"name": "tinyColorPicker", "name": "tinyColorPicker",
"version": "1.0.0", "version": "1.0.1",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "http://github.com/PitPik/tinyColorPicker.git" "url": "http://github.com/PitPik/tinyColorPicker.git"

Loading…
Cancel
Save