1 /* |
1 /* |
2 * jQuery UI 1.6 |
2 * jQuery UI 1.7.2 |
3 * |
3 * |
4 * Copyright (c) 2008 AUTHORS.txt (http://ui.jquery.com/about) |
4 * Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about) |
5 * Dual licensed under the MIT (MIT-LICENSE.txt) |
5 * Dual licensed under the MIT (MIT-LICENSE.txt) |
6 * and GPL (GPL-LICENSE.txt) licenses. |
6 * and GPL (GPL-LICENSE.txt) licenses. |
7 * |
7 * |
8 * http://docs.jquery.com/UI |
8 * http://docs.jquery.com/UI |
9 */ |
9 */ |
10 ;(function($) { |
10 ;jQuery.ui || (function($) { |
11 |
11 |
12 var _remove = $.fn.remove, |
12 var _remove = $.fn.remove, |
13 isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); |
13 isFF2 = $.browser.mozilla && (parseFloat($.browser.version) < 1.9); |
14 |
14 |
15 //Helper functions and ui object |
15 //Helper functions and ui object |
16 $.ui = { |
16 $.ui = { |
17 |
17 version: "1.7.2", |
18 version: "1.6", |
|
19 |
18 |
20 // $.ui.plugin is deprecated. Use the proxy pattern instead. |
19 // $.ui.plugin is deprecated. Use the proxy pattern instead. |
21 plugin: { |
20 plugin: { |
22 add: function(module, option, set) { |
21 add: function(module, option, set) { |
23 var proto = $.ui[module].prototype; |
22 var proto = $.ui[module].prototype; |
26 proto.plugins[i].push([option, set[i]]); |
25 proto.plugins[i].push([option, set[i]]); |
27 } |
26 } |
28 }, |
27 }, |
29 call: function(instance, name, args) { |
28 call: function(instance, name, args) { |
30 var set = instance.plugins[name]; |
29 var set = instance.plugins[name]; |
31 if(!set) { return; } |
30 if(!set || !instance.element[0].parentNode) { return; } |
32 |
31 |
33 for (var i = 0; i < set.length; i++) { |
32 for (var i = 0; i < set.length; i++) { |
34 if (instance.options[set[i][0]]) { |
33 if (instance.options[set[i][0]]) { |
35 set[i][1].apply(instance.element, args); |
34 set[i][1].apply(instance.element, args); |
36 } |
35 } |
37 } |
36 } |
38 } |
37 } |
39 }, |
38 }, |
40 |
39 |
41 contains: function(a, b) { |
40 contains: function(a, b) { |
42 var safari2 = $.browser.safari && $.browser.version < 522; |
41 return document.compareDocumentPosition |
43 if (a.contains && !safari2) { |
42 ? a.compareDocumentPosition(b) & 16 |
44 return a.contains(b); |
43 : a !== b && a.contains(b); |
45 } |
|
46 if (a.compareDocumentPosition) |
|
47 return !!(a.compareDocumentPosition(b) & 16); |
|
48 while (b = b.parentNode) |
|
49 if (b == a) return true; |
|
50 return false; |
|
51 }, |
|
52 |
|
53 cssCache: {}, |
|
54 css: function(name) { |
|
55 if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } |
|
56 var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); |
|
57 |
|
58 //if (!$.browser.safari) |
|
59 //tmp.appendTo('body'); |
|
60 |
|
61 //Opera and Safari set width and height to 0px instead of auto |
|
62 //Safari returns rgba(0,0,0,0) when bgcolor is not set |
|
63 $.ui.cssCache[name] = !!( |
|
64 (!(/auto|default/).test(tmp.css('cursor')) || (/^[1-9]/).test(tmp.css('height')) || (/^[1-9]/).test(tmp.css('width')) || |
|
65 !(/none/).test(tmp.css('backgroundImage')) || !(/transparent|rgba\(0, 0, 0, 0\)/).test(tmp.css('backgroundColor'))) |
|
66 ); |
|
67 try { $('body').get(0).removeChild(tmp.get(0)); } catch(e){} |
|
68 return $.ui.cssCache[name]; |
|
69 }, |
44 }, |
70 |
45 |
71 hasScroll: function(el, a) { |
46 hasScroll: function(el, a) { |
72 |
47 |
73 //If overflow is hidden, the element might have extra content, but the user wants to hide it |
48 //If overflow is hidden, the element might have extra content, but the user wants to hide it |
184 .css('MozUserSelect', 'none') |
157 .css('MozUserSelect', 'none') |
185 .bind('selectstart.ui', function() { return false; }); |
158 .bind('selectstart.ui', function() { return false; }); |
186 }, |
159 }, |
187 |
160 |
188 scrollParent: function() { |
161 scrollParent: function() { |
189 |
|
190 var scrollParent; |
162 var scrollParent; |
191 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
163 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
192 scrollParent = this.parents().filter(function() { |
164 scrollParent = this.parents().filter(function() { |
193 return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
165 return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
194 }).eq(0); |
166 }).eq(0); |
197 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
169 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
198 }).eq(0); |
170 }).eq(0); |
199 } |
171 } |
200 |
172 |
201 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
173 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
202 |
|
203 |
|
204 } |
174 } |
205 |
|
206 }); |
175 }); |
207 |
176 |
208 |
177 |
209 //Additional selectors |
178 //Additional selectors |
210 $.extend($.expr[':'], { |
179 $.extend($.expr[':'], { |
211 |
180 data: function(elem, i, match) { |
212 data: function(a, i, m) { |
181 return !!$.data(elem, match[3]); |
213 return $.data(a, m[3]); |
182 }, |
214 }, |
183 |
215 |
184 focusable: function(element) { |
216 // TODO: add support for object, area |
185 var nodeName = element.nodeName.toLowerCase(), |
217 tabbable: function(a, i, m) { |
186 tabIndex = $.attr(element, 'tabindex'); |
218 |
187 return (/input|select|textarea|button|object/.test(nodeName) |
219 var nodeName = a.nodeName.toLowerCase(); |
188 ? !element.disabled |
220 function isVisible(element) { |
189 : 'a' == nodeName || 'area' == nodeName |
221 return !($(element).is(':hidden') || $(element).parents(':hidden').length); |
190 ? element.href || !isNaN(tabIndex) |
222 } |
191 : !isNaN(tabIndex)) |
223 |
192 // the element and all of its ancestors must be visible |
224 return ( |
193 // the browser may report that the area is hidden |
225 // in tab order |
194 && !$(element)['area' == nodeName ? 'parents' : 'closest'](':hidden').length; |
226 a.tabIndex >= 0 && |
195 }, |
227 |
196 |
228 ( // filter node types that participate in the tab order |
197 tabbable: function(element) { |
229 |
198 var tabIndex = $.attr(element, 'tabindex'); |
230 // anchor tag |
199 return (isNaN(tabIndex) || tabIndex >= 0) && $(element).is(':focusable'); |
231 ('a' == nodeName && a.href) || |
|
232 |
|
233 // enabled form element |
|
234 (/input|select|textarea|button/.test(nodeName) && |
|
235 'hidden' != a.type && !a.disabled) |
|
236 ) && |
|
237 |
|
238 // visible on page |
|
239 isVisible(a) |
|
240 ); |
|
241 |
|
242 } |
200 } |
243 |
|
244 }); |
201 }); |
245 |
202 |
246 |
203 |
247 // $.widget is a factory to create jQuery plugins |
204 // $.widget is a factory to create jQuery plugins |
248 // taking some boilerplate code out of the plugin code |
205 // taking some boilerplate code out of the plugin code |
284 return this.each(function() { |
241 return this.each(function() { |
285 var instance = $.data(this, name); |
242 var instance = $.data(this, name); |
286 |
243 |
287 // constructor |
244 // constructor |
288 (!instance && !isMethodCall && |
245 (!instance && !isMethodCall && |
289 $.data(this, name, new $[namespace][name](this, options))); |
246 $.data(this, name, new $[namespace][name](this, options))._init()); |
290 |
247 |
291 // method call |
248 // method call |
292 (instance && isMethodCall && $.isFunction(instance[options]) && |
249 (instance && isMethodCall && $.isFunction(instance[options]) && |
293 instance[options].apply(instance, args)); |
250 instance[options].apply(instance, args)); |
294 }); |
251 }); |
297 // create widget constructor |
254 // create widget constructor |
298 $[namespace] = $[namespace] || {}; |
255 $[namespace] = $[namespace] || {}; |
299 $[namespace][name] = function(element, options) { |
256 $[namespace][name] = function(element, options) { |
300 var self = this; |
257 var self = this; |
301 |
258 |
|
259 this.namespace = namespace; |
302 this.widgetName = name; |
260 this.widgetName = name; |
303 this.widgetEventPrefix = $[namespace][name].eventPrefix || name; |
261 this.widgetEventPrefix = $[namespace][name].eventPrefix || name; |
304 this.widgetBaseClass = namespace + '-' + name; |
262 this.widgetBaseClass = namespace + '-' + name; |
305 |
263 |
306 this.options = $.extend({}, |
264 this.options = $.extend({}, |
309 $.metadata && $.metadata.get(element)[name], |
267 $.metadata && $.metadata.get(element)[name], |
310 options); |
268 options); |
311 |
269 |
312 this.element = $(element) |
270 this.element = $(element) |
313 .bind('setData.' + name, function(event, key, value) { |
271 .bind('setData.' + name, function(event, key, value) { |
314 return self._setData(key, value); |
272 if (event.target == element) { |
|
273 return self._setData(key, value); |
|
274 } |
315 }) |
275 }) |
316 .bind('getData.' + name, function(event, key) { |
276 .bind('getData.' + name, function(event, key) { |
317 return self._getData(key); |
277 if (event.target == element) { |
|
278 return self._getData(key); |
|
279 } |
318 }) |
280 }) |
319 .bind('remove', function() { |
281 .bind('remove', function() { |
320 return self.destroy(); |
282 return self.destroy(); |
321 }); |
283 }); |
322 |
|
323 this._init(); |
|
324 }; |
284 }; |
325 |
285 |
326 // add widget prototype |
286 // add widget prototype |
327 $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); |
287 $[namespace][name].prototype = $.extend({}, $.widget.prototype, prototype); |
328 |
288 |
332 }; |
292 }; |
333 |
293 |
334 $.widget.prototype = { |
294 $.widget.prototype = { |
335 _init: function() {}, |
295 _init: function() {}, |
336 destroy: function() { |
296 destroy: function() { |
337 this.element.removeData(this.widgetName); |
297 this.element.removeData(this.widgetName) |
|
298 .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') |
|
299 .removeAttr('aria-disabled'); |
338 }, |
300 }, |
339 |
301 |
340 option: function(key, value) { |
302 option: function(key, value) { |
341 var options = key, |
303 var options = key, |
342 self = this; |
304 self = this; |
358 }, |
320 }, |
359 _setData: function(key, value) { |
321 _setData: function(key, value) { |
360 this.options[key] = value; |
322 this.options[key] = value; |
361 |
323 |
362 if (key == 'disabled') { |
324 if (key == 'disabled') { |
363 this.element[value ? 'addClass' : 'removeClass']( |
325 this.element |
364 this.widgetBaseClass + '-disabled'); |
326 [value ? 'addClass' : 'removeClass']( |
|
327 this.widgetBaseClass + '-disabled' + ' ' + |
|
328 this.namespace + '-state-disabled') |
|
329 .attr("aria-disabled", value); |
365 } |
330 } |
366 }, |
331 }, |
367 |
332 |
368 enable: function() { |
333 enable: function() { |
369 this._setData('disabled', false); |
334 this._setData('disabled', false); |
371 disable: function() { |
336 disable: function() { |
372 this._setData('disabled', true); |
337 this._setData('disabled', true); |
373 }, |
338 }, |
374 |
339 |
375 _trigger: function(type, event, data) { |
340 _trigger: function(type, event, data) { |
376 var eventName = (type == this.widgetEventPrefix |
341 var callback = this.options[type], |
377 ? type : this.widgetEventPrefix + type); |
342 eventName = (type == this.widgetEventPrefix |
378 event = event || $.event.fix({ type: eventName, target: this.element[0] }); |
343 ? type : this.widgetEventPrefix + type); |
379 return this.element.triggerHandler(eventName, [event, data], this.options[type]); |
344 |
|
345 event = $.Event(event); |
|
346 event.type = eventName; |
|
347 |
|
348 // copy original event properties over to the new event |
|
349 // this would happen if we could call $.event.fix instead of $.Event |
|
350 // but we don't have a way to force an event to be fixed multiple times |
|
351 if (event.originalEvent) { |
|
352 for (var i = $.event.props.length, prop; i;) { |
|
353 prop = $.event.props[--i]; |
|
354 event[prop] = event.originalEvent[prop]; |
|
355 } |
|
356 } |
|
357 |
|
358 this.element.trigger(event, data); |
|
359 |
|
360 return !($.isFunction(callback) && callback.call(this.element[0], event, data) === false |
|
361 || event.isDefaultPrevented()); |
380 } |
362 } |
381 }; |
363 }; |
382 |
364 |
383 $.widget.defaults = { |
365 $.widget.defaults = { |
384 disabled: false |
366 disabled: false |
396 return self._mouseDown(event); |
378 return self._mouseDown(event); |
397 }) |
379 }) |
398 .bind('click.'+this.widgetName, function(event) { |
380 .bind('click.'+this.widgetName, function(event) { |
399 if(self._preventClickEvent) { |
381 if(self._preventClickEvent) { |
400 self._preventClickEvent = false; |
382 self._preventClickEvent = false; |
|
383 event.stopImmediatePropagation(); |
401 return false; |
384 return false; |
402 } |
385 } |
403 }); |
386 }); |
404 |
387 |
405 // Prevent text selection in IE |
388 // Prevent text selection in IE |
420 ($.browser.msie |
403 ($.browser.msie |
421 && this.element.attr('unselectable', this._mouseUnselectable)); |
404 && this.element.attr('unselectable', this._mouseUnselectable)); |
422 }, |
405 }, |
423 |
406 |
424 _mouseDown: function(event) { |
407 _mouseDown: function(event) { |
|
408 // don't let more than one widget handle mouseStart |
|
409 // TODO: figure out why we have to use originalEvent |
|
410 event.originalEvent = event.originalEvent || {}; |
|
411 if (event.originalEvent.mouseHandled) { return; } |
|
412 |
425 // we may have missed mouseup (out of window) |
413 // we may have missed mouseup (out of window) |
426 (this._mouseStarted && this._mouseUp(event)); |
414 (this._mouseStarted && this._mouseUp(event)); |
427 |
415 |
428 this._mouseDownEvent = event; |
416 this._mouseDownEvent = event; |
429 |
417 |
461 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
449 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
462 |
450 |
463 // preventDefault() is used to prevent the selection of text here - |
451 // preventDefault() is used to prevent the selection of text here - |
464 // however, in Safari, this causes select boxes not to be selectable |
452 // however, in Safari, this causes select boxes not to be selectable |
465 // anymore, so this fix is needed |
453 // anymore, so this fix is needed |
466 if(!$.browser.safari) event.preventDefault(); |
454 ($.browser.safari || event.preventDefault()); |
|
455 |
|
456 event.originalEvent.mouseHandled = true; |
467 return true; |
457 return true; |
468 }, |
458 }, |
469 |
459 |
470 _mouseMove: function(event) { |
460 _mouseMove: function(event) { |
471 // IE mouseup check - mouseup happened when mouse was out of window |
461 // IE mouseup check - mouseup happened when mouse was out of window |
492 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
482 .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) |
493 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
483 .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
494 |
484 |
495 if (this._mouseStarted) { |
485 if (this._mouseStarted) { |
496 this._mouseStarted = false; |
486 this._mouseStarted = false; |
497 this._preventClickEvent = true; |
487 this._preventClickEvent = (event.target == this._mouseDownEvent.target); |
498 this._mouseStop(event); |
488 this._mouseStop(event); |
499 } |
489 } |
500 |
490 |
501 return false; |
491 return false; |
502 }, |
492 }, |