Created
April 9, 2011 11:33
-
-
Save audreyt/911329 to your computer and use it in GitHub Desktop.
Patch to allow ColorPicker work on mobile browsers by handling the "click" event. Repository is here: https://github.com/audreyt/jquery-colorpicker---fixed-for-ie6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -dur foo/js/colorpicker.js tmp/js/colorpicker.js | |
--- foo/js/colorpicker.js 2009-05-23 13:32:36.000000000 +0800 | |
+++ tmp/js/colorpicker.js 2011-04-07 21:05:18.000000000 +0800 | |
@@ -370,6 +370,7 @@ | |
setSelector(col, cal.get(0)); | |
setHue(col, cal.get(0)); | |
setNewColor(col, cal.get(0)); | |
+ cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]); | |
}; | |
return { | |
init: function (opt) { | |
@@ -405,10 +406,28 @@ | |
.find('span').bind('mousedown', downIncrement).end() | |
.find('>div.colorpicker_current_color').bind('click', restoreOriginal); | |
options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector); | |
+ cal.find('div.colorpicker_color').bind('click', function(ev) { | |
+ moveSelector($.extend({ | |
+ data: { | |
+ cal: $(this).parent(), | |
+ pos: $(this).offset() | |
+ } | |
+ }, ev)); | |
+ }); | |
options.selectorIndic = options.selector.find('div div'); | |
options.el = this; | |
options.hue = cal.find('div.colorpicker_hue div'); | |
cal.find('div.colorpicker_hue').bind('mousedown', downHue); | |
+ cal.find('div.colorpicker_hue').bind('click', function(ev) { | |
+ var current = { | |
+ cal: $(this).parent(), | |
+ y: $(this).offset().top | |
+ }; | |
+ current.preview = current.cal.data('colorpicker').livePreview; | |
+ moveHue($.extend({ | |
+ data: current | |
+ }, ev)); | |
+ }); | |
options.newColor = cal.find('div.colorpicker_new_color'); | |
options.currentColor = cal.find('div.colorpicker_current_color'); | |
cal.data('colorpicker', options); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment