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 version: "@VERSION", |
17 |
|
18 version: "1.6", |
18 |
19 |
19 // $.ui.plugin is deprecated. Use the proxy pattern instead. |
20 // $.ui.plugin is deprecated. Use the proxy pattern instead. |
20 plugin: { |
21 plugin: { |
21 add: function(module, option, set) { |
22 add: function(module, option, set) { |
22 var proto = $.ui[module].prototype; |
23 var proto = $.ui[module].prototype; |
36 } |
37 } |
37 } |
38 } |
38 }, |
39 }, |
39 |
40 |
40 contains: function(a, b) { |
41 contains: function(a, b) { |
41 return document.compareDocumentPosition |
42 var safari2 = $.browser.safari && $.browser.version < 522; |
42 ? a.compareDocumentPosition(b) & 16 |
43 if (a.contains && !safari2) { |
43 : a !== b && a.contains(b); |
44 return 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; |
44 }, |
51 }, |
45 |
52 |
46 cssCache: {}, |
53 cssCache: {}, |
47 css: function(name) { |
54 css: function(name) { |
48 if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } |
55 if ($.ui.cssCache[name]) { return $.ui.cssCache[name]; } |
49 var tmp = $('<div class="ui-gen"></div>').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); |
56 var tmp = $('<div class="ui-gen">').addClass(name).css({position:'absolute', top:'-5000px', left:'-5000px', display:'block'}).appendTo('body'); |
50 |
57 |
51 //if (!$.browser.safari) |
58 //if (!$.browser.safari) |
52 //tmp.appendTo('body'); |
59 //tmp.appendTo('body'); |
53 |
60 |
54 //Opera and Safari set width and height to 0px instead of auto |
61 //Opera and Safari set width and height to 0px instead of auto |
151 }; |
159 }; |
152 } |
160 } |
153 |
161 |
154 //jQuery plugins |
162 //jQuery plugins |
155 $.fn.extend({ |
163 $.fn.extend({ |
|
164 |
156 remove: function() { |
165 remove: function() { |
157 // Safari has a native remove event which actually removes DOM elements, |
166 // Safari has a native remove event which actually removes DOM elements, |
158 // so we have to use triggerHandler instead of trigger (#3037). |
167 // so we have to use triggerHandler instead of trigger (#3037). |
159 $("*", this).add(this).each(function() { |
168 $("*", this).add(this).each(function() { |
160 $(this).triggerHandler("remove"); |
169 $(this).triggerHandler("remove"); |
175 .css('MozUserSelect', 'none') |
184 .css('MozUserSelect', 'none') |
176 .bind('selectstart.ui', function() { return false; }); |
185 .bind('selectstart.ui', function() { return false; }); |
177 }, |
186 }, |
178 |
187 |
179 scrollParent: function() { |
188 scrollParent: function() { |
|
189 |
180 var scrollParent; |
190 var scrollParent; |
181 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
191 if(($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) { |
182 scrollParent = this.parents().filter(function() { |
192 scrollParent = this.parents().filter(function() { |
183 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)); |
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)); |
184 }).eq(0); |
194 }).eq(0); |
187 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
197 return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1)); |
188 }).eq(0); |
198 }).eq(0); |
189 } |
199 } |
190 |
200 |
191 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
201 return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent; |
|
202 |
|
203 |
192 } |
204 } |
|
205 |
193 }); |
206 }); |
194 |
207 |
195 |
208 |
196 //Additional selectors |
209 //Additional selectors |
197 $.extend($.expr[':'], { |
210 $.extend($.expr[':'], { |
198 data: function(elem, i, match) { |
211 |
199 return !!$.data(elem, match[3]); |
212 data: function(a, i, m) { |
|
213 return $.data(a, m[3]); |
200 }, |
214 }, |
201 |
215 |
202 // TODO: add support for object, area |
216 // TODO: add support for object, area |
203 tabbable: function(elem) { |
217 tabbable: function(a, i, m) { |
204 var nodeName = elem.nodeName.toLowerCase(); |
218 |
|
219 var nodeName = a.nodeName.toLowerCase(); |
205 function isVisible(element) { |
220 function isVisible(element) { |
206 return !($(element).is(':hidden') || $(element).parents(':hidden').length); |
221 return !($(element).is(':hidden') || $(element).parents(':hidden').length); |
207 } |
222 } |
208 |
223 |
209 return ( |
224 return ( |
210 // in tab order |
225 // in tab order |
211 elem.tabIndex >= 0 && |
226 a.tabIndex >= 0 && |
212 |
227 |
213 ( // filter node types that participate in the tab order |
228 ( // filter node types that participate in the tab order |
214 |
229 |
215 // anchor tag |
230 // anchor tag |
216 ('a' == nodeName && elem.href) || |
231 ('a' == nodeName && a.href) || |
217 |
232 |
218 // enabled form element |
233 // enabled form element |
219 (/input|select|textarea|button/.test(nodeName) && |
234 (/input|select|textarea|button/.test(nodeName) && |
220 'hidden' != elem.type && !elem.disabled) |
235 'hidden' != a.type && !a.disabled) |
221 ) && |
236 ) && |
222 |
237 |
223 // visible on page |
238 // visible on page |
224 isVisible(elem) |
239 isVisible(a) |
225 ); |
240 ); |
|
241 |
226 } |
242 } |
|
243 |
227 }); |
244 }); |
228 |
245 |
229 |
246 |
230 // $.widget is a factory to create jQuery plugins |
247 // $.widget is a factory to create jQuery plugins |
231 // taking some boilerplate code out of the plugin code |
248 // taking some boilerplate code out of the plugin code |
280 // create widget constructor |
297 // create widget constructor |
281 $[namespace] = $[namespace] || {}; |
298 $[namespace] = $[namespace] || {}; |
282 $[namespace][name] = function(element, options) { |
299 $[namespace][name] = function(element, options) { |
283 var self = this; |
300 var self = this; |
284 |
301 |
285 this.namespace = namespace; |
|
286 this.widgetName = name; |
302 this.widgetName = name; |
287 this.widgetEventPrefix = $[namespace][name].eventPrefix || name; |
303 this.widgetEventPrefix = $[namespace][name].eventPrefix || name; |
288 this.widgetBaseClass = namespace + '-' + name; |
304 this.widgetBaseClass = namespace + '-' + name; |
289 |
305 |
290 this.options = $.extend({}, |
306 this.options = $.extend({}, |
293 $.metadata && $.metadata.get(element)[name], |
309 $.metadata && $.metadata.get(element)[name], |
294 options); |
310 options); |
295 |
311 |
296 this.element = $(element) |
312 this.element = $(element) |
297 .bind('setData.' + name, function(event, key, value) { |
313 .bind('setData.' + name, function(event, key, value) { |
298 if (event.target == element) { |
314 return self._setData(key, value); |
299 return self._setData(key, value); |
|
300 } |
|
301 }) |
315 }) |
302 .bind('getData.' + name, function(event, key) { |
316 .bind('getData.' + name, function(event, key) { |
303 if (event.target == element) { |
317 return self._getData(key); |
304 return self._getData(key); |
|
305 } |
|
306 }) |
318 }) |
307 .bind('remove', function() { |
319 .bind('remove', function() { |
308 return self.destroy(); |
320 return self.destroy(); |
309 }); |
321 }); |
310 |
322 |
320 }; |
332 }; |
321 |
333 |
322 $.widget.prototype = { |
334 $.widget.prototype = { |
323 _init: function() {}, |
335 _init: function() {}, |
324 destroy: function() { |
336 destroy: function() { |
325 this.element.removeData(this.widgetName) |
337 this.element.removeData(this.widgetName); |
326 .removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled') |
|
327 .removeAttr('aria-disabled'); |
|
328 }, |
338 }, |
329 |
339 |
330 option: function(key, value) { |
340 option: function(key, value) { |
331 var options = key, |
341 var options = key, |
332 self = this; |
342 self = this; |
348 }, |
358 }, |
349 _setData: function(key, value) { |
359 _setData: function(key, value) { |
350 this.options[key] = value; |
360 this.options[key] = value; |
351 |
361 |
352 if (key == 'disabled') { |
362 if (key == 'disabled') { |
353 this.element |
363 this.element[value ? 'addClass' : 'removeClass']( |
354 [value ? 'addClass' : 'removeClass']( |
364 this.widgetBaseClass + '-disabled'); |
355 this.widgetBaseClass + '-disabled' + ' ' + |
|
356 this.namespace + '-state-disabled') |
|
357 .attr("aria-disabled", value); |
|
358 } |
365 } |
359 }, |
366 }, |
360 |
367 |
361 enable: function() { |
368 enable: function() { |
362 this._setData('disabled', false); |
369 this._setData('disabled', false); |
364 disable: function() { |
371 disable: function() { |
365 this._setData('disabled', true); |
372 this._setData('disabled', true); |
366 }, |
373 }, |
367 |
374 |
368 _trigger: function(type, event, data) { |
375 _trigger: function(type, event, data) { |
369 var callback = this.options[type], |
376 var eventName = (type == this.widgetEventPrefix |
370 eventName = (type == this.widgetEventPrefix |
377 ? type : this.widgetEventPrefix + type); |
371 ? type : this.widgetEventPrefix + type); |
378 event = event || $.event.fix({ type: eventName, target: this.element[0] }); |
372 |
379 return this.element.triggerHandler(eventName, [event, data], this.options[type]); |
373 event = event ? $.event.fix(event) : $.Event(); |
|
374 event.type = eventName; |
|
375 |
|
376 this.element.trigger(event, data); |
|
377 |
|
378 return !(callback && callback.call(this.element[0], event, data) === false |
|
379 || event.isDefaultPrevented()); |
|
380 } |
380 } |
381 }; |
381 }; |
382 |
382 |
383 $.widget.defaults = { |
383 $.widget.defaults = { |
384 disabled: false |
384 disabled: false |
461 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
461 .bind('mouseup.'+this.widgetName, this._mouseUpDelegate); |
462 |
462 |
463 // preventDefault() is used to prevent the selection of text here - |
463 // preventDefault() is used to prevent the selection of text here - |
464 // however, in Safari, this causes select boxes not to be selectable |
464 // however, in Safari, this causes select boxes not to be selectable |
465 // anymore, so this fix is needed |
465 // anymore, so this fix is needed |
466 ($.browser.safari || event.preventDefault()); |
466 if(!$.browser.safari) event.preventDefault(); |
467 |
|
468 return true; |
467 return true; |
469 }, |
468 }, |
470 |
469 |
471 _mouseMove: function(event) { |
470 _mouseMove: function(event) { |
472 // IE mouseup check - mouseup happened when mouse was out of window |
471 // IE mouseup check - mouseup happened when mouse was out of window |