annotate WebContent/jscripts/jquery/jquery.js @ 5:0be9d53a6967

editor for annotations
author dwinter
date Tue, 13 Dec 2011 17:43:46 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 /*!
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2 * jQuery JavaScript Library v1.4.3
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 * http://jquery.com/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 * Copyright 2010, John Resig
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 * Dual licensed under the MIT or GPL Version 2 licenses.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 * http://jquery.org/license
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 * Includes Sizzle.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10 * http://sizzlejs.com/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 * Copyright 2010, The Dojo Foundation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 * Released under the MIT, BSD, and GPL Licenses.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 * Date: Thu Oct 14 23:10:06 2010 -0400
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 (function( window, undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18 // Use the correct document accordingly with window argument (sandbox)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 var document = window.document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20 var jQuery = (function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 // Define a local copy of jQuery
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 var jQuery = function( selector, context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 // The jQuery object is actually just the init constructor 'enhanced'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 return new jQuery.fn.init( selector, context );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 // Map over jQuery in case of overwrite
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 _jQuery = window.jQuery,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 // Map over the $ in case of overwrite
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 _$ = window.$,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 // A central reference to the root jQuery(document)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 rootjQuery,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 // A simple way to check for HTML strings or ID strings
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 // (both of which we optimize for)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41 // Is it a simple selector
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 isSimple = /^.[^:#\[\.,]*$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44 // Check if a string has a non-whitespace character in it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 rnotwhite = /\S/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 rwhite = /\s/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 // Used for trimming whitespace
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 trimLeft = /^\s+/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 trimRight = /\s+$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52 // Check for non-word characters
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 rnonword = /\W/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 // Check for digits
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 rdigit = /\d/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58 // Match a standalone tag
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61 // JSON RegExp
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62 rvalidchars = /^[\],:{}\s]*$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 // Useragent RegExp
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 rwebkit = /(webkit)[ \/]([\w.]+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 rmsie = /(msie) ([\w.]+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 // Keep a UserAgent string for use with jQuery.browser
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74 userAgent = navigator.userAgent,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 // For matching the engine and version of the browser
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 browserMatch,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 // Has the ready events already been bound?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80 readyBound = false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 // The functions to execute on DOM ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83 readyList = [],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85 // The ready event handler
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86 DOMContentLoaded,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 // Save a reference to some core methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 toString = Object.prototype.toString,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90 hasOwn = Object.prototype.hasOwnProperty,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91 push = Array.prototype.push,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92 slice = Array.prototype.slice,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93 trim = String.prototype.trim,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94 indexOf = Array.prototype.indexOf,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96 // [[Class]] -> type pairs
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97 class2type = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99 jQuery.fn = jQuery.prototype = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100 init: function( selector, context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 var match, elem, ret, doc;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
102
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
103 // Handle $(""), $(null), or $(undefined)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
104 if ( !selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
105 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
106 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
107
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
108 // Handle $(DOMElement)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
109 if ( selector.nodeType ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
110 this.context = this[0] = selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
111 this.length = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
112 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
113 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
114
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
115 // The body element only exists once, optimize finding it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
116 if ( selector === "body" && !context && document.body ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
117 this.context = document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
118 this[0] = document.body;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
119 this.selector = "body";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
120 this.length = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
121 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
122 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
123
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
124 // Handle HTML strings
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
125 if ( typeof selector === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
126 // Are we dealing with HTML string or an ID?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
127 match = quickExpr.exec( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
128
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
129 // Verify a match, and that no context was specified for #id
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
130 if ( match && (match[1] || !context) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
131
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
132 // HANDLE: $(html) -> $(array)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
133 if ( match[1] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
134 doc = (context ? context.ownerDocument || context : document);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
135
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
136 // If a single string is passed in and it's a single tag
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
137 // just do a createElement and skip the rest
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
138 ret = rsingleTag.exec( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
139
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
140 if ( ret ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
141 if ( jQuery.isPlainObject( context ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
142 selector = [ document.createElement( ret[1] ) ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
143 jQuery.fn.attr.call( selector, context, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
144
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
145 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
146 selector = [ doc.createElement( ret[1] ) ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
147 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
149 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
150 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
151 selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
152 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
153
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
154 return jQuery.merge( this, selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
155
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
156 // HANDLE: $("#id")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
157 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
158 elem = document.getElementById( match[2] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
159
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
160 // Check parentNode to catch when Blackberry 4.6 returns
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
161 // nodes that are no longer in the document #6963
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
162 if ( elem && elem.parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
163 // Handle the case where IE and Opera return items
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
164 // by name instead of ID
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
165 if ( elem.id !== match[2] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
166 return rootjQuery.find( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
167 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
168
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
169 // Otherwise, we inject the element directly into the jQuery object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
170 this.length = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
171 this[0] = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
172 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
173
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
174 this.context = document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
175 this.selector = selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
176 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
177 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
178
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
179 // HANDLE: $("TAG")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
180 } else if ( !context && !rnonword.test( selector ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
181 this.selector = selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
182 this.context = document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
183 selector = document.getElementsByTagName( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
184 return jQuery.merge( this, selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
185
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
186 // HANDLE: $(expr, $(...))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
187 } else if ( !context || context.jquery ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
188 return (context || rootjQuery).find( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
189
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
190 // HANDLE: $(expr, context)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
191 // (which is just equivalent to: $(context).find(expr)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
192 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
193 return jQuery( context ).find( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
194 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
195
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
196 // HANDLE: $(function)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
197 // Shortcut for document ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
198 } else if ( jQuery.isFunction( selector ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
199 return rootjQuery.ready( selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
200 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
201
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
202 if (selector.selector !== undefined) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
203 this.selector = selector.selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
204 this.context = selector.context;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
205 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
206
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
207 return jQuery.makeArray( selector, this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
208 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
209
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
210 // Start with an empty selector
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
211 selector: "",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
212
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
213 // The current version of jQuery being used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
214 jquery: "1.4.3",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
215
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
216 // The default length of a jQuery object is 0
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
217 length: 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
218
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
219 // The number of elements contained in the matched element set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
220 size: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
221 return this.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
222 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
223
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
224 toArray: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
225 return slice.call( this, 0 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
226 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
227
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
228 // Get the Nth element in the matched element set OR
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
229 // Get the whole matched element set as a clean array
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
230 get: function( num ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
231 return num == null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
232
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
233 // Return a 'clean' array
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
234 this.toArray() :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
235
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
236 // Return just the object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
237 ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
238 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
239
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
240 // Take an array of elements and push it onto the stack
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
241 // (returning the new matched element set)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
242 pushStack: function( elems, name, selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
243 // Build a new jQuery matched element set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
244 var ret = jQuery();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
245
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
246 if ( jQuery.isArray( elems ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
247 push.apply( ret, elems );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
248
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
249 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
250 jQuery.merge( ret, elems );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
251 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
252
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
253 // Add the old object onto the stack (as a reference)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
254 ret.prevObject = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
255
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
256 ret.context = this.context;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
257
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
258 if ( name === "find" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
259 ret.selector = this.selector + (this.selector ? " " : "") + selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
260 } else if ( name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
261 ret.selector = this.selector + "." + name + "(" + selector + ")";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
262 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
263
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
264 // Return the newly-formed element set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
265 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
266 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
267
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
268 // Execute a callback for every element in the matched set.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
269 // (You can seed the arguments with an array of args, but this is
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
270 // only used internally.)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
271 each: function( callback, args ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
272 return jQuery.each( this, callback, args );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
273 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
274
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
275 ready: function( fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
276 // Attach the listeners
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
277 jQuery.bindReady();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
278
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
279 // If the DOM is already ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
280 if ( jQuery.isReady ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
281 // Execute the function immediately
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
282 fn.call( document, jQuery );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
283
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
284 // Otherwise, remember the function for later
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
285 } else if ( readyList ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
286 // Add the function to the wait list
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
287 readyList.push( fn );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
288 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
289
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
290 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
291 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
292
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
293 eq: function( i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
294 return i === -1 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
295 this.slice( i ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
296 this.slice( i, +i + 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
297 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
298
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
299 first: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
300 return this.eq( 0 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
301 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
302
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
303 last: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
304 return this.eq( -1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
305 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
306
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
307 slice: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
308 return this.pushStack( slice.apply( this, arguments ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
309 "slice", slice.call(arguments).join(",") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
310 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
311
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
312 map: function( callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
313 return this.pushStack( jQuery.map(this, function( elem, i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
314 return callback.call( elem, i, elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
315 }));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
316 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
317
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
318 end: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
319 return this.prevObject || jQuery(null);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
320 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
321
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
322 // For internal use only.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
323 // Behaves like an Array's method, not like a jQuery method.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
324 push: push,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
325 sort: [].sort,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
326 splice: [].splice
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
327 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
328
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
329 // Give the init function the jQuery prototype for later instantiation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
330 jQuery.fn.init.prototype = jQuery.fn;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
331
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
332 jQuery.extend = jQuery.fn.extend = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
333 // copy reference to target object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
334 var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
335
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
336 // Handle a deep copy situation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
337 if ( typeof target === "boolean" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
338 deep = target;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
339 target = arguments[1] || {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
340 // skip the boolean and the target
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
341 i = 2;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
342 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
343
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
344 // Handle case when target is a string or something (possible in deep copy)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
345 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
346 target = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
347 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
348
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
349 // extend jQuery itself if only one argument is passed
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
350 if ( length === i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
351 target = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
352 --i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
353 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
354
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
355 for ( ; i < length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
356 // Only deal with non-null/undefined values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
357 if ( (options = arguments[ i ]) != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
358 // Extend the base object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
359 for ( name in options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
360 src = target[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
361 copy = options[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
362
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
363 // Prevent never-ending loop
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
364 if ( target === copy ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
365 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
366 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
367
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
368 // Recurse if we're merging plain objects or arrays
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
369 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
370 if ( copyIsArray ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
371 copyIsArray = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
372 clone = src && jQuery.isArray(src) ? src : [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
373
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
374 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
375 clone = src && jQuery.isPlainObject(src) ? src : {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
376 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
377
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
378 // Never move original objects, clone them
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
379 target[ name ] = jQuery.extend( deep, clone, copy );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
380
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
381 // Don't bring in undefined values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
382 } else if ( copy !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
383 target[ name ] = copy;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
384 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
385 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
386 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
387 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
388
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
389 // Return the modified object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
390 return target;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
391 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
392
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
393 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
394 noConflict: function( deep ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
395 window.$ = _$;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
396
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
397 if ( deep ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
398 window.jQuery = _jQuery;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
399 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
400
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
401 return jQuery;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
402 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
403
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
404 // Is the DOM ready to be used? Set to true once it occurs.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
405 isReady: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
406
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
407 // A counter to track how many items to wait for before
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
408 // the ready event fires. See #6781
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
409 readyWait: 1,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
410
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
411 // Handle when the DOM is ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
412 ready: function( wait ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
413 // A third-party is pushing the ready event forwards
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
414 if ( wait === true ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
415 jQuery.readyWait--;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
416 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
417
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
418 // Make sure that the DOM is not already loaded
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
419 if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
420 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
421 if ( !document.body ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
422 return setTimeout( jQuery.ready, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
423 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
424
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
425 // Remember that the DOM is ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
426 jQuery.isReady = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
427
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
428 // If a normal DOM Ready event fired, decrement, and wait if need be
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
429 if ( wait !== true && --jQuery.readyWait > 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
430 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
431 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
432
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
433 // If there are functions bound, to execute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
434 if ( readyList ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
435 // Execute all of them
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
436 var fn, i = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
437 while ( (fn = readyList[ i++ ]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
438 fn.call( document, jQuery );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
439 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
440
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
441 // Reset the list of functions
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
442 readyList = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
443 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
444
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
445 // Trigger any bound ready events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
446 if ( jQuery.fn.triggerHandler ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
447 jQuery( document ).triggerHandler( "ready" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
448 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
449 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
450 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
451
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
452 bindReady: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
453 if ( readyBound ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
454 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
455 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
456
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
457 readyBound = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
458
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
459 // Catch cases where $(document).ready() is called after the
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
460 // browser event has already occurred.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
461 if ( document.readyState === "complete" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
462 // Handle it asynchronously to allow scripts the opportunity to delay ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
463 return setTimeout( jQuery.ready, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
464 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
465
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
466 // Mozilla, Opera and webkit nightlies currently support this event
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
467 if ( document.addEventListener ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
468 // Use the handy event callback
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
469 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
470
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
471 // A fallback to window.onload, that will always work
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
472 window.addEventListener( "load", jQuery.ready, false );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
473
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
474 // If IE event model is used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
475 } else if ( document.attachEvent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
476 // ensure firing before onload,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
477 // maybe late but safe also for iframes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
478 document.attachEvent("onreadystatechange", DOMContentLoaded);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
479
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
480 // A fallback to window.onload, that will always work
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
481 window.attachEvent( "onload", jQuery.ready );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
482
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
483 // If IE and not a frame
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
484 // continually check to see if the document is ready
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
485 var toplevel = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
486
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
487 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
488 toplevel = window.frameElement == null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
489 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
490
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
491 if ( document.documentElement.doScroll && toplevel ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
492 doScrollCheck();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
493 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
494 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
495 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
496
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
497 // See test/unit/core.js for details concerning isFunction.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
498 // Since version 1.3, DOM methods and functions like alert
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
499 // aren't supported. They return false on IE (#2968).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
500 isFunction: function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
501 return jQuery.type(obj) === "function";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
502 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
503
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
504 isArray: Array.isArray || function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
505 return jQuery.type(obj) === "array";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
506 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
507
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
508 // A crude way of determining if an object is a window
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
509 isWindow: function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
510 return obj && typeof obj === "object" && "setInterval" in obj;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
511 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
512
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
513 isNaN: function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
514 return obj == null || !rdigit.test( obj ) || isNaN( obj );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
515 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
516
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
517 type: function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
518 return obj == null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
519 String( obj ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
520 class2type[ toString.call(obj) ] || "object";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
521 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
522
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
523 isPlainObject: function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
524 // Must be an Object.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
525 // Because of IE, we also have to check the presence of the constructor property.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
526 // Make sure that DOM nodes and window objects don't pass through, as well
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
527 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
528 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
529 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
530
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
531 // Not own constructor property must be Object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
532 if ( obj.constructor &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
533 !hasOwn.call(obj, "constructor") &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
534 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
535 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
536 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
537
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
538 // Own properties are enumerated firstly, so to speed up,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
539 // if last one is own, then all properties are own.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
540
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
541 var key;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
542 for ( key in obj ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
543
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
544 return key === undefined || hasOwn.call( obj, key );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
545 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
546
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
547 isEmptyObject: function( obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
548 for ( var name in obj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
549 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
550 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
551 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
552 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
553
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
554 error: function( msg ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
555 throw msg;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
556 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
557
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
558 parseJSON: function( data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
559 if ( typeof data !== "string" || !data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
560 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
561 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
562
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
563 // Make sure leading/trailing whitespace is removed (IE can't handle it)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
564 data = jQuery.trim( data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
565
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
566 // Make sure the incoming data is actual JSON
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
567 // Logic borrowed from http://json.org/json2.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
568 if ( rvalidchars.test(data.replace(rvalidescape, "@")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
569 .replace(rvalidtokens, "]")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
570 .replace(rvalidbraces, "")) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
571
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
572 // Try to use the native JSON parser first
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
573 return window.JSON && window.JSON.parse ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
574 window.JSON.parse( data ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
575 (new Function("return " + data))();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
576
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
577 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
578 jQuery.error( "Invalid JSON: " + data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
579 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
580 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
581
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
582 noop: function() {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
583
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
584 // Evalulates a script in a global context
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
585 globalEval: function( data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
586 if ( data && rnotwhite.test(data) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
587 // Inspired by code by Andrea Giammarchi
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
588 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
589 var head = document.getElementsByTagName("head")[0] || document.documentElement,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
590 script = document.createElement("script");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
591
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
592 script.type = "text/javascript";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
593
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
594 if ( jQuery.support.scriptEval ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
595 script.appendChild( document.createTextNode( data ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
596 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
597 script.text = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
598 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
599
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
600 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
601 // This arises when a base node is used (#2709).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
602 head.insertBefore( script, head.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
603 head.removeChild( script );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
604 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
605 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
606
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
607 nodeName: function( elem, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
608 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
609 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
610
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
611 // args is for internal usage only
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
612 each: function( object, callback, args ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
613 var name, i = 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
614 length = object.length,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
615 isObj = length === undefined || jQuery.isFunction(object);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
616
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
617 if ( args ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
618 if ( isObj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
619 for ( name in object ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
620 if ( callback.apply( object[ name ], args ) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
621 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
622 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
623 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
624 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
625 for ( ; i < length; ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
626 if ( callback.apply( object[ i++ ], args ) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
627 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
628 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
629 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
630 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
631
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
632 // A special, fast, case for the most common use of each
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
633 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
634 if ( isObj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
635 for ( name in object ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
636 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
637 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
638 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
639 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
640 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
641 for ( var value = object[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
642 i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
643 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
644 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
645
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
646 return object;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
647 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
648
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
649 // Use native String.trim function wherever possible
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
650 trim: trim ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
651 function( text ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
652 return text == null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
653 "" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
654 trim.call( text );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
655 } :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
656
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
657 // Otherwise use our own trimming functionality
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
658 function( text ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
659 return text == null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
660 "" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
661 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
662 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
663
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
664 // results is for internal usage only
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
665 makeArray: function( array, results ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
666 var ret = results || [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
667
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
668 if ( array != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
669 // The window, strings (and functions) also have 'length'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
670 // The extra typeof function check is to prevent crashes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
671 // in Safari 2 (See: #3039)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
672 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
673 var type = jQuery.type(array);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
674
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
675 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
676 push.call( ret, array );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
677 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
678 jQuery.merge( ret, array );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
679 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
680 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
681
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
682 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
683 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
684
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
685 inArray: function( elem, array ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
686 if ( array.indexOf ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
687 return array.indexOf( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
688 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
689
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
690 for ( var i = 0, length = array.length; i < length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
691 if ( array[ i ] === elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
692 return i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
693 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
694 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
695
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
696 return -1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
697 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
698
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
699 merge: function( first, second ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
700 var i = first.length, j = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
701
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
702 if ( typeof second.length === "number" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
703 for ( var l = second.length; j < l; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
704 first[ i++ ] = second[ j ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
705 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
706
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
707 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
708 while ( second[j] !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
709 first[ i++ ] = second[ j++ ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
710 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
711 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
712
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
713 first.length = i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
714
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
715 return first;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
716 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
717
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
718 grep: function( elems, callback, inv ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
719 var ret = [], retVal;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
720 inv = !!inv;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
721
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
722 // Go through the array, only saving the items
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
723 // that pass the validator function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
724 for ( var i = 0, length = elems.length; i < length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
725 retVal = !!callback( elems[ i ], i );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
726 if ( inv !== retVal ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
727 ret.push( elems[ i ] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
728 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
729 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
730
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
731 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
732 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
733
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
734 // arg is for internal usage only
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
735 map: function( elems, callback, arg ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
736 var ret = [], value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
737
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
738 // Go through the array, translating each of the items to their
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
739 // new value (or values).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
740 for ( var i = 0, length = elems.length; i < length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
741 value = callback( elems[ i ], i, arg );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
742
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
743 if ( value != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
744 ret[ ret.length ] = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
745 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
746 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
747
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
748 return ret.concat.apply( [], ret );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
749 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
750
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
751 // A global GUID counter for objects
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
752 guid: 1,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
753
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
754 proxy: function( fn, proxy, thisObject ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
755 if ( arguments.length === 2 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
756 if ( typeof proxy === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
757 thisObject = fn;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
758 fn = thisObject[ proxy ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
759 proxy = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
760
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
761 } else if ( proxy && !jQuery.isFunction( proxy ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
762 thisObject = proxy;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
763 proxy = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
764 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
765 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
766
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
767 if ( !proxy && fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
768 proxy = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
769 return fn.apply( thisObject || this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
770 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
771 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
772
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
773 // Set the guid of unique handler to the same of original handler, so it can be removed
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
774 if ( fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
775 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
776 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
777
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
778 // So proxy can be declared as an argument
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
779 return proxy;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
780 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
781
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
782 // Mutifunctional method to get and set values to a collection
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
783 // The value/s can be optionally by executed if its a function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
784 access: function( elems, key, value, exec, fn, pass ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
785 var length = elems.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
786
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
787 // Setting many attributes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
788 if ( typeof key === "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
789 for ( var k in key ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
790 jQuery.access( elems, k, key[k], exec, fn, value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
791 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
792 return elems;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
793 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
794
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
795 // Setting one attribute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
796 if ( value !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
797 // Optionally, function values get executed if exec is true
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
798 exec = !pass && exec && jQuery.isFunction(value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
799
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
800 for ( var i = 0; i < length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
801 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
802 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
803
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
804 return elems;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
805 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
806
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
807 // Getting an attribute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
808 return length ? fn( elems[0], key ) : undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
809 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
810
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
811 now: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
812 return (new Date()).getTime();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
813 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
814
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
815 // Use of jQuery.browser is frowned upon.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
816 // More details: http://docs.jquery.com/Utilities/jQuery.browser
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
817 uaMatch: function( ua ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
818 ua = ua.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
819
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
820 var match = rwebkit.exec( ua ) ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
821 ropera.exec( ua ) ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
822 rmsie.exec( ua ) ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
823 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
824 [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
825
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
826 return { browser: match[1] || "", version: match[2] || "0" };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
827 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
828
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
829 browser: {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
830 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
831
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
832 // Populate the class2type map
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
833 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
834 class2type[ "[object " + name + "]" ] = name.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
835 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
836
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
837 browserMatch = jQuery.uaMatch( userAgent );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
838 if ( browserMatch.browser ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
839 jQuery.browser[ browserMatch.browser ] = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
840 jQuery.browser.version = browserMatch.version;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
841 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
842
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
843 // Deprecated, use jQuery.browser.webkit instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
844 if ( jQuery.browser.webkit ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
845 jQuery.browser.safari = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
846 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
847
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
848 if ( indexOf ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
849 jQuery.inArray = function( elem, array ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
850 return indexOf.call( array, elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
851 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
852 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
853
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
854 // Verify that \s matches non-breaking spaces
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
855 // (IE fails on this test)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
856 if ( !rwhite.test( "\xA0" ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
857 trimLeft = /^[\s\xA0]+/;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
858 trimRight = /[\s\xA0]+$/;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
859 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
860
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
861 // All jQuery objects should point back to these
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
862 rootjQuery = jQuery(document);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
863
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
864 // Cleanup functions for the document ready method
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
865 if ( document.addEventListener ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
866 DOMContentLoaded = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
867 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
868 jQuery.ready();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
869 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
870
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
871 } else if ( document.attachEvent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
872 DOMContentLoaded = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
873 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
874 if ( document.readyState === "complete" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
875 document.detachEvent( "onreadystatechange", DOMContentLoaded );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
876 jQuery.ready();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
877 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
878 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
879 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
880
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
881 // The DOM ready check for Internet Explorer
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
882 function doScrollCheck() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
883 if ( jQuery.isReady ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
884 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
885 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
886
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
887 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
888 // If IE is used, use the trick by Diego Perini
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
889 // http://javascript.nwbox.com/IEContentLoaded/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
890 document.documentElement.doScroll("left");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
891 } catch(e) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
892 setTimeout( doScrollCheck, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
893 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
894 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
895
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
896 // and execute any waiting functions
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
897 jQuery.ready();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
898 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
899
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
900 // Expose jQuery to the global object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
901 return (window.jQuery = window.$ = jQuery);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
902
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
903 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
904
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
905
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
906 (function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
907
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
908 jQuery.support = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
909
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
910 var root = document.documentElement,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
911 script = document.createElement("script"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
912 div = document.createElement("div"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
913 id = "script" + jQuery.now();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
914
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
915 div.style.display = "none";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
916 div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
917
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
918 var all = div.getElementsByTagName("*"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
919 a = div.getElementsByTagName("a")[0],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
920 select = document.createElement("select"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
921 opt = select.appendChild( document.createElement("option") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
922
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
923 // Can't get basic test support
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
924 if ( !all || !all.length || !a ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
925 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
926 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
927
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
928 jQuery.support = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
929 // IE strips leading whitespace when .innerHTML is used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
930 leadingWhitespace: div.firstChild.nodeType === 3,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
931
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
932 // Make sure that tbody elements aren't automatically inserted
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
933 // IE will insert them into empty tables
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
934 tbody: !div.getElementsByTagName("tbody").length,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
935
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
936 // Make sure that link elements get serialized correctly by innerHTML
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
937 // This requires a wrapper element in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
938 htmlSerialize: !!div.getElementsByTagName("link").length,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
939
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
940 // Get the style information from getAttribute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
941 // (IE uses .cssText insted)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
942 style: /red/.test( a.getAttribute("style") ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
943
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
944 // Make sure that URLs aren't manipulated
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
945 // (IE normalizes it by default)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
946 hrefNormalized: a.getAttribute("href") === "/a",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
947
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
948 // Make sure that element opacity exists
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
949 // (IE uses filter instead)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
950 // Use a regex to work around a WebKit issue. See #5145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
951 opacity: /^0.55$/.test( a.style.opacity ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
952
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
953 // Verify style float existence
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
954 // (IE uses styleFloat instead of cssFloat)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
955 cssFloat: !!a.style.cssFloat,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
956
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
957 // Make sure that if no value is specified for a checkbox
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
958 // that it defaults to "on".
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
959 // (WebKit defaults to "" instead)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
960 checkOn: div.getElementsByTagName("input")[0].value === "on",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
961
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
962 // Make sure that a selected-by-default option has a working selected property.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
963 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
964 optSelected: opt.selected,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
965
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
966 // Will be defined later
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
967 optDisabled: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
968 checkClone: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
969 scriptEval: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
970 noCloneEvent: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
971 boxModel: null,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
972 inlineBlockNeedsLayout: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
973 shrinkWrapBlocks: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
974 reliableHiddenOffsets: true
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
975 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
976
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
977 // Make sure that the options inside disabled selects aren't marked as disabled
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
978 // (WebKit marks them as diabled)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
979 select.disabled = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
980 jQuery.support.optDisabled = !opt.disabled;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
981
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
982 script.type = "text/javascript";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
983 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
984 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
985 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
986
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
987 root.insertBefore( script, root.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
988
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
989 // Make sure that the execution of code works by injecting a script
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
990 // tag with appendChild/createTextNode
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
991 // (IE doesn't support this, fails, and uses .text instead)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
992 if ( window[ id ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
993 jQuery.support.scriptEval = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
994 delete window[ id ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
995 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
996
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
997 root.removeChild( script );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
998
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
999 if ( div.attachEvent && div.fireEvent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1000 div.attachEvent("onclick", function click() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1001 // Cloning a node shouldn't copy over any
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1002 // bound event handlers (IE does this)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1003 jQuery.support.noCloneEvent = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1004 div.detachEvent("onclick", click);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1005 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1006 div.cloneNode(true).fireEvent("onclick");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1007 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1008
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1009 div = document.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1010 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1011
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1012 var fragment = document.createDocumentFragment();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1013 fragment.appendChild( div.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1014
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1015 // WebKit doesn't clone checked state correctly in fragments
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1016 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1017
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1018 // Figure out if the W3C box model works as expected
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1019 // document.body must exist before we can do this
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1020 jQuery(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1021 var div = document.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1022 div.style.width = div.style.paddingLeft = "1px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1023
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1024 document.body.appendChild( div );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1025 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1026
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1027 if ( "zoom" in div.style ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1028 // Check if natively block-level elements act like inline-block
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1029 // elements when setting their display to 'inline' and giving
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1030 // them layout
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1031 // (IE < 8 does this)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1032 div.style.display = "inline";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1033 div.style.zoom = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1034 jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1035
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1036 // Check if elements with layout shrink-wrap their children
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1037 // (IE 6 does this)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1038 div.style.display = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1039 div.innerHTML = "<div style='width:4px;'></div>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1040 jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1041 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1042
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1043 div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1044 var tds = div.getElementsByTagName("td");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1045
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1046 // Check if table cells still have offsetWidth/Height when they are set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1047 // to display:none and there are still other visible table cells in a
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1048 // table row; if so, offsetWidth/Height are not reliable for use when
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1049 // determining if an element has been hidden directly using
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1050 // display:none (it is still safe to use offsets if a parent element is
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1051 // hidden; don safety goggles and see bug #4512 for more information).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1052 // (only IE 8 fails this test)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1053 jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1054
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1055 tds[0].style.display = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1056 tds[1].style.display = "none";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1057
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1058 // Check if empty table cells still have offsetWidth/Height
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1059 // (IE < 8 fail this test)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1060 jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1061 div.innerHTML = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1062
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1063 document.body.removeChild( div ).style.display = "none";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1064 div = tds = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1065 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1066
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1067 // Technique from Juriy Zaytsev
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1068 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1069 var eventSupported = function( eventName ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1070 var el = document.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1071 eventName = "on" + eventName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1072
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1073 var isSupported = (eventName in el);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1074 if ( !isSupported ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1075 el.setAttribute(eventName, "return;");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1076 isSupported = typeof el[eventName] === "function";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1077 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1078 el = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1079
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1080 return isSupported;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1081 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1082
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1083 jQuery.support.submitBubbles = eventSupported("submit");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1084 jQuery.support.changeBubbles = eventSupported("change");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1085
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1086 // release memory in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1087 root = script = div = all = a = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1088 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1089
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1090 jQuery.props = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1091 "for": "htmlFor",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1092 "class": "className",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1093 readonly: "readOnly",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1094 maxlength: "maxLength",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1095 cellspacing: "cellSpacing",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1096 rowspan: "rowSpan",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1097 colspan: "colSpan",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1098 tabindex: "tabIndex",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1099 usemap: "useMap",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1100 frameborder: "frameBorder"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1101 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1102
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1103
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1104
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1105
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1106 var windowData = {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1107 rbrace = /^(?:\{.*\}|\[.*\])$/;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1108
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1109 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1110 cache: {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1111
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1112 // Please use with caution
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1113 uuid: 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1114
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1115 // Unique for each copy of jQuery on the page
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1116 expando: "jQuery" + jQuery.now(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1117
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1118 // The following elements throw uncatchable exceptions if you
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1119 // attempt to add expando properties to them.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1120 noData: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1121 "embed": true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1122 // Ban all objects except for Flash (which handle expandos)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1123 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1124 "applet": true
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1125 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1126
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1127 data: function( elem, name, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1128 if ( !jQuery.acceptData( elem ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1129 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1130 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1131
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1132 elem = elem == window ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1133 windowData :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1134 elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1135
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1136 var isNode = elem.nodeType,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1137 id = isNode ? elem[ jQuery.expando ] : null,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1138 cache = jQuery.cache, thisCache;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1139
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1140 if ( isNode && !id && typeof name === "string" && data === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1141 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1142 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1143
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1144 // Get the data from the object directly
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1145 if ( !isNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1146 cache = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1147
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1148 // Compute a unique ID for the element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1149 } else if ( !id ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1150 elem[ jQuery.expando ] = id = ++jQuery.uuid;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1151 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1152
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1153 // Avoid generating a new cache unless none exists and we
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1154 // want to manipulate it.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1155 if ( typeof name === "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1156 if ( isNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1157 cache[ id ] = jQuery.extend(cache[ id ], name);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1158
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1159 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1160 jQuery.extend( cache, name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1161 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1162
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1163 } else if ( isNode && !cache[ id ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1164 cache[ id ] = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1165 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1166
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1167 thisCache = isNode ? cache[ id ] : cache;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1168
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1169 // Prevent overriding the named cache with undefined values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1170 if ( data !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1171 thisCache[ name ] = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1172 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1173
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1174 return typeof name === "string" ? thisCache[ name ] : thisCache;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1175 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1176
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1177 removeData: function( elem, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1178 if ( !jQuery.acceptData( elem ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1179 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1180 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1181
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1182 elem = elem == window ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1183 windowData :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1184 elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1185
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1186 var isNode = elem.nodeType,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1187 id = isNode ? elem[ jQuery.expando ] : elem,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1188 cache = jQuery.cache,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1189 thisCache = isNode ? cache[ id ] : id;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1190
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1191 // If we want to remove a specific section of the element's data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1192 if ( name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1193 if ( thisCache ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1194 // Remove the section of cache data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1195 delete thisCache[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1196
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1197 // If we've removed all the data, remove the element's cache
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1198 if ( isNode && jQuery.isEmptyObject(thisCache) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1199 jQuery.removeData( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1200 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1201 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1202
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1203 // Otherwise, we want to remove all of the element's data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1204 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1205 if ( isNode && jQuery.support.deleteExpando ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1206 delete elem[ jQuery.expando ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1207
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1208 } else if ( elem.removeAttribute ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1209 elem.removeAttribute( jQuery.expando );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1210
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1211 // Completely remove the data cache
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1212 } else if ( isNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1213 delete cache[ id ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1214
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1215 // Remove all fields from the object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1216 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1217 for ( var n in elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1218 delete elem[ n ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1219 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1220 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1221 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1222 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1223
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1224 // A method for determining if a DOM node can handle the data expando
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1225 acceptData: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1226 if ( elem.nodeName ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1227 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1228
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1229 if ( match ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1230 return !(match === true || elem.getAttribute("classid") !== match);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1231 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1232 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1233
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1234 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1235 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1236 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1237
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1238 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1239 data: function( key, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1240 if ( typeof key === "undefined" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1241 return this.length ? jQuery.data( this[0] ) : null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1242
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1243 } else if ( typeof key === "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1244 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1245 jQuery.data( this, key );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1246 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1247 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1248
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1249 var parts = key.split(".");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1250 parts[1] = parts[1] ? "." + parts[1] : "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1251
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1252 if ( value === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1253 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1254
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1255 // Try to fetch any internally stored data first
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1256 if ( data === undefined && this.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1257 data = jQuery.data( this[0], key );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1258
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1259 // If nothing was found internally, try to fetch any
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1260 // data from the HTML5 data-* attribute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1261 if ( data === undefined && this[0].nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1262 data = this[0].getAttribute( "data-" + key );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1263
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1264 if ( typeof data === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1265 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1266 data = data === "true" ? true :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1267 data === "false" ? false :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1268 data === "null" ? null :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1269 !jQuery.isNaN( data ) ? parseFloat( data ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1270 rbrace.test( data ) ? jQuery.parseJSON( data ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1271 data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1272 } catch( e ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1273
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1274 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1275 data = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1276 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1277 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1278 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1279
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1280 return data === undefined && parts[1] ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1281 this.data( parts[0] ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1282 data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1283
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1284 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1285 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1286 var $this = jQuery( this ), args = [ parts[0], value ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1287
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1288 $this.triggerHandler( "setData" + parts[1] + "!", args );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1289 jQuery.data( this, key, value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1290 $this.triggerHandler( "changeData" + parts[1] + "!", args );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1291 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1292 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1293 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1294
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1295 removeData: function( key ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1296 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1297 jQuery.removeData( this, key );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1298 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1299 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1300 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1301
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1302
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1303
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1304
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1305 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1306 queue: function( elem, type, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1307 if ( !elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1308 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1309 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1310
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1311 type = (type || "fx") + "queue";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1312 var q = jQuery.data( elem, type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1313
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1314 // Speed up dequeue by getting out quickly if this is just a lookup
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1315 if ( !data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1316 return q || [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1317 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1318
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1319 if ( !q || jQuery.isArray(data) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1320 q = jQuery.data( elem, type, jQuery.makeArray(data) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1321
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1322 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1323 q.push( data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1324 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1325
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1326 return q;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1327 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1328
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1329 dequeue: function( elem, type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1330 type = type || "fx";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1331
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1332 var queue = jQuery.queue( elem, type ), fn = queue.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1333
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1334 // If the fx queue is dequeued, always remove the progress sentinel
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1335 if ( fn === "inprogress" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1336 fn = queue.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1337 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1338
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1339 if ( fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1340 // Add a progress sentinel to prevent the fx queue from being
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1341 // automatically dequeued
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1342 if ( type === "fx" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1343 queue.unshift("inprogress");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1344 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1345
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1346 fn.call(elem, function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1347 jQuery.dequeue(elem, type);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1348 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1349 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1350 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1351 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1352
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1353 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1354 queue: function( type, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1355 if ( typeof type !== "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1356 data = type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1357 type = "fx";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1358 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1359
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1360 if ( data === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1361 return jQuery.queue( this[0], type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1362 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1363 return this.each(function( i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1364 var queue = jQuery.queue( this, type, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1365
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1366 if ( type === "fx" && queue[0] !== "inprogress" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1367 jQuery.dequeue( this, type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1368 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1369 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1370 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1371 dequeue: function( type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1372 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1373 jQuery.dequeue( this, type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1374 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1375 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1376
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1377 // Based off of the plugin by Clint Helfers, with permission.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1378 // http://blindsignals.com/index.php/2009/07/jquery-delay/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1379 delay: function( time, type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1380 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1381 type = type || "fx";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1382
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1383 return this.queue( type, function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1384 var elem = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1385 setTimeout(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1386 jQuery.dequeue( elem, type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1387 }, time );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1388 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1389 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1390
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1391 clearQueue: function( type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1392 return this.queue( type || "fx", [] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1393 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1394 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1395
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1396
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1397
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1398
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1399 var rclass = /[\n\t]/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1400 rspaces = /\s+/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1401 rreturn = /\r/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1402 rspecialurl = /^(?:href|src|style)$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1403 rtype = /^(?:button|input)$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1404 rfocusable = /^(?:button|input|object|select|textarea)$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1405 rclickable = /^a(?:rea)?$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1406 rradiocheck = /^(?:radio|checkbox)$/i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1407
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1408 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1409 attr: function( name, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1410 return jQuery.access( this, name, value, true, jQuery.attr );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1411 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1412
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1413 removeAttr: function( name, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1414 return this.each(function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1415 jQuery.attr( this, name, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1416 if ( this.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1417 this.removeAttribute( name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1418 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1419 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1420 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1421
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1422 addClass: function( value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1423 if ( jQuery.isFunction(value) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1424 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1425 var self = jQuery(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1426 self.addClass( value.call(this, i, self.attr("class")) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1427 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1428 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1429
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1430 if ( value && typeof value === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1431 var classNames = (value || "").split( rspaces );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1432
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1433 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1434 var elem = this[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1435
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1436 if ( elem.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1437 if ( !elem.className ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1438 elem.className = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1439
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1440 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1441 var className = " " + elem.className + " ", setClass = elem.className;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1442 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1443 if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1444 setClass += " " + classNames[c];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1445 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1446 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1447 elem.className = jQuery.trim( setClass );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1448 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1449 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1450 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1451 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1452
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1453 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1454 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1455
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1456 removeClass: function( value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1457 if ( jQuery.isFunction(value) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1458 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1459 var self = jQuery(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1460 self.removeClass( value.call(this, i, self.attr("class")) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1461 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1462 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1463
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1464 if ( (value && typeof value === "string") || value === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1465 var classNames = (value || "").split( rspaces );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1466
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1467 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1468 var elem = this[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1469
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1470 if ( elem.nodeType === 1 && elem.className ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1471 if ( value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1472 var className = (" " + elem.className + " ").replace(rclass, " ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1473 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1474 className = className.replace(" " + classNames[c] + " ", " ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1475 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1476 elem.className = jQuery.trim( className );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1477
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1478 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1479 elem.className = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1480 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1481 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1482 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1483 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1484
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1485 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1486 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1487
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1488 toggleClass: function( value, stateVal ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1489 var type = typeof value, isBool = typeof stateVal === "boolean";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1490
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1491 if ( jQuery.isFunction( value ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1492 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1493 var self = jQuery(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1494 self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1495 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1496 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1497
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1498 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1499 if ( type === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1500 // toggle individual class names
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1501 var className, i = 0, self = jQuery(this),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1502 state = stateVal,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1503 classNames = value.split( rspaces );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1504
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1505 while ( (className = classNames[ i++ ]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1506 // check each className given, space seperated list
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1507 state = isBool ? state : !self.hasClass( className );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1508 self[ state ? "addClass" : "removeClass" ]( className );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1509 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1510
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1511 } else if ( type === "undefined" || type === "boolean" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1512 if ( this.className ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1513 // store className if set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1514 jQuery.data( this, "__className__", this.className );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1515 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1516
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1517 // toggle whole className
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1518 this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1519 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1520 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1521 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1522
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1523 hasClass: function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1524 var className = " " + selector + " ";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1525 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1526 if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1527 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1528 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1529 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1530
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1531 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1532 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1533
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1534 val: function( value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1535 if ( !arguments.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1536 var elem = this[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1537
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1538 if ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1539 if ( jQuery.nodeName( elem, "option" ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1540 // attributes.value is undefined in Blackberry 4.7 but
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1541 // uses .value. See #6932
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1542 var val = elem.attributes.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1543 return !val || val.specified ? elem.value : elem.text;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1544 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1545
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1546 // We need to handle select boxes special
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1547 if ( jQuery.nodeName( elem, "select" ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1548 var index = elem.selectedIndex,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1549 values = [],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1550 options = elem.options,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1551 one = elem.type === "select-one";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1552
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1553 // Nothing was selected
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1554 if ( index < 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1555 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1556 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1557
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1558 // Loop through all the selected options
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1559 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1560 var option = options[ i ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1561
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1562 // Don't return options that are disabled or in a disabled optgroup
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1563 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1564 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1565
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1566 // Get the specific value for the option
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1567 value = jQuery(option).val();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1568
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1569 // We don't need an array for one selects
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1570 if ( one ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1571 return value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1572 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1573
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1574 // Multi-Selects return an array
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1575 values.push( value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1576 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1577 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1578
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1579 return values;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1580 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1581
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1582 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1583 if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1584 return elem.getAttribute("value") === null ? "on" : elem.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1585 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1586
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1587
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1588 // Everything else, we just grab the value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1589 return (elem.value || "").replace(rreturn, "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1590
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1591 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1592
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1593 return undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1594 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1595
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1596 var isFunction = jQuery.isFunction(value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1597
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1598 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1599 var self = jQuery(this), val = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1600
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1601 if ( this.nodeType !== 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1602 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1603 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1604
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1605 if ( isFunction ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1606 val = value.call(this, i, self.val());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1607 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1608
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1609 // Treat null/undefined as ""; convert numbers to string
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1610 if ( val == null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1611 val = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1612 } else if ( typeof val === "number" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1613 val += "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1614 } else if ( jQuery.isArray(val) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1615 val = jQuery.map(val, function (value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1616 return value == null ? "" : value + "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1617 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1618 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1619
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1620 if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1621 this.checked = jQuery.inArray( self.val(), val ) >= 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1622
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1623 } else if ( jQuery.nodeName( this, "select" ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1624 var values = jQuery.makeArray(val);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1625
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1626 jQuery( "option", this ).each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1627 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1628 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1629
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1630 if ( !values.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1631 this.selectedIndex = -1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1632 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1633
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1634 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1635 this.value = val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1636 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1637 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1638 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1639 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1640
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1641 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1642 attrFn: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1643 val: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1644 css: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1645 html: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1646 text: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1647 data: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1648 width: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1649 height: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1650 offset: true
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1651 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1652
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1653 attr: function( elem, name, value, pass ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1654 // don't set attributes on text and comment nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1655 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1656 return undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1657 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1658
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1659 if ( pass && name in jQuery.attrFn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1660 return jQuery(elem)[name](value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1661 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1662
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1663 var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1664 // Whether we are setting (or getting)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1665 set = value !== undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1666
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1667 // Try to normalize/fix the name
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1668 name = notxml && jQuery.props[ name ] || name;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1669
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1670 // Only do all the following if this is a node (faster for style)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1671 if ( elem.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1672 // These attributes require special treatment
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1673 var special = rspecialurl.test( name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1674
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1675 // Safari mis-reports the default selected property of an option
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1676 // Accessing the parent's selectedIndex property fixes it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1677 if ( name === "selected" && !jQuery.support.optSelected ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1678 var parent = elem.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1679 if ( parent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1680 parent.selectedIndex;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1681
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1682 // Make sure that it also works with optgroups, see #5701
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1683 if ( parent.parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1684 parent.parentNode.selectedIndex;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1685 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1686 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1687 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1688
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1689 // If applicable, access the attribute via the DOM 0 way
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1690 // 'in' checks fail in Blackberry 4.7 #6931
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1691 if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1692 if ( set ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1693 // We can't allow the type property to be changed (since it causes problems in IE)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1694 if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1695 jQuery.error( "type property can't be changed" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1696 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1697
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1698 if ( value === null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1699 if ( elem.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1700 elem.removeAttribute( name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1701 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1702
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1703 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1704 elem[ name ] = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1705 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1706 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1707
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1708 // browsers index elements by id/name on forms, give priority to attributes.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1709 if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1710 return elem.getAttributeNode( name ).nodeValue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1711 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1712
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1713 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1714 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1715 if ( name === "tabIndex" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1716 var attributeNode = elem.getAttributeNode( "tabIndex" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1717
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1718 return attributeNode && attributeNode.specified ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1719 attributeNode.value :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1720 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1721 0 :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1722 undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1723 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1724
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1725 return elem[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1726 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1727
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1728 if ( !jQuery.support.style && notxml && name === "style" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1729 if ( set ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1730 elem.style.cssText = "" + value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1731 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1732
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1733 return elem.style.cssText;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1734 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1735
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1736 if ( set ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1737 // convert the value to a string (all browsers do this but IE) see #1070
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1738 elem.setAttribute( name, "" + value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1739 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1740
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1741 // Ensure that missing attributes return undefined
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1742 // Blackberry 4.7 returns "" from getAttribute #6938
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1743 if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1744 return undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1745 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1746
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1747 var attr = !jQuery.support.hrefNormalized && notxml && special ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1748 // Some attributes require a special call on IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1749 elem.getAttribute( name, 2 ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1750 elem.getAttribute( name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1751
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1752 // Non-existent attributes return null, we normalize to undefined
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1753 return attr === null ? undefined : attr;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1754 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1755 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1756 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1757
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1758
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1759
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1760
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1761 var rnamespaces = /\.(.*)$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1762 rformElems = /^(?:textarea|input|select)$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1763 rperiod = /\./g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1764 rspace = / /g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1765 rescape = /[^\w\s.|`]/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1766 fcleanup = function( nm ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1767 return nm.replace(rescape, "\\$&");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1768 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1769 focusCounts = { focusin: 0, focusout: 0 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1770
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1771 /*
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1772 * A number of helper functions used for managing events.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1773 * Many of the ideas behind this code originated from
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1774 * Dean Edwards' addEvent library.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1775 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1776 jQuery.event = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1777
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1778 // Bind an event to an element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1779 // Original by Dean Edwards
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1780 add: function( elem, types, handler, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1781 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1782 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1783 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1784
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1785 // For whatever reason, IE has trouble passing the window object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1786 // around, causing it to be cloned in the process
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1787 if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1788 elem = window;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1789 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1790
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1791 if ( handler === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1792 handler = returnFalse;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1793 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1794
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1795 var handleObjIn, handleObj;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1796
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1797 if ( handler.handler ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1798 handleObjIn = handler;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1799 handler = handleObjIn.handler;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1800 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1801
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1802 // Make sure that the function being executed has a unique ID
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1803 if ( !handler.guid ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1804 handler.guid = jQuery.guid++;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1805 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1806
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1807 // Init the element's event structure
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1808 var elemData = jQuery.data( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1809
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1810 // If no elemData is found then we must be trying to bind to one of the
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1811 // banned noData elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1812 if ( !elemData ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1813 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1814 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1815
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1816 // Use a key less likely to result in collisions for plain JS objects.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1817 // Fixes bug #7150.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1818 var eventKey = elem.nodeType ? "events" : "__events__",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1819 events = elemData[ eventKey ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1820 eventHandle = elemData.handle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1821
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1822 if ( typeof events === "function" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1823 // On plain objects events is a fn that holds the the data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1824 // which prevents this data from being JSON serialized
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1825 // the function does not need to be called, it just contains the data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1826 eventHandle = events.handle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1827 events = events.events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1828
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1829 } else if ( !events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1830 if ( !elem.nodeType ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1831 // On plain objects, create a fn that acts as the holder
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1832 // of the values to avoid JSON serialization of event data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1833 elemData[ eventKey ] = elemData = function(){};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1834 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1835
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1836 elemData.events = events = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1837 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1838
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1839 if ( !eventHandle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1840 elemData.handle = eventHandle = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1841 // Handle the second event of a trigger and when
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1842 // an event is called after a page has unloaded
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1843 return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1844 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1845 undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1846 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1847 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1848
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1849 // Add elem as a property of the handle function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1850 // This is to prevent a memory leak with non-native events in IE.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1851 eventHandle.elem = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1852
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1853 // Handle multiple events separated by a space
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1854 // jQuery(...).bind("mouseover mouseout", fn);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1855 types = types.split(" ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1856
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1857 var type, i = 0, namespaces;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1858
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1859 while ( (type = types[ i++ ]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1860 handleObj = handleObjIn ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1861 jQuery.extend({}, handleObjIn) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1862 { handler: handler, data: data };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1863
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1864 // Namespaced event handlers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1865 if ( type.indexOf(".") > -1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1866 namespaces = type.split(".");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1867 type = namespaces.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1868 handleObj.namespace = namespaces.slice(0).sort().join(".");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1869
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1870 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1871 namespaces = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1872 handleObj.namespace = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1873 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1874
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1875 handleObj.type = type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1876 if ( !handleObj.guid ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1877 handleObj.guid = handler.guid;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1878 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1879
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1880 // Get the current list of functions bound to this event
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1881 var handlers = events[ type ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1882 special = jQuery.event.special[ type ] || {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1883
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1884 // Init the event handler queue
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1885 if ( !handlers ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1886 handlers = events[ type ] = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1887
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1888 // Check for a special event handler
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1889 // Only use addEventListener/attachEvent if the special
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1890 // events handler returns false
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1891 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1892 // Bind the global event handler to the element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1893 if ( elem.addEventListener ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1894 elem.addEventListener( type, eventHandle, false );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1895
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1896 } else if ( elem.attachEvent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1897 elem.attachEvent( "on" + type, eventHandle );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1898 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1899 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1900 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1901
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1902 if ( special.add ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1903 special.add.call( elem, handleObj );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1904
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1905 if ( !handleObj.handler.guid ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1906 handleObj.handler.guid = handler.guid;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1907 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1908 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1909
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1910 // Add the function to the element's handler list
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1911 handlers.push( handleObj );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1912
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1913 // Keep track of which events have been used, for global triggering
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1914 jQuery.event.global[ type ] = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1915 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1916
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1917 // Nullify elem to prevent memory leaks in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1918 elem = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1919 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1920
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1921 global: {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1922
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1923 // Detach an event or set of events from an element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1924 remove: function( elem, types, handler, pos ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1925 // don't do events on text and comment nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1926 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1927 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1928 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1929
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1930 if ( handler === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1931 handler = returnFalse;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1932 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1933
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1934 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1935 eventKey = elem.nodeType ? "events" : "__events__",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1936 elemData = jQuery.data( elem ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1937 events = elemData && elemData[ eventKey ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1938
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1939 if ( !elemData || !events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1940 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1941 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1942
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1943 if ( typeof events === "function" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1944 elemData = events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1945 events = events.events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1946 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1947
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1948 // types is actually an event object here
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1949 if ( types && types.type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1950 handler = types.handler;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1951 types = types.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1952 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1953
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1954 // Unbind all events for the element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1955 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1956 types = types || "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1957
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1958 for ( type in events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1959 jQuery.event.remove( elem, type + types );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1960 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1961
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1962 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1963 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1964
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1965 // Handle multiple events separated by a space
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1966 // jQuery(...).unbind("mouseover mouseout", fn);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1967 types = types.split(" ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1968
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1969 while ( (type = types[ i++ ]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1970 origType = type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1971 handleObj = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1972 all = type.indexOf(".") < 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1973 namespaces = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1974
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1975 if ( !all ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1976 // Namespaced event handlers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1977 namespaces = type.split(".");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1978 type = namespaces.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1979
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1980 namespace = new RegExp("(^|\\.)" +
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1981 jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1982 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1983
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1984 eventType = events[ type ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1985
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1986 if ( !eventType ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1987 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1988 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1989
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1990 if ( !handler ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1991 for ( j = 0; j < eventType.length; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1992 handleObj = eventType[ j ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1993
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1994 if ( all || namespace.test( handleObj.namespace ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1995 jQuery.event.remove( elem, origType, handleObj.handler, j );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1996 eventType.splice( j--, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1997 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1998 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1999
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2000 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2001 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2002
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2003 special = jQuery.event.special[ type ] || {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2004
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2005 for ( j = pos || 0; j < eventType.length; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2006 handleObj = eventType[ j ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2007
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2008 if ( handler.guid === handleObj.guid ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2009 // remove the given handler for the given type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2010 if ( all || namespace.test( handleObj.namespace ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2011 if ( pos == null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2012 eventType.splice( j--, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2013 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2014
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2015 if ( special.remove ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2016 special.remove.call( elem, handleObj );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2017 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2018 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2019
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2020 if ( pos != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2021 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2022 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2023 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2024 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2025
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2026 // remove generic event handler if no more handlers exist
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2027 if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2028 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2029 jQuery.removeEvent( elem, type, elemData.handle );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2030 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2031
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2032 ret = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2033 delete events[ type ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2034 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2035 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2036
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2037 // Remove the expando if it's no longer used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2038 if ( jQuery.isEmptyObject( events ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2039 var handle = elemData.handle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2040 if ( handle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2041 handle.elem = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2042 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2043
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2044 delete elemData.events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2045 delete elemData.handle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2046
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2047 if ( typeof elemData === "function" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2048 jQuery.removeData( elem, eventKey );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2049
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2050 } else if ( jQuery.isEmptyObject( elemData ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2051 jQuery.removeData( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2052 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2053 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2054 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2055
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2056 // bubbling is internal
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2057 trigger: function( event, data, elem /*, bubbling */ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2058 // Event object or event type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2059 var type = event.type || event,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2060 bubbling = arguments[3];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2061
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2062 if ( !bubbling ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2063 event = typeof event === "object" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2064 // jQuery.Event object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2065 event[ jQuery.expando ] ? event :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2066 // Object literal
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2067 jQuery.extend( jQuery.Event(type), event ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2068 // Just the event type (string)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2069 jQuery.Event(type);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2070
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2071 if ( type.indexOf("!") >= 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2072 event.type = type = type.slice(0, -1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2073 event.exclusive = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2074 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2075
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2076 // Handle a global trigger
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2077 if ( !elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2078 // Don't bubble custom events when global (to avoid too much overhead)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2079 event.stopPropagation();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2080
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2081 // Only trigger if we've ever bound an event for it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2082 if ( jQuery.event.global[ type ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2083 jQuery.each( jQuery.cache, function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2084 if ( this.events && this.events[type] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2085 jQuery.event.trigger( event, data, this.handle.elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2086 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2087 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2088 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2089 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2090
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2091 // Handle triggering a single element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2092
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2093 // don't do events on text and comment nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2094 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2095 return undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2096 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2097
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2098 // Clean up in case it is reused
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2099 event.result = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2100 event.target = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2101
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2102 // Clone the incoming data, if any
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2103 data = jQuery.makeArray( data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2104 data.unshift( event );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2105 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2106
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2107 event.currentTarget = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2108
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2109 // Trigger the event, it is assumed that "handle" is a function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2110 var handle = elem.nodeType ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2111 jQuery.data( elem, "handle" ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2112 (jQuery.data( elem, "__events__" ) || {}).handle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2113
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2114 if ( handle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2115 handle.apply( elem, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2116 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2117
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2118 var parent = elem.parentNode || elem.ownerDocument;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2119
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2120 // Trigger an inline bound script
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2121 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2122 if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2123 if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2124 event.result = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2125 event.preventDefault();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2126 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2127 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2128
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2129 // prevent IE from throwing an error for some elements with some event types, see #3533
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2130 } catch (inlineError) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2131
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2132 if ( !event.isPropagationStopped() && parent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2133 jQuery.event.trigger( event, data, parent, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2134
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2135 } else if ( !event.isDefaultPrevented() ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2136 var target = event.target, old, targetType = type.replace(rnamespaces, ""),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2137 isClick = jQuery.nodeName(target, "a") && targetType === "click",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2138 special = jQuery.event.special[ targetType ] || {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2139
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2140 if ( (!special._default || special._default.call( elem, event ) === false) &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2141 !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2142
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2143 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2144 if ( target[ targetType ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2145 // Make sure that we don't accidentally re-trigger the onFOO events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2146 old = target[ "on" + targetType ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2147
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2148 if ( old ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2149 target[ "on" + targetType ] = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2150 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2151
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2152 jQuery.event.triggered = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2153 target[ targetType ]();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2154 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2155
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2156 // prevent IE from throwing an error for some elements with some event types, see #3533
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2157 } catch (triggerError) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2158
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2159 if ( old ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2160 target[ "on" + targetType ] = old;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2161 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2162
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2163 jQuery.event.triggered = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2164 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2165 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2166 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2167
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2168 handle: function( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2169 var all, handlers, namespaces, namespace_sort = [], namespace_re, events, args = jQuery.makeArray( arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2170
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2171 event = args[0] = jQuery.event.fix( event || window.event );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2172 event.currentTarget = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2173
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2174 // Namespaced event handlers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2175 all = event.type.indexOf(".") < 0 && !event.exclusive;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2176
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2177 if ( !all ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2178 namespaces = event.type.split(".");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2179 event.type = namespaces.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2180 namespace_sort = namespaces.slice(0).sort();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2181 namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2182 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2183
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2184 event.namespace = event.namespace || namespace_sort.join(".");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2185
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2186 events = jQuery.data(this, this.nodeType ? "events" : "__events__");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2187
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2188 if ( typeof events === "function" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2189 events = events.events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2190 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2191
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2192 handlers = (events || {})[ event.type ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2193
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2194 if ( events && handlers ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2195 // Clone the handlers to prevent manipulation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2196 handlers = handlers.slice(0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2197
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2198 for ( var j = 0, l = handlers.length; j < l; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2199 var handleObj = handlers[ j ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2200
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2201 // Filter the functions by class
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2202 if ( all || namespace_re.test( handleObj.namespace ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2203 // Pass in a reference to the handler function itself
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2204 // So that we can later remove it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2205 event.handler = handleObj.handler;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2206 event.data = handleObj.data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2207 event.handleObj = handleObj;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2208
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2209 var ret = handleObj.handler.apply( this, args );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2210
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2211 if ( ret !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2212 event.result = ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2213 if ( ret === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2214 event.preventDefault();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2215 event.stopPropagation();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2216 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2217 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2218
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2219 if ( event.isImmediatePropagationStopped() ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2220 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2221 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2222 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2223 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2224 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2225
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2226 return event.result;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2227 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2228
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2229 props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2230
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2231 fix: function( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2232 if ( event[ jQuery.expando ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2233 return event;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2234 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2235
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2236 // store a copy of the original event object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2237 // and "clone" to set read-only properties
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2238 var originalEvent = event;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2239 event = jQuery.Event( originalEvent );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2240
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2241 for ( var i = this.props.length, prop; i; ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2242 prop = this.props[ --i ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2243 event[ prop ] = originalEvent[ prop ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2244 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2245
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2246 // Fix target property, if necessary
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2247 if ( !event.target ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2248 event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2249 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2250
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2251 // check if target is a textnode (safari)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2252 if ( event.target.nodeType === 3 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2253 event.target = event.target.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2254 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2255
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2256 // Add relatedTarget, if necessary
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2257 if ( !event.relatedTarget && event.fromElement ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2258 event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2259 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2260
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2261 // Calculate pageX/Y if missing and clientX/Y available
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2262 if ( event.pageX == null && event.clientX != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2263 var doc = document.documentElement, body = document.body;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2264 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2265 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2266 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2267
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2268 // Add which for key events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2269 if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2270 event.which = event.charCode != null ? event.charCode : event.keyCode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2271 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2272
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2273 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2274 if ( !event.metaKey && event.ctrlKey ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2275 event.metaKey = event.ctrlKey;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2276 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2277
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2278 // Add which for click: 1 === left; 2 === middle; 3 === right
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2279 // Note: button is not normalized, so don't use it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2280 if ( !event.which && event.button !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2281 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2282 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2283
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2284 return event;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2285 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2286
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2287 // Deprecated, use jQuery.guid instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2288 guid: 1E8,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2289
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2290 // Deprecated, use jQuery.proxy instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2291 proxy: jQuery.proxy,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2292
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2293 special: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2294 ready: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2295 // Make sure the ready event is setup
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2296 setup: jQuery.bindReady,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2297 teardown: jQuery.noop
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2298 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2299
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2300 live: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2301 add: function( handleObj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2302 jQuery.event.add( this,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2303 liveConvert( handleObj.origType, handleObj.selector ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2304 jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2305 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2306
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2307 remove: function( handleObj ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2308 jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2309 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2310 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2311
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2312 beforeunload: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2313 setup: function( data, namespaces, eventHandle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2314 // We only want to do this special case on windows
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2315 if ( jQuery.isWindow( this ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2316 this.onbeforeunload = eventHandle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2317 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2318 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2319
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2320 teardown: function( namespaces, eventHandle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2321 if ( this.onbeforeunload === eventHandle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2322 this.onbeforeunload = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2323 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2324 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2325 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2326 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2327 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2328
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2329 jQuery.removeEvent = document.removeEventListener ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2330 function( elem, type, handle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2331 if ( elem.removeEventListener ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2332 elem.removeEventListener( type, handle, false );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2333 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2334 } :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2335 function( elem, type, handle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2336 if ( elem.detachEvent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2337 elem.detachEvent( "on" + type, handle );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2338 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2339 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2340
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2341 jQuery.Event = function( src ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2342 // Allow instantiation without the 'new' keyword
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2343 if ( !this.preventDefault ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2344 return new jQuery.Event( src );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2345 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2346
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2347 // Event object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2348 if ( src && src.type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2349 this.originalEvent = src;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2350 this.type = src.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2351 // Event type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2352 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2353 this.type = src;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2354 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2355
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2356 // timeStamp is buggy for some events on Firefox(#3843)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2357 // So we won't rely on the native value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2358 this.timeStamp = jQuery.now();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2359
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2360 // Mark it as fixed
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2361 this[ jQuery.expando ] = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2362 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2363
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2364 function returnFalse() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2365 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2366 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2367 function returnTrue() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2368 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2369 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2370
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2371 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2372 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2373 jQuery.Event.prototype = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2374 preventDefault: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2375 this.isDefaultPrevented = returnTrue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2376
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2377 var e = this.originalEvent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2378 if ( !e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2379 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2380 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2381
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2382 // if preventDefault exists run it on the original event
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2383 if ( e.preventDefault ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2384 e.preventDefault();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2385
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2386 // otherwise set the returnValue property of the original event to false (IE)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2387 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2388 e.returnValue = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2389 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2390 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2391 stopPropagation: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2392 this.isPropagationStopped = returnTrue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2393
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2394 var e = this.originalEvent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2395 if ( !e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2396 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2397 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2398 // if stopPropagation exists run it on the original event
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2399 if ( e.stopPropagation ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2400 e.stopPropagation();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2401 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2402 // otherwise set the cancelBubble property of the original event to true (IE)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2403 e.cancelBubble = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2404 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2405 stopImmediatePropagation: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2406 this.isImmediatePropagationStopped = returnTrue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2407 this.stopPropagation();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2408 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2409 isDefaultPrevented: returnFalse,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2410 isPropagationStopped: returnFalse,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2411 isImmediatePropagationStopped: returnFalse
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2412 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2413
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2414 // Checks if an event happened on an element within another element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2415 // Used in jQuery.event.special.mouseenter and mouseleave handlers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2416 var withinElement = function( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2417 // Check if mouse(over|out) are still within the same parent element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2418 var parent = event.relatedTarget;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2419
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2420 // Firefox sometimes assigns relatedTarget a XUL element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2421 // which we cannot access the parentNode property of
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2422 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2423 // Traverse up the tree
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2424 while ( parent && parent !== this ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2425 parent = parent.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2426 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2427
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2428 if ( parent !== this ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2429 // set the correct event type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2430 event.type = event.data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2431
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2432 // handle event if we actually just moused on to a non sub-element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2433 jQuery.event.handle.apply( this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2434 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2435
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2436 // assuming we've left the element since we most likely mousedover a xul element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2437 } catch(e) { }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2438 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2439
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2440 // In case of event delegation, we only need to rename the event.type,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2441 // liveHandler will take care of the rest.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2442 delegate = function( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2443 event.type = event.data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2444 jQuery.event.handle.apply( this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2445 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2446
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2447 // Create mouseenter and mouseleave events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2448 jQuery.each({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2449 mouseenter: "mouseover",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2450 mouseleave: "mouseout"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2451 }, function( orig, fix ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2452 jQuery.event.special[ orig ] = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2453 setup: function( data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2454 jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2455 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2456 teardown: function( data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2457 jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2458 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2459 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2460 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2461
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2462 // submit delegation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2463 if ( !jQuery.support.submitBubbles ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2464
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2465 jQuery.event.special.submit = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2466 setup: function( data, namespaces ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2467 if ( this.nodeName.toLowerCase() !== "form" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2468 jQuery.event.add(this, "click.specialSubmit", function( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2469 var elem = e.target, type = elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2470
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2471 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2472 e.liveFired = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2473 return trigger( "submit", this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2474 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2475 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2476
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2477 jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2478 var elem = e.target, type = elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2479
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2480 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2481 e.liveFired = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2482 return trigger( "submit", this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2483 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2484 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2485
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2486 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2487 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2488 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2489 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2490
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2491 teardown: function( namespaces ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2492 jQuery.event.remove( this, ".specialSubmit" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2493 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2494 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2495
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2496 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2497
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2498 // change delegation, happens here so we have bind.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2499 if ( !jQuery.support.changeBubbles ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2500
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2501 var changeFilters,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2502
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2503 getVal = function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2504 var type = elem.type, val = elem.value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2505
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2506 if ( type === "radio" || type === "checkbox" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2507 val = elem.checked;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2508
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2509 } else if ( type === "select-multiple" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2510 val = elem.selectedIndex > -1 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2511 jQuery.map( elem.options, function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2512 return elem.selected;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2513 }).join("-") :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2514 "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2515
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2516 } else if ( elem.nodeName.toLowerCase() === "select" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2517 val = elem.selectedIndex;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2518 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2519
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2520 return val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2521 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2522
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2523 testChange = function testChange( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2524 var elem = e.target, data, val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2525
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2526 if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2527 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2528 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2529
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2530 data = jQuery.data( elem, "_change_data" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2531 val = getVal(elem);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2532
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2533 // the current data will be also retrieved by beforeactivate
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2534 if ( e.type !== "focusout" || elem.type !== "radio" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2535 jQuery.data( elem, "_change_data", val );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2536 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2537
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2538 if ( data === undefined || val === data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2539 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2540 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2541
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2542 if ( data != null || val ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2543 e.type = "change";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2544 e.liveFired = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2545 return jQuery.event.trigger( e, arguments[1], elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2546 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2547 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2548
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2549 jQuery.event.special.change = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2550 filters: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2551 focusout: testChange,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2552
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2553 beforedeactivate: testChange,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2554
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2555 click: function( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2556 var elem = e.target, type = elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2557
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2558 if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2559 return testChange.call( this, e );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2560 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2561 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2562
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2563 // Change has to be called before submit
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2564 // Keydown will be called before keypress, which is used in submit-event delegation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2565 keydown: function( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2566 var elem = e.target, type = elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2567
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2568 if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2569 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2570 type === "select-multiple" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2571 return testChange.call( this, e );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2572 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2573 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2574
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2575 // Beforeactivate happens also before the previous element is blurred
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2576 // with this event you can't trigger a change event, but you can store
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2577 // information
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2578 beforeactivate: function( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2579 var elem = e.target;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2580 jQuery.data( elem, "_change_data", getVal(elem) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2581 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2582 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2583
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2584 setup: function( data, namespaces ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2585 if ( this.type === "file" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2586 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2587 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2588
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2589 for ( var type in changeFilters ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2590 jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2591 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2592
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2593 return rformElems.test( this.nodeName );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2594 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2595
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2596 teardown: function( namespaces ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2597 jQuery.event.remove( this, ".specialChange" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2598
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2599 return rformElems.test( this.nodeName );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2600 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2601 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2602
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2603 changeFilters = jQuery.event.special.change.filters;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2604
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2605 // Handle when the input is .focus()'d
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2606 changeFilters.focus = changeFilters.beforeactivate;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2607 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2608
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2609 function trigger( type, elem, args ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2610 args[0].type = type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2611 return jQuery.event.handle.apply( elem, args );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2612 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2613
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2614 // Create "bubbling" focus and blur events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2615 if ( document.addEventListener ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2616 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2617 jQuery.event.special[ fix ] = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2618 setup: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2619 if ( focusCounts[fix]++ === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2620 document.addEventListener( orig, handler, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2621 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2622 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2623 teardown: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2624 if ( --focusCounts[fix] === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2625 document.removeEventListener( orig, handler, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2626 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2627 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2628 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2629
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2630 function handler( e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2631 e = jQuery.event.fix( e );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2632 e.type = fix;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2633 return jQuery.event.trigger( e, null, e.target );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2634 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2635 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2636 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2637
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2638 jQuery.each(["bind", "one"], function( i, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2639 jQuery.fn[ name ] = function( type, data, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2640 // Handle object literals
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2641 if ( typeof type === "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2642 for ( var key in type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2643 this[ name ](key, data, type[key], fn);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2644 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2645 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2646 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2647
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2648 if ( jQuery.isFunction( data ) || data === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2649 fn = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2650 data = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2651 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2652
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2653 var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2654 jQuery( this ).unbind( event, handler );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2655 return fn.apply( this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2656 }) : fn;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2657
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2658 if ( type === "unload" && name !== "one" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2659 this.one( type, data, fn );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2660
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2661 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2662 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2663 jQuery.event.add( this[i], type, handler, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2664 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2665 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2666
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2667 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2668 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2669 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2670
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2671 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2672 unbind: function( type, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2673 // Handle object literals
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2674 if ( typeof type === "object" && !type.preventDefault ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2675 for ( var key in type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2676 this.unbind(key, type[key]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2677 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2678
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2679 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2680 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2681 jQuery.event.remove( this[i], type, fn );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2682 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2683 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2684
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2685 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2686 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2687
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2688 delegate: function( selector, types, data, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2689 return this.live( types, data, fn, selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2690 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2691
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2692 undelegate: function( selector, types, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2693 if ( arguments.length === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2694 return this.unbind( "live" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2695
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2696 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2697 return this.die( types, null, fn, selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2698 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2699 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2700
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2701 trigger: function( type, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2702 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2703 jQuery.event.trigger( type, data, this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2704 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2705 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2706
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2707 triggerHandler: function( type, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2708 if ( this[0] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2709 var event = jQuery.Event( type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2710 event.preventDefault();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2711 event.stopPropagation();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2712 jQuery.event.trigger( event, data, this[0] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2713 return event.result;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2714 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2715 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2716
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2717 toggle: function( fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2718 // Save reference to arguments for access in closure
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2719 var args = arguments, i = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2720
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2721 // link all the functions, so any of them can unbind this click handler
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2722 while ( i < args.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2723 jQuery.proxy( fn, args[ i++ ] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2724 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2725
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2726 return this.click( jQuery.proxy( fn, function( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2727 // Figure out which function to execute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2728 var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2729 jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2730
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2731 // Make sure that clicks stop
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2732 event.preventDefault();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2733
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2734 // and execute the function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2735 return args[ lastToggle ].apply( this, arguments ) || false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2736 }));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2737 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2738
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2739 hover: function( fnOver, fnOut ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2740 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2741 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2742 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2743
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2744 var liveMap = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2745 focus: "focusin",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2746 blur: "focusout",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2747 mouseenter: "mouseover",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2748 mouseleave: "mouseout"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2749 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2750
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2751 jQuery.each(["live", "die"], function( i, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2752 jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2753 var type, i = 0, match, namespaces, preType,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2754 selector = origSelector || this.selector,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2755 context = origSelector ? this : jQuery( this.context );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2756
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2757 if ( typeof types === "object" && !types.preventDefault ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2758 for ( var key in types ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2759 context[ name ]( key, data, types[key], selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2760 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2761
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2762 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2763 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2764
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2765 if ( jQuery.isFunction( data ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2766 fn = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2767 data = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2768 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2769
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2770 types = (types || "").split(" ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2771
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2772 while ( (type = types[ i++ ]) != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2773 match = rnamespaces.exec( type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2774 namespaces = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2775
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2776 if ( match ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2777 namespaces = match[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2778 type = type.replace( rnamespaces, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2779 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2780
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2781 if ( type === "hover" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2782 types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2783 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2784 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2785
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2786 preType = type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2787
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2788 if ( type === "focus" || type === "blur" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2789 types.push( liveMap[ type ] + namespaces );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2790 type = type + namespaces;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2791
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2792 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2793 type = (liveMap[ type ] || type) + namespaces;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2794 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2795
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2796 if ( name === "live" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2797 // bind live handler
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2798 for ( var j = 0, l = context.length; j < l; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2799 jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2800 { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2801 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2802
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2803 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2804 // unbind live handler
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2805 context.unbind( "live." + liveConvert( type, selector ), fn );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2806 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2807 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2808
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2809 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2810 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2811 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2812
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2813 function liveHandler( event ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2814 var stop, maxLevel, elems = [], selectors = [],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2815 related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2816 events = jQuery.data( this, this.nodeType ? "events" : "__events__" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2817
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2818 if ( typeof events === "function" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2819 events = events.events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2820 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2821
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2822 // Make sure we avoid non-left-click bubbling in Firefox (#3861)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2823 if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2824 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2825 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2826
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2827 if ( event.namespace ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2828 namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2829 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2830
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2831 event.liveFired = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2832
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2833 var live = events.live.slice(0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2834
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2835 for ( j = 0; j < live.length; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2836 handleObj = live[j];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2837
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2838 if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2839 selectors.push( handleObj.selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2840
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2841 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2842 live.splice( j--, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2843 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2844 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2845
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2846 match = jQuery( event.target ).closest( selectors, event.currentTarget );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2847
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2848 for ( i = 0, l = match.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2849 close = match[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2850
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2851 for ( j = 0; j < live.length; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2852 handleObj = live[j];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2853
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2854 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2855 elem = close.elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2856 related = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2857
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2858 // Those two events require additional checking
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2859 if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2860 event.type = handleObj.preType;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2861 related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2862 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2863
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2864 if ( !related || related !== elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2865 elems.push({ elem: elem, handleObj: handleObj, level: close.level });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2866 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2867 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2868 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2869 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2870
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2871 for ( i = 0, l = elems.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2872 match = elems[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2873
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2874 if ( maxLevel && match.level > maxLevel ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2875 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2876 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2877
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2878 event.currentTarget = match.elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2879 event.data = match.handleObj.data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2880 event.handleObj = match.handleObj;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2881
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2882 ret = match.handleObj.origHandler.apply( match.elem, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2883
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2884 if ( ret === false || event.isPropagationStopped() ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2885 maxLevel = match.level;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2886
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2887 if ( ret === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2888 stop = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2889 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2890 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2891 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2892
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2893 return stop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2894 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2895
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2896 function liveConvert( type, selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2897 return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2898 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2899
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2900 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2901 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2902 "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2903
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2904 // Handle event binding
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2905 jQuery.fn[ name ] = function( data, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2906 if ( fn == null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2907 fn = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2908 data = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2909 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2910
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2911 return arguments.length > 0 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2912 this.bind( name, data, fn ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2913 this.trigger( name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2914 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2915
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2916 if ( jQuery.attrFn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2917 jQuery.attrFn[ name ] = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2918 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2919 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2920
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2921 // Prevent memory leaks in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2922 // Window isn't included so as not to unbind existing unload events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2923 // More info:
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2924 // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2925 if ( window.attachEvent && !window.addEventListener ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2926 jQuery(window).bind("unload", function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2927 for ( var id in jQuery.cache ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2928 if ( jQuery.cache[ id ].handle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2929 // Try/Catch is to handle iframes being unloaded, see #4280
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2930 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2931 jQuery.event.remove( jQuery.cache[ id ].handle.elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2932 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2933 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2934 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2935 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2936 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2937
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2938
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2939 /*!
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2940 * Sizzle CSS Selector Engine - v1.0
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2941 * Copyright 2009, The Dojo Foundation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2942 * Released under the MIT, BSD, and GPL Licenses.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2943 * More information: http://sizzlejs.com/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2944 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2945 (function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2946
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2947 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2948 done = 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2949 toString = Object.prototype.toString,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2950 hasDuplicate = false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2951 baseHasDuplicate = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2952
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2953 // Here we check if the JavaScript engine is using some sort of
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2954 // optimization where it does not always call our comparision
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2955 // function. If that is the case, discard the hasDuplicate value.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2956 // Thus far that includes Google Chrome.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2957 [0, 0].sort(function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2958 baseHasDuplicate = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2959 return 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2960 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2961
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2962 var Sizzle = function(selector, context, results, seed) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2963 results = results || [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2964 context = context || document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2965
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2966 var origContext = context;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2967
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2968 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2969 return [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2970 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2971
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2972 if ( !selector || typeof selector !== "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2973 return results;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2974 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2975
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2976 var parts = [], m, set, checkSet, extra, prune = true, contextXML = Sizzle.isXML(context),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2977 soFar = selector, ret, cur, pop, i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2978
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2979 // Reset the position of the chunker regexp (start from head)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2980 do {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2981 chunker.exec("");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2982 m = chunker.exec(soFar);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2983
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2984 if ( m ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2985 soFar = m[3];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2986
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2987 parts.push( m[1] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2988
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2989 if ( m[2] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2990 extra = m[3];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2991 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2992 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2993 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2994 } while ( m );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2995
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2996 if ( parts.length > 1 && origPOS.exec( selector ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2997 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2998 set = posProcess( parts[0] + parts[1], context );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2999 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3000 set = Expr.relative[ parts[0] ] ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3001 [ context ] :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3002 Sizzle( parts.shift(), context );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3003
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3004 while ( parts.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3005 selector = parts.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3006
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3007 if ( Expr.relative[ selector ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3008 selector += parts.shift();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3009 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3010
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3011 set = posProcess( selector, set );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3012 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3013 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3014 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3015 // Take a shortcut and set the context if the root selector is an ID
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3016 // (but not if it'll be faster if the inner selector is an ID)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3017 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3018 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3019 ret = Sizzle.find( parts.shift(), context, contextXML );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3020 context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3021 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3022
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3023 if ( context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3024 ret = seed ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3025 { expr: parts.pop(), set: makeArray(seed) } :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3026 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3027 set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3028
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3029 if ( parts.length > 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3030 checkSet = makeArray(set);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3031 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3032 prune = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3033 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3034
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3035 while ( parts.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3036 cur = parts.pop();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3037 pop = cur;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3038
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3039 if ( !Expr.relative[ cur ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3040 cur = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3041 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3042 pop = parts.pop();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3043 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3044
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3045 if ( pop == null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3046 pop = context;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3047 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3048
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3049 Expr.relative[ cur ]( checkSet, pop, contextXML );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3050 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3051 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3052 checkSet = parts = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3053 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3054 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3055
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3056 if ( !checkSet ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3057 checkSet = set;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3058 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3059
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3060 if ( !checkSet ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3061 Sizzle.error( cur || selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3062 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3063
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3064 if ( toString.call(checkSet) === "[object Array]" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3065 if ( !prune ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3066 results.push.apply( results, checkSet );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3067 } else if ( context && context.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3068 for ( i = 0; checkSet[i] != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3069 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3070 results.push( set[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3071 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3072 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3073 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3074 for ( i = 0; checkSet[i] != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3075 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3076 results.push( set[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3077 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3078 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3079 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3080 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3081 makeArray( checkSet, results );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3082 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3083
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3084 if ( extra ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3085 Sizzle( extra, origContext, results, seed );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3086 Sizzle.uniqueSort( results );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3087 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3088
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3089 return results;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3090 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3091
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3092 Sizzle.uniqueSort = function(results){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3093 if ( sortOrder ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3094 hasDuplicate = baseHasDuplicate;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3095 results.sort(sortOrder);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3096
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3097 if ( hasDuplicate ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3098 for ( var i = 1; i < results.length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3099 if ( results[i] === results[i-1] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3100 results.splice(i--, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3101 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3102 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3103 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3104 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3105
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3106 return results;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3107 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3108
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3109 Sizzle.matches = function(expr, set){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3110 return Sizzle(expr, null, null, set);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3111 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3112
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3113 Sizzle.matchesSelector = function(node, expr){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3114 return Sizzle(expr, null, null, [node]).length > 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3115 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3116
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3117 Sizzle.find = function(expr, context, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3118 var set;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3119
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3120 if ( !expr ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3121 return [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3122 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3123
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3124 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3125 var type = Expr.order[i], match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3126
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3127 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3128 var left = match[1];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3129 match.splice(1,1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3130
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3131 if ( left.substr( left.length - 1 ) !== "\\" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3132 match[1] = (match[1] || "").replace(/\\/g, "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3133 set = Expr.find[ type ]( match, context, isXML );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3134 if ( set != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3135 expr = expr.replace( Expr.match[ type ], "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3136 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3137 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3138 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3139 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3140 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3141
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3142 if ( !set ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3143 set = context.getElementsByTagName("*");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3144 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3146 return {set: set, expr: expr};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3147 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3149 Sizzle.filter = function(expr, set, inplace, not){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3150 var old = expr, result = [], curLoop = set, match, anyFound,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3151 isXMLFilter = set && set[0] && Sizzle.isXML(set[0]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3152
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3153 while ( expr && set.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3154 for ( var type in Expr.filter ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3155 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3156 var filter = Expr.filter[ type ], found, item, left = match[1];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3157 anyFound = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3158
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3159 match.splice(1,1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3160
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3161 if ( left.substr( left.length - 1 ) === "\\" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3162 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3163 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3164
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3165 if ( curLoop === result ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3166 result = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3167 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3168
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3169 if ( Expr.preFilter[ type ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3170 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3171
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3172 if ( !match ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3173 anyFound = found = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3174 } else if ( match === true ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3175 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3176 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3177 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3178
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3179 if ( match ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3180 for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3181 if ( item ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3182 found = filter( item, match, i, curLoop );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3183 var pass = not ^ !!found;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3184
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3185 if ( inplace && found != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3186 if ( pass ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3187 anyFound = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3188 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3189 curLoop[i] = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3190 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3191 } else if ( pass ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3192 result.push( item );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3193 anyFound = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3194 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3195 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3196 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3197 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3198
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3199 if ( found !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3200 if ( !inplace ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3201 curLoop = result;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3202 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3203
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3204 expr = expr.replace( Expr.match[ type ], "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3205
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3206 if ( !anyFound ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3207 return [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3208 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3209
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3210 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3211 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3212 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3213 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3214
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3215 // Improper expression
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3216 if ( expr === old ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3217 if ( anyFound == null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3218 Sizzle.error( expr );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3219 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3220 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3221 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3222 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3223
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3224 old = expr;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3225 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3226
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3227 return curLoop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3228 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3229
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3230 Sizzle.error = function( msg ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3231 throw "Syntax error, unrecognized expression: " + msg;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3232 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3233
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3234 var Expr = Sizzle.selectors = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3235 order: [ "ID", "NAME", "TAG" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3236 match: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3237 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3238 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3239 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3240 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3241 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3242 CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3243 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3244 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3245 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3246 leftMatch: {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3247 attrMap: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3248 "class": "className",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3249 "for": "htmlFor"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3250 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3251 attrHandle: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3252 href: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3253 return elem.getAttribute("href");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3254 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3255 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3256 relative: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3257 "+": function(checkSet, part){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3258 var isPartStr = typeof part === "string",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3259 isTag = isPartStr && !/\W/.test(part),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3260 isPartStrNotTag = isPartStr && !isTag;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3261
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3262 if ( isTag ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3263 part = part.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3264 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3265
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3266 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3267 if ( (elem = checkSet[i]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3268 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3269
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3270 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3271 elem || false :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3272 elem === part;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3273 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3274 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3275
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3276 if ( isPartStrNotTag ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3277 Sizzle.filter( part, checkSet, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3278 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3279 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3280 ">": function(checkSet, part){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3281 var isPartStr = typeof part === "string",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3282 elem, i = 0, l = checkSet.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3283
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3284 if ( isPartStr && !/\W/.test(part) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3285 part = part.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3286
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3287 for ( ; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3288 elem = checkSet[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3289 if ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3290 var parent = elem.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3291 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3292 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3293 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3294 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3295 for ( ; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3296 elem = checkSet[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3297 if ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3298 checkSet[i] = isPartStr ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3299 elem.parentNode :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3300 elem.parentNode === part;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3301 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3302 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3303
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3304 if ( isPartStr ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3305 Sizzle.filter( part, checkSet, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3306 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3307 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3308 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3309 "": function(checkSet, part, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3310 var doneName = done++, checkFn = dirCheck, nodeCheck;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3311
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3312 if ( typeof part === "string" && !/\W/.test(part) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3313 part = part.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3314 nodeCheck = part;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3315 checkFn = dirNodeCheck;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3316 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3317
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3318 checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3319 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3320 "~": function(checkSet, part, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3321 var doneName = done++, checkFn = dirCheck, nodeCheck;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3322
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3323 if ( typeof part === "string" && !/\W/.test(part) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3324 part = part.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3325 nodeCheck = part;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3326 checkFn = dirNodeCheck;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3327 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3328
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3329 checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3330 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3331 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3332 find: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3333 ID: function(match, context, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3334 if ( typeof context.getElementById !== "undefined" && !isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3335 var m = context.getElementById(match[1]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3336 // Check parentNode to catch when Blackberry 4.6 returns
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3337 // nodes that are no longer in the document #6963
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3338 return m && m.parentNode ? [m] : [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3339 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3340 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3341 NAME: function(match, context){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3342 if ( typeof context.getElementsByName !== "undefined" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3343 var ret = [], results = context.getElementsByName(match[1]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3344
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3345 for ( var i = 0, l = results.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3346 if ( results[i].getAttribute("name") === match[1] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3347 ret.push( results[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3348 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3349 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3350
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3351 return ret.length === 0 ? null : ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3352 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3353 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3354 TAG: function(match, context){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3355 return context.getElementsByTagName(match[1]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3356 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3357 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3358 preFilter: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3359 CLASS: function(match, curLoop, inplace, result, not, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3360 match = " " + match[1].replace(/\\/g, "") + " ";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3361
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3362 if ( isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3363 return match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3364 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3365
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3366 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3367 if ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3368 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3369 if ( !inplace ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3370 result.push( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3371 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3372 } else if ( inplace ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3373 curLoop[i] = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3374 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3375 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3376 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3377
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3378 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3379 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3380 ID: function(match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3381 return match[1].replace(/\\/g, "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3382 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3383 TAG: function(match, curLoop){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3384 return match[1].toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3385 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3386 CHILD: function(match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3387 if ( match[1] === "nth" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3388 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3389 var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3390 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3391 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3392
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3393 // calculate the numbers (first)n+(last) including if they are negative
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3394 match[2] = (test[1] + (test[2] || 1)) - 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3395 match[3] = test[3] - 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3396 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3397
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3398 // TODO: Move to normal caching system
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3399 match[0] = done++;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3400
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3401 return match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3402 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3403 ATTR: function(match, curLoop, inplace, result, not, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3404 var name = match[1].replace(/\\/g, "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3405
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3406 if ( !isXML && Expr.attrMap[name] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3407 match[1] = Expr.attrMap[name];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3408 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3409
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3410 if ( match[2] === "~=" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3411 match[4] = " " + match[4] + " ";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3412 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3413
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3414 return match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3415 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3416 PSEUDO: function(match, curLoop, inplace, result, not){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3417 if ( match[1] === "not" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3418 // If we're dealing with a complex expression, or a simple one
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3419 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3420 match[3] = Sizzle(match[3], null, null, curLoop);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3421 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3422 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3423 if ( !inplace ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3424 result.push.apply( result, ret );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3425 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3426 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3427 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3428 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3429 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3430 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3431
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3432 return match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3433 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3434 POS: function(match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3435 match.unshift( true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3436 return match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3437 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3438 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3439 filters: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3440 enabled: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3441 return elem.disabled === false && elem.type !== "hidden";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3442 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3443 disabled: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3444 return elem.disabled === true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3445 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3446 checked: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3447 return elem.checked === true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3448 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3449 selected: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3450 // Accessing this property makes selected-by-default
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3451 // options in Safari work properly
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3452 elem.parentNode.selectedIndex;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3453 return elem.selected === true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3454 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3455 parent: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3456 return !!elem.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3457 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3458 empty: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3459 return !elem.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3460 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3461 has: function(elem, i, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3462 return !!Sizzle( match[3], elem ).length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3463 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3464 header: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3465 return (/h\d/i).test( elem.nodeName );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3466 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3467 text: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3468 return "text" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3469 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3470 radio: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3471 return "radio" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3472 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3473 checkbox: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3474 return "checkbox" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3475 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3476 file: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3477 return "file" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3478 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3479 password: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3480 return "password" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3481 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3482 submit: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3483 return "submit" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3484 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3485 image: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3486 return "image" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3487 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3488 reset: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3489 return "reset" === elem.type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3490 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3491 button: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3492 return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3493 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3494 input: function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3495 return (/input|select|textarea|button/i).test(elem.nodeName);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3496 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3497 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3498 setFilters: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3499 first: function(elem, i){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3500 return i === 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3501 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3502 last: function(elem, i, match, array){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3503 return i === array.length - 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3504 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3505 even: function(elem, i){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3506 return i % 2 === 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3507 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3508 odd: function(elem, i){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3509 return i % 2 === 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3510 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3511 lt: function(elem, i, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3512 return i < match[3] - 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3513 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3514 gt: function(elem, i, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3515 return i > match[3] - 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3516 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3517 nth: function(elem, i, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3518 return match[3] - 0 === i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3519 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3520 eq: function(elem, i, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3521 return match[3] - 0 === i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3522 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3523 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3524 filter: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3525 PSEUDO: function(elem, match, i, array){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3526 var name = match[1], filter = Expr.filters[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3527
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3528 if ( filter ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3529 return filter( elem, i, match, array );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3530 } else if ( name === "contains" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3531 return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3532 } else if ( name === "not" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3533 var not = match[3];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3534
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3535 for ( var j = 0, l = not.length; j < l; j++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3536 if ( not[j] === elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3537 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3538 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3539 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3540
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3541 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3542 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3543 Sizzle.error( "Syntax error, unrecognized expression: " + name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3544 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3545 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3546 CHILD: function(elem, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3547 var type = match[1], node = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3548 switch (type) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3549 case 'only':
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3550 case 'first':
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3551 while ( (node = node.previousSibling) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3552 if ( node.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3553 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3554 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3555 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3556 if ( type === "first" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3557 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3558 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3559 node = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3560 case 'last':
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3561 while ( (node = node.nextSibling) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3562 if ( node.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3563 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3564 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3565 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3566 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3567 case 'nth':
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3568 var first = match[2], last = match[3];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3569
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3570 if ( first === 1 && last === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3571 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3572 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3573
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3574 var doneName = match[0],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3575 parent = elem.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3576
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3577 if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3578 var count = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3579 for ( node = parent.firstChild; node; node = node.nextSibling ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3580 if ( node.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3581 node.nodeIndex = ++count;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3582 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3583 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3584 parent.sizcache = doneName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3585 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3586
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3587 var diff = elem.nodeIndex - last;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3588 if ( first === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3589 return diff === 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3590 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3591 return ( diff % first === 0 && diff / first >= 0 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3592 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3593 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3594 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3595 ID: function(elem, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3596 return elem.nodeType === 1 && elem.getAttribute("id") === match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3597 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3598 TAG: function(elem, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3599 return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3600 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3601 CLASS: function(elem, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3602 return (" " + (elem.className || elem.getAttribute("class")) + " ")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3603 .indexOf( match ) > -1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3604 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3605 ATTR: function(elem, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3606 var name = match[1],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3607 result = Expr.attrHandle[ name ] ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3608 Expr.attrHandle[ name ]( elem ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3609 elem[ name ] != null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3610 elem[ name ] :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3611 elem.getAttribute( name ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3612 value = result + "",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3613 type = match[2],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3614 check = match[4];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3615
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3616 return result == null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3617 type === "!=" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3618 type === "=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3619 value === check :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3620 type === "*=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3621 value.indexOf(check) >= 0 :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3622 type === "~=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3623 (" " + value + " ").indexOf(check) >= 0 :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3624 !check ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3625 value && result !== false :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3626 type === "!=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3627 value !== check :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3628 type === "^=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3629 value.indexOf(check) === 0 :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3630 type === "$=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3631 value.substr(value.length - check.length) === check :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3632 type === "|=" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3633 value === check || value.substr(0, check.length + 1) === check + "-" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3634 false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3635 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3636 POS: function(elem, match, i, array){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3637 var name = match[2], filter = Expr.setFilters[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3638
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3639 if ( filter ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3640 return filter( elem, i, match, array );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3641 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3642 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3643 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3644 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3645
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3646 var origPOS = Expr.match.POS,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3647 fescape = function(all, num){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3648 return "\\" + (num - 0 + 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3649 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3650
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3651 for ( var type in Expr.match ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3652 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3653 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3654 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3655
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3656 var makeArray = function(array, results) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3657 array = Array.prototype.slice.call( array, 0 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3658
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3659 if ( results ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3660 results.push.apply( results, array );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3661 return results;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3662 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3663
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3664 return array;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3665 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3666
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3667 // Perform a simple check to determine if the browser is capable of
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3668 // converting a NodeList to an array using builtin methods.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3669 // Also verifies that the returned array holds DOM nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3670 // (which is not the case in the Blackberry browser)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3671 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3672 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3673
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3674 // Provide a fallback method if it does not work
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3675 } catch(e){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3676 makeArray = function(array, results) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3677 var ret = results || [], i = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3678
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3679 if ( toString.call(array) === "[object Array]" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3680 Array.prototype.push.apply( ret, array );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3681 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3682 if ( typeof array.length === "number" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3683 for ( var l = array.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3684 ret.push( array[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3685 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3686 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3687 for ( ; array[i]; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3688 ret.push( array[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3689 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3690 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3691 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3692
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3693 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3694 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3695 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3696
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3697 var sortOrder, siblingCheck;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3698
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3699 if ( document.documentElement.compareDocumentPosition ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3700 sortOrder = function( a, b ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3701 if ( a === b ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3702 hasDuplicate = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3703 return 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3704 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3705
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3706 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3707 return a.compareDocumentPosition ? -1 : 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3708 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3709
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3710 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3711 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3712 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3713 sortOrder = function( a, b ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3714 var ap = [], bp = [], aup = a.parentNode, bup = b.parentNode,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3715 cur = aup, al, bl;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3716
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3717 // The nodes are identical, we can exit early
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3718 if ( a === b ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3719 hasDuplicate = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3720 return 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3721
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3722 // If the nodes are siblings (or identical) we can do a quick check
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3723 } else if ( aup === bup ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3724 return siblingCheck( a, b );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3725
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3726 // If no parents were found then the nodes are disconnected
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3727 } else if ( !aup ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3728 return -1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3729
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3730 } else if ( !bup ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3731 return 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3732 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3733
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3734 // Otherwise they're somewhere else in the tree so we need
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3735 // to build up a full list of the parentNodes for comparison
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3736 while ( cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3737 ap.unshift( cur );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3738 cur = cur.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3739 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3740
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3741 cur = bup;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3742
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3743 while ( cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3744 bp.unshift( cur );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3745 cur = cur.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3746 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3747
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3748 al = ap.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3749 bl = bp.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3750
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3751 // Start walking down the tree looking for a discrepancy
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3752 for ( var i = 0; i < al && i < bl; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3753 if ( ap[i] !== bp[i] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3754 return siblingCheck( ap[i], bp[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3755 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3756 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3757
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3758 // We ended someplace up the tree so do a sibling check
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3759 return i === al ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3760 siblingCheck( a, bp[i], -1 ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3761 siblingCheck( ap[i], b, 1 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3762 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3763
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3764 siblingCheck = function( a, b, ret ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3765 if ( a === b ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3766 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3767 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3768
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3769 var cur = a.nextSibling;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3770
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3771 while ( cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3772 if ( cur === b ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3773 return -1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3774 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3775
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3776 cur = cur.nextSibling;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3777 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3778
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3779 return 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3780 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3781 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3782
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3783 // Utility function for retreiving the text value of an array of DOM nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3784 Sizzle.getText = function( elems ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3785 var ret = "", elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3786
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3787 for ( var i = 0; elems[i]; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3788 elem = elems[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3789
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3790 // Get the text from text nodes and CDATA nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3791 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3792 ret += elem.nodeValue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3793
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3794 // Traverse everything else, except comment nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3795 } else if ( elem.nodeType !== 8 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3796 ret += Sizzle.getText( elem.childNodes );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3797 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3798 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3799
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3800 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3801 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3802
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3803 // Check to see if the browser returns elements by name when
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3804 // querying by getElementById (and provide a workaround)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3805 (function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3806 // We're going to inject a fake input element with a specified name
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3807 var form = document.createElement("div"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3808 id = "script" + (new Date()).getTime();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3809 form.innerHTML = "<a name='" + id + "'/>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3810
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3811 // Inject it into the root element, check its status, and remove it quickly
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3812 var root = document.documentElement;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3813 root.insertBefore( form, root.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3814
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3815 // The workaround has to do additional checks after a getElementById
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3816 // Which slows things down for other browsers (hence the branching)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3817 if ( document.getElementById( id ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3818 Expr.find.ID = function(match, context, isXML){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3819 if ( typeof context.getElementById !== "undefined" && !isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3820 var m = context.getElementById(match[1]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3821 return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3822 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3823 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3824
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3825 Expr.filter.ID = function(elem, match){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3826 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3827 return elem.nodeType === 1 && node && node.nodeValue === match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3828 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3829 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3830
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3831 root.removeChild( form );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3832 root = form = null; // release memory in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3833 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3834
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3835 (function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3836 // Check to see if the browser returns only elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3837 // when doing getElementsByTagName("*")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3838
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3839 // Create a fake element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3840 var div = document.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3841 div.appendChild( document.createComment("") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3842
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3843 // Make sure no comments are found
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3844 if ( div.getElementsByTagName("*").length > 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3845 Expr.find.TAG = function(match, context){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3846 var results = context.getElementsByTagName(match[1]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3847
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3848 // Filter out possible comments
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3849 if ( match[1] === "*" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3850 var tmp = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3851
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3852 for ( var i = 0; results[i]; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3853 if ( results[i].nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3854 tmp.push( results[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3855 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3856 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3857
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3858 results = tmp;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3859 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3860
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3861 return results;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3862 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3863 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3864
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3865 // Check to see if an attribute returns normalized href attributes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3866 div.innerHTML = "<a href='#'></a>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3867 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3868 div.firstChild.getAttribute("href") !== "#" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3869 Expr.attrHandle.href = function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3870 return elem.getAttribute("href", 2);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3871 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3872 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3873
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3874 div = null; // release memory in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3875 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3876
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3877 if ( document.querySelectorAll ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3878 (function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3879 var oldSizzle = Sizzle, div = document.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3880 div.innerHTML = "<p class='TEST'></p>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3881
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3882 // Safari can't handle uppercase or unicode characters when
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3883 // in quirks mode.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3884 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3885 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3886 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3887
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3888 Sizzle = function(query, context, extra, seed){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3889 context = context || document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3890
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3891 // Only use querySelectorAll on non-XML documents
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3892 // (ID selectors don't work in non-HTML documents)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3893 if ( !seed && !Sizzle.isXML(context) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3894 if ( context.nodeType === 9 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3895 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3896 return makeArray( context.querySelectorAll(query), extra );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3897 } catch(qsaError) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3898
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3899 // qSA works strangely on Element-rooted queries
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3900 // We can work around this by specifying an extra ID on the root
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3901 // and working up from there (Thanks to Andrew Dupont for the technique)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3902 // IE 8 doesn't work on object elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3903 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3904 var old = context.id, id = context.id = "__sizzle__";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3905
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3906 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3907 return makeArray( context.querySelectorAll( "#" + id + " " + query ), extra );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3908
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3909 } catch(pseudoError) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3910 } finally {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3911 if ( old ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3912 context.id = old;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3913
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3914 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3915 context.removeAttribute( "id" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3916 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3917 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3918 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3919 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3920
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3921 return oldSizzle(query, context, extra, seed);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3922 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3923
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3924 for ( var prop in oldSizzle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3925 Sizzle[ prop ] = oldSizzle[ prop ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3926 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3927
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3928 div = null; // release memory in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3929 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3930 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3931
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3932 (function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3933 var html = document.documentElement,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3934 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3935 pseudoWorks = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3936
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3937 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3938 // This should fail with an exception
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3939 // Gecko does not error, returns false instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3940 matches.call( document.documentElement, ":sizzle" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3941
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3942 } catch( pseudoError ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3943 pseudoWorks = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3944 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3945
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3946 if ( matches ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3947 Sizzle.matchesSelector = function( node, expr ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3948 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3949 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3950 return matches.call( node, expr );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3951 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3952 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3953
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3954 return Sizzle(expr, null, null, [node]).length > 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3955 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3956 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3957 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3958
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3959 (function(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3960 var div = document.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3961
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3962 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3963
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3964 // Opera can't find a second classname (in 9.6)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3965 // Also, make sure that getElementsByClassName actually exists
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3966 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3967 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3968 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3969
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3970 // Safari caches class attributes, doesn't catch changes (in 3.2)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3971 div.lastChild.className = "e";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3972
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3973 if ( div.getElementsByClassName("e").length === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3974 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3975 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3976
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3977 Expr.order.splice(1, 0, "CLASS");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3978 Expr.find.CLASS = function(match, context, isXML) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3979 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3980 return context.getElementsByClassName(match[1]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3981 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3982 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3983
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3984 div = null; // release memory in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3985 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3986
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3987 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3988 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3989 var elem = checkSet[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3990 if ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3991 elem = elem[dir];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3992 var match = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3993
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3994 while ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3995 if ( elem.sizcache === doneName ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3996 match = checkSet[elem.sizset];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3997 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3998 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3999
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4000 if ( elem.nodeType === 1 && !isXML ){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4001 elem.sizcache = doneName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4002 elem.sizset = i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4003 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4004
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4005 if ( elem.nodeName.toLowerCase() === cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4006 match = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4007 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4008 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4009
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4010 elem = elem[dir];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4011 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4012
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4013 checkSet[i] = match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4014 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4015 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4016 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4017
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4018 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4019 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4020 var elem = checkSet[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4021 if ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4022 elem = elem[dir];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4023 var match = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4024
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4025 while ( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4026 if ( elem.sizcache === doneName ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4027 match = checkSet[elem.sizset];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4028 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4029 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4030
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4031 if ( elem.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4032 if ( !isXML ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4033 elem.sizcache = doneName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4034 elem.sizset = i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4035 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4036 if ( typeof cur !== "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4037 if ( elem === cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4038 match = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4039 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4040 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4041
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4042 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4043 match = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4044 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4045 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4046 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4047
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4048 elem = elem[dir];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4049 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4050
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4051 checkSet[i] = match;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4052 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4053 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4054 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4055
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4056 Sizzle.contains = document.documentElement.contains ? function(a, b){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4057 return a !== b && (a.contains ? a.contains(b) : true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4058 } : function(a, b){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4059 return !!(a.compareDocumentPosition(b) & 16);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4060 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4061
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4062 Sizzle.isXML = function(elem){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4063 // documentElement is verified for cases where it doesn't yet exist
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4064 // (such as loading iframes in IE - #4833)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4065 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4066 return documentElement ? documentElement.nodeName !== "HTML" : false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4067 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4068
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4069 var posProcess = function(selector, context){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4070 var tmpSet = [], later = "", match,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4071 root = context.nodeType ? [context] : context;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4072
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4073 // Position selectors must be done after the filter
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4074 // And so must :not(positional) so we move all PSEUDOs to the end
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4075 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4076 later += match[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4077 selector = selector.replace( Expr.match.PSEUDO, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4078 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4079
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4080 selector = Expr.relative[selector] ? selector + "*" : selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4081
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4082 for ( var i = 0, l = root.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4083 Sizzle( selector, root[i], tmpSet );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4084 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4085
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4086 return Sizzle.filter( later, tmpSet );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4087 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4088
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4089 // EXPOSE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4090 jQuery.find = Sizzle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4091 jQuery.expr = Sizzle.selectors;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4092 jQuery.expr[":"] = jQuery.expr.filters;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4093 jQuery.unique = Sizzle.uniqueSort;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4094 jQuery.text = Sizzle.getText;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4095 jQuery.isXMLDoc = Sizzle.isXML;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4096 jQuery.contains = Sizzle.contains;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4097
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4098
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4099 })();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4100
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4101
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4102 var runtil = /Until$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4103 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4104 // Note: This RegExp should be improved, or likely pulled from Sizzle
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4105 rmultiselector = /,/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4106 isSimple = /^.[^:#\[\.,]*$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4107 slice = Array.prototype.slice,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4108 POS = jQuery.expr.match.POS;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4109
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4110 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4111 find: function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4112 var ret = this.pushStack( "", "find", selector ), length = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4113
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4114 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4115 length = ret.length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4116 jQuery.find( selector, this[i], ret );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4117
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4118 if ( i > 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4119 // Make sure that the results are unique
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4120 for ( var n = length; n < ret.length; n++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4121 for ( var r = 0; r < length; r++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4122 if ( ret[r] === ret[n] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4123 ret.splice(n--, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4124 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4125 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4126 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4127 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4128 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4129 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4130
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4131 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4132 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4133
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4134 has: function( target ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4135 var targets = jQuery( target );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4136 return this.filter(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4137 for ( var i = 0, l = targets.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4138 if ( jQuery.contains( this, targets[i] ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4139 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4140 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4141 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4142 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4143 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4144
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4145 not: function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4146 return this.pushStack( winnow(this, selector, false), "not", selector);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4147 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4149 filter: function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4150 return this.pushStack( winnow(this, selector, true), "filter", selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4151 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4152
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4153 is: function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4154 return !!selector && jQuery.filter( selector, this ).length > 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4155 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4156
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4157 closest: function( selectors, context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4158 var ret = [], i, l, cur = this[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4159
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4160 if ( jQuery.isArray( selectors ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4161 var match, matches = {}, selector, level = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4162
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4163 if ( cur && selectors.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4164 for ( i = 0, l = selectors.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4165 selector = selectors[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4166
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4167 if ( !matches[selector] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4168 matches[selector] = jQuery.expr.match.POS.test( selector ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4169 jQuery( selector, context || this.context ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4170 selector;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4171 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4172 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4173
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4174 while ( cur && cur.ownerDocument && cur !== context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4175 for ( selector in matches ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4176 match = matches[selector];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4177
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4178 if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4179 ret.push({ selector: selector, elem: cur, level: level });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4180 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4181 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4182
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4183 cur = cur.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4184 level++;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4185 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4186 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4187
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4188 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4189 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4190
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4191 var pos = POS.test( selectors ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4192 jQuery( selectors, context || this.context ) : null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4193
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4194 for ( i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4195 cur = this[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4196
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4197 while ( cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4198 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4199 ret.push( cur );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4200 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4201
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4202 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4203 cur = cur.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4204 if ( !cur || !cur.ownerDocument || cur === context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4205 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4206 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4207 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4208 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4209 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4210
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4211 ret = ret.length > 1 ? jQuery.unique(ret) : ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4212
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4213 return this.pushStack( ret, "closest", selectors );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4214 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4215
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4216 // Determine the position of an element within
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4217 // the matched set of elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4218 index: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4219 if ( !elem || typeof elem === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4220 return jQuery.inArray( this[0],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4221 // If it receives a string, the selector is used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4222 // If it receives nothing, the siblings are used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4223 elem ? jQuery( elem ) : this.parent().children() );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4224 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4225 // Locate the position of the desired element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4226 return jQuery.inArray(
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4227 // If it receives a jQuery object, the first element is used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4228 elem.jquery ? elem[0] : elem, this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4229 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4230
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4231 add: function( selector, context ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4232 var set = typeof selector === "string" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4233 jQuery( selector, context || this.context ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4234 jQuery.makeArray( selector ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4235 all = jQuery.merge( this.get(), set );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4236
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4237 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4238 all :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4239 jQuery.unique( all ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4240 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4241
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4242 andSelf: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4243 return this.add( this.prevObject );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4244 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4245 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4246
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4247 // A painfully simple check to see if an element is disconnected
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4248 // from a document (should be improved, where feasible).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4249 function isDisconnected( node ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4250 return !node || !node.parentNode || node.parentNode.nodeType === 11;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4251 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4252
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4253 jQuery.each({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4254 parent: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4255 var parent = elem.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4256 return parent && parent.nodeType !== 11 ? parent : null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4257 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4258 parents: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4259 return jQuery.dir( elem, "parentNode" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4260 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4261 parentsUntil: function( elem, i, until ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4262 return jQuery.dir( elem, "parentNode", until );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4263 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4264 next: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4265 return jQuery.nth( elem, 2, "nextSibling" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4266 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4267 prev: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4268 return jQuery.nth( elem, 2, "previousSibling" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4269 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4270 nextAll: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4271 return jQuery.dir( elem, "nextSibling" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4272 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4273 prevAll: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4274 return jQuery.dir( elem, "previousSibling" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4275 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4276 nextUntil: function( elem, i, until ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4277 return jQuery.dir( elem, "nextSibling", until );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4278 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4279 prevUntil: function( elem, i, until ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4280 return jQuery.dir( elem, "previousSibling", until );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4281 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4282 siblings: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4283 return jQuery.sibling( elem.parentNode.firstChild, elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4284 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4285 children: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4286 return jQuery.sibling( elem.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4287 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4288 contents: function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4289 return jQuery.nodeName( elem, "iframe" ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4290 elem.contentDocument || elem.contentWindow.document :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4291 jQuery.makeArray( elem.childNodes );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4292 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4293 }, function( name, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4294 jQuery.fn[ name ] = function( until, selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4295 var ret = jQuery.map( this, fn, until );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4296
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4297 if ( !runtil.test( name ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4298 selector = until;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4299 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4300
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4301 if ( selector && typeof selector === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4302 ret = jQuery.filter( selector, ret );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4303 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4304
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4305 ret = this.length > 1 ? jQuery.unique( ret ) : ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4306
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4307 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4308 ret = ret.reverse();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4309 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4310
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4311 return this.pushStack( ret, name, slice.call(arguments).join(",") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4312 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4313 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4314
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4315 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4316 filter: function( expr, elems, not ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4317 if ( not ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4318 expr = ":not(" + expr + ")";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4319 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4320
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4321 return elems.length === 1 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4322 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4323 jQuery.find.matches(expr, elems);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4324 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4325
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4326 dir: function( elem, dir, until ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4327 var matched = [], cur = elem[dir];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4328 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4329 if ( cur.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4330 matched.push( cur );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4331 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4332 cur = cur[dir];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4333 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4334 return matched;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4335 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4336
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4337 nth: function( cur, result, dir, elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4338 result = result || 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4339 var num = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4340
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4341 for ( ; cur; cur = cur[dir] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4342 if ( cur.nodeType === 1 && ++num === result ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4343 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4344 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4345 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4346
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4347 return cur;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4348 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4349
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4350 sibling: function( n, elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4351 var r = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4352
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4353 for ( ; n; n = n.nextSibling ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4354 if ( n.nodeType === 1 && n !== elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4355 r.push( n );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4356 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4357 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4358
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4359 return r;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4360 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4361 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4362
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4363 // Implement the identical functionality for filter and not
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4364 function winnow( elements, qualifier, keep ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4365 if ( jQuery.isFunction( qualifier ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4366 return jQuery.grep(elements, function( elem, i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4367 var retVal = !!qualifier.call( elem, i, elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4368 return retVal === keep;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4369 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4370
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4371 } else if ( qualifier.nodeType ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4372 return jQuery.grep(elements, function( elem, i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4373 return (elem === qualifier) === keep;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4374 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4375
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4376 } else if ( typeof qualifier === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4377 var filtered = jQuery.grep(elements, function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4378 return elem.nodeType === 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4379 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4380
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4381 if ( isSimple.test( qualifier ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4382 return jQuery.filter(qualifier, filtered, !keep);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4383 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4384 qualifier = jQuery.filter( qualifier, filtered );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4385 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4386 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4387
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4388 return jQuery.grep(elements, function( elem, i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4389 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4390 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4391 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4392
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4393
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4394
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4395
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4396 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4397 rleadingWhitespace = /^\s+/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4398 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4399 rtagName = /<([\w:]+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4400 rtbody = /<tbody/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4401 rhtml = /<|&#?\w+;/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4402 rnocache = /<(?:script|object|embed|option|style)/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4403 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4404 raction = /\=([^="'>\s]+\/)>/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4405 wrapMap = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4406 option: [ 1, "<select multiple='multiple'>", "</select>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4407 legend: [ 1, "<fieldset>", "</fieldset>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4408 thead: [ 1, "<table>", "</table>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4409 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4410 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4411 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4412 area: [ 1, "<map>", "</map>" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4413 _default: [ 0, "", "" ]
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4414 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4415
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4416 wrapMap.optgroup = wrapMap.option;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4417 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4418 wrapMap.th = wrapMap.td;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4419
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4420 // IE can't serialize <link> and <script> tags normally
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4421 if ( !jQuery.support.htmlSerialize ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4422 wrapMap._default = [ 1, "div<div>", "</div>" ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4423 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4424
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4425 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4426 text: function( text ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4427 if ( jQuery.isFunction(text) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4428 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4429 var self = jQuery(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4430 self.text( text.call(this, i, self.text()) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4431 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4432 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4433
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4434 if ( typeof text !== "object" && text !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4435 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4436 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4437
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4438 return jQuery.text( this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4439 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4440
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4441 wrapAll: function( html ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4442 if ( jQuery.isFunction( html ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4443 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4444 jQuery(this).wrapAll( html.call(this, i) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4445 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4446 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4447
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4448 if ( this[0] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4449 // The elements to wrap the target around
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4450 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4451
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4452 if ( this[0].parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4453 wrap.insertBefore( this[0] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4454 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4455
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4456 wrap.map(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4457 var elem = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4458
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4459 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4460 elem = elem.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4461 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4462
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4463 return elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4464 }).append(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4465 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4466
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4467 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4468 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4469
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4470 wrapInner: function( html ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4471 if ( jQuery.isFunction( html ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4472 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4473 jQuery(this).wrapInner( html.call(this, i) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4474 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4475 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4476
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4477 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4478 var self = jQuery( this ), contents = self.contents();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4479
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4480 if ( contents.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4481 contents.wrapAll( html );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4482
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4483 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4484 self.append( html );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4485 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4486 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4487 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4488
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4489 wrap: function( html ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4490 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4491 jQuery( this ).wrapAll( html );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4492 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4493 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4494
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4495 unwrap: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4496 return this.parent().each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4497 if ( !jQuery.nodeName( this, "body" ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4498 jQuery( this ).replaceWith( this.childNodes );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4499 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4500 }).end();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4501 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4502
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4503 append: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4504 return this.domManip(arguments, true, function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4505 if ( this.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4506 this.appendChild( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4507 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4508 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4509 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4510
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4511 prepend: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4512 return this.domManip(arguments, true, function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4513 if ( this.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4514 this.insertBefore( elem, this.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4515 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4516 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4517 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4518
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4519 before: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4520 if ( this[0] && this[0].parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4521 return this.domManip(arguments, false, function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4522 this.parentNode.insertBefore( elem, this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4523 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4524 } else if ( arguments.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4525 var set = jQuery(arguments[0]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4526 set.push.apply( set, this.toArray() );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4527 return this.pushStack( set, "before", arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4528 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4529 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4530
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4531 after: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4532 if ( this[0] && this[0].parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4533 return this.domManip(arguments, false, function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4534 this.parentNode.insertBefore( elem, this.nextSibling );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4535 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4536 } else if ( arguments.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4537 var set = this.pushStack( this, "after", arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4538 set.push.apply( set, jQuery(arguments[0]).toArray() );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4539 return set;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4540 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4541 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4542
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4543 // keepData is for internal use only--do not document
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4544 remove: function( selector, keepData ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4545 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4546 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4547 if ( !keepData && elem.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4548 jQuery.cleanData( elem.getElementsByTagName("*") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4549 jQuery.cleanData( [ elem ] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4550 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4551
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4552 if ( elem.parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4553 elem.parentNode.removeChild( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4554 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4555 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4556 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4557
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4558 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4559 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4560
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4561 empty: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4562 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4563 // Remove element nodes and prevent memory leaks
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4564 if ( elem.nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4565 jQuery.cleanData( elem.getElementsByTagName("*") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4566 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4567
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4568 // Remove any remaining nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4569 while ( elem.firstChild ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4570 elem.removeChild( elem.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4571 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4572 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4573
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4574 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4575 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4576
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4577 clone: function( events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4578 // Do the clone
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4579 var ret = this.map(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4580 if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4581 // IE copies events bound via attachEvent when
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4582 // using cloneNode. Calling detachEvent on the
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4583 // clone will also remove the events from the orignal
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4584 // In order to get around this, we use innerHTML.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4585 // Unfortunately, this means some modifications to
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4586 // attributes in IE that are actually only stored
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4587 // as properties will not be copied (such as the
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4588 // the name attribute on an input).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4589 var html = this.outerHTML, ownerDocument = this.ownerDocument;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4590 if ( !html ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4591 var div = ownerDocument.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4592 div.appendChild( this.cloneNode(true) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4593 html = div.innerHTML;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4594 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4595
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4596 return jQuery.clean([html.replace(rinlinejQuery, "")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4597 // Handle the case in IE 8 where action=/test/> self-closes a tag
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4598 .replace(raction, '="$1">')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4599 .replace(rleadingWhitespace, "")], ownerDocument)[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4600 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4601 return this.cloneNode(true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4602 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4603 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4604
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4605 // Copy the events from the original to the clone
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4606 if ( events === true ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4607 cloneCopyEvent( this, ret );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4608 cloneCopyEvent( this.find("*"), ret.find("*") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4609 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4610
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4611 // Return the cloned set
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4612 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4613 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4614
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4615 html: function( value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4616 if ( value === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4617 return this[0] && this[0].nodeType === 1 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4618 this[0].innerHTML.replace(rinlinejQuery, "") :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4619 null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4620
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4621 // See if we can take a shortcut and just use innerHTML
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4622 } else if ( typeof value === "string" && !rnocache.test( value ) &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4623 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4624 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4625
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4626 value = value.replace(rxhtmlTag, "<$1></$2>");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4627
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4628 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4629 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4630 // Remove element nodes and prevent memory leaks
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4631 if ( this[i].nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4632 jQuery.cleanData( this[i].getElementsByTagName("*") );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4633 this[i].innerHTML = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4634 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4635 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4636
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4637 // If using innerHTML throws an exception, use the fallback method
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4638 } catch(e) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4639 this.empty().append( value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4640 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4641
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4642 } else if ( jQuery.isFunction( value ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4643 this.each(function(i){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4644 var self = jQuery(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4645 self.html( value.call(this, i, self.html()) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4646 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4647
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4648 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4649 this.empty().append( value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4650 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4651
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4652 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4653 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4654
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4655 replaceWith: function( value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4656 if ( this[0] && this[0].parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4657 // Make sure that the elements are removed from the DOM before they are inserted
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4658 // this can help fix replacing a parent with child elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4659 if ( jQuery.isFunction( value ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4660 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4661 var self = jQuery(this), old = self.html();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4662 self.replaceWith( value.call( this, i, old ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4663 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4664 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4665
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4666 if ( typeof value !== "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4667 value = jQuery(value).detach();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4668 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4669
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4670 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4671 var next = this.nextSibling, parent = this.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4672
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4673 jQuery(this).remove();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4674
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4675 if ( next ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4676 jQuery(next).before( value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4677 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4678 jQuery(parent).append( value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4679 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4680 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4681 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4682 return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4683 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4684 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4685
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4686 detach: function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4687 return this.remove( selector, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4688 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4689
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4690 domManip: function( args, table, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4691 var results, first, value = args[0], scripts = [], fragment, parent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4692
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4693 // We can't cloneNode fragments that contain checked, in WebKit
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4694 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4695 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4696 jQuery(this).domManip( args, table, callback, true );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4697 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4698 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4699
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4700 if ( jQuery.isFunction(value) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4701 return this.each(function(i) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4702 var self = jQuery(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4703 args[0] = value.call(this, i, table ? self.html() : undefined);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4704 self.domManip( args, table, callback );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4705 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4706 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4707
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4708 if ( this[0] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4709 parent = value && value.parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4710
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4711 // If we're in a fragment, just use that instead of building a new one
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4712 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4713 results = { fragment: parent };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4714
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4715 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4716 results = jQuery.buildFragment( args, this, scripts );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4717 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4718
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4719 fragment = results.fragment;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4720
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4721 if ( fragment.childNodes.length === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4722 first = fragment = fragment.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4723 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4724 first = fragment.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4725 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4726
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4727 if ( first ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4728 table = table && jQuery.nodeName( first, "tr" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4729
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4730 for ( var i = 0, l = this.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4731 callback.call(
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4732 table ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4733 root(this[i], first) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4734 this[i],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4735 i > 0 || results.cacheable || this.length > 1 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4736 fragment.cloneNode(true) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4737 fragment
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4738 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4739 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4740 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4741
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4742 if ( scripts.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4743 jQuery.each( scripts, evalScript );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4744 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4745 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4746
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4747 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4748 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4749 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4750
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4751 function root( elem, cur ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4752 return jQuery.nodeName(elem, "table") ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4753 (elem.getElementsByTagName("tbody")[0] ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4754 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4755 elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4756 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4757
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4758 function cloneCopyEvent(orig, ret) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4759 var i = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4760
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4761 ret.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4762 if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4763 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4764 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4765
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4766 var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4767
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4768 if ( events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4769 delete curData.handle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4770 curData.events = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4771
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4772 for ( var type in events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4773 for ( var handler in events[ type ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4774 jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4775 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4776 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4777 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4778 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4779 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4780
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4781 jQuery.buildFragment = function( args, nodes, scripts ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4782 var fragment, cacheable, cacheresults,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4783 doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4784
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4785 // Only cache "small" (1/2 KB) strings that are associated with the main document
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4786 // Cloning options loses the selected state, so don't cache them
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4787 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4788 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4789 if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4790 !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4791
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4792 cacheable = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4793 cacheresults = jQuery.fragments[ args[0] ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4794 if ( cacheresults ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4795 if ( cacheresults !== 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4796 fragment = cacheresults;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4797 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4798 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4799 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4800
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4801 if ( !fragment ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4802 fragment = doc.createDocumentFragment();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4803 jQuery.clean( args, doc, fragment, scripts );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4804 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4805
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4806 if ( cacheable ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4807 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4808 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4809
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4810 return { fragment: fragment, cacheable: cacheable };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4811 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4812
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4813 jQuery.fragments = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4814
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4815 jQuery.each({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4816 appendTo: "append",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4817 prependTo: "prepend",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4818 insertBefore: "before",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4819 insertAfter: "after",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4820 replaceAll: "replaceWith"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4821 }, function( name, original ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4822 jQuery.fn[ name ] = function( selector ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4823 var ret = [], insert = jQuery( selector ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4824 parent = this.length === 1 && this[0].parentNode;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4825
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4826 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4827 insert[ original ]( this[0] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4828 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4829
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4830 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4831 for ( var i = 0, l = insert.length; i < l; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4832 var elems = (i > 0 ? this.clone(true) : this).get();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4833 jQuery( insert[i] )[ original ]( elems );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4834 ret = ret.concat( elems );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4835 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4836
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4837 return this.pushStack( ret, name, insert.selector );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4838 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4839 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4840 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4841
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4842 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4843 clean: function( elems, context, fragment, scripts ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4844 context = context || document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4845
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4846 // !context.createElement fails in IE with an error but returns typeof 'object'
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4847 if ( typeof context.createElement === "undefined" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4848 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4849 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4850
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4851 var ret = [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4852
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4853 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4854 if ( typeof elem === "number" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4855 elem += "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4856 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4857
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4858 if ( !elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4859 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4860 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4861
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4862 // Convert html string into DOM nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4863 if ( typeof elem === "string" && !rhtml.test( elem ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4864 elem = context.createTextNode( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4865
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4866 } else if ( typeof elem === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4867 // Fix "XHTML"-style tags in all browsers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4868 elem = elem.replace(rxhtmlTag, "<$1></$2>");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4869
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4870 // Trim whitespace, otherwise indexOf won't work as expected
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4871 var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4872 wrap = wrapMap[ tag ] || wrapMap._default,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4873 depth = wrap[0],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4874 div = context.createElement("div");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4875
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4876 // Go to html and back, then peel off extra wrappers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4877 div.innerHTML = wrap[1] + elem + wrap[2];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4878
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4879 // Move to the right depth
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4880 while ( depth-- ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4881 div = div.lastChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4882 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4883
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4884 // Remove IE's autoinserted <tbody> from table fragments
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4885 if ( !jQuery.support.tbody ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4886
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4887 // String was a <table>, *may* have spurious <tbody>
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4888 var hasBody = rtbody.test(elem),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4889 tbody = tag === "table" && !hasBody ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4890 div.firstChild && div.firstChild.childNodes :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4891
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4892 // String was a bare <thead> or <tfoot>
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4893 wrap[1] === "<table>" && !hasBody ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4894 div.childNodes :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4895 [];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4896
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4897 for ( var j = tbody.length - 1; j >= 0 ; --j ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4898 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4899 tbody[ j ].parentNode.removeChild( tbody[ j ] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4900 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4901 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4902
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4903 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4904
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4905 // IE completely kills leading whitespace when innerHTML is used
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4906 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4907 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4908 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4909
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4910 elem = div.childNodes;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4911 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4912
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4913 if ( elem.nodeType ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4914 ret.push( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4915 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4916 ret = jQuery.merge( ret, elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4917 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4918 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4919
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4920 if ( fragment ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4921 for ( i = 0; ret[i]; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4922 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4923 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4924
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4925 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4926 if ( ret[i].nodeType === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4927 ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4928 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4929 fragment.appendChild( ret[i] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4930 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4931 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4932 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4933
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4934 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4935 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4936
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4937 cleanData: function( elems ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4938 var data, id, cache = jQuery.cache,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4939 special = jQuery.event.special,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4940 deleteExpando = jQuery.support.deleteExpando;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4941
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4942 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4943 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4944 continue;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4945 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4946
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4947 id = elem[ jQuery.expando ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4948
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4949 if ( id ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4950 data = cache[ id ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4951
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4952 if ( data && data.events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4953 for ( var type in data.events ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4954 if ( special[ type ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4955 jQuery.event.remove( elem, type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4956
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4957 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4958 jQuery.removeEvent( elem, type, data.handle );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4959 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4960 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4961 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4962
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4963 if ( deleteExpando ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4964 delete elem[ jQuery.expando ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4965
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4966 } else if ( elem.removeAttribute ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4967 elem.removeAttribute( jQuery.expando );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4968 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4969
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4970 delete cache[ id ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4971 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4972 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4973 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4974 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4975
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4976 function evalScript( i, elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4977 if ( elem.src ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4978 jQuery.ajax({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4979 url: elem.src,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4980 async: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4981 dataType: "script"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4982 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4983 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4984 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4985 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4986
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4987 if ( elem.parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4988 elem.parentNode.removeChild( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4989 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4990 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4991
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4992
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4993
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4994
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4995 var ralpha = /alpha\([^)]*\)/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4996 ropacity = /opacity=([^)]*)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4997 rdashAlpha = /-([a-z])/ig,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4998 rupper = /([A-Z])/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4999 rnumpx = /^-?\d+(?:px)?$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5000 rnum = /^-?\d/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5001
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5002 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5003 cssWidth = [ "Left", "Right" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5004 cssHeight = [ "Top", "Bottom" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5005 curCSS,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5006
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5007 // cache check for defaultView.getComputedStyle
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5008 getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5009
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5010 fcamelCase = function( all, letter ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5011 return letter.toUpperCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5012 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5013
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5014 jQuery.fn.css = function( name, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5015 // Setting 'undefined' is a no-op
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5016 if ( arguments.length === 2 && value === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5017 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5018 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5019
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5020 return jQuery.access( this, name, value, true, function( elem, name, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5021 return value !== undefined ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5022 jQuery.style( elem, name, value ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5023 jQuery.css( elem, name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5024 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5025 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5026
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5027 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5028 // Add in style property hooks for overriding the default
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5029 // behavior of getting and setting a style property
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5030 cssHooks: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5031 opacity: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5032 get: function( elem, computed ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5033 if ( computed ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5034 // We should always get a number back from opacity
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5035 var ret = curCSS( elem, "opacity", "opacity" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5036 return ret === "" ? "1" : ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5037
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5038 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5039 return elem.style.opacity;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5040 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5041 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5042 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5043 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5044
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5045 // Exclude the following css properties to add px
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5046 cssNumber: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5047 "zIndex": true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5048 "fontWeight": true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5049 "opacity": true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5050 "zoom": true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5051 "lineHeight": true
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5052 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5053
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5054 // Add in properties whose names you wish to fix before
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5055 // setting or getting the value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5056 cssProps: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5057 // normalize float css property
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5058 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5059 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5060
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5061 // Get and set the style property on a DOM Node
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5062 style: function( elem, name, value, extra ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5063 // Don't set styles on text and comment nodes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5064 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5065 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5066 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5067
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5068 // Make sure that we're working with the right name
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5069 var ret, origName = jQuery.camelCase( name ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5070 style = elem.style, hooks = jQuery.cssHooks[ origName ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5071
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5072 name = jQuery.cssProps[ origName ] || origName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5073
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5074 // Check if we're setting a value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5075 if ( value !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5076 // Make sure that NaN and null values aren't set. See: #7116
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5077 if ( typeof value === "number" && isNaN( value ) || value == null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5078 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5079 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5080
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5081 // If a number was passed in, add 'px' to the (except for certain CSS properties)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5082 if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5083 value += "px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5084 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5085
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5086 // If a hook was provided, use that value, otherwise just set the specified value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5087 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5088 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5089 // Fixes bug #5509
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5090 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5091 style[ name ] = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5092 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5093 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5094
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5095 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5096 // If a hook was provided get the non-computed value from there
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5097 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5098 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5099 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5100
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5101 // Otherwise just get the value from the style object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5102 return style[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5103 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5104 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5105
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5106 css: function( elem, name, extra ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5107 // Make sure that we're working with the right name
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5108 var ret, origName = jQuery.camelCase( name ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5109 hooks = jQuery.cssHooks[ origName ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5110
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5111 name = jQuery.cssProps[ origName ] || origName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5112
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5113 // If a hook was provided get the computed value from there
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5114 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5115 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5116
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5117 // Otherwise, if a way to get the computed value exists, use that
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5118 } else if ( curCSS ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5119 return curCSS( elem, name, origName );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5120 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5121 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5122
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5123 // A method for quickly swapping in/out CSS properties to get correct calculations
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5124 swap: function( elem, options, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5125 var old = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5126
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5127 // Remember the old values, and insert the new ones
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5128 for ( var name in options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5129 old[ name ] = elem.style[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5130 elem.style[ name ] = options[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5131 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5132
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5133 callback.call( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5134
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5135 // Revert the old values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5136 for ( name in options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5137 elem.style[ name ] = old[ name ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5138 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5139 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5140
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5141 camelCase: function( string ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5142 return string.replace( rdashAlpha, fcamelCase );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5143 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5144 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5146 // DEPRECATED, Use jQuery.css() instead
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5147 jQuery.curCSS = jQuery.css;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5148
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5149 jQuery.each(["height", "width"], function( i, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5150 jQuery.cssHooks[ name ] = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5151 get: function( elem, computed, extra ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5152 var val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5153
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5154 if ( computed ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5155 if ( elem.offsetWidth !== 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5156 val = getWH( elem, name, extra );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5157
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5158 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5159 jQuery.swap( elem, cssShow, function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5160 val = getWH( elem, name, extra );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5161 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5162 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5163
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5164 return val + "px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5165 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5166 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5167
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5168 set: function( elem, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5169 if ( rnumpx.test( value ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5170 // ignore negative width and height values #1599
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5171 value = parseFloat(value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5172
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5173 if ( value >= 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5174 return value + "px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5175 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5176
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5177 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5178 return value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5179 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5180 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5181 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5182 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5183
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5184 if ( !jQuery.support.opacity ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5185 jQuery.cssHooks.opacity = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5186 get: function( elem, computed ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5187 // IE uses filters for opacity
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5188 return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5189 (parseFloat(RegExp.$1) / 100) + "" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5190 computed ? "1" : "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5191 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5192
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5193 set: function( elem, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5194 var style = elem.style;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5195
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5196 // IE has trouble with opacity if it does not have layout
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5197 // Force it by setting the zoom level
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5198 style.zoom = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5199
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5200 // Set the alpha filter to set the opacity
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5201 var opacity = jQuery.isNaN(value) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5202 "" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5203 "alpha(opacity=" + value * 100 + ")",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5204 filter = style.filter || "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5205
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5206 style.filter = ralpha.test(filter) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5207 filter.replace(ralpha, opacity) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5208 style.filter + ' ' + opacity;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5209 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5210 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5211 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5212
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5213 if ( getComputedStyle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5214 curCSS = function( elem, newName, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5215 var ret, defaultView, computedStyle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5216
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5217 name = name.replace( rupper, "-$1" ).toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5218
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5219 if ( !(defaultView = elem.ownerDocument.defaultView) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5220 return undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5221 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5222
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5223 if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5224 ret = computedStyle.getPropertyValue( name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5225 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5226 ret = jQuery.style( elem, name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5227 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5228 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5229
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5230 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5231 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5232
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5233 } else if ( document.documentElement.currentStyle ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5234 curCSS = function( elem, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5235 var left, rsLeft, ret = elem.currentStyle && elem.currentStyle[ name ], style = elem.style;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5236
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5237 // From the awesome hack by Dean Edwards
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5238 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5239
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5240 // If we're not dealing with a regular pixel number
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5241 // but a number that has a weird ending, we need to convert it to pixels
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5242 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5243 // Remember the original values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5244 left = style.left;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5245 rsLeft = elem.runtimeStyle.left;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5246
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5247 // Put in the new values to get a computed value out
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5248 elem.runtimeStyle.left = elem.currentStyle.left;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5249 style.left = name === "fontSize" ? "1em" : (ret || 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5250 ret = style.pixelLeft + "px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5251
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5252 // Revert the changed values
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5253 style.left = left;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5254 elem.runtimeStyle.left = rsLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5255 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5256
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5257 return ret;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5258 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5259 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5260
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5261 function getWH( elem, name, extra ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5262 var which = name === "width" ? cssWidth : cssHeight,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5263 val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5264
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5265 if ( extra === "border" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5266 return val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5267 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5268
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5269 jQuery.each( which, function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5270 if ( !extra ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5271 val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5272 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5273
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5274 if ( extra === "margin" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5275 val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5276
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5277 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5278 val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5279 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5280 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5281
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5282 return val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5283 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5284
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5285 if ( jQuery.expr && jQuery.expr.filters ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5286 jQuery.expr.filters.hidden = function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5287 var width = elem.offsetWidth, height = elem.offsetHeight;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5288
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5289 return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5290 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5291
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5292 jQuery.expr.filters.visible = function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5293 return !jQuery.expr.filters.hidden( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5294 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5295 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5296
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5297
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5298
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5299
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5300 var jsc = jQuery.now(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5301 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5302 rselectTextarea = /^(?:select|textarea)/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5303 rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5304 rnoContent = /^(?:GET|HEAD|DELETE)$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5305 rbracket = /\[\]$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5306 jsre = /\=\?(&|$)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5307 rquery = /\?/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5308 rts = /([?&])_=[^&]*/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5309 rurl = /^(\w+:)?\/\/([^\/?#]+)/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5310 r20 = /%20/g,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5311 rhash = /#.*$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5312
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5313 // Keep a copy of the old load method
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5314 _load = jQuery.fn.load;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5315
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5316 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5317 load: function( url, params, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5318 if ( typeof url !== "string" && _load ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5319 return _load.apply( this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5320
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5321 // Don't do a request if no elements are being requested
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5322 } else if ( !this.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5323 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5324 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5325
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5326 var off = url.indexOf(" ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5327 if ( off >= 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5328 var selector = url.slice(off, url.length);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5329 url = url.slice(0, off);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5330 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5331
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5332 // Default to a GET request
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5333 var type = "GET";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5334
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5335 // If the second parameter was provided
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5336 if ( params ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5337 // If it's a function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5338 if ( jQuery.isFunction( params ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5339 // We assume that it's the callback
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5340 callback = params;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5341 params = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5342
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5343 // Otherwise, build a param string
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5344 } else if ( typeof params === "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5345 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5346 type = "POST";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5347 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5348 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5349
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5350 var self = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5351
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5352 // Request the remote document
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5353 jQuery.ajax({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5354 url: url,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5355 type: type,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5356 dataType: "html",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5357 data: params,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5358 complete: function( res, status ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5359 // If successful, inject the HTML into all the matched elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5360 if ( status === "success" || status === "notmodified" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5361 // See if a selector was specified
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5362 self.html( selector ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5363 // Create a dummy div to hold the results
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5364 jQuery("<div>")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5365 // inject the contents of the document in, removing the scripts
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5366 // to avoid any 'Permission Denied' errors in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5367 .append(res.responseText.replace(rscript, ""))
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5368
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5369 // Locate the specified elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5370 .find(selector) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5371
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5372 // If not, just inject the full result
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5373 res.responseText );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5374 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5375
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5376 if ( callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5377 self.each( callback, [res.responseText, status, res] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5378 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5379 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5380 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5381
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5382 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5383 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5384
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5385 serialize: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5386 return jQuery.param(this.serializeArray());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5387 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5388
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5389 serializeArray: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5390 return this.map(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5391 return this.elements ? jQuery.makeArray(this.elements) : this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5392 })
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5393 .filter(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5394 return this.name && !this.disabled &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5395 (this.checked || rselectTextarea.test(this.nodeName) ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5396 rinput.test(this.type));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5397 })
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5398 .map(function( i, elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5399 var val = jQuery(this).val();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5400
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5401 return val == null ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5402 null :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5403 jQuery.isArray(val) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5404 jQuery.map( val, function( val, i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5405 return { name: elem.name, value: val };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5406 }) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5407 { name: elem.name, value: val };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5408 }).get();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5409 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5410 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5411
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5412 // Attach a bunch of functions for handling common AJAX events
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5413 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5414 jQuery.fn[o] = function( f ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5415 return this.bind(o, f);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5416 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5417 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5418
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5419 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5420 get: function( url, data, callback, type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5421 // shift arguments if data argument was omited
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5422 if ( jQuery.isFunction( data ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5423 type = type || callback;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5424 callback = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5425 data = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5426 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5427
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5428 return jQuery.ajax({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5429 type: "GET",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5430 url: url,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5431 data: data,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5432 success: callback,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5433 dataType: type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5434 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5435 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5436
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5437 getScript: function( url, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5438 return jQuery.get(url, null, callback, "script");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5439 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5440
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5441 getJSON: function( url, data, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5442 return jQuery.get(url, data, callback, "json");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5443 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5444
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5445 post: function( url, data, callback, type ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5446 // shift arguments if data argument was omited
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5447 if ( jQuery.isFunction( data ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5448 type = type || callback;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5449 callback = data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5450 data = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5451 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5452
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5453 return jQuery.ajax({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5454 type: "POST",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5455 url: url,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5456 data: data,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5457 success: callback,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5458 dataType: type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5459 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5460 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5461
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5462 ajaxSetup: function( settings ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5463 jQuery.extend( jQuery.ajaxSettings, settings );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5464 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5465
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5466 ajaxSettings: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5467 url: location.href,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5468 global: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5469 type: "GET",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5470 contentType: "application/x-www-form-urlencoded",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5471 processData: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5472 async: true,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5473 /*
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5474 timeout: 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5475 data: null,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5476 username: null,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5477 password: null,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5478 traditional: false,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5479 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5480 // This function can be overriden by calling jQuery.ajaxSetup
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5481 xhr: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5482 return new window.XMLHttpRequest();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5483 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5484 accepts: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5485 xml: "application/xml, text/xml",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5486 html: "text/html",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5487 script: "text/javascript, application/javascript",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5488 json: "application/json, text/javascript",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5489 text: "text/plain",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5490 _default: "*/*"
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5491 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5492 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5493
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5494 ajax: function( origSettings ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5495 var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5496 jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5497
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5498 s.url = s.url.replace( rhash, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5499
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5500 // Use original (not extended) context object if it was provided
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5501 s.context = origSettings && origSettings.context != null ? origSettings.context : s;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5502
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5503 // convert data if not already a string
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5504 if ( s.data && s.processData && typeof s.data !== "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5505 s.data = jQuery.param( s.data, s.traditional );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5506 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5507
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5508 // Handle JSONP Parameter Callbacks
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5509 if ( s.dataType === "jsonp" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5510 if ( type === "GET" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5511 if ( !jsre.test( s.url ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5512 s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5513 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5514 } else if ( !s.data || !jsre.test(s.data) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5515 s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5516 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5517 s.dataType = "json";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5518 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5519
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5520 // Build temporary JSONP function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5521 if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5522 jsonp = s.jsonpCallback || ("jsonp" + jsc++);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5523
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5524 // Replace the =? sequence both in the query string and the data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5525 if ( s.data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5526 s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5527 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5528
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5529 s.url = s.url.replace(jsre, "=" + jsonp + "$1");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5530
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5531 // We need to make sure
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5532 // that a JSONP style response is executed properly
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5533 s.dataType = "script";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5534
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5535 // Handle JSONP-style loading
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5536 var customJsonp = window[ jsonp ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5537
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5538 window[ jsonp ] = function( tmp ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5539 data = tmp;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5540 jQuery.handleSuccess( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5541 jQuery.handleComplete( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5542
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5543 if ( jQuery.isFunction( customJsonp ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5544 customJsonp( tmp );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5545
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5546 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5547 // Garbage collect
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5548 window[ jsonp ] = undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5549
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5550 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5551 delete window[ jsonp ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5552 } catch( jsonpError ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5553 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5554
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5555 if ( head ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5556 head.removeChild( script );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5557 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5558 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5559 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5560
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5561 if ( s.dataType === "script" && s.cache === null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5562 s.cache = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5563 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5564
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5565 if ( s.cache === false && type === "GET" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5566 var ts = jQuery.now();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5567
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5568 // try replacing _= if it is there
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5569 var ret = s.url.replace(rts, "$1_=" + ts);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5570
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5571 // if nothing was replaced, add timestamp to the end
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5572 s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5573 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5574
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5575 // If data is available, append data to url for get requests
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5576 if ( s.data && type === "GET" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5577 s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5578 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5579
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5580 // Watch for a new set of requests
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5581 if ( s.global && jQuery.active++ === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5582 jQuery.event.trigger( "ajaxStart" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5583 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5584
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5585 // Matches an absolute URL, and saves the domain
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5586 var parts = rurl.exec( s.url ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5587 remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5588
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5589 // If we're requesting a remote document
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5590 // and trying to load JSON or Script with a GET
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5591 if ( s.dataType === "script" && type === "GET" && remote ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5592 var head = document.getElementsByTagName("head")[0] || document.documentElement;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5593 var script = document.createElement("script");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5594 if ( s.scriptCharset ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5595 script.charset = s.scriptCharset;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5596 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5597 script.src = s.url;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5598
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5599 // Handle Script loading
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5600 if ( !jsonp ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5601 var done = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5602
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5603 // Attach handlers for all browsers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5604 script.onload = script.onreadystatechange = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5605 if ( !done && (!this.readyState ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5606 this.readyState === "loaded" || this.readyState === "complete") ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5607 done = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5608 jQuery.handleSuccess( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5609 jQuery.handleComplete( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5610
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5611 // Handle memory leak in IE
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5612 script.onload = script.onreadystatechange = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5613 if ( head && script.parentNode ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5614 head.removeChild( script );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5615 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5616 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5617 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5618 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5619
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5620 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5621 // This arises when a base node is used (#2709 and #4378).
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5622 head.insertBefore( script, head.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5623
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5624 // We handle everything using the script element injection
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5625 return undefined;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5626 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5627
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5628 var requestDone = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5629
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5630 // Create the request object
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5631 var xhr = s.xhr();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5632
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5633 if ( !xhr ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5634 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5635 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5636
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5637 // Open the socket
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5638 // Passing null username, generates a login popup on Opera (#2865)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5639 if ( s.username ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5640 xhr.open(type, s.url, s.async, s.username, s.password);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5641 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5642 xhr.open(type, s.url, s.async);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5643 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5644
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5645 // Need an extra try/catch for cross domain requests in Firefox 3
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5646 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5647 // Set content-type if data specified and content-body is valid for this type
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5648 if ( (s.data != null && !noContent) || (origSettings && origSettings.contentType) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5649 xhr.setRequestHeader("Content-Type", s.contentType);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5650 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5651
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5652 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5653 if ( s.ifModified ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5654 if ( jQuery.lastModified[s.url] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5655 xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5656 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5657
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5658 if ( jQuery.etag[s.url] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5659 xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5660 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5661 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5662
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5663 // Set header so the called script knows that it's an XMLHttpRequest
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5664 // Only send the header if it's not a remote XHR
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5665 if ( !remote ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5666 xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5667 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5668
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5669 // Set the Accepts header for the server, depending on the dataType
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5670 xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5671 s.accepts[ s.dataType ] + ", */*; q=0.01" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5672 s.accepts._default );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5673 } catch( headerError ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5674
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5675 // Allow custom headers/mimetypes and early abort
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5676 if ( s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5677 // Handle the global AJAX counter
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5678 if ( s.global && jQuery.active-- === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5679 jQuery.event.trigger( "ajaxStop" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5680 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5681
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5682 // close opended socket
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5683 xhr.abort();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5684 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5685 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5686
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5687 if ( s.global ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5688 jQuery.triggerGlobal( s, "ajaxSend", [xhr, s] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5689 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5690
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5691 // Wait for a response to come back
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5692 var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5693 // The request was aborted
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5694 if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5695 // Opera doesn't call onreadystatechange before this point
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5696 // so we simulate the call
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5697 if ( !requestDone ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5698 jQuery.handleComplete( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5699 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5700
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5701 requestDone = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5702 if ( xhr ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5703 xhr.onreadystatechange = jQuery.noop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5704 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5705
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5706 // The transfer is complete and the data is available, or the request timed out
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5707 } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5708 requestDone = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5709 xhr.onreadystatechange = jQuery.noop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5710
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5711 status = isTimeout === "timeout" ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5712 "timeout" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5713 !jQuery.httpSuccess( xhr ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5714 "error" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5715 s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5716 "notmodified" :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5717 "success";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5718
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5719 var errMsg;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5720
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5721 if ( status === "success" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5722 // Watch for, and catch, XML document parse errors
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5723 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5724 // process the data (runs the xml through httpData regardless of callback)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5725 data = jQuery.httpData( xhr, s.dataType, s );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5726 } catch( parserError ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5727 status = "parsererror";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5728 errMsg = parserError;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5729 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5730 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5731
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5732 // Make sure that the request was successful or notmodified
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5733 if ( status === "success" || status === "notmodified" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5734 // JSONP handles its own success callback
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5735 if ( !jsonp ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5736 jQuery.handleSuccess( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5737 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5738 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5739 jQuery.handleError( s, xhr, status, errMsg );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5740 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5741
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5742 // Fire the complete handlers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5743 if ( !jsonp ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5744 jQuery.handleComplete( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5745 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5746
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5747 if ( isTimeout === "timeout" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5748 xhr.abort();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5749 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5750
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5751 // Stop memory leaks
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5752 if ( s.async ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5753 xhr = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5754 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5755 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5756 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5757
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5758 // Override the abort handler, if we can (IE 6 doesn't allow it, but that's OK)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5759 // Opera doesn't fire onreadystatechange at all on abort
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5760 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5761 var oldAbort = xhr.abort;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5762 xhr.abort = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5763 // xhr.abort in IE7 is not a native JS function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5764 // and does not have a call property
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5765 if ( xhr && oldAbort.call ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5766 oldAbort.call( xhr );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5767 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5768
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5769 onreadystatechange( "abort" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5770 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5771 } catch( abortError ) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5772
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5773 // Timeout checker
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5774 if ( s.async && s.timeout > 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5775 setTimeout(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5776 // Check to see if the request is still happening
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5777 if ( xhr && !requestDone ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5778 onreadystatechange( "timeout" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5779 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5780 }, s.timeout);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5781 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5782
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5783 // Send the data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5784 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5785 xhr.send( noContent || s.data == null ? null : s.data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5786
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5787 } catch( sendError ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5788 jQuery.handleError( s, xhr, null, sendError );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5789
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5790 // Fire the complete handlers
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5791 jQuery.handleComplete( s, xhr, status, data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5792 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5793
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5794 // firefox 1.5 doesn't fire statechange for sync requests
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5795 if ( !s.async ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5796 onreadystatechange();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5797 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5798
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5799 // return XMLHttpRequest to allow aborting the request etc.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5800 return xhr;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5801 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5802
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5803 // Serialize an array of form elements or a set of
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5804 // key/values into a query string
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5805 param: function( a, traditional ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5806 var s = [], add = function( key, value ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5807 // If value is a function, invoke it and return its value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5808 value = jQuery.isFunction(value) ? value() : value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5809 s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5810 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5811
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5812 // Set traditional to true for jQuery <= 1.3.2 behavior.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5813 if ( traditional === undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5814 traditional = jQuery.ajaxSettings.traditional;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5815 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5816
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5817 // If an array was passed in, assume that it is an array of form elements.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5818 if ( jQuery.isArray(a) || a.jquery ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5819 // Serialize the form elements
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5820 jQuery.each( a, function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5821 add( this.name, this.value );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5822 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5823
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5824 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5825 // If traditional, encode the "old" way (the way 1.3.2 or older
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5826 // did it), otherwise encode params recursively.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5827 for ( var prefix in a ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5828 buildParams( prefix, a[prefix], traditional, add );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5829 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5830 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5831
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5832 // Return the resulting serialization
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5833 return s.join("&").replace(r20, "+");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5834 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5835 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5836
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5837 function buildParams( prefix, obj, traditional, add ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5838 if ( jQuery.isArray(obj) && obj.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5839 // Serialize array item.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5840 jQuery.each( obj, function( i, v ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5841 if ( traditional || rbracket.test( prefix ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5842 // Treat each array item as a scalar.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5843 add( prefix, v );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5844
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5845 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5846 // If array item is non-scalar (array or object), encode its
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5847 // numeric index to resolve deserialization ambiguity issues.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5848 // Note that rack (as of 1.0.0) can't currently deserialize
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5849 // nested arrays properly, and attempting to do so may cause
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5850 // a server error. Possible fixes are to modify rack's
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5851 // deserialization algorithm or to provide an option or flag
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5852 // to force array serialization to be shallow.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5853 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5854 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5855 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5856
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5857 } else if ( !traditional && obj != null && typeof obj === "object" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5858 if ( jQuery.isEmptyObject( obj ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5859 add( prefix, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5860
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5861 // Serialize object item.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5862 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5863 jQuery.each( obj, function( k, v ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5864 buildParams( prefix + "[" + k + "]", v, traditional, add );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5865 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5866 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5867
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5868 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5869 // Serialize scalar item.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5870 add( prefix, obj );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5871 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5872 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5873
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5874 // This is still on the jQuery object... for now
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5875 // Want to move this to jQuery.ajax some day
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5876 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5877
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5878 // Counter for holding the number of active queries
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5879 active: 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5880
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5881 // Last-Modified header cache for next request
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5882 lastModified: {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5883 etag: {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5884
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5885 handleError: function( s, xhr, status, e ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5886 // If a local callback was specified, fire it
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5887 if ( s.error ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5888 s.error.call( s.context, xhr, status, e );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5889 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5890
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5891 // Fire the global callback
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5892 if ( s.global ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5893 jQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5894 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5895 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5896
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5897 handleSuccess: function( s, xhr, status, data ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5898 // If a local callback was specified, fire it and pass it the data
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5899 if ( s.success ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5900 s.success.call( s.context, data, status, xhr );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5901 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5902
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5903 // Fire the global callback
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5904 if ( s.global ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5905 jQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5906 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5907 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5908
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5909 handleComplete: function( s, xhr, status ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5910 // Process result
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5911 if ( s.complete ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5912 s.complete.call( s.context, xhr, status );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5913 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5914
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5915 // The request was completed
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5916 if ( s.global ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5917 jQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5918 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5919
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5920 // Handle the global AJAX counter
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5921 if ( s.global && jQuery.active-- === 1 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5922 jQuery.event.trigger( "ajaxStop" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5923 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5924 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5925
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5926 triggerGlobal: function( s, type, args ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5927 (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5928 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5929
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5930 // Determines if an XMLHttpRequest was successful or not
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5931 httpSuccess: function( xhr ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5932 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5933 // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5934 return !xhr.status && location.protocol === "file:" ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5935 xhr.status >= 200 && xhr.status < 300 ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5936 xhr.status === 304 || xhr.status === 1223;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5937 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5938
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5939 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5940 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5941
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5942 // Determines if an XMLHttpRequest returns NotModified
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5943 httpNotModified: function( xhr, url ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5944 var lastModified = xhr.getResponseHeader("Last-Modified"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5945 etag = xhr.getResponseHeader("Etag");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5946
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5947 if ( lastModified ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5948 jQuery.lastModified[url] = lastModified;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5949 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5950
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5951 if ( etag ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5952 jQuery.etag[url] = etag;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5953 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5954
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5955 return xhr.status === 304;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5956 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5957
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5958 httpData: function( xhr, type, s ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5959 var ct = xhr.getResponseHeader("content-type") || "",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5960 xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5961 data = xml ? xhr.responseXML : xhr.responseText;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5962
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5963 if ( xml && data.documentElement.nodeName === "parsererror" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5964 jQuery.error( "parsererror" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5965 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5966
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5967 // Allow a pre-filtering function to sanitize the response
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5968 // s is checked to keep backwards compatibility
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5969 if ( s && s.dataFilter ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5970 data = s.dataFilter( data, type );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5971 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5972
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5973 // The filter can actually parse the response
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5974 if ( typeof data === "string" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5975 // Get the JavaScript object, if JSON is used.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5976 if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5977 data = jQuery.parseJSON( data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5978
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5979 // If the type is "script", eval it in global context
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5980 } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5981 jQuery.globalEval( data );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5982 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5983 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5984
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5985 return data;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5986 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5987
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5988 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5989
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5990 /*
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5991 * Create the request object; Microsoft failed to properly
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5992 * implement the XMLHttpRequest in IE7 (can't request local files),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5993 * so we use the ActiveXObject when it is available
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5994 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5995 * we need a fallback.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5996 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5997 if ( window.ActiveXObject ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5998 jQuery.ajaxSettings.xhr = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5999 if ( window.location.protocol !== "file:" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6000 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6001 return new window.XMLHttpRequest();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6002 } catch(xhrError) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6003 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6004
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6005 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6006 return new window.ActiveXObject("Microsoft.XMLHTTP");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6007 } catch(activeError) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6008 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6009 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6010
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6011 // Does this browser support XHR requests?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6012 jQuery.support.ajax = !!jQuery.ajaxSettings.xhr();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6013
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6014
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6015
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6016
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6017 var elemdisplay = {},
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6018 rfxtypes = /^(?:toggle|show|hide)$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6019 rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6020 timerId,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6021 fxAttrs = [
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6022 // height animations
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6023 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6024 // width animations
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6025 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6026 // opacity animations
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6027 [ "opacity" ]
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6028 ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6029
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6030 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6031 show: function( speed, easing, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6032 if ( speed || speed === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6033 return this.animate( genFx("show", 3), speed, easing, callback);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6034 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6035 for ( var i = 0, j = this.length; i < j; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6036 // Reset the inline display of this element to learn if it is
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6037 // being hidden by cascaded rules or not
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6038 if ( !jQuery.data(this[i], "olddisplay") && this[i].style.display === "none" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6039 this[i].style.display = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6040 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6041
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6042 // Set elements which have been overridden with display: none
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6043 // in a stylesheet to whatever the default browser style is
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6044 // for such an element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6045 if ( this[i].style.display === "" && jQuery.css( this[i], "display" ) === "none" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6046 jQuery.data(this[i], "olddisplay", defaultDisplay(this[i].nodeName));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6047 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6048 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6049
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6050 // Set the display of most of the elements in a second loop
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6051 // to avoid the constant reflow
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6052 for ( i = 0; i < j; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6053 this[i].style.display = jQuery.data(this[i], "olddisplay") || "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6054 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6055
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6056 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6057 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6058 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6059
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6060 hide: function( speed, easing, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6061 if ( speed || speed === 0 ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6062 return this.animate( genFx("hide", 3), speed, easing, callback);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6063
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6064 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6065 for ( var i = 0, j = this.length; i < j; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6066 var display = jQuery.css( this[i], "display" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6067
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6068 if ( display !== "none" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6069 jQuery.data( this[i], "olddisplay", display );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6070 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6071 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6072
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6073 // Set the display of the elements in a second loop
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6074 // to avoid the constant reflow
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6075 for ( i = 0; i < j; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6076 this[i].style.display = "none";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6077 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6078
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6079 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6080 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6081 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6082
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6083 // Save the old toggle function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6084 _toggle: jQuery.fn.toggle,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6085
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6086 toggle: function( fn, fn2, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6087 var bool = typeof fn === "boolean";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6088
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6089 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6090 this._toggle.apply( this, arguments );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6091
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6092 } else if ( fn == null || bool ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6093 this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6094 var state = bool ? fn : jQuery(this).is(":hidden");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6095 jQuery(this)[ state ? "show" : "hide" ]();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6096 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6097
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6098 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6099 this.animate(genFx("toggle", 3), fn, fn2, callback);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6100 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6101
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6102 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6103 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6104
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6105 fadeTo: function( speed, to, easing, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6106 return this.filter(":hidden").css("opacity", 0).show().end()
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6107 .animate({opacity: to}, speed, easing, callback);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6108 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6109
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6110 animate: function( prop, speed, easing, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6111 var optall = jQuery.speed(speed, easing, callback);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6112
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6113 if ( jQuery.isEmptyObject( prop ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6114 return this.each( optall.complete );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6115 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6116
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6117 return this[ optall.queue === false ? "each" : "queue" ](function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6118 // XXX ‘this’ does not always have a nodeName when running the
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6119 // test suite
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6120
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6121 var opt = jQuery.extend({}, optall), p,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6122 isElement = this.nodeType === 1,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6123 hidden = isElement && jQuery(this).is(":hidden"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6124 self = this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6125
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6126 for ( p in prop ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6127 var name = jQuery.camelCase( p );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6128
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6129 if ( p !== name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6130 prop[ name ] = prop[ p ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6131 delete prop[ p ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6132 p = name;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6133 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6134
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6135 if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6136 return opt.complete.call(this);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6137 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6138
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6139 if ( isElement && ( p === "height" || p === "width" ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6140 // Make sure that nothing sneaks out
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6141 // Record all 3 overflow attributes because IE does not
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6142 // change the overflow attribute when overflowX and
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6143 // overflowY are set to the same value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6144 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6146 // Set display property to inline-block for height/width
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6147 // animations on inline elements that are having width/height
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6148 // animated
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6149 if ( jQuery.css( this, "display" ) === "inline" &&
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6150 jQuery.css( this, "float" ) === "none" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6151 if ( !jQuery.support.inlineBlockNeedsLayout ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6152 this.style.display = "inline-block";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6153
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6154 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6155 var display = defaultDisplay(this.nodeName);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6156
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6157 // inline-level elements accept inline-block;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6158 // block-level elements need to be inline with layout
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6159 if ( display === "inline" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6160 this.style.display = "inline-block";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6161
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6162 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6163 this.style.display = "inline";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6164 this.style.zoom = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6165 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6166 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6167 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6168 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6169
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6170 if ( jQuery.isArray( prop[p] ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6171 // Create (if needed) and add to specialEasing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6172 (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6173 prop[p] = prop[p][0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6174 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6175 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6176
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6177 if ( opt.overflow != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6178 this.style.overflow = "hidden";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6179 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6180
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6181 opt.curAnim = jQuery.extend({}, prop);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6182
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6183 jQuery.each( prop, function( name, val ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6184 var e = new jQuery.fx( self, opt, name );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6185
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6186 if ( rfxtypes.test(val) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6187 e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6188
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6189 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6190 var parts = rfxnum.exec(val),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6191 start = e.cur(true) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6192
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6193 if ( parts ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6194 var end = parseFloat( parts[2] ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6195 unit = parts[3] || "px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6196
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6197 // We need to compute starting value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6198 if ( unit !== "px" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6199 jQuery.style( self, name, (end || 1) + unit);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6200 start = ((end || 1) / e.cur(true)) * start;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6201 jQuery.style( self, name, start + unit);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6202 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6203
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6204 // If a +=/-= token was provided, we're doing a relative animation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6205 if ( parts[1] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6206 end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6207 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6208
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6209 e.custom( start, end, unit );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6210
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6211 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6212 e.custom( start, val, "" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6213 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6214 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6215 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6216
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6217 // For JS strict compliance
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6218 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6219 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6220 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6221
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6222 stop: function( clearQueue, gotoEnd ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6223 var timers = jQuery.timers;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6224
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6225 if ( clearQueue ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6226 this.queue([]);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6227 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6228
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6229 this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6230 // go in reverse order so anything added to the queue during the loop is ignored
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6231 for ( var i = timers.length - 1; i >= 0; i-- ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6232 if ( timers[i].elem === this ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6233 if (gotoEnd) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6234 // force the next step to be the last
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6235 timers[i](true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6236 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6237
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6238 timers.splice(i, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6239 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6240 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6241 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6242
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6243 // start the next in the queue if the last step wasn't forced
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6244 if ( !gotoEnd ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6245 this.dequeue();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6246 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6247
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6248 return this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6249 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6250
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6251 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6252
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6253 function genFx( type, num ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6254 var obj = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6255
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6256 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6257 obj[ this ] = type;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6258 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6259
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6260 return obj;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6261 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6262
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6263 // Generate shortcuts for custom animations
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6264 jQuery.each({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6265 slideDown: genFx("show", 1),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6266 slideUp: genFx("hide", 1),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6267 slideToggle: genFx("toggle", 1),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6268 fadeIn: { opacity: "show" },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6269 fadeOut: { opacity: "hide" }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6270 }, function( name, props ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6271 jQuery.fn[ name ] = function( speed, easing, callback ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6272 return this.animate( props, speed, easing, callback );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6273 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6274 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6275
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6276 jQuery.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6277 speed: function( speed, easing, fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6278 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6279 complete: fn || !fn && easing ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6280 jQuery.isFunction( speed ) && speed,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6281 duration: speed,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6282 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6283 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6284
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6285 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6286 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6287
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6288 // Queueing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6289 opt.old = opt.complete;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6290 opt.complete = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6291 if ( opt.queue !== false ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6292 jQuery(this).dequeue();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6293 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6294 if ( jQuery.isFunction( opt.old ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6295 opt.old.call( this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6296 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6297 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6298
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6299 return opt;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6300 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6301
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6302 easing: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6303 linear: function( p, n, firstNum, diff ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6304 return firstNum + diff * p;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6305 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6306 swing: function( p, n, firstNum, diff ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6307 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6308 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6309 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6310
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6311 timers: [],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6312
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6313 fx: function( elem, options, prop ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6314 this.options = options;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6315 this.elem = elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6316 this.prop = prop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6317
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6318 if ( !options.orig ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6319 options.orig = {};
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6320 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6321 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6322
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6323 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6324
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6325 jQuery.fx.prototype = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6326 // Simple function for setting a style value
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6327 update: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6328 if ( this.options.step ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6329 this.options.step.call( this.elem, this.now, this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6330 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6331
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6332 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6333 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6334
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6335 // Get the current size
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6336 cur: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6337 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6338 return this.elem[ this.prop ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6339 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6340
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6341 var r = parseFloat( jQuery.css( this.elem, this.prop ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6342 return r && r > -10000 ? r : 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6343 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6344
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6345 // Start an animation from one number to another
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6346 custom: function( from, to, unit ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6347 this.startTime = jQuery.now();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6348 this.start = from;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6349 this.end = to;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6350 this.unit = unit || this.unit || "px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6351 this.now = this.start;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6352 this.pos = this.state = 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6353
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6354 var self = this, fx = jQuery.fx;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6355 function t( gotoEnd ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6356 return self.step(gotoEnd);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6357 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6358
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6359 t.elem = this.elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6360
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6361 if ( t() && jQuery.timers.push(t) && !timerId ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6362 timerId = setInterval(fx.tick, fx.interval);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6363 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6364 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6365
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6366 // Simple 'show' function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6367 show: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6368 // Remember where we started, so that we can go back to it later
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6369 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6370 this.options.show = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6371
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6372 // Begin the animation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6373 // Make sure that we start at a small width/height to avoid any
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6374 // flash of content
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6375 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6376
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6377 // Start by showing the element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6378 jQuery( this.elem ).show();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6379 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6380
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6381 // Simple 'hide' function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6382 hide: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6383 // Remember where we started, so that we can go back to it later
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6384 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6385 this.options.hide = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6386
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6387 // Begin the animation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6388 this.custom(this.cur(), 0);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6389 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6390
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6391 // Each step of an animation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6392 step: function( gotoEnd ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6393 var t = jQuery.now(), done = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6394
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6395 if ( gotoEnd || t >= this.options.duration + this.startTime ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6396 this.now = this.end;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6397 this.pos = this.state = 1;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6398 this.update();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6399
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6400 this.options.curAnim[ this.prop ] = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6401
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6402 for ( var i in this.options.curAnim ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6403 if ( this.options.curAnim[i] !== true ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6404 done = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6405 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6406 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6407
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6408 if ( done ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6409 // Reset the overflow
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6410 if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6411 var elem = this.elem, options = this.options;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6412 jQuery.each( [ "", "X", "Y" ], function (index, value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6413 elem.style[ "overflow" + value ] = options.overflow[index];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6414 } );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6415 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6416
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6417 // Hide the element if the "hide" operation was done
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6418 if ( this.options.hide ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6419 jQuery(this.elem).hide();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6420 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6421
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6422 // Reset the properties, if the item has been hidden or shown
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6423 if ( this.options.hide || this.options.show ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6424 for ( var p in this.options.curAnim ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6425 jQuery.style( this.elem, p, this.options.orig[p] );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6426 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6427 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6428
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6429 // Execute the complete function
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6430 this.options.complete.call( this.elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6431 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6432
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6433 return false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6434
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6435 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6436 var n = t - this.startTime;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6437 this.state = n / this.options.duration;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6438
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6439 // Perform the easing function, defaults to swing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6440 var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6441 var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6442 this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6443 this.now = this.start + ((this.end - this.start) * this.pos);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6444
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6445 // Perform the next step of the animation
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6446 this.update();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6447 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6448
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6449 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6450 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6451 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6452
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6453 jQuery.extend( jQuery.fx, {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6454 tick: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6455 var timers = jQuery.timers;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6456
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6457 for ( var i = 0; i < timers.length; i++ ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6458 if ( !timers[i]() ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6459 timers.splice(i--, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6460 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6461 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6462
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6463 if ( !timers.length ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6464 jQuery.fx.stop();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6465 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6466 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6467
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6468 interval: 13,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6469
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6470 stop: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6471 clearInterval( timerId );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6472 timerId = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6473 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6474
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6475 speeds: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6476 slow: 600,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6477 fast: 200,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6478 // Default speed
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6479 _default: 400
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6480 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6481
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6482 step: {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6483 opacity: function( fx ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6484 jQuery.style( fx.elem, "opacity", fx.now );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6485 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6486
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6487 _default: function( fx ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6488 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6489 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6490 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6491 fx.elem[ fx.prop ] = fx.now;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6492 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6493 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6494 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6495 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6496
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6497 if ( jQuery.expr && jQuery.expr.filters ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6498 jQuery.expr.filters.animated = function( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6499 return jQuery.grep(jQuery.timers, function( fn ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6500 return elem === fn.elem;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6501 }).length;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6502 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6503 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6504
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6505 function defaultDisplay( nodeName ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6506 if ( !elemdisplay[ nodeName ] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6507 var elem = jQuery("<" + nodeName + ">").appendTo("body"),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6508 display = elem.css("display");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6509
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6510 elem.remove();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6511
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6512 if ( display === "none" || display === "" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6513 display = "block";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6514 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6515
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6516 elemdisplay[ nodeName ] = display;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6517 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6518
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6519 return elemdisplay[ nodeName ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6520 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6521
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6522
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6523
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6524
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6525 var rtable = /^t(?:able|d|h)$/i,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6526 rroot = /^(?:body|html)$/i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6527
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6528 if ( "getBoundingClientRect" in document.documentElement ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6529 jQuery.fn.offset = function( options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6530 var elem = this[0], box;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6531
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6532 if ( options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6533 return this.each(function( i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6534 jQuery.offset.setOffset( this, options, i );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6535 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6536 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6537
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6538 if ( !elem || !elem.ownerDocument ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6539 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6540 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6541
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6542 if ( elem === elem.ownerDocument.body ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6543 return jQuery.offset.bodyOffset( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6544 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6545
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6546 try {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6547 box = elem.getBoundingClientRect();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6548 } catch(e) {}
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6549
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6550 var doc = elem.ownerDocument,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6551 docElem = doc.documentElement;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6552
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6553 // Make sure we're not dealing with a disconnected DOM node
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6554 if ( !box || !jQuery.contains( docElem, elem ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6555 return box || { top: 0, left: 0 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6556 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6557
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6558 var body = doc.body,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6559 win = getWindow(doc),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6560 clientTop = docElem.clientTop || body.clientTop || 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6561 clientLeft = docElem.clientLeft || body.clientLeft || 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6562 scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6563 scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6564 top = box.top + scrollTop - clientTop,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6565 left = box.left + scrollLeft - clientLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6566
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6567 return { top: top, left: left };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6568 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6569
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6570 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6571 jQuery.fn.offset = function( options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6572 var elem = this[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6573
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6574 if ( options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6575 return this.each(function( i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6576 jQuery.offset.setOffset( this, options, i );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6577 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6578 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6579
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6580 if ( !elem || !elem.ownerDocument ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6581 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6582 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6583
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6584 if ( elem === elem.ownerDocument.body ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6585 return jQuery.offset.bodyOffset( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6586 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6587
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6588 jQuery.offset.initialize();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6589
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6590 var offsetParent = elem.offsetParent, prevOffsetParent = elem,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6591 doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6592 body = doc.body, defaultView = doc.defaultView,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6593 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6594 top = elem.offsetTop, left = elem.offsetLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6595
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6596 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6597 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6598 break;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6599 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6600
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6601 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6602 top -= elem.scrollTop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6603 left -= elem.scrollLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6604
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6605 if ( elem === offsetParent ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6606 top += elem.offsetTop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6607 left += elem.offsetLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6608
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6609 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6610 top += parseFloat( computedStyle.borderTopWidth ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6611 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6612 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6613
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6614 prevOffsetParent = offsetParent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6615 offsetParent = elem.offsetParent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6616 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6617
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6618 if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6619 top += parseFloat( computedStyle.borderTopWidth ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6620 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6621 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6622
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6623 prevComputedStyle = computedStyle;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6624 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6625
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6626 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6627 top += body.offsetTop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6628 left += body.offsetLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6629 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6630
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6631 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6632 top += Math.max( docElem.scrollTop, body.scrollTop );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6633 left += Math.max( docElem.scrollLeft, body.scrollLeft );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6634 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6635
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6636 return { top: top, left: left };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6637 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6638 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6639
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6640 jQuery.offset = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6641 initialize: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6642 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6643 html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6644
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6645 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6646
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6647 container.innerHTML = html;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6648 body.insertBefore( container, body.firstChild );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6649 innerDiv = container.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6650 checkDiv = innerDiv.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6651 td = innerDiv.nextSibling.firstChild.firstChild;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6652
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6653 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6654 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6655
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6656 checkDiv.style.position = "fixed";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6657 checkDiv.style.top = "20px";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6658
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6659 // safari subtracts parent border width here which is 5px
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6660 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6661 checkDiv.style.position = checkDiv.style.top = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6662
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6663 innerDiv.style.overflow = "hidden";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6664 innerDiv.style.position = "relative";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6665
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6666 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6667
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6668 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6669
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6670 body.removeChild( container );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6671 body = container = innerDiv = checkDiv = table = td = null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6672 jQuery.offset.initialize = jQuery.noop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6673 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6674
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6675 bodyOffset: function( body ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6676 var top = body.offsetTop, left = body.offsetLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6677
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6678 jQuery.offset.initialize();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6679
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6680 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6681 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6682 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6683 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6684
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6685 return { top: top, left: left };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6686 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6687
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6688 setOffset: function( elem, options, i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6689 var position = jQuery.css( elem, "position" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6690
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6691 // set position first, in-case top/left are set even on static elem
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6692 if ( position === "static" ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6693 elem.style.position = "relative";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6694 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6695
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6696 var curElem = jQuery( elem ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6697 curOffset = curElem.offset(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6698 curCSSTop = jQuery.css( elem, "top" ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6699 curCSSLeft = jQuery.css( elem, "left" ),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6700 calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6701 props = {}, curPosition = {}, curTop, curLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6702
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6703 // need to be able to calculate position if either top or left is auto and position is absolute
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6704 if ( calculatePosition ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6705 curPosition = curElem.position();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6706 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6707
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6708 curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6709 curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6710
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6711 if ( jQuery.isFunction( options ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6712 options = options.call( elem, i, curOffset );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6713 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6714
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6715 if (options.top != null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6716 props.top = (options.top - curOffset.top) + curTop;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6717 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6718 if (options.left != null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6719 props.left = (options.left - curOffset.left) + curLeft;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6720 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6721
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6722 if ( "using" in options ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6723 options.using.call( elem, props );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6724 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6725 curElem.css( props );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6726 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6727 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6728 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6729
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6730
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6731 jQuery.fn.extend({
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6732 position: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6733 if ( !this[0] ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6734 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6735 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6736
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6737 var elem = this[0],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6738
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6739 // Get *real* offsetParent
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6740 offsetParent = this.offsetParent(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6741
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6742 // Get correct offsets
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6743 offset = this.offset(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6744 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6745
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6746 // Subtract element margins
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6747 // note: when an element has margin: auto the offsetLeft and marginLeft
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6748 // are the same in Safari causing offset.left to incorrectly be 0
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6749 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6750 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6751
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6752 // Add offsetParent borders
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6753 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6754 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6755
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6756 // Subtract the two offsets
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6757 return {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6758 top: offset.top - parentOffset.top,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6759 left: offset.left - parentOffset.left
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6760 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6761 },
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6762
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6763 offsetParent: function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6764 return this.map(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6765 var offsetParent = this.offsetParent || document.body;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6766 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6767 offsetParent = offsetParent.offsetParent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6768 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6769 return offsetParent;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6770 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6771 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6772 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6773
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6774
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6775 // Create scrollLeft and scrollTop methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6776 jQuery.each( ["Left", "Top"], function( i, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6777 var method = "scroll" + name;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6778
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6779 jQuery.fn[ method ] = function(val) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6780 var elem = this[0], win;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6781
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6782 if ( !elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6783 return null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6784 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6785
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6786 if ( val !== undefined ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6787 // Set the scroll offset
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6788 return this.each(function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6789 win = getWindow( this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6790
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6791 if ( win ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6792 win.scrollTo(
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6793 !i ? val : jQuery(win).scrollLeft(),
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6794 i ? val : jQuery(win).scrollTop()
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6795 );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6796
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6797 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6798 this[ method ] = val;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6799 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6800 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6801 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6802 win = getWindow( elem );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6803
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6804 // Return the scroll offset
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6805 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6806 jQuery.support.boxModel && win.document.documentElement[ method ] ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6807 win.document.body[ method ] :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6808 elem[ method ];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6809 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6810 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6811 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6812
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6813 function getWindow( elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6814 return jQuery.isWindow( elem ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6815 elem :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6816 elem.nodeType === 9 ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6817 elem.defaultView || elem.parentWindow :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6818 false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6819 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6820
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6821
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6822
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6823
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6824 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6825 jQuery.each([ "Height", "Width" ], function( i, name ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6826
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6827 var type = name.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6828
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6829 // innerHeight and innerWidth
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6830 jQuery.fn["inner" + name] = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6831 return this[0] ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6832 parseFloat( jQuery.css( this[0], type, "padding" ) ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6833 null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6834 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6835
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6836 // outerHeight and outerWidth
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6837 jQuery.fn["outer" + name] = function( margin ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6838 return this[0] ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6839 parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6840 null;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6841 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6842
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6843 jQuery.fn[ type ] = function( size ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6844 // Get window width or height
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6845 var elem = this[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6846 if ( !elem ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6847 return size == null ? null : this;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6848 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6849
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6850 if ( jQuery.isFunction( size ) ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6851 return this.each(function( i ) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6852 var self = jQuery( this );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6853 self[ type ]( size.call( this, i, self[ type ]() ) );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6854 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6855 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6856
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6857 return jQuery.isWindow( elem ) ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6858 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6859 elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6860 elem.document.body[ "client" + name ] :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6861
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6862 // Get document width or height
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6863 (elem.nodeType === 9) ? // is it a document
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6864 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6865 Math.max(
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6866 elem.documentElement["client" + name],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6867 elem.body["scroll" + name], elem.documentElement["scroll" + name],
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6868 elem.body["offset" + name], elem.documentElement["offset" + name]
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6869 ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6870
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6871 // Get or set width or height on the element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6872 size === undefined ?
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6873 // Get width or height on the element
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6874 parseFloat( jQuery.css( elem, type ) ) :
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6875
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6876 // Set the width or height on the element (default to pixels if value is unitless)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6877 this.css( type, typeof size === "string" ? size : size + "px" );
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6878 };
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6879
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6880 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6881
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6882
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6883 })(window);