From 81928ce8c7855607453648072b1c5e35fae3eb11 Mon Sep 17 00:00:00 2001 From: Dave Perrett Date: Mon, 8 Apr 2013 01:44:05 +1200 Subject: [PATCH 1/3] Set background color of example color picker. --- examples/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/index.html b/examples/index.html index 1a676f9..995f37d 100644 --- a/examples/index.html +++ b/examples/index.html @@ -58,6 +58,9 @@ font-family: Helvetica; margin: 10px 0; } + .simpleColorChooser { + background-color: #fff; + } .button { clear: right; From a6f1a72b5d257190c692b74030380b189ccd38d2 Mon Sep 17 00:00:00 2001 From: Dave Perrett Date: Mon, 8 Apr 2013 01:45:28 +1200 Subject: [PATCH 2/3] Rename callback() option to onSelect(). --- README.markdown | 9 +++++---- examples/index.html | 4 ++-- src/jquery.simple-color.js | 10 +++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index d5c2a44..2db8d7c 100644 --- a/README.markdown +++ b/README.markdown @@ -102,7 +102,7 @@ colorCodeColor: Text color of the color code inside the button. Only used if 'displayColorCode' is true. default value: '#FFF' -callback: Function to be called when a color is selected. The +onSelect: Function to be called when a color is selected. The hex code is passed into the function. default value: null @@ -170,10 +170,11 @@ Total time: 2 seconds Change history ----------- -* **Version 1.1.2 (2013-04-06)** : Add onCellEnter, onClose and livePreview options (thanks [jbergen](https://github.com/jbergen)). -* **Version 1.1.1 (2013-03-29)** : Add callback option (thanks [jbergen](https://github.com/jbergen)). +* **Version 1.1.3 (2013-04-07)** : Rename *callback* option to *onSelect*. +* **Version 1.1.2 (2013-04-06)** : Add *onCellEnter*, *onClose* and *livePreview* options (thanks [jbergen](https://github.com/jbergen)). +* **Version 1.1.1 (2013-03-29)** : Add *callback* option (thanks [jbergen](https://github.com/jbergen)). * **Version 1.1.0 (2012-10-14)** : Remove select and cancel buttons (thanks [wesnolte](https://github.com/wesnolte)). -* **Version 1.0.1 (2011-08-15)** : Trigger change() event when a color is selected (thanks [firstclown](https://github.com/firstclown)), and make colored display box clickable to select colors. +* **Version 1.0.1 (2011-08-15)** : Trigger *change()* event when a color is selected (thanks [firstclown](https://github.com/firstclown)), and make colored display box clickable to select colors. * **Version 1.0.0 (2011-05-21)** : 1.0 release. diff --git a/examples/index.html b/examples/index.html index 995f37d..26a2397 100644 --- a/examples/index.html +++ b/examples/index.html @@ -17,7 +17,7 @@ $('.simple_color_live_preview').simpleColor({ livePreview: true }); $('.simple_color_callback').simpleColor({ - callback: function( hex ) { + onSelect: function( hex ) { alert("You selected #" + hex); } }); @@ -35,7 +35,7 @@ buttonClass: 'button', displayColorCode: true, livePreview: true, - callback: function( hex ) { + onSelect: function( hex ) { alert("You selected #" + hex); }, onCellEnter: function( hex ) { diff --git a/src/jquery.simple-color.js b/src/jquery.simple-color.js index 02ab758..878c0bb 100644 --- a/src/jquery.simple-color.js +++ b/src/jquery.simple-color.js @@ -54,7 +54,7 @@ * colorCodeColor: Text color of the color code inside the button. Only used if 'displayColorCode' is true. * Default value: '#FFF' * - * callback: Callback function to call after a color has been chosen. + * onSelect: Callback function to call after a color has been chosen. * Default value: null * Returns: hex value * @@ -118,7 +118,7 @@ displayColorCode: this.attr('displayColorCode') || false, colorCodeAlign: this.attr('colorCodeAlign') || 'center', colorCodeColor: this.attr('colorCodeColor') || '#FFF', - callback: null, + onSelect: null, onCellEnter: null, onClose: null, livePreview: false @@ -262,9 +262,9 @@ if (options.displayColorCode) { event.data.display_box.text('#' + this.id); } - // If a callback function is defined then excecute it. - if (options.callback) { - options.callback(this.id); + // If an onSelect callback function is defined then excecute it. + if (options.onSelect) { + options.onSelect(this.id); } }); From 007032bb7ea183e33055bddbd4c20d99ebd7e8ff Mon Sep 17 00:00:00 2001 From: Dave Perrett Date: Mon, 8 Apr 2013 01:46:28 +1200 Subject: [PATCH 3/3] Bump version to 1.1.3. --- VERSION | 2 +- jquery.simple-color.js | 12 ++++++------ jquery.simple-color.min.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/VERSION b/VERSION index 8428158..9c1218c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.2 \ No newline at end of file +1.1.3 \ No newline at end of file diff --git a/jquery.simple-color.js b/jquery.simple-color.js index fd23a8d..78365aa 100644 --- a/jquery.simple-color.js +++ b/jquery.simple-color.js @@ -7,7 +7,7 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Version: 1.1.2 (201304062015) + * Version: 1.1.3 (201304080141) */ (function($) { /** @@ -54,7 +54,7 @@ * colorCodeColor: Text color of the color code inside the button. Only used if 'displayColorCode' is true. * Default value: '#FFF' * - * callback: Callback function to call after a color has been chosen. + * onSelect: Callback function to call after a color has been chosen. * Default value: null * Returns: hex value * @@ -118,7 +118,7 @@ displayColorCode: this.attr('displayColorCode') || false, colorCodeAlign: this.attr('colorCodeAlign') || 'center', colorCodeColor: this.attr('colorCodeColor') || '#FFF', - callback: null, + onSelect: null, onCellEnter: null, onClose: null, livePreview: false @@ -262,9 +262,9 @@ if (options.displayColorCode) { event.data.display_box.text('#' + this.id); } - // If a callback function is defined then excecute it. - if (options.callback) { - options.callback(this.id); + // If an onSelect callback function is defined then excecute it. + if (options.onSelect) { + options.onSelect(this.id); } }); diff --git a/jquery.simple-color.min.js b/jquery.simple-color.min.js index 8e01c40..a5efb32 100644 --- a/jquery.simple-color.min.js +++ b/jquery.simple-color.min.js @@ -7,16 +7,16 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Version: 1.1.2 (201304062015) + * Version: 1.1.3 (201304080141) */ (function(b){b.fn.simpleColor=function(a){var k=["990033","ff3366","cc0033","ff0033","ff9999","cc3366","ffccff","cc6699","993366","660033","cc3399","ff99cc","ff66cc","ff99ff","ff6699","cc0066","ff0066","ff3399","ff0099","ff33cc","ff00cc","ff66ff","ff33ff","ff00ff","cc0099","990066","cc66cc","cc33cc","cc99ff","cc66ff","cc33ff","993399","cc00cc","cc00ff","9900cc","990099","cc99cc","996699","663366","660099","9933cc","660066","9900ff","9933ff","9966cc","330033","663399","6633cc","6600cc","9966ff","330066", "6600ff","6633ff","ccccff","9999ff","9999cc","6666cc","6666ff","666699","333366","333399","330099","3300cc","3300ff","3333ff","3333cc","0066ff","0033ff","3366ff","3366cc","000066","000033","0000ff","000099","0033cc","0000cc","336699","0066cc","99ccff","6699ff","003366","6699cc","006699","3399cc","0099cc","66ccff","3399ff","003399","0099ff","33ccff","00ccff","99ffff","66ffff","33ffff","00ffff","00cccc","009999","669999","99cccc","ccffff","33cccc","66cccc","339999","336666","006666","003333","00ffcc", "33ffcc","33cc99","00cc99","66ffcc","99ffcc","00ff99","339966","006633","336633","669966","66cc66","99ff99","66ff66","339933","99cc99","66ff99","33ff99","33cc66","00cc66","66cc99","009966","009933","33ff66","00ff66","ccffcc","ccff99","99ff66","99ff33","00ff33","33ff33","00cc33","33cc33","66ff33","00ff00","66cc33","006600","003300","009900","33ff00","66ff00","99ff00","66cc00","00cc00","33cc00","339900","99cc66","669933","99cc33","336600","669900","99cc00","ccff66","ccff33","ccff00","999900","cccc00", "cccc33","333300","666600","999933","cccc66","666633","999966","cccc99","ffffcc","ffff99","ffff66","ffff33","ffff00","ffcc00","ffcc66","ffcc33","cc9933","996600","cc9900","ff9900","cc6600","993300","cc6633","663300","ff9966","ff6633","ff9933","ff6600","cc3300","996633","330000","663333","996666","cc9999","993333","cc6666","ffcccc","ff3333","cc3333","ff6666","660000","990000","cc0000","ff0000","ff3300","cc9966","ffcc99","ffffff","cccccc","999999","666666","333333","000000","000000","000000","000000", "000000","000000","000000","000000","000000"];a=b.extend({defaultColor:this.attr("defaultColor")||"#FFF",border:this.attr("border")||"1px solid #000",cellWidth:this.attr("cellWidth")||10,cellHeight:this.attr("cellHeight")||10,cellMargin:this.attr("cellMargin")||1,boxWidth:this.attr("boxWidth")||"115px",boxHeight:this.attr("boxHeight")||"20px",columns:this.attr("columns")||16,insert:this.attr("insert")||"after",buttonClass:this.attr("buttonClass")||"",colors:this.attr("colors")||k,displayColorCode:this.attr("displayColorCode")|| -false,colorCodeAlign:this.attr("colorCodeAlign")||"center",colorCodeColor:this.attr("colorCodeColor")||"#FFF",callback:null,onCellEnter:null,onClose:null,livePreview:false},a||{});this.hide();a.totalWidth=a.columns*(a.cellWidth+2*a.cellMargin);if(b.browser.msie)a.totalWidth+=2;a.totalHeight=Math.ceil(a.colors.length/a.columns)*(a.cellHeight+2*a.cellMargin);b.simpleColorOptions=a;this.each(function(){a=b.simpleColorOptions;var e=b("
");e.css("position","relative"); +false,colorCodeAlign:this.attr("colorCodeAlign")||"center",colorCodeColor:this.attr("colorCodeColor")||"#FFF",onSelect:null,onCellEnter:null,onClose:null,livePreview:false},a||{});this.hide();a.totalWidth=a.columns*(a.cellWidth+2*a.cellMargin);if(b.browser.msie)a.totalWidth+=2;a.totalHeight=Math.ceil(a.colors.length/a.columns)*(a.cellHeight+2*a.cellMargin);b.simpleColorOptions=a;this.each(function(){a=b.simpleColorOptions;var e=b("
");e.css("position","relative"); var j=this.value&&this.value!=""?this.value:a.defaultColor,c=b("
");c.css({backgroundColor:j,border:a.border,width:a.boxWidth,height:a.boxHeight,"line-height":a.boxHeight,cursor:"pointer"});e.append(c);if(a.displayColorCode){c.text(this.value);c.css({color:a.colorCodeColor,textAlign:a.colorCodeAlign})}c.bind("click",{container:e,input:this,display_box:c},function(f){b("html").bind("click.simpleColorDisplay",function(d){b("html").unbind("click.simpleColorDisplay"); b(".simpleColorChooser").hide();d=b(d.target);if(d.is(".simpleColorCell")===false||b.contains(b(f.target).closest(".simpleColorContainer")[0],d[0])===false){c.css("backgroundColor",j);a.displayColorCode&&c.text(j)}a.onClose&&a.onClose()});if(f.data.container.chooser)f.data.container.chooser.toggle();else{var g=b("
");g.css({border:a.border,margin:"0 0 0 5px",width:a.totalWidth,height:a.totalHeight,top:0,left:a.boxWidth,position:"absolute"});f.data.container.chooser= g;f.data.container.append(g);for(var h=0;h");i.css({width:a.cellWidth+"px",height:a.cellHeight+"px",margin:a.cellMargin+"px",cursor:"pointer",lineHeight:a.cellHeight+"px",fontSize:"1px","float":"left",backgroundColor:"#"+a.colors[h]});g.append(i);if(a.onCellEnter||a.livePreview)i.bind("mouseenter",function(){a.onCellEnter&&a.onCellEnter(this.id);if(a.livePreview){c.css("backgroundColor","#"+this.id);a.displayColorCode&& -c.text("#"+this.id)}});i.bind("click",{input:f.data.input,chooser:g,display_box:c},function(d){d.data.input.value="#"+this.id;b(d.data.input).change();d.data.display_box.css("backgroundColor","#"+this.id);d.data.chooser.hide();d.data.display_box.show();a.displayColorCode&&d.data.display_box.text("#"+this.id);a.callback&&a.callback(this.id)})}}});b(this).after(e)});b(".simpleColorDisplay").each(function(){b(this).click(function(e){e.stopPropagation()})});return this};b.fn.closeSelector=function(){this.each(function(){var a= +c.text("#"+this.id)}});i.bind("click",{input:f.data.input,chooser:g,display_box:c},function(d){d.data.input.value="#"+this.id;b(d.data.input).change();d.data.display_box.css("backgroundColor","#"+this.id);d.data.chooser.hide();d.data.display_box.show();a.displayColorCode&&d.data.display_box.text("#"+this.id);a.onSelect&&a.onSelect(this.id)})}}});b(this).after(e)});b(".simpleColorDisplay").each(function(){b(this).click(function(e){e.stopPropagation()})});return this};b.fn.closeSelector=function(){this.each(function(){var a= b(this).parent().find("div.simpleColorContainer");a.find(".simpleColorChooser").hide();a.find(".simpleColorDisplay").show()});return this}})(jQuery);