1 // Limit scope pollution from any deprecated API
4 var matched, browser, eventAdd, eventRemove,
5 oldToggle = jQuery.fn.toggle,
6 rhoverHack = /(?:^|\s)hover(\.\S+|)\b/,
7 hoverHack = function( events ) {
8 return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
11 // Use of jQuery.browser is frowned upon.
12 // More details: http://api.jquery.com/jQuery.browser
13 // jQuery.uaMatch maintained for back-compat
14 jQuery.uaMatch = function( ua ) {
15 ua = ua.toLowerCase();
17 var match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
18 /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
19 /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
20 /(msie) ([\w.]+)/.exec( ua ) ||
21 ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
25 browser: match[ 1 ] || "",
26 version: match[ 2 ] || "0"
30 matched = jQuery.uaMatch( navigator.userAgent );
33 if ( matched.browser ) {
34 browser[ matched.browser ] = true;
35 browser.version = matched.version;
38 // Chrome is Webkit, but Webkit is also Safari.
39 if ( browser.chrome ) {
40 browser.webkit = true;
41 } else if ( browser.webkit ) {
42 browser.safari = true;
45 jQuery.browser = browser;
47 jQuery.sub = function() {
48 function jQuerySub( selector, context ) {
49 return new jQuerySub.fn.init( selector, context );
51 jQuery.extend( true, jQuerySub, this );
52 jQuerySub.superclass = this;
53 jQuerySub.fn = jQuerySub.prototype = this();
54 jQuerySub.fn.constructor = jQuerySub;
55 jQuerySub.sub = this.sub;
56 jQuerySub.fn.init = function init( selector, context ) {
57 if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
58 context = jQuerySub( context );
61 return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
63 jQuerySub.fn.init.prototype = jQuerySub.fn;
64 var rootjQuerySub = jQuerySub(document);
68 jQuery.fn.toggle = function( fn, fn2 ) {
70 if ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {
71 return oldToggle.apply( this, arguments );
74 // Save reference to arguments for access in closure
76 guid = fn.guid || jQuery.guid++,
78 toggler = function( event ) {
79 // Figure out which function to execute
80 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
81 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
83 // Make sure that clicks stop
84 event.preventDefault();
86 // and execute the function
87 return args[ lastToggle ].apply( this, arguments ) || false;
90 // link all the functions, so any of them can unbind this click handler
92 while ( i < args.length ) {
93 args[ i++ ].guid = guid;
96 return this.click( toggler );
100 // Support for 'hover' type
101 eventAdd = jQuery.event.add;
103 // Duck punch jQuery.event.add, and jquery.event.remove
106 // add: function( elem, types, handler, data, selector ) {
107 // remove: function( elem, types, handler, selector, mappedTypes ) {
108 jQuery.event.add = function( elem, types, handler, data, selector ){
110 types = hoverHack( types );
112 eventAdd.call( this, elem, types, handler, data, selector );
115 eventRemove = jQuery.event.remove;
117 jQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){
119 types = hoverHack( types );
121 eventRemove.call( this, elem, types, handler, selector, mappedTypes );
124 // Unused in 1.8, left in so attrFn-stabbers won't die; remove in 1.9