equal
deleted
inserted
replaced
1 /*! |
1 /*! |
2 * Farbtastic: jQuery color picker plug-in v1.3u |
2 * Farbtastic: jQuery color picker plug-in v1.3u |
|
3 * https://github.com/mattfarina/farbtastic |
3 * |
4 * |
4 * Licensed under the GPL license: |
5 * Licensed under the GPL license: |
5 * http://www.gnu.org/licenses/gpl.html |
6 * http://www.gnu.org/licenses/gpl.html |
6 */ |
7 */ |
|
8 /** |
|
9 * Modified for WordPress: replaced deprecated jQuery methods. |
|
10 * See https://core.trac.wordpress.org/ticket/57946. |
|
11 */ |
|
12 |
7 (function($) { |
13 (function($) { |
8 |
14 |
9 $.fn.farbtastic = function (options) { |
15 $.fn.farbtastic = function (options) { |
10 $.farbtastic(this, options); |
16 $.farbtastic(this, options); |
11 return this; |
17 return this; |
47 * Link to the given element(s) or callback. |
53 * Link to the given element(s) or callback. |
48 */ |
54 */ |
49 fb.linkTo = function (callback) { |
55 fb.linkTo = function (callback) { |
50 // Unbind previous nodes |
56 // Unbind previous nodes |
51 if (typeof fb.callback == 'object') { |
57 if (typeof fb.callback == 'object') { |
52 $(fb.callback).unbind('keyup', fb.updateValue); |
58 $(fb.callback).off('keyup', fb.updateValue); |
53 } |
59 } |
54 |
60 |
55 // Reset color |
61 // Reset color |
56 fb.color = null; |
62 fb.color = null; |
57 |
63 |
59 if (typeof callback == 'function') { |
65 if (typeof callback == 'function') { |
60 fb.callback = callback; |
66 fb.callback = callback; |
61 } |
67 } |
62 else if (typeof callback == 'object' || typeof callback == 'string') { |
68 else if (typeof callback == 'object' || typeof callback == 'string') { |
63 fb.callback = $(callback); |
69 fb.callback = $(callback); |
64 fb.callback.bind('keyup', fb.updateValue); |
70 fb.callback.on('keyup', fb.updateValue); |
65 if (fb.callback.get(0).value) { |
71 if (fb.callback.get(0).value) { |
66 fb.setColor(fb.callback.get(0).value); |
72 fb.setColor(fb.callback.get(0).value); |
67 } |
73 } |
68 } |
74 } |
69 return this; |
75 return this; |
114 * Mousedown handler |
120 * Mousedown handler |
115 */ |
121 */ |
116 fb.mousedown = function (event) { |
122 fb.mousedown = function (event) { |
117 // Capture mouse |
123 // Capture mouse |
118 if (!document.dragging) { |
124 if (!document.dragging) { |
119 $(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup); |
125 $(document).on('mousemove', fb.mousemove).on('mouseup', fb.mouseup); |
120 document.dragging = true; |
126 document.dragging = true; |
121 } |
127 } |
122 |
128 |
123 // Check which area is being dragged |
129 // Check which area is being dragged |
124 var pos = fb.widgetCoords(event); |
130 var pos = fb.widgetCoords(event); |
153 /** |
159 /** |
154 * Mouseup handler |
160 * Mouseup handler |
155 */ |
161 */ |
156 fb.mouseup = function () { |
162 fb.mouseup = function () { |
157 // Uncapture mouse |
163 // Uncapture mouse |
158 $(document).unbind('mousemove', fb.mousemove); |
164 $(document).off('mousemove', fb.mousemove); |
159 $(document).unbind('mouseup', fb.mouseup); |
165 $(document).off('mouseup', fb.mouseup); |
160 document.dragging = false; |
166 document.dragging = false; |
161 }; |
167 }; |
162 |
168 |
163 /** |
169 /** |
164 * Update the markers and styles |
170 * Update the markers and styles |
260 } |
266 } |
261 return [h, s, l]; |
267 return [h, s, l]; |
262 }; |
268 }; |
263 |
269 |
264 // Install mousedown handler (the others are set on the document on-demand) |
270 // Install mousedown handler (the others are set on the document on-demand) |
265 $('*', e).mousedown(fb.mousedown); |
271 $('*', e).on('mousedown', fb.mousedown); |
266 |
272 |
267 // Init color |
273 // Init color |
268 fb.setColor('#000000'); |
274 fb.setColor('#000000'); |
269 |
275 |
270 // Set linked elements/callback |
276 // Set linked elements/callback |