-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpetitPicker.js
43 lines (33 loc) · 1.05 KB
/
petitPicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* petitPicker.js - JQuery plugin
* a minimalist color picker
* MIT Licensed
* Francesco Ricceri ([email protected])
*/
(function( $ ) {
$.fn.petitPicker = function(callBack) {
var colors = { 'black': '#000',
'red' : '#f00',
'yellow' : '#ff0',
'green' : '#0f0',
'blue' : '#00f',
'magenta' : '#f0f',
'cyan' : '#0ff' };
$(this).html('');
$(this).append("<a id='btnToggle'>Color..</a>");
var anchor = $(this).find('#btnToggle');
var fatherId = $(this).attr('id');
anchor.live('click', function() { $('#' + fatherId + ' .ptCell').toggle('fast'); });
var id;
for (var i in colors) {
id = i + fatherId;
$(this).append("<div class='ptCell ptFont ptCtr ' id='" + id + "' style='background-color: " + colors[i] + "'>" + i + "</div>");
(function(i){
$('#' + id).click(function() {
$(' .ptCell').hide();
callBack(i, colors);
});
})(i);
}
};
})(jQuery);