annotate DataTables-1.9.4/docs/media/js/jquery.js @ 7:0f2b740536fb draft

Uploaded
author saskia-hiltemann
date Mon, 21 Aug 2017 09:16:07 -0400
parents ac5f9272033b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 /*!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 * jQuery JavaScript Library v1.5.1
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3 * http://jquery.com/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 * Copyright 2011, John Resig
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 * Dual licensed under the MIT or GPL Version 2 licenses.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 * http://jquery.org/license
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 * Includes Sizzle.js
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 * http://sizzlejs.com/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 * Copyright 2011, The Dojo Foundation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12 * Released under the MIT, BSD, and GPL Licenses.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 *
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 * Date: Wed Feb 23 13:55:29 2011 -0500
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 (function( window, undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18 // Use the correct document accordingly with window argument (sandbox)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 var document = window.document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 var jQuery = (function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 // Define a local copy of jQuery
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 var jQuery = function( selector, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24 // The jQuery object is actually just the init constructor 'enhanced'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 return new jQuery.fn.init( selector, context, rootjQuery );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 // Map over jQuery in case of overwrite
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 _jQuery = window.jQuery,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31 // Map over the $ in case of overwrite
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 _$ = window.$,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 // A central reference to the root jQuery(document)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 rootjQuery,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37 // A simple way to check for HTML strings or ID strings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 // (both of which we optimize for)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 // Check if a string has a non-whitespace character in it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 rnotwhite = /\S/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 // Used for trimming whitespace
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 trimLeft = /^\s+/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 trimRight = /\s+$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 // Check for digits
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49 rdigit = /\d/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 // Match a standalone tag
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 // JSON RegExp
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55 rvalidchars = /^[\],:{}\s]*$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 // Useragent RegExp
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 rwebkit = /(webkit)[ \/]([\w.]+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 rmsie = /(msie) ([\w.]+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 // Keep a UserAgent string for use with jQuery.browser
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 userAgent = navigator.userAgent,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 // For matching the engine and version of the browser
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 browserMatch,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72 // Has the ready events already been bound?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 readyBound = false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 // The deferred used on DOM ready
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 readyList,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 // Promise methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79 promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 // The ready event handler
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 DOMContentLoaded,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 // Save a reference to some core methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85 toString = Object.prototype.toString,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 hasOwn = Object.prototype.hasOwnProperty,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 push = Array.prototype.push,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 slice = Array.prototype.slice,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 trim = String.prototype.trim,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 indexOf = Array.prototype.indexOf,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 // [[Class]] -> type pairs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 class2type = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 jQuery.fn = jQuery.prototype = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 constructor: jQuery,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 init: function( selector, context, rootjQuery ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98 var match, elem, ret, doc;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 // Handle $(""), $(null), or $(undefined)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 if ( !selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 // Handle $(DOMElement)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 if ( selector.nodeType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 this.context = this[0] = selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 this.length = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 // The body element only exists once, optimize finding it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113 if ( selector === "body" && !context && document.body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 this.context = document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 this[0] = document.body;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116 this.selector = "body";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117 this.length = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121 // Handle HTML strings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 if ( typeof selector === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123 // Are we dealing with HTML string or an ID?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 match = quickExpr.exec( selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 // Verify a match, and that no context was specified for #id
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127 if ( match && (match[1] || !context) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 // HANDLE: $(html) -> $(array)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 if ( match[1] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131 context = context instanceof jQuery ? context[0] : context;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132 doc = (context ? context.ownerDocument || context : document);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134 // If a single string is passed in and it's a single tag
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 // just do a createElement and skip the rest
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 ret = rsingleTag.exec( selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
137
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
138 if ( ret ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
139 if ( jQuery.isPlainObject( context ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
140 selector = [ document.createElement( ret[1] ) ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
141 jQuery.fn.attr.call( selector, context, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
142
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
143 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
144 selector = [ doc.createElement( ret[1] ) ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
145 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
147 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
148 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
149 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
150 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
151
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
152 return jQuery.merge( this, selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
153
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
154 // HANDLE: $("#id")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
155 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
156 elem = document.getElementById( match[2] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
157
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
158 // Check parentNode to catch when Blackberry 4.6 returns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
159 // nodes that are no longer in the document #6963
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
160 if ( elem && elem.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
161 // Handle the case where IE and Opera return items
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
162 // by name instead of ID
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
163 if ( elem.id !== match[2] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
164 return rootjQuery.find( selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
165 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
166
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
167 // Otherwise, we inject the element directly into the jQuery object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
168 this.length = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
169 this[0] = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
170 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
172 this.context = document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
173 this.selector = selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
174 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
175 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
176
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
177 // HANDLE: $(expr, $(...))
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
178 } else if ( !context || context.jquery ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
179 return (context || rootjQuery).find( selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
180
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
181 // HANDLE: $(expr, context)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
182 // (which is just equivalent to: $(context).find(expr)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
183 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
184 return this.constructor( context ).find( selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
185 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
186
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
187 // HANDLE: $(function)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
188 // Shortcut for document ready
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
189 } else if ( jQuery.isFunction( selector ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
190 return rootjQuery.ready( selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
191 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
192
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
193 if (selector.selector !== undefined) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
194 this.selector = selector.selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
195 this.context = selector.context;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
196 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
197
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
198 return jQuery.makeArray( selector, this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
199 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
200
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
201 // Start with an empty selector
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
202 selector: "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
203
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
204 // The current version of jQuery being used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
205 jquery: "1.5.1",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
206
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
207 // The default length of a jQuery object is 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
208 length: 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
209
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
210 // The number of elements contained in the matched element set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
211 size: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
212 return this.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
213 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
214
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
215 toArray: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
216 return slice.call( this, 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
217 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
218
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
219 // Get the Nth element in the matched element set OR
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
220 // Get the whole matched element set as a clean array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
221 get: function( num ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
222 return num == null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
223
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
224 // Return a 'clean' array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
225 this.toArray() :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
226
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
227 // Return just the object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
228 ( num < 0 ? this[ this.length + num ] : this[ num ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
229 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
230
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
231 // Take an array of elements and push it onto the stack
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
232 // (returning the new matched element set)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
233 pushStack: function( elems, name, selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
234 // Build a new jQuery matched element set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
235 var ret = this.constructor();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
236
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
237 if ( jQuery.isArray( elems ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
238 push.apply( ret, elems );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
239
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
240 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
241 jQuery.merge( ret, elems );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
242 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
243
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
244 // Add the old object onto the stack (as a reference)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
245 ret.prevObject = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
246
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
247 ret.context = this.context;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
248
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
249 if ( name === "find" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
250 ret.selector = this.selector + (this.selector ? " " : "") + selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
251 } else if ( name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
252 ret.selector = this.selector + "." + name + "(" + selector + ")";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
253 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
254
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
255 // Return the newly-formed element set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
256 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
257 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
258
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
259 // Execute a callback for every element in the matched set.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
260 // (You can seed the arguments with an array of args, but this is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
261 // only used internally.)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
262 each: function( callback, args ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
263 return jQuery.each( this, callback, args );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
264 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
265
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
266 ready: function( fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
267 // Attach the listeners
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
268 jQuery.bindReady();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
269
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
270 // Add the callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
271 readyList.done( fn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
272
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
273 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
274 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
276 eq: function( i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
277 return i === -1 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
278 this.slice( i ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
279 this.slice( i, +i + 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
280 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
281
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
282 first: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
283 return this.eq( 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
284 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
285
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
286 last: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
287 return this.eq( -1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
288 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
289
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
290 slice: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
291 return this.pushStack( slice.apply( this, arguments ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
292 "slice", slice.call(arguments).join(",") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
293 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
294
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
295 map: function( callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
296 return this.pushStack( jQuery.map(this, function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
297 return callback.call( elem, i, elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
298 }));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
299 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
300
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
301 end: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
302 return this.prevObject || this.constructor(null);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
303 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
304
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
305 // For internal use only.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
306 // Behaves like an Array's method, not like a jQuery method.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
307 push: push,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
308 sort: [].sort,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
309 splice: [].splice
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
310 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
311
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
312 // Give the init function the jQuery prototype for later instantiation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
313 jQuery.fn.init.prototype = jQuery.fn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
314
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
315 jQuery.extend = jQuery.fn.extend = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
316 var options, name, src, copy, copyIsArray, clone,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
317 target = arguments[0] || {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
318 i = 1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
319 length = arguments.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
320 deep = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
321
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
322 // Handle a deep copy situation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
323 if ( typeof target === "boolean" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
324 deep = target;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
325 target = arguments[1] || {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
326 // skip the boolean and the target
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
327 i = 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
328 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
329
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
330 // Handle case when target is a string or something (possible in deep copy)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
331 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
332 target = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
333 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
334
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
335 // extend jQuery itself if only one argument is passed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
336 if ( length === i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
337 target = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
338 --i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
339 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
340
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
341 for ( ; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
342 // Only deal with non-null/undefined values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
343 if ( (options = arguments[ i ]) != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
344 // Extend the base object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
345 for ( name in options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
346 src = target[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
347 copy = options[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
348
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
349 // Prevent never-ending loop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
350 if ( target === copy ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
351 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
352 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
353
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
354 // Recurse if we're merging plain objects or arrays
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
355 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
356 if ( copyIsArray ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
357 copyIsArray = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
358 clone = src && jQuery.isArray(src) ? src : [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
360 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
361 clone = src && jQuery.isPlainObject(src) ? src : {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
362 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
363
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
364 // Never move original objects, clone them
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
365 target[ name ] = jQuery.extend( deep, clone, copy );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
366
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
367 // Don't bring in undefined values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
368 } else if ( copy !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
369 target[ name ] = copy;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
370 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
371 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
373 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
374
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
375 // Return the modified object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
376 return target;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
377 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
378
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
379 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
380 noConflict: function( deep ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
381 window.$ = _$;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
382
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
383 if ( deep ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
384 window.jQuery = _jQuery;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
385 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
386
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
387 return jQuery;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
388 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
389
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
390 // Is the DOM ready to be used? Set to true once it occurs.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
391 isReady: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
392
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
393 // A counter to track how many items to wait for before
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
394 // the ready event fires. See #6781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
395 readyWait: 1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
396
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
397 // Handle when the DOM is ready
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
398 ready: function( wait ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
399 // A third-party is pushing the ready event forwards
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
400 if ( wait === true ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
401 jQuery.readyWait--;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
402 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
404 // Make sure that the DOM is not already loaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
405 if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
406 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
407 if ( !document.body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
408 return setTimeout( jQuery.ready, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
409 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
410
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
411 // Remember that the DOM is ready
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
412 jQuery.isReady = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
413
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
414 // If a normal DOM Ready event fired, decrement, and wait if need be
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
415 if ( wait !== true && --jQuery.readyWait > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
416 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
417 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
418
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
419 // If there are functions bound, to execute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
420 readyList.resolveWith( document, [ jQuery ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
421
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
422 // Trigger any bound ready events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
423 if ( jQuery.fn.trigger ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
424 jQuery( document ).trigger( "ready" ).unbind( "ready" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
425 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
426 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
427 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
428
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
429 bindReady: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
430 if ( readyBound ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
431 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
432 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
433
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
434 readyBound = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
435
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
436 // Catch cases where $(document).ready() is called after the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
437 // browser event has already occurred.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
438 if ( document.readyState === "complete" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
439 // Handle it asynchronously to allow scripts the opportunity to delay ready
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
440 return setTimeout( jQuery.ready, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
441 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
442
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
443 // Mozilla, Opera and webkit nightlies currently support this event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
444 if ( document.addEventListener ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
445 // Use the handy event callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
446 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
447
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
448 // A fallback to window.onload, that will always work
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
449 window.addEventListener( "load", jQuery.ready, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
450
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
451 // If IE event model is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
452 } else if ( document.attachEvent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
453 // ensure firing before onload,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
454 // maybe late but safe also for iframes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
455 document.attachEvent("onreadystatechange", DOMContentLoaded);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
457 // A fallback to window.onload, that will always work
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
458 window.attachEvent( "onload", jQuery.ready );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
459
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
460 // If IE and not a frame
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
461 // continually check to see if the document is ready
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
462 var toplevel = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
463
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
464 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
465 toplevel = window.frameElement == null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
466 } catch(e) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
467
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
468 if ( document.documentElement.doScroll && toplevel ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
469 doScrollCheck();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
470 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
471 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
472 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
473
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
474 // See test/unit/core.js for details concerning isFunction.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
475 // Since version 1.3, DOM methods and functions like alert
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
476 // aren't supported. They return false on IE (#2968).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
477 isFunction: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
478 return jQuery.type(obj) === "function";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
479 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
480
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
481 isArray: Array.isArray || function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
482 return jQuery.type(obj) === "array";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
483 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
484
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
485 // A crude way of determining if an object is a window
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
486 isWindow: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
487 return obj && typeof obj === "object" && "setInterval" in obj;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
488 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
489
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
490 isNaN: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
491 return obj == null || !rdigit.test( obj ) || isNaN( obj );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
492 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
493
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
494 type: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
495 return obj == null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
496 String( obj ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
497 class2type[ toString.call(obj) ] || "object";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
498 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
499
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
500 isPlainObject: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
501 // Must be an Object.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
502 // Because of IE, we also have to check the presence of the constructor property.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
503 // Make sure that DOM nodes and window objects don't pass through, as well
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
504 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
505 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
506 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
507
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
508 // Not own constructor property must be Object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
509 if ( obj.constructor &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
510 !hasOwn.call(obj, "constructor") &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
511 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
512 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
513 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
514
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
515 // Own properties are enumerated firstly, so to speed up,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
516 // if last one is own, then all properties are own.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
518 var key;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
519 for ( key in obj ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
520
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
521 return key === undefined || hasOwn.call( obj, key );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
522 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
523
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
524 isEmptyObject: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
525 for ( var name in obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
526 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
527 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
528 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
529 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
530
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
531 error: function( msg ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
532 throw msg;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
533 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
534
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
535 parseJSON: function( data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
536 if ( typeof data !== "string" || !data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
537 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
538 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
540 // Make sure leading/trailing whitespace is removed (IE can't handle it)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
541 data = jQuery.trim( data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
542
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
543 // Make sure the incoming data is actual JSON
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
544 // Logic borrowed from http://json.org/json2.js
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
545 if ( rvalidchars.test(data.replace(rvalidescape, "@")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
546 .replace(rvalidtokens, "]")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
547 .replace(rvalidbraces, "")) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
548
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
549 // Try to use the native JSON parser first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
550 return window.JSON && window.JSON.parse ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
551 window.JSON.parse( data ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
552 (new Function("return " + data))();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
554 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
555 jQuery.error( "Invalid JSON: " + data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
556 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
557 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
558
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
559 // Cross-browser xml parsing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
560 // (xml & tmp used internally)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
561 parseXML: function( data , xml , tmp ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
562
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
563 if ( window.DOMParser ) { // Standard
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
564 tmp = new DOMParser();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
565 xml = tmp.parseFromString( data , "text/xml" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
566 } else { // IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
567 xml = new ActiveXObject( "Microsoft.XMLDOM" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
568 xml.async = "false";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
569 xml.loadXML( data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
570 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
571
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
572 tmp = xml.documentElement;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
573
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
574 if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
575 jQuery.error( "Invalid XML: " + data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
576 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
577
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
578 return xml;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
579 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
580
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
581 noop: function() {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
582
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
583 // Evalulates a script in a global context
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
584 globalEval: function( data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
585 if ( data && rnotwhite.test(data) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
586 // Inspired by code by Andrea Giammarchi
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
587 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
588 var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
589 script = document.createElement( "script" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
590
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
591 if ( jQuery.support.scriptEval() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
592 script.appendChild( document.createTextNode( data ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
593 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
594 script.text = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
595 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
596
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
597 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
598 // This arises when a base node is used (#2709).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
599 head.insertBefore( script, head.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
600 head.removeChild( script );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
601 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
602 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
603
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
604 nodeName: function( elem, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
605 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
606 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
607
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
608 // args is for internal usage only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
609 each: function( object, callback, args ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
610 var name, i = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
611 length = object.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
612 isObj = length === undefined || jQuery.isFunction(object);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
613
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
614 if ( args ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
615 if ( isObj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
616 for ( name in object ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
617 if ( callback.apply( object[ name ], args ) === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
618 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
619 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
620 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
621 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
622 for ( ; i < length; ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
623 if ( callback.apply( object[ i++ ], args ) === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
624 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
625 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
626 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
627 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
628
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
629 // A special, fast, case for the most common use of each
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
630 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
631 if ( isObj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
632 for ( name in object ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
633 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
634 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
635 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
636 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
637 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
638 for ( var value = object[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
639 i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
640 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
641 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
642
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
643 return object;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
644 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
645
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
646 // Use native String.trim function wherever possible
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
647 trim: trim ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
648 function( text ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
649 return text == null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
650 "" :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
651 trim.call( text );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
652 } :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
653
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
654 // Otherwise use our own trimming functionality
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
655 function( text ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
656 return text == null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
657 "" :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
658 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
659 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
660
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
661 // results is for internal usage only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
662 makeArray: function( array, results ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
663 var ret = results || [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
664
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
665 if ( array != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
666 // The window, strings (and functions) also have 'length'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
667 // The extra typeof function check is to prevent crashes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
668 // in Safari 2 (See: #3039)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
669 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
670 var type = jQuery.type(array);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
671
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
672 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
673 push.call( ret, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
674 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
675 jQuery.merge( ret, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
676 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
677 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
678
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
679 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
680 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
681
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
682 inArray: function( elem, array ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
683 if ( array.indexOf ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
684 return array.indexOf( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
685 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
686
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
687 for ( var i = 0, length = array.length; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
688 if ( array[ i ] === elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
689 return i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
690 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
691 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
692
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
693 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
694 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
695
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
696 merge: function( first, second ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
697 var i = first.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
698 j = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
699
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
700 if ( typeof second.length === "number" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
701 for ( var l = second.length; j < l; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
702 first[ i++ ] = second[ j ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
703 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
704
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
705 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
706 while ( second[j] !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
707 first[ i++ ] = second[ j++ ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
708 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
709 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
710
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
711 first.length = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
712
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
713 return first;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
714 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
715
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
716 grep: function( elems, callback, inv ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
717 var ret = [], retVal;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
718 inv = !!inv;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
719
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
720 // Go through the array, only saving the items
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
721 // that pass the validator function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
722 for ( var i = 0, length = elems.length; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
723 retVal = !!callback( elems[ i ], i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
724 if ( inv !== retVal ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
725 ret.push( elems[ i ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
726 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
727 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
728
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
729 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
730 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
731
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
732 // arg is for internal usage only
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
733 map: function( elems, callback, arg ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
734 var ret = [], value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
735
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
736 // Go through the array, translating each of the items to their
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
737 // new value (or values).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
738 for ( var i = 0, length = elems.length; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
739 value = callback( elems[ i ], i, arg );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
740
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
741 if ( value != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
742 ret[ ret.length ] = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
743 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
744 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
745
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
746 // Flatten any nested arrays
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
747 return ret.concat.apply( [], ret );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
748 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
749
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
750 // A global GUID counter for objects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
751 guid: 1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
752
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
753 proxy: function( fn, proxy, thisObject ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
754 if ( arguments.length === 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
755 if ( typeof proxy === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
756 thisObject = fn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
757 fn = thisObject[ proxy ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
758 proxy = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
759
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
760 } else if ( proxy && !jQuery.isFunction( proxy ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
761 thisObject = proxy;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
762 proxy = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
763 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
764 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
766 if ( !proxy && fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
767 proxy = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
768 return fn.apply( thisObject || this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
769 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
770 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
771
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
772 // Set the guid of unique handler to the same of original handler, so it can be removed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
773 if ( fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
774 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
775 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
776
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
777 // So proxy can be declared as an argument
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
778 return proxy;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
779 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
780
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
781 // Mutifunctional method to get and set values to a collection
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
782 // The value/s can be optionally by executed if its a function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
783 access: function( elems, key, value, exec, fn, pass ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
784 var length = elems.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
785
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
786 // Setting many attributes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
787 if ( typeof key === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
788 for ( var k in key ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
789 jQuery.access( elems, k, key[k], exec, fn, value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
790 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
791 return elems;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
792 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
793
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
794 // Setting one attribute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
795 if ( value !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
796 // Optionally, function values get executed if exec is true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
797 exec = !pass && exec && jQuery.isFunction(value);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
798
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
799 for ( var i = 0; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
800 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
801 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
802
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
803 return elems;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
804 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
805
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
806 // Getting an attribute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
807 return length ? fn( elems[0], key ) : undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
808 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
809
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
810 now: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
811 return (new Date()).getTime();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
812 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
813
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
814 // Create a simple deferred (one callbacks list)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
815 _Deferred: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
816 var // callbacks list
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
817 callbacks = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
818 // stored [ context , args ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
819 fired,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
820 // to avoid firing when already doing so
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
821 firing,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
822 // flag to know if the deferred has been cancelled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
823 cancelled,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
824 // the deferred itself
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
825 deferred = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
826
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
827 // done( f1, f2, ...)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
828 done: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
829 if ( !cancelled ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
830 var args = arguments,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
831 i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
832 length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
833 elem,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
834 type,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
835 _fired;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
836 if ( fired ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
837 _fired = fired;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
838 fired = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
839 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
840 for ( i = 0, length = args.length; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
841 elem = args[ i ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
842 type = jQuery.type( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
843 if ( type === "array" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
844 deferred.done.apply( deferred, elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
845 } else if ( type === "function" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
846 callbacks.push( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
847 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
848 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
849 if ( _fired ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
850 deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
851 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
852 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
853 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
854 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
855
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
856 // resolve with given context and args
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
857 resolveWith: function( context, args ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
858 if ( !cancelled && !fired && !firing ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
859 firing = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
860 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
861 while( callbacks[ 0 ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
862 callbacks.shift().apply( context, args );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
863 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
864 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
865 // We have to add a catch block for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
866 // IE prior to 8 or else the finally
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
867 // block will never get executed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
868 catch (e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
869 throw e;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
870 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
871 finally {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
872 fired = [ context, args ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
873 firing = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
874 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
875 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
876 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
877 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
878
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
879 // resolve with this as context and given arguments
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
880 resolve: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
881 deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
882 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
883 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
884
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
885 // Has this deferred been resolved?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
886 isResolved: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
887 return !!( firing || fired );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
888 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
889
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
890 // Cancel
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
891 cancel: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
892 cancelled = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
893 callbacks = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
894 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
895 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
896 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
897
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
898 return deferred;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
899 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
900
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
901 // Full fledged deferred (two callbacks list)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
902 Deferred: function( func ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
903 var deferred = jQuery._Deferred(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
904 failDeferred = jQuery._Deferred(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
905 promise;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
906 // Add errorDeferred methods, then and promise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
907 jQuery.extend( deferred, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
908 then: function( doneCallbacks, failCallbacks ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
909 deferred.done( doneCallbacks ).fail( failCallbacks );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
910 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
911 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
912 fail: failDeferred.done,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
913 rejectWith: failDeferred.resolveWith,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
914 reject: failDeferred.resolve,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
915 isRejected: failDeferred.isResolved,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
916 // Get a promise for this deferred
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
917 // If obj is provided, the promise aspect is added to the object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
918 promise: function( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
919 if ( obj == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
920 if ( promise ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
921 return promise;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
922 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
923 promise = obj = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
924 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
925 var i = promiseMethods.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
926 while( i-- ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
927 obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
928 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
929 return obj;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
930 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
931 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
932 // Make sure only one callback list will be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
933 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
934 // Unexpose cancel
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
935 delete deferred.cancel;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
936 // Call given func if any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
937 if ( func ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
938 func.call( deferred, deferred );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
939 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
940 return deferred;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
941 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
942
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
943 // Deferred helper
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
944 when: function( object ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
945 var lastIndex = arguments.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
946 deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
947 object :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
948 jQuery.Deferred(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
949 promise = deferred.promise();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
950
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
951 if ( lastIndex > 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
952 var array = slice.call( arguments, 0 ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
953 count = lastIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
954 iCallback = function( index ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
955 return function( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
956 array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
957 if ( !( --count ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
958 deferred.resolveWith( promise, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
959 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
960 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
961 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
962 while( ( lastIndex-- ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
963 object = array[ lastIndex ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
964 if ( object && jQuery.isFunction( object.promise ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
965 object.promise().then( iCallback(lastIndex), deferred.reject );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
966 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
967 --count;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
968 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
969 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
970 if ( !count ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
971 deferred.resolveWith( promise, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
972 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
973 } else if ( deferred !== object ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
974 deferred.resolve( object );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
975 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
976 return promise;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
977 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
978
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
979 // Use of jQuery.browser is frowned upon.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
980 // More details: http://docs.jquery.com/Utilities/jQuery.browser
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
981 uaMatch: function( ua ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
982 ua = ua.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
983
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
984 var match = rwebkit.exec( ua ) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
985 ropera.exec( ua ) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
986 rmsie.exec( ua ) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
987 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
988 [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
989
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
990 return { browser: match[1] || "", version: match[2] || "0" };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
991 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
992
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
993 sub: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
994 function jQuerySubclass( selector, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
995 return new jQuerySubclass.fn.init( selector, context );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
996 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
997 jQuery.extend( true, jQuerySubclass, this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
998 jQuerySubclass.superclass = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
999 jQuerySubclass.fn = jQuerySubclass.prototype = this();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1000 jQuerySubclass.fn.constructor = jQuerySubclass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1001 jQuerySubclass.subclass = this.subclass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1002 jQuerySubclass.fn.init = function init( selector, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1003 if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1004 context = jQuerySubclass(context);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1005 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1006
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1007 return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1008 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1009 jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1010 var rootjQuerySubclass = jQuerySubclass(document);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1011 return jQuerySubclass;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1012 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1013
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1014 browser: {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1015 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1016
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1017 // Create readyList deferred
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1018 readyList = jQuery._Deferred();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1019
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1020 // Populate the class2type map
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1021 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1022 class2type[ "[object " + name + "]" ] = name.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1023 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1024
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1025 browserMatch = jQuery.uaMatch( userAgent );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1026 if ( browserMatch.browser ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1027 jQuery.browser[ browserMatch.browser ] = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1028 jQuery.browser.version = browserMatch.version;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1029 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1030
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1031 // Deprecated, use jQuery.browser.webkit instead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1032 if ( jQuery.browser.webkit ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1033 jQuery.browser.safari = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1034 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1035
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1036 if ( indexOf ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1037 jQuery.inArray = function( elem, array ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1038 return indexOf.call( array, elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1039 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1040 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1041
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1042 // IE doesn't match non-breaking spaces with \s
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1043 if ( rnotwhite.test( "\xA0" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1044 trimLeft = /^[\s\xA0]+/;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1045 trimRight = /[\s\xA0]+$/;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1046 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1047
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1048 // All jQuery objects should point back to these
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1049 rootjQuery = jQuery(document);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1050
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1051 // Cleanup functions for the document ready method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1052 if ( document.addEventListener ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1053 DOMContentLoaded = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1054 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1055 jQuery.ready();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1056 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1057
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1058 } else if ( document.attachEvent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1059 DOMContentLoaded = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1060 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1061 if ( document.readyState === "complete" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1062 document.detachEvent( "onreadystatechange", DOMContentLoaded );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1063 jQuery.ready();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1064 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1065 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1066 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1067
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1068 // The DOM ready check for Internet Explorer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1069 function doScrollCheck() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1070 if ( jQuery.isReady ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1071 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1072 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1073
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1074 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1075 // If IE is used, use the trick by Diego Perini
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1076 // http://javascript.nwbox.com/IEContentLoaded/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1077 document.documentElement.doScroll("left");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1078 } catch(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1079 setTimeout( doScrollCheck, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1080 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1081 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1082
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1083 // and execute any waiting functions
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1084 jQuery.ready();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1085 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1086
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1087 // Expose jQuery to the global object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1088 return jQuery;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1089
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1090 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1091
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1092
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1093 (function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1094
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1095 jQuery.support = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1096
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1097 var div = document.createElement("div");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1098
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1099 div.style.display = "none";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1100 div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1102 var all = div.getElementsByTagName("*"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1103 a = div.getElementsByTagName("a")[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1104 select = document.createElement("select"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1105 opt = select.appendChild( document.createElement("option") ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1106 input = div.getElementsByTagName("input")[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1107
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1108 // Can't get basic test support
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1109 if ( !all || !all.length || !a ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1110 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1111 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1112
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1113 jQuery.support = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1114 // IE strips leading whitespace when .innerHTML is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1115 leadingWhitespace: div.firstChild.nodeType === 3,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1117 // Make sure that tbody elements aren't automatically inserted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1118 // IE will insert them into empty tables
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1119 tbody: !div.getElementsByTagName("tbody").length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1120
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1121 // Make sure that link elements get serialized correctly by innerHTML
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1122 // This requires a wrapper element in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1123 htmlSerialize: !!div.getElementsByTagName("link").length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1124
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1125 // Get the style information from getAttribute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1126 // (IE uses .cssText insted)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1127 style: /red/.test( a.getAttribute("style") ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1128
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1129 // Make sure that URLs aren't manipulated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1130 // (IE normalizes it by default)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1131 hrefNormalized: a.getAttribute("href") === "/a",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1132
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1133 // Make sure that element opacity exists
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1134 // (IE uses filter instead)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1135 // Use a regex to work around a WebKit issue. See #5145
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1136 opacity: /^0.55$/.test( a.style.opacity ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1137
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1138 // Verify style float existence
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1139 // (IE uses styleFloat instead of cssFloat)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1140 cssFloat: !!a.style.cssFloat,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1141
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1142 // Make sure that if no value is specified for a checkbox
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1143 // that it defaults to "on".
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1144 // (WebKit defaults to "" instead)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1145 checkOn: input.value === "on",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1147 // Make sure that a selected-by-default option has a working selected property.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1148 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1149 optSelected: opt.selected,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1150
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1151 // Will be defined later
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1152 deleteExpando: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1153 optDisabled: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1154 checkClone: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1155 noCloneEvent: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1156 noCloneChecked: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1157 boxModel: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1158 inlineBlockNeedsLayout: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1159 shrinkWrapBlocks: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1160 reliableHiddenOffsets: true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1161 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1162
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1163 input.checked = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1164 jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1165
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1166 // Make sure that the options inside disabled selects aren't marked as disabled
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1167 // (WebKit marks them as diabled)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1168 select.disabled = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1169 jQuery.support.optDisabled = !opt.disabled;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1170
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1171 var _scriptEval = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1172 jQuery.support.scriptEval = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1173 if ( _scriptEval === null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1174 var root = document.documentElement,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1175 script = document.createElement("script"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1176 id = "script" + jQuery.now();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1177
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1178 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1179 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1180 } catch(e) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1181
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1182 root.insertBefore( script, root.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1183
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1184 // Make sure that the execution of code works by injecting a script
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1185 // tag with appendChild/createTextNode
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1186 // (IE doesn't support this, fails, and uses .text instead)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1187 if ( window[ id ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1188 _scriptEval = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1189 delete window[ id ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1190 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1191 _scriptEval = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1192 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1193
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1194 root.removeChild( script );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1195 // release memory in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1196 root = script = id = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1197 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1198
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1199 return _scriptEval;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1200 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1201
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1202 // Test to see if it's possible to delete an expando from an element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1203 // Fails in Internet Explorer
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1204 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1205 delete div.test;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1206
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1207 } catch(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1208 jQuery.support.deleteExpando = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1209 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1210
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1211 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1212 div.attachEvent("onclick", function click() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1213 // Cloning a node shouldn't copy over any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1214 // bound event handlers (IE does this)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1215 jQuery.support.noCloneEvent = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1216 div.detachEvent("onclick", click);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1217 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1218 div.cloneNode(true).fireEvent("onclick");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1219 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1221 div = document.createElement("div");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1222 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1223
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1224 var fragment = document.createDocumentFragment();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1225 fragment.appendChild( div.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1226
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1227 // WebKit doesn't clone checked state correctly in fragments
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1228 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1230 // Figure out if the W3C box model works as expected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1231 // document.body must exist before we can do this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1232 jQuery(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1233 var div = document.createElement("div"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1234 body = document.getElementsByTagName("body")[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1235
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1236 // Frameset documents with no body should not run this code
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1237 if ( !body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1238 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1239 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1241 div.style.width = div.style.paddingLeft = "1px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1242 body.appendChild( div );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1243 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1244
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1245 if ( "zoom" in div.style ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1246 // Check if natively block-level elements act like inline-block
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1247 // elements when setting their display to 'inline' and giving
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1248 // them layout
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1249 // (IE < 8 does this)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1250 div.style.display = "inline";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1251 div.style.zoom = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1252 jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1253
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1254 // Check if elements with layout shrink-wrap their children
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1255 // (IE 6 does this)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1256 div.style.display = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1257 div.innerHTML = "<div style='width:4px;'></div>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1258 jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1259 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1260
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1261 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1262 var tds = div.getElementsByTagName("td");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1263
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1264 // Check if table cells still have offsetWidth/Height when they are set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1265 // to display:none and there are still other visible table cells in a
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1266 // table row; if so, offsetWidth/Height are not reliable for use when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1267 // determining if an element has been hidden directly using
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1268 // display:none (it is still safe to use offsets if a parent element is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1269 // hidden; don safety goggles and see bug #4512 for more information).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1270 // (only IE 8 fails this test)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1271 jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1272
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1273 tds[0].style.display = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1274 tds[1].style.display = "none";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1276 // Check if empty table cells still have offsetWidth/Height
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1277 // (IE < 8 fail this test)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1278 jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1279 div.innerHTML = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1280
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1281 body.removeChild( div ).style.display = "none";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1282 div = tds = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1283 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1284
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1285 // Technique from Juriy Zaytsev
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1286 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1287 var eventSupported = function( eventName ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1288 var el = document.createElement("div");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1289 eventName = "on" + eventName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1290
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1291 // We only care about the case where non-standard event systems
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1292 // are used, namely in IE. Short-circuiting here helps us to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1293 // avoid an eval call (in setAttribute) which can cause CSP
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1294 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1295 if ( !el.attachEvent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1296 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1297 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1298
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1299 var isSupported = (eventName in el);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1300 if ( !isSupported ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1301 el.setAttribute(eventName, "return;");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1302 isSupported = typeof el[eventName] === "function";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1303 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1304 el = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1305
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1306 return isSupported;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1307 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1308
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1309 jQuery.support.submitBubbles = eventSupported("submit");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1310 jQuery.support.changeBubbles = eventSupported("change");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1311
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1312 // release memory in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1313 div = all = a = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1314 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1315
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1316
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1317
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1318 var rbrace = /^(?:\{.*\}|\[.*\])$/;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1319
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1320 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1321 cache: {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1322
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1323 // Please use with caution
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1324 uuid: 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1325
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1326 // Unique for each copy of jQuery on the page
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1327 // Non-digits removed to match rinlinejQuery
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1328 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1329
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1330 // The following elements throw uncatchable exceptions if you
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1331 // attempt to add expando properties to them.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1332 noData: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1333 "embed": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1334 // Ban all objects except for Flash (which handle expandos)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1335 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1336 "applet": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1337 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1338
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1339 hasData: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1340 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1341
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1342 return !!elem && !isEmptyDataObject( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1343 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1344
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1345 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1346 if ( !jQuery.acceptData( elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1347 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1348 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1349
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1350 var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1351
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1352 // We have to handle DOM nodes and JS objects differently because IE6-7
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1353 // can't GC object references properly across the DOM-JS boundary
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1354 isNode = elem.nodeType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1355
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1356 // Only DOM nodes need the global jQuery cache; JS object data is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1357 // attached directly to the object so GC can occur automatically
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1358 cache = isNode ? jQuery.cache : elem,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1359
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1360 // Only defining an ID for JS objects if its cache already exists allows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1361 // the code to shortcut on the same path as a DOM node with no cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1362 id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1363
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1364 // Avoid doing any more work than we need to when trying to get data on an
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1365 // object that has no data at all
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1366 if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1367 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1368 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1369
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1370 if ( !id ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1371 // Only DOM nodes need a new unique ID for each element since their data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1372 // ends up in the global cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1373 if ( isNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1374 elem[ jQuery.expando ] = id = ++jQuery.uuid;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1375 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1376 id = jQuery.expando;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1377 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1378 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1380 if ( !cache[ id ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1381 cache[ id ] = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1382
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1383 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1384 // metadata on plain JS objects when the object is serialized using
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1385 // JSON.stringify
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1386 if ( !isNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1387 cache[ id ].toJSON = jQuery.noop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1388 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1389 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1390
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1391 // An object can be passed to jQuery.data instead of a key/value pair; this gets
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1392 // shallow copied over onto the existing cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1393 if ( typeof name === "object" || typeof name === "function" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1394 if ( pvt ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1395 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1396 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1397 cache[ id ] = jQuery.extend(cache[ id ], name);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1398 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1399 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1400
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1401 thisCache = cache[ id ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1402
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1403 // Internal jQuery data is stored in a separate object inside the object's data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1404 // cache in order to avoid key collisions between internal data and user-defined
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1405 // data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1406 if ( pvt ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1407 if ( !thisCache[ internalKey ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1408 thisCache[ internalKey ] = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1409 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1410
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1411 thisCache = thisCache[ internalKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1412 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1413
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1414 if ( data !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1415 thisCache[ name ] = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1416 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1417
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1418 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1419 // not attempt to inspect the internal events object using jQuery.data, as this
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1420 // internal data object is undocumented and subject to change.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1421 if ( name === "events" && !thisCache[name] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1422 return thisCache[ internalKey ] && thisCache[ internalKey ].events;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1423 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1424
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1425 return getByName ? thisCache[ name ] : thisCache;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1426 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1427
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1428 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1429 if ( !jQuery.acceptData( elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1430 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1431 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1432
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1433 var internalKey = jQuery.expando, isNode = elem.nodeType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1434
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1435 // See jQuery.data for more information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1436 cache = isNode ? jQuery.cache : elem,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1437
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1438 // See jQuery.data for more information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1439 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1440
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1441 // If there is already no cache entry for this object, there is no
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1442 // purpose in continuing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1443 if ( !cache[ id ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1444 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1445 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1446
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1447 if ( name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1448 var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1449
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1450 if ( thisCache ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1451 delete thisCache[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1452
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1453 // If there is no data left in the cache, we want to continue
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1454 // and let the cache object itself get destroyed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1455 if ( !isEmptyDataObject(thisCache) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1456 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1457 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1458 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1459 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1460
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1461 // See jQuery.data for more information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1462 if ( pvt ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1463 delete cache[ id ][ internalKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1464
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1465 // Don't destroy the parent cache unless the internal data object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1466 // had been the only thing left in it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1467 if ( !isEmptyDataObject(cache[ id ]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1468 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1469 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1470 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1471
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1472 var internalCache = cache[ id ][ internalKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1473
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1474 // Browsers that fail expando deletion also refuse to delete expandos on
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1475 // the window, but it will allow it on all other JS objects; other browsers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1476 // don't care
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1477 if ( jQuery.support.deleteExpando || cache != window ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1478 delete cache[ id ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1479 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1480 cache[ id ] = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1481 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1482
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1483 // We destroyed the entire user cache at once because it's faster than
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1484 // iterating through each key, but we need to continue to persist internal
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1485 // data if it existed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1486 if ( internalCache ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1487 cache[ id ] = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1488 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1489 // metadata on plain JS objects when the object is serialized using
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1490 // JSON.stringify
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1491 if ( !isNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1492 cache[ id ].toJSON = jQuery.noop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1493 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1494
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1495 cache[ id ][ internalKey ] = internalCache;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1496
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1497 // Otherwise, we need to eliminate the expando on the node to avoid
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1498 // false lookups in the cache for entries that no longer exist
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1499 } else if ( isNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1500 // IE does not allow us to delete expando properties from nodes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1501 // nor does it have a removeAttribute function on Document nodes;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1502 // we must handle all of these cases
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1503 if ( jQuery.support.deleteExpando ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1504 delete elem[ jQuery.expando ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1505 } else if ( elem.removeAttribute ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1506 elem.removeAttribute( jQuery.expando );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1507 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1508 elem[ jQuery.expando ] = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1509 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1510 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1511 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1512
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1513 // For internal use only.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1514 _data: function( elem, name, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1515 return jQuery.data( elem, name, data, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1516 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1518 // A method for determining if a DOM node can handle the data expando
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1519 acceptData: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1520 if ( elem.nodeName ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1521 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1522
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1523 if ( match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1524 return !(match === true || elem.getAttribute("classid") !== match);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1525 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1526 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1527
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1528 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1529 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1530 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1531
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1532 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1533 data: function( key, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1534 var data = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1535
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1536 if ( typeof key === "undefined" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1537 if ( this.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1538 data = jQuery.data( this[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1540 if ( this[0].nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1541 var attr = this[0].attributes, name;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1542 for ( var i = 0, l = attr.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1543 name = attr[i].name;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1544
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1545 if ( name.indexOf( "data-" ) === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1546 name = name.substr( 5 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1547 dataAttr( this[0], name, data[ name ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1548 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1549 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1550 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1551 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1552
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1553 return data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1554
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1555 } else if ( typeof key === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1556 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1557 jQuery.data( this, key );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1558 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1559 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1560
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1561 var parts = key.split(".");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1562 parts[1] = parts[1] ? "." + parts[1] : "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1563
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1564 if ( value === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1565 data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1566
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1567 // Try to fetch any internally stored data first
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1568 if ( data === undefined && this.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1569 data = jQuery.data( this[0], key );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1570 data = dataAttr( this[0], key, data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1571 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1572
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1573 return data === undefined && parts[1] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1574 this.data( parts[0] ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1575 data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1576
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1577 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1578 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1579 var $this = jQuery( this ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1580 args = [ parts[0], value ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1581
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1582 $this.triggerHandler( "setData" + parts[1] + "!", args );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1583 jQuery.data( this, key, value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1584 $this.triggerHandler( "changeData" + parts[1] + "!", args );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1585 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1586 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1587 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1588
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1589 removeData: function( key ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1590 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1591 jQuery.removeData( this, key );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1592 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1593 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1594 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1595
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1596 function dataAttr( elem, key, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1597 // If nothing was found internally, try to fetch any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1598 // data from the HTML5 data-* attribute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1599 if ( data === undefined && elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1600 data = elem.getAttribute( "data-" + key );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1601
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1602 if ( typeof data === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1603 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1604 data = data === "true" ? true :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1605 data === "false" ? false :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1606 data === "null" ? null :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1607 !jQuery.isNaN( data ) ? parseFloat( data ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1608 rbrace.test( data ) ? jQuery.parseJSON( data ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1609 data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1610 } catch( e ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1611
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1612 // Make sure we set the data so it isn't changed later
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1613 jQuery.data( elem, key, data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1614
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1615 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1616 data = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1617 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1618 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1620 return data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1621 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1622
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1623 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1624 // property to be considered empty objects; this property always exists in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1625 // order to make sure JSON.stringify does not expose internal metadata
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1626 function isEmptyDataObject( obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1627 for ( var name in obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1628 if ( name !== "toJSON" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1629 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1630 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1631 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1632
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1633 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1634 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1635
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1636
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1637
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1638
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1639 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1640 queue: function( elem, type, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1641 if ( !elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1642 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1643 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1644
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1645 type = (type || "fx") + "queue";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1646 var q = jQuery._data( elem, type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1647
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1648 // Speed up dequeue by getting out quickly if this is just a lookup
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1649 if ( !data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1650 return q || [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1651 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1653 if ( !q || jQuery.isArray(data) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1654 q = jQuery._data( elem, type, jQuery.makeArray(data) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1655
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1656 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1657 q.push( data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1658 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1659
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1660 return q;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1661 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1662
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1663 dequeue: function( elem, type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1664 type = type || "fx";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1665
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1666 var queue = jQuery.queue( elem, type ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1667 fn = queue.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1669 // If the fx queue is dequeued, always remove the progress sentinel
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1670 if ( fn === "inprogress" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1671 fn = queue.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1672 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1673
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1674 if ( fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1675 // Add a progress sentinel to prevent the fx queue from being
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1676 // automatically dequeued
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1677 if ( type === "fx" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1678 queue.unshift("inprogress");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1679 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1680
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1681 fn.call(elem, function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1682 jQuery.dequeue(elem, type);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1683 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1684 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1685
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1686 if ( !queue.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1687 jQuery.removeData( elem, type + "queue", true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1688 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1689 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1690 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1691
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1692 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1693 queue: function( type, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1694 if ( typeof type !== "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1695 data = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1696 type = "fx";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1697 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1698
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1699 if ( data === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1700 return jQuery.queue( this[0], type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1701 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1702 return this.each(function( i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1703 var queue = jQuery.queue( this, type, data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1704
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1705 if ( type === "fx" && queue[0] !== "inprogress" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1706 jQuery.dequeue( this, type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1707 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1708 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1709 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1710 dequeue: function( type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1711 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1712 jQuery.dequeue( this, type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1713 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1714 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1715
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1716 // Based off of the plugin by Clint Helfers, with permission.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1717 // http://blindsignals.com/index.php/2009/07/jquery-delay/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1718 delay: function( time, type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1719 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1720 type = type || "fx";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1721
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1722 return this.queue( type, function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1723 var elem = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1724 setTimeout(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1725 jQuery.dequeue( elem, type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1726 }, time );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1727 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1728 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1729
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1730 clearQueue: function( type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1731 return this.queue( type || "fx", [] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1732 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1733 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1734
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1735
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1736
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1737
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1738 var rclass = /[\n\t\r]/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1739 rspaces = /\s+/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1740 rreturn = /\r/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1741 rspecialurl = /^(?:href|src|style)$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1742 rtype = /^(?:button|input)$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1743 rfocusable = /^(?:button|input|object|select|textarea)$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1744 rclickable = /^a(?:rea)?$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1745 rradiocheck = /^(?:radio|checkbox)$/i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1746
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1747 jQuery.props = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1748 "for": "htmlFor",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1749 "class": "className",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1750 readonly: "readOnly",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1751 maxlength: "maxLength",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1752 cellspacing: "cellSpacing",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1753 rowspan: "rowSpan",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1754 colspan: "colSpan",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1755 tabindex: "tabIndex",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1756 usemap: "useMap",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1757 frameborder: "frameBorder"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1758 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1759
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1760 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1761 attr: function( name, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1762 return jQuery.access( this, name, value, true, jQuery.attr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1763 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1764
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1765 removeAttr: function( name, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1766 return this.each(function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1767 jQuery.attr( this, name, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1768 if ( this.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1769 this.removeAttribute( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1770 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1771 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1772 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1773
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1774 addClass: function( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1775 if ( jQuery.isFunction(value) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1776 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1777 var self = jQuery(this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1778 self.addClass( value.call(this, i, self.attr("class")) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1779 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1780 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1782 if ( value && typeof value === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1783 var classNames = (value || "").split( rspaces );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1784
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1785 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1786 var elem = this[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1787
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1788 if ( elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1789 if ( !elem.className ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1790 elem.className = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1791
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1792 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1793 var className = " " + elem.className + " ",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1794 setClass = elem.className;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1796 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1797 if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1798 setClass += " " + classNames[c];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1799 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1800 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1801 elem.className = jQuery.trim( setClass );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1802 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1803 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1804 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1805 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1806
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1807 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1808 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1809
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1810 removeClass: function( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1811 if ( jQuery.isFunction(value) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1812 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1813 var self = jQuery(this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1814 self.removeClass( value.call(this, i, self.attr("class")) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1815 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1816 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1817
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1818 if ( (value && typeof value === "string") || value === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1819 var classNames = (value || "").split( rspaces );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1820
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1821 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1822 var elem = this[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1823
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1824 if ( elem.nodeType === 1 && elem.className ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1825 if ( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1826 var className = (" " + elem.className + " ").replace(rclass, " ");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1827 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1828 className = className.replace(" " + classNames[c] + " ", " ");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1829 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1830 elem.className = jQuery.trim( className );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1831
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1832 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1833 elem.className = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1834 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1835 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1836 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1837 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1838
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1839 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1840 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1841
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1842 toggleClass: function( value, stateVal ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1843 var type = typeof value,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1844 isBool = typeof stateVal === "boolean";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1845
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1846 if ( jQuery.isFunction( value ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1847 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1848 var self = jQuery(this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1849 self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1850 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1851 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1852
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1853 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1854 if ( type === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1855 // toggle individual class names
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1856 var className,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1857 i = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1858 self = jQuery( this ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1859 state = stateVal,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1860 classNames = value.split( rspaces );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1861
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1862 while ( (className = classNames[ i++ ]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1863 // check each className given, space seperated list
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1864 state = isBool ? state : !self.hasClass( className );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1865 self[ state ? "addClass" : "removeClass" ]( className );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1866 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1867
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1868 } else if ( type === "undefined" || type === "boolean" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1869 if ( this.className ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1870 // store className if set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1871 jQuery._data( this, "__className__", this.className );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1872 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1873
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1874 // toggle whole className
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1875 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1876 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1877 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1878 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1879
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1880 hasClass: function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1881 var className = " " + selector + " ";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1882 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1883 if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1884 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1885 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1886 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1888 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1889 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1890
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1891 val: function( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1892 if ( !arguments.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1893 var elem = this[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1894
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1895 if ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1896 if ( jQuery.nodeName( elem, "option" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1897 // attributes.value is undefined in Blackberry 4.7 but
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1898 // uses .value. See #6932
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1899 var val = elem.attributes.value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1900 return !val || val.specified ? elem.value : elem.text;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1901 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1902
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1903 // We need to handle select boxes special
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1904 if ( jQuery.nodeName( elem, "select" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1905 var index = elem.selectedIndex,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1906 values = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1907 options = elem.options,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1908 one = elem.type === "select-one";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1909
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1910 // Nothing was selected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1911 if ( index < 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1912 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1913 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1914
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1915 // Loop through all the selected options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1916 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1917 var option = options[ i ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1918
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1919 // Don't return options that are disabled or in a disabled optgroup
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1920 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1921 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1922
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1923 // Get the specific value for the option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1924 value = jQuery(option).val();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1925
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1926 // We don't need an array for one selects
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1927 if ( one ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1928 return value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1929 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1930
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1931 // Multi-Selects return an array
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1932 values.push( value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1933 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1934 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1935
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1936 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1937 if ( one && !values.length && options.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1938 return jQuery( options[ index ] ).val();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1939 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1940
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1941 return values;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1942 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1943
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1944 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1945 if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1946 return elem.getAttribute("value") === null ? "on" : elem.value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1947 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1948
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1949 // Everything else, we just grab the value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1950 return (elem.value || "").replace(rreturn, "");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1951
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1952 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1953
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1954 return undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1955 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1956
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1957 var isFunction = jQuery.isFunction(value);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1958
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1959 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1960 var self = jQuery(this), val = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1961
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1962 if ( this.nodeType !== 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1963 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1964 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1965
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1966 if ( isFunction ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1967 val = value.call(this, i, self.val());
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1968 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1969
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1970 // Treat null/undefined as ""; convert numbers to string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1971 if ( val == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1972 val = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1973 } else if ( typeof val === "number" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1974 val += "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1975 } else if ( jQuery.isArray(val) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1976 val = jQuery.map(val, function (value) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1977 return value == null ? "" : value + "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1978 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1979 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1980
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1981 if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1982 this.checked = jQuery.inArray( self.val(), val ) >= 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1983
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1984 } else if ( jQuery.nodeName( this, "select" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1985 var values = jQuery.makeArray(val);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1986
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1987 jQuery( "option", this ).each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1988 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1989 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1990
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1991 if ( !values.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1992 this.selectedIndex = -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1993 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1994
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1995 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1996 this.value = val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1997 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1998 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1999 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2000 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2001
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2002 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2003 attrFn: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2004 val: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2005 css: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2006 html: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2007 text: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2008 data: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2009 width: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2010 height: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2011 offset: true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2012 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2013
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2014 attr: function( elem, name, value, pass ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2015 // don't get/set attributes on text, comment and attribute nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2016 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2017 return undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2018 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2019
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2020 if ( pass && name in jQuery.attrFn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2021 return jQuery(elem)[name](value);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2022 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2023
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2024 var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2025 // Whether we are setting (or getting)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2026 set = value !== undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2027
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2028 // Try to normalize/fix the name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2029 name = notxml && jQuery.props[ name ] || name;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2030
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2031 // Only do all the following if this is a node (faster for style)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2032 if ( elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2033 // These attributes require special treatment
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2034 var special = rspecialurl.test( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2035
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2036 // Safari mis-reports the default selected property of an option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2037 // Accessing the parent's selectedIndex property fixes it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2038 if ( name === "selected" && !jQuery.support.optSelected ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2039 var parent = elem.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2040 if ( parent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2041 parent.selectedIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2042
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2043 // Make sure that it also works with optgroups, see #5701
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2044 if ( parent.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2045 parent.parentNode.selectedIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2046 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2047 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2048 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2049
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2050 // If applicable, access the attribute via the DOM 0 way
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2051 // 'in' checks fail in Blackberry 4.7 #6931
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2052 if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2053 if ( set ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2054 // We can't allow the type property to be changed (since it causes problems in IE)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2055 if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2056 jQuery.error( "type property can't be changed" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2057 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2058
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2059 if ( value === null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2060 if ( elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2061 elem.removeAttribute( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2062 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2063
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2064 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2065 elem[ name ] = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2066 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2067 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2068
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2069 // browsers index elements by id/name on forms, give priority to attributes.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2070 if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2071 return elem.getAttributeNode( name ).nodeValue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2072 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2073
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2074 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2075 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2076 if ( name === "tabIndex" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2077 var attributeNode = elem.getAttributeNode( "tabIndex" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2078
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2079 return attributeNode && attributeNode.specified ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2080 attributeNode.value :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2081 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2082 0 :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2083 undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2084 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2085
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2086 return elem[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2087 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2088
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2089 if ( !jQuery.support.style && notxml && name === "style" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2090 if ( set ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2091 elem.style.cssText = "" + value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2092 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2093
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2094 return elem.style.cssText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2095 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2096
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2097 if ( set ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2098 // convert the value to a string (all browsers do this but IE) see #1070
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2099 elem.setAttribute( name, "" + value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2100 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2101
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2102 // Ensure that missing attributes return undefined
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2103 // Blackberry 4.7 returns "" from getAttribute #6938
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2104 if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2105 return undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2106 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2107
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2108 var attr = !jQuery.support.hrefNormalized && notxml && special ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2109 // Some attributes require a special call on IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2110 elem.getAttribute( name, 2 ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2111 elem.getAttribute( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2112
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2113 // Non-existent attributes return null, we normalize to undefined
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2114 return attr === null ? undefined : attr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2115 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2116 // Handle everything which isn't a DOM element node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2117 if ( set ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2118 elem[ name ] = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2119 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2120 return elem[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2121 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2122 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2123
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2124
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2126
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2127 var rnamespaces = /\.(.*)$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2128 rformElems = /^(?:textarea|input|select)$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2129 rperiod = /\./g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2130 rspace = / /g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2131 rescape = /[^\w\s.|`]/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2132 fcleanup = function( nm ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2133 return nm.replace(rescape, "\\$&");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2134 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2135
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2136 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2137 * A number of helper functions used for managing events.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2138 * Many of the ideas behind this code originated from
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2139 * Dean Edwards' addEvent library.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2140 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2141 jQuery.event = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2142
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2143 // Bind an event to an element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2144 // Original by Dean Edwards
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2145 add: function( elem, types, handler, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2146 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2147 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2148 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2149
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2150 // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2151 // Minor release fix for bug #8018
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2152 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2153 // For whatever reason, IE has trouble passing the window object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2154 // around, causing it to be cloned in the process
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2155 if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2156 elem = window;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2157 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2158 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2159 catch ( e ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2160
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2161 if ( handler === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2162 handler = returnFalse;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2163 } else if ( !handler ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2164 // Fixes bug #7229. Fix recommended by jdalton
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2165 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2166 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2167
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2168 var handleObjIn, handleObj;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2169
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2170 if ( handler.handler ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2171 handleObjIn = handler;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2172 handler = handleObjIn.handler;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2173 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2174
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2175 // Make sure that the function being executed has a unique ID
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2176 if ( !handler.guid ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2177 handler.guid = jQuery.guid++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2178 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2179
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2180 // Init the element's event structure
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2181 var elemData = jQuery._data( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2182
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2183 // If no elemData is found then we must be trying to bind to one of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2184 // banned noData elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2185 if ( !elemData ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2186 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2187 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2188
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2189 var events = elemData.events,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2190 eventHandle = elemData.handle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2191
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2192 if ( !events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2193 elemData.events = events = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2194 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2195
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2196 if ( !eventHandle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2197 elemData.handle = eventHandle = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2198 // Handle the second event of a trigger and when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2199 // an event is called after a page has unloaded
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2200 return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2201 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2202 undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2203 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2204 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2205
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2206 // Add elem as a property of the handle function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2207 // This is to prevent a memory leak with non-native events in IE.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2208 eventHandle.elem = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2209
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2210 // Handle multiple events separated by a space
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2211 // jQuery(...).bind("mouseover mouseout", fn);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2212 types = types.split(" ");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2213
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2214 var type, i = 0, namespaces;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2215
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2216 while ( (type = types[ i++ ]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2217 handleObj = handleObjIn ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2218 jQuery.extend({}, handleObjIn) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2219 { handler: handler, data: data };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2221 // Namespaced event handlers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2222 if ( type.indexOf(".") > -1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2223 namespaces = type.split(".");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2224 type = namespaces.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2225 handleObj.namespace = namespaces.slice(0).sort().join(".");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2226
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2227 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2228 namespaces = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2229 handleObj.namespace = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2230 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2231
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2232 handleObj.type = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2233 if ( !handleObj.guid ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2234 handleObj.guid = handler.guid;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2235 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2236
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2237 // Get the current list of functions bound to this event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2238 var handlers = events[ type ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2239 special = jQuery.event.special[ type ] || {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2241 // Init the event handler queue
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2242 if ( !handlers ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2243 handlers = events[ type ] = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2244
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2245 // Check for a special event handler
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2246 // Only use addEventListener/attachEvent if the special
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2247 // events handler returns false
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2248 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2249 // Bind the global event handler to the element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2250 if ( elem.addEventListener ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2251 elem.addEventListener( type, eventHandle, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2252
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2253 } else if ( elem.attachEvent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2254 elem.attachEvent( "on" + type, eventHandle );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2255 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2256 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2257 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2258
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2259 if ( special.add ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2260 special.add.call( elem, handleObj );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2261
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2262 if ( !handleObj.handler.guid ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2263 handleObj.handler.guid = handler.guid;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2264 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2265 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2266
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2267 // Add the function to the element's handler list
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2268 handlers.push( handleObj );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2269
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2270 // Keep track of which events have been used, for global triggering
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2271 jQuery.event.global[ type ] = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2272 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2273
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2274 // Nullify elem to prevent memory leaks in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2275 elem = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2276 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2277
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2278 global: {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2279
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2280 // Detach an event or set of events from an element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2281 remove: function( elem, types, handler, pos ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2282 // don't do events on text and comment nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2283 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2284 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2285 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2286
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2287 if ( handler === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2288 handler = returnFalse;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2289 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2290
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2291 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2292 elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2293 events = elemData && elemData.events;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2294
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2295 if ( !elemData || !events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2296 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2297 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2298
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2299 // types is actually an event object here
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2300 if ( types && types.type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2301 handler = types.handler;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2302 types = types.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2303 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2304
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2305 // Unbind all events for the element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2306 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2307 types = types || "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2308
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2309 for ( type in events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2310 jQuery.event.remove( elem, type + types );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2311 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2313 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2314 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2315
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2316 // Handle multiple events separated by a space
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2317 // jQuery(...).unbind("mouseover mouseout", fn);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2318 types = types.split(" ");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2319
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2320 while ( (type = types[ i++ ]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2321 origType = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2322 handleObj = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2323 all = type.indexOf(".") < 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2324 namespaces = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2325
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2326 if ( !all ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2327 // Namespaced event handlers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2328 namespaces = type.split(".");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2329 type = namespaces.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2330
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2331 namespace = new RegExp("(^|\\.)" +
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2332 jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2333 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2334
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2335 eventType = events[ type ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2336
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2337 if ( !eventType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2338 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2339 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2340
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2341 if ( !handler ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2342 for ( j = 0; j < eventType.length; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2343 handleObj = eventType[ j ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2344
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2345 if ( all || namespace.test( handleObj.namespace ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2346 jQuery.event.remove( elem, origType, handleObj.handler, j );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2347 eventType.splice( j--, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2348 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2349 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2350
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2351 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2352 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2353
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2354 special = jQuery.event.special[ type ] || {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2355
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2356 for ( j = pos || 0; j < eventType.length; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2357 handleObj = eventType[ j ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2358
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2359 if ( handler.guid === handleObj.guid ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2360 // remove the given handler for the given type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2361 if ( all || namespace.test( handleObj.namespace ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2362 if ( pos == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2363 eventType.splice( j--, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2364 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2365
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2366 if ( special.remove ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2367 special.remove.call( elem, handleObj );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2368 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2369 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2370
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2371 if ( pos != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2372 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2373 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2374 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2375 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2376
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2377 // remove generic event handler if no more handlers exist
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2378 if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2379 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2380 jQuery.removeEvent( elem, type, elemData.handle );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2381 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2382
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2383 ret = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2384 delete events[ type ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2385 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2386 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2387
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2388 // Remove the expando if it's no longer used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2389 if ( jQuery.isEmptyObject( events ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2390 var handle = elemData.handle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2391 if ( handle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2392 handle.elem = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2393 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2394
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2395 delete elemData.events;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2396 delete elemData.handle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2397
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2398 if ( jQuery.isEmptyObject( elemData ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2399 jQuery.removeData( elem, undefined, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2400 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2401 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2402 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2404 // bubbling is internal
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2405 trigger: function( event, data, elem /*, bubbling */ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2406 // Event object or event type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2407 var type = event.type || event,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2408 bubbling = arguments[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2409
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2410 if ( !bubbling ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2411 event = typeof event === "object" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2412 // jQuery.Event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2413 event[ jQuery.expando ] ? event :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2414 // Object literal
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2415 jQuery.extend( jQuery.Event(type), event ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2416 // Just the event type (string)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2417 jQuery.Event(type);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2418
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2419 if ( type.indexOf("!") >= 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2420 event.type = type = type.slice(0, -1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2421 event.exclusive = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2422 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2423
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2424 // Handle a global trigger
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2425 if ( !elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2426 // Don't bubble custom events when global (to avoid too much overhead)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2427 event.stopPropagation();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2428
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2429 // Only trigger if we've ever bound an event for it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2430 if ( jQuery.event.global[ type ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2431 // XXX This code smells terrible. event.js should not be directly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2432 // inspecting the data cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2433 jQuery.each( jQuery.cache, function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2434 // internalKey variable is just used to make it easier to find
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2435 // and potentially change this stuff later; currently it just
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2436 // points to jQuery.expando
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2437 var internalKey = jQuery.expando,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2438 internalCache = this[ internalKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2439 if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2440 jQuery.event.trigger( event, data, internalCache.handle.elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2441 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2442 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2443 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2444 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2445
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2446 // Handle triggering a single element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2447
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2448 // don't do events on text and comment nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2449 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2450 return undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2451 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2452
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2453 // Clean up in case it is reused
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2454 event.result = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2455 event.target = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2457 // Clone the incoming data, if any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2458 data = jQuery.makeArray( data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2459 data.unshift( event );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2460 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2461
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2462 event.currentTarget = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2463
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2464 // Trigger the event, it is assumed that "handle" is a function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2465 var handle = jQuery._data( elem, "handle" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2466
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2467 if ( handle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2468 handle.apply( elem, data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2469 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2471 var parent = elem.parentNode || elem.ownerDocument;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2472
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2473 // Trigger an inline bound script
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2474 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2475 if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2476 if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2477 event.result = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2478 event.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2479 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2480 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2481
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2482 // prevent IE from throwing an error for some elements with some event types, see #3533
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2483 } catch (inlineError) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2484
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2485 if ( !event.isPropagationStopped() && parent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2486 jQuery.event.trigger( event, data, parent, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2487
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2488 } else if ( !event.isDefaultPrevented() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2489 var old,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2490 target = event.target,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2491 targetType = type.replace( rnamespaces, "" ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2492 isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2493 special = jQuery.event.special[ targetType ] || {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2494
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2495 if ( (!special._default || special._default.call( elem, event ) === false) &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2496 !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2497
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2498 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2499 if ( target[ targetType ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2500 // Make sure that we don't accidentally re-trigger the onFOO events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2501 old = target[ "on" + targetType ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2502
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2503 if ( old ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2504 target[ "on" + targetType ] = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2505 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2506
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2507 jQuery.event.triggered = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2508 target[ targetType ]();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2509 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2510
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2511 // prevent IE from throwing an error for some elements with some event types, see #3533
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2512 } catch (triggerError) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2513
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2514 if ( old ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2515 target[ "on" + targetType ] = old;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2516 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2518 jQuery.event.triggered = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2519 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2520 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2521 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2522
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2523 handle: function( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2524 var all, handlers, namespaces, namespace_re, events,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2525 namespace_sort = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2526 args = jQuery.makeArray( arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2527
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2528 event = args[0] = jQuery.event.fix( event || window.event );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2529 event.currentTarget = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2530
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2531 // Namespaced event handlers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2532 all = event.type.indexOf(".") < 0 && !event.exclusive;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2533
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2534 if ( !all ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2535 namespaces = event.type.split(".");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2536 event.type = namespaces.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2537 namespace_sort = namespaces.slice(0).sort();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2538 namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2539 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2540
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2541 event.namespace = event.namespace || namespace_sort.join(".");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2542
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2543 events = jQuery._data(this, "events");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2544
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2545 handlers = (events || {})[ event.type ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2546
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2547 if ( events && handlers ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2548 // Clone the handlers to prevent manipulation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2549 handlers = handlers.slice(0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2550
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2551 for ( var j = 0, l = handlers.length; j < l; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2552 var handleObj = handlers[ j ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2554 // Filter the functions by class
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2555 if ( all || namespace_re.test( handleObj.namespace ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2556 // Pass in a reference to the handler function itself
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2557 // So that we can later remove it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2558 event.handler = handleObj.handler;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2559 event.data = handleObj.data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2560 event.handleObj = handleObj;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2562 var ret = handleObj.handler.apply( this, args );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2563
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2564 if ( ret !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2565 event.result = ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2566 if ( ret === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2567 event.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2568 event.stopPropagation();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2569 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2570 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2571
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2572 if ( event.isImmediatePropagationStopped() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2573 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2574 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2575 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2576 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2577 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2578
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2579 return event.result;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2580 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2581
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2582 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(" "),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2583
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2584 fix: function( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2585 if ( event[ jQuery.expando ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2586 return event;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2587 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2588
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2589 // store a copy of the original event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2590 // and "clone" to set read-only properties
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2591 var originalEvent = event;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2592 event = jQuery.Event( originalEvent );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2593
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2594 for ( var i = this.props.length, prop; i; ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2595 prop = this.props[ --i ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2596 event[ prop ] = originalEvent[ prop ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2597 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2598
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2599 // Fix target property, if necessary
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2600 if ( !event.target ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2601 // Fixes #1925 where srcElement might not be defined either
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2602 event.target = event.srcElement || document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2603 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2604
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2605 // check if target is a textnode (safari)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2606 if ( event.target.nodeType === 3 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2607 event.target = event.target.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2608 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2609
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2610 // Add relatedTarget, if necessary
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2611 if ( !event.relatedTarget && event.fromElement ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2612 event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2613 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2614
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2615 // Calculate pageX/Y if missing and clientX/Y available
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2616 if ( event.pageX == null && event.clientX != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2617 var doc = document.documentElement,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2618 body = document.body;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2620 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2621 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2622 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2623
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2624 // Add which for key events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2625 if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2626 event.which = event.charCode != null ? event.charCode : event.keyCode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2627 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2628
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2629 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2630 if ( !event.metaKey && event.ctrlKey ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2631 event.metaKey = event.ctrlKey;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2632 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2633
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2634 // Add which for click: 1 === left; 2 === middle; 3 === right
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2635 // Note: button is not normalized, so don't use it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2636 if ( !event.which && event.button !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2637 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2638 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2639
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2640 return event;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2641 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2642
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2643 // Deprecated, use jQuery.guid instead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2644 guid: 1E8,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2645
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2646 // Deprecated, use jQuery.proxy instead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2647 proxy: jQuery.proxy,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2648
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2649 special: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2650 ready: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2651 // Make sure the ready event is setup
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2652 setup: jQuery.bindReady,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2653 teardown: jQuery.noop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2654 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2655
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2656 live: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2657 add: function( handleObj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2658 jQuery.event.add( this,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2659 liveConvert( handleObj.origType, handleObj.selector ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2660 jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2661 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2662
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2663 remove: function( handleObj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2664 jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2665 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2666 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2667
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2668 beforeunload: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2669 setup: function( data, namespaces, eventHandle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2670 // We only want to do this special case on windows
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2671 if ( jQuery.isWindow( this ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2672 this.onbeforeunload = eventHandle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2673 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2674 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2675
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2676 teardown: function( namespaces, eventHandle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2677 if ( this.onbeforeunload === eventHandle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2678 this.onbeforeunload = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2679 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2680 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2681 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2682 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2683 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2684
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2685 jQuery.removeEvent = document.removeEventListener ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2686 function( elem, type, handle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2687 if ( elem.removeEventListener ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2688 elem.removeEventListener( type, handle, false );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2689 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2690 } :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2691 function( elem, type, handle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2692 if ( elem.detachEvent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2693 elem.detachEvent( "on" + type, handle );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2694 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2695 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2696
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2697 jQuery.Event = function( src ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2698 // Allow instantiation without the 'new' keyword
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2699 if ( !this.preventDefault ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2700 return new jQuery.Event( src );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2701 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2702
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2703 // Event object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2704 if ( src && src.type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2705 this.originalEvent = src;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2706 this.type = src.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2707
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2708 // Events bubbling up the document may have been marked as prevented
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2709 // by a handler lower down the tree; reflect the correct value.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2710 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2711 src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2712
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2713 // Event type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2714 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2715 this.type = src;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2716 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2717
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2718 // timeStamp is buggy for some events on Firefox(#3843)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2719 // So we won't rely on the native value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2720 this.timeStamp = jQuery.now();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2721
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2722 // Mark it as fixed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2723 this[ jQuery.expando ] = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2724 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2725
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2726 function returnFalse() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2727 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2728 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2729 function returnTrue() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2730 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2731 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2732
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2733 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2734 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2735 jQuery.Event.prototype = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2736 preventDefault: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2737 this.isDefaultPrevented = returnTrue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2738
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2739 var e = this.originalEvent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2740 if ( !e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2741 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2742 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2743
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2744 // if preventDefault exists run it on the original event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2745 if ( e.preventDefault ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2746 e.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2747
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2748 // otherwise set the returnValue property of the original event to false (IE)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2749 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2750 e.returnValue = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2751 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2752 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2753 stopPropagation: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2754 this.isPropagationStopped = returnTrue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2755
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2756 var e = this.originalEvent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2757 if ( !e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2758 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2759 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2760 // if stopPropagation exists run it on the original event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2761 if ( e.stopPropagation ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2762 e.stopPropagation();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2763 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2764 // otherwise set the cancelBubble property of the original event to true (IE)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2765 e.cancelBubble = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2766 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2767 stopImmediatePropagation: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2768 this.isImmediatePropagationStopped = returnTrue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2769 this.stopPropagation();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2770 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2771 isDefaultPrevented: returnFalse,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2772 isPropagationStopped: returnFalse,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2773 isImmediatePropagationStopped: returnFalse
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2774 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2775
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2776 // Checks if an event happened on an element within another element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2777 // Used in jQuery.event.special.mouseenter and mouseleave handlers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2778 var withinElement = function( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2779 // Check if mouse(over|out) are still within the same parent element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2780 var parent = event.relatedTarget;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2782 // Firefox sometimes assigns relatedTarget a XUL element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2783 // which we cannot access the parentNode property of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2784 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2785
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2786 // Chrome does something similar, the parentNode property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2787 // can be accessed but is null.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2788 if ( parent !== document && !parent.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2789 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2790 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2791 // Traverse up the tree
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2792 while ( parent && parent !== this ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2793 parent = parent.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2794 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2796 if ( parent !== this ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2797 // set the correct event type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2798 event.type = event.data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2799
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2800 // handle event if we actually just moused on to a non sub-element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2801 jQuery.event.handle.apply( this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2802 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2803
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2804 // assuming we've left the element since we most likely mousedover a xul element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2805 } catch(e) { }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2806 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2807
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2808 // In case of event delegation, we only need to rename the event.type,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2809 // liveHandler will take care of the rest.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2810 delegate = function( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2811 event.type = event.data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2812 jQuery.event.handle.apply( this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2813 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2814
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2815 // Create mouseenter and mouseleave events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2816 jQuery.each({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2817 mouseenter: "mouseover",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2818 mouseleave: "mouseout"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2819 }, function( orig, fix ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2820 jQuery.event.special[ orig ] = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2821 setup: function( data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2822 jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2823 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2824 teardown: function( data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2825 jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2826 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2827 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2828 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2829
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2830 // submit delegation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2831 if ( !jQuery.support.submitBubbles ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2832
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2833 jQuery.event.special.submit = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2834 setup: function( data, namespaces ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2835 if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2836 jQuery.event.add(this, "click.specialSubmit", function( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2837 var elem = e.target,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2838 type = elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2839
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2840 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2841 trigger( "submit", this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2842 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2843 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2844
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2845 jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2846 var elem = e.target,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2847 type = elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2848
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2849 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2850 trigger( "submit", this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2851 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2852 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2853
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2854 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2855 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2856 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2857 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2858
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2859 teardown: function( namespaces ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2860 jQuery.event.remove( this, ".specialSubmit" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2861 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2862 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2863
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2864 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2865
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2866 // change delegation, happens here so we have bind.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2867 if ( !jQuery.support.changeBubbles ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2868
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2869 var changeFilters,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2870
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2871 getVal = function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2872 var type = elem.type, val = elem.value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2873
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2874 if ( type === "radio" || type === "checkbox" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2875 val = elem.checked;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2876
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2877 } else if ( type === "select-multiple" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2878 val = elem.selectedIndex > -1 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2879 jQuery.map( elem.options, function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2880 return elem.selected;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2881 }).join("-") :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2882 "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2883
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2884 } else if ( elem.nodeName.toLowerCase() === "select" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2885 val = elem.selectedIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2886 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2888 return val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2889 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2890
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2891 testChange = function testChange( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2892 var elem = e.target, data, val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2893
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2894 if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2895 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2896 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2897
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2898 data = jQuery._data( elem, "_change_data" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2899 val = getVal(elem);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2900
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2901 // the current data will be also retrieved by beforeactivate
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2902 if ( e.type !== "focusout" || elem.type !== "radio" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2903 jQuery._data( elem, "_change_data", val );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2904 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2905
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2906 if ( data === undefined || val === data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2907 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2908 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2909
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2910 if ( data != null || val ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2911 e.type = "change";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2912 e.liveFired = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2913 jQuery.event.trigger( e, arguments[1], elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2914 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2915 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2916
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2917 jQuery.event.special.change = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2918 filters: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2919 focusout: testChange,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2920
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2921 beforedeactivate: testChange,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2922
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2923 click: function( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2924 var elem = e.target, type = elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2925
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2926 if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2927 testChange.call( this, e );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2928 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2929 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2930
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2931 // Change has to be called before submit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2932 // Keydown will be called before keypress, which is used in submit-event delegation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2933 keydown: function( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2934 var elem = e.target, type = elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2935
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2936 if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2937 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2938 type === "select-multiple" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2939 testChange.call( this, e );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2940 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2941 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2942
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2943 // Beforeactivate happens also before the previous element is blurred
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2944 // with this event you can't trigger a change event, but you can store
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2945 // information
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2946 beforeactivate: function( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2947 var elem = e.target;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2948 jQuery._data( elem, "_change_data", getVal(elem) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2949 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2950 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2951
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2952 setup: function( data, namespaces ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2953 if ( this.type === "file" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2954 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2955 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2956
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2957 for ( var type in changeFilters ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2958 jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2959 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2960
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2961 return rformElems.test( this.nodeName );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2962 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2963
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2964 teardown: function( namespaces ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2965 jQuery.event.remove( this, ".specialChange" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2966
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2967 return rformElems.test( this.nodeName );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2968 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2969 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2970
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2971 changeFilters = jQuery.event.special.change.filters;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2972
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2973 // Handle when the input is .focus()'d
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2974 changeFilters.focus = changeFilters.beforeactivate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2975 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2976
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2977 function trigger( type, elem, args ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2978 // Piggyback on a donor event to simulate a different one.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2979 // Fake originalEvent to avoid donor's stopPropagation, but if the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2980 // simulated event prevents default then we do the same on the donor.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2981 // Don't pass args or remember liveFired; they apply to the donor event.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2982 var event = jQuery.extend( {}, args[ 0 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2983 event.type = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2984 event.originalEvent = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2985 event.liveFired = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2986 jQuery.event.handle.call( elem, event );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2987 if ( event.isDefaultPrevented() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2988 args[ 0 ].preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2989 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2990 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2991
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2992 // Create "bubbling" focus and blur events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2993 if ( document.addEventListener ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2994 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2995 jQuery.event.special[ fix ] = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2996 setup: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2997 this.addEventListener( orig, handler, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2998 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2999 teardown: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3000 this.removeEventListener( orig, handler, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3001 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3002 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3004 function handler( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3005 e = jQuery.event.fix( e );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3006 e.type = fix;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3007 return jQuery.event.handle.call( this, e );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3008 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3009 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3010 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3011
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3012 jQuery.each(["bind", "one"], function( i, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3013 jQuery.fn[ name ] = function( type, data, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3014 // Handle object literals
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3015 if ( typeof type === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3016 for ( var key in type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3017 this[ name ](key, data, type[key], fn);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3018 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3019 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3020 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3021
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3022 if ( jQuery.isFunction( data ) || data === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3023 fn = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3024 data = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3025 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3026
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3027 var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3028 jQuery( this ).unbind( event, handler );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3029 return fn.apply( this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3030 }) : fn;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3031
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3032 if ( type === "unload" && name !== "one" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3033 this.one( type, data, fn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3034
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3035 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3036 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3037 jQuery.event.add( this[i], type, handler, data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3038 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3039 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3040
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3041 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3042 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3043 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3044
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3045 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3046 unbind: function( type, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3047 // Handle object literals
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3048 if ( typeof type === "object" && !type.preventDefault ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3049 for ( var key in type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3050 this.unbind(key, type[key]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3051 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3052
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3053 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3054 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3055 jQuery.event.remove( this[i], type, fn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3056 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3057 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3058
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3059 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3060 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3061
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3062 delegate: function( selector, types, data, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3063 return this.live( types, data, fn, selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3064 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3065
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3066 undelegate: function( selector, types, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3067 if ( arguments.length === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3068 return this.unbind( "live" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3069
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3070 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3071 return this.die( types, null, fn, selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3072 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3073 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3074
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3075 trigger: function( type, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3076 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3077 jQuery.event.trigger( type, data, this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3078 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3079 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3080
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3081 triggerHandler: function( type, data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3082 if ( this[0] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3083 var event = jQuery.Event( type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3084 event.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3085 event.stopPropagation();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3086 jQuery.event.trigger( event, data, this[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3087 return event.result;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3088 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3089 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3090
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3091 toggle: function( fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3092 // Save reference to arguments for access in closure
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3093 var args = arguments,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3094 i = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3095
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3096 // link all the functions, so any of them can unbind this click handler
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3097 while ( i < args.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3098 jQuery.proxy( fn, args[ i++ ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3099 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3100
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3101 return this.click( jQuery.proxy( fn, function( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3102 // Figure out which function to execute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3103 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3104 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3105
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3106 // Make sure that clicks stop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3107 event.preventDefault();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3108
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3109 // and execute the function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3110 return args[ lastToggle ].apply( this, arguments ) || false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3111 }));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3112 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3113
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3114 hover: function( fnOver, fnOut ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3115 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3116 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3117 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3118
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3119 var liveMap = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3120 focus: "focusin",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3121 blur: "focusout",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3122 mouseenter: "mouseover",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3123 mouseleave: "mouseout"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3124 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3126 jQuery.each(["live", "die"], function( i, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3127 jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3128 var type, i = 0, match, namespaces, preType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3129 selector = origSelector || this.selector,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3130 context = origSelector ? this : jQuery( this.context );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3131
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3132 if ( typeof types === "object" && !types.preventDefault ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3133 for ( var key in types ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3134 context[ name ]( key, data, types[key], selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3135 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3136
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3137 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3138 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3139
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3140 if ( jQuery.isFunction( data ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3141 fn = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3142 data = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3143 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3144
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3145 types = (types || "").split(" ");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3147 while ( (type = types[ i++ ]) != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3148 match = rnamespaces.exec( type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3149 namespaces = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3150
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3151 if ( match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3152 namespaces = match[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3153 type = type.replace( rnamespaces, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3154 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3155
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3156 if ( type === "hover" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3157 types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3158 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3159 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3160
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3161 preType = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3162
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3163 if ( type === "focus" || type === "blur" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3164 types.push( liveMap[ type ] + namespaces );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3165 type = type + namespaces;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3166
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3167 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3168 type = (liveMap[ type ] || type) + namespaces;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3169 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3170
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3171 if ( name === "live" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3172 // bind live handler
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3173 for ( var j = 0, l = context.length; j < l; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3174 jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3175 { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3176 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3177
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3178 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3179 // unbind live handler
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3180 context.unbind( "live." + liveConvert( type, selector ), fn );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3181 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3182 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3183
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3184 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3185 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3186 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3187
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3188 function liveHandler( event ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3189 var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3190 elems = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3191 selectors = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3192 events = jQuery._data( this, "events" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3193
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3194 // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3195 if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3196 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3197 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3198
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3199 if ( event.namespace ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3200 namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3201 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3202
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3203 event.liveFired = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3205 var live = events.live.slice(0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3206
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3207 for ( j = 0; j < live.length; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3208 handleObj = live[j];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3209
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3210 if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3211 selectors.push( handleObj.selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3212
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3213 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3214 live.splice( j--, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3215 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3216 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3217
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3218 match = jQuery( event.target ).closest( selectors, event.currentTarget );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3219
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3220 for ( i = 0, l = match.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3221 close = match[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3222
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3223 for ( j = 0; j < live.length; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3224 handleObj = live[j];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3225
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3226 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3227 elem = close.elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3228 related = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3230 // Those two events require additional checking
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3231 if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3232 event.type = handleObj.preType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3233 related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3234 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3235
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3236 if ( !related || related !== elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3237 elems.push({ elem: elem, handleObj: handleObj, level: close.level });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3238 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3239 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3240 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3241 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3242
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3243 for ( i = 0, l = elems.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3244 match = elems[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3245
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3246 if ( maxLevel && match.level > maxLevel ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3247 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3248 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3249
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3250 event.currentTarget = match.elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3251 event.data = match.handleObj.data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3252 event.handleObj = match.handleObj;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3253
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3254 ret = match.handleObj.origHandler.apply( match.elem, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3255
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3256 if ( ret === false || event.isPropagationStopped() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3257 maxLevel = match.level;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3258
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3259 if ( ret === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3260 stop = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3261 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3262 if ( event.isImmediatePropagationStopped() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3263 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3264 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3265 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3266 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3267
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3268 return stop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3269 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3270
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3271 function liveConvert( type, selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3272 return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3273 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3274
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3275 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3276 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3277 "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3278
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3279 // Handle event binding
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3280 jQuery.fn[ name ] = function( data, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3281 if ( fn == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3282 fn = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3283 data = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3284 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3285
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3286 return arguments.length > 0 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3287 this.bind( name, data, fn ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3288 this.trigger( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3289 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3290
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3291 if ( jQuery.attrFn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3292 jQuery.attrFn[ name ] = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3293 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3294 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3295
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3296
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3297 /*!
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3298 * Sizzle CSS Selector Engine
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3299 * Copyright 2011, The Dojo Foundation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3300 * Released under the MIT, BSD, and GPL Licenses.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3301 * More information: http://sizzlejs.com/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3302 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3303 (function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3304
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3305 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3306 done = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3307 toString = Object.prototype.toString,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3308 hasDuplicate = false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3309 baseHasDuplicate = true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3310 rBackslash = /\\/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3311 rNonWord = /\W/;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3313 // Here we check if the JavaScript engine is using some sort of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3314 // optimization where it does not always call our comparision
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3315 // function. If that is the case, discard the hasDuplicate value.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3316 // Thus far that includes Google Chrome.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3317 [0, 0].sort(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3318 baseHasDuplicate = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3319 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3320 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3321
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3322 var Sizzle = function( selector, context, results, seed ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3323 results = results || [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3324 context = context || document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3325
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3326 var origContext = context;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3327
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3328 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3329 return [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3330 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3331
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3332 if ( !selector || typeof selector !== "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3333 return results;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3334 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3335
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3336 var m, set, checkSet, extra, ret, cur, pop, i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3337 prune = true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3338 contextXML = Sizzle.isXML( context ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3339 parts = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3340 soFar = selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3341
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3342 // Reset the position of the chunker regexp (start from head)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3343 do {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3344 chunker.exec( "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3345 m = chunker.exec( soFar );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3346
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3347 if ( m ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3348 soFar = m[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3349
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3350 parts.push( m[1] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3351
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3352 if ( m[2] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3353 extra = m[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3354 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3355 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3356 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3357 } while ( m );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3358
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3359 if ( parts.length > 1 && origPOS.exec( selector ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3360
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3361 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3362 set = posProcess( parts[0] + parts[1], context );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3363
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3364 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3365 set = Expr.relative[ parts[0] ] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3366 [ context ] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3367 Sizzle( parts.shift(), context );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3368
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3369 while ( parts.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3370 selector = parts.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3371
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3372 if ( Expr.relative[ selector ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3373 selector += parts.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3374 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3375
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3376 set = posProcess( selector, set );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3377 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3378 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3380 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3381 // Take a shortcut and set the context if the root selector is an ID
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3382 // (but not if it'll be faster if the inner selector is an ID)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3383 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3384 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3385
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3386 ret = Sizzle.find( parts.shift(), context, contextXML );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3387 context = ret.expr ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3388 Sizzle.filter( ret.expr, ret.set )[0] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3389 ret.set[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3390 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3391
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3392 if ( context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3393 ret = seed ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3394 { expr: parts.pop(), set: makeArray(seed) } :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3395 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3396
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3397 set = ret.expr ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3398 Sizzle.filter( ret.expr, ret.set ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3399 ret.set;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3400
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3401 if ( parts.length > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3402 checkSet = makeArray( set );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3404 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3405 prune = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3406 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3407
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3408 while ( parts.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3409 cur = parts.pop();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3410 pop = cur;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3411
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3412 if ( !Expr.relative[ cur ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3413 cur = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3414 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3415 pop = parts.pop();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3416 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3417
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3418 if ( pop == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3419 pop = context;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3420 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3421
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3422 Expr.relative[ cur ]( checkSet, pop, contextXML );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3423 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3424
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3425 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3426 checkSet = parts = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3427 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3428 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3429
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3430 if ( !checkSet ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3431 checkSet = set;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3432 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3433
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3434 if ( !checkSet ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3435 Sizzle.error( cur || selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3436 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3437
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3438 if ( toString.call(checkSet) === "[object Array]" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3439 if ( !prune ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3440 results.push.apply( results, checkSet );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3441
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3442 } else if ( context && context.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3443 for ( i = 0; checkSet[i] != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3444 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3445 results.push( set[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3446 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3447 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3448
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3449 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3450 for ( i = 0; checkSet[i] != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3451 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3452 results.push( set[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3453 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3454 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3455 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3456
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3457 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3458 makeArray( checkSet, results );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3459 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3460
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3461 if ( extra ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3462 Sizzle( extra, origContext, results, seed );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3463 Sizzle.uniqueSort( results );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3464 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3465
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3466 return results;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3467 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3468
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3469 Sizzle.uniqueSort = function( results ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3470 if ( sortOrder ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3471 hasDuplicate = baseHasDuplicate;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3472 results.sort( sortOrder );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3473
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3474 if ( hasDuplicate ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3475 for ( var i = 1; i < results.length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3476 if ( results[i] === results[ i - 1 ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3477 results.splice( i--, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3478 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3479 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3480 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3481 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3482
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3483 return results;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3484 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3485
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3486 Sizzle.matches = function( expr, set ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3487 return Sizzle( expr, null, null, set );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3488 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3489
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3490 Sizzle.matchesSelector = function( node, expr ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3491 return Sizzle( expr, null, null, [node] ).length > 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3492 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3493
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3494 Sizzle.find = function( expr, context, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3495 var set;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3496
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3497 if ( !expr ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3498 return [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3499 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3500
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3501 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3502 var match,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3503 type = Expr.order[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3504
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3505 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3506 var left = match[1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3507 match.splice( 1, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3508
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3509 if ( left.substr( left.length - 1 ) !== "\\" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3510 match[1] = (match[1] || "").replace( rBackslash, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3511 set = Expr.find[ type ]( match, context, isXML );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3512
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3513 if ( set != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3514 expr = expr.replace( Expr.match[ type ], "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3515 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3516 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3517 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3518 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3519 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3520
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3521 if ( !set ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3522 set = typeof context.getElementsByTagName !== "undefined" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3523 context.getElementsByTagName( "*" ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3524 [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3525 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3526
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3527 return { set: set, expr: expr };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3528 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3529
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3530 Sizzle.filter = function( expr, set, inplace, not ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3531 var match, anyFound,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3532 old = expr,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3533 result = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3534 curLoop = set,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3535 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3536
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3537 while ( expr && set.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3538 for ( var type in Expr.filter ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3539 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3540 var found, item,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3541 filter = Expr.filter[ type ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3542 left = match[1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3543
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3544 anyFound = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3545
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3546 match.splice(1,1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3547
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3548 if ( left.substr( left.length - 1 ) === "\\" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3549 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3550 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3551
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3552 if ( curLoop === result ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3553 result = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3554 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3555
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3556 if ( Expr.preFilter[ type ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3557 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3558
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3559 if ( !match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3560 anyFound = found = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3562 } else if ( match === true ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3563 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3564 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3565 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3566
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3567 if ( match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3568 for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3569 if ( item ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3570 found = filter( item, match, i, curLoop );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3571 var pass = not ^ !!found;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3572
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3573 if ( inplace && found != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3574 if ( pass ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3575 anyFound = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3576
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3577 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3578 curLoop[i] = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3579 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3580
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3581 } else if ( pass ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3582 result.push( item );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3583 anyFound = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3584 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3585 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3586 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3587 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3588
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3589 if ( found !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3590 if ( !inplace ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3591 curLoop = result;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3592 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3593
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3594 expr = expr.replace( Expr.match[ type ], "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3595
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3596 if ( !anyFound ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3597 return [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3598 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3600 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3601 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3602 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3603 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3604
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3605 // Improper expression
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3606 if ( expr === old ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3607 if ( anyFound == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3608 Sizzle.error( expr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3609
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3610 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3611 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3612 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3613 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3614
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3615 old = expr;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3616 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3617
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3618 return curLoop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3619 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3620
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3621 Sizzle.error = function( msg ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3622 throw "Syntax error, unrecognized expression: " + msg;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3623 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3624
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3625 var Expr = Sizzle.selectors = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3626 order: [ "ID", "NAME", "TAG" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3627
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3628 match: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3629 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3630 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3631 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3632 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3633 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3634 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3635 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3636 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3637 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3638
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3639 leftMatch: {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3640
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3641 attrMap: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3642 "class": "className",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3643 "for": "htmlFor"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3644 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3645
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3646 attrHandle: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3647 href: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3648 return elem.getAttribute( "href" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3649 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3650 type: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3651 return elem.getAttribute( "type" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3652 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3653 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3654
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3655 relative: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3656 "+": function(checkSet, part){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3657 var isPartStr = typeof part === "string",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3658 isTag = isPartStr && !rNonWord.test( part ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3659 isPartStrNotTag = isPartStr && !isTag;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3660
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3661 if ( isTag ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3662 part = part.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3663 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3664
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3665 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3666 if ( (elem = checkSet[i]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3667 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3669 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3670 elem || false :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3671 elem === part;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3672 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3673 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3674
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3675 if ( isPartStrNotTag ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3676 Sizzle.filter( part, checkSet, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3677 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3678 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3679
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3680 ">": function( checkSet, part ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3681 var elem,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3682 isPartStr = typeof part === "string",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3683 i = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3684 l = checkSet.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3685
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3686 if ( isPartStr && !rNonWord.test( part ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3687 part = part.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3688
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3689 for ( ; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3690 elem = checkSet[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3691
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3692 if ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3693 var parent = elem.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3694 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3695 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3696 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3697
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3698 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3699 for ( ; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3700 elem = checkSet[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3701
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3702 if ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3703 checkSet[i] = isPartStr ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3704 elem.parentNode :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3705 elem.parentNode === part;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3706 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3707 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3708
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3709 if ( isPartStr ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3710 Sizzle.filter( part, checkSet, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3711 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3712 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3713 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3714
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3715 "": function(checkSet, part, isXML){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3716 var nodeCheck,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3717 doneName = done++,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3718 checkFn = dirCheck;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3719
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3720 if ( typeof part === "string" && !rNonWord.test( part ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3721 part = part.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3722 nodeCheck = part;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3723 checkFn = dirNodeCheck;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3724 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3725
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3726 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3727 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3728
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3729 "~": function( checkSet, part, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3730 var nodeCheck,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3731 doneName = done++,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3732 checkFn = dirCheck;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3733
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3734 if ( typeof part === "string" && !rNonWord.test( part ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3735 part = part.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3736 nodeCheck = part;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3737 checkFn = dirNodeCheck;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3738 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3739
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3740 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3741 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3742 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3743
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3744 find: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3745 ID: function( match, context, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3746 if ( typeof context.getElementById !== "undefined" && !isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3747 var m = context.getElementById(match[1]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3748 // Check parentNode to catch when Blackberry 4.6 returns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3749 // nodes that are no longer in the document #6963
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3750 return m && m.parentNode ? [m] : [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3751 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3752 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3753
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3754 NAME: function( match, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3755 if ( typeof context.getElementsByName !== "undefined" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3756 var ret = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3757 results = context.getElementsByName( match[1] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3758
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3759 for ( var i = 0, l = results.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3760 if ( results[i].getAttribute("name") === match[1] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3761 ret.push( results[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3762 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3763 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3764
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3765 return ret.length === 0 ? null : ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3766 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3767 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3768
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3769 TAG: function( match, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3770 if ( typeof context.getElementsByTagName !== "undefined" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3771 return context.getElementsByTagName( match[1] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3772 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3773 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3774 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3775 preFilter: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3776 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3777 match = " " + match[1].replace( rBackslash, "" ) + " ";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3778
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3779 if ( isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3780 return match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3781 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3782
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3783 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3784 if ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3785 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3786 if ( !inplace ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3787 result.push( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3788 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3789
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3790 } else if ( inplace ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3791 curLoop[i] = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3792 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3793 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3794 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3796 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3797 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3798
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3799 ID: function( match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3800 return match[1].replace( rBackslash, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3801 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3802
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3803 TAG: function( match, curLoop ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3804 return match[1].replace( rBackslash, "" ).toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3805 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3806
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3807 CHILD: function( match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3808 if ( match[1] === "nth" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3809 if ( !match[2] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3810 Sizzle.error( match[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3811 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3812
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3813 match[2] = match[2].replace(/^\+|\s*/g, '');
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3814
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3815 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3816 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3817 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3818 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3819
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3820 // calculate the numbers (first)n+(last) including if they are negative
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3821 match[2] = (test[1] + (test[2] || 1)) - 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3822 match[3] = test[3] - 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3823 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3824 else if ( match[2] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3825 Sizzle.error( match[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3826 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3827
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3828 // TODO: Move to normal caching system
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3829 match[0] = done++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3830
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3831 return match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3832 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3833
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3834 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3835 var name = match[1] = match[1].replace( rBackslash, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3836
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3837 if ( !isXML && Expr.attrMap[name] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3838 match[1] = Expr.attrMap[name];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3839 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3840
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3841 // Handle if an un-quoted value was used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3842 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3843
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3844 if ( match[2] === "~=" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3845 match[4] = " " + match[4] + " ";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3846 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3847
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3848 return match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3849 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3850
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3851 PSEUDO: function( match, curLoop, inplace, result, not ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3852 if ( match[1] === "not" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3853 // If we're dealing with a complex expression, or a simple one
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3854 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3855 match[3] = Sizzle(match[3], null, null, curLoop);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3856
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3857 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3858 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3859
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3860 if ( !inplace ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3861 result.push.apply( result, ret );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3862 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3863
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3864 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3865 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3866
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3867 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3868 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3869 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3870
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3871 return match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3872 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3873
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3874 POS: function( match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3875 match.unshift( true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3876
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3877 return match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3878 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3879 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3880
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3881 filters: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3882 enabled: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3883 return elem.disabled === false && elem.type !== "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3884 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3885
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3886 disabled: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3887 return elem.disabled === true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3888 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3889
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3890 checked: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3891 return elem.checked === true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3892 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3893
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3894 selected: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3895 // Accessing this property makes selected-by-default
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3896 // options in Safari work properly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3897 if ( elem.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3898 elem.parentNode.selectedIndex;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3899 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3900
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3901 return elem.selected === true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3902 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3903
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3904 parent: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3905 return !!elem.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3906 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3907
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3908 empty: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3909 return !elem.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3910 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3911
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3912 has: function( elem, i, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3913 return !!Sizzle( match[3], elem ).length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3914 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3915
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3916 header: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3917 return (/h\d/i).test( elem.nodeName );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3918 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3919
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3920 text: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3921 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3922 // use getAttribute instead to test this case
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3923 return "text" === elem.getAttribute( 'type' );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3924 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3925 radio: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3926 return "radio" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3927 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3928
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3929 checkbox: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3930 return "checkbox" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3931 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3932
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3933 file: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3934 return "file" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3935 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3936 password: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3937 return "password" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3938 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3939
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3940 submit: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3941 return "submit" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3942 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3943
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3944 image: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3945 return "image" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3946 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3947
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3948 reset: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3949 return "reset" === elem.type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3950 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3951
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3952 button: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3953 return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3954 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3955
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3956 input: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3957 return (/input|select|textarea|button/i).test( elem.nodeName );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3958 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3959 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3960 setFilters: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3961 first: function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3962 return i === 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3963 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3964
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3965 last: function( elem, i, match, array ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3966 return i === array.length - 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3967 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3968
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3969 even: function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3970 return i % 2 === 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3971 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3972
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3973 odd: function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3974 return i % 2 === 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3975 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3976
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3977 lt: function( elem, i, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3978 return i < match[3] - 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3979 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3980
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3981 gt: function( elem, i, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3982 return i > match[3] - 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3983 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3984
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3985 nth: function( elem, i, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3986 return match[3] - 0 === i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3987 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3988
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3989 eq: function( elem, i, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3990 return match[3] - 0 === i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3991 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3992 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3993 filter: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3994 PSEUDO: function( elem, match, i, array ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3995 var name = match[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3996 filter = Expr.filters[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3997
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3998 if ( filter ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3999 return filter( elem, i, match, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4000
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4001 } else if ( name === "contains" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4002 return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4004 } else if ( name === "not" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4005 var not = match[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4006
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4007 for ( var j = 0, l = not.length; j < l; j++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4008 if ( not[j] === elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4009 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4010 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4011 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4012
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4013 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4014
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4015 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4016 Sizzle.error( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4017 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4018 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4019
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4020 CHILD: function( elem, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4021 var type = match[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4022 node = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4023
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4024 switch ( type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4025 case "only":
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4026 case "first":
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4027 while ( (node = node.previousSibling) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4028 if ( node.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4029 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4030 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4031 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4032
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4033 if ( type === "first" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4034 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4035 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4036
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4037 node = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4038
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4039 case "last":
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4040 while ( (node = node.nextSibling) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4041 if ( node.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4042 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4043 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4044 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4045
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4046 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4047
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4048 case "nth":
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4049 var first = match[2],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4050 last = match[3];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4051
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4052 if ( first === 1 && last === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4053 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4054 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4055
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4056 var doneName = match[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4057 parent = elem.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4058
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4059 if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4060 var count = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4061
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4062 for ( node = parent.firstChild; node; node = node.nextSibling ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4063 if ( node.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4064 node.nodeIndex = ++count;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4065 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4066 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4067
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4068 parent.sizcache = doneName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4069 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4070
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4071 var diff = elem.nodeIndex - last;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4072
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4073 if ( first === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4074 return diff === 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4075
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4076 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4077 return ( diff % first === 0 && diff / first >= 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4078 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4079 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4080 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4081
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4082 ID: function( elem, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4083 return elem.nodeType === 1 && elem.getAttribute("id") === match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4084 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4085
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4086 TAG: function( elem, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4087 return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4088 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4089
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4090 CLASS: function( elem, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4091 return (" " + (elem.className || elem.getAttribute("class")) + " ")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4092 .indexOf( match ) > -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4093 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4094
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4095 ATTR: function( elem, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4096 var name = match[1],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4097 result = Expr.attrHandle[ name ] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4098 Expr.attrHandle[ name ]( elem ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4099 elem[ name ] != null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4100 elem[ name ] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4101 elem.getAttribute( name ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4102 value = result + "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4103 type = match[2],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4104 check = match[4];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4105
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4106 return result == null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4107 type === "!=" :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4108 type === "=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4109 value === check :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4110 type === "*=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4111 value.indexOf(check) >= 0 :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4112 type === "~=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4113 (" " + value + " ").indexOf(check) >= 0 :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4114 !check ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4115 value && result !== false :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4116 type === "!=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4117 value !== check :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4118 type === "^=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4119 value.indexOf(check) === 0 :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4120 type === "$=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4121 value.substr(value.length - check.length) === check :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4122 type === "|=" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4123 value === check || value.substr(0, check.length + 1) === check + "-" :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4124 false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4125 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4126
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4127 POS: function( elem, match, i, array ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4128 var name = match[2],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4129 filter = Expr.setFilters[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4130
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4131 if ( filter ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4132 return filter( elem, i, match, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4133 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4134 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4135 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4136 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4137
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4138 var origPOS = Expr.match.POS,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4139 fescape = function(all, num){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4140 return "\\" + (num - 0 + 1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4141 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4142
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4143 for ( var type in Expr.match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4144 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4145 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4146 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4147
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4148 var makeArray = function( array, results ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4149 array = Array.prototype.slice.call( array, 0 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4150
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4151 if ( results ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4152 results.push.apply( results, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4153 return results;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4154 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4155
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4156 return array;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4157 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4158
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4159 // Perform a simple check to determine if the browser is capable of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4160 // converting a NodeList to an array using builtin methods.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4161 // Also verifies that the returned array holds DOM nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4162 // (which is not the case in the Blackberry browser)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4163 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4164 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4165
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4166 // Provide a fallback method if it does not work
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4167 } catch( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4168 makeArray = function( array, results ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4169 var i = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4170 ret = results || [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4172 if ( toString.call(array) === "[object Array]" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4173 Array.prototype.push.apply( ret, array );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4174
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4175 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4176 if ( typeof array.length === "number" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4177 for ( var l = array.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4178 ret.push( array[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4179 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4180
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4181 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4182 for ( ; array[i]; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4183 ret.push( array[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4184 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4185 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4186 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4187
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4188 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4189 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4190 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4191
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4192 var sortOrder, siblingCheck;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4193
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4194 if ( document.documentElement.compareDocumentPosition ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4195 sortOrder = function( a, b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4196 if ( a === b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4197 hasDuplicate = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4198 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4199 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4200
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4201 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4202 return a.compareDocumentPosition ? -1 : 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4203 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4205 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4206 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4207
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4208 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4209 sortOrder = function( a, b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4210 var al, bl,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4211 ap = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4212 bp = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4213 aup = a.parentNode,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4214 bup = b.parentNode,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4215 cur = aup;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4216
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4217 // The nodes are identical, we can exit early
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4218 if ( a === b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4219 hasDuplicate = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4220 return 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4221
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4222 // If the nodes are siblings (or identical) we can do a quick check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4223 } else if ( aup === bup ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4224 return siblingCheck( a, b );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4225
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4226 // If no parents were found then the nodes are disconnected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4227 } else if ( !aup ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4228 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4230 } else if ( !bup ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4231 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4232 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4233
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4234 // Otherwise they're somewhere else in the tree so we need
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4235 // to build up a full list of the parentNodes for comparison
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4236 while ( cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4237 ap.unshift( cur );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4238 cur = cur.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4239 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4241 cur = bup;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4242
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4243 while ( cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4244 bp.unshift( cur );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4245 cur = cur.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4246 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4247
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4248 al = ap.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4249 bl = bp.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4250
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4251 // Start walking down the tree looking for a discrepancy
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4252 for ( var i = 0; i < al && i < bl; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4253 if ( ap[i] !== bp[i] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4254 return siblingCheck( ap[i], bp[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4255 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4256 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4257
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4258 // We ended someplace up the tree so do a sibling check
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4259 return i === al ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4260 siblingCheck( a, bp[i], -1 ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4261 siblingCheck( ap[i], b, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4262 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4263
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4264 siblingCheck = function( a, b, ret ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4265 if ( a === b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4266 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4267 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4268
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4269 var cur = a.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4270
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4271 while ( cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4272 if ( cur === b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4273 return -1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4274 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4276 cur = cur.nextSibling;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4277 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4278
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4279 return 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4280 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4281 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4282
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4283 // Utility function for retreiving the text value of an array of DOM nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4284 Sizzle.getText = function( elems ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4285 var ret = "", elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4286
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4287 for ( var i = 0; elems[i]; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4288 elem = elems[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4289
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4290 // Get the text from text nodes and CDATA nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4291 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4292 ret += elem.nodeValue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4293
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4294 // Traverse everything else, except comment nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4295 } else if ( elem.nodeType !== 8 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4296 ret += Sizzle.getText( elem.childNodes );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4297 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4298 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4299
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4300 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4301 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4302
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4303 // Check to see if the browser returns elements by name when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4304 // querying by getElementById (and provide a workaround)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4305 (function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4306 // We're going to inject a fake input element with a specified name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4307 var form = document.createElement("div"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4308 id = "script" + (new Date()).getTime(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4309 root = document.documentElement;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4310
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4311 form.innerHTML = "<a name='" + id + "'/>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4313 // Inject it into the root element, check its status, and remove it quickly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4314 root.insertBefore( form, root.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4315
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4316 // The workaround has to do additional checks after a getElementById
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4317 // Which slows things down for other browsers (hence the branching)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4318 if ( document.getElementById( id ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4319 Expr.find.ID = function( match, context, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4320 if ( typeof context.getElementById !== "undefined" && !isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4321 var m = context.getElementById(match[1]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4322
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4323 return m ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4324 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4325 [m] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4326 undefined :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4327 [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4328 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4329 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4330
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4331 Expr.filter.ID = function( elem, match ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4332 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4333
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4334 return elem.nodeType === 1 && node && node.nodeValue === match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4335 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4336 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4337
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4338 root.removeChild( form );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4339
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4340 // release memory in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4341 root = form = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4342 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4343
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4344 (function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4345 // Check to see if the browser returns only elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4346 // when doing getElementsByTagName("*")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4347
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4348 // Create a fake element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4349 var div = document.createElement("div");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4350 div.appendChild( document.createComment("") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4351
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4352 // Make sure no comments are found
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4353 if ( div.getElementsByTagName("*").length > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4354 Expr.find.TAG = function( match, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4355 var results = context.getElementsByTagName( match[1] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4356
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4357 // Filter out possible comments
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4358 if ( match[1] === "*" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4359 var tmp = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4360
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4361 for ( var i = 0; results[i]; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4362 if ( results[i].nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4363 tmp.push( results[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4364 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4365 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4366
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4367 results = tmp;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4368 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4369
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4370 return results;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4371 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4373
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4374 // Check to see if an attribute returns normalized href attributes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4375 div.innerHTML = "<a href='#'></a>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4376
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4377 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4378 div.firstChild.getAttribute("href") !== "#" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4380 Expr.attrHandle.href = function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4381 return elem.getAttribute( "href", 2 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4382 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4383 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4384
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4385 // release memory in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4386 div = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4387 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4388
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4389 if ( document.querySelectorAll ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4390 (function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4391 var oldSizzle = Sizzle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4392 div = document.createElement("div"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4393 id = "__sizzle__";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4394
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4395 div.innerHTML = "<p class='TEST'></p>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4396
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4397 // Safari can't handle uppercase or unicode characters when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4398 // in quirks mode.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4399 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4400 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4401 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4402
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4403 Sizzle = function( query, context, extra, seed ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4404 context = context || document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4405
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4406 // Only use querySelectorAll on non-XML documents
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4407 // (ID selectors don't work in non-HTML documents)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4408 if ( !seed && !Sizzle.isXML(context) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4409 // See if we find a selector to speed up
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4410 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4411
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4412 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4413 // Speed-up: Sizzle("TAG")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4414 if ( match[1] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4415 return makeArray( context.getElementsByTagName( query ), extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4416
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4417 // Speed-up: Sizzle(".CLASS")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4418 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4419 return makeArray( context.getElementsByClassName( match[2] ), extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4420 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4421 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4422
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4423 if ( context.nodeType === 9 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4424 // Speed-up: Sizzle("body")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4425 // The body element only exists once, optimize finding it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4426 if ( query === "body" && context.body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4427 return makeArray( [ context.body ], extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4428
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4429 // Speed-up: Sizzle("#ID")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4430 } else if ( match && match[3] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4431 var elem = context.getElementById( match[3] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4432
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4433 // Check parentNode to catch when Blackberry 4.6 returns
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4434 // nodes that are no longer in the document #6963
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4435 if ( elem && elem.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4436 // Handle the case where IE and Opera return items
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4437 // by name instead of ID
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4438 if ( elem.id === match[3] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4439 return makeArray( [ elem ], extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4440 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4441
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4442 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4443 return makeArray( [], extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4444 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4445 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4446
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4447 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4448 return makeArray( context.querySelectorAll(query), extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4449 } catch(qsaError) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4450
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4451 // qSA works strangely on Element-rooted queries
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4452 // We can work around this by specifying an extra ID on the root
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4453 // and working up from there (Thanks to Andrew Dupont for the technique)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4454 // IE 8 doesn't work on object elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4455 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4456 var oldContext = context,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4457 old = context.getAttribute( "id" ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4458 nid = old || id,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4459 hasParent = context.parentNode,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4460 relativeHierarchySelector = /^\s*[+~]/.test( query );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4461
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4462 if ( !old ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4463 context.setAttribute( "id", nid );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4464 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4465 nid = nid.replace( /'/g, "\\$&" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4466 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4467 if ( relativeHierarchySelector && hasParent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4468 context = context.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4469 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4471 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4472 if ( !relativeHierarchySelector || hasParent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4473 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4474 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4475
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4476 } catch(pseudoError) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4477 } finally {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4478 if ( !old ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4479 oldContext.removeAttribute( "id" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4480 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4481 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4482 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4483 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4484
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4485 return oldSizzle(query, context, extra, seed);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4486 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4487
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4488 for ( var prop in oldSizzle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4489 Sizzle[ prop ] = oldSizzle[ prop ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4490 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4491
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4492 // release memory in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4493 div = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4494 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4495 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4496
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4497 (function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4498 var html = document.documentElement,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4499 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4500 pseudoWorks = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4501
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4502 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4503 // This should fail with an exception
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4504 // Gecko does not error, returns false instead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4505 matches.call( document.documentElement, "[test!='']:sizzle" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4506
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4507 } catch( pseudoError ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4508 pseudoWorks = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4509 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4510
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4511 if ( matches ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4512 Sizzle.matchesSelector = function( node, expr ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4513 // Make sure that attribute selectors are quoted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4514 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4515
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4516 if ( !Sizzle.isXML( node ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4517 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4518 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4519 return matches.call( node, expr );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4520 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4521 } catch(e) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4522 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4523
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4524 return Sizzle(expr, null, null, [node]).length > 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4525 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4526 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4527 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4528
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4529 (function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4530 var div = document.createElement("div");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4531
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4532 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4533
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4534 // Opera can't find a second classname (in 9.6)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4535 // Also, make sure that getElementsByClassName actually exists
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4536 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4537 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4538 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4540 // Safari caches class attributes, doesn't catch changes (in 3.2)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4541 div.lastChild.className = "e";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4542
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4543 if ( div.getElementsByClassName("e").length === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4544 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4545 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4546
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4547 Expr.order.splice(1, 0, "CLASS");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4548 Expr.find.CLASS = function( match, context, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4549 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4550 return context.getElementsByClassName(match[1]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4551 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4552 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4554 // release memory in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4555 div = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4556 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4557
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4558 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4559 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4560 var elem = checkSet[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4561
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4562 if ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4563 var match = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4564
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4565 elem = elem[dir];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4566
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4567 while ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4568 if ( elem.sizcache === doneName ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4569 match = checkSet[elem.sizset];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4570 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4571 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4572
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4573 if ( elem.nodeType === 1 && !isXML ){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4574 elem.sizcache = doneName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4575 elem.sizset = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4576 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4577
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4578 if ( elem.nodeName.toLowerCase() === cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4579 match = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4580 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4581 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4582
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4583 elem = elem[dir];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4584 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4585
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4586 checkSet[i] = match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4587 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4588 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4589 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4590
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4591 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4592 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4593 var elem = checkSet[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4594
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4595 if ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4596 var match = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4597
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4598 elem = elem[dir];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4600 while ( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4601 if ( elem.sizcache === doneName ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4602 match = checkSet[elem.sizset];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4603 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4604 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4605
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4606 if ( elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4607 if ( !isXML ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4608 elem.sizcache = doneName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4609 elem.sizset = i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4610 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4611
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4612 if ( typeof cur !== "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4613 if ( elem === cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4614 match = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4615 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4616 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4617
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4618 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4619 match = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4620 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4621 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4622 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4623
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4624 elem = elem[dir];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4625 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4626
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4627 checkSet[i] = match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4628 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4629 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4630 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4631
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4632 if ( document.documentElement.contains ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4633 Sizzle.contains = function( a, b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4634 return a !== b && (a.contains ? a.contains(b) : true);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4635 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4636
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4637 } else if ( document.documentElement.compareDocumentPosition ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4638 Sizzle.contains = function( a, b ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4639 return !!(a.compareDocumentPosition(b) & 16);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4640 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4641
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4642 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4643 Sizzle.contains = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4644 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4645 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4646 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4647
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4648 Sizzle.isXML = function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4649 // documentElement is verified for cases where it doesn't yet exist
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4650 // (such as loading iframes in IE - #4833)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4651 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4653 return documentElement ? documentElement.nodeName !== "HTML" : false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4654 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4655
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4656 var posProcess = function( selector, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4657 var match,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4658 tmpSet = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4659 later = "",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4660 root = context.nodeType ? [context] : context;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4661
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4662 // Position selectors must be done after the filter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4663 // And so must :not(positional) so we move all PSEUDOs to the end
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4664 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4665 later += match[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4666 selector = selector.replace( Expr.match.PSEUDO, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4667 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4669 selector = Expr.relative[selector] ? selector + "*" : selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4670
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4671 for ( var i = 0, l = root.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4672 Sizzle( selector, root[i], tmpSet );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4673 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4674
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4675 return Sizzle.filter( later, tmpSet );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4676 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4677
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4678 // EXPOSE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4679 jQuery.find = Sizzle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4680 jQuery.expr = Sizzle.selectors;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4681 jQuery.expr[":"] = jQuery.expr.filters;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4682 jQuery.unique = Sizzle.uniqueSort;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4683 jQuery.text = Sizzle.getText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4684 jQuery.isXMLDoc = Sizzle.isXML;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4685 jQuery.contains = Sizzle.contains;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4686
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4687
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4688 })();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4689
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4690
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4691 var runtil = /Until$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4692 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4693 // Note: This RegExp should be improved, or likely pulled from Sizzle
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4694 rmultiselector = /,/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4695 isSimple = /^.[^:#\[\.,]*$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4696 slice = Array.prototype.slice,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4697 POS = jQuery.expr.match.POS,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4698 // methods guaranteed to produce a unique set when starting from a unique set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4699 guaranteedUnique = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4700 children: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4701 contents: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4702 next: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4703 prev: true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4704 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4705
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4706 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4707 find: function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4708 var ret = this.pushStack( "", "find", selector ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4709 length = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4710
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4711 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4712 length = ret.length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4713 jQuery.find( selector, this[i], ret );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4714
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4715 if ( i > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4716 // Make sure that the results are unique
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4717 for ( var n = length; n < ret.length; n++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4718 for ( var r = 0; r < length; r++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4719 if ( ret[r] === ret[n] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4720 ret.splice(n--, 1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4721 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4722 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4723 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4724 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4725 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4726 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4727
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4728 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4729 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4730
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4731 has: function( target ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4732 var targets = jQuery( target );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4733 return this.filter(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4734 for ( var i = 0, l = targets.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4735 if ( jQuery.contains( this, targets[i] ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4736 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4737 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4738 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4739 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4740 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4741
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4742 not: function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4743 return this.pushStack( winnow(this, selector, false), "not", selector);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4744 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4745
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4746 filter: function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4747 return this.pushStack( winnow(this, selector, true), "filter", selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4748 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4749
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4750 is: function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4751 return !!selector && jQuery.filter( selector, this ).length > 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4752 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4753
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4754 closest: function( selectors, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4755 var ret = [], i, l, cur = this[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4756
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4757 if ( jQuery.isArray( selectors ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4758 var match, selector,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4759 matches = {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4760 level = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4761
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4762 if ( cur && selectors.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4763 for ( i = 0, l = selectors.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4764 selector = selectors[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4766 if ( !matches[selector] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4767 matches[selector] = jQuery.expr.match.POS.test( selector ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4768 jQuery( selector, context || this.context ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4769 selector;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4770 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4771 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4772
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4773 while ( cur && cur.ownerDocument && cur !== context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4774 for ( selector in matches ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4775 match = matches[selector];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4776
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4777 if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4778 ret.push({ selector: selector, elem: cur, level: level });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4779 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4780 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4782 cur = cur.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4783 level++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4784 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4785 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4786
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4787 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4788 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4789
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4790 var pos = POS.test( selectors ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4791 jQuery( selectors, context || this.context ) : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4792
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4793 for ( i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4794 cur = this[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4795
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4796 while ( cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4797 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4798 ret.push( cur );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4799 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4800
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4801 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4802 cur = cur.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4803 if ( !cur || !cur.ownerDocument || cur === context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4804 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4805 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4806 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4807 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4808 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4809
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4810 ret = ret.length > 1 ? jQuery.unique(ret) : ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4811
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4812 return this.pushStack( ret, "closest", selectors );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4813 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4814
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4815 // Determine the position of an element within
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4816 // the matched set of elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4817 index: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4818 if ( !elem || typeof elem === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4819 return jQuery.inArray( this[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4820 // If it receives a string, the selector is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4821 // If it receives nothing, the siblings are used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4822 elem ? jQuery( elem ) : this.parent().children() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4823 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4824 // Locate the position of the desired element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4825 return jQuery.inArray(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4826 // If it receives a jQuery object, the first element is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4827 elem.jquery ? elem[0] : elem, this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4828 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4829
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4830 add: function( selector, context ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4831 var set = typeof selector === "string" ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4832 jQuery( selector, context ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4833 jQuery.makeArray( selector ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4834 all = jQuery.merge( this.get(), set );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4835
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4836 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4837 all :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4838 jQuery.unique( all ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4839 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4840
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4841 andSelf: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4842 return this.add( this.prevObject );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4843 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4844 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4845
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4846 // A painfully simple check to see if an element is disconnected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4847 // from a document (should be improved, where feasible).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4848 function isDisconnected( node ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4849 return !node || !node.parentNode || node.parentNode.nodeType === 11;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4850 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4851
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4852 jQuery.each({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4853 parent: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4854 var parent = elem.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4855 return parent && parent.nodeType !== 11 ? parent : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4856 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4857 parents: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4858 return jQuery.dir( elem, "parentNode" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4859 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4860 parentsUntil: function( elem, i, until ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4861 return jQuery.dir( elem, "parentNode", until );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4862 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4863 next: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4864 return jQuery.nth( elem, 2, "nextSibling" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4865 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4866 prev: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4867 return jQuery.nth( elem, 2, "previousSibling" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4868 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4869 nextAll: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4870 return jQuery.dir( elem, "nextSibling" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4871 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4872 prevAll: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4873 return jQuery.dir( elem, "previousSibling" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4874 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4875 nextUntil: function( elem, i, until ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4876 return jQuery.dir( elem, "nextSibling", until );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4877 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4878 prevUntil: function( elem, i, until ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4879 return jQuery.dir( elem, "previousSibling", until );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4880 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4881 siblings: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4882 return jQuery.sibling( elem.parentNode.firstChild, elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4883 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4884 children: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4885 return jQuery.sibling( elem.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4886 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4887 contents: function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4888 return jQuery.nodeName( elem, "iframe" ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4889 elem.contentDocument || elem.contentWindow.document :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4890 jQuery.makeArray( elem.childNodes );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4891 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4892 }, function( name, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4893 jQuery.fn[ name ] = function( until, selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4894 var ret = jQuery.map( this, fn, until ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4895 // The variable 'args' was introduced in
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4896 // https://github.com/jquery/jquery/commit/52a0238
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4897 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4898 // http://code.google.com/p/v8/issues/detail?id=1050
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4899 args = slice.call(arguments);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4900
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4901 if ( !runtil.test( name ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4902 selector = until;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4903 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4904
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4905 if ( selector && typeof selector === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4906 ret = jQuery.filter( selector, ret );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4907 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4908
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4909 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4910
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4911 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4912 ret = ret.reverse();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4913 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4914
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4915 return this.pushStack( ret, name, args.join(",") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4916 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4917 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4918
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4919 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4920 filter: function( expr, elems, not ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4921 if ( not ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4922 expr = ":not(" + expr + ")";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4923 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4924
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4925 return elems.length === 1 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4926 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4927 jQuery.find.matches(expr, elems);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4928 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4929
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4930 dir: function( elem, dir, until ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4931 var matched = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4932 cur = elem[ dir ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4933
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4934 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4935 if ( cur.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4936 matched.push( cur );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4937 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4938 cur = cur[dir];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4939 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4940 return matched;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4941 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4942
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4943 nth: function( cur, result, dir, elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4944 result = result || 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4945 var num = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4946
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4947 for ( ; cur; cur = cur[dir] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4948 if ( cur.nodeType === 1 && ++num === result ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4949 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4950 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4951 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4952
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4953 return cur;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4954 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4955
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4956 sibling: function( n, elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4957 var r = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4958
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4959 for ( ; n; n = n.nextSibling ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4960 if ( n.nodeType === 1 && n !== elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4961 r.push( n );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4962 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4963 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4964
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4965 return r;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4966 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4967 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4968
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4969 // Implement the identical functionality for filter and not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4970 function winnow( elements, qualifier, keep ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4971 if ( jQuery.isFunction( qualifier ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4972 return jQuery.grep(elements, function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4973 var retVal = !!qualifier.call( elem, i, elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4974 return retVal === keep;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4975 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4976
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4977 } else if ( qualifier.nodeType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4978 return jQuery.grep(elements, function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4979 return (elem === qualifier) === keep;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4980 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4981
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4982 } else if ( typeof qualifier === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4983 var filtered = jQuery.grep(elements, function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4984 return elem.nodeType === 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4985 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4986
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4987 if ( isSimple.test( qualifier ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4988 return jQuery.filter(qualifier, filtered, !keep);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4989 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4990 qualifier = jQuery.filter( qualifier, filtered );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4991 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4992 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4993
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4994 return jQuery.grep(elements, function( elem, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4995 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4996 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4997 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4998
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4999
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5000
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5001
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5002 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5003 rleadingWhitespace = /^\s+/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5004 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5005 rtagName = /<([\w:]+)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5006 rtbody = /<tbody/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5007 rhtml = /<|&#?\w+;/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5008 rnocache = /<(?:script|object|embed|option|style)/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5009 // checked="checked" or checked
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5010 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5011 wrapMap = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5012 option: [ 1, "<select multiple='multiple'>", "</select>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5013 legend: [ 1, "<fieldset>", "</fieldset>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5014 thead: [ 1, "<table>", "</table>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5015 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5016 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5017 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5018 area: [ 1, "<map>", "</map>" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5019 _default: [ 0, "", "" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5020 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5021
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5022 wrapMap.optgroup = wrapMap.option;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5023 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5024 wrapMap.th = wrapMap.td;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5025
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5026 // IE can't serialize <link> and <script> tags normally
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5027 if ( !jQuery.support.htmlSerialize ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5028 wrapMap._default = [ 1, "div<div>", "</div>" ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5029 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5030
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5031 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5032 text: function( text ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5033 if ( jQuery.isFunction(text) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5034 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5035 var self = jQuery( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5036
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5037 self.text( text.call(this, i, self.text()) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5038 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5039 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5040
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5041 if ( typeof text !== "object" && text !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5042 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5043 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5044
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5045 return jQuery.text( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5046 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5047
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5048 wrapAll: function( html ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5049 if ( jQuery.isFunction( html ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5050 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5051 jQuery(this).wrapAll( html.call(this, i) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5052 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5053 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5054
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5055 if ( this[0] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5056 // The elements to wrap the target around
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5057 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5058
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5059 if ( this[0].parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5060 wrap.insertBefore( this[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5061 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5062
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5063 wrap.map(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5064 var elem = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5065
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5066 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5067 elem = elem.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5068 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5069
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5070 return elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5071 }).append(this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5072 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5073
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5074 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5075 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5076
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5077 wrapInner: function( html ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5078 if ( jQuery.isFunction( html ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5079 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5080 jQuery(this).wrapInner( html.call(this, i) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5081 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5082 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5083
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5084 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5085 var self = jQuery( this ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5086 contents = self.contents();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5087
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5088 if ( contents.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5089 contents.wrapAll( html );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5090
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5091 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5092 self.append( html );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5093 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5094 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5095 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5096
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5097 wrap: function( html ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5098 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5099 jQuery( this ).wrapAll( html );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5100 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5101 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5102
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5103 unwrap: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5104 return this.parent().each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5105 if ( !jQuery.nodeName( this, "body" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5106 jQuery( this ).replaceWith( this.childNodes );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5107 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5108 }).end();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5109 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5110
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5111 append: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5112 return this.domManip(arguments, true, function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5113 if ( this.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5114 this.appendChild( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5115 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5116 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5117 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5118
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5119 prepend: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5120 return this.domManip(arguments, true, function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5121 if ( this.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5122 this.insertBefore( elem, this.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5123 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5124 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5125 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5126
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5127 before: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5128 if ( this[0] && this[0].parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5129 return this.domManip(arguments, false, function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5130 this.parentNode.insertBefore( elem, this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5131 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5132 } else if ( arguments.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5133 var set = jQuery(arguments[0]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5134 set.push.apply( set, this.toArray() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5135 return this.pushStack( set, "before", arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5136 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5137 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5138
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5139 after: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5140 if ( this[0] && this[0].parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5141 return this.domManip(arguments, false, function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5142 this.parentNode.insertBefore( elem, this.nextSibling );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5143 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5144 } else if ( arguments.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5145 var set = this.pushStack( this, "after", arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5146 set.push.apply( set, jQuery(arguments[0]).toArray() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5147 return set;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5148 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5149 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5150
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5151 // keepData is for internal use only--do not document
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5152 remove: function( selector, keepData ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5153 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5154 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5155 if ( !keepData && elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5156 jQuery.cleanData( elem.getElementsByTagName("*") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5157 jQuery.cleanData( [ elem ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5158 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5159
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5160 if ( elem.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5161 elem.parentNode.removeChild( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5162 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5163 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5164 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5165
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5166 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5167 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5168
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5169 empty: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5170 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5171 // Remove element nodes and prevent memory leaks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5172 if ( elem.nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5173 jQuery.cleanData( elem.getElementsByTagName("*") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5174 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5175
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5176 // Remove any remaining nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5177 while ( elem.firstChild ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5178 elem.removeChild( elem.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5179 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5180 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5181
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5182 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5183 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5184
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5185 clone: function( dataAndEvents, deepDataAndEvents ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5186 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5187 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5188
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5189 return this.map( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5190 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5191 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5192 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5193
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5194 html: function( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5195 if ( value === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5196 return this[0] && this[0].nodeType === 1 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5197 this[0].innerHTML.replace(rinlinejQuery, "") :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5198 null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5199
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5200 // See if we can take a shortcut and just use innerHTML
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5201 } else if ( typeof value === "string" && !rnocache.test( value ) &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5202 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5203 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5205 value = value.replace(rxhtmlTag, "<$1></$2>");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5206
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5207 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5208 for ( var i = 0, l = this.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5209 // Remove element nodes and prevent memory leaks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5210 if ( this[i].nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5211 jQuery.cleanData( this[i].getElementsByTagName("*") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5212 this[i].innerHTML = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5213 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5214 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5215
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5216 // If using innerHTML throws an exception, use the fallback method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5217 } catch(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5218 this.empty().append( value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5219 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5220
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5221 } else if ( jQuery.isFunction( value ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5222 this.each(function(i){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5223 var self = jQuery( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5224
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5225 self.html( value.call(this, i, self.html()) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5226 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5227
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5228 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5229 this.empty().append( value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5230 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5231
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5232 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5233 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5234
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5235 replaceWith: function( value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5236 if ( this[0] && this[0].parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5237 // Make sure that the elements are removed from the DOM before they are inserted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5238 // this can help fix replacing a parent with child elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5239 if ( jQuery.isFunction( value ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5240 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5241 var self = jQuery(this), old = self.html();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5242 self.replaceWith( value.call( this, i, old ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5243 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5244 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5245
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5246 if ( typeof value !== "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5247 value = jQuery( value ).detach();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5248 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5249
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5250 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5251 var next = this.nextSibling,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5252 parent = this.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5253
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5254 jQuery( this ).remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5255
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5256 if ( next ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5257 jQuery(next).before( value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5258 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5259 jQuery(parent).append( value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5260 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5261 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5262 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5263 return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5264 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5265 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5266
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5267 detach: function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5268 return this.remove( selector, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5269 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5270
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5271 domManip: function( args, table, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5272 var results, first, fragment, parent,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5273 value = args[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5274 scripts = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5276 // We can't cloneNode fragments that contain checked, in WebKit
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5277 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5278 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5279 jQuery(this).domManip( args, table, callback, true );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5280 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5281 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5282
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5283 if ( jQuery.isFunction(value) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5284 return this.each(function(i) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5285 var self = jQuery(this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5286 args[0] = value.call(this, i, table ? self.html() : undefined);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5287 self.domManip( args, table, callback );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5288 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5289 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5290
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5291 if ( this[0] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5292 parent = value && value.parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5293
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5294 // If we're in a fragment, just use that instead of building a new one
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5295 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5296 results = { fragment: parent };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5297
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5298 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5299 results = jQuery.buildFragment( args, this, scripts );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5300 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5301
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5302 fragment = results.fragment;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5303
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5304 if ( fragment.childNodes.length === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5305 first = fragment = fragment.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5306 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5307 first = fragment.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5308 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5309
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5310 if ( first ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5311 table = table && jQuery.nodeName( first, "tr" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5313 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5314 callback.call(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5315 table ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5316 root(this[i], first) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5317 this[i],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5318 // Make sure that we do not leak memory by inadvertently discarding
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5319 // the original fragment (which might have attached data) instead of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5320 // using it; in addition, use the original fragment object for the last
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5321 // item instead of first because it can end up being emptied incorrectly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5322 // in certain situations (Bug #8070).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5323 // Fragments from the fragment cache must always be cloned and never used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5324 // in place.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5325 results.cacheable || (l > 1 && i < lastIndex) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5326 jQuery.clone( fragment, true, true ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5327 fragment
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5328 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5329 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5330 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5331
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5332 if ( scripts.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5333 jQuery.each( scripts, evalScript );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5334 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5335 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5336
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5337 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5338 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5339 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5340
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5341 function root( elem, cur ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5342 return jQuery.nodeName(elem, "table") ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5343 (elem.getElementsByTagName("tbody")[0] ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5344 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5345 elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5346 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5347
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5348 function cloneCopyEvent( src, dest ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5349
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5350 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5351 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5352 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5353
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5354 var internalKey = jQuery.expando,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5355 oldData = jQuery.data( src ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5356 curData = jQuery.data( dest, oldData );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5357
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5358 // Switch to use the internal data object, if it exists, for the next
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5359 // stage of data copying
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5360 if ( (oldData = oldData[ internalKey ]) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5361 var events = oldData.events;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5362 curData = curData[ internalKey ] = jQuery.extend({}, oldData);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5363
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5364 if ( events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5365 delete curData.handle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5366 curData.events = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5367
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5368 for ( var type in events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5369 for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5370 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5371 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5373 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5374 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5375 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5376
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5377 function cloneFixAttributes(src, dest) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5378 // We do not need to do anything for non-Elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5379 if ( dest.nodeType !== 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5380 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5381 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5382
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5383 var nodeName = dest.nodeName.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5384
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5385 // clearAttributes removes the attributes, which we don't want,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5386 // but also removes the attachEvent events, which we *do* want
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5387 dest.clearAttributes();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5388
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5389 // mergeAttributes, in contrast, only merges back on the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5390 // original attributes, not the events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5391 dest.mergeAttributes(src);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5392
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5393 // IE6-8 fail to clone children inside object elements that use
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5394 // the proprietary classid attribute value (rather than the type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5395 // attribute) to identify the type of content to display
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5396 if ( nodeName === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5397 dest.outerHTML = src.outerHTML;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5398
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5399 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5400 // IE6-8 fails to persist the checked state of a cloned checkbox
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5401 // or radio button. Worse, IE6-7 fail to give the cloned element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5402 // a checked appearance if the defaultChecked value isn't also set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5403 if ( src.checked ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5404 dest.defaultChecked = dest.checked = src.checked;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5405 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5406
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5407 // IE6-7 get confused and end up setting the value of a cloned
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5408 // checkbox/radio button to an empty string instead of "on"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5409 if ( dest.value !== src.value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5410 dest.value = src.value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5411 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5412
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5413 // IE6-8 fails to return the selected option to the default selected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5414 // state when cloning options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5415 } else if ( nodeName === "option" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5416 dest.selected = src.defaultSelected;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5417
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5418 // IE6-8 fails to set the defaultValue to the correct value when
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5419 // cloning other types of input fields
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5420 } else if ( nodeName === "input" || nodeName === "textarea" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5421 dest.defaultValue = src.defaultValue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5422 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5423
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5424 // Event data gets referenced instead of copied if the expando
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5425 // gets copied too
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5426 dest.removeAttribute( jQuery.expando );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5427 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5428
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5429 jQuery.buildFragment = function( args, nodes, scripts ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5430 var fragment, cacheable, cacheresults,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5431 doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5432
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5433 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5434 // Cloning options loses the selected state, so don't cache them
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5435 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5436 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5437 if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5438 args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5439
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5440 cacheable = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5441 cacheresults = jQuery.fragments[ args[0] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5442 if ( cacheresults ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5443 if ( cacheresults !== 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5444 fragment = cacheresults;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5445 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5446 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5447 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5448
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5449 if ( !fragment ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5450 fragment = doc.createDocumentFragment();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5451 jQuery.clean( args, doc, fragment, scripts );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5452 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5453
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5454 if ( cacheable ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5455 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5456 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5457
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5458 return { fragment: fragment, cacheable: cacheable };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5459 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5460
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5461 jQuery.fragments = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5462
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5463 jQuery.each({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5464 appendTo: "append",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5465 prependTo: "prepend",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5466 insertBefore: "before",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5467 insertAfter: "after",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5468 replaceAll: "replaceWith"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5469 }, function( name, original ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5470 jQuery.fn[ name ] = function( selector ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5471 var ret = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5472 insert = jQuery( selector ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5473 parent = this.length === 1 && this[0].parentNode;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5474
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5475 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5476 insert[ original ]( this[0] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5477 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5478
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5479 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5480 for ( var i = 0, l = insert.length; i < l; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5481 var elems = (i > 0 ? this.clone(true) : this).get();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5482 jQuery( insert[i] )[ original ]( elems );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5483 ret = ret.concat( elems );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5484 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5485
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5486 return this.pushStack( ret, name, insert.selector );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5487 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5488 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5489 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5490
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5491 function getAll( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5492 if ( "getElementsByTagName" in elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5493 return elem.getElementsByTagName( "*" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5494
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5495 } else if ( "querySelectorAll" in elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5496 return elem.querySelectorAll( "*" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5497
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5498 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5499 return [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5500 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5501 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5502
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5503 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5504 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5505 var clone = elem.cloneNode(true),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5506 srcElements,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5507 destElements,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5508 i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5509
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5510 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5511 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5512 // IE copies events bound via attachEvent when using cloneNode.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5513 // Calling detachEvent on the clone will also remove the events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5514 // from the original. In order to get around this, we use some
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5515 // proprietary methods to clear the events. Thanks to MooTools
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5516 // guys for this hotness.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5518 cloneFixAttributes( elem, clone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5519
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5520 // Using Sizzle here is crazy slow, so we use getElementsByTagName
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5521 // instead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5522 srcElements = getAll( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5523 destElements = getAll( clone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5524
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5525 // Weird iteration because IE will replace the length property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5526 // with an element if you are cloning the body and one of the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5527 // elements on the page has a name or id of "length"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5528 for ( i = 0; srcElements[i]; ++i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5529 cloneFixAttributes( srcElements[i], destElements[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5530 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5531 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5532
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5533 // Copy the events from the original to the clone
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5534 if ( dataAndEvents ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5535 cloneCopyEvent( elem, clone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5536
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5537 if ( deepDataAndEvents ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5538 srcElements = getAll( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5539 destElements = getAll( clone );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5540
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5541 for ( i = 0; srcElements[i]; ++i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5542 cloneCopyEvent( srcElements[i], destElements[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5543 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5544 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5545 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5546
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5547 // Return the cloned set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5548 return clone;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5549 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5550 clean: function( elems, context, fragment, scripts ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5551 context = context || document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5552
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5553 // !context.createElement fails in IE with an error but returns typeof 'object'
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5554 if ( typeof context.createElement === "undefined" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5555 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5556 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5557
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5558 var ret = [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5559
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5560 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5561 if ( typeof elem === "number" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5562 elem += "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5563 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5564
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5565 if ( !elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5566 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5567 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5568
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5569 // Convert html string into DOM nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5570 if ( typeof elem === "string" && !rhtml.test( elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5571 elem = context.createTextNode( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5572
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5573 } else if ( typeof elem === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5574 // Fix "XHTML"-style tags in all browsers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5575 elem = elem.replace(rxhtmlTag, "<$1></$2>");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5576
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5577 // Trim whitespace, otherwise indexOf won't work as expected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5578 var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5579 wrap = wrapMap[ tag ] || wrapMap._default,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5580 depth = wrap[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5581 div = context.createElement("div");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5582
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5583 // Go to html and back, then peel off extra wrappers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5584 div.innerHTML = wrap[1] + elem + wrap[2];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5585
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5586 // Move to the right depth
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5587 while ( depth-- ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5588 div = div.lastChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5589 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5590
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5591 // Remove IE's autoinserted <tbody> from table fragments
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5592 if ( !jQuery.support.tbody ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5593
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5594 // String was a <table>, *may* have spurious <tbody>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5595 var hasBody = rtbody.test(elem),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5596 tbody = tag === "table" && !hasBody ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5597 div.firstChild && div.firstChild.childNodes :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5598
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5599 // String was a bare <thead> or <tfoot>
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5600 wrap[1] === "<table>" && !hasBody ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5601 div.childNodes :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5602 [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5603
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5604 for ( var j = tbody.length - 1; j >= 0 ; --j ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5605 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5606 tbody[ j ].parentNode.removeChild( tbody[ j ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5607 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5608 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5609
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5610 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5611
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5612 // IE completely kills leading whitespace when innerHTML is used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5613 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5614 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5615 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5616
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5617 elem = div.childNodes;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5618 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5620 if ( elem.nodeType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5621 ret.push( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5622 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5623 ret = jQuery.merge( ret, elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5624 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5625 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5626
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5627 if ( fragment ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5628 for ( i = 0; ret[i]; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5629 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5630 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5631
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5632 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5633 if ( ret[i].nodeType === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5634 ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5635 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5636 fragment.appendChild( ret[i] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5637 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5638 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5639 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5640
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5641 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5642 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5643
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5644 cleanData: function( elems ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5645 var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5646 deleteExpando = jQuery.support.deleteExpando;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5647
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5648 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5649 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5650 continue;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5651 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5652
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5653 id = elem[ jQuery.expando ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5654
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5655 if ( id ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5656 data = cache[ id ] && cache[ id ][ internalKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5657
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5658 if ( data && data.events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5659 for ( var type in data.events ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5660 if ( special[ type ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5661 jQuery.event.remove( elem, type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5662
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5663 // This is a shortcut to avoid jQuery.event.remove's overhead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5664 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5665 jQuery.removeEvent( elem, type, data.handle );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5666 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5667 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5668
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5669 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5670 if ( data.handle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5671 data.handle.elem = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5672 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5673 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5674
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5675 if ( deleteExpando ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5676 delete elem[ jQuery.expando ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5677
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5678 } else if ( elem.removeAttribute ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5679 elem.removeAttribute( jQuery.expando );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5680 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5681
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5682 delete cache[ id ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5683 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5684 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5685 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5686 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5687
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5688 function evalScript( i, elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5689 if ( elem.src ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5690 jQuery.ajax({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5691 url: elem.src,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5692 async: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5693 dataType: "script"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5694 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5695 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5696 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5697 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5698
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5699 if ( elem.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5700 elem.parentNode.removeChild( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5701 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5702 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5703
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5704
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5705
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5706
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5707 var ralpha = /alpha\([^)]*\)/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5708 ropacity = /opacity=([^)]*)/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5709 rdashAlpha = /-([a-z])/ig,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5710 rupper = /([A-Z])/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5711 rnumpx = /^-?\d+(?:px)?$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5712 rnum = /^-?\d/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5713
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5714 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5715 cssWidth = [ "Left", "Right" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5716 cssHeight = [ "Top", "Bottom" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5717 curCSS,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5718
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5719 getComputedStyle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5720 currentStyle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5721
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5722 fcamelCase = function( all, letter ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5723 return letter.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5724 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5725
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5726 jQuery.fn.css = function( name, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5727 // Setting 'undefined' is a no-op
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5728 if ( arguments.length === 2 && value === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5729 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5730 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5731
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5732 return jQuery.access( this, name, value, true, function( elem, name, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5733 return value !== undefined ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5734 jQuery.style( elem, name, value ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5735 jQuery.css( elem, name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5736 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5737 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5738
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5739 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5740 // Add in style property hooks for overriding the default
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5741 // behavior of getting and setting a style property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5742 cssHooks: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5743 opacity: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5744 get: function( elem, computed ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5745 if ( computed ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5746 // We should always get a number back from opacity
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5747 var ret = curCSS( elem, "opacity", "opacity" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5748 return ret === "" ? "1" : ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5749
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5750 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5751 return elem.style.opacity;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5752 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5753 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5754 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5755 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5756
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5757 // Exclude the following css properties to add px
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5758 cssNumber: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5759 "zIndex": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5760 "fontWeight": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5761 "opacity": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5762 "zoom": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5763 "lineHeight": true
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5764 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5766 // Add in properties whose names you wish to fix before
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5767 // setting or getting the value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5768 cssProps: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5769 // normalize float css property
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5770 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5771 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5772
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5773 // Get and set the style property on a DOM Node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5774 style: function( elem, name, value, extra ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5775 // Don't set styles on text and comment nodes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5776 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5777 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5778 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5779
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5780 // Make sure that we're working with the right name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5781 var ret, origName = jQuery.camelCase( name ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5782 style = elem.style, hooks = jQuery.cssHooks[ origName ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5783
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5784 name = jQuery.cssProps[ origName ] || origName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5785
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5786 // Check if we're setting a value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5787 if ( value !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5788 // Make sure that NaN and null values aren't set. See: #7116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5789 if ( typeof value === "number" && isNaN( value ) || value == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5790 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5791 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5792
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5793 // If a number was passed in, add 'px' to the (except for certain CSS properties)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5794 if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5795 value += "px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5796 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5797
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5798 // If a hook was provided, use that value, otherwise just set the specified value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5799 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5800 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5801 // Fixes bug #5509
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5802 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5803 style[ name ] = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5804 } catch(e) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5805 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5806
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5807 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5808 // If a hook was provided get the non-computed value from there
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5809 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5810 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5811 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5812
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5813 // Otherwise just get the value from the style object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5814 return style[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5815 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5816 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5817
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5818 css: function( elem, name, extra ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5819 // Make sure that we're working with the right name
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5820 var ret, origName = jQuery.camelCase( name ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5821 hooks = jQuery.cssHooks[ origName ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5822
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5823 name = jQuery.cssProps[ origName ] || origName;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5824
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5825 // If a hook was provided get the computed value from there
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5826 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5827 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5828
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5829 // Otherwise, if a way to get the computed value exists, use that
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5830 } else if ( curCSS ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5831 return curCSS( elem, name, origName );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5832 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5833 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5834
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5835 // A method for quickly swapping in/out CSS properties to get correct calculations
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5836 swap: function( elem, options, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5837 var old = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5838
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5839 // Remember the old values, and insert the new ones
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5840 for ( var name in options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5841 old[ name ] = elem.style[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5842 elem.style[ name ] = options[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5843 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5844
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5845 callback.call( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5846
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5847 // Revert the old values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5848 for ( name in options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5849 elem.style[ name ] = old[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5850 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5851 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5852
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5853 camelCase: function( string ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5854 return string.replace( rdashAlpha, fcamelCase );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5855 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5856 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5857
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5858 // DEPRECATED, Use jQuery.css() instead
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5859 jQuery.curCSS = jQuery.css;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5860
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5861 jQuery.each(["height", "width"], function( i, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5862 jQuery.cssHooks[ name ] = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5863 get: function( elem, computed, extra ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5864 var val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5865
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5866 if ( computed ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5867 if ( elem.offsetWidth !== 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5868 val = getWH( elem, name, extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5869
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5870 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5871 jQuery.swap( elem, cssShow, function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5872 val = getWH( elem, name, extra );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5873 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5874 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5875
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5876 if ( val <= 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5877 val = curCSS( elem, name, name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5878
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5879 if ( val === "0px" && currentStyle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5880 val = currentStyle( elem, name, name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5881 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5882
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5883 if ( val != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5884 // Should return "auto" instead of 0, use 0 for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5885 // temporary backwards-compat
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5886 return val === "" || val === "auto" ? "0px" : val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5887 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5888 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5889
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5890 if ( val < 0 || val == null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5891 val = elem.style[ name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5892
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5893 // Should return "auto" instead of 0, use 0 for
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5894 // temporary backwards-compat
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5895 return val === "" || val === "auto" ? "0px" : val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5896 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5897
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5898 return typeof val === "string" ? val : val + "px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5899 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5900 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5901
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5902 set: function( elem, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5903 if ( rnumpx.test( value ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5904 // ignore negative width and height values #1599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5905 value = parseFloat(value);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5906
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5907 if ( value >= 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5908 return value + "px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5909 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5910
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5911 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5912 return value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5913 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5914 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5915 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5916 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5917
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5918 if ( !jQuery.support.opacity ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5919 jQuery.cssHooks.opacity = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5920 get: function( elem, computed ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5921 // IE uses filters for opacity
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5922 return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5923 (parseFloat(RegExp.$1) / 100) + "" :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5924 computed ? "1" : "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5925 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5926
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5927 set: function( elem, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5928 var style = elem.style;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5929
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5930 // IE has trouble with opacity if it does not have layout
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5931 // Force it by setting the zoom level
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5932 style.zoom = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5933
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5934 // Set the alpha filter to set the opacity
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5935 var opacity = jQuery.isNaN(value) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5936 "" :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5937 "alpha(opacity=" + value * 100 + ")",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5938 filter = style.filter || "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5939
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5940 style.filter = ralpha.test(filter) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5941 filter.replace(ralpha, opacity) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5942 style.filter + ' ' + opacity;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5943 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5944 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5945 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5946
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5947 if ( document.defaultView && document.defaultView.getComputedStyle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5948 getComputedStyle = function( elem, newName, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5949 var ret, defaultView, computedStyle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5950
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5951 name = name.replace( rupper, "-$1" ).toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5952
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5953 if ( !(defaultView = elem.ownerDocument.defaultView) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5954 return undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5955 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5956
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5957 if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5958 ret = computedStyle.getPropertyValue( name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5959 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5960 ret = jQuery.style( elem, name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5961 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5962 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5963
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5964 return ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5965 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5966 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5967
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5968 if ( document.documentElement.currentStyle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5969 currentStyle = function( elem, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5970 var left,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5971 ret = elem.currentStyle && elem.currentStyle[ name ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5972 rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5973 style = elem.style;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5974
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5975 // From the awesome hack by Dean Edwards
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5976 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5977
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5978 // If we're not dealing with a regular pixel number
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5979 // but a number that has a weird ending, we need to convert it to pixels
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5980 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5981 // Remember the original values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5982 left = style.left;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5983
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5984 // Put in the new values to get a computed value out
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5985 if ( rsLeft ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5986 elem.runtimeStyle.left = elem.currentStyle.left;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5987 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5988 style.left = name === "fontSize" ? "1em" : (ret || 0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5989 ret = style.pixelLeft + "px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5990
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5991 // Revert the changed values
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5992 style.left = left;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5993 if ( rsLeft ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5994 elem.runtimeStyle.left = rsLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5995 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5996 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5997
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5998 return ret === "" ? "auto" : ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5999 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6000 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6001
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6002 curCSS = getComputedStyle || currentStyle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6004 function getWH( elem, name, extra ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6005 var which = name === "width" ? cssWidth : cssHeight,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6006 val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6007
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6008 if ( extra === "border" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6009 return val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6010 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6011
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6012 jQuery.each( which, function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6013 if ( !extra ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6014 val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6015 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6016
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6017 if ( extra === "margin" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6018 val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6019
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6020 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6021 val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6022 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6023 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6024
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6025 return val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6026 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6027
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6028 if ( jQuery.expr && jQuery.expr.filters ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6029 jQuery.expr.filters.hidden = function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6030 var width = elem.offsetWidth,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6031 height = elem.offsetHeight;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6032
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6033 return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6034 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6035
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6036 jQuery.expr.filters.visible = function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6037 return !jQuery.expr.filters.hidden( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6038 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6039 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6040
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6041
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6042
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6043
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6044 var r20 = /%20/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6045 rbracket = /\[\]$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6046 rCRLF = /\r?\n/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6047 rhash = /#.*$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6048 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6049 rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6050 // #7653, #8125, #8152: local protocol detection
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6051 rlocalProtocol = /(?:^file|^widget|\-extension):$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6052 rnoContent = /^(?:GET|HEAD)$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6053 rprotocol = /^\/\//,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6054 rquery = /\?/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6055 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6056 rselectTextarea = /^(?:select|textarea)/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6057 rspacesAjax = /\s+/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6058 rts = /([?&])_=[^&]*/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6059 rucHeaders = /(^|\-)([a-z])/g,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6060 rucHeadersFunc = function( _, $1, $2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6061 return $1 + $2.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6062 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6063 rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6064
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6065 // Keep a copy of the old load method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6066 _load = jQuery.fn.load,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6067
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6068 /* Prefilters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6069 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6070 * 2) These are called:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6071 * - BEFORE asking for a transport
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6072 * - AFTER param serialization (s.data is a string if s.processData is true)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6073 * 3) key is the dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6074 * 4) the catchall symbol "*" can be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6075 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6076 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6077 prefilters = {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6078
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6079 /* Transports bindings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6080 * 1) key is the dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6081 * 2) the catchall symbol "*" can be used
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6082 * 3) selection will start with transport dataType and THEN go to "*" if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6083 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6084 transports = {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6085
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6086 // Document location
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6087 ajaxLocation,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6088
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6089 // Document location segments
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6090 ajaxLocParts;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6091
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6092 // #8138, IE may throw an exception when accessing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6093 // a field from document.location if document.domain has been set
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6094 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6095 ajaxLocation = document.location.href;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6096 } catch( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6097 // Use the href attribute of an A element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6098 // since IE will modify it given document.location
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6099 ajaxLocation = document.createElement( "a" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6100 ajaxLocation.href = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6101 ajaxLocation = ajaxLocation.href;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6102 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6103
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6104 // Segment location into parts
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6105 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6106
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6107 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6108 function addToPrefiltersOrTransports( structure ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6109
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6110 // dataTypeExpression is optional and defaults to "*"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6111 return function( dataTypeExpression, func ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6112
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6113 if ( typeof dataTypeExpression !== "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6114 func = dataTypeExpression;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6115 dataTypeExpression = "*";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6116 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6117
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6118 if ( jQuery.isFunction( func ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6119 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6120 i = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6121 length = dataTypes.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6122 dataType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6123 list,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6124 placeBefore;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6126 // For each dataType in the dataTypeExpression
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6127 for(; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6128 dataType = dataTypes[ i ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6129 // We control if we're asked to add before
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6130 // any existing element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6131 placeBefore = /^\+/.test( dataType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6132 if ( placeBefore ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6133 dataType = dataType.substr( 1 ) || "*";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6134 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6135 list = structure[ dataType ] = structure[ dataType ] || [];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6136 // then we add to the structure accordingly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6137 list[ placeBefore ? "unshift" : "push" ]( func );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6138 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6139 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6140 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6141 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6142
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6143 //Base inspection function for prefilters and transports
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6144 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6145 dataType /* internal */, inspected /* internal */ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6147 dataType = dataType || options.dataTypes[ 0 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6148 inspected = inspected || {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6149
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6150 inspected[ dataType ] = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6151
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6152 var list = structure[ dataType ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6153 i = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6154 length = list ? list.length : 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6155 executeOnly = ( structure === prefilters ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6156 selection;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6157
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6158 for(; i < length && ( executeOnly || !selection ); i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6159 selection = list[ i ]( options, originalOptions, jqXHR );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6160 // If we got redirected to another dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6161 // we try there if executing only and not done already
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6162 if ( typeof selection === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6163 if ( !executeOnly || inspected[ selection ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6164 selection = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6165 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6166 options.dataTypes.unshift( selection );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6167 selection = inspectPrefiltersOrTransports(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6168 structure, options, originalOptions, jqXHR, selection, inspected );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6169 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6170 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6171 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6172 // If we're only executing or nothing was selected
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6173 // we try the catchall dataType if not done already
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6174 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6175 selection = inspectPrefiltersOrTransports(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6176 structure, options, originalOptions, jqXHR, "*", inspected );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6177 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6178 // unnecessary when only executing (prefilters)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6179 // but it'll be ignored by the caller in that case
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6180 return selection;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6181 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6182
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6183 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6184 load: function( url, params, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6185 if ( typeof url !== "string" && _load ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6186 return _load.apply( this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6187
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6188 // Don't do a request if no elements are being requested
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6189 } else if ( !this.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6190 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6191 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6192
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6193 var off = url.indexOf( " " );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6194 if ( off >= 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6195 var selector = url.slice( off, url.length );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6196 url = url.slice( 0, off );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6197 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6198
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6199 // Default to a GET request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6200 var type = "GET";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6201
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6202 // If the second parameter was provided
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6203 if ( params ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6204 // If it's a function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6205 if ( jQuery.isFunction( params ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6206 // We assume that it's the callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6207 callback = params;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6208 params = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6209
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6210 // Otherwise, build a param string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6211 } else if ( typeof params === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6212 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6213 type = "POST";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6214 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6215 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6216
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6217 var self = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6218
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6219 // Request the remote document
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6220 jQuery.ajax({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6221 url: url,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6222 type: type,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6223 dataType: "html",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6224 data: params,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6225 // Complete callback (responseText is used internally)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6226 complete: function( jqXHR, status, responseText ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6227 // Store the response as specified by the jqXHR object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6228 responseText = jqXHR.responseText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6229 // If successful, inject the HTML into all the matched elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6230 if ( jqXHR.isResolved() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6231 // #4825: Get the actual response in case
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6232 // a dataFilter is present in ajaxSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6233 jqXHR.done(function( r ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6234 responseText = r;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6235 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6236 // See if a selector was specified
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6237 self.html( selector ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6238 // Create a dummy div to hold the results
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6239 jQuery("<div>")
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6240 // inject the contents of the document in, removing the scripts
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6241 // to avoid any 'Permission Denied' errors in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6242 .append(responseText.replace(rscript, ""))
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6243
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6244 // Locate the specified elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6245 .find(selector) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6246
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6247 // If not, just inject the full result
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6248 responseText );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6249 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6250
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6251 if ( callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6252 self.each( callback, [ responseText, status, jqXHR ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6253 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6254 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6255 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6256
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6257 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6258 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6259
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6260 serialize: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6261 return jQuery.param( this.serializeArray() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6262 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6263
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6264 serializeArray: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6265 return this.map(function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6266 return this.elements ? jQuery.makeArray( this.elements ) : this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6267 })
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6268 .filter(function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6269 return this.name && !this.disabled &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6270 ( this.checked || rselectTextarea.test( this.nodeName ) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6271 rinput.test( this.type ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6272 })
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6273 .map(function( i, elem ){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6274 var val = jQuery( this ).val();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6276 return val == null ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6277 null :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6278 jQuery.isArray( val ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6279 jQuery.map( val, function( val, i ){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6280 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6281 }) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6282 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6283 }).get();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6284 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6285 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6286
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6287 // Attach a bunch of functions for handling common AJAX events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6288 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6289 jQuery.fn[ o ] = function( f ){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6290 return this.bind( o, f );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6291 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6292 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6293
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6294 jQuery.each( [ "get", "post" ], function( i, method ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6295 jQuery[ method ] = function( url, data, callback, type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6296 // shift arguments if data argument was omitted
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6297 if ( jQuery.isFunction( data ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6298 type = type || callback;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6299 callback = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6300 data = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6301 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6302
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6303 return jQuery.ajax({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6304 type: method,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6305 url: url,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6306 data: data,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6307 success: callback,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6308 dataType: type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6309 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6310 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6311 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6312
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6313 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6314
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6315 getScript: function( url, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6316 return jQuery.get( url, undefined, callback, "script" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6317 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6318
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6319 getJSON: function( url, data, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6320 return jQuery.get( url, data, callback, "json" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6321 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6322
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6323 // Creates a full fledged settings object into target
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6324 // with both ajaxSettings and settings fields.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6325 // If target is omitted, writes into ajaxSettings.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6326 ajaxSetup: function ( target, settings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6327 if ( !settings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6328 // Only one parameter, we extend ajaxSettings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6329 settings = target;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6330 target = jQuery.extend( true, jQuery.ajaxSettings, settings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6331 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6332 // target was provided, we extend into it
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6333 jQuery.extend( true, target, jQuery.ajaxSettings, settings );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6334 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6335 // Flatten fields we don't want deep extended
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6336 for( var field in { context: 1, url: 1 } ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6337 if ( field in settings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6338 target[ field ] = settings[ field ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6339 } else if( field in jQuery.ajaxSettings ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6340 target[ field ] = jQuery.ajaxSettings[ field ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6341 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6342 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6343 return target;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6344 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6345
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6346 ajaxSettings: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6347 url: ajaxLocation,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6348 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6349 global: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6350 type: "GET",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6351 contentType: "application/x-www-form-urlencoded",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6352 processData: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6353 async: true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6354 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6355 timeout: 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6356 data: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6357 dataType: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6358 username: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6359 password: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6360 cache: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6361 traditional: false,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6362 headers: {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6363 crossDomain: null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6364 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6365
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6366 accepts: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6367 xml: "application/xml, text/xml",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6368 html: "text/html",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6369 text: "text/plain",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6370 json: "application/json, text/javascript",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6371 "*": "*/*"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6372 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6373
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6374 contents: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6375 xml: /xml/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6376 html: /html/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6377 json: /json/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6378 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6380 responseFields: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6381 xml: "responseXML",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6382 text: "responseText"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6383 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6384
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6385 // List of data converters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6386 // 1) key format is "source_type destination_type" (a single space in-between)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6387 // 2) the catchall symbol "*" can be used for source_type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6388 converters: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6389
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6390 // Convert anything to text
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6391 "* text": window.String,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6392
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6393 // Text to html (true = no transformation)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6394 "text html": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6395
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6396 // Evaluate text as a json expression
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6397 "text json": jQuery.parseJSON,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6398
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6399 // Parse text as xml
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6400 "text xml": jQuery.parseXML
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6401 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6402 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6404 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6405 ajaxTransport: addToPrefiltersOrTransports( transports ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6406
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6407 // Main method
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6408 ajax: function( url, options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6409
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6410 // If url is an object, simulate pre-1.5 signature
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6411 if ( typeof url === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6412 options = url;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6413 url = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6414 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6415
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6416 // Force options to be an object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6417 options = options || {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6418
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6419 var // Create the final options object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6420 s = jQuery.ajaxSetup( {}, options ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6421 // Callbacks context
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6422 callbackContext = s.context || s,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6423 // Context for global events
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6424 // It's the callbackContext if one was provided in the options
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6425 // and if it's a DOM node or a jQuery collection
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6426 globalEventContext = callbackContext !== s &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6427 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6428 jQuery( callbackContext ) : jQuery.event,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6429 // Deferreds
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6430 deferred = jQuery.Deferred(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6431 completeDeferred = jQuery._Deferred(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6432 // Status-dependent callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6433 statusCode = s.statusCode || {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6434 // ifModified key
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6435 ifModifiedKey,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6436 // Headers (they are sent all at once)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6437 requestHeaders = {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6438 // Response headers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6439 responseHeadersString,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6440 responseHeaders,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6441 // transport
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6442 transport,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6443 // timeout handle
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6444 timeoutTimer,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6445 // Cross-domain detection vars
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6446 parts,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6447 // The jqXHR state
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6448 state = 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6449 // To know if global events are to be dispatched
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6450 fireGlobals,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6451 // Loop variable
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6452 i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6453 // Fake xhr
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6454 jqXHR = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6455
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6456 readyState: 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6457
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6458 // Caches the header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6459 setRequestHeader: function( name, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6460 if ( !state ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6461 requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6462 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6463 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6464 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6465
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6466 // Raw string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6467 getAllResponseHeaders: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6468 return state === 2 ? responseHeadersString : null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6469 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6471 // Builds headers hashtable if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6472 getResponseHeader: function( key ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6473 var match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6474 if ( state === 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6475 if ( !responseHeaders ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6476 responseHeaders = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6477 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6478 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6479 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6480 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6481 match = responseHeaders[ key.toLowerCase() ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6482 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6483 return match === undefined ? null : match;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6484 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6485
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6486 // Overrides response content-type header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6487 overrideMimeType: function( type ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6488 if ( !state ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6489 s.mimeType = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6490 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6491 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6492 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6493
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6494 // Cancel the request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6495 abort: function( statusText ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6496 statusText = statusText || "abort";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6497 if ( transport ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6498 transport.abort( statusText );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6499 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6500 done( 0, statusText );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6501 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6502 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6503 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6504
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6505 // Callback for when everything is done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6506 // It is defined here because jslint complains if it is declared
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6507 // at the end of the function (which would be more logical and readable)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6508 function done( status, statusText, responses, headers ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6509
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6510 // Called once
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6511 if ( state === 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6512 return;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6513 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6514
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6515 // State is "done" now
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6516 state = 2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6517
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6518 // Clear timeout if it exists
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6519 if ( timeoutTimer ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6520 clearTimeout( timeoutTimer );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6521 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6522
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6523 // Dereference transport for early garbage collection
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6524 // (no matter how long the jqXHR object will be used)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6525 transport = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6526
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6527 // Cache response headers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6528 responseHeadersString = headers || "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6529
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6530 // Set readyState
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6531 jqXHR.readyState = status ? 4 : 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6532
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6533 var isSuccess,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6534 success,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6535 error,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6536 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6537 lastModified,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6538 etag;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6540 // If successful, handle type chaining
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6541 if ( status >= 200 && status < 300 || status === 304 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6542
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6543 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6544 if ( s.ifModified ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6545
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6546 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6547 jQuery.lastModified[ ifModifiedKey ] = lastModified;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6548 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6549 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6550 jQuery.etag[ ifModifiedKey ] = etag;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6551 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6552 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6553
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6554 // If not modified
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6555 if ( status === 304 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6556
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6557 statusText = "notmodified";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6558 isSuccess = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6559
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6560 // If we have data
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6561 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6562
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6563 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6564 success = ajaxConvert( s, response );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6565 statusText = "success";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6566 isSuccess = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6567 } catch(e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6568 // We have a parsererror
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6569 statusText = "parsererror";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6570 error = e;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6571 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6572 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6573 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6574 // We extract error from statusText
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6575 // then normalize statusText and status for non-aborts
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6576 error = statusText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6577 if( !statusText || status ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6578 statusText = "error";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6579 if ( status < 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6580 status = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6581 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6582 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6583 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6584
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6585 // Set data for the fake xhr object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6586 jqXHR.status = status;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6587 jqXHR.statusText = statusText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6588
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6589 // Success/Error
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6590 if ( isSuccess ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6591 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6592 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6593 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6594 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6595
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6596 // Status-dependent callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6597 jqXHR.statusCode( statusCode );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6598 statusCode = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6600 if ( fireGlobals ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6601 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6602 [ jqXHR, s, isSuccess ? success : error ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6603 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6604
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6605 // Complete
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6606 completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6607
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6608 if ( fireGlobals ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6609 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6610 // Handle the global AJAX counter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6611 if ( !( --jQuery.active ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6612 jQuery.event.trigger( "ajaxStop" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6613 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6614 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6615 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6616
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6617 // Attach deferreds
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6618 deferred.promise( jqXHR );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6619 jqXHR.success = jqXHR.done;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6620 jqXHR.error = jqXHR.fail;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6621 jqXHR.complete = completeDeferred.done;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6622
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6623 // Status-dependent callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6624 jqXHR.statusCode = function( map ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6625 if ( map ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6626 var tmp;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6627 if ( state < 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6628 for( tmp in map ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6629 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6630 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6631 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6632 tmp = map[ jqXHR.status ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6633 jqXHR.then( tmp, tmp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6634 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6635 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6636 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6637 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6638
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6639 // Remove hash character (#7531: and string promotion)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6640 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6641 // We also use the url parameter if available
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6642 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6643
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6644 // Extract dataTypes list
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6645 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6646
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6647 // Determine if a cross-domain request is in order
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6648 if ( !s.crossDomain ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6649 parts = rurl.exec( s.url.toLowerCase() );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6650 s.crossDomain = !!( parts &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6651 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6652 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6653 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6654 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6655 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6656
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6657 // Convert data if not already a string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6658 if ( s.data && s.processData && typeof s.data !== "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6659 s.data = jQuery.param( s.data, s.traditional );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6660 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6661
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6662 // Apply prefilters
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6663 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6664
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6665 // If request was aborted inside a prefiler, stop there
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6666 if ( state === 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6667 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6668 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6669
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6670 // We can fire global events as of now if asked to
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6671 fireGlobals = s.global;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6672
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6673 // Uppercase the type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6674 s.type = s.type.toUpperCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6675
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6676 // Determine if request has content
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6677 s.hasContent = !rnoContent.test( s.type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6678
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6679 // Watch for a new set of requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6680 if ( fireGlobals && jQuery.active++ === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6681 jQuery.event.trigger( "ajaxStart" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6682 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6683
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6684 // More options handling for requests with no content
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6685 if ( !s.hasContent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6686
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6687 // If data is available, append data to url
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6688 if ( s.data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6689 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6690 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6691
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6692 // Get ifModifiedKey before adding the anti-cache parameter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6693 ifModifiedKey = s.url;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6694
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6695 // Add anti-cache in url if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6696 if ( s.cache === false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6697
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6698 var ts = jQuery.now(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6699 // try replacing _= if it is there
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6700 ret = s.url.replace( rts, "$1_=" + ts );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6701
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6702 // if nothing was replaced, add timestamp to the end
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6703 s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6704 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6705 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6706
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6707 // Set the correct header, if data is being sent
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6708 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6709 requestHeaders[ "Content-Type" ] = s.contentType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6710 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6711
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6712 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6713 if ( s.ifModified ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6714 ifModifiedKey = ifModifiedKey || s.url;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6715 if ( jQuery.lastModified[ ifModifiedKey ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6716 requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6717 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6718 if ( jQuery.etag[ ifModifiedKey ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6719 requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6720 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6721 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6722
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6723 // Set the Accepts header for the server, depending on the dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6724 requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6725 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6726 s.accepts[ "*" ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6727
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6728 // Check for headers option
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6729 for ( i in s.headers ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6730 jqXHR.setRequestHeader( i, s.headers[ i ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6731 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6732
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6733 // Allow custom headers/mimetypes and early abort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6734 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6735 // Abort if not done already
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6736 jqXHR.abort();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6737 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6738
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6739 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6740
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6741 // Install callbacks on deferreds
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6742 for ( i in { success: 1, error: 1, complete: 1 } ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6743 jqXHR[ i ]( s[ i ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6744 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6745
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6746 // Get transport
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6747 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6748
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6749 // If no transport, we auto-abort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6750 if ( !transport ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6751 done( -1, "No Transport" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6752 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6753 jqXHR.readyState = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6754 // Send global event
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6755 if ( fireGlobals ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6756 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6757 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6758 // Timeout
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6759 if ( s.async && s.timeout > 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6760 timeoutTimer = setTimeout( function(){
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6761 jqXHR.abort( "timeout" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6762 }, s.timeout );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6763 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6764
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6765 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6766 state = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6767 transport.send( requestHeaders, done );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6768 } catch (e) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6769 // Propagate exception as error if not done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6770 if ( status < 2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6771 done( -1, e );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6772 // Simply rethrow otherwise
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6773 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6774 jQuery.error( e );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6775 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6776 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6777 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6778
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6779 return jqXHR;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6780 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6781
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6782 // Serialize an array of form elements or a set of
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6783 // key/values into a query string
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6784 param: function( a, traditional ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6785 var s = [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6786 add = function( key, value ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6787 // If value is a function, invoke it and return its value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6788 value = jQuery.isFunction( value ) ? value() : value;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6789 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6790 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6791
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6792 // Set traditional to true for jQuery <= 1.3.2 behavior.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6793 if ( traditional === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6794 traditional = jQuery.ajaxSettings.traditional;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6795 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6796
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6797 // If an array was passed in, assume that it is an array of form elements.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6798 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6799 // Serialize the form elements
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6800 jQuery.each( a, function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6801 add( this.name, this.value );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6802 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6803
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6804 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6805 // If traditional, encode the "old" way (the way 1.3.2 or older
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6806 // did it), otherwise encode params recursively.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6807 for ( var prefix in a ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6808 buildParams( prefix, a[ prefix ], traditional, add );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6809 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6810 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6811
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6812 // Return the resulting serialization
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6813 return s.join( "&" ).replace( r20, "+" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6814 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6815 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6816
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6817 function buildParams( prefix, obj, traditional, add ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6818 if ( jQuery.isArray( obj ) && obj.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6819 // Serialize array item.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6820 jQuery.each( obj, function( i, v ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6821 if ( traditional || rbracket.test( prefix ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6822 // Treat each array item as a scalar.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6823 add( prefix, v );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6824
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6825 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6826 // If array item is non-scalar (array or object), encode its
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6827 // numeric index to resolve deserialization ambiguity issues.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6828 // Note that rack (as of 1.0.0) can't currently deserialize
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6829 // nested arrays properly, and attempting to do so may cause
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6830 // a server error. Possible fixes are to modify rack's
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6831 // deserialization algorithm or to provide an option or flag
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6832 // to force array serialization to be shallow.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6833 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6834 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6835 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6836
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6837 } else if ( !traditional && obj != null && typeof obj === "object" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6838 // If we see an array here, it is empty and should be treated as an empty
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6839 // object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6840 if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6841 add( prefix, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6842
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6843 // Serialize object item.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6844 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6845 for ( var name in obj ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6846 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6847 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6848 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6849
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6850 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6851 // Serialize scalar item.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6852 add( prefix, obj );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6853 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6854 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6855
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6856 // This is still on the jQuery object... for now
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6857 // Want to move this to jQuery.ajax some day
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6858 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6859
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6860 // Counter for holding the number of active queries
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6861 active: 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6862
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6863 // Last-Modified header cache for next request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6864 lastModified: {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6865 etag: {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6866
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6867 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6868
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6869 /* Handles responses to an ajax request:
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6870 * - sets all responseXXX fields accordingly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6871 * - finds the right dataType (mediates between content-type and expected dataType)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6872 * - returns the corresponding response
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6873 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6874 function ajaxHandleResponses( s, jqXHR, responses ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6875
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6876 var contents = s.contents,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6877 dataTypes = s.dataTypes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6878 responseFields = s.responseFields,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6879 ct,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6880 type,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6881 finalDataType,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6882 firstDataType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6883
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6884 // Fill responseXXX fields
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6885 for( type in responseFields ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6886 if ( type in responses ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6887 jqXHR[ responseFields[type] ] = responses[ type ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6888 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6889 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6890
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6891 // Remove auto dataType and get content-type in the process
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6892 while( dataTypes[ 0 ] === "*" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6893 dataTypes.shift();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6894 if ( ct === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6895 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6896 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6897 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6898
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6899 // Check if we're dealing with a known content-type
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6900 if ( ct ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6901 for ( type in contents ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6902 if ( contents[ type ] && contents[ type ].test( ct ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6903 dataTypes.unshift( type );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6904 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6905 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6906 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6907 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6908
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6909 // Check to see if we have a response for the expected dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6910 if ( dataTypes[ 0 ] in responses ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6911 finalDataType = dataTypes[ 0 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6912 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6913 // Try convertible dataTypes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6914 for ( type in responses ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6915 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6916 finalDataType = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6917 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6918 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6919 if ( !firstDataType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6920 firstDataType = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6921 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6922 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6923 // Or just use first one
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6924 finalDataType = finalDataType || firstDataType;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6925 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6926
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6927 // If we found a dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6928 // We add the dataType to the list if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6929 // and return the corresponding response
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6930 if ( finalDataType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6931 if ( finalDataType !== dataTypes[ 0 ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6932 dataTypes.unshift( finalDataType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6933 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6934 return responses[ finalDataType ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6935 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6936 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6937
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6938 // Chain conversions given the request and the original response
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6939 function ajaxConvert( s, response ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6940
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6941 // Apply the dataFilter if provided
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6942 if ( s.dataFilter ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6943 response = s.dataFilter( response, s.dataType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6944 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6945
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6946 var dataTypes = s.dataTypes,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6947 converters = {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6948 i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6949 key,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6950 length = dataTypes.length,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6951 tmp,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6952 // Current and previous dataTypes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6953 current = dataTypes[ 0 ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6954 prev,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6955 // Conversion expression
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6956 conversion,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6957 // Conversion function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6958 conv,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6959 // Conversion functions (transitive conversion)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6960 conv1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6961 conv2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6962
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6963 // For each dataType in the chain
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6964 for( i = 1; i < length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6965
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6966 // Create converters map
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6967 // with lowercased keys
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6968 if ( i === 1 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6969 for( key in s.converters ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6970 if( typeof key === "string" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6971 converters[ key.toLowerCase() ] = s.converters[ key ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6972 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6973 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6974 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6975
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6976 // Get the dataTypes
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6977 prev = current;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6978 current = dataTypes[ i ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6979
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6980 // If current is auto dataType, update it to prev
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6981 if( current === "*" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6982 current = prev;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6983 // If no auto and dataTypes are actually different
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6984 } else if ( prev !== "*" && prev !== current ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6985
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6986 // Get the converter
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6987 conversion = prev + " " + current;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6988 conv = converters[ conversion ] || converters[ "* " + current ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6989
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6990 // If there is no direct converter, search transitively
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6991 if ( !conv ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6992 conv2 = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6993 for( conv1 in converters ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6994 tmp = conv1.split( " " );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6995 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6996 conv2 = converters[ tmp[1] + " " + current ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6997 if ( conv2 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6998 conv1 = converters[ conv1 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6999 if ( conv1 === true ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7000 conv = conv2;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7001 } else if ( conv2 === true ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7002 conv = conv1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7003 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7004 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7005 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7006 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7007 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7008 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7009 // If we found no converter, dispatch an error
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7010 if ( !( conv || conv2 ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7011 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7012 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7013 // If found converter is not an equivalence
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7014 if ( conv !== true ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7015 // Convert with 1 or 2 converters accordingly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7016 response = conv ? conv( response ) : conv2( conv1(response) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7017 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7018 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7019 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7020 return response;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7021 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7022
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7023
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7024
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7025
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7026 var jsc = jQuery.now(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7027 jsre = /(\=)\?(&|$)|()\?\?()/i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7028
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7029 // Default jsonp settings
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7030 jQuery.ajaxSetup({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7031 jsonp: "callback",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7032 jsonpCallback: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7033 return jQuery.expando + "_" + ( jsc++ );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7034 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7035 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7036
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7037 // Detect, normalize options and install callbacks for jsonp requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7038 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7039
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7040 var dataIsString = ( typeof s.data === "string" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7041
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7042 if ( s.dataTypes[ 0 ] === "jsonp" ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7043 originalSettings.jsonpCallback ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7044 originalSettings.jsonp != null ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7045 s.jsonp !== false && ( jsre.test( s.url ) ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7046 dataIsString && jsre.test( s.data ) ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7047
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7048 var responseContainer,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7049 jsonpCallback = s.jsonpCallback =
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7050 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7051 previous = window[ jsonpCallback ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7052 url = s.url,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7053 data = s.data,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7054 replace = "$1" + jsonpCallback + "$2",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7055 cleanUp = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7056 // Set callback back to previous value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7057 window[ jsonpCallback ] = previous;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7058 // Call if it was a function and we have a response
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7059 if ( responseContainer && jQuery.isFunction( previous ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7060 window[ jsonpCallback ]( responseContainer[ 0 ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7061 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7062 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7063
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7064 if ( s.jsonp !== false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7065 url = url.replace( jsre, replace );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7066 if ( s.url === url ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7067 if ( dataIsString ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7068 data = data.replace( jsre, replace );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7069 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7070 if ( s.data === data ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7071 // Add callback manually
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7072 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7073 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7074 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7075 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7076
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7077 s.url = url;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7078 s.data = data;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7079
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7080 // Install callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7081 window[ jsonpCallback ] = function( response ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7082 responseContainer = [ response ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7083 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7084
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7085 // Install cleanUp function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7086 jqXHR.then( cleanUp, cleanUp );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7087
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7088 // Use data converter to retrieve json after script execution
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7089 s.converters["script json"] = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7090 if ( !responseContainer ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7091 jQuery.error( jsonpCallback + " was not called" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7092 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7093 return responseContainer[ 0 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7094 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7095
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7096 // force json dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7097 s.dataTypes[ 0 ] = "json";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7098
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7099 // Delegate to script
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7100 return "script";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7101 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7102 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7103
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7104
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7105
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7106
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7107 // Install script dataType
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7108 jQuery.ajaxSetup({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7109 accepts: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7110 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7111 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7112 contents: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7113 script: /javascript|ecmascript/
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7114 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7115 converters: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7116 "text script": function( text ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7117 jQuery.globalEval( text );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7118 return text;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7119 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7120 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7121 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7122
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7123 // Handle cache's special case and global
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7124 jQuery.ajaxPrefilter( "script", function( s ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7125 if ( s.cache === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7126 s.cache = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7127 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7128 if ( s.crossDomain ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7129 s.type = "GET";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7130 s.global = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7131 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7132 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7133
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7134 // Bind script tag hack transport
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7135 jQuery.ajaxTransport( "script", function(s) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7136
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7137 // This transport only deals with cross domain requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7138 if ( s.crossDomain ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7139
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7140 var script,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7141 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7142
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7143 return {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7144
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7145 send: function( _, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7146
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7147 script = document.createElement( "script" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7148
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7149 script.async = "async";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7150
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7151 if ( s.scriptCharset ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7152 script.charset = s.scriptCharset;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7153 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7154
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7155 script.src = s.url;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7156
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7157 // Attach handlers for all browsers
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7158 script.onload = script.onreadystatechange = function( _, isAbort ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7159
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7160 if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7161
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7162 // Handle memory leak in IE
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7163 script.onload = script.onreadystatechange = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7164
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7165 // Remove the script
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7166 if ( head && script.parentNode ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7167 head.removeChild( script );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7168 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7169
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7170 // Dereference the script
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7171 script = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7172
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7173 // Callback if not abort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7174 if ( !isAbort ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7175 callback( 200, "success" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7176 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7177 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7178 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7179 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7180 // This arises when a base node is used (#2709 and #4378).
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7181 head.insertBefore( script, head.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7182 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7183
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7184 abort: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7185 if ( script ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7186 script.onload( 0, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7187 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7188 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7189 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7190 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7191 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7192
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7193
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7194
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7195
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7196 var // #5280: next active xhr id and list of active xhrs' callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7197 xhrId = jQuery.now(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7198 xhrCallbacks,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7199
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7200 // XHR used to determine supports properties
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7201 testXHR;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7202
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7203 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7204 function xhrOnUnloadAbort() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7205 jQuery( window ).unload(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7206 // Abort all pending requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7207 for ( var key in xhrCallbacks ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7208 xhrCallbacks[ key ]( 0, 1 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7209 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7210 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7211 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7212
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7213 // Functions to create xhrs
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7214 function createStandardXHR() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7215 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7216 return new window.XMLHttpRequest();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7217 } catch( e ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7218 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7219
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7220 function createActiveXHR() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7221 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7222 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7223 } catch( e ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7224 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7225
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7226 // Create the request object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7227 // (This is still attached to ajaxSettings for backward compatibility)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7228 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7229 /* Microsoft failed to properly
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7230 * implement the XMLHttpRequest in IE7 (can't request local files),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7231 * so we use the ActiveXObject when it is available
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7232 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7233 * we need a fallback.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7234 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7235 function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7236 return !this.isLocal && createStandardXHR() || createActiveXHR();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7237 } :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7238 // For all other browsers, use the standard XMLHttpRequest object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7239 createStandardXHR;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7240
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7241 // Test if we can create an xhr object
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7242 testXHR = jQuery.ajaxSettings.xhr();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7243 jQuery.support.ajax = !!testXHR;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7244
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7245 // Does this browser support crossDomain XHR requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7246 jQuery.support.cors = testXHR && ( "withCredentials" in testXHR );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7247
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7248 // No need for the temporary xhr anymore
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7249 testXHR = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7250
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7251 // Create transport if the browser can provide an xhr
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7252 if ( jQuery.support.ajax ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7253
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7254 jQuery.ajaxTransport(function( s ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7255 // Cross domain only allowed if supported through XMLHttpRequest
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7256 if ( !s.crossDomain || jQuery.support.cors ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7257
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7258 var callback;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7259
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7260 return {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7261 send: function( headers, complete ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7262
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7263 // Get a new xhr
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7264 var xhr = s.xhr(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7265 handle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7266 i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7267
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7268 // Open the socket
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7269 // Passing null username, generates a login popup on Opera (#2865)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7270 if ( s.username ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7271 xhr.open( s.type, s.url, s.async, s.username, s.password );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7272 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7273 xhr.open( s.type, s.url, s.async );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7274 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7276 // Apply custom fields if provided
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7277 if ( s.xhrFields ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7278 for ( i in s.xhrFields ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7279 xhr[ i ] = s.xhrFields[ i ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7280 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7281 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7282
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7283 // Override mime type if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7284 if ( s.mimeType && xhr.overrideMimeType ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7285 xhr.overrideMimeType( s.mimeType );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7286 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7287
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7288 // Requested-With header
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7289 // Not set for crossDomain requests with no content
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7290 // (see why at http://trac.dojotoolkit.org/ticket/9486)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7291 // Won't change header if already provided
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7292 if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7293 headers[ "X-Requested-With" ] = "XMLHttpRequest";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7294 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7295
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7296 // Need an extra try/catch for cross domain requests in Firefox 3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7297 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7298 for ( i in headers ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7299 xhr.setRequestHeader( i, headers[ i ] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7300 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7301 } catch( _ ) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7302
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7303 // Do send the request
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7304 // This may raise an exception which is actually
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7305 // handled in jQuery.ajax (so no try/catch here)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7306 xhr.send( ( s.hasContent && s.data ) || null );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7307
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7308 // Listener
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7309 callback = function( _, isAbort ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7310
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7311 var status,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7312 statusText,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7313 responseHeaders,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7314 responses,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7315 xml;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7316
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7317 // Firefox throws exceptions when accessing properties
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7318 // of an xhr when a network error occured
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7319 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7320 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7321
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7322 // Was never called and is aborted or complete
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7323 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7324
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7325 // Only called once
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7326 callback = undefined;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7327
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7328 // Do not keep as active anymore
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7329 if ( handle ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7330 xhr.onreadystatechange = jQuery.noop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7331 delete xhrCallbacks[ handle ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7332 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7333
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7334 // If it's an abort
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7335 if ( isAbort ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7336 // Abort it manually if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7337 if ( xhr.readyState !== 4 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7338 xhr.abort();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7339 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7340 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7341 status = xhr.status;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7342 responseHeaders = xhr.getAllResponseHeaders();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7343 responses = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7344 xml = xhr.responseXML;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7345
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7346 // Construct response list
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7347 if ( xml && xml.documentElement /* #4958 */ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7348 responses.xml = xml;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7349 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7350 responses.text = xhr.responseText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7351
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7352 // Firefox throws an exception when accessing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7353 // statusText for faulty cross-domain requests
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7354 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7355 statusText = xhr.statusText;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7356 } catch( e ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7357 // We normalize with Webkit giving an empty statusText
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7358 statusText = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7359 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7360
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7361 // Filter status for non standard behaviors
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7362
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7363 // If the request is local and we have data: assume a success
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7364 // (success with no data won't get notified, that's the best we
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7365 // can do given current implementations)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7366 if ( !status && s.isLocal && !s.crossDomain ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7367 status = responses.text ? 200 : 404;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7368 // IE - #1450: sometimes returns 1223 when it should be 204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7369 } else if ( status === 1223 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7370 status = 204;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7371 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7372 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7373 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7374 } catch( firefoxAccessException ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7375 if ( !isAbort ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7376 complete( -1, firefoxAccessException );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7377 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7378 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7379
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7380 // Call complete if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7381 if ( responses ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7382 complete( status, statusText, responses, responseHeaders );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7383 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7384 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7385
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7386 // if we're in sync mode or it's in cache
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7387 // and has been retrieved directly (IE6 & IE7)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7388 // we need to manually fire the callback
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7389 if ( !s.async || xhr.readyState === 4 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7390 callback();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7391 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7392 // Create the active xhrs callbacks list if needed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7393 // and attach the unload handler
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7394 if ( !xhrCallbacks ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7395 xhrCallbacks = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7396 xhrOnUnloadAbort();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7397 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7398 // Add to list of active xhrs callbacks
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7399 handle = xhrId++;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7400 xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7401 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7402 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7403
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7404 abort: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7405 if ( callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7406 callback(0,1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7407 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7408 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7409 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7410 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7411 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7412 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7413
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7414
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7415
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7416
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7417 var elemdisplay = {},
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7418 rfxtypes = /^(?:toggle|show|hide)$/,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7419 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7420 timerId,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7421 fxAttrs = [
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7422 // height animations
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7423 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7424 // width animations
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7425 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7426 // opacity animations
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7427 [ "opacity" ]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7428 ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7429
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7430 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7431 show: function( speed, easing, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7432 var elem, display;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7433
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7434 if ( speed || speed === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7435 return this.animate( genFx("show", 3), speed, easing, callback);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7436
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7437 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7438 for ( var i = 0, j = this.length; i < j; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7439 elem = this[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7440 display = elem.style.display;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7441
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7442 // Reset the inline display of this element to learn if it is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7443 // being hidden by cascaded rules or not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7444 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7445 display = elem.style.display = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7446 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7447
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7448 // Set elements which have been overridden with display: none
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7449 // in a stylesheet to whatever the default browser style is
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7450 // for such an element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7451 if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7452 jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7453 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7454 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7455
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7456 // Set the display of most of the elements in a second loop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7457 // to avoid the constant reflow
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7458 for ( i = 0; i < j; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7459 elem = this[i];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7460 display = elem.style.display;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7461
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7462 if ( display === "" || display === "none" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7463 elem.style.display = jQuery._data(elem, "olddisplay") || "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7464 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7465 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7466
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7467 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7468 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7469 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7470
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7471 hide: function( speed, easing, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7472 if ( speed || speed === 0 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7473 return this.animate( genFx("hide", 3), speed, easing, callback);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7474
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7475 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7476 for ( var i = 0, j = this.length; i < j; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7477 var display = jQuery.css( this[i], "display" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7478
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7479 if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7480 jQuery._data( this[i], "olddisplay", display );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7481 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7482 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7483
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7484 // Set the display of the elements in a second loop
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7485 // to avoid the constant reflow
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7486 for ( i = 0; i < j; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7487 this[i].style.display = "none";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7488 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7489
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7490 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7491 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7492 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7493
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7494 // Save the old toggle function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7495 _toggle: jQuery.fn.toggle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7496
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7497 toggle: function( fn, fn2, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7498 var bool = typeof fn === "boolean";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7499
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7500 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7501 this._toggle.apply( this, arguments );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7502
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7503 } else if ( fn == null || bool ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7504 this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7505 var state = bool ? fn : jQuery(this).is(":hidden");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7506 jQuery(this)[ state ? "show" : "hide" ]();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7507 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7508
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7509 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7510 this.animate(genFx("toggle", 3), fn, fn2, callback);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7511 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7512
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7513 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7514 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7515
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7516 fadeTo: function( speed, to, easing, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7517 return this.filter(":hidden").css("opacity", 0).show().end()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7518 .animate({opacity: to}, speed, easing, callback);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7519 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7520
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7521 animate: function( prop, speed, easing, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7522 var optall = jQuery.speed(speed, easing, callback);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7523
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7524 if ( jQuery.isEmptyObject( prop ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7525 return this.each( optall.complete );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7526 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7527
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7528 return this[ optall.queue === false ? "each" : "queue" ](function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7529 // XXX 'this' does not always have a nodeName when running the
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7530 // test suite
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7531
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7532 var opt = jQuery.extend({}, optall), p,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7533 isElement = this.nodeType === 1,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7534 hidden = isElement && jQuery(this).is(":hidden"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7535 self = this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7536
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7537 for ( p in prop ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7538 var name = jQuery.camelCase( p );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7539
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7540 if ( p !== name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7541 prop[ name ] = prop[ p ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7542 delete prop[ p ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7543 p = name;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7544 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7545
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7546 if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7547 return opt.complete.call(this);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7548 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7549
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7550 if ( isElement && ( p === "height" || p === "width" ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7551 // Make sure that nothing sneaks out
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7552 // Record all 3 overflow attributes because IE does not
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7553 // change the overflow attribute when overflowX and
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7554 // overflowY are set to the same value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7555 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7556
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7557 // Set display property to inline-block for height/width
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7558 // animations on inline elements that are having width/height
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7559 // animated
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7560 if ( jQuery.css( this, "display" ) === "inline" &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7561 jQuery.css( this, "float" ) === "none" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7562 if ( !jQuery.support.inlineBlockNeedsLayout ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7563 this.style.display = "inline-block";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7564
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7565 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7566 var display = defaultDisplay(this.nodeName);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7567
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7568 // inline-level elements accept inline-block;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7569 // block-level elements need to be inline with layout
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7570 if ( display === "inline" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7571 this.style.display = "inline-block";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7572
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7573 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7574 this.style.display = "inline";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7575 this.style.zoom = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7576 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7577 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7578 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7579 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7580
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7581 if ( jQuery.isArray( prop[p] ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7582 // Create (if needed) and add to specialEasing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7583 (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7584 prop[p] = prop[p][0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7585 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7586 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7587
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7588 if ( opt.overflow != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7589 this.style.overflow = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7590 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7591
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7592 opt.curAnim = jQuery.extend({}, prop);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7593
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7594 jQuery.each( prop, function( name, val ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7595 var e = new jQuery.fx( self, opt, name );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7596
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7597 if ( rfxtypes.test(val) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7598 e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7599
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7600 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7601 var parts = rfxnum.exec(val),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7602 start = e.cur();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7603
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7604 if ( parts ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7605 var end = parseFloat( parts[2] ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7606 unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7607
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7608 // We need to compute starting value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7609 if ( unit !== "px" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7610 jQuery.style( self, name, (end || 1) + unit);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7611 start = ((end || 1) / e.cur()) * start;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7612 jQuery.style( self, name, start + unit);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7613 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7614
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7615 // If a +=/-= token was provided, we're doing a relative animation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7616 if ( parts[1] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7617 end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7618 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7619
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7620 e.custom( start, end, unit );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7621
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7622 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7623 e.custom( start, val, "" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7624 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7625 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7626 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7627
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7628 // For JS strict compliance
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7629 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7630 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7631 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7632
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7633 stop: function( clearQueue, gotoEnd ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7634 var timers = jQuery.timers;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7635
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7636 if ( clearQueue ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7637 this.queue([]);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7638 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7639
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7640 this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7641 // go in reverse order so anything added to the queue during the loop is ignored
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7642 for ( var i = timers.length - 1; i >= 0; i-- ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7643 if ( timers[i].elem === this ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7644 if (gotoEnd) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7645 // force the next step to be the last
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7646 timers[i](true);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7647 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7648
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7649 timers.splice(i, 1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7650 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7651 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7652 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7653
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7654 // start the next in the queue if the last step wasn't forced
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7655 if ( !gotoEnd ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7656 this.dequeue();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7657 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7658
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7659 return this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7660 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7661
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7662 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7663
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7664 function genFx( type, num ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7665 var obj = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7666
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7667 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7668 obj[ this ] = type;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7669 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7670
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7671 return obj;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7672 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7673
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7674 // Generate shortcuts for custom animations
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7675 jQuery.each({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7676 slideDown: genFx("show", 1),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7677 slideUp: genFx("hide", 1),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7678 slideToggle: genFx("toggle", 1),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7679 fadeIn: { opacity: "show" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7680 fadeOut: { opacity: "hide" },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7681 fadeToggle: { opacity: "toggle" }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7682 }, function( name, props ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7683 jQuery.fn[ name ] = function( speed, easing, callback ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7684 return this.animate( props, speed, easing, callback );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7685 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7686 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7687
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7688 jQuery.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7689 speed: function( speed, easing, fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7690 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7691 complete: fn || !fn && easing ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7692 jQuery.isFunction( speed ) && speed,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7693 duration: speed,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7694 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7695 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7696
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7697 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7698 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7699
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7700 // Queueing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7701 opt.old = opt.complete;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7702 opt.complete = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7703 if ( opt.queue !== false ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7704 jQuery(this).dequeue();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7705 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7706 if ( jQuery.isFunction( opt.old ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7707 opt.old.call( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7708 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7709 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7710
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7711 return opt;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7712 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7713
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7714 easing: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7715 linear: function( p, n, firstNum, diff ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7716 return firstNum + diff * p;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7717 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7718 swing: function( p, n, firstNum, diff ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7719 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7720 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7721 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7722
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7723 timers: [],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7724
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7725 fx: function( elem, options, prop ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7726 this.options = options;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7727 this.elem = elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7728 this.prop = prop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7729
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7730 if ( !options.orig ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7731 options.orig = {};
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7732 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7733 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7734
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7735 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7736
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7737 jQuery.fx.prototype = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7738 // Simple function for setting a style value
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7739 update: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7740 if ( this.options.step ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7741 this.options.step.call( this.elem, this.now, this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7742 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7743
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7744 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7745 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7746
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7747 // Get the current size
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7748 cur: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7749 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7750 return this.elem[ this.prop ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7751 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7752
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7753 var parsed,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7754 r = jQuery.css( this.elem, this.prop );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7755 // Empty strings, null, undefined and "auto" are converted to 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7756 // complex values such as "rotate(1rad)" are returned as is,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7757 // simple values such as "10px" are parsed to Float.
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7758 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7759 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7760
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7761 // Start an animation from one number to another
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7762 custom: function( from, to, unit ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7763 var self = this,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7764 fx = jQuery.fx;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7765
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7766 this.startTime = jQuery.now();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7767 this.start = from;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7768 this.end = to;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7769 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7770 this.now = this.start;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7771 this.pos = this.state = 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7772
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7773 function t( gotoEnd ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7774 return self.step(gotoEnd);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7775 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7776
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7777 t.elem = this.elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7778
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7779 if ( t() && jQuery.timers.push(t) && !timerId ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7780 timerId = setInterval(fx.tick, fx.interval);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7781 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7782 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7783
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7784 // Simple 'show' function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7785 show: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7786 // Remember where we started, so that we can go back to it later
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7787 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7788 this.options.show = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7789
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7790 // Begin the animation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7791 // Make sure that we start at a small width/height to avoid any
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7792 // flash of content
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7793 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7794
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7795 // Start by showing the element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7796 jQuery( this.elem ).show();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7797 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7798
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7799 // Simple 'hide' function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7800 hide: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7801 // Remember where we started, so that we can go back to it later
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7802 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7803 this.options.hide = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7804
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7805 // Begin the animation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7806 this.custom(this.cur(), 0);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7807 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7808
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7809 // Each step of an animation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7810 step: function( gotoEnd ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7811 var t = jQuery.now(), done = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7812
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7813 if ( gotoEnd || t >= this.options.duration + this.startTime ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7814 this.now = this.end;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7815 this.pos = this.state = 1;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7816 this.update();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7817
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7818 this.options.curAnim[ this.prop ] = true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7819
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7820 for ( var i in this.options.curAnim ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7821 if ( this.options.curAnim[i] !== true ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7822 done = false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7823 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7824 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7825
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7826 if ( done ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7827 // Reset the overflow
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7828 if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7829 var elem = this.elem,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7830 options = this.options;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7831
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7832 jQuery.each( [ "", "X", "Y" ], function (index, value) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7833 elem.style[ "overflow" + value ] = options.overflow[index];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7834 } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7835 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7836
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7837 // Hide the element if the "hide" operation was done
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7838 if ( this.options.hide ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7839 jQuery(this.elem).hide();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7840 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7841
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7842 // Reset the properties, if the item has been hidden or shown
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7843 if ( this.options.hide || this.options.show ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7844 for ( var p in this.options.curAnim ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7845 jQuery.style( this.elem, p, this.options.orig[p] );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7846 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7847 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7848
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7849 // Execute the complete function
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7850 this.options.complete.call( this.elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7851 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7852
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7853 return false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7854
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7855 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7856 var n = t - this.startTime;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7857 this.state = n / this.options.duration;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7858
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7859 // Perform the easing function, defaults to swing
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7860 var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7861 var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7862 this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7863 this.now = this.start + ((this.end - this.start) * this.pos);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7864
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7865 // Perform the next step of the animation
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7866 this.update();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7867 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7868
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7869 return true;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7870 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7871 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7872
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7873 jQuery.extend( jQuery.fx, {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7874 tick: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7875 var timers = jQuery.timers;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7876
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7877 for ( var i = 0; i < timers.length; i++ ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7878 if ( !timers[i]() ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7879 timers.splice(i--, 1);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7880 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7881 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7882
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7883 if ( !timers.length ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7884 jQuery.fx.stop();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7885 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7886 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7887
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7888 interval: 13,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7889
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7890 stop: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7891 clearInterval( timerId );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7892 timerId = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7893 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7894
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7895 speeds: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7896 slow: 600,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7897 fast: 200,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7898 // Default speed
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7899 _default: 400
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7900 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7901
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7902 step: {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7903 opacity: function( fx ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7904 jQuery.style( fx.elem, "opacity", fx.now );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7905 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7906
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7907 _default: function( fx ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7908 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7909 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7910 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7911 fx.elem[ fx.prop ] = fx.now;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7912 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7913 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7914 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7915 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7916
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7917 if ( jQuery.expr && jQuery.expr.filters ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7918 jQuery.expr.filters.animated = function( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7919 return jQuery.grep(jQuery.timers, function( fn ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7920 return elem === fn.elem;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7921 }).length;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7922 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7923 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7924
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7925 function defaultDisplay( nodeName ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7926 if ( !elemdisplay[ nodeName ] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7927 var elem = jQuery("<" + nodeName + ">").appendTo("body"),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7928 display = elem.css("display");
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7929
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7930 elem.remove();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7931
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7932 if ( display === "none" || display === "" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7933 display = "block";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7934 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7935
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7936 elemdisplay[ nodeName ] = display;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7937 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7938
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7939 return elemdisplay[ nodeName ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7940 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7941
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7942
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7943
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7944
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7945 var rtable = /^t(?:able|d|h)$/i,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7946 rroot = /^(?:body|html)$/i;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7947
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7948 if ( "getBoundingClientRect" in document.documentElement ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7949 jQuery.fn.offset = function( options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7950 var elem = this[0], box;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7951
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7952 if ( options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7953 return this.each(function( i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7954 jQuery.offset.setOffset( this, options, i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7955 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7956 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7957
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7958 if ( !elem || !elem.ownerDocument ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7959 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7960 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7961
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7962 if ( elem === elem.ownerDocument.body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7963 return jQuery.offset.bodyOffset( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7964 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7965
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7966 try {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7967 box = elem.getBoundingClientRect();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7968 } catch(e) {}
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7969
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7970 var doc = elem.ownerDocument,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7971 docElem = doc.documentElement;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7972
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7973 // Make sure we're not dealing with a disconnected DOM node
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7974 if ( !box || !jQuery.contains( docElem, elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7975 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7976 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7977
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7978 var body = doc.body,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7979 win = getWindow(doc),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7980 clientTop = docElem.clientTop || body.clientTop || 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7981 clientLeft = docElem.clientLeft || body.clientLeft || 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7982 scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7983 scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7984 top = box.top + scrollTop - clientTop,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7985 left = box.left + scrollLeft - clientLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7986
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7987 return { top: top, left: left };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7988 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7989
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7990 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7991 jQuery.fn.offset = function( options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7992 var elem = this[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7993
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7994 if ( options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7995 return this.each(function( i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7996 jQuery.offset.setOffset( this, options, i );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7997 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7998 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7999
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8000 if ( !elem || !elem.ownerDocument ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8001 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8002 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8003
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8004 if ( elem === elem.ownerDocument.body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8005 return jQuery.offset.bodyOffset( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8006 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8007
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8008 jQuery.offset.initialize();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8009
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8010 var computedStyle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8011 offsetParent = elem.offsetParent,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8012 prevOffsetParent = elem,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8013 doc = elem.ownerDocument,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8014 docElem = doc.documentElement,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8015 body = doc.body,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8016 defaultView = doc.defaultView,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8017 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8018 top = elem.offsetTop,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8019 left = elem.offsetLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8020
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8021 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8022 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8023 break;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8024 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8025
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8026 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8027 top -= elem.scrollTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8028 left -= elem.scrollLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8029
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8030 if ( elem === offsetParent ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8031 top += elem.offsetTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8032 left += elem.offsetLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8033
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8034 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8035 top += parseFloat( computedStyle.borderTopWidth ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8036 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8037 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8038
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8039 prevOffsetParent = offsetParent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8040 offsetParent = elem.offsetParent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8041 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8042
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8043 if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8044 top += parseFloat( computedStyle.borderTopWidth ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8045 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8046 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8047
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8048 prevComputedStyle = computedStyle;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8049 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8050
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8051 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8052 top += body.offsetTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8053 left += body.offsetLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8054 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8055
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8056 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8057 top += Math.max( docElem.scrollTop, body.scrollTop );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8058 left += Math.max( docElem.scrollLeft, body.scrollLeft );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8059 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8060
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8061 return { top: top, left: left };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8062 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8063 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8064
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8065 jQuery.offset = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8066 initialize: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8067 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8068 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>";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8069
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8070 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8071
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8072 container.innerHTML = html;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8073 body.insertBefore( container, body.firstChild );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8074 innerDiv = container.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8075 checkDiv = innerDiv.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8076 td = innerDiv.nextSibling.firstChild.firstChild;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8077
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8078 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8079 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8080
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8081 checkDiv.style.position = "fixed";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8082 checkDiv.style.top = "20px";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8083
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8084 // safari subtracts parent border width here which is 5px
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8085 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8086 checkDiv.style.position = checkDiv.style.top = "";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8087
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8088 innerDiv.style.overflow = "hidden";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8089 innerDiv.style.position = "relative";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8090
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8091 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8092
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8093 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8094
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8095 body.removeChild( container );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8096 body = container = innerDiv = checkDiv = table = td = null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8097 jQuery.offset.initialize = jQuery.noop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8098 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8099
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8100 bodyOffset: function( body ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8101 var top = body.offsetTop,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8102 left = body.offsetLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8103
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8104 jQuery.offset.initialize();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8105
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8106 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8107 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8108 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8109 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8110
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8111 return { top: top, left: left };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8112 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8113
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8114 setOffset: function( elem, options, i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8115 var position = jQuery.css( elem, "position" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8117 // set position first, in-case top/left are set even on static elem
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8118 if ( position === "static" ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8119 elem.style.position = "relative";
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8120 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8121
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8122 var curElem = jQuery( elem ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8123 curOffset = curElem.offset(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8124 curCSSTop = jQuery.css( elem, "top" ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8125 curCSSLeft = jQuery.css( elem, "left" ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8126 calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8127 props = {}, curPosition = {}, curTop, curLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8128
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8129 // need to be able to calculate position if either top or left is auto and position is absolute
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8130 if ( calculatePosition ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8131 curPosition = curElem.position();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8132 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8133
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8134 curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8135 curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8136
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8137 if ( jQuery.isFunction( options ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8138 options = options.call( elem, i, curOffset );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8139 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8140
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8141 if (options.top != null) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8142 props.top = (options.top - curOffset.top) + curTop;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8143 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8144 if (options.left != null) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8145 props.left = (options.left - curOffset.left) + curLeft;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8146 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8147
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8148 if ( "using" in options ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8149 options.using.call( elem, props );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8150 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8151 curElem.css( props );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8152 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8153 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8154 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8155
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8156
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8157 jQuery.fn.extend({
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8158 position: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8159 if ( !this[0] ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8160 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8161 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8162
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8163 var elem = this[0],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8164
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8165 // Get *real* offsetParent
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8166 offsetParent = this.offsetParent(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8167
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8168 // Get correct offsets
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8169 offset = this.offset(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8170 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8171
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8172 // Subtract element margins
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8173 // note: when an element has margin: auto the offsetLeft and marginLeft
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8174 // are the same in Safari causing offset.left to incorrectly be 0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8175 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8176 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8177
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8178 // Add offsetParent borders
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8179 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8180 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8181
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8182 // Subtract the two offsets
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8183 return {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8184 top: offset.top - parentOffset.top,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8185 left: offset.left - parentOffset.left
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8186 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8187 },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8188
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8189 offsetParent: function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8190 return this.map(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8191 var offsetParent = this.offsetParent || document.body;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8192 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8193 offsetParent = offsetParent.offsetParent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8194 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8195 return offsetParent;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8196 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8197 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8198 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8199
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8200
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8201 // Create scrollLeft and scrollTop methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8202 jQuery.each( ["Left", "Top"], function( i, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8203 var method = "scroll" + name;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8204
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8205 jQuery.fn[ method ] = function(val) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8206 var elem = this[0], win;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8207
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8208 if ( !elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8209 return null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8210 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8211
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8212 if ( val !== undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8213 // Set the scroll offset
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8214 return this.each(function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8215 win = getWindow( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8216
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8217 if ( win ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8218 win.scrollTo(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8219 !i ? val : jQuery(win).scrollLeft(),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8220 i ? val : jQuery(win).scrollTop()
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8221 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8222
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8223 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8224 this[ method ] = val;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8225 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8226 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8227 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8228 win = getWindow( elem );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8229
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8230 // Return the scroll offset
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8231 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8232 jQuery.support.boxModel && win.document.documentElement[ method ] ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8233 win.document.body[ method ] :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8234 elem[ method ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8235 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8236 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8237 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8238
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8239 function getWindow( elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8240 return jQuery.isWindow( elem ) ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8241 elem :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8242 elem.nodeType === 9 ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8243 elem.defaultView || elem.parentWindow :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8244 false;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8245 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8246
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8247
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8248
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8249
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8250 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8251 jQuery.each([ "Height", "Width" ], function( i, name ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8252
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8253 var type = name.toLowerCase();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8254
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8255 // innerHeight and innerWidth
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8256 jQuery.fn["inner" + name] = function() {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8257 return this[0] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8258 parseFloat( jQuery.css( this[0], type, "padding" ) ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8259 null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8260 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8261
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8262 // outerHeight and outerWidth
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8263 jQuery.fn["outer" + name] = function( margin ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8264 return this[0] ?
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8265 parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8266 null;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8267 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8268
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8269 jQuery.fn[ type ] = function( size ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8270 // Get window width or height
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8271 var elem = this[0];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8272 if ( !elem ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8273 return size == null ? null : this;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8274 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8275
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8276 if ( jQuery.isFunction( size ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8277 return this.each(function( i ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8278 var self = jQuery( this );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8279 self[ type ]( size.call( this, i, self[ type ]() ) );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8280 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8281 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8282
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8283 if ( jQuery.isWindow( elem ) ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8284 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8285 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8286 var docElemProp = elem.document.documentElement[ "client" + name ];
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8287 return elem.document.compatMode === "CSS1Compat" && docElemProp ||
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8288 elem.document.body[ "client" + name ] || docElemProp;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8289
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8290 // Get document width or height
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8291 } else if ( elem.nodeType === 9 ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8292 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8293 return Math.max(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8294 elem.documentElement["client" + name],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8295 elem.body["scroll" + name], elem.documentElement["scroll" + name],
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8296 elem.body["offset" + name], elem.documentElement["offset" + name]
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8297 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8298
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8299 // Get or set width or height on the element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8300 } else if ( size === undefined ) {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8301 var orig = jQuery.css( elem, type ),
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8302 ret = parseFloat( orig );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8303
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8304 return jQuery.isNaN( ret ) ? orig : ret;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8305
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8306 // Set the width or height on the element (default to pixels if value is unitless)
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8307 } else {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8308 return this.css( type, typeof size === "string" ? size : size + "px" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8309 }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8310 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8311
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8312 });
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8313
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8314
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8315 window.jQuery = window.$ = jQuery;
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8316 })(window);