annotate web/static/jquery-2.1.0.js @ 216:e3b85f9fbb03

merge
author Matt Johnston <matt@ucc.asn.au>
date Fri, 25 Jul 2014 23:55:35 +0800
parents ae5efca89001
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
188
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*!
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 * jQuery JavaScript Library v2.1.0
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 * http://jquery.com/
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 * Includes Sizzle.js
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 * http://sizzlejs.com/
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * Released under the MIT license
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 * http://jquery.org/license
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 * Date: 2014-01-23T21:10Z
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 (function( global, factory ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 if ( typeof module === "object" && typeof module.exports === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 // For CommonJS and CommonJS-like environments where a proper window is present,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 // execute the factory and get jQuery
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 // For environments that do not inherently posses a window with a document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 // (such as Node.js), expose a jQuery-making factory as module.exports
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 // This accentuates the need for the creation of a real window
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 // e.g. var jQuery = require("jquery")(window);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24 // See ticket #14549 for more info
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 module.exports = global.document ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 factory( global, true ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 function( w ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 if ( !w.document ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 throw new Error( "jQuery requires a window with a document" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31 return factory( w );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
33 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 factory( global );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 // Pass this if window is not defined yet
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 // Can't do this because several apps including ASP.NET trace
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 // the stack via arguments.caller.callee and Firefox dies if
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 // you try to trace through "use strict" call chains. (#13335)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 // Support: Firefox 18+
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 var arr = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 var slice = arr.slice;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 var concat = arr.concat;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 var push = arr.push;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 var indexOf = arr.indexOf;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 var class2type = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 var toString = class2type.toString;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60 var hasOwn = class2type.hasOwnProperty;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 var trim = "".trim;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 var support = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 var
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 // Use the correct document accordingly with window argument (sandbox)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
70 document = window.document,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72 version = "2.1.0",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 // Define a local copy of jQuery
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
75 jQuery = function( selector, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
76 // The jQuery object is actually just the init constructor 'enhanced'
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
77 // Need init if jQuery is called (just allow error to be thrown if not included)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 return new jQuery.fn.init( selector, context );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
80
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
81 // Matches dashed string for camelizing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
82 rmsPrefix = /^-ms-/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83 rdashAlpha = /-([\da-z])/gi,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
84
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
85 // Used by jQuery.camelCase as callback to replace()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
86 fcamelCase = function( all, letter ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
87 return letter.toUpperCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
88 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
89
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 jQuery.fn = jQuery.prototype = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 // The current version of jQuery being used
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92 jquery: version,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94 constructor: jQuery,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 // Start with an empty selector
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
97 selector: "",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99 // The default length of a jQuery object is 0
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
100 length: 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102 toArray: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 return slice.call( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 // Get the Nth element in the matched element set OR
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 // Get the whole matched element set as a clean array
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 get: function( num ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 return num != null ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
111 // Return a 'clean' array
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114 // Return just the object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
115 slice.call( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
116 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
117
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
118 // Take an array of elements and push it onto the stack
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
119 // (returning the new matched element set)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120 pushStack: function( elems ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
121
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
122 // Build a new jQuery matched element set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
123 var ret = jQuery.merge( this.constructor(), elems );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
124
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
125 // Add the old object onto the stack (as a reference)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
126 ret.prevObject = this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
127 ret.context = this.context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
129 // Return the newly-formed element set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
131 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
133 // Execute a callback for every element in the matched set.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134 // (You can seed the arguments with an array of args, but this is
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 // only used internally.)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
136 each: function( callback, args ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
137 return jQuery.each( this, callback, args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 map: function( callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 return this.pushStack( jQuery.map(this, function( elem, i ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142 return callback.call( elem, i, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
143 }));
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
145
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 slice: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
147 return this.pushStack( slice.apply( this, arguments ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
148 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
149
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
150 first: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
151 return this.eq( 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154 last: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155 return this.eq( -1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
156 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
158 eq: function( i ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
159 var len = this.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
160 j = +i + ( i < 0 ? len : 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161 return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 end: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
165 return this.prevObject || this.constructor(null);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
166 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
167
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
168 // For internal use only.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
169 // Behaves like an Array's method, not like a jQuery method.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
170 push: push,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 sort: arr.sort,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
172 splice: arr.splice
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
174
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175 jQuery.extend = jQuery.fn.extend = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 var options, name, src, copy, copyIsArray, clone,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
177 target = arguments[0] || {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
178 i = 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179 length = arguments.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
180 deep = false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
181
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
182 // Handle a deep copy situation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183 if ( typeof target === "boolean" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
184 deep = target;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
185
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186 // skip the boolean and the target
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
187 target = arguments[ i ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
188 i++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
189 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
190
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
191 // Handle case when target is a string or something (possible in deep copy)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
192 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
193 target = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
194 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
195
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
196 // extend jQuery itself if only one argument is passed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
197 if ( i === length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
198 target = this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
199 i--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
200 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
201
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
202 for ( ; i < length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
203 // Only deal with non-null/undefined values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
204 if ( (options = arguments[ i ]) != null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
205 // Extend the base object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
206 for ( name in options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
207 src = target[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
208 copy = options[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
209
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
210 // Prevent never-ending loop
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
211 if ( target === copy ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
212 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
213 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
214
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
215 // Recurse if we're merging plain objects or arrays
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
216 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
217 if ( copyIsArray ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
218 copyIsArray = false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
219 clone = src && jQuery.isArray(src) ? src : [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
220
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
221 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
222 clone = src && jQuery.isPlainObject(src) ? src : {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
223 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
224
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
225 // Never move original objects, clone them
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
226 target[ name ] = jQuery.extend( deep, clone, copy );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
227
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
228 // Don't bring in undefined values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
229 } else if ( copy !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
230 target[ name ] = copy;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
231 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
232 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
233 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
234 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
235
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
236 // Return the modified object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
237 return target;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
238 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
239
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
240 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
241 // Unique for each copy of jQuery on the page
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
242 expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
243
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
244 // Assume jQuery is ready without the ready module
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
245 isReady: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
246
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
247 error: function( msg ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
248 throw new Error( msg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
249 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
250
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
251 noop: function() {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
252
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
253 // See test/unit/core.js for details concerning isFunction.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
254 // Since version 1.3, DOM methods and functions like alert
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
255 // aren't supported. They return false on IE (#2968).
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
256 isFunction: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
257 return jQuery.type(obj) === "function";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
258 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
259
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
260 isArray: Array.isArray,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
261
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
262 isWindow: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
263 return obj != null && obj === obj.window;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
264 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
265
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
266 isNumeric: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
267 // parseFloat NaNs numeric-cast false positives (null|true|false|"")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
268 // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
269 // subtraction forces infinities to NaN
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
270 return obj - parseFloat( obj ) >= 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
271 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
272
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
273 isPlainObject: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
274 // Not plain objects:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
275 // - Any object or value whose internal [[Class]] property is not "[object Object]"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
276 // - DOM nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
277 // - window
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
278 if ( jQuery.type( obj ) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
279 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
280 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
281
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
282 // Support: Firefox <20
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
283 // The try/catch suppresses exceptions thrown when attempting to access
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
284 // the "constructor" property of certain host objects, ie. |window.location|
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
285 // https://bugzilla.mozilla.org/show_bug.cgi?id=814622
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
286 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
287 if ( obj.constructor &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
288 !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
289 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
290 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
291 } catch ( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
292 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
293 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
294
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
295 // If the function hasn't returned already, we're confident that
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
296 // |obj| is a plain object, created by {} or constructed with new Object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
297 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
298 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
299
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
300 isEmptyObject: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
301 var name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
302 for ( name in obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
303 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
304 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
305 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
306 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
307
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
308 type: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
309 if ( obj == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
310 return obj + "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
311 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
312 // Support: Android < 4.0, iOS < 6 (functionish RegExp)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
313 return typeof obj === "object" || typeof obj === "function" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
314 class2type[ toString.call(obj) ] || "object" :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
315 typeof obj;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
316 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
317
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
318 // Evaluates a script in a global context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
319 globalEval: function( code ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
320 var script,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
321 indirect = eval;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
322
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
323 code = jQuery.trim( code );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
324
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
325 if ( code ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
326 // If the code includes a valid, prologue position
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
327 // strict mode pragma, execute code by injecting a
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
328 // script tag into the document.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
329 if ( code.indexOf("use strict") === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
330 script = document.createElement("script");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
331 script.text = code;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
332 document.head.appendChild( script ).parentNode.removeChild( script );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
333 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
334 // Otherwise, avoid the DOM node creation, insertion
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
335 // and removal by using an indirect global eval
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
336 indirect( code );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
337 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
338 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
339 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
340
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
341 // Convert dashed to camelCase; used by the css and data modules
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
342 // Microsoft forgot to hump their vendor prefix (#9572)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
343 camelCase: function( string ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
344 return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
345 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
346
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
347 nodeName: function( elem, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
348 return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
349 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
350
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
351 // args is for internal usage only
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
352 each: function( obj, callback, args ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
353 var value,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
354 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
355 length = obj.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
356 isArray = isArraylike( obj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
357
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
358 if ( args ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
359 if ( isArray ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
360 for ( ; i < length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
361 value = callback.apply( obj[ i ], args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
362
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
363 if ( value === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
364 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
365 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
366 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
367 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
368 for ( i in obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
369 value = callback.apply( obj[ i ], args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
370
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
371 if ( value === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
372 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
373 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
374 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
375 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
376
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
377 // A special, fast, case for the most common use of each
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
378 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
379 if ( isArray ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
380 for ( ; i < length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
381 value = callback.call( obj[ i ], i, obj[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
382
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
383 if ( value === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
384 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
385 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
386 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
387 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
388 for ( i in obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
389 value = callback.call( obj[ i ], i, obj[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
390
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
391 if ( value === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
392 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
393 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
394 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
395 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
396 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
397
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
398 return obj;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
399 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
400
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
401 trim: function( text ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
402 return text == null ? "" : trim.call( text );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
403 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
404
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
405 // results is for internal usage only
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
406 makeArray: function( arr, results ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
407 var ret = results || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
408
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
409 if ( arr != null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
410 if ( isArraylike( Object(arr) ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
411 jQuery.merge( ret,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
412 typeof arr === "string" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
413 [ arr ] : arr
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
414 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
415 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
416 push.call( ret, arr );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
417 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
418 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
419
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
420 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
421 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
422
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
423 inArray: function( elem, arr, i ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
424 return arr == null ? -1 : indexOf.call( arr, elem, i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
425 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
426
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
427 merge: function( first, second ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
428 var len = +second.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
429 j = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
430 i = first.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
431
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
432 for ( ; j < len; j++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
433 first[ i++ ] = second[ j ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
434 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
435
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
436 first.length = i;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
437
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
438 return first;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
439 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
440
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
441 grep: function( elems, callback, invert ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
442 var callbackInverse,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
443 matches = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
444 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
445 length = elems.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
446 callbackExpect = !invert;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
447
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
448 // Go through the array, only saving the items
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
449 // that pass the validator function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
450 for ( ; i < length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
451 callbackInverse = !callback( elems[ i ], i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
452 if ( callbackInverse !== callbackExpect ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
453 matches.push( elems[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
454 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
455 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
456
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
457 return matches;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
458 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
459
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
460 // arg is for internal usage only
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
461 map: function( elems, callback, arg ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
462 var value,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
463 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
464 length = elems.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
465 isArray = isArraylike( elems ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
466 ret = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
467
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
468 // Go through the array, translating each of the items to their new values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
469 if ( isArray ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
470 for ( ; i < length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
471 value = callback( elems[ i ], i, arg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
472
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
473 if ( value != null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
474 ret.push( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
475 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
476 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
477
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
478 // Go through every key on the object,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
479 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
480 for ( i in elems ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
481 value = callback( elems[ i ], i, arg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
482
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
483 if ( value != null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
484 ret.push( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
485 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
486 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
487 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
488
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
489 // Flatten any nested arrays
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
490 return concat.apply( [], ret );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
491 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
492
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
493 // A global GUID counter for objects
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
494 guid: 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
495
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
496 // Bind a function to a context, optionally partially applying any
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
497 // arguments.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
498 proxy: function( fn, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
499 var tmp, args, proxy;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
500
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
501 if ( typeof context === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
502 tmp = fn[ context ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
503 context = fn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
504 fn = tmp;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
505 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
506
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
507 // Quick check to determine if target is callable, in the spec
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
508 // this throws a TypeError, but we will just return undefined.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
509 if ( !jQuery.isFunction( fn ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
510 return undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
511 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
512
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
513 // Simulated bind
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
514 args = slice.call( arguments, 2 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
515 proxy = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
516 return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
517 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
518
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
519 // Set the guid of unique handler to the same of original handler, so it can be removed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
520 proxy.guid = fn.guid = fn.guid || jQuery.guid++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
521
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
522 return proxy;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
523 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
524
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
525 now: Date.now,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
526
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
527 // jQuery.support is not used in Core but other projects attach their
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
528 // properties to it so it needs to exist.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
529 support: support
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
530 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
531
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
532 // Populate the class2type map
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
533 jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
534 class2type[ "[object " + name + "]" ] = name.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
535 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
536
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
537 function isArraylike( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
538 var length = obj.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
539 type = jQuery.type( obj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
540
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
541 if ( type === "function" || jQuery.isWindow( obj ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
542 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
543 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
544
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
545 if ( obj.nodeType === 1 && length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
546 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
547 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
548
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
549 return type === "array" || length === 0 ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
550 typeof length === "number" && length > 0 && ( length - 1 ) in obj;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
551 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
552 var Sizzle =
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
553 /*!
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
554 * Sizzle CSS Selector Engine v1.10.16
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
555 * http://sizzlejs.com/
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
556 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
557 * Copyright 2013 jQuery Foundation, Inc. and other contributors
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
558 * Released under the MIT license
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
559 * http://jquery.org/license
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
560 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
561 * Date: 2014-01-13
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
562 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
563 (function( window ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
564
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
565 var i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
566 support,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
567 Expr,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
568 getText,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
569 isXML,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
570 compile,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
571 outermostContext,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
572 sortInput,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
573 hasDuplicate,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
574
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
575 // Local document vars
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
576 setDocument,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
577 document,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
578 docElem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
579 documentIsHTML,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
580 rbuggyQSA,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
581 rbuggyMatches,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
582 matches,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
583 contains,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
584
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
585 // Instance-specific data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
586 expando = "sizzle" + -(new Date()),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
587 preferredDoc = window.document,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
588 dirruns = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
589 done = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
590 classCache = createCache(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
591 tokenCache = createCache(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
592 compilerCache = createCache(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
593 sortOrder = function( a, b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
594 if ( a === b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
595 hasDuplicate = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
596 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
597 return 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
598 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
599
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
600 // General-purpose constants
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
601 strundefined = typeof undefined,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
602 MAX_NEGATIVE = 1 << 31,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
603
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
604 // Instance methods
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
605 hasOwn = ({}).hasOwnProperty,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
606 arr = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
607 pop = arr.pop,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
608 push_native = arr.push,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
609 push = arr.push,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
610 slice = arr.slice,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
611 // Use a stripped-down indexOf if we can't use a native one
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
612 indexOf = arr.indexOf || function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
613 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
614 len = this.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
615 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
616 if ( this[i] === elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
617 return i;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
618 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
619 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
620 return -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
621 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
622
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
623 booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
624
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
625 // Regular expressions
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
626
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
627 // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
628 whitespace = "[\\x20\\t\\r\\n\\f]",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
629 // http://www.w3.org/TR/css3-syntax/#characters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
630 characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
631
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
632 // Loosely modeled on CSS identifier characters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
633 // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
634 // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
635 identifier = characterEncoding.replace( "w", "w#" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
636
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
637 // Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
638 attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
639 "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
640
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
641 // Prefer arguments quoted,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
642 // then not containing pseudos/brackets,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
643 // then attribute selectors/non-parenthetical expressions,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
644 // then anything else
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
645 // These preferences are here to reduce the number of selectors
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
646 // needing tokenize in the PSEUDO preFilter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
647 pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
648
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
649 // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
650 rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
651
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
652 rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
653 rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
654
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
655 rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
656
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
657 rpseudo = new RegExp( pseudos ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
658 ridentifier = new RegExp( "^" + identifier + "$" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
659
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
660 matchExpr = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
661 "ID": new RegExp( "^#(" + characterEncoding + ")" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
662 "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
663 "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
664 "ATTR": new RegExp( "^" + attributes ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
665 "PSEUDO": new RegExp( "^" + pseudos ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
666 "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
667 "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
668 "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
669 "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
670 // For use in libraries implementing .is()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
671 // We use this for POS matching in `select`
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
672 "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
673 whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
674 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
675
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
676 rinputs = /^(?:input|select|textarea|button)$/i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
677 rheader = /^h\d$/i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
678
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
679 rnative = /^[^{]+\{\s*\[native \w/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
680
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
681 // Easily-parseable/retrievable ID or TAG or CLASS selectors
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
682 rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
683
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
684 rsibling = /[+~]/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
685 rescape = /'|\\/g,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
686
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
687 // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
688 runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
689 funescape = function( _, escaped, escapedWhitespace ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
690 var high = "0x" + escaped - 0x10000;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
691 // NaN means non-codepoint
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
692 // Support: Firefox
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
693 // Workaround erroneous numeric interpretation of +"0x"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
694 return high !== high || escapedWhitespace ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
695 escaped :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
696 high < 0 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
697 // BMP codepoint
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
698 String.fromCharCode( high + 0x10000 ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
699 // Supplemental Plane codepoint (surrogate pair)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
700 String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
701 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
702
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
703 // Optimize for push.apply( _, NodeList )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
704 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
705 push.apply(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
706 (arr = slice.call( preferredDoc.childNodes )),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
707 preferredDoc.childNodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
708 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
709 // Support: Android<4.0
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
710 // Detect silently failing push.apply
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
711 arr[ preferredDoc.childNodes.length ].nodeType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
712 } catch ( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
713 push = { apply: arr.length ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
714
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
715 // Leverage slice if possible
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
716 function( target, els ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
717 push_native.apply( target, slice.call(els) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
718 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
719
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
720 // Support: IE<9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
721 // Otherwise append directly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
722 function( target, els ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
723 var j = target.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
724 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
725 // Can't trust NodeList.length
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
726 while ( (target[j++] = els[i++]) ) {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
727 target.length = j - 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
728 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
729 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
730 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
731
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
732 function Sizzle( selector, context, results, seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
733 var match, elem, m, nodeType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
734 // QSA vars
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
735 i, groups, old, nid, newContext, newSelector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
736
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
737 if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
738 setDocument( context );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
739 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
740
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
741 context = context || document;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
742 results = results || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
743
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
744 if ( !selector || typeof selector !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
745 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
746 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
747
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
748 if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
749 return [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
750 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
751
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
752 if ( documentIsHTML && !seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
753
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
754 // Shortcuts
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
755 if ( (match = rquickExpr.exec( selector )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
756 // Speed-up: Sizzle("#ID")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
757 if ( (m = match[1]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
758 if ( nodeType === 9 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
759 elem = context.getElementById( m );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
760 // Check parentNode to catch when Blackberry 4.6 returns
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
761 // nodes that are no longer in the document (jQuery #6963)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
762 if ( elem && elem.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
763 // Handle the case where IE, Opera, and Webkit return items
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
764 // by name instead of ID
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
765 if ( elem.id === m ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
766 results.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
767 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
768 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
769 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
770 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
771 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
772 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
773 // Context is not a document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
774 if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
775 contains( context, elem ) && elem.id === m ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
776 results.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
777 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
778 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
779 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
780
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
781 // Speed-up: Sizzle("TAG")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
782 } else if ( match[2] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
783 push.apply( results, context.getElementsByTagName( selector ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
784 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
785
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
786 // Speed-up: Sizzle(".CLASS")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
787 } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
788 push.apply( results, context.getElementsByClassName( m ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
789 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
790 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
791 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
792
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
793 // QSA path
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
794 if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
795 nid = old = expando;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
796 newContext = context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
797 newSelector = nodeType === 9 && selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
798
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
799 // qSA works strangely on Element-rooted queries
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
800 // We can work around this by specifying an extra ID on the root
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
801 // and working up from there (Thanks to Andrew Dupont for the technique)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
802 // IE 8 doesn't work on object elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
803 if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
804 groups = tokenize( selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
805
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
806 if ( (old = context.getAttribute("id")) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
807 nid = old.replace( rescape, "\\$&" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
808 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
809 context.setAttribute( "id", nid );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
810 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
811 nid = "[id='" + nid + "'] ";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
812
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
813 i = groups.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
814 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
815 groups[i] = nid + toSelector( groups[i] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
816 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
817 newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
818 newSelector = groups.join(",");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
819 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
820
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
821 if ( newSelector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
822 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
823 push.apply( results,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
824 newContext.querySelectorAll( newSelector )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
825 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
826 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
827 } catch(qsaError) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
828 } finally {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
829 if ( !old ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
830 context.removeAttribute("id");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
831 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
832 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
833 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
834 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
835 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
836
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
837 // All others
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
838 return select( selector.replace( rtrim, "$1" ), context, results, seed );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
839 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
840
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
841 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
842 * Create key-value caches of limited size
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
843 * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
844 * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
845 * deleting the oldest entry
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
846 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
847 function createCache() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
848 var keys = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
849
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
850 function cache( key, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
851 // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
852 if ( keys.push( key + " " ) > Expr.cacheLength ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
853 // Only keep the most recent entries
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
854 delete cache[ keys.shift() ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
855 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
856 return (cache[ key + " " ] = value);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
857 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
858 return cache;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
859 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
860
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
861 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
862 * Mark a function for special use by Sizzle
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
863 * @param {Function} fn The function to mark
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
864 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
865 function markFunction( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
866 fn[ expando ] = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
867 return fn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
868 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
869
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
870 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
871 * Support testing using an element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
872 * @param {Function} fn Passed the created div and expects a boolean result
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
873 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
874 function assert( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
875 var div = document.createElement("div");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
876
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
877 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
878 return !!fn( div );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
879 } catch (e) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
880 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
881 } finally {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
882 // Remove from its parent by default
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
883 if ( div.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
884 div.parentNode.removeChild( div );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
885 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
886 // release memory in IE
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
887 div = null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
888 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
889 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
890
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
891 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
892 * Adds the same handler for all of the specified attrs
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
893 * @param {String} attrs Pipe-separated list of attributes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
894 * @param {Function} handler The method that will be applied
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
895 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
896 function addHandle( attrs, handler ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
897 var arr = attrs.split("|"),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
898 i = attrs.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
899
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
900 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
901 Expr.attrHandle[ arr[i] ] = handler;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
902 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
903 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
904
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
905 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
906 * Checks document order of two siblings
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
907 * @param {Element} a
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
908 * @param {Element} b
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
909 * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
910 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
911 function siblingCheck( a, b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
912 var cur = b && a,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
913 diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
914 ( ~b.sourceIndex || MAX_NEGATIVE ) -
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
915 ( ~a.sourceIndex || MAX_NEGATIVE );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
916
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
917 // Use IE sourceIndex if available on both nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
918 if ( diff ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
919 return diff;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
920 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
921
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
922 // Check if b follows a
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
923 if ( cur ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
924 while ( (cur = cur.nextSibling) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
925 if ( cur === b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
926 return -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
927 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
928 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
929 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
930
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
931 return a ? 1 : -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
932 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
933
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
934 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
935 * Returns a function to use in pseudos for input types
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
936 * @param {String} type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
937 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
938 function createInputPseudo( type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
939 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
940 var name = elem.nodeName.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
941 return name === "input" && elem.type === type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
942 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
943 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
944
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
945 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
946 * Returns a function to use in pseudos for buttons
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
947 * @param {String} type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
948 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
949 function createButtonPseudo( type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
950 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
951 var name = elem.nodeName.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
952 return (name === "input" || name === "button") && elem.type === type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
953 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
954 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
955
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
956 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
957 * Returns a function to use in pseudos for positionals
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
958 * @param {Function} fn
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
959 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
960 function createPositionalPseudo( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
961 return markFunction(function( argument ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
962 argument = +argument;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
963 return markFunction(function( seed, matches ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
964 var j,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
965 matchIndexes = fn( [], seed.length, argument ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
966 i = matchIndexes.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
967
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
968 // Match elements found at the specified indexes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
969 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
970 if ( seed[ (j = matchIndexes[i]) ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
971 seed[j] = !(matches[j] = seed[j]);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
972 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
973 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
974 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
975 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
976 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
977
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
978 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
979 * Checks a node for validity as a Sizzle context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
980 * @param {Element|Object=} context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
981 * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
982 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
983 function testContext( context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
984 return context && typeof context.getElementsByTagName !== strundefined && context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
985 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
986
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
987 // Expose support vars for convenience
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
988 support = Sizzle.support = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
989
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
990 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
991 * Detects XML nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
992 * @param {Element|Object} elem An element or a document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
993 * @returns {Boolean} True iff elem is a non-HTML XML node
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
994 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
995 isXML = Sizzle.isXML = function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
996 // documentElement is verified for cases where it doesn't yet exist
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
997 // (such as loading iframes in IE - #4833)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
998 var documentElement = elem && (elem.ownerDocument || elem).documentElement;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
999 return documentElement ? documentElement.nodeName !== "HTML" : false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1000 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1001
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1002 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1003 * Sets document-related variables once based on the current document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1004 * @param {Element|Object} [doc] An element or document object to use to set the document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1005 * @returns {Object} Returns the current document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1006 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1007 setDocument = Sizzle.setDocument = function( node ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1008 var hasCompare,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1009 doc = node ? node.ownerDocument || node : preferredDoc,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1010 parent = doc.defaultView;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1011
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1012 // If no document and documentElement is available, return
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1013 if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1014 return document;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1015 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1016
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1017 // Set our document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1018 document = doc;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1019 docElem = doc.documentElement;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1020
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1021 // Support tests
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1022 documentIsHTML = !isXML( doc );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1023
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1024 // Support: IE>8
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1025 // If iframe document is assigned to "document" variable and if iframe has been reloaded,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1026 // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1027 // IE6-8 do not support the defaultView property so parent will be undefined
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1028 if ( parent && parent !== parent.top ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1029 // IE11 does not have attachEvent, so all must suffer
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1030 if ( parent.addEventListener ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1031 parent.addEventListener( "unload", function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1032 setDocument();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1033 }, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1034 } else if ( parent.attachEvent ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1035 parent.attachEvent( "onunload", function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1036 setDocument();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1037 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1038 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1039 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1040
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1041 /* Attributes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1042 ---------------------------------------------------------------------- */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1043
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1044 // Support: IE<8
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1045 // Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1046 support.attributes = assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1047 div.className = "i";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1048 return !div.getAttribute("className");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1049 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1050
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1051 /* getElement(s)By*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1052 ---------------------------------------------------------------------- */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1053
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1054 // Check if getElementsByTagName("*") returns only elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1055 support.getElementsByTagName = assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1056 div.appendChild( doc.createComment("") );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1057 return !div.getElementsByTagName("*").length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1058 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1059
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1060 // Check if getElementsByClassName can be trusted
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1061 support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1062 div.innerHTML = "<div class='a'></div><div class='a i'></div>";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1063
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1064 // Support: Safari<4
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1065 // Catch class over-caching
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1066 div.firstChild.className = "i";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1067 // Support: Opera<10
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1068 // Catch gEBCN failure to find non-leading classes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1069 return div.getElementsByClassName("i").length === 2;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1070 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1071
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1072 // Support: IE<10
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1073 // Check if getElementById returns elements by name
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1074 // The broken getElementById methods don't pick up programatically-set names,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1075 // so use a roundabout getElementsByName test
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1076 support.getById = assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1077 docElem.appendChild( div ).id = expando;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1078 return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1079 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1080
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1081 // ID find and filter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1082 if ( support.getById ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1083 Expr.find["ID"] = function( id, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1084 if ( typeof context.getElementById !== strundefined && documentIsHTML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1085 var m = context.getElementById( id );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1086 // Check parentNode to catch when Blackberry 4.6 returns
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1087 // nodes that are no longer in the document #6963
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1088 return m && m.parentNode ? [m] : [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1089 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1090 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1091 Expr.filter["ID"] = function( id ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1092 var attrId = id.replace( runescape, funescape );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1093 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1094 return elem.getAttribute("id") === attrId;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1095 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1096 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1097 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1098 // Support: IE6/7
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1099 // getElementById is not reliable as a find shortcut
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1100 delete Expr.find["ID"];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1101
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1102 Expr.filter["ID"] = function( id ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1103 var attrId = id.replace( runescape, funescape );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1104 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1105 var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1106 return node && node.value === attrId;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1107 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1108 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1109 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1110
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1111 // Tag
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1112 Expr.find["TAG"] = support.getElementsByTagName ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1113 function( tag, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1114 if ( typeof context.getElementsByTagName !== strundefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1115 return context.getElementsByTagName( tag );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1116 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1117 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1118 function( tag, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1119 var elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1120 tmp = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1121 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1122 results = context.getElementsByTagName( tag );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1123
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1124 // Filter out possible comments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1125 if ( tag === "*" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1126 while ( (elem = results[i++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1127 if ( elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1128 tmp.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1129 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1130 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1131
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1132 return tmp;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1133 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1134 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1135 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1136
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1137 // Class
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1138 Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1139 if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1140 return context.getElementsByClassName( className );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1141 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1142 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1143
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1144 /* QSA/matchesSelector
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1145 ---------------------------------------------------------------------- */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1146
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1147 // QSA and matchesSelector support
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1148
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1149 // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1150 rbuggyMatches = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1151
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1152 // qSa(:focus) reports false when true (Chrome 21)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1153 // We allow this because of a bug in IE8/9 that throws an error
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1154 // whenever `document.activeElement` is accessed on an iframe
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1155 // So, we allow :focus to pass through QSA all the time to avoid the IE error
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1156 // See http://bugs.jquery.com/ticket/13378
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1157 rbuggyQSA = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1158
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1159 if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1160 // Build QSA regex
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1161 // Regex strategy adopted from Diego Perini
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1162 assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1163 // Select is set to empty string on purpose
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1164 // This is to test IE's treatment of not explicitly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1165 // setting a boolean content attribute,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1166 // since its presence should be enough
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1167 // http://bugs.jquery.com/ticket/12359
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1168 div.innerHTML = "<select t=''><option selected=''></option></select>";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1169
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1170 // Support: IE8, Opera 10-12
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1171 // Nothing should be selected when empty strings follow ^= or $= or *=
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1172 if ( div.querySelectorAll("[t^='']").length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1173 rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1174 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1175
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1176 // Support: IE8
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1177 // Boolean attributes and "value" are not treated correctly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1178 if ( !div.querySelectorAll("[selected]").length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1179 rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1180 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1181
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1182 // Webkit/Opera - :checked should return selected option elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1183 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1184 // IE8 throws error here and will not see later tests
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1185 if ( !div.querySelectorAll(":checked").length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1186 rbuggyQSA.push(":checked");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1187 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1188 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1189
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1190 assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1191 // Support: Windows 8 Native Apps
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1192 // The type and name attributes are restricted during .innerHTML assignment
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1193 var input = doc.createElement("input");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1194 input.setAttribute( "type", "hidden" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1195 div.appendChild( input ).setAttribute( "name", "D" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1196
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1197 // Support: IE8
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1198 // Enforce case-sensitivity of name attribute
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1199 if ( div.querySelectorAll("[name=d]").length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1200 rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1201 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1202
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1203 // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1204 // IE8 throws error here and will not see later tests
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1205 if ( !div.querySelectorAll(":enabled").length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1206 rbuggyQSA.push( ":enabled", ":disabled" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1207 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1208
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1209 // Opera 10-11 does not throw on post-comma invalid pseudos
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1210 div.querySelectorAll("*,:x");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1211 rbuggyQSA.push(",.*:");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1212 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1213 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1214
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1215 if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1216 docElem.mozMatchesSelector ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1217 docElem.oMatchesSelector ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1218 docElem.msMatchesSelector) )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1219
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1220 assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1221 // Check to see if it's possible to do matchesSelector
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1222 // on a disconnected node (IE 9)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1223 support.disconnectedMatch = matches.call( div, "div" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1224
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1225 // This should fail with an exception
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1226 // Gecko does not error, returns false instead
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1227 matches.call( div, "[s!='']:x" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1228 rbuggyMatches.push( "!=", pseudos );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1229 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1230 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1231
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1232 rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1233 rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1234
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1235 /* Contains
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1236 ---------------------------------------------------------------------- */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1237 hasCompare = rnative.test( docElem.compareDocumentPosition );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1238
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1239 // Element contains another
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1240 // Purposefully does not implement inclusive descendent
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1241 // As in, an element does not contain itself
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1242 contains = hasCompare || rnative.test( docElem.contains ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1243 function( a, b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1244 var adown = a.nodeType === 9 ? a.documentElement : a,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1245 bup = b && b.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1246 return a === bup || !!( bup && bup.nodeType === 1 && (
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1247 adown.contains ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1248 adown.contains( bup ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1249 a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1250 ));
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1251 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1252 function( a, b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1253 if ( b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1254 while ( (b = b.parentNode) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1255 if ( b === a ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1256 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1257 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1258 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1259 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1260 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1261 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1262
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1263 /* Sorting
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1264 ---------------------------------------------------------------------- */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1265
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1266 // Document order sorting
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1267 sortOrder = hasCompare ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1268 function( a, b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1269
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1270 // Flag for duplicate removal
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1271 if ( a === b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1272 hasDuplicate = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1273 return 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1274 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1275
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1276 // Sort on method existence if only one input has compareDocumentPosition
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1277 var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1278 if ( compare ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1279 return compare;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1280 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1281
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1282 // Calculate position if both inputs belong to the same document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1283 compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1284 a.compareDocumentPosition( b ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1285
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1286 // Otherwise we know they are disconnected
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1287 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1288
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1289 // Disconnected nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1290 if ( compare & 1 ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1291 (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1292
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1293 // Choose the first element that is related to our preferred document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1294 if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1295 return -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1296 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1297 if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1298 return 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1299 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1300
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1301 // Maintain original order
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1302 return sortInput ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1303 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1304 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1305 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1306
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1307 return compare & 4 ? -1 : 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1308 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1309 function( a, b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1310 // Exit early if the nodes are identical
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1311 if ( a === b ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1312 hasDuplicate = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1313 return 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1314 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1315
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1316 var cur,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1317 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1318 aup = a.parentNode,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1319 bup = b.parentNode,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1320 ap = [ a ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1321 bp = [ b ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1322
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1323 // Parentless nodes are either documents or disconnected
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1324 if ( !aup || !bup ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1325 return a === doc ? -1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1326 b === doc ? 1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1327 aup ? -1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1328 bup ? 1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1329 sortInput ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1330 ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1331 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1332
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1333 // If the nodes are siblings, we can do a quick check
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1334 } else if ( aup === bup ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1335 return siblingCheck( a, b );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1336 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1337
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1338 // Otherwise we need full lists of their ancestors for comparison
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1339 cur = a;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1340 while ( (cur = cur.parentNode) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1341 ap.unshift( cur );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1342 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1343 cur = b;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1344 while ( (cur = cur.parentNode) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1345 bp.unshift( cur );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1346 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1347
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1348 // Walk down the tree looking for a discrepancy
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1349 while ( ap[i] === bp[i] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1350 i++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1351 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1352
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1353 return i ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1354 // Do a sibling check if the nodes have a common ancestor
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1355 siblingCheck( ap[i], bp[i] ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1356
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1357 // Otherwise nodes in our document sort first
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1358 ap[i] === preferredDoc ? -1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1359 bp[i] === preferredDoc ? 1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1360 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1361 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1362
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1363 return doc;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1364 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1365
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1366 Sizzle.matches = function( expr, elements ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1367 return Sizzle( expr, null, null, elements );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1368 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1369
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1370 Sizzle.matchesSelector = function( elem, expr ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1371 // Set document vars if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1372 if ( ( elem.ownerDocument || elem ) !== document ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1373 setDocument( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1374 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1375
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1376 // Make sure that attribute selectors are quoted
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1377 expr = expr.replace( rattributeQuotes, "='$1']" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1378
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1379 if ( support.matchesSelector && documentIsHTML &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1380 ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1381 ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1382
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1383 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1384 var ret = matches.call( elem, expr );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1385
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1386 // IE 9's matchesSelector returns false on disconnected nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1387 if ( ret || support.disconnectedMatch ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1388 // As well, disconnected nodes are said to be in a document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1389 // fragment in IE 9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1390 elem.document && elem.document.nodeType !== 11 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1391 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1392 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1393 } catch(e) {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1394 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1395
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1396 return Sizzle( expr, document, null, [elem] ).length > 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1397 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1398
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1399 Sizzle.contains = function( context, elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1400 // Set document vars if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1401 if ( ( context.ownerDocument || context ) !== document ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1402 setDocument( context );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1403 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1404 return contains( context, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1405 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1406
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1407 Sizzle.attr = function( elem, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1408 // Set document vars if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1409 if ( ( elem.ownerDocument || elem ) !== document ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1410 setDocument( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1411 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1412
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1413 var fn = Expr.attrHandle[ name.toLowerCase() ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1414 // Don't get fooled by Object.prototype properties (jQuery #13807)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1415 val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1416 fn( elem, name, !documentIsHTML ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1417 undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1418
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1419 return val !== undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1420 val :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1421 support.attributes || !documentIsHTML ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1422 elem.getAttribute( name ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1423 (val = elem.getAttributeNode(name)) && val.specified ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1424 val.value :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1425 null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1426 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1427
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1428 Sizzle.error = function( msg ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1429 throw new Error( "Syntax error, unrecognized expression: " + msg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1430 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1431
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1432 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1433 * Document sorting and removing duplicates
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1434 * @param {ArrayLike} results
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1435 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1436 Sizzle.uniqueSort = function( results ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1437 var elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1438 duplicates = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1439 j = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1440 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1441
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1442 // Unless we *know* we can detect duplicates, assume their presence
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1443 hasDuplicate = !support.detectDuplicates;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1444 sortInput = !support.sortStable && results.slice( 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1445 results.sort( sortOrder );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1446
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1447 if ( hasDuplicate ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1448 while ( (elem = results[i++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1449 if ( elem === results[ i ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1450 j = duplicates.push( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1451 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1452 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1453 while ( j-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1454 results.splice( duplicates[ j ], 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1455 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1456 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1457
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1458 // Clear input after sorting to release objects
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1459 // See https://github.com/jquery/sizzle/pull/225
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1460 sortInput = null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1461
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1462 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1463 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1464
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1465 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1466 * Utility function for retrieving the text value of an array of DOM nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1467 * @param {Array|Element} elem
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1468 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1469 getText = Sizzle.getText = function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1470 var node,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1471 ret = "",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1472 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1473 nodeType = elem.nodeType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1474
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1475 if ( !nodeType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1476 // If no nodeType, this is expected to be an array
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1477 while ( (node = elem[i++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1478 // Do not traverse comment nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1479 ret += getText( node );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1480 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1481 } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1482 // Use textContent for elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1483 // innerText usage removed for consistency of new lines (jQuery #11153)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1484 if ( typeof elem.textContent === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1485 return elem.textContent;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1486 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1487 // Traverse its children
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1488 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1489 ret += getText( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1490 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1491 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1492 } else if ( nodeType === 3 || nodeType === 4 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1493 return elem.nodeValue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1494 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1495 // Do not include comment or processing instruction nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1496
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1497 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1498 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1499
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1500 Expr = Sizzle.selectors = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1501
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1502 // Can be adjusted by the user
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1503 cacheLength: 50,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1504
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1505 createPseudo: markFunction,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1506
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1507 match: matchExpr,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1508
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1509 attrHandle: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1510
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1511 find: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1512
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1513 relative: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1514 ">": { dir: "parentNode", first: true },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1515 " ": { dir: "parentNode" },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1516 "+": { dir: "previousSibling", first: true },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1517 "~": { dir: "previousSibling" }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1518 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1519
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1520 preFilter: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1521 "ATTR": function( match ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1522 match[1] = match[1].replace( runescape, funescape );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1523
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1524 // Move the given value to match[3] whether quoted or unquoted
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1525 match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1526
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1527 if ( match[2] === "~=" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1528 match[3] = " " + match[3] + " ";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1529 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1530
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1531 return match.slice( 0, 4 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1532 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1533
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1534 "CHILD": function( match ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1535 /* matches from matchExpr["CHILD"]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1536 1 type (only|nth|...)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1537 2 what (child|of-type)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1538 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1539 4 xn-component of xn+y argument ([+-]?\d*n|)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1540 5 sign of xn-component
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1541 6 x of xn-component
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1542 7 sign of y-component
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1543 8 y of y-component
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1544 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1545 match[1] = match[1].toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1546
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1547 if ( match[1].slice( 0, 3 ) === "nth" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1548 // nth-* requires argument
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1549 if ( !match[3] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1550 Sizzle.error( match[0] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1551 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1552
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1553 // numeric x and y parameters for Expr.filter.CHILD
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1554 // remember that false/true cast respectively to 0/1
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1555 match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1556 match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1557
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1558 // other types prohibit arguments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1559 } else if ( match[3] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1560 Sizzle.error( match[0] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1561 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1562
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1563 return match;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1564 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1565
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1566 "PSEUDO": function( match ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1567 var excess,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1568 unquoted = !match[5] && match[2];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1569
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1570 if ( matchExpr["CHILD"].test( match[0] ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1571 return null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1572 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1573
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1574 // Accept quoted arguments as-is
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1575 if ( match[3] && match[4] !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1576 match[2] = match[4];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1577
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1578 // Strip excess characters from unquoted arguments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1579 } else if ( unquoted && rpseudo.test( unquoted ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1580 // Get excess from tokenize (recursively)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1581 (excess = tokenize( unquoted, true )) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1582 // advance to the next closing parenthesis
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1583 (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1584
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1585 // excess is a negative index
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1586 match[0] = match[0].slice( 0, excess );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1587 match[2] = unquoted.slice( 0, excess );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1588 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1589
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1590 // Return only captures needed by the pseudo filter method (type and argument)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1591 return match.slice( 0, 3 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1592 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1593 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1594
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1595 filter: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1596
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1597 "TAG": function( nodeNameSelector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1598 var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1599 return nodeNameSelector === "*" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1600 function() { return true; } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1601 function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1602 return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1603 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1604 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1605
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1606 "CLASS": function( className ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1607 var pattern = classCache[ className + " " ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1608
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1609 return pattern ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1610 (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1611 classCache( className, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1612 return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1613 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1614 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1615
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1616 "ATTR": function( name, operator, check ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1617 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1618 var result = Sizzle.attr( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1619
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1620 if ( result == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1621 return operator === "!=";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1622 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1623 if ( !operator ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1624 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1625 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1626
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1627 result += "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1628
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1629 return operator === "=" ? result === check :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1630 operator === "!=" ? result !== check :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1631 operator === "^=" ? check && result.indexOf( check ) === 0 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1632 operator === "*=" ? check && result.indexOf( check ) > -1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1633 operator === "$=" ? check && result.slice( -check.length ) === check :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1634 operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1635 operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1636 false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1637 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1638 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1639
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1640 "CHILD": function( type, what, argument, first, last ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1641 var simple = type.slice( 0, 3 ) !== "nth",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1642 forward = type.slice( -4 ) !== "last",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1643 ofType = what === "of-type";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1644
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1645 return first === 1 && last === 0 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1646
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1647 // Shortcut for :nth-*(n)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1648 function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1649 return !!elem.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1650 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1651
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1652 function( elem, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1653 var cache, outerCache, node, diff, nodeIndex, start,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1654 dir = simple !== forward ? "nextSibling" : "previousSibling",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1655 parent = elem.parentNode,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1656 name = ofType && elem.nodeName.toLowerCase(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1657 useCache = !xml && !ofType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1658
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1659 if ( parent ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1660
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1661 // :(first|last|only)-(child|of-type)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1662 if ( simple ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1663 while ( dir ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1664 node = elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1665 while ( (node = node[ dir ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1666 if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1667 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1668 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1669 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1670 // Reverse direction for :only-* (if we haven't yet done so)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1671 start = dir = type === "only" && !start && "nextSibling";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1672 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1673 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1674 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1675
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1676 start = [ forward ? parent.firstChild : parent.lastChild ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1677
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1678 // non-xml :nth-child(...) stores cache data on `parent`
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1679 if ( forward && useCache ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1680 // Seek `elem` from a previously-cached index
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1681 outerCache = parent[ expando ] || (parent[ expando ] = {});
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1682 cache = outerCache[ type ] || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1683 nodeIndex = cache[0] === dirruns && cache[1];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1684 diff = cache[0] === dirruns && cache[2];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1685 node = nodeIndex && parent.childNodes[ nodeIndex ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1686
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1687 while ( (node = ++nodeIndex && node && node[ dir ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1688
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1689 // Fallback to seeking `elem` from the start
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1690 (diff = nodeIndex = 0) || start.pop()) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1691
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1692 // When found, cache indexes on `parent` and break
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1693 if ( node.nodeType === 1 && ++diff && node === elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1694 outerCache[ type ] = [ dirruns, nodeIndex, diff ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1695 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1696 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1697 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1698
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1699 // Use previously-cached element index if available
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1700 } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1701 diff = cache[1];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1702
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1703 // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1704 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1705 // Use the same loop as above to seek `elem` from the start
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1706 while ( (node = ++nodeIndex && node && node[ dir ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1707 (diff = nodeIndex = 0) || start.pop()) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1708
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1709 if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1710 // Cache the index of each encountered element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1711 if ( useCache ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1712 (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1713 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1714
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1715 if ( node === elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1716 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1717 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1718 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1719 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1720 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1721
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1722 // Incorporate the offset, then check against cycle size
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1723 diff -= last;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1724 return diff === first || ( diff % first === 0 && diff / first >= 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1725 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1726 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1727 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1728
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1729 "PSEUDO": function( pseudo, argument ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1730 // pseudo-class names are case-insensitive
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1731 // http://www.w3.org/TR/selectors/#pseudo-classes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1732 // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1733 // Remember that setFilters inherits from pseudos
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1734 var args,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1735 fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1736 Sizzle.error( "unsupported pseudo: " + pseudo );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1737
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1738 // The user may use createPseudo to indicate that
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1739 // arguments are needed to create the filter function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1740 // just as Sizzle does
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1741 if ( fn[ expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1742 return fn( argument );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1743 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1744
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1745 // But maintain support for old signatures
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1746 if ( fn.length > 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1747 args = [ pseudo, pseudo, "", argument ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1748 return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1749 markFunction(function( seed, matches ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1750 var idx,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1751 matched = fn( seed, argument ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1752 i = matched.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1753 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1754 idx = indexOf.call( seed, matched[i] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1755 seed[ idx ] = !( matches[ idx ] = matched[i] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1756 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1757 }) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1758 function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1759 return fn( elem, 0, args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1760 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1761 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1762
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1763 return fn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1764 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1765 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1766
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1767 pseudos: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1768 // Potentially complex pseudos
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1769 "not": markFunction(function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1770 // Trim the selector passed to compile
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1771 // to avoid treating leading and trailing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1772 // spaces as combinators
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1773 var input = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1774 results = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1775 matcher = compile( selector.replace( rtrim, "$1" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1776
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1777 return matcher[ expando ] ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1778 markFunction(function( seed, matches, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1779 var elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1780 unmatched = matcher( seed, null, xml, [] ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1781 i = seed.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1782
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1783 // Match elements unmatched by `matcher`
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1784 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1785 if ( (elem = unmatched[i]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1786 seed[i] = !(matches[i] = elem);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1787 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1788 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1789 }) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1790 function( elem, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1791 input[0] = elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1792 matcher( input, null, xml, results );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1793 return !results.pop();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1794 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1795 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1796
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1797 "has": markFunction(function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1798 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1799 return Sizzle( selector, elem ).length > 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1800 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1801 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1802
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1803 "contains": markFunction(function( text ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1804 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1805 return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1806 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1807 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1808
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1809 // "Whether an element is represented by a :lang() selector
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1810 // is based solely on the element's language value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1811 // being equal to the identifier C,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1812 // or beginning with the identifier C immediately followed by "-".
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1813 // The matching of C against the element's language value is performed case-insensitively.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1814 // The identifier C does not have to be a valid language name."
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1815 // http://www.w3.org/TR/selectors/#lang-pseudo
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1816 "lang": markFunction( function( lang ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1817 // lang value must be a valid identifier
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1818 if ( !ridentifier.test(lang || "") ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1819 Sizzle.error( "unsupported lang: " + lang );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1820 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1821 lang = lang.replace( runescape, funescape ).toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1822 return function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1823 var elemLang;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1824 do {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1825 if ( (elemLang = documentIsHTML ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1826 elem.lang :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1827 elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1828
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1829 elemLang = elemLang.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1830 return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1831 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1832 } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1833 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1834 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1835 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1836
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1837 // Miscellaneous
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1838 "target": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1839 var hash = window.location && window.location.hash;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1840 return hash && hash.slice( 1 ) === elem.id;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1841 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1842
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1843 "root": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1844 return elem === docElem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1845 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1846
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1847 "focus": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1848 return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1849 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1850
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1851 // Boolean properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1852 "enabled": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1853 return elem.disabled === false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1854 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1855
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1856 "disabled": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1857 return elem.disabled === true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1858 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1859
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1860 "checked": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1861 // In CSS3, :checked should return both checked and selected elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1862 // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1863 var nodeName = elem.nodeName.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1864 return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1865 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1866
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1867 "selected": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1868 // Accessing this property makes selected-by-default
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1869 // options in Safari work properly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1870 if ( elem.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1871 elem.parentNode.selectedIndex;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1872 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1873
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1874 return elem.selected === true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1875 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1876
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1877 // Contents
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1878 "empty": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1879 // http://www.w3.org/TR/selectors/#empty-pseudo
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1880 // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1881 // but not by others (comment: 8; processing instruction: 7; etc.)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1882 // nodeType < 6 works because attributes (2) do not appear as children
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1883 for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1884 if ( elem.nodeType < 6 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1885 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1886 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1887 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1888 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1889 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1890
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1891 "parent": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1892 return !Expr.pseudos["empty"]( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1893 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1894
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1895 // Element/input types
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1896 "header": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1897 return rheader.test( elem.nodeName );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1898 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1899
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1900 "input": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1901 return rinputs.test( elem.nodeName );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1902 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1903
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1904 "button": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1905 var name = elem.nodeName.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1906 return name === "input" && elem.type === "button" || name === "button";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1907 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1908
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1909 "text": function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1910 var attr;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1911 return elem.nodeName.toLowerCase() === "input" &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1912 elem.type === "text" &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1913
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1914 // Support: IE<8
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1915 // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1916 ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1917 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1918
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1919 // Position-in-collection
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1920 "first": createPositionalPseudo(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1921 return [ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1922 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1923
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1924 "last": createPositionalPseudo(function( matchIndexes, length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1925 return [ length - 1 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1926 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1927
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1928 "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1929 return [ argument < 0 ? argument + length : argument ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1930 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1931
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1932 "even": createPositionalPseudo(function( matchIndexes, length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1933 var i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1934 for ( ; i < length; i += 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1935 matchIndexes.push( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1936 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1937 return matchIndexes;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1938 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1939
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1940 "odd": createPositionalPseudo(function( matchIndexes, length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1941 var i = 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1942 for ( ; i < length; i += 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1943 matchIndexes.push( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1944 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1945 return matchIndexes;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1946 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1947
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1948 "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1949 var i = argument < 0 ? argument + length : argument;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1950 for ( ; --i >= 0; ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1951 matchIndexes.push( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1952 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1953 return matchIndexes;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1954 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1955
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1956 "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1957 var i = argument < 0 ? argument + length : argument;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1958 for ( ; ++i < length; ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1959 matchIndexes.push( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1960 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1961 return matchIndexes;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1962 })
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1963 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1964 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1965
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1966 Expr.pseudos["nth"] = Expr.pseudos["eq"];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1967
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1968 // Add button/input type pseudos
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1969 for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1970 Expr.pseudos[ i ] = createInputPseudo( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1971 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1972 for ( i in { submit: true, reset: true } ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1973 Expr.pseudos[ i ] = createButtonPseudo( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1974 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1975
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1976 // Easy API for creating new setFilters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1977 function setFilters() {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1978 setFilters.prototype = Expr.filters = Expr.pseudos;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1979 Expr.setFilters = new setFilters();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1980
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1981 function tokenize( selector, parseOnly ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1982 var matched, match, tokens, type,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1983 soFar, groups, preFilters,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1984 cached = tokenCache[ selector + " " ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1985
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1986 if ( cached ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1987 return parseOnly ? 0 : cached.slice( 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1988 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1989
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1990 soFar = selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1991 groups = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1992 preFilters = Expr.preFilter;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1993
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1994 while ( soFar ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1995
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1996 // Comma and first run
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1997 if ( !matched || (match = rcomma.exec( soFar )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1998 if ( match ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1999 // Don't consume trailing commas as valid
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2000 soFar = soFar.slice( match[0].length ) || soFar;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2001 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2002 groups.push( (tokens = []) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2003 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2004
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2005 matched = false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2006
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2007 // Combinators
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2008 if ( (match = rcombinators.exec( soFar )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2009 matched = match.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2010 tokens.push({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2011 value: matched,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2012 // Cast descendant combinators to space
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2013 type: match[0].replace( rtrim, " " )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2014 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2015 soFar = soFar.slice( matched.length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2016 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2017
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2018 // Filters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2019 for ( type in Expr.filter ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2020 if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2021 (match = preFilters[ type ]( match ))) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2022 matched = match.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2023 tokens.push({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2024 value: matched,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2025 type: type,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2026 matches: match
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2027 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2028 soFar = soFar.slice( matched.length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2029 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2030 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2031
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2032 if ( !matched ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2033 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2034 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2035 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2036
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2037 // Return the length of the invalid excess
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2038 // if we're just parsing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2039 // Otherwise, throw an error or return tokens
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2040 return parseOnly ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2041 soFar.length :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2042 soFar ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2043 Sizzle.error( selector ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2044 // Cache the tokens
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2045 tokenCache( selector, groups ).slice( 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2046 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2047
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2048 function toSelector( tokens ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2049 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2050 len = tokens.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2051 selector = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2052 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2053 selector += tokens[i].value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2054 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2055 return selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2056 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2057
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2058 function addCombinator( matcher, combinator, base ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2059 var dir = combinator.dir,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2060 checkNonElements = base && dir === "parentNode",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2061 doneName = done++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2062
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2063 return combinator.first ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2064 // Check against closest ancestor/preceding element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2065 function( elem, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2066 while ( (elem = elem[ dir ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2067 if ( elem.nodeType === 1 || checkNonElements ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2068 return matcher( elem, context, xml );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2069 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2070 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2071 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2072
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2073 // Check against all ancestor/preceding elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2074 function( elem, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2075 var oldCache, outerCache,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2076 newCache = [ dirruns, doneName ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2077
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2078 // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2079 if ( xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2080 while ( (elem = elem[ dir ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2081 if ( elem.nodeType === 1 || checkNonElements ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2082 if ( matcher( elem, context, xml ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2083 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2084 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2085 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2086 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2087 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2088 while ( (elem = elem[ dir ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2089 if ( elem.nodeType === 1 || checkNonElements ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2090 outerCache = elem[ expando ] || (elem[ expando ] = {});
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2091 if ( (oldCache = outerCache[ dir ]) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2092 oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2093
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2094 // Assign to newCache so results back-propagate to previous elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2095 return (newCache[ 2 ] = oldCache[ 2 ]);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2096 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2097 // Reuse newcache so results back-propagate to previous elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2098 outerCache[ dir ] = newCache;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2099
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2100 // A match means we're done; a fail means we have to keep checking
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2101 if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2102 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2103 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2104 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2105 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2106 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2107 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2108 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2109 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2110
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2111 function elementMatcher( matchers ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2112 return matchers.length > 1 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2113 function( elem, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2114 var i = matchers.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2115 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2116 if ( !matchers[i]( elem, context, xml ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2117 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2118 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2119 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2120 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2121 } :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2122 matchers[0];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2123 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2124
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2125 function condense( unmatched, map, filter, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2126 var elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2127 newUnmatched = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2128 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2129 len = unmatched.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2130 mapped = map != null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2131
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2132 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2133 if ( (elem = unmatched[i]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2134 if ( !filter || filter( elem, context, xml ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2135 newUnmatched.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2136 if ( mapped ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2137 map.push( i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2138 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2139 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2140 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2141 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2142
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2143 return newUnmatched;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2144 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2145
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2146 function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2147 if ( postFilter && !postFilter[ expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2148 postFilter = setMatcher( postFilter );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2149 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2150 if ( postFinder && !postFinder[ expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2151 postFinder = setMatcher( postFinder, postSelector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2152 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2153 return markFunction(function( seed, results, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2154 var temp, i, elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2155 preMap = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2156 postMap = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2157 preexisting = results.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2158
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2159 // Get initial elements from seed or context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2160 elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2161
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2162 // Prefilter to get matcher input, preserving a map for seed-results synchronization
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2163 matcherIn = preFilter && ( seed || !selector ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2164 condense( elems, preMap, preFilter, context, xml ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2165 elems,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2166
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2167 matcherOut = matcher ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2168 // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2169 postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2170
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2171 // ...intermediate processing is necessary
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2172 [] :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2173
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2174 // ...otherwise use results directly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2175 results :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2176 matcherIn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2177
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2178 // Find primary matches
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2179 if ( matcher ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2180 matcher( matcherIn, matcherOut, context, xml );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2181 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2182
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2183 // Apply postFilter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2184 if ( postFilter ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2185 temp = condense( matcherOut, postMap );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2186 postFilter( temp, [], context, xml );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2187
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2188 // Un-match failing elements by moving them back to matcherIn
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2189 i = temp.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2190 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2191 if ( (elem = temp[i]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2192 matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2193 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2194 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2195 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2196
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2197 if ( seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2198 if ( postFinder || preFilter ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2199 if ( postFinder ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2200 // Get the final matcherOut by condensing this intermediate into postFinder contexts
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2201 temp = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2202 i = matcherOut.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2203 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2204 if ( (elem = matcherOut[i]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2205 // Restore matcherIn since elem is not yet a final match
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2206 temp.push( (matcherIn[i] = elem) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2207 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2208 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2209 postFinder( null, (matcherOut = []), temp, xml );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2210 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2211
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2212 // Move matched elements from seed to results to keep them synchronized
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2213 i = matcherOut.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2214 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2215 if ( (elem = matcherOut[i]) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2216 (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2217
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2218 seed[temp] = !(results[temp] = elem);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2219 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2220 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2221 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2222
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2223 // Add elements to results, through postFinder if defined
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2224 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2225 matcherOut = condense(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2226 matcherOut === results ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2227 matcherOut.splice( preexisting, matcherOut.length ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2228 matcherOut
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2229 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2230 if ( postFinder ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2231 postFinder( null, results, matcherOut, xml );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2232 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2233 push.apply( results, matcherOut );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2234 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2235 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2236 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2237 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2238
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2239 function matcherFromTokens( tokens ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2240 var checkContext, matcher, j,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2241 len = tokens.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2242 leadingRelative = Expr.relative[ tokens[0].type ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2243 implicitRelative = leadingRelative || Expr.relative[" "],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2244 i = leadingRelative ? 1 : 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2245
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2246 // The foundational matcher ensures that elements are reachable from top-level context(s)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2247 matchContext = addCombinator( function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2248 return elem === checkContext;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2249 }, implicitRelative, true ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2250 matchAnyContext = addCombinator( function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2251 return indexOf.call( checkContext, elem ) > -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2252 }, implicitRelative, true ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2253 matchers = [ function( elem, context, xml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2254 return ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2255 (checkContext = context).nodeType ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2256 matchContext( elem, context, xml ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2257 matchAnyContext( elem, context, xml ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2258 } ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2259
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2260 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2261 if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2262 matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2263 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2264 matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2265
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2266 // Return special upon seeing a positional matcher
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2267 if ( matcher[ expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2268 // Find the next relative operator (if any) for proper handling
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2269 j = ++i;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2270 for ( ; j < len; j++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2271 if ( Expr.relative[ tokens[j].type ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2272 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2273 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2274 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2275 return setMatcher(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2276 i > 1 && elementMatcher( matchers ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2277 i > 1 && toSelector(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2278 // If the preceding token was a descendant combinator, insert an implicit any-element `*`
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2279 tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2280 ).replace( rtrim, "$1" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2281 matcher,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2282 i < j && matcherFromTokens( tokens.slice( i, j ) ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2283 j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2284 j < len && toSelector( tokens )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2285 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2286 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2287 matchers.push( matcher );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2288 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2289 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2290
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2291 return elementMatcher( matchers );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2292 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2293
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2294 function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2295 var bySet = setMatchers.length > 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2296 byElement = elementMatchers.length > 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2297 superMatcher = function( seed, context, xml, results, outermost ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2298 var elem, j, matcher,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2299 matchedCount = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2300 i = "0",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2301 unmatched = seed && [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2302 setMatched = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2303 contextBackup = outermostContext,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2304 // We must always have either seed elements or outermost context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2305 elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2306 // Use integer dirruns iff this is the outermost matcher
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2307 dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2308 len = elems.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2309
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2310 if ( outermost ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2311 outermostContext = context !== document && context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2312 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2313
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2314 // Add elements passing elementMatchers directly to results
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2315 // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2316 // Support: IE<9, Safari
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2317 // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2318 for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2319 if ( byElement && elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2320 j = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2321 while ( (matcher = elementMatchers[j++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2322 if ( matcher( elem, context, xml ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2323 results.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2324 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2325 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2326 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2327 if ( outermost ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2328 dirruns = dirrunsUnique;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2329 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2330 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2331
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2332 // Track unmatched elements for set filters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2333 if ( bySet ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2334 // They will have gone through all possible matchers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2335 if ( (elem = !matcher && elem) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2336 matchedCount--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2337 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2338
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2339 // Lengthen the array for every element, matched or not
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2340 if ( seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2341 unmatched.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2342 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2343 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2344 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2345
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2346 // Apply set filters to unmatched elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2347 matchedCount += i;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2348 if ( bySet && i !== matchedCount ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2349 j = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2350 while ( (matcher = setMatchers[j++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2351 matcher( unmatched, setMatched, context, xml );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2352 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2353
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2354 if ( seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2355 // Reintegrate element matches to eliminate the need for sorting
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2356 if ( matchedCount > 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2357 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2358 if ( !(unmatched[i] || setMatched[i]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2359 setMatched[i] = pop.call( results );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2360 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2361 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2362 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2363
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2364 // Discard index placeholder values to get only actual matches
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2365 setMatched = condense( setMatched );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2366 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2367
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2368 // Add matches to results
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2369 push.apply( results, setMatched );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2370
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2371 // Seedless set matches succeeding multiple successful matchers stipulate sorting
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2372 if ( outermost && !seed && setMatched.length > 0 &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2373 ( matchedCount + setMatchers.length ) > 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2374
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2375 Sizzle.uniqueSort( results );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2376 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2377 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2378
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2379 // Override manipulation of globals by nested matchers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2380 if ( outermost ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2381 dirruns = dirrunsUnique;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2382 outermostContext = contextBackup;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2383 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2384
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2385 return unmatched;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2386 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2387
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2388 return bySet ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2389 markFunction( superMatcher ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2390 superMatcher;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2391 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2392
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2393 compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2394 var i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2395 setMatchers = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2396 elementMatchers = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2397 cached = compilerCache[ selector + " " ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2398
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2399 if ( !cached ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2400 // Generate a function of recursive functions that can be used to check each element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2401 if ( !group ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2402 group = tokenize( selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2403 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2404 i = group.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2405 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2406 cached = matcherFromTokens( group[i] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2407 if ( cached[ expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2408 setMatchers.push( cached );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2409 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2410 elementMatchers.push( cached );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2411 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2412 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2413
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2414 // Cache the compiled function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2415 cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2416 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2417 return cached;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2418 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2419
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2420 function multipleContexts( selector, contexts, results ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2421 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2422 len = contexts.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2423 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2424 Sizzle( selector, contexts[i], results );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2425 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2426 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2427 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2428
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2429 function select( selector, context, results, seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2430 var i, tokens, token, type, find,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2431 match = tokenize( selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2432
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2433 if ( !seed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2434 // Try to minimize operations if there is only one group
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2435 if ( match.length === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2436
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2437 // Take a shortcut and set the context if the root selector is an ID
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2438 tokens = match[0] = match[0].slice( 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2439 if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2440 support.getById && context.nodeType === 9 && documentIsHTML &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2441 Expr.relative[ tokens[1].type ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2442
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2443 context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2444 if ( !context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2445 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2446 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2447 selector = selector.slice( tokens.shift().value.length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2448 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2449
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2450 // Fetch a seed set for right-to-left matching
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2451 i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2452 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2453 token = tokens[i];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2454
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2455 // Abort if we hit a combinator
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2456 if ( Expr.relative[ (type = token.type) ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2457 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2458 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2459 if ( (find = Expr.find[ type ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2460 // Search, expanding context for leading sibling combinators
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2461 if ( (seed = find(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2462 token.matches[0].replace( runescape, funescape ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2463 rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2464 )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2465
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2466 // If seed is empty or no tokens remain, we can return early
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2467 tokens.splice( i, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2468 selector = seed.length && toSelector( tokens );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2469 if ( !selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2470 push.apply( results, seed );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2471 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2472 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2473
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2474 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2475 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2476 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2477 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2478 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2479 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2480
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2481 // Compile and execute a filtering function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2482 // Provide `match` to avoid retokenization if we modified the selector above
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2483 compile( selector, match )(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2484 seed,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2485 context,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2486 !documentIsHTML,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2487 results,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2488 rsibling.test( selector ) && testContext( context.parentNode ) || context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2489 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2490 return results;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2491 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2492
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2493 // One-time assignments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2494
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2495 // Sort stability
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2496 support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2497
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2498 // Support: Chrome<14
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2499 // Always assume duplicates if they aren't passed to the comparison function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2500 support.detectDuplicates = !!hasDuplicate;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2501
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2502 // Initialize against the default document
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2503 setDocument();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2504
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2505 // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2506 // Detached nodes confoundingly follow *each other*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2507 support.sortDetached = assert(function( div1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2508 // Should return 1, but returns 4 (following)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2509 return div1.compareDocumentPosition( document.createElement("div") ) & 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2510 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2511
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2512 // Support: IE<8
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2513 // Prevent attribute/property "interpolation"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2514 // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2515 if ( !assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2516 div.innerHTML = "<a href='#'></a>";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2517 return div.firstChild.getAttribute("href") === "#" ;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2518 }) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2519 addHandle( "type|href|height|width", function( elem, name, isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2520 if ( !isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2521 return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2522 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2523 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2524 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2525
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2526 // Support: IE<9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2527 // Use defaultValue in place of getAttribute("value")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2528 if ( !support.attributes || !assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2529 div.innerHTML = "<input/>";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2530 div.firstChild.setAttribute( "value", "" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2531 return div.firstChild.getAttribute( "value" ) === "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2532 }) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2533 addHandle( "value", function( elem, name, isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2534 if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2535 return elem.defaultValue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2536 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2537 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2538 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2539
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2540 // Support: IE<9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2541 // Use getAttributeNode to fetch booleans when getAttribute lies
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2542 if ( !assert(function( div ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2543 return div.getAttribute("disabled") == null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2544 }) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2545 addHandle( booleans, function( elem, name, isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2546 var val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2547 if ( !isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2548 return elem[ name ] === true ? name.toLowerCase() :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2549 (val = elem.getAttributeNode( name )) && val.specified ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2550 val.value :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2551 null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2552 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2553 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2554 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2555
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2556 return Sizzle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2557
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2558 })( window );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2559
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2560
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2561
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2562 jQuery.find = Sizzle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2563 jQuery.expr = Sizzle.selectors;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2564 jQuery.expr[":"] = jQuery.expr.pseudos;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2565 jQuery.unique = Sizzle.uniqueSort;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2566 jQuery.text = Sizzle.getText;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2567 jQuery.isXMLDoc = Sizzle.isXML;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2568 jQuery.contains = Sizzle.contains;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2569
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2570
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2571
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2572 var rneedsContext = jQuery.expr.match.needsContext;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2573
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2574 var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2575
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2576
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2577
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2578 var risSimple = /^.[^:#\[\.,]*$/;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2579
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2580 // Implement the identical functionality for filter and not
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2581 function winnow( elements, qualifier, not ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2582 if ( jQuery.isFunction( qualifier ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2583 return jQuery.grep( elements, function( elem, i ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2584 /* jshint -W018 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2585 return !!qualifier.call( elem, i, elem ) !== not;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2586 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2587
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2588 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2589
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2590 if ( qualifier.nodeType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2591 return jQuery.grep( elements, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2592 return ( elem === qualifier ) !== not;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2593 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2594
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2595 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2596
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2597 if ( typeof qualifier === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2598 if ( risSimple.test( qualifier ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2599 return jQuery.filter( qualifier, elements, not );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2600 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2601
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2602 qualifier = jQuery.filter( qualifier, elements );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2603 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2604
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2605 return jQuery.grep( elements, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2606 return ( indexOf.call( qualifier, elem ) >= 0 ) !== not;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2607 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2608 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2609
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2610 jQuery.filter = function( expr, elems, not ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2611 var elem = elems[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2612
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2613 if ( not ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2614 expr = ":not(" + expr + ")";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2615 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2616
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2617 return elems.length === 1 && elem.nodeType === 1 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2618 jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2619 jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2620 return elem.nodeType === 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2621 }));
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2622 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2623
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2624 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2625 find: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2626 var i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2627 len = this.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2628 ret = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2629 self = this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2630
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2631 if ( typeof selector !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2632 return this.pushStack( jQuery( selector ).filter(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2633 for ( i = 0; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2634 if ( jQuery.contains( self[ i ], this ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2635 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2636 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2637 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2638 }) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2639 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2640
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2641 for ( i = 0; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2642 jQuery.find( selector, self[ i ], ret );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2643 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2644
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2645 // Needed because $( selector, context ) becomes $( context ).find( selector )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2646 ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2647 ret.selector = this.selector ? this.selector + " " + selector : selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2648 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2649 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2650 filter: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2651 return this.pushStack( winnow(this, selector || [], false) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2652 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2653 not: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2654 return this.pushStack( winnow(this, selector || [], true) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2655 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2656 is: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2657 return !!winnow(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2658 this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2659
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2660 // If this is a positional/relative selector, check membership in the returned set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2661 // so $("p:first").is("p:last") won't return true for a doc with two "p".
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2662 typeof selector === "string" && rneedsContext.test( selector ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2663 jQuery( selector ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2664 selector || [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2665 false
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2666 ).length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2667 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2668 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2669
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2670
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2671 // Initialize a jQuery object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2672
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2673
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2674 // A central reference to the root jQuery(document)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2675 var rootjQuery,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2676
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2677 // A simple way to check for HTML strings
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2678 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2679 // Strict HTML recognition (#11290: must start with <)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2680 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2681
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2682 init = jQuery.fn.init = function( selector, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2683 var match, elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2684
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2685 // HANDLE: $(""), $(null), $(undefined), $(false)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2686 if ( !selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2687 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2688 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2689
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2690 // Handle HTML strings
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2691 if ( typeof selector === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2692 if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2693 // Assume that strings that start and end with <> are HTML and skip the regex check
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2694 match = [ null, selector, null ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2695
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2696 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2697 match = rquickExpr.exec( selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2698 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2699
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2700 // Match html or make sure no context is specified for #id
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2701 if ( match && (match[1] || !context) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2702
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2703 // HANDLE: $(html) -> $(array)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2704 if ( match[1] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2705 context = context instanceof jQuery ? context[0] : context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2706
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2707 // scripts is true for back-compat
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2708 // Intentionally let the error be thrown if parseHTML is not present
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2709 jQuery.merge( this, jQuery.parseHTML(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2710 match[1],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2711 context && context.nodeType ? context.ownerDocument || context : document,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2712 true
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2713 ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2714
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2715 // HANDLE: $(html, props)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2716 if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2717 for ( match in context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2718 // Properties of context are called as methods if possible
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2719 if ( jQuery.isFunction( this[ match ] ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2720 this[ match ]( context[ match ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2721
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2722 // ...and otherwise set as attributes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2723 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2724 this.attr( match, context[ match ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2725 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2726 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2727 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2728
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2729 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2730
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2731 // HANDLE: $(#id)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2732 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2733 elem = document.getElementById( match[2] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2734
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2735 // Check parentNode to catch when Blackberry 4.6 returns
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2736 // nodes that are no longer in the document #6963
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2737 if ( elem && elem.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2738 // Inject the element directly into the jQuery object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2739 this.length = 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2740 this[0] = elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2741 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2742
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2743 this.context = document;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2744 this.selector = selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2745 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2746 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2747
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2748 // HANDLE: $(expr, $(...))
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2749 } else if ( !context || context.jquery ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2750 return ( context || rootjQuery ).find( selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2751
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2752 // HANDLE: $(expr, context)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2753 // (which is just equivalent to: $(context).find(expr)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2754 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2755 return this.constructor( context ).find( selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2756 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2757
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2758 // HANDLE: $(DOMElement)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2759 } else if ( selector.nodeType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2760 this.context = this[0] = selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2761 this.length = 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2762 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2763
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2764 // HANDLE: $(function)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2765 // Shortcut for document ready
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2766 } else if ( jQuery.isFunction( selector ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2767 return typeof rootjQuery.ready !== "undefined" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2768 rootjQuery.ready( selector ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2769 // Execute immediately if ready is not present
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2770 selector( jQuery );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2771 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2772
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2773 if ( selector.selector !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2774 this.selector = selector.selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2775 this.context = selector.context;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2776 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2777
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2778 return jQuery.makeArray( selector, this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2779 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2780
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2781 // Give the init function the jQuery prototype for later instantiation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2782 init.prototype = jQuery.fn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2783
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2784 // Initialize central reference
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2785 rootjQuery = jQuery( document );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2786
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2787
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2788 var rparentsprev = /^(?:parents|prev(?:Until|All))/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2789 // methods guaranteed to produce a unique set when starting from a unique set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2790 guaranteedUnique = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2791 children: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2792 contents: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2793 next: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2794 prev: true
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2795 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2796
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2797 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2798 dir: function( elem, dir, until ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2799 var matched = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2800 truncate = until !== undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2801
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2802 while ( (elem = elem[ dir ]) && elem.nodeType !== 9 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2803 if ( elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2804 if ( truncate && jQuery( elem ).is( until ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2805 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2806 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2807 matched.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2808 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2809 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2810 return matched;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2811 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2812
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2813 sibling: function( n, elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2814 var matched = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2815
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2816 for ( ; n; n = n.nextSibling ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2817 if ( n.nodeType === 1 && n !== elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2818 matched.push( n );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2819 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2820 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2821
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2822 return matched;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2823 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2824 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2825
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2826 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2827 has: function( target ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2828 var targets = jQuery( target, this ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2829 l = targets.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2830
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2831 return this.filter(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2832 var i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2833 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2834 if ( jQuery.contains( this, targets[i] ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2835 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2836 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2837 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2838 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2839 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2840
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2841 closest: function( selectors, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2842 var cur,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2843 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2844 l = this.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2845 matched = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2846 pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2847 jQuery( selectors, context || this.context ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2848 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2849
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2850 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2851 for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2852 // Always skip document fragments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2853 if ( cur.nodeType < 11 && (pos ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2854 pos.index(cur) > -1 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2855
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2856 // Don't pass non-elements to Sizzle
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2857 cur.nodeType === 1 &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2858 jQuery.find.matchesSelector(cur, selectors)) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2859
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2860 matched.push( cur );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2861 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2862 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2863 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2864 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2865
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2866 return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2867 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2868
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2869 // Determine the position of an element within
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2870 // the matched set of elements
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2871 index: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2872
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2873 // No argument, return index in parent
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2874 if ( !elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2875 return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2876 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2877
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2878 // index in selector
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2879 if ( typeof elem === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2880 return indexOf.call( jQuery( elem ), this[ 0 ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2881 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2882
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2883 // Locate the position of the desired element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2884 return indexOf.call( this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2885
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2886 // If it receives a jQuery object, the first element is used
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2887 elem.jquery ? elem[ 0 ] : elem
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2888 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2889 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2890
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2891 add: function( selector, context ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2892 return this.pushStack(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2893 jQuery.unique(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2894 jQuery.merge( this.get(), jQuery( selector, context ) )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2895 )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2896 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2897 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2898
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2899 addBack: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2900 return this.add( selector == null ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2901 this.prevObject : this.prevObject.filter(selector)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2902 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2903 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2904 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2905
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2906 function sibling( cur, dir ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2907 while ( (cur = cur[dir]) && cur.nodeType !== 1 ) {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2908 return cur;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2909 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2910
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2911 jQuery.each({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2912 parent: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2913 var parent = elem.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2914 return parent && parent.nodeType !== 11 ? parent : null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2915 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2916 parents: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2917 return jQuery.dir( elem, "parentNode" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2918 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2919 parentsUntil: function( elem, i, until ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2920 return jQuery.dir( elem, "parentNode", until );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2921 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2922 next: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2923 return sibling( elem, "nextSibling" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2924 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2925 prev: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2926 return sibling( elem, "previousSibling" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2927 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2928 nextAll: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2929 return jQuery.dir( elem, "nextSibling" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2930 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2931 prevAll: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2932 return jQuery.dir( elem, "previousSibling" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2933 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2934 nextUntil: function( elem, i, until ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2935 return jQuery.dir( elem, "nextSibling", until );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2936 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2937 prevUntil: function( elem, i, until ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2938 return jQuery.dir( elem, "previousSibling", until );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2939 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2940 siblings: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2941 return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2942 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2943 children: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2944 return jQuery.sibling( elem.firstChild );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2945 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2946 contents: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2947 return elem.contentDocument || jQuery.merge( [], elem.childNodes );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2948 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2949 }, function( name, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2950 jQuery.fn[ name ] = function( until, selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2951 var matched = jQuery.map( this, fn, until );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2952
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2953 if ( name.slice( -5 ) !== "Until" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2954 selector = until;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2955 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2956
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2957 if ( selector && typeof selector === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2958 matched = jQuery.filter( selector, matched );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2959 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2960
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2961 if ( this.length > 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2962 // Remove duplicates
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2963 if ( !guaranteedUnique[ name ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2964 jQuery.unique( matched );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2965 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2966
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2967 // Reverse order for parents* and prev-derivatives
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2968 if ( rparentsprev.test( name ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2969 matched.reverse();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2970 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2971 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2972
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2973 return this.pushStack( matched );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2974 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2975 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2976 var rnotwhite = (/\S+/g);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2977
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2978
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2979
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2980 // String to Object options format cache
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2981 var optionsCache = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2982
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2983 // Convert String-formatted options into Object-formatted ones and store in cache
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2984 function createOptions( options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2985 var object = optionsCache[ options ] = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2986 jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2987 object[ flag ] = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2988 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2989 return object;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2990 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2991
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2992 /*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2993 * Create a callback list using the following parameters:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2994 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2995 * options: an optional list of space-separated options that will change how
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2996 * the callback list behaves or a more traditional option object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2997 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2998 * By default a callback list will act like an event callback list and can be
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2999 * "fired" multiple times.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3000 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3001 * Possible options:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3002 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3003 * once: will ensure the callback list can only be fired once (like a Deferred)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3004 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3005 * memory: will keep track of previous values and will call any callback added
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3006 * after the list has been fired right away with the latest "memorized"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3007 * values (like a Deferred)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3008 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3009 * unique: will ensure a callback can only be added once (no duplicate in the list)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3010 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3011 * stopOnFalse: interrupt callings when a callback returns false
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3012 *
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3013 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3014 jQuery.Callbacks = function( options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3015
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3016 // Convert options from String-formatted to Object-formatted if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3017 // (we check in cache first)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3018 options = typeof options === "string" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3019 ( optionsCache[ options ] || createOptions( options ) ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3020 jQuery.extend( {}, options );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3021
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3022 var // Last fire value (for non-forgettable lists)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3023 memory,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3024 // Flag to know if list was already fired
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3025 fired,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3026 // Flag to know if list is currently firing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3027 firing,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3028 // First callback to fire (used internally by add and fireWith)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3029 firingStart,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3030 // End of the loop when firing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3031 firingLength,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3032 // Index of currently firing callback (modified by remove if needed)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3033 firingIndex,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3034 // Actual callback list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3035 list = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3036 // Stack of fire calls for repeatable lists
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3037 stack = !options.once && [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3038 // Fire callbacks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3039 fire = function( data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3040 memory = options.memory && data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3041 fired = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3042 firingIndex = firingStart || 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3043 firingStart = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3044 firingLength = list.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3045 firing = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3046 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3047 if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3048 memory = false; // To prevent further calls using add
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3049 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3050 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3051 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3052 firing = false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3053 if ( list ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3054 if ( stack ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3055 if ( stack.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3056 fire( stack.shift() );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3057 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3058 } else if ( memory ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3059 list = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3060 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3061 self.disable();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3062 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3063 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3064 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3065 // Actual Callbacks object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3066 self = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3067 // Add a callback or a collection of callbacks to the list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3068 add: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3069 if ( list ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3070 // First, we save the current length
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3071 var start = list.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3072 (function add( args ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3073 jQuery.each( args, function( _, arg ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3074 var type = jQuery.type( arg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3075 if ( type === "function" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3076 if ( !options.unique || !self.has( arg ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3077 list.push( arg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3078 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3079 } else if ( arg && arg.length && type !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3080 // Inspect recursively
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3081 add( arg );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3082 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3083 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3084 })( arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3085 // Do we need to add the callbacks to the
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3086 // current firing batch?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3087 if ( firing ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3088 firingLength = list.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3089 // With memory, if we're not firing then
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3090 // we should call right away
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3091 } else if ( memory ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3092 firingStart = start;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3093 fire( memory );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3094 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3095 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3096 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3097 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3098 // Remove a callback from the list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3099 remove: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3100 if ( list ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3101 jQuery.each( arguments, function( _, arg ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3102 var index;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3103 while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3104 list.splice( index, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3105 // Handle firing indexes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3106 if ( firing ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3107 if ( index <= firingLength ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3108 firingLength--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3109 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3110 if ( index <= firingIndex ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3111 firingIndex--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3112 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3113 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3114 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3115 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3116 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3117 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3118 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3119 // Check if a given callback is in the list.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3120 // If no argument is given, return whether or not list has callbacks attached.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3121 has: function( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3122 return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3123 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3124 // Remove all callbacks from the list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3125 empty: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3126 list = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3127 firingLength = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3128 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3129 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3130 // Have the list do nothing anymore
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3131 disable: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3132 list = stack = memory = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3133 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3134 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3135 // Is it disabled?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3136 disabled: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3137 return !list;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3138 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3139 // Lock the list in its current state
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3140 lock: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3141 stack = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3142 if ( !memory ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3143 self.disable();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3144 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3145 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3146 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3147 // Is it locked?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3148 locked: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3149 return !stack;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3150 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3151 // Call all callbacks with the given context and arguments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3152 fireWith: function( context, args ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3153 if ( list && ( !fired || stack ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3154 args = args || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3155 args = [ context, args.slice ? args.slice() : args ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3156 if ( firing ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3157 stack.push( args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3158 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3159 fire( args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3160 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3161 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3162 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3163 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3164 // Call all the callbacks with the given arguments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3165 fire: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3166 self.fireWith( this, arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3167 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3168 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3169 // To know if the callbacks have already been called at least once
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3170 fired: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3171 return !!fired;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3172 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3173 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3174
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3175 return self;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3176 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3177
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3178
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3179 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3180
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3181 Deferred: function( func ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3182 var tuples = [
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3183 // action, add listener, listener list, final state
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3184 [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3185 [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3186 [ "notify", "progress", jQuery.Callbacks("memory") ]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3187 ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3188 state = "pending",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3189 promise = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3190 state: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3191 return state;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3192 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3193 always: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3194 deferred.done( arguments ).fail( arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3195 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3196 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3197 then: function( /* fnDone, fnFail, fnProgress */ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3198 var fns = arguments;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3199 return jQuery.Deferred(function( newDefer ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3200 jQuery.each( tuples, function( i, tuple ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3201 var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3202 // deferred[ done | fail | progress ] for forwarding actions to newDefer
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3203 deferred[ tuple[1] ](function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3204 var returned = fn && fn.apply( this, arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3205 if ( returned && jQuery.isFunction( returned.promise ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3206 returned.promise()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3207 .done( newDefer.resolve )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3208 .fail( newDefer.reject )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3209 .progress( newDefer.notify );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3210 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3211 newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3212 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3213 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3214 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3215 fns = null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3216 }).promise();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3217 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3218 // Get a promise for this deferred
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3219 // If obj is provided, the promise aspect is added to the object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3220 promise: function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3221 return obj != null ? jQuery.extend( obj, promise ) : promise;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3222 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3223 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3224 deferred = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3225
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3226 // Keep pipe for back-compat
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3227 promise.pipe = promise.then;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3228
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3229 // Add list-specific methods
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3230 jQuery.each( tuples, function( i, tuple ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3231 var list = tuple[ 2 ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3232 stateString = tuple[ 3 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3233
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3234 // promise[ done | fail | progress ] = list.add
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3235 promise[ tuple[1] ] = list.add;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3236
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3237 // Handle state
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3238 if ( stateString ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3239 list.add(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3240 // state = [ resolved | rejected ]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3241 state = stateString;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3242
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3243 // [ reject_list | resolve_list ].disable; progress_list.lock
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3244 }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3245 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3246
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3247 // deferred[ resolve | reject | notify ]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3248 deferred[ tuple[0] ] = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3249 deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3250 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3251 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3252 deferred[ tuple[0] + "With" ] = list.fireWith;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3253 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3254
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3255 // Make the deferred a promise
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3256 promise.promise( deferred );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3257
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3258 // Call given func if any
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3259 if ( func ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3260 func.call( deferred, deferred );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3261 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3262
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3263 // All done!
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3264 return deferred;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3265 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3266
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3267 // Deferred helper
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3268 when: function( subordinate /* , ..., subordinateN */ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3269 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3270 resolveValues = slice.call( arguments ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3271 length = resolveValues.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3272
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3273 // the count of uncompleted subordinates
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3274 remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3275
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3276 // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3277 deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3278
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3279 // Update function for both resolve and progress values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3280 updateFunc = function( i, contexts, values ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3281 return function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3282 contexts[ i ] = this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3283 values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3284 if ( values === progressValues ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3285 deferred.notifyWith( contexts, values );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3286 } else if ( !( --remaining ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3287 deferred.resolveWith( contexts, values );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3288 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3289 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3290 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3291
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3292 progressValues, progressContexts, resolveContexts;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3293
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3294 // add listeners to Deferred subordinates; treat others as resolved
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3295 if ( length > 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3296 progressValues = new Array( length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3297 progressContexts = new Array( length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3298 resolveContexts = new Array( length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3299 for ( ; i < length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3300 if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3301 resolveValues[ i ].promise()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3302 .done( updateFunc( i, resolveContexts, resolveValues ) )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3303 .fail( deferred.reject )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3304 .progress( updateFunc( i, progressContexts, progressValues ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3305 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3306 --remaining;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3307 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3308 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3309 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3310
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3311 // if we're not waiting on anything, resolve the master
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3312 if ( !remaining ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3313 deferred.resolveWith( resolveContexts, resolveValues );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3314 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3315
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3316 return deferred.promise();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3317 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3318 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3319
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3320
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3321 // The deferred used on DOM ready
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3322 var readyList;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3323
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3324 jQuery.fn.ready = function( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3325 // Add the callback
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3326 jQuery.ready.promise().done( fn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3327
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3328 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3329 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3330
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3331 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3332 // Is the DOM ready to be used? Set to true once it occurs.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3333 isReady: false,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3334
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3335 // A counter to track how many items to wait for before
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3336 // the ready event fires. See #6781
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3337 readyWait: 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3338
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3339 // Hold (or release) the ready event
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3340 holdReady: function( hold ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3341 if ( hold ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3342 jQuery.readyWait++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3343 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3344 jQuery.ready( true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3345 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3346 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3347
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3348 // Handle when the DOM is ready
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3349 ready: function( wait ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3350
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3351 // Abort if there are pending holds or we're already ready
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3352 if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3353 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3354 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3355
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3356 // Remember that the DOM is ready
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3357 jQuery.isReady = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3358
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3359 // If a normal DOM Ready event fired, decrement, and wait if need be
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3360 if ( wait !== true && --jQuery.readyWait > 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3361 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3362 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3363
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3364 // If there are functions bound, to execute
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3365 readyList.resolveWith( document, [ jQuery ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3366
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3367 // Trigger any bound ready events
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3368 if ( jQuery.fn.trigger ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3369 jQuery( document ).trigger("ready").off("ready");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3370 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3371 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3372 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3373
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3374 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3375 * The ready event handler and self cleanup method
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3376 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3377 function completed() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3378 document.removeEventListener( "DOMContentLoaded", completed, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3379 window.removeEventListener( "load", completed, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3380 jQuery.ready();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3381 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3382
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3383 jQuery.ready.promise = function( obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3384 if ( !readyList ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3385
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3386 readyList = jQuery.Deferred();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3387
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3388 // Catch cases where $(document).ready() is called after the browser event has already occurred.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3389 // we once tried to use readyState "interactive" here, but it caused issues like the one
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3390 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3391 if ( document.readyState === "complete" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3392 // Handle it asynchronously to allow scripts the opportunity to delay ready
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3393 setTimeout( jQuery.ready );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3394
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3395 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3396
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3397 // Use the handy event callback
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3398 document.addEventListener( "DOMContentLoaded", completed, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3399
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3400 // A fallback to window.onload, that will always work
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3401 window.addEventListener( "load", completed, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3402 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3403 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3404 return readyList.promise( obj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3405 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3406
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3407 // Kick off the DOM ready check even if the user does not
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3408 jQuery.ready.promise();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3409
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3410
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3411
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3412
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3413 // Multifunctional method to get and set values of a collection
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3414 // The value/s can optionally be executed if it's a function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3415 var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3416 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3417 len = elems.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3418 bulk = key == null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3419
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3420 // Sets many values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3421 if ( jQuery.type( key ) === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3422 chainable = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3423 for ( i in key ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3424 jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3425 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3426
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3427 // Sets one value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3428 } else if ( value !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3429 chainable = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3430
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3431 if ( !jQuery.isFunction( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3432 raw = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3433 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3434
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3435 if ( bulk ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3436 // Bulk operations run against the entire set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3437 if ( raw ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3438 fn.call( elems, value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3439 fn = null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3440
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3441 // ...except when executing function values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3442 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3443 bulk = fn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3444 fn = function( elem, key, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3445 return bulk.call( jQuery( elem ), value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3446 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3447 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3448 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3449
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3450 if ( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3451 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3452 fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3453 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3454 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3455 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3456
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3457 return chainable ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3458 elems :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3459
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3460 // Gets
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3461 bulk ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3462 fn.call( elems ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3463 len ? fn( elems[0], key ) : emptyGet;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3464 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3465
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3466
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3467 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3468 * Determines whether an object can have data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3469 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3470 jQuery.acceptData = function( owner ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3471 // Accepts only:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3472 // - Node
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3473 // - Node.ELEMENT_NODE
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3474 // - Node.DOCUMENT_NODE
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3475 // - Object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3476 // - Any
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3477 /* jshint -W018 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3478 return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3479 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3480
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3481
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3482 function Data() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3483 // Support: Android < 4,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3484 // Old WebKit does not have Object.preventExtensions/freeze method,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3485 // return new empty object instead with no [[set]] accessor
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3486 Object.defineProperty( this.cache = {}, 0, {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3487 get: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3488 return {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3489 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3490 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3491
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3492 this.expando = jQuery.expando + Math.random();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3493 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3494
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3495 Data.uid = 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3496 Data.accepts = jQuery.acceptData;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3497
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3498 Data.prototype = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3499 key: function( owner ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3500 // We can accept data for non-element nodes in modern browsers,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3501 // but we should not, see #8335.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3502 // Always return the key for a frozen object.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3503 if ( !Data.accepts( owner ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3504 return 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3505 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3506
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3507 var descriptor = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3508 // Check if the owner object already has a cache key
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3509 unlock = owner[ this.expando ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3510
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3511 // If not, create one
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3512 if ( !unlock ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3513 unlock = Data.uid++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3514
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3515 // Secure it in a non-enumerable, non-writable property
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3516 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3517 descriptor[ this.expando ] = { value: unlock };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3518 Object.defineProperties( owner, descriptor );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3519
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3520 // Support: Android < 4
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3521 // Fallback to a less secure definition
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3522 } catch ( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3523 descriptor[ this.expando ] = unlock;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3524 jQuery.extend( owner, descriptor );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3525 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3526 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3527
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3528 // Ensure the cache object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3529 if ( !this.cache[ unlock ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3530 this.cache[ unlock ] = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3531 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3532
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3533 return unlock;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3534 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3535 set: function( owner, data, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3536 var prop,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3537 // There may be an unlock assigned to this node,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3538 // if there is no entry for this "owner", create one inline
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3539 // and set the unlock as though an owner entry had always existed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3540 unlock = this.key( owner ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3541 cache = this.cache[ unlock ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3542
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3543 // Handle: [ owner, key, value ] args
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3544 if ( typeof data === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3545 cache[ data ] = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3546
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3547 // Handle: [ owner, { properties } ] args
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3548 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3549 // Fresh assignments by object are shallow copied
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3550 if ( jQuery.isEmptyObject( cache ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3551 jQuery.extend( this.cache[ unlock ], data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3552 // Otherwise, copy the properties one-by-one to the cache object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3553 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3554 for ( prop in data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3555 cache[ prop ] = data[ prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3556 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3557 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3558 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3559 return cache;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3560 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3561 get: function( owner, key ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3562 // Either a valid cache is found, or will be created.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3563 // New caches will be created and the unlock returned,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3564 // allowing direct access to the newly created
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3565 // empty data object. A valid owner object must be provided.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3566 var cache = this.cache[ this.key( owner ) ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3567
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3568 return key === undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3569 cache : cache[ key ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3570 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3571 access: function( owner, key, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3572 var stored;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3573 // In cases where either:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3574 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3575 // 1. No key was specified
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3576 // 2. A string key was specified, but no value provided
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3577 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3578 // Take the "read" path and allow the get method to determine
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3579 // which value to return, respectively either:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3580 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3581 // 1. The entire cache object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3582 // 2. The data stored at the key
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3583 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3584 if ( key === undefined ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3585 ((key && typeof key === "string") && value === undefined) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3586
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3587 stored = this.get( owner, key );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3588
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3589 return stored !== undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3590 stored : this.get( owner, jQuery.camelCase(key) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3591 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3592
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3593 // [*]When the key is not a string, or both a key and value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3594 // are specified, set or extend (existing objects) with either:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3595 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3596 // 1. An object of properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3597 // 2. A key and value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3598 //
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3599 this.set( owner, key, value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3600
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3601 // Since the "set" path can have two possible entry points
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3602 // return the expected data based on which path was taken[*]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3603 return value !== undefined ? value : key;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3604 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3605 remove: function( owner, key ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3606 var i, name, camel,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3607 unlock = this.key( owner ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3608 cache = this.cache[ unlock ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3609
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3610 if ( key === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3611 this.cache[ unlock ] = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3612
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3613 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3614 // Support array or space separated string of keys
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3615 if ( jQuery.isArray( key ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3616 // If "name" is an array of keys...
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3617 // When data is initially created, via ("key", "val") signature,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3618 // keys will be converted to camelCase.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3619 // Since there is no way to tell _how_ a key was added, remove
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3620 // both plain key and camelCase key. #12786
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3621 // This will only penalize the array argument path.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3622 name = key.concat( key.map( jQuery.camelCase ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3623 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3624 camel = jQuery.camelCase( key );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3625 // Try the string as a key before any manipulation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3626 if ( key in cache ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3627 name = [ key, camel ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3628 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3629 // If a key with the spaces exists, use it.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3630 // Otherwise, create an array by matching non-whitespace
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3631 name = camel;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3632 name = name in cache ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3633 [ name ] : ( name.match( rnotwhite ) || [] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3634 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3635 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3636
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3637 i = name.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3638 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3639 delete cache[ name[ i ] ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3640 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3641 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3642 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3643 hasData: function( owner ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3644 return !jQuery.isEmptyObject(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3645 this.cache[ owner[ this.expando ] ] || {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3646 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3647 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3648 discard: function( owner ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3649 if ( owner[ this.expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3650 delete this.cache[ owner[ this.expando ] ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3651 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3652 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3653 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3654 var data_priv = new Data();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3655
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3656 var data_user = new Data();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3657
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3658
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3659
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3660 /*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3661 Implementation Summary
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3662
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3663 1. Enforce API surface and semantic compatibility with 1.9.x branch
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3664 2. Improve the module's maintainability by reducing the storage
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3665 paths to a single mechanism.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3666 3. Use the same single mechanism to support "private" and "user" data.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3667 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3668 5. Avoid exposing implementation details on user objects (eg. expando properties)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3669 6. Provide a clear path for implementation upgrade to WeakMap in 2014
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3670 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3671 var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3672 rmultiDash = /([A-Z])/g;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3673
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3674 function dataAttr( elem, key, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3675 var name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3676
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3677 // If nothing was found internally, try to fetch any
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3678 // data from the HTML5 data-* attribute
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3679 if ( data === undefined && elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3680 name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3681 data = elem.getAttribute( name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3682
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3683 if ( typeof data === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3684 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3685 data = data === "true" ? true :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3686 data === "false" ? false :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3687 data === "null" ? null :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3688 // Only convert to a number if it doesn't change the string
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3689 +data + "" === data ? +data :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3690 rbrace.test( data ) ? jQuery.parseJSON( data ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3691 data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3692 } catch( e ) {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3693
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3694 // Make sure we set the data so it isn't changed later
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3695 data_user.set( elem, key, data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3696 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3697 data = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3698 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3699 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3700 return data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3701 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3702
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3703 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3704 hasData: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3705 return data_user.hasData( elem ) || data_priv.hasData( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3706 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3707
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3708 data: function( elem, name, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3709 return data_user.access( elem, name, data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3710 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3711
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3712 removeData: function( elem, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3713 data_user.remove( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3714 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3715
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3716 // TODO: Now that all calls to _data and _removeData have been replaced
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3717 // with direct calls to data_priv methods, these can be deprecated.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3718 _data: function( elem, name, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3719 return data_priv.access( elem, name, data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3720 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3721
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3722 _removeData: function( elem, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3723 data_priv.remove( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3724 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3725 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3726
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3727 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3728 data: function( key, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3729 var i, name, data,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3730 elem = this[ 0 ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3731 attrs = elem && elem.attributes;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3732
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3733 // Gets all values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3734 if ( key === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3735 if ( this.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3736 data = data_user.get( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3737
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3738 if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3739 i = attrs.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3740 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3741 name = attrs[ i ].name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3742
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3743 if ( name.indexOf( "data-" ) === 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3744 name = jQuery.camelCase( name.slice(5) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3745 dataAttr( elem, name, data[ name ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3746 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3747 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3748 data_priv.set( elem, "hasDataAttrs", true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3749 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3750 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3751
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3752 return data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3753 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3754
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3755 // Sets multiple values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3756 if ( typeof key === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3757 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3758 data_user.set( this, key );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3759 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3760 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3761
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3762 return access( this, function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3763 var data,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3764 camelKey = jQuery.camelCase( key );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3765
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3766 // The calling jQuery object (element matches) is not empty
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3767 // (and therefore has an element appears at this[ 0 ]) and the
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3768 // `value` parameter was not undefined. An empty jQuery object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3769 // will result in `undefined` for elem = this[ 0 ] which will
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3770 // throw an exception if an attempt to read a data cache is made.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3771 if ( elem && value === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3772 // Attempt to get data from the cache
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3773 // with the key as-is
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3774 data = data_user.get( elem, key );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3775 if ( data !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3776 return data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3777 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3778
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3779 // Attempt to get data from the cache
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3780 // with the key camelized
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3781 data = data_user.get( elem, camelKey );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3782 if ( data !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3783 return data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3784 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3785
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3786 // Attempt to "discover" the data in
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3787 // HTML5 custom data-* attrs
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3788 data = dataAttr( elem, camelKey, undefined );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3789 if ( data !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3790 return data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3791 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3792
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3793 // We tried really hard, but the data doesn't exist.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3794 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3795 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3796
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3797 // Set the data...
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3798 this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3799 // First, attempt to store a copy or reference of any
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3800 // data that might've been store with a camelCased key.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3801 var data = data_user.get( this, camelKey );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3802
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3803 // For HTML5 data-* attribute interop, we have to
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3804 // store property names with dashes in a camelCase form.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3805 // This might not apply to all properties...*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3806 data_user.set( this, camelKey, value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3807
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3808 // *... In the case of properties that might _actually_
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3809 // have dashes, we need to also store a copy of that
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3810 // unchanged property.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3811 if ( key.indexOf("-") !== -1 && data !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3812 data_user.set( this, key, value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3813 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3814 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3815 }, null, value, arguments.length > 1, null, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3816 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3817
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3818 removeData: function( key ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3819 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3820 data_user.remove( this, key );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3821 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3822 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3823 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3824
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3825
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3826 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3827 queue: function( elem, type, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3828 var queue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3829
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3830 if ( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3831 type = ( type || "fx" ) + "queue";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3832 queue = data_priv.get( elem, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3833
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3834 // Speed up dequeue by getting out quickly if this is just a lookup
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3835 if ( data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3836 if ( !queue || jQuery.isArray( data ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3837 queue = data_priv.access( elem, type, jQuery.makeArray(data) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3838 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3839 queue.push( data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3840 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3841 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3842 return queue || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3843 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3844 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3845
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3846 dequeue: function( elem, type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3847 type = type || "fx";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3848
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3849 var queue = jQuery.queue( elem, type ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3850 startLength = queue.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3851 fn = queue.shift(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3852 hooks = jQuery._queueHooks( elem, type ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3853 next = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3854 jQuery.dequeue( elem, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3855 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3856
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3857 // If the fx queue is dequeued, always remove the progress sentinel
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3858 if ( fn === "inprogress" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3859 fn = queue.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3860 startLength--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3861 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3862
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3863 if ( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3864
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3865 // Add a progress sentinel to prevent the fx queue from being
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3866 // automatically dequeued
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3867 if ( type === "fx" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3868 queue.unshift( "inprogress" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3869 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3870
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3871 // clear up the last queue stop function
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3872 delete hooks.stop;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3873 fn.call( elem, next, hooks );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3874 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3875
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3876 if ( !startLength && hooks ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3877 hooks.empty.fire();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3878 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3879 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3880
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3881 // not intended for public consumption - generates a queueHooks object, or returns the current one
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3882 _queueHooks: function( elem, type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3883 var key = type + "queueHooks";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3884 return data_priv.get( elem, key ) || data_priv.access( elem, key, {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3885 empty: jQuery.Callbacks("once memory").add(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3886 data_priv.remove( elem, [ type + "queue", key ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3887 })
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3888 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3889 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3890 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3891
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3892 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3893 queue: function( type, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3894 var setter = 2;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3895
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3896 if ( typeof type !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3897 data = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3898 type = "fx";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3899 setter--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3900 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3901
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3902 if ( arguments.length < setter ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3903 return jQuery.queue( this[0], type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3904 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3905
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3906 return data === undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3907 this :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3908 this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3909 var queue = jQuery.queue( this, type, data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3910
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3911 // ensure a hooks for this queue
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3912 jQuery._queueHooks( this, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3913
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3914 if ( type === "fx" && queue[0] !== "inprogress" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3915 jQuery.dequeue( this, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3916 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3917 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3918 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3919 dequeue: function( type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3920 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3921 jQuery.dequeue( this, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3922 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3923 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3924 clearQueue: function( type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3925 return this.queue( type || "fx", [] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3926 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3927 // Get a promise resolved when queues of a certain type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3928 // are emptied (fx is the type by default)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3929 promise: function( type, obj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3930 var tmp,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3931 count = 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3932 defer = jQuery.Deferred(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3933 elements = this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3934 i = this.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3935 resolve = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3936 if ( !( --count ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3937 defer.resolveWith( elements, [ elements ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3938 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3939 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3940
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3941 if ( typeof type !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3942 obj = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3943 type = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3944 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3945 type = type || "fx";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3946
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3947 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3948 tmp = data_priv.get( elements[ i ], type + "queueHooks" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3949 if ( tmp && tmp.empty ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3950 count++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3951 tmp.empty.add( resolve );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3952 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3953 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3954 resolve();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3955 return defer.promise( obj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3956 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3957 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3958 var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3959
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3960 var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3961
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3962 var isHidden = function( elem, el ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3963 // isHidden might be called from jQuery#filter function;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3964 // in that case, element will be second argument
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3965 elem = el || elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3966 return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3967 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3968
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3969 var rcheckableType = (/^(?:checkbox|radio)$/i);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3970
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3971
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3972
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3973 (function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3974 var fragment = document.createDocumentFragment(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3975 div = fragment.appendChild( document.createElement( "div" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3976
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3977 // #11217 - WebKit loses check when the name is after the checked attribute
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3978 div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3979
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3980 // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3981 // old WebKit doesn't clone checked state correctly in fragments
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3982 support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3983
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3984 // Make sure textarea (and checkbox) defaultValue is properly cloned
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3985 // Support: IE9-IE11+
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3986 div.innerHTML = "<textarea>x</textarea>";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3987 support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3988 })();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3989 var strundefined = typeof undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3990
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3991
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3992
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3993 support.focusinBubbles = "onfocusin" in window;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3994
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3995
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3996 var
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3997 rkeyEvent = /^key/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3998 rmouseEvent = /^(?:mouse|contextmenu)|click/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3999 rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4000 rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4001
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4002 function returnTrue() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4003 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4004 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4005
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4006 function returnFalse() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4007 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4008 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4009
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4010 function safeActiveElement() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4011 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4012 return document.activeElement;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4013 } catch ( err ) { }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4014 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4015
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4016 /*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4017 * Helper functions for managing events -- not part of the public interface.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4018 * Props to Dean Edwards' addEvent library for many of the ideas.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4019 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4020 jQuery.event = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4021
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4022 global: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4023
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4024 add: function( elem, types, handler, data, selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4025
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4026 var handleObjIn, eventHandle, tmp,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4027 events, t, handleObj,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4028 special, handlers, type, namespaces, origType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4029 elemData = data_priv.get( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4030
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4031 // Don't attach events to noData or text/comment nodes (but allow plain objects)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4032 if ( !elemData ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4033 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4034 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4035
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4036 // Caller can pass in an object of custom data in lieu of the handler
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4037 if ( handler.handler ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4038 handleObjIn = handler;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4039 handler = handleObjIn.handler;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4040 selector = handleObjIn.selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4041 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4042
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4043 // Make sure that the handler has a unique ID, used to find/remove it later
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4044 if ( !handler.guid ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4045 handler.guid = jQuery.guid++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4046 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4047
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4048 // Init the element's event structure and main handler, if this is the first
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4049 if ( !(events = elemData.events) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4050 events = elemData.events = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4051 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4052 if ( !(eventHandle = elemData.handle) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4053 eventHandle = elemData.handle = function( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4054 // Discard the second event of a jQuery.event.trigger() and
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4055 // when an event is called after a page has unloaded
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4056 return typeof jQuery !== strundefined && jQuery.event.triggered !== e.type ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4057 jQuery.event.dispatch.apply( elem, arguments ) : undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4058 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4059 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4060
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4061 // Handle multiple events separated by a space
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4062 types = ( types || "" ).match( rnotwhite ) || [ "" ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4063 t = types.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4064 while ( t-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4065 tmp = rtypenamespace.exec( types[t] ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4066 type = origType = tmp[1];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4067 namespaces = ( tmp[2] || "" ).split( "." ).sort();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4068
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4069 // There *must* be a type, no attaching namespace-only handlers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4070 if ( !type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4071 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4072 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4073
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4074 // If event changes its type, use the special event handlers for the changed type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4075 special = jQuery.event.special[ type ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4076
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4077 // If selector defined, determine special event api type, otherwise given type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4078 type = ( selector ? special.delegateType : special.bindType ) || type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4079
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4080 // Update special based on newly reset type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4081 special = jQuery.event.special[ type ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4082
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4083 // handleObj is passed to all event handlers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4084 handleObj = jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4085 type: type,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4086 origType: origType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4087 data: data,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4088 handler: handler,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4089 guid: handler.guid,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4090 selector: selector,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4091 needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4092 namespace: namespaces.join(".")
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4093 }, handleObjIn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4094
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4095 // Init the event handler queue if we're the first
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4096 if ( !(handlers = events[ type ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4097 handlers = events[ type ] = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4098 handlers.delegateCount = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4099
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4100 // Only use addEventListener if the special events handler returns false
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4101 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4102 if ( elem.addEventListener ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4103 elem.addEventListener( type, eventHandle, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4104 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4105 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4106 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4107
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4108 if ( special.add ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4109 special.add.call( elem, handleObj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4110
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4111 if ( !handleObj.handler.guid ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4112 handleObj.handler.guid = handler.guid;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4113 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4114 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4115
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4116 // Add to the element's handler list, delegates in front
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4117 if ( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4118 handlers.splice( handlers.delegateCount++, 0, handleObj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4119 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4120 handlers.push( handleObj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4121 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4122
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4123 // Keep track of which events have ever been used, for event optimization
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4124 jQuery.event.global[ type ] = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4125 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4126
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4127 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4128
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4129 // Detach an event or set of events from an element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4130 remove: function( elem, types, handler, selector, mappedTypes ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4131
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4132 var j, origCount, tmp,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4133 events, t, handleObj,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4134 special, handlers, type, namespaces, origType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4135 elemData = data_priv.hasData( elem ) && data_priv.get( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4136
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4137 if ( !elemData || !(events = elemData.events) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4138 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4139 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4140
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4141 // Once for each type.namespace in types; type may be omitted
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4142 types = ( types || "" ).match( rnotwhite ) || [ "" ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4143 t = types.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4144 while ( t-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4145 tmp = rtypenamespace.exec( types[t] ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4146 type = origType = tmp[1];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4147 namespaces = ( tmp[2] || "" ).split( "." ).sort();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4148
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4149 // Unbind all events (on this namespace, if provided) for the element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4150 if ( !type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4151 for ( type in events ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4152 jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4153 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4154 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4155 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4156
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4157 special = jQuery.event.special[ type ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4158 type = ( selector ? special.delegateType : special.bindType ) || type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4159 handlers = events[ type ] || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4160 tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4161
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4162 // Remove matching events
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4163 origCount = j = handlers.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4164 while ( j-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4165 handleObj = handlers[ j ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4166
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4167 if ( ( mappedTypes || origType === handleObj.origType ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4168 ( !handler || handler.guid === handleObj.guid ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4169 ( !tmp || tmp.test( handleObj.namespace ) ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4170 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4171 handlers.splice( j, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4172
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4173 if ( handleObj.selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4174 handlers.delegateCount--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4175 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4176 if ( special.remove ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4177 special.remove.call( elem, handleObj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4178 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4179 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4180 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4181
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4182 // Remove generic event handler if we removed something and no more handlers exist
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4183 // (avoids potential for endless recursion during removal of special event handlers)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4184 if ( origCount && !handlers.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4185 if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4186 jQuery.removeEvent( elem, type, elemData.handle );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4187 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4188
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4189 delete events[ type ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4190 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4191 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4192
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4193 // Remove the expando if it's no longer used
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4194 if ( jQuery.isEmptyObject( events ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4195 delete elemData.handle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4196 data_priv.remove( elem, "events" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4197 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4198 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4199
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4200 trigger: function( event, data, elem, onlyHandlers ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4201
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4202 var i, cur, tmp, bubbleType, ontype, handle, special,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4203 eventPath = [ elem || document ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4204 type = hasOwn.call( event, "type" ) ? event.type : event,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4205 namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4206
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4207 cur = tmp = elem = elem || document;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4208
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4209 // Don't do events on text and comment nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4210 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4211 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4212 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4213
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4214 // focus/blur morphs to focusin/out; ensure we're not firing them right now
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4215 if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4216 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4217 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4218
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4219 if ( type.indexOf(".") >= 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4220 // Namespaced trigger; create a regexp to match event type in handle()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4221 namespaces = type.split(".");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4222 type = namespaces.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4223 namespaces.sort();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4224 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4225 ontype = type.indexOf(":") < 0 && "on" + type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4226
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4227 // Caller can pass in a jQuery.Event object, Object, or just an event type string
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4228 event = event[ jQuery.expando ] ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4229 event :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4230 new jQuery.Event( type, typeof event === "object" && event );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4231
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4232 // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4233 event.isTrigger = onlyHandlers ? 2 : 3;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4234 event.namespace = namespaces.join(".");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4235 event.namespace_re = event.namespace ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4236 new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4237 null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4238
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4239 // Clean up the event in case it is being reused
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4240 event.result = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4241 if ( !event.target ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4242 event.target = elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4243 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4244
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4245 // Clone any incoming data and prepend the event, creating the handler arg list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4246 data = data == null ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4247 [ event ] :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4248 jQuery.makeArray( data, [ event ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4249
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4250 // Allow special events to draw outside the lines
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4251 special = jQuery.event.special[ type ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4252 if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4253 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4254 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4255
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4256 // Determine event propagation path in advance, per W3C events spec (#9951)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4257 // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4258 if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4259
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4260 bubbleType = special.delegateType || type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4261 if ( !rfocusMorph.test( bubbleType + type ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4262 cur = cur.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4263 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4264 for ( ; cur; cur = cur.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4265 eventPath.push( cur );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4266 tmp = cur;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4267 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4268
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4269 // Only add window if we got to document (e.g., not plain obj or detached DOM)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4270 if ( tmp === (elem.ownerDocument || document) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4271 eventPath.push( tmp.defaultView || tmp.parentWindow || window );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4272 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4273 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4274
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4275 // Fire handlers on the event path
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4276 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4277 while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4278
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4279 event.type = i > 1 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4280 bubbleType :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4281 special.bindType || type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4282
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4283 // jQuery handler
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4284 handle = ( data_priv.get( cur, "events" ) || {} )[ event.type ] && data_priv.get( cur, "handle" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4285 if ( handle ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4286 handle.apply( cur, data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4287 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4288
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4289 // Native handler
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4290 handle = ontype && cur[ ontype ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4291 if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4292 event.result = handle.apply( cur, data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4293 if ( event.result === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4294 event.preventDefault();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4295 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4296 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4297 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4298 event.type = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4299
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4300 // If nobody prevented the default action, do it now
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4301 if ( !onlyHandlers && !event.isDefaultPrevented() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4302
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4303 if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4304 jQuery.acceptData( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4305
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4306 // Call a native DOM method on the target with the same name name as the event.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4307 // Don't do default actions on window, that's where global variables be (#6170)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4308 if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4309
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4310 // Don't re-trigger an onFOO event when we call its FOO() method
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4311 tmp = elem[ ontype ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4312
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4313 if ( tmp ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4314 elem[ ontype ] = null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4315 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4316
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4317 // Prevent re-triggering of the same event, since we already bubbled it above
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4318 jQuery.event.triggered = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4319 elem[ type ]();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4320 jQuery.event.triggered = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4321
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4322 if ( tmp ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4323 elem[ ontype ] = tmp;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4324 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4325 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4326 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4327 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4328
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4329 return event.result;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4330 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4331
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4332 dispatch: function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4333
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4334 // Make a writable jQuery.Event from the native event object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4335 event = jQuery.event.fix( event );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4336
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4337 var i, j, ret, matched, handleObj,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4338 handlerQueue = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4339 args = slice.call( arguments ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4340 handlers = ( data_priv.get( this, "events" ) || {} )[ event.type ] || [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4341 special = jQuery.event.special[ event.type ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4342
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4343 // Use the fix-ed jQuery.Event rather than the (read-only) native event
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4344 args[0] = event;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4345 event.delegateTarget = this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4346
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4347 // Call the preDispatch hook for the mapped type, and let it bail if desired
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4348 if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4349 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4350 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4351
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4352 // Determine handlers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4353 handlerQueue = jQuery.event.handlers.call( this, event, handlers );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4354
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4355 // Run delegates first; they may want to stop propagation beneath us
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4356 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4357 while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4358 event.currentTarget = matched.elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4359
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4360 j = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4361 while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4362
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4363 // Triggered event must either 1) have no namespace, or
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4364 // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4365 if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4366
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4367 event.handleObj = handleObj;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4368 event.data = handleObj.data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4369
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4370 ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4371 .apply( matched.elem, args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4372
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4373 if ( ret !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4374 if ( (event.result = ret) === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4375 event.preventDefault();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4376 event.stopPropagation();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4377 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4378 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4379 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4380 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4381 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4382
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4383 // Call the postDispatch hook for the mapped type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4384 if ( special.postDispatch ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4385 special.postDispatch.call( this, event );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4386 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4387
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4388 return event.result;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4389 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4390
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4391 handlers: function( event, handlers ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4392 var i, matches, sel, handleObj,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4393 handlerQueue = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4394 delegateCount = handlers.delegateCount,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4395 cur = event.target;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4396
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4397 // Find delegate handlers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4398 // Black-hole SVG <use> instance trees (#13180)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4399 // Avoid non-left-click bubbling in Firefox (#3861)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4400 if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4401
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4402 for ( ; cur !== this; cur = cur.parentNode || this ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4403
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4404 // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4405 if ( cur.disabled !== true || event.type !== "click" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4406 matches = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4407 for ( i = 0; i < delegateCount; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4408 handleObj = handlers[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4409
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4410 // Don't conflict with Object.prototype properties (#13203)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4411 sel = handleObj.selector + " ";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4412
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4413 if ( matches[ sel ] === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4414 matches[ sel ] = handleObj.needsContext ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4415 jQuery( sel, this ).index( cur ) >= 0 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4416 jQuery.find( sel, this, null, [ cur ] ).length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4417 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4418 if ( matches[ sel ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4419 matches.push( handleObj );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4420 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4421 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4422 if ( matches.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4423 handlerQueue.push({ elem: cur, handlers: matches });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4424 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4425 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4426 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4427 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4428
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4429 // Add the remaining (directly-bound) handlers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4430 if ( delegateCount < handlers.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4431 handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4432 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4433
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4434 return handlerQueue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4435 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4436
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4437 // Includes some event props shared by KeyEvent and MouseEvent
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4438 props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4439
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4440 fixHooks: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4441
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4442 keyHooks: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4443 props: "char charCode key keyCode".split(" "),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4444 filter: function( event, original ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4445
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4446 // Add which for key events
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4447 if ( event.which == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4448 event.which = original.charCode != null ? original.charCode : original.keyCode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4449 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4450
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4451 return event;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4452 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4453 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4454
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4455 mouseHooks: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4456 props: "button buttons clientX clientY offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4457 filter: function( event, original ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4458 var eventDoc, doc, body,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4459 button = original.button;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4460
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4461 // Calculate pageX/Y if missing and clientX/Y available
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4462 if ( event.pageX == null && original.clientX != null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4463 eventDoc = event.target.ownerDocument || document;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4464 doc = eventDoc.documentElement;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4465 body = eventDoc.body;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4466
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4467 event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4468 event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4469 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4470
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4471 // Add which for click: 1 === left; 2 === middle; 3 === right
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4472 // Note: button is not normalized, so don't use it
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4473 if ( !event.which && button !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4474 event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4475 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4476
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4477 return event;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4478 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4479 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4480
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4481 fix: function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4482 if ( event[ jQuery.expando ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4483 return event;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4484 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4485
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4486 // Create a writable copy of the event object and normalize some properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4487 var i, prop, copy,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4488 type = event.type,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4489 originalEvent = event,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4490 fixHook = this.fixHooks[ type ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4491
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4492 if ( !fixHook ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4493 this.fixHooks[ type ] = fixHook =
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4494 rmouseEvent.test( type ) ? this.mouseHooks :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4495 rkeyEvent.test( type ) ? this.keyHooks :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4496 {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4497 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4498 copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4499
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4500 event = new jQuery.Event( originalEvent );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4501
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4502 i = copy.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4503 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4504 prop = copy[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4505 event[ prop ] = originalEvent[ prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4506 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4507
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4508 // Support: Cordova 2.5 (WebKit) (#13255)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4509 // All events should have a target; Cordova deviceready doesn't
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4510 if ( !event.target ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4511 event.target = document;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4512 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4513
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4514 // Support: Safari 6.0+, Chrome < 28
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4515 // Target should not be a text node (#504, #13143)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4516 if ( event.target.nodeType === 3 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4517 event.target = event.target.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4518 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4519
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4520 return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4521 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4522
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4523 special: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4524 load: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4525 // Prevent triggered image.load events from bubbling to window.load
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4526 noBubble: true
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4527 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4528 focus: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4529 // Fire native event if possible so blur/focus sequence is correct
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4530 trigger: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4531 if ( this !== safeActiveElement() && this.focus ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4532 this.focus();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4533 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4534 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4535 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4536 delegateType: "focusin"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4537 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4538 blur: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4539 trigger: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4540 if ( this === safeActiveElement() && this.blur ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4541 this.blur();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4542 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4543 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4544 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4545 delegateType: "focusout"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4546 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4547 click: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4548 // For checkbox, fire native event so checked state will be right
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4549 trigger: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4550 if ( this.type === "checkbox" && this.click && jQuery.nodeName( this, "input" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4551 this.click();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4552 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4553 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4554 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4555
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4556 // For cross-browser consistency, don't fire native .click() on links
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4557 _default: function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4558 return jQuery.nodeName( event.target, "a" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4559 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4560 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4561
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4562 beforeunload: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4563 postDispatch: function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4564
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4565 // Support: Firefox 20+
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4566 // Firefox doesn't alert if the returnValue field is not set.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4567 if ( event.result !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4568 event.originalEvent.returnValue = event.result;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4569 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4570 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4571 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4572 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4573
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4574 simulate: function( type, elem, event, bubble ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4575 // Piggyback on a donor event to simulate a different one.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4576 // Fake originalEvent to avoid donor's stopPropagation, but if the
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4577 // simulated event prevents default then we do the same on the donor.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4578 var e = jQuery.extend(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4579 new jQuery.Event(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4580 event,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4581 {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4582 type: type,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4583 isSimulated: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4584 originalEvent: {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4585 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4586 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4587 if ( bubble ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4588 jQuery.event.trigger( e, null, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4589 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4590 jQuery.event.dispatch.call( elem, e );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4591 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4592 if ( e.isDefaultPrevented() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4593 event.preventDefault();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4594 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4595 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4596 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4597
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4598 jQuery.removeEvent = function( elem, type, handle ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4599 if ( elem.removeEventListener ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4600 elem.removeEventListener( type, handle, false );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4601 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4602 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4603
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4604 jQuery.Event = function( src, props ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4605 // Allow instantiation without the 'new' keyword
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4606 if ( !(this instanceof jQuery.Event) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4607 return new jQuery.Event( src, props );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4608 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4609
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4610 // Event object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4611 if ( src && src.type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4612 this.originalEvent = src;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4613 this.type = src.type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4614
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4615 // Events bubbling up the document may have been marked as prevented
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4616 // by a handler lower down the tree; reflect the correct value.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4617 this.isDefaultPrevented = src.defaultPrevented ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4618 // Support: Android < 4.0
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4619 src.defaultPrevented === undefined &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4620 src.getPreventDefault && src.getPreventDefault() ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4621 returnTrue :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4622 returnFalse;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4623
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4624 // Event type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4625 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4626 this.type = src;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4627 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4628
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4629 // Put explicitly provided properties onto the event object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4630 if ( props ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4631 jQuery.extend( this, props );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4632 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4633
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4634 // Create a timestamp if incoming event doesn't have one
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4635 this.timeStamp = src && src.timeStamp || jQuery.now();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4636
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4637 // Mark it as fixed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4638 this[ jQuery.expando ] = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4639 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4640
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4641 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4642 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4643 jQuery.Event.prototype = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4644 isDefaultPrevented: returnFalse,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4645 isPropagationStopped: returnFalse,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4646 isImmediatePropagationStopped: returnFalse,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4647
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4648 preventDefault: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4649 var e = this.originalEvent;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4650
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4651 this.isDefaultPrevented = returnTrue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4652
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4653 if ( e && e.preventDefault ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4654 e.preventDefault();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4655 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4656 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4657 stopPropagation: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4658 var e = this.originalEvent;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4659
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4660 this.isPropagationStopped = returnTrue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4661
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4662 if ( e && e.stopPropagation ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4663 e.stopPropagation();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4664 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4665 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4666 stopImmediatePropagation: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4667 this.isImmediatePropagationStopped = returnTrue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4668 this.stopPropagation();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4669 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4670 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4671
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4672 // Create mouseenter/leave events using mouseover/out and event-time checks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4673 // Support: Chrome 15+
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4674 jQuery.each({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4675 mouseenter: "mouseover",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4676 mouseleave: "mouseout"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4677 }, function( orig, fix ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4678 jQuery.event.special[ orig ] = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4679 delegateType: fix,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4680 bindType: fix,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4681
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4682 handle: function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4683 var ret,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4684 target = this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4685 related = event.relatedTarget,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4686 handleObj = event.handleObj;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4687
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4688 // For mousenter/leave call the handler if related is outside the target.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4689 // NB: No relatedTarget if the mouse left/entered the browser window
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4690 if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4691 event.type = handleObj.origType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4692 ret = handleObj.handler.apply( this, arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4693 event.type = fix;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4694 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4695 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4696 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4697 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4698 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4699
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4700 // Create "bubbling" focus and blur events
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4701 // Support: Firefox, Chrome, Safari
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4702 if ( !support.focusinBubbles ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4703 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4704
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4705 // Attach a single capturing handler on the document while someone wants focusin/focusout
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4706 var handler = function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4707 jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4708 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4709
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4710 jQuery.event.special[ fix ] = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4711 setup: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4712 var doc = this.ownerDocument || this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4713 attaches = data_priv.access( doc, fix );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4714
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4715 if ( !attaches ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4716 doc.addEventListener( orig, handler, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4717 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4718 data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4719 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4720 teardown: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4721 var doc = this.ownerDocument || this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4722 attaches = data_priv.access( doc, fix ) - 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4723
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4724 if ( !attaches ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4725 doc.removeEventListener( orig, handler, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4726 data_priv.remove( doc, fix );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4727
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4728 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4729 data_priv.access( doc, fix, attaches );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4730 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4731 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4732 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4733 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4734 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4735
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4736 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4737
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4738 on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4739 var origFn, type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4740
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4741 // Types can be a map of types/handlers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4742 if ( typeof types === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4743 // ( types-Object, selector, data )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4744 if ( typeof selector !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4745 // ( types-Object, data )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4746 data = data || selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4747 selector = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4748 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4749 for ( type in types ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4750 this.on( type, selector, data, types[ type ], one );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4751 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4752 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4753 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4754
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4755 if ( data == null && fn == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4756 // ( types, fn )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4757 fn = selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4758 data = selector = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4759 } else if ( fn == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4760 if ( typeof selector === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4761 // ( types, selector, fn )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4762 fn = data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4763 data = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4764 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4765 // ( types, data, fn )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4766 fn = data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4767 data = selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4768 selector = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4769 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4770 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4771 if ( fn === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4772 fn = returnFalse;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4773 } else if ( !fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4774 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4775 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4776
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4777 if ( one === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4778 origFn = fn;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4779 fn = function( event ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4780 // Can use an empty set, since event contains the info
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4781 jQuery().off( event );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4782 return origFn.apply( this, arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4783 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4784 // Use same guid so caller can remove using origFn
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4785 fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4786 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4787 return this.each( function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4788 jQuery.event.add( this, types, fn, data, selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4789 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4790 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4791 one: function( types, selector, data, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4792 return this.on( types, selector, data, fn, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4793 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4794 off: function( types, selector, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4795 var handleObj, type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4796 if ( types && types.preventDefault && types.handleObj ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4797 // ( event ) dispatched jQuery.Event
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4798 handleObj = types.handleObj;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4799 jQuery( types.delegateTarget ).off(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4800 handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4801 handleObj.selector,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4802 handleObj.handler
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4803 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4804 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4805 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4806 if ( typeof types === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4807 // ( types-object [, selector] )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4808 for ( type in types ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4809 this.off( type, selector, types[ type ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4810 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4811 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4812 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4813 if ( selector === false || typeof selector === "function" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4814 // ( types [, fn] )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4815 fn = selector;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4816 selector = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4817 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4818 if ( fn === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4819 fn = returnFalse;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4820 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4821 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4822 jQuery.event.remove( this, types, fn, selector );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4823 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4824 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4825
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4826 trigger: function( type, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4827 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4828 jQuery.event.trigger( type, data, this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4829 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4830 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4831 triggerHandler: function( type, data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4832 var elem = this[0];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4833 if ( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4834 return jQuery.event.trigger( type, data, elem, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4835 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4836 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4837 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4838
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4839
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4840 var
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4841 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4842 rtagName = /<([\w:]+)/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4843 rhtml = /<|&#?\w+;/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4844 rnoInnerhtml = /<(?:script|style|link)/i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4845 // checked="checked" or checked
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4846 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4847 rscriptType = /^$|\/(?:java|ecma)script/i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4848 rscriptTypeMasked = /^true\/(.*)/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4849 rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4850
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4851 // We have to close these tags to support XHTML (#13200)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4852 wrapMap = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4853
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4854 // Support: IE 9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4855 option: [ 1, "<select multiple='multiple'>", "</select>" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4856
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4857 thead: [ 1, "<table>", "</table>" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4858 col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4859 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4860 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4861
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4862 _default: [ 0, "", "" ]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4863 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4864
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4865 // Support: IE 9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4866 wrapMap.optgroup = wrapMap.option;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4867
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4868 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4869 wrapMap.th = wrapMap.td;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4870
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4871 // Support: 1.x compatibility
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4872 // Manipulating tables requires a tbody
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4873 function manipulationTarget( elem, content ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4874 return jQuery.nodeName( elem, "table" ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4875 jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4876
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4877 elem.getElementsByTagName("tbody")[0] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4878 elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4879 elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4880 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4881
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4882 // Replace/restore the type attribute of script elements for safe DOM manipulation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4883 function disableScript( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4884 elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4885 return elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4886 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4887 function restoreScript( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4888 var match = rscriptTypeMasked.exec( elem.type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4889
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4890 if ( match ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4891 elem.type = match[ 1 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4892 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4893 elem.removeAttribute("type");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4894 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4895
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4896 return elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4897 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4898
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4899 // Mark scripts as having already been evaluated
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4900 function setGlobalEval( elems, refElements ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4901 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4902 l = elems.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4903
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4904 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4905 data_priv.set(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4906 elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4907 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4908 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4909 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4910
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4911 function cloneCopyEvent( src, dest ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4912 var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4913
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4914 if ( dest.nodeType !== 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4915 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4916 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4917
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4918 // 1. Copy private data: events, handlers, etc.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4919 if ( data_priv.hasData( src ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4920 pdataOld = data_priv.access( src );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4921 pdataCur = data_priv.set( dest, pdataOld );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4922 events = pdataOld.events;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4923
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4924 if ( events ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4925 delete pdataCur.handle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4926 pdataCur.events = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4927
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4928 for ( type in events ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4929 for ( i = 0, l = events[ type ].length; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4930 jQuery.event.add( dest, type, events[ type ][ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4931 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4932 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4933 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4934 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4935
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4936 // 2. Copy user data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4937 if ( data_user.hasData( src ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4938 udataOld = data_user.access( src );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4939 udataCur = jQuery.extend( {}, udataOld );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4940
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4941 data_user.set( dest, udataCur );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4942 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4943 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4944
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4945 function getAll( context, tag ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4946 var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4947 context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4948 [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4949
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4950 return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4951 jQuery.merge( [ context ], ret ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4952 ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4953 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4954
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4955 // Support: IE >= 9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4956 function fixInput( src, dest ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4957 var nodeName = dest.nodeName.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4958
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4959 // Fails to persist the checked state of a cloned checkbox or radio button.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4960 if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4961 dest.checked = src.checked;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4962
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4963 // Fails to return the selected option to the default selected state when cloning options
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4964 } else if ( nodeName === "input" || nodeName === "textarea" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4965 dest.defaultValue = src.defaultValue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4966 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4967 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4968
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4969 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4970 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4971 var i, l, srcElements, destElements,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4972 clone = elem.cloneNode( true ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4973 inPage = jQuery.contains( elem.ownerDocument, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4974
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4975 // Support: IE >= 9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4976 // Fix Cloning issues
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4977 if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4978 !jQuery.isXMLDoc( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4979
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4980 // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4981 destElements = getAll( clone );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4982 srcElements = getAll( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4983
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4984 for ( i = 0, l = srcElements.length; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4985 fixInput( srcElements[ i ], destElements[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4986 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4987 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4988
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4989 // Copy the events from the original to the clone
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4990 if ( dataAndEvents ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4991 if ( deepDataAndEvents ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4992 srcElements = srcElements || getAll( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4993 destElements = destElements || getAll( clone );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4994
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4995 for ( i = 0, l = srcElements.length; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4996 cloneCopyEvent( srcElements[ i ], destElements[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4997 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4998 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4999 cloneCopyEvent( elem, clone );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5000 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5001 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5002
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5003 // Preserve script evaluation history
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5004 destElements = getAll( clone, "script" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5005 if ( destElements.length > 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5006 setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5007 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5008
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5009 // Return the cloned set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5010 return clone;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5011 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5012
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5013 buildFragment: function( elems, context, scripts, selection ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5014 var elem, tmp, tag, wrap, contains, j,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5015 fragment = context.createDocumentFragment(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5016 nodes = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5017 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5018 l = elems.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5019
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5020 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5021 elem = elems[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5022
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5023 if ( elem || elem === 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5024
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5025 // Add nodes directly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5026 if ( jQuery.type( elem ) === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5027 // Support: QtWebKit
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5028 // jQuery.merge because push.apply(_, arraylike) throws
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5029 jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5030
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5031 // Convert non-html into a text node
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5032 } else if ( !rhtml.test( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5033 nodes.push( context.createTextNode( elem ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5034
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5035 // Convert html into DOM nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5036 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5037 tmp = tmp || fragment.appendChild( context.createElement("div") );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5038
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5039 // Deserialize a standard representation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5040 tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5041 wrap = wrapMap[ tag ] || wrapMap._default;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5042 tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5043
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5044 // Descend through wrappers to the right content
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5045 j = wrap[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5046 while ( j-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5047 tmp = tmp.lastChild;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5048 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5049
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5050 // Support: QtWebKit
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5051 // jQuery.merge because push.apply(_, arraylike) throws
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5052 jQuery.merge( nodes, tmp.childNodes );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5053
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5054 // Remember the top-level container
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5055 tmp = fragment.firstChild;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5056
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5057 // Fixes #12346
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5058 // Support: Webkit, IE
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5059 tmp.textContent = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5060 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5061 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5062 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5063
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5064 // Remove wrapper from fragment
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5065 fragment.textContent = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5066
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5067 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5068 while ( (elem = nodes[ i++ ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5069
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5070 // #4087 - If origin and destination elements are the same, and this is
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5071 // that element, do not do anything
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5072 if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5073 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5074 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5075
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5076 contains = jQuery.contains( elem.ownerDocument, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5077
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5078 // Append to fragment
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5079 tmp = getAll( fragment.appendChild( elem ), "script" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5080
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5081 // Preserve script evaluation history
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5082 if ( contains ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5083 setGlobalEval( tmp );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5084 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5085
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5086 // Capture executables
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5087 if ( scripts ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5088 j = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5089 while ( (elem = tmp[ j++ ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5090 if ( rscriptType.test( elem.type || "" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5091 scripts.push( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5092 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5093 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5094 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5095 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5096
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5097 return fragment;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5098 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5099
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5100 cleanData: function( elems ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5101 var data, elem, events, type, key, j,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5102 special = jQuery.event.special,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5103 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5104
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5105 for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5106 if ( jQuery.acceptData( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5107 key = elem[ data_priv.expando ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5108
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5109 if ( key && (data = data_priv.cache[ key ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5110 events = Object.keys( data.events || {} );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5111 if ( events.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5112 for ( j = 0; (type = events[j]) !== undefined; j++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5113 if ( special[ type ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5114 jQuery.event.remove( elem, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5115
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5116 // This is a shortcut to avoid jQuery.event.remove's overhead
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5117 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5118 jQuery.removeEvent( elem, type, data.handle );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5119 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5120 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5121 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5122 if ( data_priv.cache[ key ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5123 // Discard any remaining `private` data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5124 delete data_priv.cache[ key ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5125 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5126 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5127 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5128 // Discard any remaining `user` data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5129 delete data_user.cache[ elem[ data_user.expando ] ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5130 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5131 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5132 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5133
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5134 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5135 text: function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5136 return access( this, function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5137 return value === undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5138 jQuery.text( this ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5139 this.empty().each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5140 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5141 this.textContent = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5142 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5143 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5144 }, null, value, arguments.length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5145 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5146
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5147 append: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5148 return this.domManip( arguments, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5149 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5150 var target = manipulationTarget( this, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5151 target.appendChild( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5152 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5153 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5154 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5155
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5156 prepend: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5157 return this.domManip( arguments, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5158 if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5159 var target = manipulationTarget( this, elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5160 target.insertBefore( elem, target.firstChild );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5161 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5162 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5163 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5164
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5165 before: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5166 return this.domManip( arguments, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5167 if ( this.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5168 this.parentNode.insertBefore( elem, this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5169 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5170 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5171 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5172
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5173 after: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5174 return this.domManip( arguments, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5175 if ( this.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5176 this.parentNode.insertBefore( elem, this.nextSibling );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5177 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5178 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5179 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5180
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5181 remove: function( selector, keepData /* Internal Use Only */ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5182 var elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5183 elems = selector ? jQuery.filter( selector, this ) : this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5184 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5185
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5186 for ( ; (elem = elems[i]) != null; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5187 if ( !keepData && elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5188 jQuery.cleanData( getAll( elem ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5189 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5190
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5191 if ( elem.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5192 if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5193 setGlobalEval( getAll( elem, "script" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5194 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5195 elem.parentNode.removeChild( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5196 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5197 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5198
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5199 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5200 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5201
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5202 empty: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5203 var elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5204 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5205
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5206 for ( ; (elem = this[i]) != null; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5207 if ( elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5208
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5209 // Prevent memory leaks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5210 jQuery.cleanData( getAll( elem, false ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5211
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5212 // Remove any remaining nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5213 elem.textContent = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5214 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5215 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5216
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5217 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5218 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5219
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5220 clone: function( dataAndEvents, deepDataAndEvents ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5221 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5222 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5223
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5224 return this.map(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5225 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5226 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5227 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5228
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5229 html: function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5230 return access( this, function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5231 var elem = this[ 0 ] || {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5232 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5233 l = this.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5234
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5235 if ( value === undefined && elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5236 return elem.innerHTML;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5237 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5238
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5239 // See if we can take a shortcut and just use innerHTML
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5240 if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5241 !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5242
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5243 value = value.replace( rxhtmlTag, "<$1></$2>" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5244
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5245 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5246 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5247 elem = this[ i ] || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5248
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5249 // Remove element nodes and prevent memory leaks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5250 if ( elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5251 jQuery.cleanData( getAll( elem, false ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5252 elem.innerHTML = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5253 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5254 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5255
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5256 elem = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5257
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5258 // If using innerHTML throws an exception, use the fallback method
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5259 } catch( e ) {}
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5260 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5261
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5262 if ( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5263 this.empty().append( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5264 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5265 }, null, value, arguments.length );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5266 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5267
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5268 replaceWith: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5269 var arg = arguments[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5270
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5271 // Make the changes, replacing each context element with the new content
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5272 this.domManip( arguments, function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5273 arg = this.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5274
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5275 jQuery.cleanData( getAll( this ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5276
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5277 if ( arg ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5278 arg.replaceChild( elem, this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5279 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5280 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5281
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5282 // Force removal if there was no new content (e.g., from empty arguments)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5283 return arg && (arg.length || arg.nodeType) ? this : this.remove();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5284 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5285
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5286 detach: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5287 return this.remove( selector, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5288 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5289
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5290 domManip: function( args, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5291
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5292 // Flatten any nested arrays
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5293 args = concat.apply( [], args );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5294
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5295 var fragment, first, scripts, hasScripts, node, doc,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5296 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5297 l = this.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5298 set = this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5299 iNoClone = l - 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5300 value = args[ 0 ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5301 isFunction = jQuery.isFunction( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5302
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5303 // We can't cloneNode fragments that contain checked, in WebKit
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5304 if ( isFunction ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5305 ( l > 1 && typeof value === "string" &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5306 !support.checkClone && rchecked.test( value ) ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5307 return this.each(function( index ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5308 var self = set.eq( index );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5309 if ( isFunction ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5310 args[ 0 ] = value.call( this, index, self.html() );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5311 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5312 self.domManip( args, callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5313 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5314 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5315
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5316 if ( l ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5317 fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5318 first = fragment.firstChild;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5319
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5320 if ( fragment.childNodes.length === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5321 fragment = first;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5322 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5323
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5324 if ( first ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5325 scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5326 hasScripts = scripts.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5327
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5328 // Use the original fragment for the last item instead of the first because it can end up
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5329 // being emptied incorrectly in certain situations (#8070).
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5330 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5331 node = fragment;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5332
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5333 if ( i !== iNoClone ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5334 node = jQuery.clone( node, true, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5335
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5336 // Keep references to cloned scripts for later restoration
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5337 if ( hasScripts ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5338 // Support: QtWebKit
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5339 // jQuery.merge because push.apply(_, arraylike) throws
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5340 jQuery.merge( scripts, getAll( node, "script" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5341 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5342 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5343
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5344 callback.call( this[ i ], node, i );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5345 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5346
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5347 if ( hasScripts ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5348 doc = scripts[ scripts.length - 1 ].ownerDocument;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5349
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5350 // Reenable scripts
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5351 jQuery.map( scripts, restoreScript );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5352
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5353 // Evaluate executable scripts on first document insertion
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5354 for ( i = 0; i < hasScripts; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5355 node = scripts[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5356 if ( rscriptType.test( node.type || "" ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5357 !data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5358
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5359 if ( node.src ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5360 // Optional AJAX dependency, but won't run scripts if not present
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5361 if ( jQuery._evalUrl ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5362 jQuery._evalUrl( node.src );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5363 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5364 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5365 jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5366 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5367 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5368 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5369 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5370 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5371 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5372
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5373 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5374 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5375 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5376
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5377 jQuery.each({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5378 appendTo: "append",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5379 prependTo: "prepend",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5380 insertBefore: "before",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5381 insertAfter: "after",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5382 replaceAll: "replaceWith"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5383 }, function( name, original ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5384 jQuery.fn[ name ] = function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5385 var elems,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5386 ret = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5387 insert = jQuery( selector ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5388 last = insert.length - 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5389 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5390
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5391 for ( ; i <= last; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5392 elems = i === last ? this : this.clone( true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5393 jQuery( insert[ i ] )[ original ]( elems );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5394
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5395 // Support: QtWebKit
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5396 // .get() because push.apply(_, arraylike) throws
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5397 push.apply( ret, elems.get() );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5398 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5399
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5400 return this.pushStack( ret );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5401 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5402 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5403
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5404
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5405 var iframe,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5406 elemdisplay = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5407
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5408 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5409 * Retrieve the actual display of a element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5410 * @param {String} name nodeName of the element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5411 * @param {Object} doc Document object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5412 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5413 // Called only from within defaultDisplay
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5414 function actualDisplay( name, doc ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5415 var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5416
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5417 // getDefaultComputedStyle might be reliably used only on attached element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5418 display = window.getDefaultComputedStyle ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5419
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5420 // Use of this method is a temporary fix (more like optmization) until something better comes along,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5421 // since it was removed from specification and supported only in FF
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5422 window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5423
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5424 // We don't have any data stored on the element,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5425 // so use "detach" method as fast way to get rid of the element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5426 elem.detach();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5427
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5428 return display;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5429 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5430
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5431 /**
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5432 * Try to determine the default display value of an element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5433 * @param {String} nodeName
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5434 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5435 function defaultDisplay( nodeName ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5436 var doc = document,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5437 display = elemdisplay[ nodeName ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5438
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5439 if ( !display ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5440 display = actualDisplay( nodeName, doc );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5441
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5442 // If the simple way fails, read from inside an iframe
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5443 if ( display === "none" || !display ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5444
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5445 // Use the already-created iframe if possible
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5446 iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5447
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5448 // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5449 doc = iframe[ 0 ].contentDocument;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5450
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5451 // Support: IE
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5452 doc.write();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5453 doc.close();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5454
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5455 display = actualDisplay( nodeName, doc );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5456 iframe.detach();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5457 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5458
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5459 // Store the correct default display
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5460 elemdisplay[ nodeName ] = display;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5461 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5462
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5463 return display;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5464 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5465 var rmargin = (/^margin/);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5466
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5467 var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5468
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5469 var getStyles = function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5470 return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5471 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5472
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5473
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5474
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5475 function curCSS( elem, name, computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5476 var width, minWidth, maxWidth, ret,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5477 style = elem.style;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5478
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5479 computed = computed || getStyles( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5480
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5481 // Support: IE9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5482 // getPropertyValue is only needed for .css('filter') in IE9, see #12537
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5483 if ( computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5484 ret = computed.getPropertyValue( name ) || computed[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5485 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5486
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5487 if ( computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5488
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5489 if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5490 ret = jQuery.style( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5491 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5492
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5493 // Support: iOS < 6
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5494 // A tribute to the "awesome hack by Dean Edwards"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5495 // iOS < 6 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5496 // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5497 if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5498
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5499 // Remember the original values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5500 width = style.width;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5501 minWidth = style.minWidth;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5502 maxWidth = style.maxWidth;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5503
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5504 // Put in the new values to get a computed value out
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5505 style.minWidth = style.maxWidth = style.width = ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5506 ret = computed.width;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5507
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5508 // Revert the changed values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5509 style.width = width;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5510 style.minWidth = minWidth;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5511 style.maxWidth = maxWidth;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5512 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5513 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5514
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5515 return ret !== undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5516 // Support: IE
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5517 // IE returns zIndex value as an integer.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5518 ret + "" :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5519 ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5520 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5521
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5522
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5523 function addGetHookIf( conditionFn, hookFn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5524 // Define the hook, we'll check on the first run if it's really needed.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5525 return {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5526 get: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5527 if ( conditionFn() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5528 // Hook not needed (or it's not possible to use it due to missing dependency),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5529 // remove it.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5530 // Since there are no other hooks for marginRight, remove the whole object.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5531 delete this.get;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5532 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5533 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5534
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5535 // Hook needed; redefine it so that the support test is not executed again.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5536
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5537 return (this.get = hookFn).apply( this, arguments );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5538 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5539 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5540 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5541
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5542
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5543 (function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5544 var pixelPositionVal, boxSizingReliableVal,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5545 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5546 divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5547 "-moz-box-sizing:content-box;box-sizing:content-box",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5548 docElem = document.documentElement,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5549 container = document.createElement( "div" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5550 div = document.createElement( "div" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5551
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5552 div.style.backgroundClip = "content-box";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5553 div.cloneNode( true ).style.backgroundClip = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5554 support.clearCloneStyle = div.style.backgroundClip === "content-box";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5555
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5556 container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5557 "margin-top:1px";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5558 container.appendChild( div );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5559
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5560 // Executing both pixelPosition & boxSizingReliable tests require only one layout
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5561 // so they're executed at the same time to save the second computation.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5562 function computePixelPositionAndBoxSizingReliable() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5563 // Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5564 div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5565 "box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5566 "position:absolute;top:1%";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5567 docElem.appendChild( container );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5568
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5569 var divStyle = window.getComputedStyle( div, null );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5570 pixelPositionVal = divStyle.top !== "1%";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5571 boxSizingReliableVal = divStyle.width === "4px";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5572
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5573 docElem.removeChild( container );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5574 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5575
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5576 // Use window.getComputedStyle because jsdom on node.js will break without it.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5577 if ( window.getComputedStyle ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5578 jQuery.extend(support, {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5579 pixelPosition: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5580 // This test is executed only once but we still do memoizing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5581 // since we can use the boxSizingReliable pre-computing.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5582 // No need to check if the test was already performed, though.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5583 computePixelPositionAndBoxSizingReliable();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5584 return pixelPositionVal;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5585 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5586 boxSizingReliable: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5587 if ( boxSizingReliableVal == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5588 computePixelPositionAndBoxSizingReliable();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5589 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5590 return boxSizingReliableVal;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5591 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5592 reliableMarginRight: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5593 // Support: Android 2.3
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5594 // Check if div with explicit width and no margin-right incorrectly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5595 // gets computed margin-right based on width of container. (#3333)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5596 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5597 // This support function is only executed once so no memoizing is needed.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5598 var ret,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5599 marginDiv = div.appendChild( document.createElement( "div" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5600 marginDiv.style.cssText = div.style.cssText = divReset;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5601 marginDiv.style.marginRight = marginDiv.style.width = "0";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5602 div.style.width = "1px";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5603 docElem.appendChild( container );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5604
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5605 ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5606
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5607 docElem.removeChild( container );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5608
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5609 // Clean up the div for other support tests.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5610 div.innerHTML = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5611
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5612 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5613 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5614 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5615 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5616 })();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5617
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5618
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5619 // A method for quickly swapping in/out CSS properties to get correct calculations.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5620 jQuery.swap = function( elem, options, callback, args ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5621 var ret, name,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5622 old = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5623
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5624 // Remember the old values, and insert the new ones
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5625 for ( name in options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5626 old[ name ] = elem.style[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5627 elem.style[ name ] = options[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5628 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5629
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5630 ret = callback.apply( elem, args || [] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5631
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5632 // Revert the old values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5633 for ( name in options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5634 elem.style[ name ] = old[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5635 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5636
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5637 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5638 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5639
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5640
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5641 var
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5642 // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5643 // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5644 rdisplayswap = /^(none|table(?!-c[ea]).+)/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5645 rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5646 rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5647
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5648 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5649 cssNormalTransform = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5650 letterSpacing: 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5651 fontWeight: 400
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5652 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5653
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5654 cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5655
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5656 // return a css property mapped to a potentially vendor prefixed property
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5657 function vendorPropName( style, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5658
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5659 // shortcut for names that are not vendor prefixed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5660 if ( name in style ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5661 return name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5662 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5663
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5664 // check for vendor prefixed names
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5665 var capName = name[0].toUpperCase() + name.slice(1),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5666 origName = name,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5667 i = cssPrefixes.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5668
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5669 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5670 name = cssPrefixes[ i ] + capName;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5671 if ( name in style ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5672 return name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5673 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5674 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5675
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5676 return origName;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5677 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5678
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5679 function setPositiveNumber( elem, value, subtract ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5680 var matches = rnumsplit.exec( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5681 return matches ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5682 // Guard against undefined "subtract", e.g., when used as in cssHooks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5683 Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5684 value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5685 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5686
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5687 function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5688 var i = extra === ( isBorderBox ? "border" : "content" ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5689 // If we already have the right measurement, avoid augmentation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5690 4 :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5691 // Otherwise initialize for horizontal or vertical properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5692 name === "width" ? 1 : 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5693
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5694 val = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5695
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5696 for ( ; i < 4; i += 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5697 // both box models exclude margin, so add it if we want it
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5698 if ( extra === "margin" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5699 val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5700 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5701
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5702 if ( isBorderBox ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5703 // border-box includes padding, so remove it if we want content
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5704 if ( extra === "content" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5705 val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5706 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5707
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5708 // at this point, extra isn't border nor margin, so remove border
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5709 if ( extra !== "margin" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5710 val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5711 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5712 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5713 // at this point, extra isn't content, so add padding
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5714 val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5715
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5716 // at this point, extra isn't content nor padding, so add border
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5717 if ( extra !== "padding" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5718 val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5719 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5720 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5721 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5722
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5723 return val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5724 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5725
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5726 function getWidthOrHeight( elem, name, extra ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5727
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5728 // Start with offset property, which is equivalent to the border-box value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5729 var valueIsBorderBox = true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5730 val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5731 styles = getStyles( elem ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5732 isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5733
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5734 // some non-html elements return undefined for offsetWidth, so check for null/undefined
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5735 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5736 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5737 if ( val <= 0 || val == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5738 // Fall back to computed then uncomputed css if necessary
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5739 val = curCSS( elem, name, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5740 if ( val < 0 || val == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5741 val = elem.style[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5742 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5743
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5744 // Computed unit is not pixels. Stop here and return.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5745 if ( rnumnonpx.test(val) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5746 return val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5747 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5748
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5749 // we need the check for style in case a browser which returns unreliable values
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5750 // for getComputedStyle silently falls back to the reliable elem.style
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5751 valueIsBorderBox = isBorderBox &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5752 ( support.boxSizingReliable() || val === elem.style[ name ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5753
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5754 // Normalize "", auto, and prepare for extra
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5755 val = parseFloat( val ) || 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5756 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5757
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5758 // use the active box-sizing model to add/subtract irrelevant styles
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5759 return ( val +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5760 augmentWidthOrHeight(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5761 elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5762 name,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5763 extra || ( isBorderBox ? "border" : "content" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5764 valueIsBorderBox,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5765 styles
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5766 )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5767 ) + "px";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5768 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5769
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5770 function showHide( elements, show ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5771 var display, elem, hidden,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5772 values = [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5773 index = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5774 length = elements.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5775
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5776 for ( ; index < length; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5777 elem = elements[ index ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5778 if ( !elem.style ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5779 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5780 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5781
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5782 values[ index ] = data_priv.get( elem, "olddisplay" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5783 display = elem.style.display;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5784 if ( show ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5785 // Reset the inline display of this element to learn if it is
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5786 // being hidden by cascaded rules or not
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5787 if ( !values[ index ] && display === "none" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5788 elem.style.display = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5789 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5790
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5791 // Set elements which have been overridden with display: none
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5792 // in a stylesheet to whatever the default browser style is
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5793 // for such an element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5794 if ( elem.style.display === "" && isHidden( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5795 values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5796 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5797 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5798
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5799 if ( !values[ index ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5800 hidden = isHidden( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5801
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5802 if ( display && display !== "none" || !hidden ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5803 data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5804 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5805 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5806 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5807 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5808
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5809 // Set the display of most of the elements in a second loop
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5810 // to avoid the constant reflow
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5811 for ( index = 0; index < length; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5812 elem = elements[ index ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5813 if ( !elem.style ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5814 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5815 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5816 if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5817 elem.style.display = show ? values[ index ] || "" : "none";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5818 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5819 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5820
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5821 return elements;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5822 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5823
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5824 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5825 // Add in style property hooks for overriding the default
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5826 // behavior of getting and setting a style property
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5827 cssHooks: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5828 opacity: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5829 get: function( elem, computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5830 if ( computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5831 // We should always get a number back from opacity
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5832 var ret = curCSS( elem, "opacity" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5833 return ret === "" ? "1" : ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5834 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5835 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5836 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5837 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5838
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5839 // Don't automatically add "px" to these possibly-unitless properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5840 cssNumber: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5841 "columnCount": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5842 "fillOpacity": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5843 "fontWeight": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5844 "lineHeight": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5845 "opacity": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5846 "order": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5847 "orphans": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5848 "widows": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5849 "zIndex": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5850 "zoom": true
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5851 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5852
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5853 // Add in properties whose names you wish to fix before
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5854 // setting or getting the value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5855 cssProps: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5856 // normalize float css property
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5857 "float": "cssFloat"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5858 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5859
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5860 // Get and set the style property on a DOM Node
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5861 style: function( elem, name, value, extra ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5862 // Don't set styles on text and comment nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5863 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5864 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5865 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5866
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5867 // Make sure that we're working with the right name
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5868 var ret, type, hooks,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5869 origName = jQuery.camelCase( name ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5870 style = elem.style;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5871
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5872 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5873
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5874 // gets hook for the prefixed version
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5875 // followed by the unprefixed version
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5876 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5877
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5878 // Check if we're setting a value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5879 if ( value !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5880 type = typeof value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5881
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5882 // convert relative number strings (+= or -=) to relative numbers. #7345
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5883 if ( type === "string" && (ret = rrelNum.exec( value )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5884 value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5885 // Fixes bug #9237
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5886 type = "number";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5887 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5888
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5889 // Make sure that null and NaN values aren't set. See: #7116
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5890 if ( value == null || value !== value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5891 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5892 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5893
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5894 // If a number was passed in, add 'px' to the (except for certain CSS properties)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5895 if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5896 value += "px";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5897 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5898
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5899 // Fixes #8908, it can be done more correctly by specifying setters in cssHooks,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5900 // but it would mean to define eight (for every problematic property) identical functions
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5901 if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5902 style[ name ] = "inherit";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5903 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5904
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5905 // If a hook was provided, use that value, otherwise just set the specified value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5906 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5907 // Support: Chrome, Safari
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5908 // Setting style to blank string required to delete "style: x !important;"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5909 style[ name ] = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5910 style[ name ] = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5911 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5912
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5913 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5914 // If a hook was provided get the non-computed value from there
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5915 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5916 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5917 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5918
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5919 // Otherwise just get the value from the style object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5920 return style[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5921 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5922 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5923
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5924 css: function( elem, name, extra, styles ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5925 var val, num, hooks,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5926 origName = jQuery.camelCase( name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5927
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5928 // Make sure that we're working with the right name
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5929 name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5930
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5931 // gets hook for the prefixed version
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5932 // followed by the unprefixed version
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5933 hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5934
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5935 // If a hook was provided get the computed value from there
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5936 if ( hooks && "get" in hooks ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5937 val = hooks.get( elem, true, extra );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5938 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5939
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5940 // Otherwise, if a way to get the computed value exists, use that
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5941 if ( val === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5942 val = curCSS( elem, name, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5943 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5944
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5945 //convert "normal" to computed value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5946 if ( val === "normal" && name in cssNormalTransform ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5947 val = cssNormalTransform[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5948 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5949
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5950 // Return, converting to number if forced or a qualifier was provided and val looks numeric
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5951 if ( extra === "" || extra ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5952 num = parseFloat( val );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5953 return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5954 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5955 return val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5956 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5957 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5958
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5959 jQuery.each([ "height", "width" ], function( i, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5960 jQuery.cssHooks[ name ] = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5961 get: function( elem, computed, extra ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5962 if ( computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5963 // certain elements can have dimension info if we invisibly show them
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5964 // however, it must have a current display style that would benefit from this
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5965 return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5966 jQuery.swap( elem, cssShow, function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5967 return getWidthOrHeight( elem, name, extra );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5968 }) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5969 getWidthOrHeight( elem, name, extra );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5970 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5971 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5972
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5973 set: function( elem, value, extra ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5974 var styles = extra && getStyles( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5975 return setPositiveNumber( elem, value, extra ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5976 augmentWidthOrHeight(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5977 elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5978 name,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5979 extra,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5980 jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5981 styles
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5982 ) : 0
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5983 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5984 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5985 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5986 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5987
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5988 // Support: Android 2.3
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5989 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5990 function( elem, computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5991 if ( computed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5992 // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5993 // Work around by temporarily setting element display to inline-block
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5994 return jQuery.swap( elem, { "display": "inline-block" },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5995 curCSS, [ elem, "marginRight" ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5996 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5997 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5998 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5999
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6000 // These hooks are used by animate to expand properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6001 jQuery.each({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6002 margin: "",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6003 padding: "",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6004 border: "Width"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6005 }, function( prefix, suffix ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6006 jQuery.cssHooks[ prefix + suffix ] = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6007 expand: function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6008 var i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6009 expanded = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6010
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6011 // assumes a single number if not a string
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6012 parts = typeof value === "string" ? value.split(" ") : [ value ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6013
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6014 for ( ; i < 4; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6015 expanded[ prefix + cssExpand[ i ] + suffix ] =
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6016 parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6017 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6018
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6019 return expanded;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6020 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6021 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6022
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6023 if ( !rmargin.test( prefix ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6024 jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6025 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6026 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6027
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6028 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6029 css: function( name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6030 return access( this, function( elem, name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6031 var styles, len,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6032 map = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6033 i = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6034
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6035 if ( jQuery.isArray( name ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6036 styles = getStyles( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6037 len = name.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6038
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6039 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6040 map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6041 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6042
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6043 return map;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6044 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6045
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6046 return value !== undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6047 jQuery.style( elem, name, value ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6048 jQuery.css( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6049 }, name, value, arguments.length > 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6050 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6051 show: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6052 return showHide( this, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6053 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6054 hide: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6055 return showHide( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6056 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6057 toggle: function( state ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6058 if ( typeof state === "boolean" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6059 return state ? this.show() : this.hide();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6060 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6061
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6062 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6063 if ( isHidden( this ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6064 jQuery( this ).show();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6065 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6066 jQuery( this ).hide();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6067 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6068 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6069 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6070 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6071
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6072
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6073 function Tween( elem, options, prop, end, easing ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6074 return new Tween.prototype.init( elem, options, prop, end, easing );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6075 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6076 jQuery.Tween = Tween;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6077
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6078 Tween.prototype = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6079 constructor: Tween,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6080 init: function( elem, options, prop, end, easing, unit ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6081 this.elem = elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6082 this.prop = prop;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6083 this.easing = easing || "swing";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6084 this.options = options;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6085 this.start = this.now = this.cur();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6086 this.end = end;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6087 this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6088 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6089 cur: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6090 var hooks = Tween.propHooks[ this.prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6091
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6092 return hooks && hooks.get ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6093 hooks.get( this ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6094 Tween.propHooks._default.get( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6095 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6096 run: function( percent ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6097 var eased,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6098 hooks = Tween.propHooks[ this.prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6099
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6100 if ( this.options.duration ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6101 this.pos = eased = jQuery.easing[ this.easing ](
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6102 percent, this.options.duration * percent, 0, 1, this.options.duration
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6103 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6104 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6105 this.pos = eased = percent;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6106 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6107 this.now = ( this.end - this.start ) * eased + this.start;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6108
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6109 if ( this.options.step ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6110 this.options.step.call( this.elem, this.now, this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6111 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6112
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6113 if ( hooks && hooks.set ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6114 hooks.set( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6115 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6116 Tween.propHooks._default.set( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6117 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6118 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6119 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6120 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6121
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6122 Tween.prototype.init.prototype = Tween.prototype;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6123
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6124 Tween.propHooks = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6125 _default: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6126 get: function( tween ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6127 var result;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6128
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6129 if ( tween.elem[ tween.prop ] != null &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6130 (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6131 return tween.elem[ tween.prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6132 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6133
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6134 // passing an empty string as a 3rd parameter to .css will automatically
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6135 // attempt a parseFloat and fallback to a string if the parse fails
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6136 // so, simple values such as "10px" are parsed to Float.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6137 // complex values such as "rotate(1rad)" are returned as is.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6138 result = jQuery.css( tween.elem, tween.prop, "" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6139 // Empty strings, null, undefined and "auto" are converted to 0.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6140 return !result || result === "auto" ? 0 : result;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6141 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6142 set: function( tween ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6143 // use step hook for back compat - use cssHook if its there - use .style if its
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6144 // available and use plain properties where available
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6145 if ( jQuery.fx.step[ tween.prop ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6146 jQuery.fx.step[ tween.prop ]( tween );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6147 } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6148 jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6149 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6150 tween.elem[ tween.prop ] = tween.now;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6151 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6152 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6153 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6154 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6155
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6156 // Support: IE9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6157 // Panic based approach to setting things on disconnected nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6158
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6159 Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6160 set: function( tween ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6161 if ( tween.elem.nodeType && tween.elem.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6162 tween.elem[ tween.prop ] = tween.now;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6163 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6164 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6165 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6166
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6167 jQuery.easing = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6168 linear: function( p ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6169 return p;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6170 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6171 swing: function( p ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6172 return 0.5 - Math.cos( p * Math.PI ) / 2;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6173 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6174 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6175
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6176 jQuery.fx = Tween.prototype.init;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6177
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6178 // Back Compat <1.8 extension point
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6179 jQuery.fx.step = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6180
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6181
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6182
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6183
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6184 var
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6185 fxNow, timerId,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6186 rfxtypes = /^(?:toggle|show|hide)$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6187 rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6188 rrun = /queueHooks$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6189 animationPrefilters = [ defaultPrefilter ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6190 tweeners = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6191 "*": [ function( prop, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6192 var tween = this.createTween( prop, value ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6193 target = tween.cur(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6194 parts = rfxnum.exec( value ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6195 unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6196
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6197 // Starting value computation is required for potential unit mismatches
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6198 start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6199 rfxnum.exec( jQuery.css( tween.elem, prop ) ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6200 scale = 1,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6201 maxIterations = 20;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6202
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6203 if ( start && start[ 3 ] !== unit ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6204 // Trust units reported by jQuery.css
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6205 unit = unit || start[ 3 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6206
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6207 // Make sure we update the tween properties later on
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6208 parts = parts || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6209
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6210 // Iteratively approximate from a nonzero starting point
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6211 start = +target || 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6212
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6213 do {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6214 // If previous iteration zeroed out, double until we get *something*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6215 // Use a string for doubling factor so we don't accidentally see scale as unchanged below
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6216 scale = scale || ".5";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6217
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6218 // Adjust and apply
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6219 start = start / scale;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6220 jQuery.style( tween.elem, prop, start + unit );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6221
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6222 // Update scale, tolerating zero or NaN from tween.cur()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6223 // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6224 } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6225 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6226
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6227 // Update tween properties
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6228 if ( parts ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6229 start = tween.start = +start || +target || 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6230 tween.unit = unit;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6231 // If a +=/-= token was provided, we're doing a relative animation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6232 tween.end = parts[ 1 ] ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6233 start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6234 +parts[ 2 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6235 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6236
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6237 return tween;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6238 } ]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6239 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6240
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6241 // Animations created synchronously will run synchronously
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6242 function createFxNow() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6243 setTimeout(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6244 fxNow = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6245 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6246 return ( fxNow = jQuery.now() );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6247 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6248
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6249 // Generate parameters to create a standard animation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6250 function genFx( type, includeWidth ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6251 var which,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6252 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6253 attrs = { height: type };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6254
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6255 // if we include width, step value is 1 to do all cssExpand values,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6256 // if we don't include width, step value is 2 to skip over Left and Right
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6257 includeWidth = includeWidth ? 1 : 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6258 for ( ; i < 4 ; i += 2 - includeWidth ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6259 which = cssExpand[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6260 attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6261 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6262
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6263 if ( includeWidth ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6264 attrs.opacity = attrs.width = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6265 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6266
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6267 return attrs;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6268 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6269
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6270 function createTween( value, prop, animation ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6271 var tween,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6272 collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6273 index = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6274 length = collection.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6275 for ( ; index < length; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6276 if ( (tween = collection[ index ].call( animation, prop, value )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6277
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6278 // we're done with this property
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6279 return tween;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6280 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6281 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6282 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6283
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6284 function defaultPrefilter( elem, props, opts ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6285 /* jshint validthis: true */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6286 var prop, value, toggle, tween, hooks, oldfire, display,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6287 anim = this,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6288 orig = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6289 style = elem.style,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6290 hidden = elem.nodeType && isHidden( elem ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6291 dataShow = data_priv.get( elem, "fxshow" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6292
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6293 // handle queue: false promises
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6294 if ( !opts.queue ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6295 hooks = jQuery._queueHooks( elem, "fx" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6296 if ( hooks.unqueued == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6297 hooks.unqueued = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6298 oldfire = hooks.empty.fire;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6299 hooks.empty.fire = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6300 if ( !hooks.unqueued ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6301 oldfire();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6302 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6303 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6304 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6305 hooks.unqueued++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6306
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6307 anim.always(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6308 // doing this makes sure that the complete handler will be called
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6309 // before this completes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6310 anim.always(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6311 hooks.unqueued--;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6312 if ( !jQuery.queue( elem, "fx" ).length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6313 hooks.empty.fire();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6314 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6315 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6316 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6317 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6318
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6319 // height/width overflow pass
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6320 if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6321 // Make sure that nothing sneaks out
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6322 // Record all 3 overflow attributes because IE9-10 do not
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6323 // change the overflow attribute when overflowX and
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6324 // overflowY are set to the same value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6325 opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6326
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6327 // Set display property to inline-block for height/width
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6328 // animations on inline elements that are having width/height animated
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6329 display = jQuery.css( elem, "display" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6330 // Get default display if display is currently "none"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6331 if ( display === "none" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6332 display = defaultDisplay( elem.nodeName );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6333 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6334 if ( display === "inline" &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6335 jQuery.css( elem, "float" ) === "none" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6336
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6337 style.display = "inline-block";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6338 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6339 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6340
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6341 if ( opts.overflow ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6342 style.overflow = "hidden";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6343 anim.always(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6344 style.overflow = opts.overflow[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6345 style.overflowX = opts.overflow[ 1 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6346 style.overflowY = opts.overflow[ 2 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6347 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6348 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6349
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6350 // show/hide pass
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6351 for ( prop in props ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6352 value = props[ prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6353 if ( rfxtypes.exec( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6354 delete props[ prop ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6355 toggle = toggle || value === "toggle";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6356 if ( value === ( hidden ? "hide" : "show" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6357
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6358 // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6359 if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6360 hidden = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6361 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6362 continue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6363 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6364 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6365 orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6366 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6367 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6368
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6369 if ( !jQuery.isEmptyObject( orig ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6370 if ( dataShow ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6371 if ( "hidden" in dataShow ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6372 hidden = dataShow.hidden;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6373 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6374 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6375 dataShow = data_priv.access( elem, "fxshow", {} );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6376 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6377
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6378 // store state if its toggle - enables .stop().toggle() to "reverse"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6379 if ( toggle ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6380 dataShow.hidden = !hidden;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6381 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6382 if ( hidden ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6383 jQuery( elem ).show();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6384 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6385 anim.done(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6386 jQuery( elem ).hide();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6387 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6388 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6389 anim.done(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6390 var prop;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6391
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6392 data_priv.remove( elem, "fxshow" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6393 for ( prop in orig ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6394 jQuery.style( elem, prop, orig[ prop ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6395 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6396 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6397 for ( prop in orig ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6398 tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6399
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6400 if ( !( prop in dataShow ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6401 dataShow[ prop ] = tween.start;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6402 if ( hidden ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6403 tween.end = tween.start;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6404 tween.start = prop === "width" || prop === "height" ? 1 : 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6405 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6406 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6407 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6408 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6409 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6410
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6411 function propFilter( props, specialEasing ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6412 var index, name, easing, value, hooks;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6413
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6414 // camelCase, specialEasing and expand cssHook pass
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6415 for ( index in props ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6416 name = jQuery.camelCase( index );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6417 easing = specialEasing[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6418 value = props[ index ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6419 if ( jQuery.isArray( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6420 easing = value[ 1 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6421 value = props[ index ] = value[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6422 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6423
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6424 if ( index !== name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6425 props[ name ] = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6426 delete props[ index ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6427 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6428
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6429 hooks = jQuery.cssHooks[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6430 if ( hooks && "expand" in hooks ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6431 value = hooks.expand( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6432 delete props[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6433
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6434 // not quite $.extend, this wont overwrite keys already present.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6435 // also - reusing 'index' from above because we have the correct "name"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6436 for ( index in value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6437 if ( !( index in props ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6438 props[ index ] = value[ index ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6439 specialEasing[ index ] = easing;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6440 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6441 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6442 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6443 specialEasing[ name ] = easing;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6444 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6445 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6446 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6447
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6448 function Animation( elem, properties, options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6449 var result,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6450 stopped,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6451 index = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6452 length = animationPrefilters.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6453 deferred = jQuery.Deferred().always( function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6454 // don't match elem in the :animated selector
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6455 delete tick.elem;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6456 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6457 tick = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6458 if ( stopped ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6459 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6460 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6461 var currentTime = fxNow || createFxNow(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6462 remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6463 // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6464 temp = remaining / animation.duration || 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6465 percent = 1 - temp,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6466 index = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6467 length = animation.tweens.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6468
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6469 for ( ; index < length ; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6470 animation.tweens[ index ].run( percent );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6471 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6472
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6473 deferred.notifyWith( elem, [ animation, percent, remaining ]);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6474
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6475 if ( percent < 1 && length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6476 return remaining;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6477 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6478 deferred.resolveWith( elem, [ animation ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6479 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6480 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6481 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6482 animation = deferred.promise({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6483 elem: elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6484 props: jQuery.extend( {}, properties ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6485 opts: jQuery.extend( true, { specialEasing: {} }, options ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6486 originalProperties: properties,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6487 originalOptions: options,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6488 startTime: fxNow || createFxNow(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6489 duration: options.duration,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6490 tweens: [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6491 createTween: function( prop, end ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6492 var tween = jQuery.Tween( elem, animation.opts, prop, end,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6493 animation.opts.specialEasing[ prop ] || animation.opts.easing );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6494 animation.tweens.push( tween );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6495 return tween;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6496 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6497 stop: function( gotoEnd ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6498 var index = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6499 // if we are going to the end, we want to run all the tweens
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6500 // otherwise we skip this part
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6501 length = gotoEnd ? animation.tweens.length : 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6502 if ( stopped ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6503 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6504 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6505 stopped = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6506 for ( ; index < length ; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6507 animation.tweens[ index ].run( 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6508 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6509
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6510 // resolve when we played the last frame
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6511 // otherwise, reject
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6512 if ( gotoEnd ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6513 deferred.resolveWith( elem, [ animation, gotoEnd ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6514 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6515 deferred.rejectWith( elem, [ animation, gotoEnd ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6516 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6517 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6518 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6519 }),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6520 props = animation.props;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6521
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6522 propFilter( props, animation.opts.specialEasing );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6523
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6524 for ( ; index < length ; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6525 result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6526 if ( result ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6527 return result;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6528 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6529 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6530
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6531 jQuery.map( props, createTween, animation );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6532
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6533 if ( jQuery.isFunction( animation.opts.start ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6534 animation.opts.start.call( elem, animation );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6535 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6536
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6537 jQuery.fx.timer(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6538 jQuery.extend( tick, {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6539 elem: elem,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6540 anim: animation,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6541 queue: animation.opts.queue
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6542 })
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6543 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6544
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6545 // attach callbacks from options
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6546 return animation.progress( animation.opts.progress )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6547 .done( animation.opts.done, animation.opts.complete )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6548 .fail( animation.opts.fail )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6549 .always( animation.opts.always );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6550 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6551
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6552 jQuery.Animation = jQuery.extend( Animation, {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6553
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6554 tweener: function( props, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6555 if ( jQuery.isFunction( props ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6556 callback = props;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6557 props = [ "*" ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6558 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6559 props = props.split(" ");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6560 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6561
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6562 var prop,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6563 index = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6564 length = props.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6565
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6566 for ( ; index < length ; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6567 prop = props[ index ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6568 tweeners[ prop ] = tweeners[ prop ] || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6569 tweeners[ prop ].unshift( callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6570 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6571 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6572
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6573 prefilter: function( callback, prepend ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6574 if ( prepend ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6575 animationPrefilters.unshift( callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6576 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6577 animationPrefilters.push( callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6578 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6579 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6580 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6581
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6582 jQuery.speed = function( speed, easing, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6583 var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6584 complete: fn || !fn && easing ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6585 jQuery.isFunction( speed ) && speed,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6586 duration: speed,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6587 easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6588 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6589
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6590 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6591 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6592
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6593 // normalize opt.queue - true/undefined/null -> "fx"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6594 if ( opt.queue == null || opt.queue === true ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6595 opt.queue = "fx";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6596 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6597
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6598 // Queueing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6599 opt.old = opt.complete;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6600
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6601 opt.complete = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6602 if ( jQuery.isFunction( opt.old ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6603 opt.old.call( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6604 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6605
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6606 if ( opt.queue ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6607 jQuery.dequeue( this, opt.queue );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6608 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6609 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6610
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6611 return opt;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6612 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6613
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6614 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6615 fadeTo: function( speed, to, easing, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6616
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6617 // show any hidden elements after setting opacity to 0
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6618 return this.filter( isHidden ).css( "opacity", 0 ).show()
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6619
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6620 // animate to the value specified
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6621 .end().animate({ opacity: to }, speed, easing, callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6622 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6623 animate: function( prop, speed, easing, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6624 var empty = jQuery.isEmptyObject( prop ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6625 optall = jQuery.speed( speed, easing, callback ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6626 doAnimation = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6627 // Operate on a copy of prop so per-property easing won't be lost
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6628 var anim = Animation( this, jQuery.extend( {}, prop ), optall );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6629
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6630 // Empty animations, or finishing resolves immediately
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6631 if ( empty || data_priv.get( this, "finish" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6632 anim.stop( true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6633 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6634 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6635 doAnimation.finish = doAnimation;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6636
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6637 return empty || optall.queue === false ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6638 this.each( doAnimation ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6639 this.queue( optall.queue, doAnimation );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6640 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6641 stop: function( type, clearQueue, gotoEnd ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6642 var stopQueue = function( hooks ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6643 var stop = hooks.stop;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6644 delete hooks.stop;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6645 stop( gotoEnd );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6646 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6647
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6648 if ( typeof type !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6649 gotoEnd = clearQueue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6650 clearQueue = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6651 type = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6652 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6653 if ( clearQueue && type !== false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6654 this.queue( type || "fx", [] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6655 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6656
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6657 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6658 var dequeue = true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6659 index = type != null && type + "queueHooks",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6660 timers = jQuery.timers,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6661 data = data_priv.get( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6662
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6663 if ( index ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6664 if ( data[ index ] && data[ index ].stop ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6665 stopQueue( data[ index ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6666 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6667 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6668 for ( index in data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6669 if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6670 stopQueue( data[ index ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6671 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6672 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6673 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6674
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6675 for ( index = timers.length; index--; ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6676 if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6677 timers[ index ].anim.stop( gotoEnd );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6678 dequeue = false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6679 timers.splice( index, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6680 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6681 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6682
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6683 // start the next in the queue if the last step wasn't forced
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6684 // timers currently will call their complete callbacks, which will dequeue
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6685 // but only if they were gotoEnd
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6686 if ( dequeue || !gotoEnd ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6687 jQuery.dequeue( this, type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6688 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6689 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6690 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6691 finish: function( type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6692 if ( type !== false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6693 type = type || "fx";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6694 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6695 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6696 var index,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6697 data = data_priv.get( this ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6698 queue = data[ type + "queue" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6699 hooks = data[ type + "queueHooks" ],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6700 timers = jQuery.timers,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6701 length = queue ? queue.length : 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6702
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6703 // enable finishing flag on private data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6704 data.finish = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6705
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6706 // empty the queue first
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6707 jQuery.queue( this, type, [] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6708
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6709 if ( hooks && hooks.stop ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6710 hooks.stop.call( this, true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6711 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6712
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6713 // look for any active animations, and finish them
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6714 for ( index = timers.length; index--; ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6715 if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6716 timers[ index ].anim.stop( true );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6717 timers.splice( index, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6718 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6719 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6720
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6721 // look for any animations in the old queue and finish them
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6722 for ( index = 0; index < length; index++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6723 if ( queue[ index ] && queue[ index ].finish ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6724 queue[ index ].finish.call( this );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6725 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6726 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6727
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6728 // turn off finishing flag
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6729 delete data.finish;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6730 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6731 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6732 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6733
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6734 jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6735 var cssFn = jQuery.fn[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6736 jQuery.fn[ name ] = function( speed, easing, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6737 return speed == null || typeof speed === "boolean" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6738 cssFn.apply( this, arguments ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6739 this.animate( genFx( name, true ), speed, easing, callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6740 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6741 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6742
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6743 // Generate shortcuts for custom animations
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6744 jQuery.each({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6745 slideDown: genFx("show"),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6746 slideUp: genFx("hide"),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6747 slideToggle: genFx("toggle"),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6748 fadeIn: { opacity: "show" },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6749 fadeOut: { opacity: "hide" },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6750 fadeToggle: { opacity: "toggle" }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6751 }, function( name, props ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6752 jQuery.fn[ name ] = function( speed, easing, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6753 return this.animate( props, speed, easing, callback );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6754 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6755 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6756
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6757 jQuery.timers = [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6758 jQuery.fx.tick = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6759 var timer,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6760 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6761 timers = jQuery.timers;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6762
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6763 fxNow = jQuery.now();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6764
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6765 for ( ; i < timers.length; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6766 timer = timers[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6767 // Checks the timer has not already been removed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6768 if ( !timer() && timers[ i ] === timer ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6769 timers.splice( i--, 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6770 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6771 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6772
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6773 if ( !timers.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6774 jQuery.fx.stop();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6775 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6776 fxNow = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6777 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6778
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6779 jQuery.fx.timer = function( timer ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6780 jQuery.timers.push( timer );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6781 if ( timer() ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6782 jQuery.fx.start();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6783 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6784 jQuery.timers.pop();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6785 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6786 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6787
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6788 jQuery.fx.interval = 13;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6789
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6790 jQuery.fx.start = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6791 if ( !timerId ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6792 timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6793 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6794 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6795
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6796 jQuery.fx.stop = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6797 clearInterval( timerId );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6798 timerId = null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6799 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6800
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6801 jQuery.fx.speeds = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6802 slow: 600,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6803 fast: 200,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6804 // Default speed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6805 _default: 400
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6806 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6807
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6808
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6809 // Based off of the plugin by Clint Helfers, with permission.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6810 // http://blindsignals.com/index.php/2009/07/jquery-delay/
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6811 jQuery.fn.delay = function( time, type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6812 time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6813 type = type || "fx";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6814
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6815 return this.queue( type, function( next, hooks ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6816 var timeout = setTimeout( next, time );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6817 hooks.stop = function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6818 clearTimeout( timeout );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6819 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6820 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6821 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6822
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6823
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6824 (function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6825 var input = document.createElement( "input" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6826 select = document.createElement( "select" ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6827 opt = select.appendChild( document.createElement( "option" ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6828
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6829 input.type = "checkbox";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6830
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6831 // Support: iOS 5.1, Android 4.x, Android 2.3
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6832 // Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6833 support.checkOn = input.value !== "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6834
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6835 // Must access the parent to make an option select properly
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6836 // Support: IE9, IE10
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6837 support.optSelected = opt.selected;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6838
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6839 // Make sure that the options inside disabled selects aren't marked as disabled
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6840 // (WebKit marks them as disabled)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6841 select.disabled = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6842 support.optDisabled = !opt.disabled;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6843
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6844 // Check if an input maintains its value after becoming a radio
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6845 // Support: IE9, IE10
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6846 input = document.createElement( "input" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6847 input.value = "t";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6848 input.type = "radio";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6849 support.radioValue = input.value === "t";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6850 })();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6851
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6852
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6853 var nodeHook, boolHook,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6854 attrHandle = jQuery.expr.attrHandle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6855
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6856 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6857 attr: function( name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6858 return access( this, jQuery.attr, name, value, arguments.length > 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6859 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6860
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6861 removeAttr: function( name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6862 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6863 jQuery.removeAttr( this, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6864 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6865 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6866 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6867
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6868 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6869 attr: function( elem, name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6870 var hooks, ret,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6871 nType = elem.nodeType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6872
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6873 // don't get/set attributes on text, comment and attribute nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6874 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6875 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6876 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6877
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6878 // Fallback to prop when attributes are not supported
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6879 if ( typeof elem.getAttribute === strundefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6880 return jQuery.prop( elem, name, value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6881 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6882
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6883 // All attributes are lowercase
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6884 // Grab necessary hook if one is defined
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6885 if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6886 name = name.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6887 hooks = jQuery.attrHooks[ name ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6888 ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6889 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6890
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6891 if ( value !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6892
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6893 if ( value === null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6894 jQuery.removeAttr( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6895
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6896 } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6897 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6898
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6899 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6900 elem.setAttribute( name, value + "" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6901 return value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6902 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6903
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6904 } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6905 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6906
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6907 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6908 ret = jQuery.find.attr( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6909
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6910 // Non-existent attributes return null, we normalize to undefined
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6911 return ret == null ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6912 undefined :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6913 ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6914 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6915 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6916
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6917 removeAttr: function( elem, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6918 var name, propName,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6919 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6920 attrNames = value && value.match( rnotwhite );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6921
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6922 if ( attrNames && elem.nodeType === 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6923 while ( (name = attrNames[i++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6924 propName = jQuery.propFix[ name ] || name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6925
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6926 // Boolean attributes get special treatment (#10870)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6927 if ( jQuery.expr.match.bool.test( name ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6928 // Set corresponding property to false
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6929 elem[ propName ] = false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6930 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6931
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6932 elem.removeAttribute( name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6933 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6934 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6935 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6936
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6937 attrHooks: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6938 type: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6939 set: function( elem, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6940 if ( !support.radioValue && value === "radio" &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6941 jQuery.nodeName( elem, "input" ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6942 // Setting the type on a radio button after the value resets the value in IE6-9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6943 // Reset value to default in case type is set after value during creation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6944 var val = elem.value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6945 elem.setAttribute( "type", value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6946 if ( val ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6947 elem.value = val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6948 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6949 return value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6950 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6951 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6952 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6953 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6954 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6955
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6956 // Hooks for boolean attributes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6957 boolHook = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6958 set: function( elem, value, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6959 if ( value === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6960 // Remove boolean attributes when set to false
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6961 jQuery.removeAttr( elem, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6962 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6963 elem.setAttribute( name, name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6964 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6965 return name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6966 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6967 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6968 jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6969 var getter = attrHandle[ name ] || jQuery.find.attr;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6970
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6971 attrHandle[ name ] = function( elem, name, isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6972 var ret, handle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6973 if ( !isXML ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6974 // Avoid an infinite loop by temporarily removing this function from the getter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6975 handle = attrHandle[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6976 attrHandle[ name ] = ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6977 ret = getter( elem, name, isXML ) != null ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6978 name.toLowerCase() :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6979 null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6980 attrHandle[ name ] = handle;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6981 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6982 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6983 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6984 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6985
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6986
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6987
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6988
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6989 var rfocusable = /^(?:input|select|textarea|button)$/i;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6990
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6991 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6992 prop: function( name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6993 return access( this, jQuery.prop, name, value, arguments.length > 1 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6994 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6995
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6996 removeProp: function( name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6997 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6998 delete this[ jQuery.propFix[ name ] || name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6999 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7000 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7001 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7002
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7003 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7004 propFix: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7005 "for": "htmlFor",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7006 "class": "className"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7007 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7008
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7009 prop: function( elem, name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7010 var ret, hooks, notxml,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7011 nType = elem.nodeType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7012
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7013 // don't get/set properties on text, comment and attribute nodes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7014 if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7015 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7016 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7017
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7018 notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7019
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7020 if ( notxml ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7021 // Fix name and attach hooks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7022 name = jQuery.propFix[ name ] || name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7023 hooks = jQuery.propHooks[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7024 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7025
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7026 if ( value !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7027 return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7028 ret :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7029 ( elem[ name ] = value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7030
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7031 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7032 return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7033 ret :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7034 elem[ name ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7035 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7036 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7037
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7038 propHooks: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7039 tabIndex: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7040 get: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7041 return elem.hasAttribute( "tabindex" ) || rfocusable.test( elem.nodeName ) || elem.href ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7042 elem.tabIndex :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7043 -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7044 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7045 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7046 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7047 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7048
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7049 // Support: IE9+
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7050 // Selectedness for an option in an optgroup can be inaccurate
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7051 if ( !support.optSelected ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7052 jQuery.propHooks.selected = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7053 get: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7054 var parent = elem.parentNode;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7055 if ( parent && parent.parentNode ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7056 parent.parentNode.selectedIndex;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7057 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7058 return null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7059 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7060 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7061 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7062
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7063 jQuery.each([
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7064 "tabIndex",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7065 "readOnly",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7066 "maxLength",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7067 "cellSpacing",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7068 "cellPadding",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7069 "rowSpan",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7070 "colSpan",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7071 "useMap",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7072 "frameBorder",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7073 "contentEditable"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7074 ], function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7075 jQuery.propFix[ this.toLowerCase() ] = this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7076 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7077
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7078
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7079
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7080
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7081 var rclass = /[\t\r\n\f]/g;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7082
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7083 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7084 addClass: function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7085 var classes, elem, cur, clazz, j, finalValue,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7086 proceed = typeof value === "string" && value,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7087 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7088 len = this.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7089
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7090 if ( jQuery.isFunction( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7091 return this.each(function( j ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7092 jQuery( this ).addClass( value.call( this, j, this.className ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7093 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7094 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7095
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7096 if ( proceed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7097 // The disjunction here is for better compressibility (see removeClass)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7098 classes = ( value || "" ).match( rnotwhite ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7099
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7100 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7101 elem = this[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7102 cur = elem.nodeType === 1 && ( elem.className ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7103 ( " " + elem.className + " " ).replace( rclass, " " ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7104 " "
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7105 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7106
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7107 if ( cur ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7108 j = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7109 while ( (clazz = classes[j++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7110 if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7111 cur += clazz + " ";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7112 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7113 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7114
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7115 // only assign if different to avoid unneeded rendering.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7116 finalValue = jQuery.trim( cur );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7117 if ( elem.className !== finalValue ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7118 elem.className = finalValue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7119 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7120 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7121 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7122 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7123
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7124 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7125 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7126
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7127 removeClass: function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7128 var classes, elem, cur, clazz, j, finalValue,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7129 proceed = arguments.length === 0 || typeof value === "string" && value,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7130 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7131 len = this.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7132
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7133 if ( jQuery.isFunction( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7134 return this.each(function( j ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7135 jQuery( this ).removeClass( value.call( this, j, this.className ) );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7136 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7137 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7138 if ( proceed ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7139 classes = ( value || "" ).match( rnotwhite ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7140
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7141 for ( ; i < len; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7142 elem = this[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7143 // This expression is here for better compressibility (see addClass)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7144 cur = elem.nodeType === 1 && ( elem.className ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7145 ( " " + elem.className + " " ).replace( rclass, " " ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7146 ""
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7147 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7148
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7149 if ( cur ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7150 j = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7151 while ( (clazz = classes[j++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7152 // Remove *all* instances
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7153 while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7154 cur = cur.replace( " " + clazz + " ", " " );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7155 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7156 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7157
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7158 // only assign if different to avoid unneeded rendering.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7159 finalValue = value ? jQuery.trim( cur ) : "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7160 if ( elem.className !== finalValue ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7161 elem.className = finalValue;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7162 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7163 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7164 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7165 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7166
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7167 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7168 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7169
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7170 toggleClass: function( value, stateVal ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7171 var type = typeof value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7172
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7173 if ( typeof stateVal === "boolean" && type === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7174 return stateVal ? this.addClass( value ) : this.removeClass( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7175 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7176
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7177 if ( jQuery.isFunction( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7178 return this.each(function( i ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7179 jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7180 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7181 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7182
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7183 return this.each(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7184 if ( type === "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7185 // toggle individual class names
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7186 var className,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7187 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7188 self = jQuery( this ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7189 classNames = value.match( rnotwhite ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7190
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7191 while ( (className = classNames[ i++ ]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7192 // check each className given, space separated list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7193 if ( self.hasClass( className ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7194 self.removeClass( className );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7195 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7196 self.addClass( className );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7197 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7198 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7199
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7200 // Toggle whole class name
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7201 } else if ( type === strundefined || type === "boolean" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7202 if ( this.className ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7203 // store className if set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7204 data_priv.set( this, "__className__", this.className );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7205 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7206
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7207 // If the element has a class name or if we're passed "false",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7208 // then remove the whole classname (if there was one, the above saved it).
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7209 // Otherwise bring back whatever was previously saved (if anything),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7210 // falling back to the empty string if nothing was stored.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7211 this.className = this.className || value === false ? "" : data_priv.get( this, "__className__" ) || "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7212 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7213 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7214 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7215
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7216 hasClass: function( selector ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7217 var className = " " + selector + " ",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7218 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7219 l = this.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7220 for ( ; i < l; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7221 if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7222 return true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7223 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7224 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7225
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7226 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7227 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7228 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7229
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7230
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7231
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7232
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7233 var rreturn = /\r/g;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7234
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7235 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7236 val: function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7237 var hooks, ret, isFunction,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7238 elem = this[0];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7239
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7240 if ( !arguments.length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7241 if ( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7242 hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7243
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7244 if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7245 return ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7246 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7247
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7248 ret = elem.value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7249
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7250 return typeof ret === "string" ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7251 // handle most common string cases
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7252 ret.replace(rreturn, "") :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7253 // handle cases where value is null/undef or number
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7254 ret == null ? "" : ret;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7255 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7256
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7257 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7258 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7259
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7260 isFunction = jQuery.isFunction( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7261
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7262 return this.each(function( i ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7263 var val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7264
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7265 if ( this.nodeType !== 1 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7266 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7267 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7268
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7269 if ( isFunction ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7270 val = value.call( this, i, jQuery( this ).val() );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7271 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7272 val = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7273 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7274
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7275 // Treat null/undefined as ""; convert numbers to string
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7276 if ( val == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7277 val = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7278
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7279 } else if ( typeof val === "number" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7280 val += "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7281
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7282 } else if ( jQuery.isArray( val ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7283 val = jQuery.map( val, function( value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7284 return value == null ? "" : value + "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7285 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7286 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7287
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7288 hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7289
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7290 // If set returns undefined, fall back to normal setting
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7291 if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7292 this.value = val;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7293 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7294 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7295 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7296 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7297
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7298 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7299 valHooks: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7300 select: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7301 get: function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7302 var value, option,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7303 options = elem.options,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7304 index = elem.selectedIndex,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7305 one = elem.type === "select-one" || index < 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7306 values = one ? null : [],
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7307 max = one ? index + 1 : options.length,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7308 i = index < 0 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7309 max :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7310 one ? index : 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7311
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7312 // Loop through all the selected options
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7313 for ( ; i < max; i++ ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7314 option = options[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7315
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7316 // IE6-9 doesn't update selected after form reset (#2551)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7317 if ( ( option.selected || i === index ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7318 // Don't return options that are disabled or in a disabled optgroup
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7319 ( support.optDisabled ? !option.disabled : option.getAttribute( "disabled" ) === null ) &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7320 ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7321
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7322 // Get the specific value for the option
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7323 value = jQuery( option ).val();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7324
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7325 // We don't need an array for one selects
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7326 if ( one ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7327 return value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7328 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7329
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7330 // Multi-Selects return an array
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7331 values.push( value );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7332 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7333 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7334
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7335 return values;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7336 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7337
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7338 set: function( elem, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7339 var optionSet, option,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7340 options = elem.options,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7341 values = jQuery.makeArray( value ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7342 i = options.length;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7343
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7344 while ( i-- ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7345 option = options[ i ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7346 if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7347 optionSet = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7348 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7349 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7350
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7351 // force browsers to behave consistently when non-matching value is set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7352 if ( !optionSet ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7353 elem.selectedIndex = -1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7354 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7355 return values;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7356 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7357 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7358 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7359 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7360
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7361 // Radios and checkboxes getter/setter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7362 jQuery.each([ "radio", "checkbox" ], function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7363 jQuery.valHooks[ this ] = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7364 set: function( elem, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7365 if ( jQuery.isArray( value ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7366 return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7367 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7368 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7369 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7370 if ( !support.checkOn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7371 jQuery.valHooks[ this ].get = function( elem ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7372 // Support: Webkit
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7373 // "" is returned instead of "on" if a value isn't specified
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7374 return elem.getAttribute("value") === null ? "on" : elem.value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7375 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7376 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7377 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7378
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7379
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7380
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7381
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7382 // Return jQuery for attributes-only inclusion
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7383
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7384
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7385 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7386 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7387 "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7388
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7389 // Handle event binding
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7390 jQuery.fn[ name ] = function( data, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7391 return arguments.length > 0 ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7392 this.on( name, null, data, fn ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7393 this.trigger( name );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7394 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7395 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7396
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7397 jQuery.fn.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7398 hover: function( fnOver, fnOut ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7399 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7400 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7401
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7402 bind: function( types, data, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7403 return this.on( types, null, data, fn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7404 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7405 unbind: function( types, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7406 return this.off( types, null, fn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7407 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7408
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7409 delegate: function( selector, types, data, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7410 return this.on( types, selector, data, fn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7411 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7412 undelegate: function( selector, types, fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7413 // ( namespace ) or ( selector, types [, fn] )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7414 return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7415 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7416 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7417
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7418
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7419 var nonce = jQuery.now();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7420
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7421 var rquery = (/\?/);
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7422
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7423
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7424
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7425 // Support: Android 2.3
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7426 // Workaround failure to string-cast null input
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7427 jQuery.parseJSON = function( data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7428 return JSON.parse( data + "" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7429 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7430
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7431
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7432 // Cross-browser xml parsing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7433 jQuery.parseXML = function( data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7434 var xml, tmp;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7435 if ( !data || typeof data !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7436 return null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7437 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7438
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7439 // Support: IE9
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7440 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7441 tmp = new DOMParser();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7442 xml = tmp.parseFromString( data, "text/xml" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7443 } catch ( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7444 xml = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7445 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7446
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7447 if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7448 jQuery.error( "Invalid XML: " + data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7449 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7450 return xml;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7451 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7452
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7453
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7454 var
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7455 // Document location
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7456 ajaxLocParts,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7457 ajaxLocation,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7458
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7459 rhash = /#.*$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7460 rts = /([?&])_=[^&]*/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7461 rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7462 // #7653, #8125, #8152: local protocol detection
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7463 rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7464 rnoContent = /^(?:GET|HEAD)$/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7465 rprotocol = /^\/\//,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7466 rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7467
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7468 /* Prefilters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7469 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7470 * 2) These are called:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7471 * - BEFORE asking for a transport
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7472 * - AFTER param serialization (s.data is a string if s.processData is true)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7473 * 3) key is the dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7474 * 4) the catchall symbol "*" can be used
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7475 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7476 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7477 prefilters = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7478
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7479 /* Transports bindings
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7480 * 1) key is the dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7481 * 2) the catchall symbol "*" can be used
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7482 * 3) selection will start with transport dataType and THEN go to "*" if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7483 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7484 transports = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7485
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7486 // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7487 allTypes = "*/".concat("*");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7488
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7489 // #8138, IE may throw an exception when accessing
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7490 // a field from window.location if document.domain has been set
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7491 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7492 ajaxLocation = location.href;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7493 } catch( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7494 // Use the href attribute of an A element
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7495 // since IE will modify it given document.location
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7496 ajaxLocation = document.createElement( "a" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7497 ajaxLocation.href = "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7498 ajaxLocation = ajaxLocation.href;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7499 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7500
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7501 // Segment location into parts
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7502 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7503
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7504 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7505 function addToPrefiltersOrTransports( structure ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7506
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7507 // dataTypeExpression is optional and defaults to "*"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7508 return function( dataTypeExpression, func ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7509
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7510 if ( typeof dataTypeExpression !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7511 func = dataTypeExpression;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7512 dataTypeExpression = "*";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7513 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7514
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7515 var dataType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7516 i = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7517 dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7518
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7519 if ( jQuery.isFunction( func ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7520 // For each dataType in the dataTypeExpression
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7521 while ( (dataType = dataTypes[i++]) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7522 // Prepend if requested
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7523 if ( dataType[0] === "+" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7524 dataType = dataType.slice( 1 ) || "*";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7525 (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7526
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7527 // Otherwise append
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7528 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7529 (structure[ dataType ] = structure[ dataType ] || []).push( func );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7530 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7531 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7532 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7533 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7534 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7535
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7536 // Base inspection function for prefilters and transports
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7537 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7538
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7539 var inspected = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7540 seekingTransport = ( structure === transports );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7541
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7542 function inspect( dataType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7543 var selected;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7544 inspected[ dataType ] = true;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7545 jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7546 var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7547 if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7548 options.dataTypes.unshift( dataTypeOrTransport );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7549 inspect( dataTypeOrTransport );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7550 return false;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7551 } else if ( seekingTransport ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7552 return !( selected = dataTypeOrTransport );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7553 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7554 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7555 return selected;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7556 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7557
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7558 return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7559 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7560
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7561 // A special extend for ajax options
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7562 // that takes "flat" options (not to be deep extended)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7563 // Fixes #9887
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7564 function ajaxExtend( target, src ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7565 var key, deep,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7566 flatOptions = jQuery.ajaxSettings.flatOptions || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7567
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7568 for ( key in src ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7569 if ( src[ key ] !== undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7570 ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7571 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7572 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7573 if ( deep ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7574 jQuery.extend( true, target, deep );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7575 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7576
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7577 return target;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7578 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7579
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7580 /* Handles responses to an ajax request:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7581 * - finds the right dataType (mediates between content-type and expected dataType)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7582 * - returns the corresponding response
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7583 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7584 function ajaxHandleResponses( s, jqXHR, responses ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7585
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7586 var ct, type, finalDataType, firstDataType,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7587 contents = s.contents,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7588 dataTypes = s.dataTypes;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7589
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7590 // Remove auto dataType and get content-type in the process
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7591 while ( dataTypes[ 0 ] === "*" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7592 dataTypes.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7593 if ( ct === undefined ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7594 ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7595 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7596 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7597
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7598 // Check if we're dealing with a known content-type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7599 if ( ct ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7600 for ( type in contents ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7601 if ( contents[ type ] && contents[ type ].test( ct ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7602 dataTypes.unshift( type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7603 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7604 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7605 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7606 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7607
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7608 // Check to see if we have a response for the expected dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7609 if ( dataTypes[ 0 ] in responses ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7610 finalDataType = dataTypes[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7611 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7612 // Try convertible dataTypes
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7613 for ( type in responses ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7614 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7615 finalDataType = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7616 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7617 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7618 if ( !firstDataType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7619 firstDataType = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7620 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7621 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7622 // Or just use first one
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7623 finalDataType = finalDataType || firstDataType;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7624 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7625
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7626 // If we found a dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7627 // We add the dataType to the list if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7628 // and return the corresponding response
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7629 if ( finalDataType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7630 if ( finalDataType !== dataTypes[ 0 ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7631 dataTypes.unshift( finalDataType );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7632 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7633 return responses[ finalDataType ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7634 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7635 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7636
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7637 /* Chain conversions given the request and the original response
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7638 * Also sets the responseXXX fields on the jqXHR instance
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7639 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7640 function ajaxConvert( s, response, jqXHR, isSuccess ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7641 var conv2, current, conv, tmp, prev,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7642 converters = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7643 // Work with a copy of dataTypes in case we need to modify it for conversion
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7644 dataTypes = s.dataTypes.slice();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7645
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7646 // Create converters map with lowercased keys
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7647 if ( dataTypes[ 1 ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7648 for ( conv in s.converters ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7649 converters[ conv.toLowerCase() ] = s.converters[ conv ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7650 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7651 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7652
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7653 current = dataTypes.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7654
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7655 // Convert to each sequential dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7656 while ( current ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7657
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7658 if ( s.responseFields[ current ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7659 jqXHR[ s.responseFields[ current ] ] = response;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7660 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7661
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7662 // Apply the dataFilter if provided
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7663 if ( !prev && isSuccess && s.dataFilter ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7664 response = s.dataFilter( response, s.dataType );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7665 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7666
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7667 prev = current;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7668 current = dataTypes.shift();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7669
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7670 if ( current ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7671
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7672 // There's only work to do if current dataType is non-auto
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7673 if ( current === "*" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7674
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7675 current = prev;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7676
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7677 // Convert response if prev dataType is non-auto and differs from current
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7678 } else if ( prev !== "*" && prev !== current ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7679
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7680 // Seek a direct converter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7681 conv = converters[ prev + " " + current ] || converters[ "* " + current ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7682
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7683 // If none found, seek a pair
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7684 if ( !conv ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7685 for ( conv2 in converters ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7686
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7687 // If conv2 outputs current
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7688 tmp = conv2.split( " " );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7689 if ( tmp[ 1 ] === current ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7690
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7691 // If prev can be converted to accepted input
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7692 conv = converters[ prev + " " + tmp[ 0 ] ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7693 converters[ "* " + tmp[ 0 ] ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7694 if ( conv ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7695 // Condense equivalence converters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7696 if ( conv === true ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7697 conv = converters[ conv2 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7698
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7699 // Otherwise, insert the intermediate dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7700 } else if ( converters[ conv2 ] !== true ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7701 current = tmp[ 0 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7702 dataTypes.unshift( tmp[ 1 ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7703 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7704 break;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7705 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7706 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7707 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7708 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7709
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7710 // Apply converter (if not an equivalence)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7711 if ( conv !== true ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7712
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7713 // Unless errors are allowed to bubble, catch and return them
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7714 if ( conv && s[ "throws" ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7715 response = conv( response );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7716 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7717 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7718 response = conv( response );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7719 } catch ( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7720 return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7721 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7722 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7723 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7724 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7725 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7726 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7727
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7728 return { state: "success", data: response };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7729 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7730
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7731 jQuery.extend({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7732
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7733 // Counter for holding the number of active queries
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7734 active: 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7735
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7736 // Last-Modified header cache for next request
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7737 lastModified: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7738 etag: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7739
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7740 ajaxSettings: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7741 url: ajaxLocation,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7742 type: "GET",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7743 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7744 global: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7745 processData: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7746 async: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7747 contentType: "application/x-www-form-urlencoded; charset=UTF-8",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7748 /*
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7749 timeout: 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7750 data: null,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7751 dataType: null,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7752 username: null,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7753 password: null,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7754 cache: null,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7755 throws: false,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7756 traditional: false,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7757 headers: {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7758 */
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7759
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7760 accepts: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7761 "*": allTypes,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7762 text: "text/plain",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7763 html: "text/html",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7764 xml: "application/xml, text/xml",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7765 json: "application/json, text/javascript"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7766 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7767
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7768 contents: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7769 xml: /xml/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7770 html: /html/,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7771 json: /json/
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7772 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7773
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7774 responseFields: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7775 xml: "responseXML",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7776 text: "responseText",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7777 json: "responseJSON"
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7778 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7779
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7780 // Data converters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7781 // Keys separate source (or catchall "*") and destination types with a single space
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7782 converters: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7783
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7784 // Convert anything to text
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7785 "* text": String,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7786
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7787 // Text to html (true = no transformation)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7788 "text html": true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7789
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7790 // Evaluate text as a json expression
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7791 "text json": jQuery.parseJSON,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7792
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7793 // Parse text as xml
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7794 "text xml": jQuery.parseXML
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7795 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7796
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7797 // For options that shouldn't be deep extended:
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7798 // you can add your own custom options here if
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7799 // and when you create one that shouldn't be
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7800 // deep extended (see ajaxExtend)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7801 flatOptions: {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7802 url: true,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7803 context: true
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7804 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7805 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7806
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7807 // Creates a full fledged settings object into target
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7808 // with both ajaxSettings and settings fields.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7809 // If target is omitted, writes into ajaxSettings.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7810 ajaxSetup: function( target, settings ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7811 return settings ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7812
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7813 // Building a settings object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7814 ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7815
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7816 // Extending ajaxSettings
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7817 ajaxExtend( jQuery.ajaxSettings, target );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7818 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7819
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7820 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7821 ajaxTransport: addToPrefiltersOrTransports( transports ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7822
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7823 // Main method
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7824 ajax: function( url, options ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7825
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7826 // If url is an object, simulate pre-1.5 signature
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7827 if ( typeof url === "object" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7828 options = url;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7829 url = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7830 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7831
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7832 // Force options to be an object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7833 options = options || {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7834
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7835 var transport,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7836 // URL without anti-cache param
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7837 cacheURL,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7838 // Response headers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7839 responseHeadersString,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7840 responseHeaders,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7841 // timeout handle
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7842 timeoutTimer,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7843 // Cross-domain detection vars
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7844 parts,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7845 // To know if global events are to be dispatched
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7846 fireGlobals,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7847 // Loop variable
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7848 i,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7849 // Create the final options object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7850 s = jQuery.ajaxSetup( {}, options ),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7851 // Callbacks context
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7852 callbackContext = s.context || s,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7853 // Context for global events is callbackContext if it is a DOM node or jQuery collection
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7854 globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7855 jQuery( callbackContext ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7856 jQuery.event,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7857 // Deferreds
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7858 deferred = jQuery.Deferred(),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7859 completeDeferred = jQuery.Callbacks("once memory"),
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7860 // Status-dependent callbacks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7861 statusCode = s.statusCode || {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7862 // Headers (they are sent all at once)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7863 requestHeaders = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7864 requestHeadersNames = {},
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7865 // The jqXHR state
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7866 state = 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7867 // Default abort message
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7868 strAbort = "canceled",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7869 // Fake xhr
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7870 jqXHR = {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7871 readyState: 0,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7872
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7873 // Builds headers hashtable if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7874 getResponseHeader: function( key ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7875 var match;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7876 if ( state === 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7877 if ( !responseHeaders ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7878 responseHeaders = {};
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7879 while ( (match = rheaders.exec( responseHeadersString )) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7880 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7881 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7882 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7883 match = responseHeaders[ key.toLowerCase() ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7884 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7885 return match == null ? null : match;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7886 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7887
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7888 // Raw string
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7889 getAllResponseHeaders: function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7890 return state === 2 ? responseHeadersString : null;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7891 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7892
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7893 // Caches the header
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7894 setRequestHeader: function( name, value ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7895 var lname = name.toLowerCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7896 if ( !state ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7897 name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7898 requestHeaders[ name ] = value;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7899 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7900 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7901 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7902
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7903 // Overrides response content-type header
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7904 overrideMimeType: function( type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7905 if ( !state ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7906 s.mimeType = type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7907 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7908 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7909 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7910
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7911 // Status-dependent callbacks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7912 statusCode: function( map ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7913 var code;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7914 if ( map ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7915 if ( state < 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7916 for ( code in map ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7917 // Lazy-add the new callback in a way that preserves old ones
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7918 statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7919 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7920 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7921 // Execute the appropriate callbacks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7922 jqXHR.always( map[ jqXHR.status ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7923 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7924 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7925 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7926 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7927
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7928 // Cancel the request
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7929 abort: function( statusText ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7930 var finalText = statusText || strAbort;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7931 if ( transport ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7932 transport.abort( finalText );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7933 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7934 done( 0, finalText );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7935 return this;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7936 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7937 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7938
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7939 // Attach deferreds
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7940 deferred.promise( jqXHR ).complete = completeDeferred.add;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7941 jqXHR.success = jqXHR.done;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7942 jqXHR.error = jqXHR.fail;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7943
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7944 // Remove hash character (#7531: and string promotion)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7945 // Add protocol if not provided (prefilters might expect it)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7946 // Handle falsy url in the settings object (#10093: consistency with old signature)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7947 // We also use the url parameter if available
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7948 s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7949 .replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7950
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7951 // Alias method option to type as per ticket #12004
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7952 s.type = options.method || options.type || s.method || s.type;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7953
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7954 // Extract dataTypes list
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7955 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7956
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7957 // A cross-domain request is in order when we have a protocol:host:port mismatch
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7958 if ( s.crossDomain == null ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7959 parts = rurl.exec( s.url.toLowerCase() );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7960 s.crossDomain = !!( parts &&
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7961 ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7962 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7963 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7964 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7965 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7966
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7967 // Convert data if not already a string
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7968 if ( s.data && s.processData && typeof s.data !== "string" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7969 s.data = jQuery.param( s.data, s.traditional );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7970 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7971
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7972 // Apply prefilters
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7973 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7974
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7975 // If request was aborted inside a prefilter, stop there
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7976 if ( state === 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7977 return jqXHR;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7978 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7979
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7980 // We can fire global events as of now if asked to
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7981 fireGlobals = s.global;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7982
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7983 // Watch for a new set of requests
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7984 if ( fireGlobals && jQuery.active++ === 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7985 jQuery.event.trigger("ajaxStart");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7986 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7987
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7988 // Uppercase the type
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7989 s.type = s.type.toUpperCase();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7990
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7991 // Determine if request has content
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7992 s.hasContent = !rnoContent.test( s.type );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7993
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7994 // Save the URL in case we're toying with the If-Modified-Since
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7995 // and/or If-None-Match header later on
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7996 cacheURL = s.url;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7997
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7998 // More options handling for requests with no content
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7999 if ( !s.hasContent ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8000
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8001 // If data is available, append data to url
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8002 if ( s.data ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8003 cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8004 // #9682: remove data so that it's not used in an eventual retry
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8005 delete s.data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8006 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8007
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8008 // Add anti-cache in url if needed
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8009 if ( s.cache === false ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8010 s.url = rts.test( cacheURL ) ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8011
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8012 // If there is already a '_' parameter, set its value
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8013 cacheURL.replace( rts, "$1_=" + nonce++ ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8014
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8015 // Otherwise add one to the end
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8016 cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8017 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8018 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8019
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8020 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8021 if ( s.ifModified ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8022 if ( jQuery.lastModified[ cacheURL ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8023 jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8024 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8025 if ( jQuery.etag[ cacheURL ] ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8026 jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8027 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8028 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8029
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8030 // Set the correct header, if data is being sent
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8031 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8032 jqXHR.setRequestHeader( "Content-Type", s.contentType );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8033 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8034
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8035 // Set the Accepts header for the server, depending on the dataType
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8036 jqXHR.setRequestHeader(
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8037 "Accept",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8038 s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8039 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8040 s.accepts[ "*" ]
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8041 );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8042
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8043 // Check for headers option
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8044 for ( i in s.headers ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8045 jqXHR.setRequestHeader( i, s.headers[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8046 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8047
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8048 // Allow custom headers/mimetypes and early abort
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8049 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8050 // Abort if not done already and return
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8051 return jqXHR.abort();
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8052 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8053
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8054 // aborting is no longer a cancellation
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8055 strAbort = "abort";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8056
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8057 // Install callbacks on deferreds
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8058 for ( i in { success: 1, error: 1, complete: 1 } ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8059 jqXHR[ i ]( s[ i ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8060 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8061
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8062 // Get transport
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8063 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8064
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8065 // If no transport, we auto-abort
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8066 if ( !transport ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8067 done( -1, "No Transport" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8068 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8069 jqXHR.readyState = 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8070
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8071 // Send global event
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8072 if ( fireGlobals ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8073 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8074 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8075 // Timeout
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8076 if ( s.async && s.timeout > 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8077 timeoutTimer = setTimeout(function() {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8078 jqXHR.abort("timeout");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8079 }, s.timeout );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8080 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8081
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8082 try {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8083 state = 1;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8084 transport.send( requestHeaders, done );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8085 } catch ( e ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8086 // Propagate exception as error if not done
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8087 if ( state < 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8088 done( -1, e );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8089 // Simply rethrow otherwise
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8090 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8091 throw e;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8092 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8093 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8094 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8095
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8096 // Callback for when everything is done
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8097 function done( status, nativeStatusText, responses, headers ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8098 var isSuccess, success, error, response, modified,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8099 statusText = nativeStatusText;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8100
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8101 // Called once
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8102 if ( state === 2 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8103 return;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8104 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8105
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8106 // State is "done" now
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8107 state = 2;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8108
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8109 // Clear timeout if it exists
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8110 if ( timeoutTimer ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8111 clearTimeout( timeoutTimer );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8112 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8113
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8114 // Dereference transport for early garbage collection
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8115 // (no matter how long the jqXHR object will be used)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8116 transport = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8117
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8118 // Cache response headers
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8119 responseHeadersString = headers || "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8120
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8121 // Set readyState
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8122 jqXHR.readyState = status > 0 ? 4 : 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8123
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8124 // Determine if successful
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8125 isSuccess = status >= 200 && status < 300 || status === 304;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8126
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8127 // Get response data
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8128 if ( responses ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8129 response = ajaxHandleResponses( s, jqXHR, responses );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8130 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8131
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8132 // Convert no matter what (that way responseXXX fields are always set)
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8133 response = ajaxConvert( s, response, jqXHR, isSuccess );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8134
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8135 // If successful, handle type chaining
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8136 if ( isSuccess ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8137
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8138 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8139 if ( s.ifModified ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8140 modified = jqXHR.getResponseHeader("Last-Modified");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8141 if ( modified ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8142 jQuery.lastModified[ cacheURL ] = modified;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8143 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8144 modified = jqXHR.getResponseHeader("etag");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8145 if ( modified ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8146 jQuery.etag[ cacheURL ] = modified;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8147 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8148 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8149
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8150 // if no content
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8151 if ( status === 204 || s.type === "HEAD" ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8152 statusText = "nocontent";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8153
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8154 // if not modified
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8155 } else if ( status === 304 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8156 statusText = "notmodified";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8157
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8158 // If we have data, let's convert it
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8159 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8160 statusText = response.state;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8161 success = response.data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8162 error = response.error;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8163 isSuccess = !error;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8164 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8165 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8166 // We extract error from statusText
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8167 // then normalize statusText and status for non-aborts
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8168 error = statusText;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8169 if ( status || !statusText ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8170 statusText = "error";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8171 if ( status < 0 ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8172 status = 0;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8173 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8174 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8175 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8176
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8177 // Set data for the fake xhr object
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8178 jqXHR.status = status;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8179 jqXHR.statusText = ( nativeStatusText || statusText ) + "";
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8180
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8181 // Success/Error
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8182 if ( isSuccess ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8183 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8184 } else {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8185 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8186 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8187
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8188 // Status-dependent callbacks
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8189 jqXHR.statusCode( statusCode );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8190 statusCode = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8191
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8192 if ( fireGlobals ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8193 globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8194 [ jqXHR, s, isSuccess ? success : error ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8195 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8196
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8197 // Complete
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8198 completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8199
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8200 if ( fireGlobals ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8201 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8202 // Handle the global AJAX counter
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8203 if ( !( --jQuery.active ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8204 jQuery.event.trigger("ajaxStop");
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8205 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8206 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8207 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8208
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8209 return jqXHR;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8210 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8211
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8212 getJSON: function( url, data, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8213 return jQuery.get( url, data, callback, "json" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8214 },
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8215
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8216 getScript: function( url, callback ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8217 return jQuery.get( url, undefined, callback, "script" );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8218 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8219 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8220
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8221 jQuery.each( [ "get", "post" ], function( i, method ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8222 jQuery[ method ] = function( url, data, callback, type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8223 // shift arguments if data argument was omitted
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8224 if ( jQuery.isFunction( data ) ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8225 type = type || callback;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8226 callback = data;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8227 data = undefined;
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8228 }
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8229
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8230 return jQuery.ajax({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8231 url: url,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8232 type: method,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8233 dataType: type,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8234 data: data,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8235 success: callback
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8236 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8237 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8238 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8239
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8240 // Attach a bunch of functions for handling common AJAX events
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8241 jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8242 jQuery.fn[ type ] = function( fn ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8243 return this.on( type, fn );
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8244 };
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8245 });
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8246
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8247
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8248 jQuery._evalUrl = function( url ) {
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8249 return jQuery.ajax({
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8250 url: url,
ae5efca89001 working OK
Matt Johnston <matt@ucc.asn.au>