Index: trunk/phase3/resources/jquery/jquery.farbtastic.css |
— | — | @@ -17,35 +17,38 @@ |
18 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | 19 | */ |
20 | 20 | .farbtastic { |
21 | | - position: relative; |
| 21 | + position: relative; |
22 | 22 | } |
23 | 23 | .farbtastic * { |
24 | | - position: absolute; |
25 | | - cursor: crosshair; |
| 24 | + position: absolute; |
| 25 | + cursor: crosshair; |
26 | 26 | } |
27 | 27 | .farbtastic, .farbtastic .wheel { |
28 | | - width: 195px; |
29 | | - height: 195px; |
| 28 | + width: 195px; |
| 29 | + height: 195px; |
30 | 30 | } |
31 | 31 | .farbtastic .color, .farbtastic .overlay { |
32 | | - top: 47px; |
33 | | - left: 47px; |
34 | | - width: 101px; |
35 | | - height: 101px; |
| 32 | + top: 47px; |
| 33 | + left: 47px; |
| 34 | + width: 101px; |
| 35 | + height: 101px; |
36 | 36 | } |
37 | 37 | .farbtastic .wheel { |
38 | | - background: url(images/wheel.png) no-repeat; |
39 | | - width: 195px; |
40 | | - height: 195px; |
| 38 | + /* @embed */ |
| 39 | + background: url(images/wheel.png) no-repeat; |
| 40 | + width: 195px; |
| 41 | + height: 195px; |
41 | 42 | } |
42 | 43 | .farbtastic .overlay { |
43 | | - background: url(images/mask.png) no-repeat; |
| 44 | + /* @embed */ |
| 45 | + background: url(images/mask.png) no-repeat; |
44 | 46 | } |
45 | 47 | .farbtastic .marker { |
46 | | - width: 17px; |
47 | | - height: 17px; |
48 | | - margin: -8px 0 0 -8px; |
49 | | - overflow: hidden; |
50 | | - background: url(images/marker.png) no-repeat; |
| 48 | + width: 17px; |
| 49 | + height: 17px; |
| 50 | + margin: -8px 0 0 -8px; |
| 51 | + overflow: hidden; |
| 52 | + /* @embed */ |
| 53 | + background: url(images/marker.png) no-repeat; |
51 | 54 | } |
52 | 55 | |
Index: trunk/phase3/resources/jquery/jquery.farbtastic.js |
— | — | @@ -23,264 +23,264 @@ |
24 | 24 | // - uniform code style |
25 | 25 | |
26 | 26 | jQuery.fn.farbtastic = function (callback) { |
27 | | - $.farbtastic(this, callback); |
28 | | - return this; |
| 27 | + $.farbtastic(this, callback); |
| 28 | + return this; |
29 | 29 | }; |
30 | 30 | |
31 | 31 | jQuery.farbtastic = function (container, callback) { |
32 | | - var container = $(container).get(0); |
33 | | - return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); |
| 32 | + var container = $(container).get(0); |
| 33 | + return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); |
34 | 34 | } |
35 | 35 | |
36 | 36 | jQuery._farbtastic = function (container, callback) { |
37 | | - // Store farbtastic object |
38 | | - var fb = this; |
| 37 | + // Store farbtastic object |
| 38 | + var fb = this; |
39 | 39 | |
40 | | - // Insert markup |
41 | | - $(container).html('<div class="farbtastic ui-widget-content"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>'); |
42 | | - $(container).addClass('ui-widget'); |
43 | | - var e = $('.farbtastic', container); |
44 | | - fb.wheel = $('.wheel', container).get(0); |
45 | | - // Dimensions |
46 | | - fb.radius = 84; |
47 | | - fb.square = 100; |
48 | | - fb.width = 194; |
| 40 | + // Insert markup |
| 41 | + $(container).html('<div class="farbtastic ui-widget-content"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>'); |
| 42 | + $(container).addClass('ui-widget'); |
| 43 | + var e = $('.farbtastic', container); |
| 44 | + fb.wheel = $('.wheel', container).get(0); |
| 45 | + // Dimensions |
| 46 | + fb.radius = 84; |
| 47 | + fb.square = 100; |
| 48 | + fb.width = 194; |
49 | 49 | |
50 | | - // Fix background PNGs in IE6 |
51 | | - if (navigator.appVersion.match(/MSIE [0-6]\./)) { |
52 | | - $('*', e).each(function () { |
53 | | - if (this.currentStyle.backgroundImage != 'none') { |
54 | | - var image = this.currentStyle.backgroundImage; |
55 | | - image = this.currentStyle.backgroundImage.substring(5, image.length - 2); |
56 | | - $(this).css({ |
57 | | - 'backgroundImage': 'none', |
58 | | - 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" |
59 | | - }); |
60 | | - } |
61 | | - }); |
62 | | - } |
| 50 | + // Fix background PNGs in IE6 |
| 51 | + if (navigator.appVersion.match(/MSIE [0-6]\./)) { |
| 52 | + $('*', e).each(function () { |
| 53 | + if (this.currentStyle.backgroundImage != 'none') { |
| 54 | + var image = this.currentStyle.backgroundImage; |
| 55 | + image = this.currentStyle.backgroundImage.substring(5, image.length - 2); |
| 56 | + $(this).css({ |
| 57 | + 'backgroundImage': 'none', |
| 58 | + 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')" |
| 59 | + }); |
| 60 | + } |
| 61 | + }); |
| 62 | + } |
63 | 63 | |
64 | | - /** |
65 | | - * Link to the given element(s) or callback. |
66 | | - */ |
67 | | - fb.linkTo = function (callback) { |
68 | | - // Unbind previous nodes |
69 | | - if (typeof fb.callback == 'object') { |
70 | | - $(fb.callback).unbind('keyup', fb.updateValue); |
71 | | - } |
| 64 | + /** |
| 65 | + * Link to the given element(s) or callback. |
| 66 | + */ |
| 67 | + fb.linkTo = function (callback) { |
| 68 | + // Unbind previous nodes |
| 69 | + if (typeof fb.callback == 'object') { |
| 70 | + $(fb.callback).unbind('keyup', fb.updateValue); |
| 71 | + } |
72 | 72 | |
73 | | - // Reset color |
74 | | - fb.color = null; |
| 73 | + // Reset color |
| 74 | + fb.color = null; |
75 | 75 | |
76 | | - // Bind callback or elements |
77 | | - if (typeof callback == 'function') { |
78 | | - fb.callback = callback; |
79 | | - } |
80 | | - else if (typeof callback == 'object' || typeof callback == 'string') { |
81 | | - fb.callback = $(callback); |
82 | | - fb.callback.bind('keyup', fb.updateValue); |
83 | | - if (fb.callback.get(0).value) { |
84 | | - fb.setColor(fb.callback.get(0).value); |
85 | | - } |
86 | | - } |
87 | | - return this; |
88 | | - } |
89 | | - fb.updateValue = function (event) { |
90 | | - if (this.value != fb.color) { |
91 | | - fb.setColor(this.value); |
92 | | - } |
93 | | - } |
| 76 | + // Bind callback or elements |
| 77 | + if (typeof callback == 'function') { |
| 78 | + fb.callback = callback; |
| 79 | + } |
| 80 | + else if (typeof callback == 'object' || typeof callback == 'string') { |
| 81 | + fb.callback = $(callback); |
| 82 | + fb.callback.bind('keyup', fb.updateValue); |
| 83 | + if (fb.callback.get(0).value) { |
| 84 | + fb.setColor(fb.callback.get(0).value); |
| 85 | + } |
| 86 | + } |
| 87 | + return this; |
| 88 | + } |
| 89 | + fb.updateValue = function (event) { |
| 90 | + if (this.value != fb.color) { |
| 91 | + fb.setColor(this.value); |
| 92 | + } |
| 93 | + } |
94 | 94 | |
95 | | - /** |
96 | | - * Change color with HTML syntax #123456 |
97 | | - */ |
98 | | - fb.setColor = function (color) { |
99 | | - var rgb = $.colorUtil.getRGB( color ); |
100 | | - if (fb.color != color && rgb) { |
101 | | - rgb = rgb.slice( 0 ); //make a clone |
102 | | - //TODO: rewrite code so that this is not needed |
103 | | - rgb[0] /= 255; |
104 | | - rgb[1] /= 255; |
105 | | - rgb[2] /= 255; |
106 | | - fb.color = color; |
107 | | - fb.rgb = rgb; |
108 | | - fb.hsl = fb.RGBToHSL(fb.rgb); |
109 | | - fb.updateDisplay(); |
110 | | - } |
111 | | - return this; |
112 | | - } |
| 95 | + /** |
| 96 | + * Change color with HTML syntax #123456 |
| 97 | + */ |
| 98 | + fb.setColor = function (color) { |
| 99 | + var rgb = $.colorUtil.getRGB( color ); |
| 100 | + if (fb.color != color && rgb) { |
| 101 | + rgb = rgb.slice( 0 ); //make a clone |
| 102 | + //TODO: rewrite code so that this is not needed |
| 103 | + rgb[0] /= 255; |
| 104 | + rgb[1] /= 255; |
| 105 | + rgb[2] /= 255; |
| 106 | + fb.color = color; |
| 107 | + fb.rgb = rgb; |
| 108 | + fb.hsl = fb.RGBToHSL(fb.rgb); |
| 109 | + fb.updateDisplay(); |
| 110 | + } |
| 111 | + return this; |
| 112 | + } |
113 | 113 | |
114 | | - /** |
115 | | - * Change color with HSL triplet [0..1, 0..1, 0..1] |
116 | | - */ |
117 | | - fb.setHSL = function (hsl) { |
118 | | - fb.hsl = hsl; |
119 | | - fb.rgb = fb.HSLToRGB(hsl); |
120 | | - fb.color = fb.pack(fb.rgb); |
121 | | - fb.updateDisplay(); |
122 | | - return this; |
123 | | - } |
| 114 | + /** |
| 115 | + * Change color with HSL triplet [0..1, 0..1, 0..1] |
| 116 | + */ |
| 117 | + fb.setHSL = function (hsl) { |
| 118 | + fb.hsl = hsl; |
| 119 | + fb.rgb = fb.HSLToRGB(hsl); |
| 120 | + fb.color = fb.pack(fb.rgb); |
| 121 | + fb.updateDisplay(); |
| 122 | + return this; |
| 123 | + } |
124 | 124 | |
125 | | - ///////////////////////////////////////////////////// |
| 125 | + ///////////////////////////////////////////////////// |
126 | 126 | |
127 | | - /** |
128 | | - * Retrieve the coordinates of the given event relative to the center |
129 | | - * of the widget. |
130 | | - */ |
131 | | - fb.widgetCoords = function (event) { |
132 | | - var ref = $( fb.wheel ).offset(); |
133 | | - return { |
134 | | - x: event.pageX - ref.left - fb.width / 2, |
135 | | - y: event.pageY - ref.top - fb.width / 2 |
136 | | - }; |
137 | | - } |
| 127 | + /** |
| 128 | + * Retrieve the coordinates of the given event relative to the center |
| 129 | + * of the widget. |
| 130 | + */ |
| 131 | + fb.widgetCoords = function (event) { |
| 132 | + var ref = $( fb.wheel ).offset(); |
| 133 | + return { |
| 134 | + x: event.pageX - ref.left - fb.width / 2, |
| 135 | + y: event.pageY - ref.top - fb.width / 2 |
| 136 | + }; |
| 137 | + } |
138 | 138 | |
139 | | - /** |
140 | | - * Mousedown handler |
141 | | - */ |
142 | | - fb.mousedown = function (event) { |
143 | | - // Capture mouse |
144 | | - if (!document.dragging) { |
145 | | - $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); |
146 | | - document.dragging = true; |
147 | | - } |
| 139 | + /** |
| 140 | + * Mousedown handler |
| 141 | + */ |
| 142 | + fb.mousedown = function (event) { |
| 143 | + // Capture mouse |
| 144 | + if (!document.dragging) { |
| 145 | + $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); |
| 146 | + document.dragging = true; |
| 147 | + } |
148 | 148 | |
149 | | - // Check which area is being dragged |
150 | | - var pos = fb.widgetCoords(event); |
151 | | - fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square; |
| 149 | + // Check which area is being dragged |
| 150 | + var pos = fb.widgetCoords(event); |
| 151 | + fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square; |
152 | 152 | |
153 | | - // Process |
154 | | - fb.mousemove(event); |
155 | | - return false; |
156 | | - } |
| 153 | + // Process |
| 154 | + fb.mousemove(event); |
| 155 | + return false; |
| 156 | + } |
157 | 157 | |
158 | | - /** |
159 | | - * Mousemove handler |
160 | | - */ |
161 | | - fb.mousemove = function (event) { |
162 | | - // Get coordinates relative to color picker center |
163 | | - var pos = fb.widgetCoords(event); |
| 158 | + /** |
| 159 | + * Mousemove handler |
| 160 | + */ |
| 161 | + fb.mousemove = function (event) { |
| 162 | + // Get coordinates relative to color picker center |
| 163 | + var pos = fb.widgetCoords(event); |
164 | 164 | |
165 | | - // Set new HSL parameters |
166 | | - if (fb.circleDrag) { |
167 | | - var hue = Math.atan2(pos.x, -pos.y) / 6.28; |
168 | | - if (hue < 0) hue += 1; |
169 | | - fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]); |
170 | | - } |
171 | | - else { |
172 | | - var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5)); |
173 | | - var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5)); |
174 | | - fb.setHSL([fb.hsl[0], sat, lum]); |
175 | | - } |
176 | | - return false; |
177 | | - } |
| 165 | + // Set new HSL parameters |
| 166 | + if (fb.circleDrag) { |
| 167 | + var hue = Math.atan2(pos.x, -pos.y) / 6.28; |
| 168 | + if (hue < 0) hue += 1; |
| 169 | + fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]); |
| 170 | + } |
| 171 | + else { |
| 172 | + var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5)); |
| 173 | + var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5)); |
| 174 | + fb.setHSL([fb.hsl[0], sat, lum]); |
| 175 | + } |
| 176 | + return false; |
| 177 | + } |
178 | 178 | |
179 | | - /** |
180 | | - * Mouseup handler |
181 | | - */ |
182 | | - fb.mouseup = function () { |
183 | | - // Uncapture mouse |
184 | | - $(document).unbind('mousemove', fb.mousemove); |
185 | | - $(document).unbind('mouseup', fb.mouseup); |
186 | | - document.dragging = false; |
187 | | - } |
| 179 | + /** |
| 180 | + * Mouseup handler |
| 181 | + */ |
| 182 | + fb.mouseup = function () { |
| 183 | + // Uncapture mouse |
| 184 | + $(document).unbind('mousemove', fb.mousemove); |
| 185 | + $(document).unbind('mouseup', fb.mouseup); |
| 186 | + document.dragging = false; |
| 187 | + } |
188 | 188 | |
189 | | - /** |
190 | | - * Update the markers and styles |
191 | | - */ |
192 | | - fb.updateDisplay = function () { |
193 | | - // Markers |
194 | | - var angle = fb.hsl[0] * 6.28; |
195 | | - $('.h-marker', e).css({ |
196 | | - left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px', |
197 | | - top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px' |
198 | | - }); |
| 189 | + /** |
| 190 | + * Update the markers and styles |
| 191 | + */ |
| 192 | + fb.updateDisplay = function () { |
| 193 | + // Markers |
| 194 | + var angle = fb.hsl[0] * 6.28; |
| 195 | + $('.h-marker', e).css({ |
| 196 | + left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px', |
| 197 | + top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px' |
| 198 | + }); |
199 | 199 | |
200 | | - $('.sl-marker', e).css({ |
201 | | - left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px', |
202 | | - top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px' |
203 | | - }); |
| 200 | + $('.sl-marker', e).css({ |
| 201 | + left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px', |
| 202 | + top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px' |
| 203 | + }); |
204 | 204 | |
205 | | - // Saturation/Luminance gradient |
206 | | - $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5]))); |
| 205 | + // Saturation/Luminance gradient |
| 206 | + $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5]))); |
207 | 207 | |
208 | | - // Linked elements or callback |
209 | | - if (typeof fb.callback == 'object') { |
210 | | - // Set background/foreground color |
211 | | - $(fb.callback).css({ |
212 | | - backgroundColor: fb.color, |
213 | | - color: fb.hsl[2] > 0.5 ? '#000' : '#fff' |
214 | | - }); |
| 208 | + // Linked elements or callback |
| 209 | + if (typeof fb.callback == 'object') { |
| 210 | + // Set background/foreground color |
| 211 | + $(fb.callback).css({ |
| 212 | + backgroundColor: fb.color, |
| 213 | + color: fb.hsl[2] > 0.5 ? '#000' : '#fff' |
| 214 | + }); |
215 | 215 | |
216 | | - // Change linked value |
217 | | - $(fb.callback).each(function() { |
218 | | - if ( $( this ).val() != fb.color) { |
219 | | - $( this ).val( fb.color ).change(); |
220 | | - } |
221 | | - }); |
222 | | - } |
223 | | - else if (typeof fb.callback == 'function') { |
224 | | - fb.callback.call(fb, fb.color); |
225 | | - } |
226 | | - } |
| 216 | + // Change linked value |
| 217 | + $(fb.callback).each(function() { |
| 218 | + if ( $( this ).val() != fb.color) { |
| 219 | + $( this ).val( fb.color ).change(); |
| 220 | + } |
| 221 | + }); |
| 222 | + } |
| 223 | + else if (typeof fb.callback == 'function') { |
| 224 | + fb.callback.call(fb, fb.color); |
| 225 | + } |
| 226 | + } |
227 | 227 | |
228 | | - /* Various color utility functions */ |
229 | | - fb.pack = function (rgb) { |
230 | | - var r = Math.round(rgb[0] * 255); |
231 | | - var g = Math.round(rgb[1] * 255); |
232 | | - var b = Math.round(rgb[2] * 255); |
233 | | - return '#' + (r < 16 ? '0' : '') + r.toString(16) + |
234 | | - (g < 16 ? '0' : '') + g.toString(16) + |
235 | | - (b < 16 ? '0' : '') + b.toString(16); |
236 | | - } |
| 228 | + /* Various color utility functions */ |
| 229 | + fb.pack = function (rgb) { |
| 230 | + var r = Math.round(rgb[0] * 255); |
| 231 | + var g = Math.round(rgb[1] * 255); |
| 232 | + var b = Math.round(rgb[2] * 255); |
| 233 | + return '#' + (r < 16 ? '0' : '') + r.toString(16) + |
| 234 | + (g < 16 ? '0' : '') + g.toString(16) + |
| 235 | + (b < 16 ? '0' : '') + b.toString(16); |
| 236 | + } |
237 | 237 | |
238 | | - fb.HSLToRGB = function (hsl) { |
239 | | - var m1, m2, r, g, b; |
240 | | - var h = hsl[0], s = hsl[1], l = hsl[2]; |
241 | | - m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s; |
242 | | - m1 = l * 2 - m2; |
243 | | - return [this.hueToRGB(m1, m2, h+0.33333), |
244 | | - this.hueToRGB(m1, m2, h), |
245 | | - this.hueToRGB(m1, m2, h-0.33333)]; |
246 | | - } |
| 238 | + fb.HSLToRGB = function (hsl) { |
| 239 | + var m1, m2, r, g, b; |
| 240 | + var h = hsl[0], s = hsl[1], l = hsl[2]; |
| 241 | + m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s; |
| 242 | + m1 = l * 2 - m2; |
| 243 | + return [this.hueToRGB(m1, m2, h+0.33333), |
| 244 | + this.hueToRGB(m1, m2, h), |
| 245 | + this.hueToRGB(m1, m2, h-0.33333)]; |
| 246 | + } |
247 | 247 | |
248 | | - fb.hueToRGB = function (m1, m2, h) { |
249 | | - h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h); |
250 | | - if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; |
251 | | - if (h * 2 < 1) return m2; |
252 | | - if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; |
253 | | - return m1; |
254 | | - } |
| 248 | + fb.hueToRGB = function (m1, m2, h) { |
| 249 | + h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h); |
| 250 | + if (h * 6 < 1) return m1 + (m2 - m1) * h * 6; |
| 251 | + if (h * 2 < 1) return m2; |
| 252 | + if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6; |
| 253 | + return m1; |
| 254 | + } |
255 | 255 | |
256 | | - fb.RGBToHSL = function (rgb) { |
257 | | - var min, max, delta, h, s, l; |
258 | | - var r = rgb[0], g = rgb[1], b = rgb[2]; |
259 | | - min = Math.min(r, Math.min(g, b)); |
260 | | - max = Math.max(r, Math.max(g, b)); |
261 | | - delta = max - min; |
262 | | - l = (min + max) / 2; |
263 | | - s = 0; |
264 | | - if (l > 0 && l < 1) { |
265 | | - s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); |
266 | | - } |
267 | | - h = 0; |
268 | | - if (delta > 0) { |
269 | | - if (max == r && max != g) h += (g - b) / delta; |
270 | | - if (max == g && max != b) h += (2 + (b - r) / delta); |
271 | | - if (max == b && max != r) h += (4 + (r - g) / delta); |
272 | | - h /= 6; |
273 | | - } |
274 | | - return [h, s, l]; |
275 | | - } |
| 256 | + fb.RGBToHSL = function (rgb) { |
| 257 | + var min, max, delta, h, s, l; |
| 258 | + var r = rgb[0], g = rgb[1], b = rgb[2]; |
| 259 | + min = Math.min(r, Math.min(g, b)); |
| 260 | + max = Math.max(r, Math.max(g, b)); |
| 261 | + delta = max - min; |
| 262 | + l = (min + max) / 2; |
| 263 | + s = 0; |
| 264 | + if (l > 0 && l < 1) { |
| 265 | + s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l)); |
| 266 | + } |
| 267 | + h = 0; |
| 268 | + if (delta > 0) { |
| 269 | + if (max == r && max != g) h += (g - b) / delta; |
| 270 | + if (max == g && max != b) h += (2 + (b - r) / delta); |
| 271 | + if (max == b && max != r) h += (4 + (r - g) / delta); |
| 272 | + h /= 6; |
| 273 | + } |
| 274 | + return [h, s, l]; |
| 275 | + } |
276 | 276 | |
277 | | - // Install mousedown handler (the others are set on the document on-demand) |
278 | | - $('*', e).mousedown(fb.mousedown); |
| 277 | + // Install mousedown handler (the others are set on the document on-demand) |
| 278 | + $('*', e).mousedown(fb.mousedown); |
279 | 279 | |
280 | | - // Init color |
281 | | - fb.setColor('#000000'); |
| 280 | + // Init color |
| 281 | + fb.setColor('#000000'); |
282 | 282 | |
283 | | - // Set linked elements/callback |
284 | | - if (callback) { |
285 | | - fb.linkTo(callback); |
286 | | - } |
| 283 | + // Set linked elements/callback |
| 284 | + if (callback) { |
| 285 | + fb.linkTo(callback); |
| 286 | + } |
287 | 287 | } |