Редакция 475 | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 475 | Редакция 682 | ||
---|---|---|---|
Строка 1... | Строка 1... | ||
1 | /*!
|
1 | /*!
|
2 | * jQuery JavaScript Library v1.4pre
|
2 | * jQuery JavaScript Library v1.3.2
|
3 | * http://jquery.com/
|
3 | * http://jquery.com/
|
4 | *
|
4 | *
|
5 | * Copyright (c) 2009 John Resig
|
5 | * Copyright (c) 2009 John Resig
|
6 | * Dual licensed under the MIT and GPL licenses.
|
6 | * Dual licensed under the MIT and GPL licenses.
|
7 | * http://docs.jquery.com/License
|
7 | * http://docs.jquery.com/License
|
8 | *
|
8 | *
|
9 | * Date: 2009-10-12 23:26:01 +0700 (Пнд, 12 Окт 2009)
|
9 | * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
|
10 | * Revision: 6617
|
10 | * Revision: 6246
|
11 | */
|
11 | */
|
12 | (function(window, undefined){ |
12 | (function(){ |
13 | - | ||
14 | // Define a local copy of jQuery
|
- | |
15 | var jQuery = function( selector, context ) { |
- | |
16 | // The jQuery object is actually just the init constructor 'enhanced'
|
- | |
17 | return arguments.length === 0 ? |
- | |
18 | rootjQuery :
|
- | |
19 | new jQuery.fn.init( selector, context ); |
- | |
20 | }, |
- | |
21 | 13 | ||
- | 14 | var
|
|
- | 15 | // Will speed up references to window, and allows munging its name.
|
|
- | 16 | window = this, |
|
- | 17 | // Will speed up references to undefined, and allows munging its name.
|
|
- | 18 | undefined, |
|
22 | // Map over jQuery in case of overwrite
|
19 | // Map over jQuery in case of overwrite
|
23 | _jQuery = window.jQuery, |
20 | _jQuery = window.jQuery, |
24 | - | ||
25 | // Map over the $ in case of overwrite
|
21 | // Map over the $ in case of overwrite
|
26 | _$ = window.$, |
22 | _$ = window.$, |
27 | 23 | ||
28 | // Use the correct document accordingly with window argument (sandbox)
|
24 | jQuery = window.jQuery = window.$ = function( selector, context ) { |
29 | document = window.document, |
25 | // The jQuery object is actually just the init constructor 'enhanced'
|
30 | - | ||
31 | // A central reference to the root jQuery(document)
|
26 | return new jQuery.fn.init( selector, context ); |
32 | rootjQuery,
|
27 | }, |
33 | 28 | ||
34 | // A simple way to check for HTML strings or ID strings
|
29 | // A simple way to check for HTML strings or ID strings
|
35 | // (both of which we optimize for)
|
30 | // (both of which we optimize for)
|
36 | quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
31 | quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, |
37 | - | ||
38 | // Is it a simple selector
|
32 | // Is it a simple selector
|
39 | isSimple = /^.[^:#\[\.,]*$/, |
33 | isSimple = /^.[^:#\[\.,]*$/; |
40 | - | ||
41 | // Check if a string has a non-whitespace character in it
|
- | |
42 | rnotwhite = /\S/, |
- | |
43 | - | ||
44 | // Used for trimming whitespace
|
- | |
45 | rtrim = /^\s+|\s+$/g, |
- | |
46 | - | ||
47 | // Match a standalone tag
|
- | |
48 | rsingleTag = /^<(\w+)\s*\/?>$/, |
- | |
49 | - | ||
50 | // Keep a UserAgent string for use with jQuery.browser
|
- | |
51 | userAgent = navigator.userAgent.toLowerCase(), |
- | |
52 | - | ||
53 | // Save a reference to some core methods
|
- | |
54 | toString = Object.prototype.toString, |
- | |
55 | push = Array.prototype.push, |
- | |
56 | slice = Array.prototype.slice, |
- | |
57 | indexOf = Array.prototype.indexOf; |
- | |
58 | 34 | ||
59 | jQuery.fn = jQuery.prototype = { |
35 | jQuery.fn = jQuery.prototype = { |
60 | init: function( selector, context ) { |
36 | init: function( selector, context ) { |
61 | var match, elem, ret, doc; |
- | |
62 | - | ||
63 | // Handle $(""), $(null), or $(undefined)
|
37 | // Make sure that a selection was provided
|
64 | if ( !selector ) { |
38 | selector = selector || document; |
65 | return this; |
- | |
66 | }
|
- | |
67 | 39 | ||
68 | // Handle $(DOMElement)
|
40 | // Handle $(DOMElement)
|
69 | if ( selector.nodeType ) { |
41 | if ( selector.nodeType ) { |
70 | this.context = this[0] = selector; |
42 | this[0] = selector; |
71 | this.length++; |
43 | this.length = 1; |
- | 44 | this.context = selector; |
|
72 | return this; |
45 | return this; |
73 | }
|
46 | }
|
74 | - | ||
75 | // Handle HTML strings
|
47 | // Handle HTML strings
|
76 | if ( typeof selector === "string" ) { |
48 | if ( typeof selector === "string" ) { |
77 | // Are we dealing with HTML string or an ID?
|
49 | // Are we dealing with HTML string or an ID?
|
78 | match = quickExpr.exec( selector ); |
50 | var match = quickExpr.exec( selector ); |
79 | 51 | ||
80 | // Verify a match, and that no context was specified for #id
|
52 | // Verify a match, and that no context was specified for #id
|
81 | if ( match && (match[1] || !context) ) { |
53 | if ( match && (match[1] || !context) ) { |
82 | 54 | ||
83 | // HANDLE: $(html) -> $(array)
|
55 | // HANDLE: $(html) -> $(array)
|
84 | if ( match[1] ) { |
56 | if ( match[1] ) |
85 | doc = (context ? context.ownerDocument || context : document); |
- | |
86 | - | ||
87 | // If a single string is passed in and it's a single tag
|
- | |
88 | // just do a createElement and skip the rest
|
- | |
89 | ret = rsingleTag.exec( selector ); |
- | |
90 | - | ||
91 | if ( ret ) { |
- | |
92 | selector = [ doc.createElement( ret[1] ) ]; |
- | |
93 | - | ||
94 | } else { |
- | |
95 | ret = buildFragment( [ match[1] ], [ doc ] ); |
57 | selector = jQuery.clean( [ match[1] ], context ); |
96 | selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
- | |
97 | }
|
- | |
98 | 58 | ||
99 | // HANDLE: $("#id")
|
59 | // HANDLE: $("#id")
|
100 | } else { |
60 | else { |
101 | elem = document.getElementById( match[2] ); |
61 | var elem = document.getElementById( match[3] ); |
102 | - | ||
103 | if ( elem ) { |
- | |
104 | // Handle the case where IE and Opera return items
|
- | |
105 | // by name instead of ID
|
- | |
106 | if ( elem.id !== match[2] ) { |
- | |
107 | return rootjQuery.find( selector ); |
- | |
108 | }
|
- | |
109 | - | ||
110 | // Otherwise, we inject the element directly into the jQuery object
|
- | |
111 | this.length++; |
- | |
112 | this[0] = elem; |
- | |
113 | }
|
- | |
114 | 62 | ||
- | 63 | // Handle the case where IE and Opera return items
|
|
115 | this.context = document; |
64 | // by name instead of ID
|
116 | this.selector = selector; |
65 | if ( elem && elem.id != match[3] ) |
117 | return this; |
66 | return jQuery().find( selector ); |
118 | }
|
- | |
119 | 67 | ||
120 | // HANDLE: $("TAG")
|
- | |
121 | } else if ( !context && /^\w+$/.test( selector ) ) { |
68 | // Otherwise, we inject the element directly into the jQuery object
|
122 | this.selector = selector; |
69 | var ret = jQuery( elem || [] ); |
123 | this.context = document; |
70 | ret.context = document; |
124 | selector = document.getElementsByTagName( selector ); |
71 | ret.selector = selector; |
125 | - | ||
126 | // HANDLE: $(expr, $(...))
|
72 | return ret; |
127 | } else if ( !context || context.jquery ) { |
73 | }
|
128 | return (context || rootjQuery).find( selector ); |
- | |
129 | 74 | ||
130 | // HANDLE: $(expr, context)
|
75 | // HANDLE: $(expr, [context])
|
131 | // (which is just equivalent to: $(context).find(expr)
|
76 | // (which is just equivalent to: $(content).find(expr)
|
132 | } else { |
77 | } else |
133 | return jQuery( context ).find( selector ); |
78 | return jQuery( context ).find( selector ); |
134 | }
|
- | |
135 | 79 | ||
136 | // HANDLE: $(function)
|
80 | // HANDLE: $(function)
|
137 | // Shortcut for document ready
|
81 | // Shortcut for document ready
|
138 | } else if ( jQuery.isFunction( selector ) ) { |
82 | } else if ( jQuery.isFunction( selector ) ) |
139 | return rootjQuery.ready( selector ); |
83 | return jQuery( document ).ready( selector ); |
140 | }
|
- | |
141 | 84 | ||
- | 85 | // Make sure that old selector state is passed along
|
|
142 | if (selector.selector !== undefined) { |
86 | if ( selector.selector && selector.context ) { |
143 | this.selector = selector.selector; |
87 | this.selector = selector.selector; |
144 | this.context = selector.context; |
88 | this.context = selector.context; |
145 | }
|
89 | }
|
146 | 90 | ||
147 | return this.setArray(jQuery.isArray( selector ) ? |
91 | return this.setArray(jQuery.isArray( selector ) ? |
Строка 151... | Строка 95... | ||
151 | 95 | ||
152 | // Start with an empty selector
|
96 | // Start with an empty selector
|
153 | selector: "", |
97 | selector: "", |
154 | 98 | ||
155 | // The current version of jQuery being used
|
99 | // The current version of jQuery being used
|
156 | jquery: "1.4pre", |
100 | jquery: "1.3.2", |
157 | - | ||
158 | // The default length of a jQuery object is 0
|
- | |
159 | length: 0, |
- | |
160 | 101 | ||
161 | // The number of elements contained in the matched element set
|
102 | // The number of elements contained in the matched element set
|
162 | size: function() { |
103 | size: function() { |
163 | return this.length; |
104 | return this.length; |
164 | }, |
105 | }, |
165 | 106 | ||
166 | toArray: function(){ |
- | |
167 | return slice.call( this, 0 ); |
- | |
168 | }, |
- | |
169 | - | ||
170 | // Get the Nth element in the matched element set OR
|
107 | // Get the Nth element in the matched element set OR
|
171 | // Get the whole matched element set as a clean array
|
108 | // Get the whole matched element set as a clean array
|
172 | get: function( num ) { |
109 | get: function( num ) { |
173 | return num == null ? |
110 | return num === undefined ? |
174 | 111 | ||
175 | // Return a 'clean' array
|
112 | // Return a 'clean' array
|
176 | this.toArray() : |
113 | Array.prototype.slice.call( this ) : |
177 | 114 | ||
178 | // Return just the object
|
115 | // Return just the object
|
179 | ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
116 | this[ num ]; |
180 | }, |
117 | }, |
181 | 118 | ||
182 | // Take an array of elements and push it onto the stack
|
119 | // Take an array of elements and push it onto the stack
|
183 | // (returning the new matched element set)
|
120 | // (returning the new matched element set)
|
184 | pushStack: function( elems, name, selector ) { |
121 | pushStack: function( elems, name, selector ) { |
185 | // Build a new jQuery matched element set
|
122 | // Build a new jQuery matched element set
|
186 | var ret = jQuery( elems || null ); |
123 | var ret = jQuery( elems ); |
187 | 124 | ||
188 | // Add the old object onto the stack (as a reference)
|
125 | // Add the old object onto the stack (as a reference)
|
189 | ret.prevObject = this; |
126 | ret.prevObject = this; |
190 | 127 | ||
191 | ret.context = this.context; |
128 | ret.context = this.context; |
192 | 129 | ||
193 | if ( name === "find" ) { |
130 | if ( name === "find" ) |
194 | ret.selector = this.selector + (this.selector ? " " : "") + selector; |
131 | ret.selector = this.selector + (this.selector ? " " : "") + selector; |
195 | } else if ( name ) { |
132 | else if ( name ) |
196 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
133 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
197 | }
|
- | |
198 | 134 | ||
199 | // Return the newly-formed element set
|
135 | // Return the newly-formed element set
|
200 | return ret; |
136 | return ret; |
201 | }, |
137 | }, |
202 | 138 | ||
Строка 205... | Строка 141... | ||
205 | // You should use pushStack() in order to do this, but maintain the stack
|
141 | // You should use pushStack() in order to do this, but maintain the stack
|
206 | setArray: function( elems ) { |
142 | setArray: function( elems ) { |
207 | // Resetting the length to 0, then using the native Array push
|
143 | // Resetting the length to 0, then using the native Array push
|
208 | // is a super-fast way to populate an object with array-like properties
|
144 | // is a super-fast way to populate an object with array-like properties
|
209 | this.length = 0; |
145 | this.length = 0; |
210 | push.apply( this, elems ); |
146 | Array.prototype.push.apply( this, elems ); |
211 | 147 | ||
212 | return this; |
148 | return this; |
213 | }, |
149 | }, |
214 | 150 | ||
215 | // Execute a callback for every element in the matched set.
|
151 | // Execute a callback for every element in the matched set.
|
Строка 220... | Строка 156... | ||
220 | }, |
156 | }, |
221 | 157 | ||
222 | // Determine the position of an element within
|
158 | // Determine the position of an element within
|
223 | // the matched set of elements
|
159 | // the matched set of elements
|
224 | index: function( elem ) { |
160 | index: function( elem ) { |
225 | if ( !elem || typeof elem === "string" ) { |
- | |
226 | return jQuery.inArray( this[0], |
- | |
227 | // If it receives a string, the selector is used
|
- | |
228 | // If it receives nothing, the siblings are used
|
- | |
229 | elem ? jQuery( elem ) : this.parent().children() ); |
- | |
230 | }
|
- | |
231 | // Locate the position of the desired element
|
161 | // Locate the position of the desired element
|
232 | return jQuery.inArray( |
162 | return jQuery.inArray( |
233 | // If it receives a jQuery object, the first element is used
|
163 | // If it receives a jQuery object, the first element is used
|
234 | elem.jquery ? elem[0] : elem, this ); |
164 | elem && elem.jquery ? elem[0] : elem |
- | 165 | , this ); |
|
235 | }, |
166 | }, |
236 | 167 | ||
237 | is: function( selector ) { |
168 | attr: function( name, value, type ) { |
238 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
- | |
239 | }, |
- | |
240 | - | ||
241 | // For internal use only.
|
- | |
242 | // Behaves like an Array's method, not like a jQuery method.
|
- | |
243 | push: push, |
- | |
244 | sort: [].sort, |
- | |
245 | splice: [].splice |
- | |
246 | }; |
- | |
247 | - | ||
248 | // Give the init function the jQuery prototype for later instantiation
|
- | |
249 | jQuery.fn.init.prototype = jQuery.fn; |
- | |
250 | - | ||
251 | jQuery.extend = jQuery.fn.extend = function() { |
- | |
252 | // copy reference to target object
|
- | |
253 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
- | |
254 | - | ||
255 | // Handle a deep copy situation
|
- | |
256 | if ( typeof target === "boolean" ) { |
- | |
257 | deep = target; |
169 | var options = name; |
258 | target = arguments[1] || {}; |
- | |
259 | // skip the boolean and the target
|
- | |
260 | i = 2; |
- | |
261 | }
|
- | |
262 | 170 | ||
263 | // Handle case when target is a string or something (possible in deep copy)
|
171 | // Look for the case where we're accessing a style value
|
264 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
172 | if ( typeof name === "string" ) |
- | 173 | if ( value === undefined ) |
|
- | 174 | return this[0] && jQuery[ type || "attr" ]( this[0], name ); |
|
- | 175 | ||
- | 176 | else { |
|
265 | target = {}; |
177 | options = {}; |
- | 178 | options[ name ] = value; |
|
- | 179 | }
|
|
- | 180 | ||
- | 181 | // Check to see if we're setting style values
|
|
- | 182 | return this.each(function(i){ |
|
- | 183 | // Set all the styles
|
|
- | 184 | for ( name in options ) |
|
- | 185 | jQuery.attr( |
|
- | 186 | type ?
|
|
- | 187 | this.style : |
|
- | 188 | this, |
|
- | 189 | name, jQuery.prop( this, options[ name ], type, i, name ) |
|
- | 190 | ); |
|
- | 191 | }); |
|
266 | }
|
192 | }, |
267 | 193 | ||
- | 194 | css: function( key, value ) { |
|
268 | // extend jQuery itself if only one argument is passed
|
195 | // ignore negative width and height values
|
269 | if ( length === i ) { |
196 | if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) |
270 | target = this; |
197 | value = undefined; |
271 | --i; |
198 | return this.attr( key, value, "curCSS" ); |
272 | }
|
199 | }, |
273 | 200 | ||
274 | for ( ; i < length; i++ ) { |
201 | text: function( text ) { |
275 | // Only deal with non-null/undefined values
|
- | |
276 | if ( (options = arguments[ i ]) != null ) { |
202 | if ( typeof text !== "object" && text != null ) |
277 | // Extend the base object
|
203 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
278 | for ( name in options ) { |
- | |
279 | src = target[ name ]; |
- | |
280 | copy = options[ name ]; |
- | |
281 | 204 | ||
282 | // Prevent never-ending loop
|
- | |
283 | if ( target === copy ) { |
- | |
284 | continue; |
205 | var ret = ""; |
285 | }
|
- | |
286 | 206 | ||
287 | // Recurse if we're merging object values
|
207 | jQuery.each( text || this, function(){ |
288 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
208 | jQuery.each( this.childNodes, function(){ |
- | 209 | if ( this.nodeType != 8 ) |
|
- | 210 | ret += this.nodeType != 1 ? |
|
289 | var clone; |
211 | this.nodeValue : |
- | 212 | jQuery.fn.text( [ this ] ); |
|
- | 213 | }); |
|
- | 214 | }); |
|
290 | 215 | ||
291 | if ( src ) { |
- | |
292 | clone = src; |
- | |
293 | } else if ( jQuery.isArray(copy) ) { |
- | |
294 | clone = []; |
- | |
295 | } else if ( jQuery.isObject(copy) ) { |
- | |
296 | clone = {}; |
- | |
297 | } else { |
216 | return ret; |
298 | clone = copy; |
- | |
299 | }
|
217 | }, |
300 | 218 | ||
- | 219 | wrapAll: function( html ) { |
|
- | 220 | if ( this[0] ) { |
|
301 | // Never move original objects, clone them
|
221 | // The elements to wrap the target around
|
302 | target[ name ] = jQuery.extend( deep, clone, copy ); |
222 | var wrap = jQuery( html, this[0].ownerDocument ).clone(); |
303 | 223 | ||
304 | // Don't bring in undefined values
|
- | |
305 | } else if ( copy !== undefined ) { |
224 | if ( this[0].parentNode ) |
306 | target[ name ] = copy; |
225 | wrap.insertBefore( this[0] ); |
307 | }
|
- | |
308 | }
|
- | |
309 | }
|
- | |
310 | }
|
- | |
311 | 226 | ||
312 | // Return the modified object
|
227 | wrap.map(function(){ |
313 | return target; |
228 | var elem = this; |
314 | }; |
- | |
315 | 229 | ||
316 | jQuery.extend({ |
- | |
317 | noConflict: function( deep ) { |
230 | while ( elem.firstChild ) |
318 | window.$ = _$; |
231 | elem = elem.firstChild; |
319 | 232 | ||
320 | if ( deep ) { |
233 | return elem; |
321 | window.jQuery = _jQuery; |
234 | }).append(this); |
322 | }
|
235 | }
|
323 | 236 | ||
324 | return jQuery; |
237 | return this; |
325 | }, |
238 | }, |
326 | 239 | ||
327 | // See test/unit/core.js for details concerning isFunction.
|
- | |
328 | // Since version 1.3, DOM methods and functions like alert
|
240 | wrapInner: function( html ) { |
329 | // aren't supported. They return false on IE (#2968).
|
- | |
330 | isFunction: function( obj ) { |
241 | return this.each(function(){ |
331 | return toString.call(obj) === "[object Function]"; |
242 | jQuery( this ).contents().wrapAll( html ); |
- | 243 | }); |
|
332 | }, |
244 | }, |
333 | 245 | ||
334 | isArray: function( obj ) { |
246 | wrap: function( html ) { |
335 | return toString.call(obj) === "[object Array]"; |
247 | return this.each(function(){ |
- | 248 | jQuery( this ).wrapAll( html ); |
|
- | 249 | }); |
|
336 | }, |
250 | }, |
337 | 251 | ||
338 | isObject: function( obj ) { |
252 | append: function() { |
339 | return this.constructor.call(obj) === Object; |
253 | return this.domManip(arguments, true, function(elem){ |
- | 254 | if (this.nodeType == 1) |
|
- | 255 | this.appendChild( elem ); |
|
- | 256 | }); |
|
340 | }, |
257 | }, |
341 | 258 | ||
342 | isEmptyObject: function( obj ) { |
259 | prepend: function() { |
- | 260 | return this.domManip(arguments, true, function(elem){ |
|
343 | for ( var name in obj ) { |
261 | if (this.nodeType == 1) |
344 | return false; |
262 | this.insertBefore( elem, this.firstChild ); |
345 | }
|
263 | }); |
346 | return true; |
- | |
347 | }, |
264 | }, |
348 | 265 | ||
349 | // check if an element is in a (or is an) XML document
|
- | |
350 | isXMLDoc: function( elem ) { |
266 | before: function() { |
351 | // documentElement is verified for cases where it doesn't yet exist
|
267 | return this.domManip(arguments, false, function(elem){ |
352 | // (such as loading iframes in IE - #4833)
|
268 | this.parentNode.insertBefore( elem, this ); |
353 | var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
- | |
354 | return documentElement ? documentElement.nodeName !== "HTML" : false; |
- | |
- | 269 | }); |
|
355 | }, |
270 | }, |
356 | 271 | ||
357 | // Evalulates a script in a global context
|
- | |
358 | globalEval: function( data ) { |
272 | after: function() { |
359 | if ( data && rnotwhite.test(data) ) { |
- | |
360 | // Inspired by code by Andrea Giammarchi
|
- | |
361 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
- | |
362 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
273 | return this.domManip(arguments, false, function(elem){ |
363 | script = document.createElement("script"); |
274 | this.parentNode.insertBefore( elem, this.nextSibling ); |
- | 275 | }); |
|
- | 276 | }, |
|
364 | 277 | ||
- | 278 | end: function() { |
|
365 | script.type = "text/javascript"; |
279 | return this.prevObject || jQuery( [] ); |
- | 280 | }, |
|
366 | 281 | ||
367 | if ( jQuery.support.scriptEval ) { |
282 | // For internal use only.
|
368 | script.appendChild( document.createTextNode( data ) ); |
283 | // Behaves like an Array's method, not like a jQuery method.
|
369 | } else { |
284 | push: [].push, |
370 | script.text = data; |
285 | sort: [].sort, |
371 | }
|
286 | splice: [].splice, |
372 | 287 | ||
- | 288 | find: function( selector ) { |
|
- | 289 | if ( this.length === 1 ) { |
|
373 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
290 | var ret = this.pushStack( [], "find", selector ); |
- | 291 | ret.length = 0; |
|
374 | // This arises when a base node is used (#2709).
|
292 | jQuery.find( selector, this[0], ret ); |
- | 293 | return ret; |
|
- | 294 | } else { |
|
- | 295 | return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ |
|
375 | head.insertBefore( script, head.firstChild ); |
296 | return jQuery.find( selector, elem ); |
376 | head.removeChild( script ); |
297 | })), "find", selector ); |
377 | }
|
298 | }
|
378 | }, |
299 | }, |
379 | 300 | ||
380 | nodeName: function( elem, name ) { |
301 | clone: function( events ) { |
- | 302 | // Do the clone
|
|
- | 303 | var ret = this.map(function(){ |
|
- | 304 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
|
- | 305 | // IE copies events bound via attachEvent when
|
|
- | 306 | // using cloneNode. Calling detachEvent on the
|
|
381 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
307 | // clone will also remove the events from the orignal
|
- | 308 | // In order to get around this, we use innerHTML.
|
|
- | 309 | // Unfortunately, this means some modifications to
|
|
- | 310 | // attributes in IE that are actually only stored
|
|
- | 311 | // as properties will not be copied (such as the
|
|
- | 312 | // the name attribute on an input).
|
|
- | 313 | var html = this.outerHTML; |
|
- | 314 | if ( !html ) { |
|
- | 315 | var div = this.ownerDocument.createElement("div"); |
|
- | 316 | div.appendChild( this.cloneNode(true) ); |
|
- | 317 | html = div.innerHTML; |
|
382 | }, |
318 | }
|
383 | 319 | ||
384 | // args is for internal usage only
|
- | |
385 | each: function( object, callback, args ) { |
320 | return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; |
386 | var name, i = 0, |
321 | } else |
387 | length = object.length, |
322 | return this.cloneNode(true); |
388 | isObj = length === undefined || jQuery.isFunction(object); |
- | |
- | 323 | }); |
|
389 | 324 | ||
390 | if ( args ) { |
- | |
391 | if ( isObj ) { |
- | |
392 | for ( name in object ) { |
- | |
393 | if ( callback.apply( object[ name ], args ) === false ) { |
325 | // Copy the events from the original to the clone
|
394 | break; |
- | |
395 | }
|
- | |
396 | }
|
- | |
397 | } else { |
- | |
398 | for ( ; i < length; ) { |
326 | if ( events === true ) { |
399 | if ( callback.apply( object[ i++ ], args ) === false ) { |
327 | var orig = this.find("*").andSelf(), i = 0; |
400 | break; |
- | |
401 | }
|
- | |
402 | }
|
- | |
403 | }
|
- | |
404 | 328 | ||
- | 329 | ret.find("*").andSelf().each(function(){ |
|
405 | // A special, fast, case for the most common use of each
|
330 | if ( this.nodeName !== orig[i].nodeName ) |
406 | } else { |
331 | return; |
- | 332 | ||
- | 333 | var events = jQuery.data( orig[i], "events" ); |
|
- | 334 | ||
407 | if ( isObj ) { |
335 | for ( var type in events ) { |
408 | for ( name in object ) { |
336 | for ( var handler in events[ type ] ) { |
409 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
337 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
410 | break; |
- | |
411 | }
|
338 | }
|
412 | }
|
339 | }
|
- | 340 | ||
413 | } else { |
341 | i++;
|
414 | for ( var value = object[0]; |
- | |
415 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
- | |
416 | }
|
342 | }); |
417 | }
|
343 | }
|
418 | 344 | ||
- | 345 | // Return the cloned set
|
|
419 | return object; |
346 | return ret; |
420 | }, |
347 | }, |
421 | 348 | ||
422 | trim: function( text ) { |
349 | filter: function( selector ) { |
- | 350 | return this.pushStack( |
|
- | 351 | jQuery.isFunction( selector ) && |
|
- | 352 | jQuery.grep(this, function(elem, i){ |
|
423 | return (text || "").replace( rtrim, "" ); |
353 | return selector.call( elem, i ); |
- | 354 | }) || |
|
- | 355 | ||
- | 356 | jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ |
|
- | 357 | return elem.nodeType === 1; |
|
- | 358 | }) ), "filter", selector ); |
|
424 | }, |
359 | }, |
425 | 360 | ||
426 | makeArray: function( array ) { |
361 | closest: function( selector ) { |
427 | var ret = [], i; |
- | |
428 | - | ||
429 | if ( array != null ) { |
362 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
430 | i = array.length; |
363 | closer = 0; |
431 | 364 | ||
432 | // The window, strings (and functions) also have 'length'
|
365 | return this.map(function(){ |
433 | if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
- | |
434 | ret[0] = array; |
366 | var cur = this; |
435 | } else { |
367 | while ( cur && cur.ownerDocument ) { |
- | 368 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
|
436 | while ( i ) { |
369 | jQuery.data(cur, "closest", closer); |
437 | ret[--i] = array[i]; |
370 | return cur; |
438 | }
|
371 | }
|
- | 372 | cur = cur.parentNode; |
|
- | 373 | closer++;
|
|
439 | }
|
374 | }
|
440 | }
|
375 | }); |
441 | - | ||
442 | return ret; |
- | |
443 | }, |
376 | }, |
444 | 377 | ||
445 | inArray: function( elem, array ) { |
378 | not: function( selector ) { |
- | 379 | if ( typeof selector === "string" ) |
|
446 | for ( var i = 0, length = array.length; i < length; i++ ) { |
380 | // test special case where just one selector is passed in
|
447 | if ( array[ i ] === elem ) { |
381 | if ( isSimple.test( selector ) ) |
448 | return i; |
382 | return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); |
449 | }
|
383 | else
|
450 | }
|
- | |
- | 384 | selector = jQuery.multiFilter( selector, this ); |
|
451 | 385 | ||
- | 386 | var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
|
- | 387 | return this.filter(function() { |
|
- | 388 | return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
|
452 | return -1; |
389 | }); |
453 | }, |
390 | }, |
454 | 391 | ||
455 | merge: function( first, second ) { |
392 | add: function( selector ) { |
456 | // We have to loop this way because IE & Opera overwrite the length
|
393 | return this.pushStack( jQuery.unique( jQuery.merge( |
- | 394 | this.get(), |
|
457 | // expando of getElementsByTagName
|
395 | typeof selector === "string" ? |
- | 396 | jQuery( selector ) : |
|
458 | var i = 0, elem, pos = first.length; |
397 | jQuery.makeArray( selector ) |
- | 398 | ))); |
|
- | 399 | }, |
|
459 | 400 | ||
- | 401 | is: function( selector ) { |
|
460 | // Also, we need to make sure that the correct elements are being returned
|
402 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
- | 403 | }, |
|
- | 404 | ||
- | 405 | hasClass: function( selector ) { |
|
461 | // (IE returns comment nodes in a '*' query)
|
406 | return !!selector && this.is( "." + selector ); |
- | 407 | }, |
|
- | 408 | ||
- | 409 | val: function( value ) { |
|
462 | if ( !jQuery.support.getAll ) { |
410 | if ( value === undefined ) { |
- | 411 | var elem = this[0]; |
|
- | 412 | ||
- | 413 | if ( elem ) { |
|
- | 414 | if( jQuery.nodeName( elem, 'option' ) ) |
|
- | 415 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
|
- | 416 | ||
- | 417 | // We need to handle select boxes special
|
|
463 | while ( (elem = second[ i++ ]) != null ) { |
418 | if ( jQuery.nodeName( elem, "select" ) ) { |
- | 419 | var index = elem.selectedIndex, |
|
- | 420 | values = [], |
|
- | 421 | options = elem.options, |
|
- | 422 | one = elem.type == "select-one"; |
|
- | 423 | ||
- | 424 | // Nothing was selected
|
|
- | 425 | if ( index < 0 ) |
|
- | 426 | return null; |
|
- | 427 | ||
- | 428 | // Loop through all the selected options
|
|
- | 429 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
|
- | 430 | var option = options[ i ]; |
|
- | 431 | ||
464 | if ( elem.nodeType !== 8 ) { |
432 | if ( option.selected ) { |
- | 433 | // Get the specifc value for the option
|
|
- | 434 | value = jQuery(option).val(); |
|
- | 435 | ||
- | 436 | // We don't need an array for one selects
|
|
- | 437 | if ( one ) |
|
- | 438 | return value; |
|
- | 439 | ||
- | 440 | // Multi-Selects return an array
|
|
465 | first[ pos++ ] = elem; |
441 | values.push( value ); |
- | 442 | }
|
|
- | 443 | }
|
|
- | 444 | ||
- | 445 | return values; |
|
466 | }
|
446 | }
|
467 | }
|
- | |
468 | 447 | ||
469 | } else { |
- | |
470 | while ( (elem = second[ i++ ]) != null ) { |
448 | // Everything else, we just grab the value
|
471 | first[ pos++ ] = elem; |
449 | return (elem.value || "").replace(/\r/g, ""); |
- | 450 | ||
472 | }
|
451 | }
|
- | 452 | ||
- | 453 | return undefined; |
|
473 | }
|
454 | }
|
474 | 455 | ||
- | 456 | if ( typeof value === "number" ) |
|
475 | return first; |
457 | value += ''; |
476 | }, |
- | |
477 | 458 | ||
478 | grep: function( elems, callback, inv ) { |
459 | return this.each(function(){ |
- | 460 | if ( this.nodeType != 1 ) |
|
479 | var ret = []; |
461 | return; |
480 | 462 | ||
481 | // Go through the array, only saving the items
|
- | |
482 | // that pass the validator function
|
- | |
483 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
463 | if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) |
484 | if ( !inv !== !callback( elems[ i ], i ) ) { |
464 | this.checked = (jQuery.inArray(this.value, value) >= 0 || |
485 | ret.push( elems[ i ] ); |
465 | jQuery.inArray(this.name, value) >= 0); |
486 | }
|
- | |
487 | }
|
- | |
488 | 466 | ||
- | 467 | else if ( jQuery.nodeName( this, "select" ) ) { |
|
- | 468 | var values = jQuery.makeArray(value); |
|
- | 469 | ||
- | 470 | jQuery( "option", this ).each(function(){ |
|
- | 471 | this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
|
- | 472 | jQuery.inArray( this.text, values ) >= 0); |
|
- | 473 | }); |
|
- | 474 | ||
- | 475 | if ( !values.length ) |
|
- | 476 | this.selectedIndex = -1; |
|
- | 477 | ||
489 | return ret; |
478 | } else |
- | 479 | this.value = value; |
|
- | 480 | }); |
|
490 | }, |
481 | }, |
491 | 482 | ||
492 | map: function( elems, callback ) { |
483 | html: function( value ) { |
- | 484 | return value === undefined ? |
|
- | 485 | (this[0] ? |
|
- | 486 | this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : |
|
- | 487 | null) : |
|
493 | var ret = [], value; |
488 | this.empty().append( value ); |
- | 489 | }, |
|
494 | 490 | ||
495 | // Go through the array, translating each of the items to their
|
- | |
496 | // new value (or values).
|
491 | replaceWith: function( value ) { |
497 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
- | |
498 | value = callback( elems[ i ], i ); |
492 | return this.after( value ).remove(); |
- | 493 | }, |
|
499 | 494 | ||
500 | if ( value != null ) { |
495 | eq: function( i ) { |
501 | ret[ ret.length ] = value; |
496 | return this.slice( i, +i + 1 ); |
502 | }
|
- | |
503 | }
|
497 | }, |
504 | 498 | ||
- | 499 | slice: function() { |
|
505 | return ret.concat.apply( [], ret ); |
500 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
- | 501 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
|
506 | }, |
502 | }, |
507 | 503 | ||
508 | // Use of jQuery.browser is deprecated.
|
504 | map: function( callback ) { |
509 | // It's included for backwards compatibility and plugins,
|
505 | return this.pushStack( jQuery.map(this, function(elem, i){ |
510 | // although they should work to migrate away.
|
- | |
511 | browser: { |
- | |
512 | version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1], |
- | |
513 | safari: /webkit/.test( userAgent ), |
- | |
514 | opera: /opera/.test( userAgent ), |
506 | return callback.call( elem, i, elem ); |
515 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
- | |
516 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
- | |
517 | }
|
507 | })); |
518 | }); |
508 | }, |
519 | 509 | ||
- | 510 | andSelf: function() { |
|
- | 511 | return this.add( this.prevObject ); |
|
- | 512 | }, |
|
- | 513 | ||
- | 514 | domManip: function( args, table, callback ) { |
|
520 | if ( indexOf ) { |
515 | if ( this[0] ) { |
- | 516 | var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), |
|
- | 517 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), |
|
- | 518 | first = fragment.firstChild; |
|
- | 519 | ||
- | 520 | if ( first ) |
|
- | 521 | for ( var i = 0, l = this.length; i < l; i++ ) |
|
- | 522 | callback.call( root(this[i], first), this.length > 1 || i > 0 ? |
|
- | 523 | fragment.cloneNode(true) : fragment ); |
|
- | 524 | ||
- | 525 | if ( scripts ) |
|
521 | jQuery.inArray = function( elem, array ) { |
526 | jQuery.each( scripts, evalScript ); |
- | 527 | }
|
|
- | 528 | ||
- | 529 | return this; |
|
- | 530 | ||
522 | return indexOf.call( array, elem ); |
531 | function root( elem, cur ) { |
- | 532 | return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? |
|
- | 533 | (elem.getElementsByTagName("tbody")[0] || |
|
- | 534 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
|
- | 535 | elem;
|
|
- | 536 | }
|
|
523 | }; |
537 | }
|
524 | }
|
538 | }; |
525 | 539 | ||
526 | // All jQuery objects should point back to these
|
540 | // Give the init function the jQuery prototype for later instantiation
|
527 | rootjQuery = jQuery(document); |
541 | jQuery.fn.init.prototype = jQuery.fn; |
528 | 542 | ||
529 | function evalScript( i, elem ) { |
543 | function evalScript( i, elem ) { |
530 | if ( elem.src ) { |
544 | if ( elem.src ) |
531 | jQuery.ajax({ |
545 | jQuery.ajax({ |
532 | url: elem.src, |
546 | url: elem.src, |
533 | async: false, |
547 | async: false, |
534 | dataType: "script" |
548 | dataType: "script" |
535 | }); |
549 | }); |
- | 550 | ||
536 | } else { |
551 | else
|
537 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
552 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
538 | }
|
- | |
539 | 553 | ||
540 | if ( elem.parentNode ) { |
554 | if ( elem.parentNode ) |
541 | elem.parentNode.removeChild( elem ); |
555 | elem.parentNode.removeChild( elem ); |
542 | }
|
- | |
543 | }
|
556 | }
|
544 | 557 | ||
- | 558 | function now(){ |
|
545 | // Mutifunctional method to get and set values to a collection
|
559 | return +new Date; |
- | 560 | }
|
|
- | 561 | ||
546 | // The value/s can be optionally by executed if its a function
|
562 | jQuery.extend = jQuery.fn.extend = function() { |
547 | function access( elems, key, value, exec, fn ) { |
563 | // copy reference to target object
|
548 | var l = elems.length; |
564 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; |
549 | 565 | ||
550 | // Setting many attributes
|
566 | // Handle a deep copy situation
|
551 | if ( typeof key === "object" ) { |
567 | if ( typeof target === "boolean" ) { |
- | 568 | deep = target; |
|
552 | for (var k in key) { |
569 | target = arguments[1] || {}; |
553 | access(elems, k, key[k], exec, fn); |
570 | // skip the boolean and the target
|
554 | }
|
571 | i = 2; |
555 | return elems; |
- | |
556 | }
|
572 | }
|
557 | 573 | ||
558 | // Setting one attribute
|
- | |
559 | if (value !== undefined) { |
- | |
560 | // Optionally, function values get executed if exec is true
|
574 | // Handle case when target is a string or something (possible in deep copy)
|
561 | exec = exec && jQuery.isFunction(value); |
575 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) |
- | 576 | target = {}; |
|
562 | 577 | ||
563 | for (var i = 0; i < l; i++) { |
578 | // extend jQuery itself if only one argument is passed
|
564 | var elem = elems[i], |
579 | if ( length == i ) { |
565 | val = exec ? value.call(elem, i) : value; |
- | |
566 | fn(elem, key, val); |
580 | target = this; |
567 | }
|
581 | --i; |
568 | return elems; |
- | |
569 | }
|
582 | }
|
570 | - | ||
571 | // Getting an attribute
|
- | |
572 | return l ? fn(elems[0], key) : null; |
- | |
573 | }
|
- | |
574 | 583 | ||
575 | function now() { |
- | |
576 | return (new Date).getTime(); |
- | |
577 | }
|
- | |
578 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
- | |
579 | var emptyObject = {}; |
- | |
580 | - | ||
581 | jQuery.extend({ |
- | |
582 | cache: {}, |
- | |
583 | - | ||
584 | expando:expando, |
- | |
585 | - | ||
586 | data: function( elem, name, data ) { |
- | |
587 | elem = elem == window ? |
- | |
588 | windowData :
|
- | |
589 | elem;
|
- | |
590 | - | ||
591 | var id = elem[ expando ], cache = jQuery.cache, thisCache; |
- | |
592 | - | ||
593 | // Handle the case where there's no name immediately
|
- | |
594 | if ( !name && !id ) { |
584 | for ( ; i < length; i++ ) |
595 | return null; |
- | |
596 | }
|
- | |
597 | - | ||
598 | // Compute a unique ID for the element
|
- | |
599 | if ( !id ) { |
- | |
600 | id = ++uuid; |
- | |
601 | }
|
- | |
602 | - | ||
603 | // Avoid generating a new cache unless none exists and we
|
- | |
604 | // want to manipulate it.
|
- | |
605 | if ( cache[ id ] ) { |
- | |
606 | thisCache = cache[ id ]; |
- | |
607 | } else if ( typeof data === "undefined" ) { |
- | |
608 | thisCache = emptyObject; |
- | |
609 | } else { |
- | |
610 | thisCache = cache[ id ] = {}; |
- | |
611 | }
|
- | |
612 | - | ||
613 | // Prevent overriding the named cache with undefined values
|
585 | // Only deal with non-null/undefined values
|
614 | if ( data !== undefined ) { |
586 | if ( (options = arguments[ i ]) != null ) |
615 | elem[ expando ] = id; |
- | |
616 | thisCache[ name ] = data; |
- | |
617 | }
|
- | |
618 | - | ||
619 | return name ? thisCache[ name ] : thisCache; |
- | |
620 | }, |
- | |
621 | - | ||
622 | removeData: function( elem, name ) { |
- | |
623 | elem = elem == window ? |
- | |
624 | windowData :
|
- | |
625 | elem;
|
- | |
626 | - | ||
627 | var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
- | |
628 | - | ||
629 | // If we want to remove a specific section of the element's data
|
- | |
630 | if ( name ) { |
- | |
631 | if ( thisCache ) { |
- | |
632 | // Remove the section of cache data
|
- | |
633 | delete thisCache[ name ]; |
- | |
634 | - | ||
635 | // If we've removed all the data, remove the element's cache
|
- | |
636 | if ( jQuery.isEmptyObject(thisCache) ) { |
- | |
637 | jQuery.removeData( elem ); |
- | |
638 | }
|
- | |
639 | }
|
- | |
640 | - | ||
641 | // Otherwise, we want to remove all of the element's data
|
- | |
642 | } else { |
- | |
643 | // Clean up the element expando
|
587 | // Extend the base object
|
644 | try { |
- | |
645 | delete elem[ expando ]; |
- | |
646 | } catch( e ) { |
- | |
647 | // IE has trouble directly removing the expando
|
- | |
648 | // but it's ok with using removeAttribute
|
- | |
649 | if ( elem.removeAttribute ) { |
- | |
650 | elem.removeAttribute( expando ); |
- | |
651 | }
|
- | |
652 | }
|
- | |
653 | - | ||
654 | // Completely remove the data cache
|
- | |
655 | delete cache[ id ]; |
- | |
656 | }
|
- | |
657 | }, |
- | |
658 | - | ||
659 | queue: function( elem, type, data ) { |
- | |
660 | if( !elem ) return; |
- | |
661 | - | ||
662 | type = (type || "fx") + "queue"; |
- | |
663 | var q = jQuery.data( elem, type ); |
- | |
664 | - | ||
665 | // Speed up dequeue by getting out quickly if this is just a lookup
|
- | |
666 | if( !data ) return q || []; |
- | |
667 | - | ||
668 | if ( !q || jQuery.isArray(data) ) |
- | |
669 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
- | |
670 | else
|
- | |
671 | q.push( data ); |
- | |
672 | - | ||
673 | return q; |
- | |
674 | }, |
- | |
675 | - | ||
676 | dequeue: function( elem, type ){ |
- | |
677 | type = type || "fx"; |
- | |
678 | - | ||
679 | var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
- | |
680 | - | ||
681 | // If the fx queue is dequeued, always remove the progress sentinel
|
- | |
682 | if( fn === "inprogress" ) fn = queue.shift(); |
- | |
683 | - | ||
684 | if( fn ) { |
- | |
685 | // Add a progress sentinel to prevent the fx queue from being
|
- | |
686 | // automatically dequeued
|
- | |
687 | if( type == "fx" ) queue.unshift("inprogress"); |
- | |
688 | - | ||
689 | fn.call(elem, function() { jQuery.dequeue(elem, type); }); |
- | |
690 | }
|
- | |
691 | }
|
- | |
692 | }); |
- | |
693 | - | ||
694 | jQuery.fn.extend({ |
- | |
695 | data: function( key, value ){ |
- | |
696 | if ( typeof key === "undefined" && this.length ) { |
- | |
697 | return jQuery.data( this[0] ); |
- | |
698 | }
|
- | |
699 | - | ||
700 | var parts = key.split("."); |
- | |
701 | parts[1] = parts[1] ? "." + parts[1] : ""; |
- | |
702 | - | ||
703 | if ( value === undefined ) { |
588 | for ( var name in options ) { |
704 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
- | |
705 | - | ||
706 | if ( data === undefined && this.length ) |
- | |
707 | data = jQuery.data( this[0], key ); |
- | |
708 | - | ||
709 | return data === undefined && parts[1] ? |
- | |
710 | this.data( parts[0] ) : |
- | |
711 | data;
|
- | |
712 | } else |
- | |
713 | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
- | |
714 | jQuery.data( this, key, value ); |
- | |
715 | }); |
- | |
716 | }, |
- | |
717 | - | ||
718 | removeData: function( key ){ |
- | |
719 | return this.each(function(){ |
- | |
720 | jQuery.removeData( this, key ); |
- | |
721 | }); |
- | |
722 | }, |
- | |
723 | queue: function(type, data){ |
- | |
724 | if ( typeof type !== "string" ) { |
- | |
725 | data = type; |
- | |
726 | type = "fx"; |
- | |
727 | }
|
- | |
728 | - | ||
729 | if ( data === undefined ) |
- | |
730 | return jQuery.queue( this[0], type ); |
- | |
731 | - | ||
732 | return this.each(function(i, elem){ |
- | |
733 | var queue = jQuery.queue( this, type, data ); |
589 | var src = target[ name ], copy = options[ name ]; |
734 | - | ||
735 | if( type == "fx" && queue[0] !== "inprogress" ) |
- | |
736 | jQuery.dequeue( this, type ) |
- | |
737 | }); |
- | |
738 | }, |
- | |
739 | dequeue: function(type){ |
- | |
740 | return this.each(function(){ |
- | |
741 | jQuery.dequeue( this, type ); |
- | |
742 | }); |
- | |
743 | }, |
- | |
744 | clearQueue: function(type){ |
- | |
745 | return this.queue( type || "fx", [] ); |
- | |
746 | }
|
- | |
747 | }); |
- | |
748 | /*
|
- | |
749 | * A number of helper functions used for managing events.
|
- | |
750 | * Many of the ideas behind this code originated from
|
- | |
751 | * Dean Edwards' addEvent library.
|
- | |
752 | */
|
- | |
753 | jQuery.event = { |
- | |
754 | 590 | ||
755 | // Bind an event to an element
|
591 | // Prevent never-ending loop
|
756 | // Original by Dean Edwards
|
592 | if ( target === copy ) |
757 | add: function( elem, types, handler, data ) { |
- | |
758 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
- | |
759 | return; |
593 | continue; |
760 | }
|
- | |
761 | 594 | ||
- | 595 | // Recurse if we're merging object values
|
|
762 | // For whatever reason, IE has trouble passing the window object
|
596 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) |
- | 597 | target[ name ] = jQuery.extend( deep, |
|
763 | // around, causing it to be cloned in the process
|
598 | // Never move original objects, clone them
|
764 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
599 | src || ( copy.length != null ? [ ] : { } ) |
765 | elem = window; |
600 | , copy ); |
766 | }
|
- | |
767 | 601 | ||
768 | // Make sure that the function being executed has a unique ID
|
602 | // Don't bring in undefined values
|
769 | if ( !handler.guid ) { |
603 | else if ( copy !== undefined ) |
770 | handler.guid = this.guid++; |
604 | target[ name ] = copy; |
771 | }
|
- | |
772 | 605 | ||
773 | // if data is passed, bind to handler
|
- | |
774 | if ( data !== undefined ) { |
- | |
775 | // Create temporary function pointer to original handler
|
- | |
776 | var fn = handler; |
606 | }
|
777 | 607 | ||
778 | // Create unique handler function, wrapped around original handler
|
608 | // Return the modified object
|
779 | handler = this.proxy( fn ); |
609 | return target; |
- | 610 | }; |
|
780 | 611 | ||
781 | // Store data in unique handler
|
612 | // exclude the following css properties to add px
|
- | 613 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
|
782 | handler.data = data; |
614 | // cache defaultView
|
783 | }
|
- | |
- | 615 | defaultView = document.defaultView || {}, |
|
- | 616 | toString = Object.prototype.toString; |
|
784 | 617 | ||
785 | // Init the element's event structure
|
- | |
786 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
- | |
787 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
- | |
788 | // Handle the second event of a trigger and when
|
- | |
789 | // an event is called after a page has unloaded
|
- | |
790 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
- | |
791 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
- | |
792 | undefined; |
618 | jQuery.extend({ |
793 | }); |
- | |
794 | // Add elem as a property of the handle function
|
- | |
795 | // This is to prevent a memory leak with non-native
|
- | |
796 | // event in IE.
|
619 | noConflict: function( deep ) { |
797 | handle.elem = elem; |
620 | window.$ = _$; |
798 | 621 | ||
799 | // Handle multiple events separated by a space
|
- | |
800 | // jQuery(...).bind("mouseover mouseout", fn);
|
- | |
801 | types = types.split( /\s+/ ); |
- | |
802 | var type, i=0; |
622 | if ( deep ) |
803 | while ( (type = types[ i++ ]) ) { |
- | |
804 | // Namespaced event handlers
|
- | |
805 | var namespaces = type.split("."); |
- | |
806 | type = namespaces.shift(); |
623 | window.jQuery = _jQuery; |
807 | handler.type = namespaces.slice(0).sort().join("."); |
- | |
808 | 624 | ||
809 | // Get the current list of functions bound to this event
|
- | |
810 | var handlers = events[ type ], |
625 | return jQuery; |
811 | special = this.special[ type ] || {}; |
- | |
- | 626 | }, |
|
812 | 627 | ||
813 | if ( special.add ) { |
- | |
814 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
628 | // See test/unit/core.js for details concerning isFunction.
|
815 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
629 | // Since version 1.3, DOM methods and functions like alert
|
816 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
630 | // aren't supported. They return false on IE (#2968).
|
817 | handler = modifiedHandler; |
631 | isFunction: function( obj ) { |
818 | }
|
- | |
- | 632 | return toString.call(obj) === "[object Function]"; |
|
819 | }
|
633 | }, |
820 | 634 | ||
821 | // Init the event handler queue
|
- | |
822 | if ( !handlers ) { |
635 | isArray: function( obj ) { |
823 | handlers = events[ type ] = {}; |
636 | return toString.call(obj) === "[object Array]"; |
- | 637 | }, |
|
824 | 638 | ||
825 | // Check for a special event handler
|
- | |
826 | // Only use addEventListener/attachEvent if the special
|
- | |
827 | // events handler returns false
|
- | |
828 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
- | |
829 | // Bind the global event handler to the element
|
639 | // check if an element is in a (or is an) XML document
|
830 | if ( elem.addEventListener ) { |
640 | isXMLDoc: function( elem ) { |
831 | elem.addEventListener( type, handle, false ); |
641 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
832 | } else if ( elem.attachEvent ) { |
- | |
833 | elem.attachEvent( "on" + type, handle ); |
642 | !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); |
834 | }
|
- | |
835 | }
|
- | |
836 | }
|
643 | }, |
837 | 644 | ||
838 | // Add the function to the element's handler list
|
645 | // Evalulates a script in a global context
|
- | 646 | globalEval: function( data ) { |
|
- | 647 | if ( data && /\S/.test(data) ) { |
|
839 | handlers[ handler.guid ] = handler; |
648 | // Inspired by code by Andrea Giammarchi
|
- | 649 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
|
- | 650 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
|
- | 651 | script = document.createElement("script"); |
|
840 | 652 | ||
- | 653 | script.type = "text/javascript"; |
|
- | 654 | if ( jQuery.support.scriptEval ) |
|
- | 655 | script.appendChild( document.createTextNode( data ) ); |
|
- | 656 | else
|
|
- | 657 | script.text = data; |
|
- | 658 | ||
841 | // Keep track of which events have been used, for global triggering
|
659 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
- | 660 | // This arises when a base node is used (#2709).
|
|
- | 661 | head.insertBefore( script, head.firstChild ); |
|
842 | this.global[ type ] = true; |
662 | head.removeChild( script ); |
843 | }
|
663 | }
|
- | 664 | }, |
|
844 | 665 | ||
845 | // Nullify elem to prevent memory leaks in IE
|
666 | nodeName: function( elem, name ) { |
846 | elem = null; |
667 | return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); |
847 | }, |
668 | }, |
848 | 669 | ||
849 | guid: 1, |
670 | // args is for internal usage only
|
850 | global: {}, |
671 | each: function( object, callback, args ) { |
- | 672 | var name, i = 0, length = object.length; |
|
851 | 673 | ||
852 | // Detach an event or set of events from an element
|
674 | if ( args ) { |
853 | remove: function( elem, types, handler ) { |
675 | if ( length === undefined ) { |
854 | // don't do events on text and comment nodes
|
676 | for ( name in object ) |
855 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
677 | if ( callback.apply( object[ name ], args ) === false ) |
856 | return; |
678 | break; |
857 | }
|
679 | } else |
- | 680 | for ( ; i < length; ) |
|
- | 681 | if ( callback.apply( object[ i++ ], args ) === false ) |
|
- | 682 | break; |
|
858 | 683 | ||
859 | var events = jQuery.data( elem, "events" ), ret, type; |
684 | // A special, fast, case for the most common use of each
|
- | 685 | } else { |
|
- | 686 | if ( length === undefined ) { |
|
- | 687 | for ( name in object ) |
|
- | 688 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) |
|
- | 689 | break; |
|
- | 690 | } else |
|
- | 691 | for ( var value = object[0]; |
|
- | 692 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} |
|
- | 693 | }
|
|
860 | 694 | ||
861 | if ( events ) { |
- | |
862 | // Unbind all events for the element
|
- | |
863 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
- | |
864 | for ( type in events ) { |
- | |
865 | this.remove( elem, type + (types || "") ); |
- | |
866 | }
|
- | |
867 | } else { |
- | |
868 | // types is actually an event object here
|
- | |
869 | if ( types.type ) { |
- | |
870 | handler = types.handler; |
- | |
871 | types = types.type; |
695 | return object; |
872 | }
|
696 | }, |
873 | 697 | ||
- | 698 | prop: function( elem, value, type, i, name ) { |
|
874 | // Handle multiple events seperated by a space
|
699 | // Handle executable functions
|
875 | // jQuery(...).unbind("mouseover mouseout", fn);
|
700 | if ( jQuery.isFunction( value ) ) |
876 | types = types.split(/\s+/); |
701 | value = value.call( elem, i ); |
- | 702 | ||
- | 703 | // Handle passing in a number to a CSS property
|
|
- | 704 | return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? |
|
877 | var i = 0; |
705 | value + "px" : |
878 | while ( (type = types[ i++ ]) ) { |
706 | value;
|
- | 707 | }, |
|
- | 708 | ||
879 | // Namespaced event handlers
|
709 | className: { |
880 | var namespaces = type.split("."); |
710 | // internal only, use addClass("class")
|
881 | type = namespaces.shift(); |
711 | add: function( elem, classNames ) { |
882 | var all = !namespaces.length, |
712 | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
883 | namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
713 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
884 | special = this.special[ type ] || {}; |
714 | elem.className += (elem.className ? " " : "") + className; |
- | 715 | }); |
|
- | 716 | }, |
|
885 | 717 | ||
886 | if ( events[ type ] ) { |
718 | // internal only, use removeClass("class")
|
887 | // remove the given handler for the given type
|
719 | remove: function( elem, classNames ) { |
888 | if ( handler ) { |
720 | if (elem.nodeType == 1) |
889 | delete events[ type ][ handler.guid ]; |
721 | elem.className = classNames !== undefined ? |
- | 722 | jQuery.grep(elem.className.split(/\s+/), function(className){ |
|
- | 723 | return !jQuery.className.has( classNames, className ); |
|
- | 724 | }).join(" ") : |
|
- | 725 | ""; |
|
- | 726 | }, |
|
890 | 727 | ||
891 | // remove all handlers for the given type
|
728 | // internal only, use hasClass("class")
|
892 | } else { |
- | |
893 | for ( var handle in events[ type ] ) { |
729 | has: function( elem, className ) { |
894 | // Handle the removal of namespaced events
|
- | |
895 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
730 | return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
896 | delete events[ type ][ handle ]; |
- | |
897 | }
|
- | |
898 | }
|
731 | }
|
899 | }
|
732 | }, |
900 | 733 | ||
- | 734 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
|
- | 735 | swap: function( elem, options, callback ) { |
|
- | 736 | var old = {}; |
|
- | 737 | // Remember the old values, and insert the new ones
|
|
901 | if ( special.remove ) { |
738 | for ( var name in options ) { |
902 | special.remove.call( elem, namespaces ); |
739 | old[ name ] = elem.style[ name ]; |
- | 740 | elem.style[ name ] = options[ name ]; |
|
903 | }
|
741 | }
|
904 | 742 | ||
905 | // remove generic event handler if no more handlers exist
|
- | |
906 | for ( ret in events[ type ] ) { |
- | |
907 | break; |
- | |
908 | }
|
- | |
909 | if ( !ret ) { |
743 | callback.call( elem ); |
910 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
- | |
911 | if ( elem.removeEventListener ) { |
- | |
912 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
- | |
913 | } else if ( elem.detachEvent ) { |
- | |
914 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
- | |
915 | }
|
- | |
916 | }
|
- | |
917 | ret = null; |
- | |
918 | delete events[ type ]; |
- | |
919 | }
|
- | |
920 | }
|
- | |
921 | }
|
- | |
922 | }
|
- | |
923 | 744 | ||
924 | // Remove the expando if it's no longer used
|
745 | // Revert the old values
|
925 | for ( ret in events ) { |
746 | for ( var name in options ) |
926 | break; |
- | |
927 | }
|
- | |
928 | if ( !ret ) { |
- | |
929 | var handle = jQuery.data( elem, "handle" ); |
- | |
930 | if ( handle ) { |
- | |
931 | handle.elem = null; |
- | |
932 | }
|
- | |
933 | jQuery.removeData( elem, "events" ); |
- | |
934 | jQuery.removeData( elem, "handle" ); |
747 | elem.style[ name ] = old[ name ]; |
935 | }
|
- | |
936 | }
|
- | |
937 | }, |
748 | }, |
938 | 749 | ||
939 | // bubbling is internal
|
- | |
940 | trigger: function( event, data, elem /*, bubbling */ ) { |
750 | css: function( elem, name, force, extra ) { |
941 | // Event object or event type
|
- | |
942 | var type = event.type || event, |
751 | if ( name == "width" || name == "height" ) { |
943 | bubbling = arguments[3]; |
752 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
944 | 753 | ||
945 | if ( !bubbling ) { |
754 | function getWH() { |
946 | event = typeof event === "object" ? |
- | |
947 | // jQuery.Event object
|
- | |
948 | event[expando] ? event : |
- | |
949 | // Object literal
|
- | |
950 | jQuery.extend( jQuery.Event(type), event ) : |
755 | val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
951 | // Just the event type (string)
|
- | |
952 | jQuery.Event(type); |
- | |
953 | 756 | ||
954 | if ( type.indexOf("!") >= 0 ) { |
757 | if ( extra === "border" ) |
955 | event.type = type = type.slice(0, -1); |
- | |
956 | event.exclusive = true; |
758 | return; |
957 | }
|
- | |
958 | 759 | ||
959 | // Handle a global trigger
|
760 | jQuery.each( which, function() { |
960 | if ( !elem ) { |
761 | if ( !extra ) |
961 | // Don't bubble custom events when global (to avoid too much overhead)
|
762 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
962 | event.stopPropagation(); |
- | |
963 | // Only trigger if we've ever bound an event for it
|
- | |
964 | if ( this.global[ type ] ) { |
763 | if ( extra === "margin" ) |
965 | jQuery.each( jQuery.cache, function() { |
- | |
966 | if ( this.events && this.events[type] ) { |
- | |
967 | jQuery.event.trigger( event, data, this.handle.elem ); |
764 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
968 | }
|
765 | else
|
- | 766 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
|
969 | }); |
767 | }); |
970 | }
|
- | |
971 | }
|
768 | }
|
972 | 769 | ||
973 | // Handle triggering a single element
|
770 | if ( elem.offsetWidth !== 0 ) |
- | 771 | getWH(); |
|
- | 772 | else
|
|
- | 773 | jQuery.swap( elem, props, getWH ); |
|
974 | 774 | ||
975 | // don't do events on text and comment nodes
|
- | |
976 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
- | |
977 | return undefined; |
775 | return Math.max(0, Math.round(val)); |
978 | }
|
776 | }
|
979 | 777 | ||
980 | // Clean up in case it is reused
|
- | |
981 | event.result = undefined; |
778 | return jQuery.curCSS( elem, name, force ); |
982 | event.target = elem; |
779 | }, |
983 | 780 | ||
984 | // Clone the incoming data, if any
|
781 | curCSS: function( elem, name, force ) { |
985 | data = jQuery.makeArray( data ); |
- | |
986 | data.unshift( event ); |
782 | var ret, style = elem.style; |
987 | }
|
- | |
988 | 783 | ||
- | 784 | // We need to handle opacity special in IE
|
|
- | 785 | if ( name == "opacity" && !jQuery.support.opacity ) { |
|
989 | event.currentTarget = elem; |
786 | ret = jQuery.attr( style, "opacity" ); |
990 | 787 | ||
991 | // Trigger the event, it is assumed that "handle" is a function
|
- | |
992 | var handle = jQuery.data( elem, "handle" ); |
- | |
993 | if ( handle ) { |
- | |
994 | handle.apply( elem, data ); |
- | |
995 | }
|
- | |
996 | - | ||
997 | var nativeFn, nativeHandler; |
- | |
998 | try { |
- | |
999 | nativeFn = elem[ type ]; |
- | |
1000 | nativeHandler = elem[ "on" + type ]; |
- | |
1001 | // prevent IE from throwing an error for some elements with some event types, see #3533
|
- | |
1002 | } catch (e) {} |
- | |
1003 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
- | |
1004 | if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
- | |
1005 | event.result = false; |
788 | return ret == "" ? |
1006 | }
|
- | |
1007 | - | ||
1008 | // Trigger the native events (except for clicks on links)
|
- | |
1009 | if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
- | |
1010 | this.triggered = true; |
- | |
1011 | try { |
789 | "1" : |
1012 | nativeFn(); |
790 | ret;
|
1013 | // prevent IE from throwing an error for some hidden elements
|
- | |
1014 | } catch (e) {} |
- | |
1015 | }
|
791 | }
|
1016 | 792 | ||
- | 793 | // Make sure we're using the right name for getting the float value
|
|
- | 794 | if ( name.match( /float/i ) ) |
|
1017 | this.triggered = false; |
795 | name = styleFloat; |
1018 | 796 | ||
1019 | if ( !event.isPropagationStopped() ) { |
797 | if ( !force && style && style[ name ] ) |
1020 | var parent = elem.parentNode || elem.ownerDocument; |
- | |
1021 | if ( parent ) { |
798 | ret = style[ name ]; |
1022 | jQuery.event.trigger( event, data, parent, true ); |
- | |
1023 | }
|
- | |
1024 | }
|
- | |
1025 | }, |
- | |
1026 | 799 | ||
1027 | handle: function( event ) { |
800 | else if ( defaultView.getComputedStyle ) { |
1028 | // returned undefined or false
|
- | |
1029 | var all, handlers; |
- | |
1030 | 801 | ||
1031 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
802 | // Only "float" is needed here
|
1032 | event.currentTarget = this; |
803 | if ( name.match( /float/i ) ) |
- | 804 | name = "float"; |
|
1033 | 805 | ||
1034 | // Namespaced event handlers
|
- | |
1035 | var namespaces = event.type.split("."); |
806 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
1036 | event.type = namespaces.shift(); |
- | |
1037 | 807 | ||
1038 | // Cache this now, all = true means, any handler
|
808 | var computedStyle = defaultView.getComputedStyle( elem, null ); |
1039 | all = !namespaces.length && !event.exclusive; |
- | |
1040 | 809 | ||
- | 810 | if ( computedStyle ) |
|
1041 | var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
811 | ret = computedStyle.getPropertyValue( name ); |
1042 | 812 | ||
1043 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
813 | // We should always get a number back from opacity
|
- | 814 | if ( name == "opacity" && ret == "" ) |
|
- | 815 | ret = "1"; |
|
1044 | 816 | ||
1045 | for ( var j in handlers ) { |
817 | } else if ( elem.currentStyle ) { |
- | 818 | var camelCase = name.replace(/\-(\w)/g, function(all, letter){ |
|
1046 | var handler = handlers[ j ]; |
819 | return letter.toUpperCase(); |
- | 820 | }); |
|
1047 | 821 | ||
1048 | // Filter the functions by class
|
- | |
1049 | if ( all || namespace.test(handler.type) ) { |
- | |
1050 | // Pass in a reference to the handler function itself
|
822 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
1051 | // So that we can later remove it
|
- | |
1052 | event.handler = handler; |
- | |
1053 | event.data = handler.data; |
- | |
1054 | 823 | ||
1055 | var ret = handler.apply( this, arguments ); |
824 | // From the awesome hack by Dean Edwards
|
- | 825 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
1056 | 826 | ||
1057 | if ( ret !== undefined ) { |
827 | // If we're not dealing with a regular pixel number
|
1058 | event.result = ret; |
828 | // but a number that has a weird ending, we need to convert it to pixels
|
1059 | if ( ret === false ) { |
829 | if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { |
1060 | event.preventDefault(); |
830 | // Remember the original values
|
1061 | event.stopPropagation(); |
831 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
1062 | }
|
- | |
1063 | }
|
- | |
1064 | 832 | ||
1065 | if ( event.isImmediatePropagationStopped() ) { |
833 | // Put in the new values to get a computed value out
|
- | 834 | elem.runtimeStyle.left = elem.currentStyle.left; |
|
1066 | break; |
835 | style.left = ret || 0; |
1067 | }
|
836 | ret = style.pixelLeft + "px"; |
1068 | 837 | ||
- | 838 | // Revert the changed values
|
|
- | 839 | style.left = left; |
|
- | 840 | elem.runtimeStyle.left = rsLeft; |
|
1069 | }
|
841 | }
|
1070 | }
|
842 | }
|
- | 843 | ||
- | 844 | return ret; |
|
1071 | }, |
845 | }, |
1072 | 846 | ||
- | 847 | clean: function( elems, context, fragment ) { |
|
- | 848 | context = context || document; |
|
- | 849 | ||
- | 850 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
|
- | 851 | if ( typeof context.createElement === "undefined" ) |
|
1073 | props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
852 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
1074 | 853 | ||
1075 | fix: function( event ) { |
854 | // If a single string is passed in and it's a single tag
|
1076 | if ( event[ expando ] ) { |
855 | // just do a createElement and skip the rest
|
- | 856 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
|
- | 857 | var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); |
|
1077 | return event; |
858 | if ( match ) |
- | 859 | return [ context.createElement( match[1] ) ]; |
|
1078 | }
|
860 | }
|
1079 | 861 | ||
1080 | // store a copy of the original event object
|
862 | var ret = [], scripts = [], div = context.createElement("div"); |
1081 | // and "clone" to set read-only properties
|
- | |
1082 | var originalEvent = event; |
- | |
1083 | event = jQuery.Event( originalEvent ); |
- | |
1084 | 863 | ||
1085 | for ( var i = this.props.length, prop; i; ) { |
864 | jQuery.each(elems, function(i, elem){ |
1086 | prop = this.props[ --i ]; |
865 | if ( typeof elem === "number" ) |
1087 | event[ prop ] = originalEvent[ prop ]; |
866 | elem += ''; |
1088 | }
|
- | |
1089 | 867 | ||
1090 | // Fix target property, if necessary
|
- | |
1091 | if ( !event.target ) { |
868 | if ( !elem ) |
1092 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
- | |
1093 | }
|
869 | return; |
1094 | 870 | ||
1095 | // check if target is a textnode (safari)
|
871 | // Convert html string into DOM nodes
|
1096 | if ( event.target.nodeType === 3 ) { |
872 | if ( typeof elem === "string" ) { |
1097 | event.target = event.target.parentNode; |
873 | // Fix "XHTML"-style tags in all browsers
|
- | 874 | elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ |
|
- | 875 | return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? |
|
- | 876 | all :
|
|
- | 877 | front + "></" + tag + ">"; |
|
1098 | }
|
878 | }); |
1099 | 879 | ||
1100 | // Add relatedTarget, if necessary
|
- | |
1101 | if ( !event.relatedTarget && event.fromElement ) { |
880 | // Trim whitespace, otherwise indexOf won't work as expected
|
1102 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
881 | var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); |
1103 | }
|
- | |
1104 | 882 | ||
- | 883 | var wrap = |
|
1105 | // Calculate pageX/Y if missing and clientX/Y available
|
884 | // option or optgroup
|
1106 | if ( event.pageX == null && event.clientX != null ) { |
885 | !tags.indexOf("<opt") && |
1107 | var doc = document.documentElement, body = document.body; |
886 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
1108 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
- | |
1109 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
- | |
1110 | }
|
- | |
1111 | 887 | ||
1112 | // Add which for key events
|
888 | !tags.indexOf("<leg") && |
1113 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
- | |
1114 | event.which = event.charCode || event.keyCode; |
889 | [ 1, "<fieldset>", "</fieldset>" ] || |
1115 | }
|
- | |
1116 | 890 | ||
1117 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
- | |
1118 | if ( !event.metaKey && event.ctrlKey ) { |
891 | tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && |
1119 | event.metaKey = event.ctrlKey; |
892 | [ 1, "<table>", "</table>" ] || |
1120 | }
|
- | |
1121 | 893 | ||
1122 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
- | |
1123 | // Note: button is not normalized, so don't use it
|
894 | !tags.indexOf("<tr") && |
1124 | if ( !event.which && event.button !== undefined ) { |
895 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
1125 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
- | |
1126 | }
|
- | |
1127 | 896 | ||
1128 | return event; |
897 | // <thead> matched above
|
1129 | }, |
- | |
- | 898 | (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
|
- | 899 | [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
|
1130 | 900 | ||
1131 | proxy: function( fn, proxy, thisObject ) { |
- | |
1132 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
- | |
1133 | thisObject = proxy; |
901 | !tags.indexOf("<col") && |
1134 | proxy = undefined; |
- | |
1135 | }
|
- | |
1136 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
902 | [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
1137 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
- | |
1138 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
- | |
1139 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
- | |
1140 | // So proxy can be declared as an argument
|
- | |
1141 | return proxy; |
- | |
1142 | }, |
- | |
1143 | 903 | ||
1144 | special: { |
- | |
1145 | ready: { |
- | |
1146 | // Make sure the ready event is setup
|
904 | // IE can't serialize <link> and <script> tags normally
|
1147 | setup: bindReady, |
905 | !jQuery.support.htmlSerialize && |
1148 | teardown: function() {} |
906 | [ 1, "div<div>", "</div>" ] || |
1149 | }, |
- | |
1150 | 907 | ||
1151 | live: { |
- | |
1152 | add: function( proxy, data, namespaces ) { |
- | |
1153 | jQuery.extend( proxy, data || {} ); |
908 | [ 0, "", "" ]; |
1154 | proxy.guid += data.selector + data.live; |
- | |
1155 | jQuery.event.add( this, data.live, liveHandler, data ); |
- | |
1156 | }, |
- | |
1157 | 909 | ||
1158 | remove: function( namespaces ) { |
910 | // Go to html and back, then peel off extra wrappers
|
1159 | if ( namespaces.length ) { |
911 | div.innerHTML = wrap[1] + elem + wrap[2]; |
1160 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
- | |
1161 | 912 | ||
- | 913 | // Move to the right depth
|
|
- | 914 | while ( wrap[0]-- ) |
|
- | 915 | div = div.lastChild; |
|
- | 916 | ||
1162 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
917 | // Remove IE's autoinserted <tbody> from table fragments
|
1163 | if ( name.test(this.type) ) { |
918 | if ( !jQuery.support.tbody ) { |
- | 919 | ||
- | 920 | // String was a <table>, *may* have spurious <tbody>
|
|
- | 921 | var hasBody = /<tbody/i.test(elem), |
|
- | 922 | tbody = !tags.indexOf("<table") && !hasBody ? |
|
- | 923 | div.firstChild && div.firstChild.childNodes : |
|
- | 924 | ||
- | 925 | // String was a bare <thead> or <tfoot>
|
|
- | 926 | wrap[1] == "<table>" && !hasBody ? |
|
1164 | remove++;
|
927 | div.childNodes : |
1165 | }
|
928 | []; |
1166 | }); |
929 | |
- | 930 | for ( var j = tbody.length - 1; j >= 0 ; --j ) |
|
- | 931 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) |
|
- | 932 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
|
1167 | 933 | ||
1168 | if ( remove < 1 ) { |
- | |
1169 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
- | |
1170 | }
|
934 | }
|
- | 935 | ||
- | 936 | // IE completely kills leading whitespace when innerHTML is used
|
|
- | 937 | if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) |
|
- | 938 | div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); |
|
- | 939 | ||
- | 940 | elem = jQuery.makeArray( div.childNodes ); |
|
- | 941 | }
|
|
- | 942 | ||
- | 943 | if ( elem.nodeType ) |
|
- | 944 | ret.push( elem ); |
|
- | 945 | else
|
|
- | 946 | ret = jQuery.merge( ret, elem ); |
|
- | 947 | ||
- | 948 | }); |
|
- | 949 | ||
- | 950 | if ( fragment ) { |
|
- | 951 | for ( var i = 0; ret[i]; i++ ) { |
|
- | 952 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
|
- | 953 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
|
- | 954 | } else { |
|
- | 955 | if ( ret[i].nodeType === 1 ) |
|
- | 956 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
|
- | 957 | fragment.appendChild( ret[i] ); |
|
1171 | }
|
958 | }
|
1172 | }
|
959 | }
|
- | 960 | ||
- | 961 | return scripts; |
|
1173 | }
|
962 | }
|
1174 | }
|
- | |
1175 | }; |
- | |
1176 | 963 | ||
1177 | jQuery.Event = function( src ){ |
- | |
1178 | // Allow instantiation without the 'new' keyword
|
- | |
1179 | if ( !this.preventDefault ) { |
- | |
1180 | return new jQuery.Event( src ); |
964 | return ret; |
1181 | }
|
965 | }, |
1182 | 966 | ||
1183 | // Event object
|
- | |
1184 | if ( src && src.type ) { |
967 | attr: function( elem, name, value ) { |
1185 | this.originalEvent = src; |
968 | // don't set attributes on text and comment nodes
|
1186 | this.type = src.type; |
969 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
1187 | // Event type
|
- | |
1188 | } else { |
- | |
1189 | this.type = src; |
970 | return undefined; |
1190 | }
|
- | |
1191 | 971 | ||
1192 | // timeStamp is buggy for some events on Firefox(#3843)
|
972 | var notxml = !jQuery.isXMLDoc( elem ), |
1193 | // So we won't rely on the native value
|
973 | // Whether we are setting (or getting)
|
1194 | this.timeStamp = now(); |
974 | set = value !== undefined; |
1195 | 975 | ||
1196 | // Mark it as fixed
|
976 | // Try to normalize/fix the name
|
1197 | this[ expando ] = true; |
977 | name = notxml && jQuery.props[ name ] || name; |
1198 | }; |
- | |
1199 | 978 | ||
1200 | function returnFalse() { |
979 | // Only do all the following if this is a node (faster for style)
|
1201 | return false; |
980 | // IE elem.getAttribute passes even for style
|
1202 | }
|
- | |
1203 | function returnTrue() { |
981 | if ( elem.tagName ) { |
1204 | return true; |
- | |
1205 | }
|
- | |
1206 | 982 | ||
1207 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
- | |
1208 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
- | |
1209 | jQuery.Event.prototype = { |
- | |
1210 | preventDefault: function() { |
983 | // These attributes require special treatment
|
1211 | this.isDefaultPrevented = returnTrue; |
984 | var special = /href|src|style/.test( name ); |
1212 | 985 | ||
1213 | var e = this.originalEvent; |
- | |
1214 | if ( !e ) { |
- | |
1215 | return; |
- | |
1216 | }
|
- | |
1217 | - | ||
1218 | // if preventDefault exists run it on the original event
|
986 | // Safari mis-reports the default selected property of a hidden option
|
1219 | if ( e.preventDefault ) { |
- | |
1220 | e.preventDefault(); |
- | |
1221 | }
|
- | |
1222 | // otherwise set the returnValue property of the original event to false (IE)
|
987 | // Accessing the parent's selectedIndex property fixes it
|
1223 | e.returnValue = false; |
988 | if ( name == "selected" && elem.parentNode ) |
1224 | }, |
- | |
1225 | stopPropagation: function() { |
989 | elem.parentNode.selectedIndex; |
1226 | this.isPropagationStopped = returnTrue; |
- | |
1227 | 990 | ||
1228 | var e = this.originalEvent; |
- | |
1229 | if ( !e ) { |
- | |
1230 | return; |
- | |
1231 | }
|
- | |
1232 | // if stopPropagation exists run it on the original event
|
991 | // If applicable, access the attribute via the DOM 0 way
|
1233 | if ( e.stopPropagation ) { |
992 | if ( name in elem && notxml && !special ) { |
1234 | e.stopPropagation(); |
993 | if ( set ){ |
1235 | }
|
- | |
1236 | // otherwise set the cancelBubble property of the original event to true (IE)
|
994 | // We can't allow the type property to be changed (since it causes problems in IE)
|
1237 | e.cancelBubble = true; |
- | |
1238 | }, |
- | |
1239 | stopImmediatePropagation: function(){ |
- | |
1240 | this.isImmediatePropagationStopped = returnTrue; |
- | |
1241 | this.stopPropagation(); |
- | |
1242 | }, |
- | |
1243 | isDefaultPrevented: returnFalse, |
- | |
1244 | isPropagationStopped: returnFalse, |
- | |
1245 | isImmediatePropagationStopped: returnFalse
|
- | |
1246 | }; |
- | |
1247 | // Checks if an event happened on an element within another element
|
- | |
1248 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
- | |
1249 | var withinElement = function( event ) { |
- | |
1250 | // Check if mouse(over|out) are still within the same parent element
|
995 | if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) |
1251 | var parent = event.relatedTarget; |
996 | throw "type property can't be changed"; |
1252 | // Traverse up the tree
|
- | |
1253 | while ( parent && parent != this ) { |
- | |
1254 | // Firefox sometimes assigns relatedTarget a XUL element
|
- | |
1255 | // which we cannot access the parentNode property of
|
- | |
1256 | try { parent = parent.parentNode; } |
- | |
1257 | // assuming we've left the element since we most likely mousedover a xul element
|
- | |
1258 | catch(e) { break; } |
- | |
1259 | }
|
- | |
1260 | 997 | ||
1261 | if ( parent != this ) { |
- | |
1262 | // set the correct event type
|
- | |
1263 | event.type = event.data; |
998 | elem[ name ] = value; |
1264 | // handle event if we actually just moused on to a non sub-element
|
- | |
1265 | jQuery.event.handle.apply( this, arguments ); |
- | |
1266 | }
|
999 | }
|
1267 | }; |
- | |
1268 | 1000 | ||
1269 | // Create mouseenter and mouseleave events
|
1001 | // browsers index elements by id/name on forms, give priority to attributes.
|
1270 | jQuery.each({ |
- | |
1271 | mouseover: "mouseenter", |
- | |
1272 | mouseout: "mouseleave" |
- | |
1273 | }, function( orig, fix ) { |
- | |
1274 | jQuery.event.special[ fix ] = { |
- | |
1275 | setup: function(){ |
- | |
1276 | jQuery.event.add( this, orig, withinElement, fix ); |
1002 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
1277 | }, |
- | |
1278 | teardown: function(){ |
- | |
1279 | jQuery.event.remove( this, orig, withinElement ); |
1003 | return elem.getAttributeNode( name ).nodeValue; |
1280 | }
|
- | |
1281 | }; |
- | |
1282 | }); |
- | |
1283 | 1004 | ||
1284 | (function() { |
- | |
1285 | - | ||
1286 | var event = jQuery.event, |
- | |
1287 | special = event.special, |
- | |
1288 | handle = event.handle; |
1005 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
1289 | - | ||
1290 | special.submit = { |
- | |
1291 | setup: function(data, namespaces) { |
1006 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
1292 | if(data.selector) { |
1007 | if ( name == "tabIndex" ) { |
1293 | event.add(this, 'click.specialSubmit', function(e, eventData) { |
1008 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
1294 | if(jQuery(e.target).filter(":submit, :image").closest(data.selector).length) { |
1009 | return attributeNode && attributeNode.specified |
1295 | e.type = "submit"; |
1010 | ? attributeNode.value |
1296 | return handle.call( this, e, eventData ); |
1011 | : elem.nodeName.match(/(button|input|object|select|textarea)/i) |
1297 | }
|
1012 | ? 0 |
1298 | }); |
- | |
1299 | - | ||
1300 | event.add(this, 'keypress.specialSubmit', function( e, eventData ) { |
1013 | : elem.nodeName.match(/^(a|area)$/i) && elem.href |
1301 | if(jQuery(e.target).filter(":text, :password").closest(data.selector).length) { |
- | |
1302 | e.type = "submit"; |
1014 | ? 0 |
1303 | return handle.call( this, e, eventData ); |
1015 | : undefined; |
1304 | }
|
1016 | }
|
1305 | }); |
1017 | |
1306 | } else { |
- | |
1307 | return false; |
1018 | return elem[ name ]; |
1308 | }
|
1019 | }
|
1309 | }, |
- | |
1310 | - | ||
1311 | remove: function(namespaces) { |
- | |
1312 | event.remove(this, 'click.specialSubmit'); |
- | |
1313 | event.remove(this, 'keypress.specialSubmit'); |
- | |
1314 | }
|
- | |
1315 | }; |
- | |
1316 | - | ||
1317 | })(); |
- | |
1318 | 1020 | ||
1319 | // Create "bubbling" focus and blur events
|
1021 | if ( !jQuery.support.style && notxml && name == "style" ) |
1320 | jQuery.each({ |
- | |
1321 | focus: "focusin", |
- | |
1322 | blur: "focusout" |
- | |
1323 | }, function( orig, fix ){ |
- | |
1324 | var event = jQuery.event, |
- | |
1325 | special = event.special, |
- | |
1326 | handle = event.handle; |
- | |
1327 | - | ||
1328 | function ieHandler() { |
- | |
1329 | arguments[0].type = orig; |
- | |
1330 | return handle.apply(this, arguments); |
1022 | return jQuery.attr( elem.style, "cssText", value ); |
1331 | }
|
- | |
1332 | 1023 | ||
1333 | special[orig] = { |
- | |
1334 | setup:function() { |
- | |
1335 | if ( this.addEventListener ) |
- | |
1336 | this.addEventListener( orig, handle, true ); |
- | |
1337 | else
|
1024 | if ( set ) |
1338 | jQuery.event.add( this, fix, ieHandler ); |
- | |
1339 | }, |
- | |
1340 | teardown:function() { |
- | |
1341 | if ( this.removeEventListener ) |
- | |
1342 | this.removeEventListener( orig, handle, true ); |
1025 | // convert the value to a string (all browsers do this but IE) see #1070
|
1343 | else
|
- | |
1344 | jQuery.event.remove( this, fix, ieHandler ); |
1026 | elem.setAttribute( name, "" + value ); |
1345 | }
|
- | |
1346 | }; |
- | |
1347 | }); |
- | |
1348 | 1027 | ||
1349 | jQuery.fn.extend({ |
- | |
1350 | // TODO: make bind(), unbind() and one() DRY!
|
1028 | var attr = !jQuery.support.hrefNormalized && notxml && special |
1351 | bind: function( type, data, fn, thisObject ) { |
1029 | // Some attributes require a special call on IE
|
1352 | // Handle object literals
|
- | |
1353 | if ( typeof type === "object" ) { |
- | |
1354 | for ( var key in type ) { |
- | |
1355 | this.bind(key, data, type[key], fn); |
- | |
1356 | }
|
- | |
1357 | return this; |
- | |
1358 | }
|
- | |
1359 | - | ||
1360 | if ( jQuery.isFunction( data ) ) { |
1030 | ? elem.getAttribute( name, 2 ) |
1361 | thisObject = fn; |
- | |
1362 | fn = data; |
- | |
1363 | data = undefined; |
- | |
1364 | }
|
- | |
1365 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
- | |
1366 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
- | |
1367 | jQuery.event.add( this, type, fn, data ); |
1031 | : elem.getAttribute( name ); |
1368 | }); |
- | |
1369 | }, |
- | |
1370 | 1032 | ||
1371 | one: function( type, data, fn, thisObject ) { |
1033 | // Non-existent attributes return null, we normalize to undefined
|
1372 | // Handle object literals
|
- | |
1373 | if ( typeof type === "object" ) { |
- | |
1374 | for ( var key in type ) { |
- | |
1375 | this.one(key, data, type[key], fn); |
1034 | return attr === null ? undefined : attr; |
1376 | }
|
- | |
1377 | return this; |
- | |
1378 | }
|
1035 | }
|
1379 | - | ||
1380 | if ( jQuery.isFunction( data ) ) { |
- | |
1381 | thisObject = fn; |
- | |
1382 | fn = data; |
- | |
1383 | data = undefined; |
- | |
1384 | }
|
- | |
1385 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
- | |
1386 | var one = jQuery.event.proxy( fn, function( event ) { |
- | |
1387 | jQuery( this ).unbind( event, one ); |
- | |
1388 | return fn.apply( this, arguments ); |
- | |
1389 | }); |
- | |
1390 | return this.each(function() { |
- | |
1391 | jQuery.event.add( this, type, one, data ); |
- | |
1392 | }); |
- | |
1393 | }, |
- | |
1394 | 1036 | ||
1395 | unbind: function( type, fn ) { |
1037 | // elem is actually elem.style ... set the style
|
- | 1038 | ||
1396 | // Handle object literals
|
1039 | // IE uses filters for opacity
|
1397 | if ( typeof type === "object" && !type.preventDefault ) { |
1040 | if ( !jQuery.support.opacity && name == "opacity" ) { |
1398 | for ( var key in type ) { |
1041 | if ( set ) { |
- | 1042 | // IE has trouble with opacity if it does not have layout
|
|
1399 | this.unbind(key, type[key]); |
1043 | // Force it by setting the zoom level
|
- | 1044 | elem.zoom = 1; |
|
- | 1045 | ||
- | 1046 | // Set the alpha filter to set the opacity
|
|
- | 1047 | elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) + |
|
- | 1048 | (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
|
1400 | }
|
1049 | }
|
- | 1050 | ||
- | 1051 | return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? |
|
- | 1052 | (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '': |
|
1401 | return this; |
1053 | ""; |
1402 | }
|
1054 | }
|
1403 | - | ||
1404 | return this.each(function() { |
- | |
1405 | jQuery.event.remove( this, type, fn ); |
- | |
1406 | }); |
- | |
1407 | }, |
- | |
1408 | 1055 | ||
1409 | trigger: function( type, data ) { |
1056 | name = name.replace(/-([a-z])/ig, function(all, letter){ |
1410 | return this.each(function() { |
1057 | return letter.toUpperCase(); |
1411 | jQuery.event.trigger( type, data, this ); |
- | |
1412 | }); |
1058 | }); |
- | 1059 | ||
- | 1060 | if ( set ) |
|
- | 1061 | elem[ name ] = value; |
|
- | 1062 | ||
- | 1063 | return elem[ name ]; |
|
1413 | }, |
1064 | }, |
1414 | 1065 | ||
1415 | triggerHandler: function( type, data ) { |
1066 | trim: function( text ) { |
1416 | if ( this[0] ) { |
- | |
1417 | var event = jQuery.Event( type ); |
- | |
1418 | event.preventDefault(); |
- | |
1419 | event.stopPropagation(); |
- | |
1420 | jQuery.event.trigger( event, data, this[0] ); |
1067 | return (text || "").replace( /^\s+|\s+$/g, "" ); |
1421 | return event.result; |
- | |
1422 | }
|
- | |
1423 | }, |
1068 | }, |
1424 | 1069 | ||
1425 | toggle: function( fn ) { |
1070 | makeArray: function( array ) { |
1426 | // Save reference to arguments for access in closure
|
- | |
1427 | var args = arguments, i = 1; |
1071 | var ret = []; |
1428 | 1072 | ||
- | 1073 | if( array != null ){ |
|
- | 1074 | var i = array.length; |
|
1429 | // link all the functions, so any of them can unbind this click handler
|
1075 | // The window, strings (and functions) also have 'length'
|
- | 1076 | if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) |
|
- | 1077 | ret[0] = array; |
|
- | 1078 | else
|
|
1430 | while( i < args.length ) { |
1079 | while( i ) |
1431 | jQuery.event.proxy( fn, args[ i++ ] ); |
1080 | ret[--i] = array[i]; |
1432 | }
|
1081 | }
|
1433 | 1082 | ||
1434 | return this.click( jQuery.event.proxy( fn, function( event ) { |
- | |
1435 | // Figure out which function to execute
|
- | |
1436 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
- | |
1437 | - | ||
1438 | // Make sure that clicks stop
|
- | |
1439 | event.preventDefault(); |
1083 | return ret; |
1440 | - | ||
1441 | // and execute the function
|
- | |
1442 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
- | |
1443 | })); |
- | |
1444 | }, |
1084 | }, |
1445 | 1085 | ||
1446 | hover: function( fnOver, fnOut ) { |
1086 | inArray: function( elem, array ) { |
1447 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
1087 | for ( var i = 0, length = array.length; i < length; i++ ) |
- | 1088 | // Use === because on IE, window == document
|
|
- | 1089 | if ( array[ i ] === elem ) |
|
1448 | }, |
1090 | return i; |
1449 | 1091 | ||
1450 | ready: function( fn ) { |
1092 | return -1; |
1451 | // Attach the listeners
|
- | |
1452 | bindReady(); |
1093 | }, |
1453 | 1094 | ||
- | 1095 | merge: function( first, second ) { |
|
- | 1096 | // We have to loop this way because IE & Opera overwrite the length
|
|
1454 | // If the DOM is already ready
|
1097 | // expando of getElementsByTagName
|
- | 1098 | var i = 0, elem, pos = first.length; |
|
- | 1099 | // Also, we need to make sure that the correct elements are being returned
|
|
- | 1100 | // (IE returns comment nodes in a '*' query)
|
|
1455 | if ( jQuery.isReady ) { |
1101 | if ( !jQuery.support.getAll ) { |
1456 | // Execute the function immediately
|
1102 | while ( (elem = second[ i++ ]) != null ) |
- | 1103 | if ( elem.nodeType != 8 ) |
|
1457 | fn.call( document, jQuery ); |
1104 | first[ pos++ ] = elem; |
1458 | 1105 | ||
1459 | // Otherwise, remember the function for later
|
- | |
1460 | } else { |
1106 | } else |
1461 | // Add the function to the wait list
|
1107 | while ( (elem = second[ i++ ]) != null ) |
1462 | jQuery.readyList.push( fn ); |
1108 | first[ pos++ ] = elem; |
1463 | }
|
- | |
1464 | 1109 | ||
1465 | return this; |
1110 | return first; |
1466 | }, |
1111 | }, |
1467 | 1112 | ||
1468 | live: function( type, data, fn, thisObject ) { |
- | |
1469 | if ( jQuery.isFunction( data ) ) { |
1113 | unique: function( array ) { |
1470 | if ( fn !== undefined ) { |
1114 | var ret = [], done = {}; |
1471 | thisObject = fn; |
- | |
1472 | }
|
- | |
1473 | fn = data; |
- | |
1474 | data = undefined; |
- | |
1475 | }
|
- | |
1476 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
- | |
1477 | data: data, selector: this.selector, live: type |
- | |
1478 | }, fn, thisObject ); |
- | |
1479 | return this; |
- | |
1480 | }, |
- | |
1481 | 1115 | ||
1482 | die: function( type, fn ) { |
- | |
1483 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
- | |
1484 | return this; |
1116 | try { |
1485 | }
|
- | |
1486 | }); |
- | |
1487 | 1117 | ||
1488 | function liveHandler( event ) { |
1118 | for ( var i = 0, length = array.length; i < length; i++ ) { |
1489 | var stop = true, elems = [], args = arguments; |
1119 | var id = jQuery.data( array[ i ] ); |
1490 | 1120 | ||
1491 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
- | |
1492 | if ( fn.live === event.type ) { |
1121 | if ( !done[ id ] ) { |
1493 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
- | |
1494 | if ( elem ) { |
1122 | done[ id ] = true; |
1495 | elems.push({ elem: elem, fn: fn }); |
1123 | ret.push( array[ i ] ); |
- | 1124 | }
|
|
1496 | }
|
1125 | }
|
1497 | }
|
- | |
1498 | }); |
- | |
1499 | - | ||
1500 | elems.sort(function( a, b ) { |
- | |
1501 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
- | |
1502 | }); |
- | |
1503 | 1126 | ||
1504 | jQuery.each(elems, function() { |
1127 | } catch( e ) { |
1505 | event.currentTarget = this.elem; |
- | |
1506 | event.data = this.fn.data; |
- | |
1507 | if ( this.fn.apply( this.elem, args ) === false ) { |
- | |
1508 | return (stop = false); |
1128 | ret = array; |
1509 | }
|
1129 | }
|
1510 | }); |
- | |
1511 | 1130 | ||
1512 | return stop; |
1131 | return ret; |
1513 | }
|
1132 | }, |
1514 | 1133 | ||
1515 | function liveConvert( type, selector ) { |
1134 | grep: function( elems, callback, inv ) { |
1516 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
1135 | var ret = []; |
1517 | }
|
- | |
1518 | 1136 | ||
1519 | jQuery.extend({ |
- | |
1520 | isReady: false, |
- | |
1521 | readyList: [], |
- | |
1522 | // Handle when the DOM is ready
|
1137 | // Go through the array, only saving the items
|
1523 | ready: function() { |
1138 | // that pass the validator function
|
1524 | // Make sure that the DOM is not already loaded
|
1139 | for ( var i = 0, length = elems.length; i < length; i++ ) |
1525 | if ( !jQuery.isReady ) { |
- | |
1526 | // Remember that the DOM is ready
|
1140 | if ( !inv != !callback( elems[ i ], i ) ) |
1527 | jQuery.isReady = true; |
1141 | ret.push( elems[ i ] ); |
1528 | 1142 | ||
1529 | // If there are functions bound, to execute
|
- | |
1530 | if ( jQuery.readyList ) { |
- | |
1531 | // Execute all of them
|
- | |
1532 | var fn, i = 0; |
1143 | return ret; |
1533 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
- | |
1534 | fn.call( document, jQuery ); |
- | |
1535 | }
|
1144 | }, |
1536 | 1145 | ||
1537 | // Reset the list of functions
|
1146 | map: function( elems, callback ) { |
1538 | jQuery.readyList = null; |
1147 | var ret = []; |
1539 | }
|
- | |
1540 | 1148 | ||
- | 1149 | // Go through the array, translating each of the items to their
|
|
1541 | // Trigger any bound ready events
|
1150 | // new value (or values).
|
- | 1151 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
|
1542 | jQuery( document ).triggerHandler( "ready" ); |
1152 | var value = callback( elems[ i ], i ); |
- | 1153 | ||
- | 1154 | if ( value != null ) |
|
- | 1155 | ret[ ret.length ] = value; |
|
1543 | }
|
1156 | }
|
- | 1157 | ||
- | 1158 | return ret.concat.apply( [], ret ); |
|
1544 | }
|
1159 | }
|
1545 | }); |
1160 | }); |
1546 | 1161 | ||
- | 1162 | // Use of jQuery.browser is deprecated.
|
|
- | 1163 | // It's included for backwards compatibility and plugins,
|
|
- | 1164 | // although they should work to migrate away.
|
|
- | 1165 | ||
- | 1166 | var userAgent = navigator.userAgent.toLowerCase(); |
|
- | 1167 | ||
- | 1168 | // Figure out what browser is being used
|
|
1547 | var readyBound = false; |
1169 | jQuery.browser = { |
- | 1170 | version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], |
|
- | 1171 | safari: /webkit/.test( userAgent ), |
|
- | 1172 | opera: /opera/.test( userAgent ), |
|
- | 1173 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
|
- | 1174 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
|
- | 1175 | }; |
|
1548 | 1176 | ||
- | 1177 | jQuery.each({ |
|
- | 1178 | parent: function(elem){return elem.parentNode;}, |
|
- | 1179 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
|
- | 1180 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
|
- | 1181 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
|
- | 1182 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
|
- | 1183 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
|
- | 1184 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
|
- | 1185 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
|
- | 1186 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
|
1549 | function bindReady() { |
1187 | }, function(name, fn){ |
1550 | if ( readyBound ) return; |
1188 | jQuery.fn[ name ] = function( selector ) { |
1551 | readyBound = true; |
1189 | var ret = jQuery.map( this, fn ); |
1552 | 1190 | ||
1553 | // Catch cases where $(document).ready() is called after the
|
- | |
1554 | // browser event has already occurred.
|
- | |
1555 | if ( document.readyState === "complete" ) { |
1191 | if ( selector && typeof selector == "string" ) |
1556 | return jQuery.ready(); |
1192 | ret = jQuery.multiFilter( selector, ret ); |
1557 | }
|
- | |
1558 | 1193 | ||
1559 | // Mozilla, Opera and webkit nightlies currently support this event
|
- | |
1560 | if ( document.addEventListener ) { |
- | |
1561 | // Use the handy event callback
|
- | |
1562 | document.addEventListener( "DOMContentLoaded", function() { |
1194 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
1563 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
- | |
1564 | jQuery.ready(); |
1195 | }; |
1565 | }, false ); |
1196 | }); |
1566 | 1197 | ||
- | 1198 | jQuery.each({ |
|
1567 | // If IE event model is used
|
1199 | appendTo: "append", |
1568 | } else if ( document.attachEvent ) { |
1200 | prependTo: "prepend", |
1569 | // ensure firing before onload,
|
1201 | insertBefore: "before", |
1570 | // maybe late but safe also for iframes
|
1202 | insertAfter: "after", |
1571 | document.attachEvent("onreadystatechange", function() { |
1203 | replaceAll: "replaceWith" |
1572 | if ( document.readyState === "complete" ) { |
1204 | }, function(name, original){ |
1573 | document.detachEvent( "onreadystatechange", arguments.callee ); |
1205 | jQuery.fn[ name ] = function( selector ) { |
1574 | jQuery.ready(); |
1206 | var ret = [], insert = jQuery( selector ); |
1575 | }
|
- | |
1576 | }); |
- | |
1577 | 1207 | ||
1578 | // If IE and not an iframe
|
- | |
1579 | // continually check to see if the document is ready
|
1208 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
1580 | // NOTE: DO NOT CHANGE TO ===, FAILS IN IE.
|
1209 | var elems = (i > 0 ? this.clone(true) : this).get(); |
1581 | if ( document.documentElement.doScroll && window == window.top ) (function() { |
1210 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
1582 | if ( jQuery.isReady ) { |
1211 | ret = ret.concat( elems ); |
1583 | return; |
- | |
1584 | }
|
1212 | }
|
1585 | 1213 | ||
1586 | try { |
- | |
1587 | // If IE is used, use the trick by Diego Perini
|
- | |
1588 | // http://javascript.nwbox.com/IEContentLoaded/
|
- | |
1589 | document.documentElement.doScroll("left"); |
- | |
1590 | } catch( error ) { |
- | |
1591 | setTimeout( arguments.callee, 0 ); |
- | |
1592 | return; |
- | |
1593 | }
|
- | |
1594 | - | ||
1595 | // and execute any waiting functions
|
- | |
1596 | jQuery.ready(); |
- | |
1597 | })(); |
- | |
1598 | }
|
- | |
1599 | - | ||
1600 | // A fallback to window.onload, that will always work
|
- | |
1601 | jQuery.event.add( window, "load", jQuery.ready ); |
- | |
1602 | }
|
- | |
1603 | - | ||
1604 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
- | |
1605 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
- | |
1606 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
- | |
1607 | - | ||
1608 | // Handle event binding
|
- | |
1609 | jQuery.fn[ name ] = function( fn ) { |
- | |
1610 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
1214 | return this.pushStack( ret, name, selector ); |
1611 | }; |
1215 | }; |
1612 | }); |
1216 | }); |
1613 | 1217 | ||
1614 | // Prevent memory leaks in IE
|
- | |
1615 | // Window isn't included so as not to unbind existing unload events
|
- | |
1616 | // More info:
|
1218 | jQuery.each({ |
1617 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
- | |
1618 | /*@cc_on
|
- | |
1619 | jQuery( window ).bind( 'unload', function() {
|
- | |
1620 | for ( var id in jQuery.cache ) {
|
1219 | removeAttr: function( name ) { |
1621 | // Skip the window
|
- | |
1622 | if ( id != 1 && jQuery.cache[ id ].handle ) {
|
- | |
1623 | jQuery.event.remove( jQuery.cache[ id ].handle.elem );
|
- | |
1624 | }
|
- | |
1625 | }
|
- | |
1626 | });
|
- | |
1627 | @*/
|
- | |
1628 | (function(){ |
- | |
1629 | - | ||
1630 | jQuery.support = {}; |
1220 | jQuery.attr( this, name, "" ); |
1631 | - | ||
1632 | var root = document.documentElement, |
- | |
1633 | script = document.createElement("script"), |
- | |
1634 | div = document.createElement("div"), |
- | |
1635 | id = "script" + (new Date).getTime(); |
- | |
1636 | - | ||
1637 | div.style.display = "none"; |
1221 | if (this.nodeType == 1) |
1638 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
- | |
1639 | - | ||
1640 | var all = div.getElementsByTagName("*"), |
- | |
1641 | a = div.getElementsByTagName("a")[0]; |
1222 | this.removeAttribute( name ); |
1642 | - | ||
1643 | // Can't get basic test support
|
- | |
1644 | if ( !all || !all.length || !a ) { |
- | |
1645 | return; |
- | |
1646 | }
|
1223 | }, |
1647 | - | ||
1648 | jQuery.support = { |
- | |
1649 | // IE strips leading whitespace when .innerHTML is used
|
- | |
1650 | leadingWhitespace: div.firstChild.nodeType == 3, |
- | |
1651 | - | ||
1652 | // Make sure that tbody elements aren't automatically inserted
|
- | |
1653 | // IE will insert them into empty tables
|
- | |
1654 | tbody: !div.getElementsByTagName("tbody").length, |
- | |
1655 | - | ||
1656 | // Make sure that link elements get serialized correctly by innerHTML
|
- | |
1657 | // This requires a wrapper element in IE
|
- | |
1658 | htmlSerialize: !!div.getElementsByTagName("link").length, |
- | |
1659 | - | ||
1660 | // Get the style information from getAttribute
|
- | |
1661 | // (IE uses .cssText insted)
|
- | |
1662 | style: /red/.test( a.getAttribute("style") ), |
- | |
1663 | - | ||
1664 | // Make sure that URLs aren't manipulated
|
- | |
1665 | // (IE normalizes it by default)
|
- | |
1666 | hrefNormalized: a.getAttribute("href") === "/a", |
- | |
1667 | - | ||
1668 | // Make sure that element opacity exists
|
- | |
1669 | // (IE uses filter instead)
|
- | |
1670 | opacity: a.style.opacity === "0.5", |
- | |
1671 | - | ||
1672 | // Verify style float existence
|
- | |
1673 | // (IE uses styleFloat instead of cssFloat)
|
- | |
1674 | cssFloat: !!a.style.cssFloat, |
- | |
1675 | 1224 | ||
1676 | // Will be defined later
|
1225 | addClass: function( classNames ) { |
1677 | scriptEval: false, |
1226 | jQuery.className.add( this, classNames ); |
1678 | noCloneEvent: true, |
- | |
1679 | boxModel: null |
- | |
1680 | }; |
1227 | }, |
1681 | 1228 | ||
1682 | script.type = "text/javascript"; |
1229 | removeClass: function( classNames ) { |
1683 | try { |
- | |
1684 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
1230 | jQuery.className.remove( this, classNames ); |
1685 | } catch(e){} |
1231 | }, |
1686 | 1232 | ||
1687 | root.insertBefore( script, root.firstChild ); |
1233 | toggleClass: function( classNames, state ) { |
- | 1234 | if( typeof state !== "boolean" ) |
|
- | 1235 | state = !jQuery.className.has( this, classNames ); |
|
- | 1236 | jQuery.className[ state ? "add" : "remove" ]( this, classNames ); |
|
- | 1237 | }, |
|
1688 | 1238 | ||
- | 1239 | remove: function( selector ) { |
|
1689 | // Make sure that the execution of code works by injecting a script
|
1240 | if ( !selector || jQuery.filter( selector, [ this ] ).length ) { |
1690 | // tag with appendChild/createTextNode
|
1241 | // Prevent memory leaks
|
1691 | // (IE doesn't support this, fails, and uses .text instead)
|
1242 | jQuery( "*", this ).add([this]).each(function(){ |
1692 | if ( window[ id ] ) { |
1243 | jQuery.event.remove(this); |
1693 | jQuery.support.scriptEval = true; |
1244 | jQuery.removeData(this); |
- | 1245 | }); |
|
1694 | delete window[ id ]; |
1246 | if (this.parentNode) |
- | 1247 | this.parentNode.removeChild( this ); |
|
- | 1248 | }
|
|
1695 | }
|
1249 | }, |
1696 | 1250 | ||
- | 1251 | empty: function() { |
|
- | 1252 | // Remove element nodes and prevent memory leaks
|
|
1697 | root.removeChild( script ); |
1253 | jQuery(this).children().remove(); |
1698 | 1254 | ||
1699 | if ( div.attachEvent && div.fireEvent ) { |
- | |
1700 | div.attachEvent("onclick", function click(){ |
- | |
1701 | // Cloning a node shouldn't copy over any
|
- | |
1702 | // bound event handlers (IE does this)
|
1255 | // Remove any remaining nodes
|
1703 | jQuery.support.noCloneEvent = false; |
- | |
1704 | div.detachEvent("onclick", click); |
1256 | while ( this.firstChild ) |
1705 | }); |
- | |
1706 | div.cloneNode(true).fireEvent("onclick"); |
1257 | this.removeChild( this.firstChild ); |
1707 | }
|
1258 | }
|
- | 1259 | }, function(name, fn){ |
|
- | 1260 | jQuery.fn[ name ] = function(){ |
|
- | 1261 | return this.each( fn, arguments ); |
|
- | 1262 | }; |
|
- | 1263 | }); |
|
1708 | 1264 | ||
1709 | // Figure out if the W3C box model works as expected
|
1265 | // Helper function used by the dimensions and offset modules
|
- | 1266 | function num(elem, prop) { |
|
- | 1267 | return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0; |
|
- | 1268 | }
|
|
1710 | // document.body must exist before we can do this
|
1269 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
- | 1270 | ||
1711 | jQuery(function(){ |
1271 | jQuery.extend({ |
- | 1272 | cache: {}, |
|
- | 1273 | ||
- | 1274 | data: function( elem, name, data ) { |
|
- | 1275 | elem = elem == window ? |
|
- | 1276 | windowData :
|
|
- | 1277 | elem;
|
|
- | 1278 | ||
1712 | var div = document.createElement("div"); |
1279 | var id = elem[ expando ]; |
- | 1280 | ||
- | 1281 | // Compute a unique ID for the element
|
|
- | 1282 | if ( !id ) |
|
1713 | div.style.width = div.style.paddingLeft = "1px"; |
1283 | id = elem[ expando ] = ++uuid; |
1714 | 1284 | ||
- | 1285 | // Only generate the data cache if we're
|
|
- | 1286 | // trying to access or manipulate it
|
|
- | 1287 | if ( name && !jQuery.cache[ id ] ) |
|
1715 | document.body.appendChild( div ); |
1288 | jQuery.cache[ id ] = {}; |
- | 1289 | ||
1716 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
1290 | // Prevent overriding the named cache with undefined values
|
- | 1291 | if ( data !== undefined ) |
|
- | 1292 | jQuery.cache[ id ][ name ] = data; |
|
- | 1293 | ||
1717 | document.body.removeChild( div ).style.display = 'none'; |
1294 | // Return the named cache data, or the ID for the element
|
1718 | div = null; |
1295 | return name ? |
- | 1296 | jQuery.cache[ id ][ name ] : |
|
- | 1297 | id;
|
|
1719 | }); |
1298 | }, |
- | 1299 | ||
- | 1300 | removeData: function( elem, name ) { |
|
- | 1301 | elem = elem == window ? |
|
- | 1302 | windowData :
|
|
- | 1303 | elem;
|
|
- | 1304 | ||
- | 1305 | var id = elem[ expando ]; |
|
- | 1306 | ||
- | 1307 | // If we want to remove a specific section of the element's data
|
|
- | 1308 | if ( name ) { |
|
- | 1309 | if ( jQuery.cache[ id ] ) { |
|
- | 1310 | // Remove the section of cache data
|
|
- | 1311 | delete jQuery.cache[ id ][ name ]; |
|
- | 1312 | ||
- | 1313 | // If we've removed all the data, remove the element's cache
|
|
- | 1314 | name = ""; |
|
- | 1315 | ||
- | 1316 | for ( name in jQuery.cache[ id ] ) |
|
- | 1317 | break; |
|
- | 1318 | ||
- | 1319 | if ( !name ) |
|
- | 1320 | jQuery.removeData( elem ); |
|
- | 1321 | }
|
|
1720 | 1322 | ||
- | 1323 | // Otherwise, we want to remove all of the element's data
|
|
- | 1324 | } else { |
|
- | 1325 | // Clean up the element expando
|
|
- | 1326 | try { |
|
1721 | // release memory in IE
|
1327 | delete elem[ expando ]; |
- | 1328 | } catch(e){ |
|
- | 1329 | // IE has trouble directly removing the expando
|
|
- | 1330 | // but it's ok with using removeAttribute
|
|
- | 1331 | if ( elem.removeAttribute ) |
|
- | 1332 | elem.removeAttribute( expando ); |
|
- | 1333 | }
|
|
- | 1334 | ||
- | 1335 | // Completely remove the data cache
|
|
- | 1336 | delete jQuery.cache[ id ]; |
|
- | 1337 | }
|
|
- | 1338 | }, |
|
- | 1339 | queue: function( elem, type, data ) { |
|
- | 1340 | if ( elem ){ |
|
- | 1341 | ||
1722 | root = script = div = all = a = null; |
1342 | type = (type || "fx") + "queue"; |
- | 1343 | ||
- | 1344 | var q = jQuery.data( elem, type ); |
|
- | 1345 | ||
- | 1346 | if ( !q || jQuery.isArray(data) ) |
|
- | 1347 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
|
- | 1348 | else if( data ) |
|
- | 1349 | q.push( data ); |
|
- | 1350 | ||
- | 1351 | }
|
|
- | 1352 | return q; |
|
- | 1353 | }, |
|
- | 1354 | ||
- | 1355 | dequeue: function( elem, type ){ |
|
- | 1356 | var queue = jQuery.queue( elem, type ), |
|
- | 1357 | fn = queue.shift(); |
|
- | 1358 | ||
- | 1359 | if( !type || type === "fx" ) |
|
- | 1360 | fn = queue[0]; |
|
- | 1361 | ||
- | 1362 | if( fn !== undefined ) |
|
- | 1363 | fn.call(elem); |
|
- | 1364 | }
|
|
1723 | })(); |
1365 | }); |
1724 | 1366 | ||
1725 | jQuery.props = { |
1367 | jQuery.fn.extend({ |
- | 1368 | data: function( key, value ){ |
|
1726 | "for": "htmlFor", |
1369 | var parts = key.split("."); |
- | 1370 | parts[1] = parts[1] ? "." + parts[1] : ""; |
|
- | 1371 | ||
- | 1372 | if ( value === undefined ) { |
|
- | 1373 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
|
- | 1374 | ||
- | 1375 | if ( data === undefined && this.length ) |
|
- | 1376 | data = jQuery.data( this[0], key ); |
|
- | 1377 | ||
- | 1378 | return data === undefined && parts[1] ? |
|
1727 | "class": "className", |
1379 | this.data( parts[0] ) : |
- | 1380 | data;
|
|
- | 1381 | } else |
|
- | 1382 | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
|
- | 1383 | jQuery.data( this, key, value ); |
|
- | 1384 | }); |
|
- | 1385 | }, |
|
- | 1386 | ||
1728 | readonly: "readOnly", |
1387 | removeData: function( key ){ |
1729 | maxlength: "maxLength", |
1388 | return this.each(function(){ |
- | 1389 | jQuery.removeData( this, key ); |
|
- | 1390 | }); |
|
- | 1391 | }, |
|
- | 1392 | queue: function(type, data){ |
|
1730 | cellspacing: "cellSpacing", |
1393 | if ( typeof type !== "string" ) { |
1731 | rowspan: "rowSpan", |
1394 | data = type; |
1732 | colspan: "colSpan", |
1395 | type = "fx"; |
- | 1396 | }
|
|
- | 1397 | ||
1733 | tabindex: "tabIndex" |
1398 | if ( data === undefined ) |
- | 1399 | return jQuery.queue( this[0], type ); |
|
- | 1400 | ||
- | 1401 | return this.each(function(){ |
|
- | 1402 | var queue = jQuery.queue( this, type, data ); |
|
- | 1403 | ||
- | 1404 | if( type == "fx" && queue.length == 1 ) |
|
- | 1405 | queue[0].call(this); |
|
- | 1406 | }); |
|
1734 | }; |
1407 | }, |
- | 1408 | dequeue: function(type){ |
|
- | 1409 | return this.each(function(){ |
|
- | 1410 | jQuery.dequeue( this, type ); |
|
- | 1411 | }); |
|
- | 1412 | }
|
|
1735 | /*!
|
1413 | });/*! |
1736 | * Sizzle CSS Selector Engine - v1.0
|
1414 | * Sizzle CSS Selector Engine - v0.9.3
|
1737 | * Copyright 2009, The Dojo Foundation
|
1415 | * Copyright 2009, The Dojo Foundation
|
1738 | * Released under the MIT, BSD, and GPL Licenses.
|
1416 | * Released under the MIT, BSD, and GPL Licenses.
|
1739 | * More information: http://sizzlejs.com/
|
1417 | * More information: http://sizzlejs.com/
|
1740 | */
|
1418 | */
|
1741 | (function(){ |
1419 | (function(){ |
1742 | 1420 | ||
1743 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
1421 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
1744 | done = 0, |
1422 | done = 0, |
1745 | toString = Object.prototype.toString, |
1423 | toString = Object.prototype.toString; |
1746 | hasDuplicate = false; |
- | |
1747 | 1424 | ||
1748 | var Sizzle = function(selector, context, results, seed) { |
1425 | var Sizzle = function(selector, context, results, seed) { |
1749 | results = results || []; |
1426 | results = results || []; |
1750 | var origContext = context = context || document; |
1427 | context = context || document; |
1751 | 1428 | ||
1752 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
1429 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) |
1753 | return []; |
1430 | return []; |
1754 | }
|
- | |
1755 | 1431 | ||
1756 | if ( !selector || typeof selector !== "string" ) { |
1432 | if ( !selector || typeof selector !== "string" ) { |
1757 | return results; |
1433 | return results; |
1758 | }
|
1434 | }
|
1759 | 1435 | ||
1760 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
1436 | var parts = [], m, set, checkSet, check, mode, extra, prune = true; |
1761 | 1437 | ||
1762 | // Reset the position of the chunker regexp (start from head)
|
1438 | // Reset the position of the chunker regexp (start from head)
|
1763 | chunker.lastIndex = 0; |
1439 | chunker.lastIndex = 0; |
1764 | 1440 | ||
1765 | while ( (m = chunker.exec(selector)) !== null ) { |
1441 | while ( (m = chunker.exec(selector)) !== null ) { |
Строка 1787... | Строка 1463... | ||
1787 | 1463 | ||
1788 | set = posProcess( selector, set ); |
1464 | set = posProcess( selector, set ); |
1789 | }
|
1465 | }
|
1790 | }
|
1466 | }
|
1791 | } else { |
1467 | } else { |
1792 | // Take a shortcut and set the context if the root selector is an ID
|
1468 | var ret = seed ? |
1793 | // (but not if it'll be faster if the inner selector is an ID)
|
1469 | { expr: parts.pop(), set: makeArray(seed) } : |
1794 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
1470 | Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context, isXML(context) ); |
1795 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
- | |
1796 | var ret = Sizzle.find( parts.shift(), context, contextXML ); |
- | |
1797 | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
1471 | set = Sizzle.filter( ret.expr, ret.set ); |
1798 | }
|
- | |
1799 | 1472 | ||
1800 | if ( context ) { |
1473 | if ( parts.length > 0 ) { |
1801 | var ret = seed ? |
1474 | checkSet = makeArray(set); |
1802 | { expr: parts.pop(), set: makeArray(seed) } : |
1475 | } else { |
1803 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
- | |
1804 | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
1476 | prune = false; |
- | 1477 | }
|
|
1805 | 1478 | ||
1806 | if ( parts.length > 0 ) { |
1479 | while ( parts.length ) { |
1807 | checkSet = makeArray(set); |
1480 | var cur = parts.pop(), pop = cur; |
- | 1481 | ||
- | 1482 | if ( !Expr.relative[ cur ] ) { |
|
- | 1483 | cur = ""; |
|
1808 | } else { |
1484 | } else { |
1809 | prune = false; |
1485 | pop = parts.pop(); |
1810 | }
|
1486 | }
|
1811 | 1487 | ||
1812 | while ( parts.length ) { |
- | |
1813 | var cur = parts.pop(), pop = cur; |
- | |
1814 | - | ||
1815 | if ( !Expr.relative[ cur ] ) { |
- | |
1816 | cur = ""; |
- | |
1817 | } else { |
- | |
1818 | pop = parts.pop(); |
- | |
1819 | }
|
- | |
1820 | - | ||
1821 | if ( pop == null ) { |
1488 | if ( pop == null ) { |
1822 | pop = context; |
1489 | pop = context; |
1823 | }
|
- | |
1824 | - | ||
1825 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
- | |
1826 | }
|
1490 | }
|
1827 | } else { |
1491 | |
1828 | checkSet = parts = []; |
1492 | Expr.relative[ cur ]( checkSet, pop, isXML(context) ); |
1829 | }
|
1493 | }
|
1830 | }
|
1494 | }
|
1831 | 1495 | ||
1832 | if ( !checkSet ) { |
1496 | if ( !checkSet ) { |
1833 | checkSet = set; |
1497 | checkSet = set; |
Строка 1838... | Строка 1502... | ||
1838 | }
|
1502 | }
|
1839 | 1503 | ||
1840 | if ( toString.call(checkSet) === "[object Array]" ) { |
1504 | if ( toString.call(checkSet) === "[object Array]" ) { |
1841 | if ( !prune ) { |
1505 | if ( !prune ) { |
1842 | results.push.apply( results, checkSet ); |
1506 | results.push.apply( results, checkSet ); |
1843 | } else if ( context && context.nodeType === 1 ) { |
1507 | } else if ( context.nodeType === 1 ) { |
1844 | for ( var i = 0; checkSet[i] != null; i++ ) { |
1508 | for ( var i = 0; checkSet[i] != null; i++ ) { |
1845 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
1509 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
1846 | results.push( set[i] ); |
1510 | results.push( set[i] ); |
1847 | }
|
1511 | }
|
1848 | }
|
1512 | }
|
Строка 1856... | Строка 1520... | ||
1856 | } else { |
1520 | } else { |
1857 | makeArray( checkSet, results ); |
1521 | makeArray( checkSet, results ); |
1858 | }
|
1522 | }
|
1859 | 1523 | ||
1860 | if ( extra ) { |
1524 | if ( extra ) { |
1861 | Sizzle( extra, origContext, results, seed ); |
1525 | Sizzle( extra, context, results, seed ); |
1862 | Sizzle.uniqueSort( results ); |
- | |
1863 | }
|
- | |
1864 | - | ||
1865 | return results; |
- | |
1866 | }; |
- | |
1867 | 1526 | ||
1868 | Sizzle.uniqueSort = function(results){ |
- | |
1869 | if ( sortOrder ) { |
1527 | if ( sortOrder ) { |
1870 | hasDuplicate = false; |
1528 | hasDuplicate = false; |
1871 | results.sort(sortOrder); |
1529 | results.sort(sortOrder); |
1872 | 1530 | ||
1873 | if ( hasDuplicate ) { |
1531 | if ( hasDuplicate ) { |
1874 | for ( var i = 1; i < results.length; i++ ) { |
1532 | for ( var i = 1; i < results.length; i++ ) { |
1875 | if ( results[i] === results[i-1] ) { |
1533 | if ( results[i] === results[i-1] ) { |
1876 | results.splice(i--, 1); |
1534 | results.splice(i--, 1); |
- | 1535 | }
|
|
1877 | }
|
1536 | }
|
1878 | }
|
1537 | }
|
1879 | }
|
1538 | }
|
1880 | }
|
1539 | }
|
1881 | 1540 | ||
Строка 2066... | Строка 1725... | ||
2066 | }
|
1725 | }
|
2067 | }, |
1726 | }, |
2068 | "": function(checkSet, part, isXML){ |
1727 | "": function(checkSet, part, isXML){ |
2069 | var doneName = done++, checkFn = dirCheck; |
1728 | var doneName = done++, checkFn = dirCheck; |
2070 | 1729 | ||
2071 | if ( !/\W/.test(part) ) { |
1730 | if ( !part.match(/\W/) ) { |
2072 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1731 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
2073 | checkFn = dirNodeCheck; |
1732 | checkFn = dirNodeCheck; |
2074 | }
|
1733 | }
|
2075 | 1734 | ||
2076 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
1735 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
2077 | }, |
1736 | }, |
2078 | "~": function(checkSet, part, isXML){ |
1737 | "~": function(checkSet, part, isXML){ |
2079 | var doneName = done++, checkFn = dirCheck; |
1738 | var doneName = done++, checkFn = dirCheck; |
2080 | 1739 | ||
2081 | if ( typeof part === "string" && !/\W/.test(part) ) { |
1740 | if ( typeof part === "string" && !part.match(/\W/) ) { |
2082 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1741 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
2083 | checkFn = dirNodeCheck; |
1742 | checkFn = dirNodeCheck; |
2084 | }
|
1743 | }
|
2085 | 1744 | ||
2086 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
1745 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
Строка 2169... | Строка 1828... | ||
2169 | return match; |
1828 | return match; |
2170 | }, |
1829 | }, |
2171 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1830 | PSEUDO: function(match, curLoop, inplace, result, not){ |
2172 | if ( match[1] === "not" ) { |
1831 | if ( match[1] === "not" ) { |
2173 | // If we're dealing with a complex expression, or a simple one
|
1832 | // If we're dealing with a complex expression, or a simple one
|
2174 | if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) { |
1833 | if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { |
2175 | match[3] = Sizzle(match[3], null, null, curLoop); |
1834 | match[3] = Sizzle(match[3], null, null, curLoop); |
2176 | } else { |
1835 | } else { |
2177 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1836 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
2178 | if ( !inplace ) { |
1837 | if ( !inplace ) { |
2179 | result.push.apply( result, ret ); |
1838 | result.push.apply( result, ret ); |
Строка 2299... | Строка 1958... | ||
2299 | CHILD: function(elem, match){ |
1958 | CHILD: function(elem, match){ |
2300 | var type = match[1], node = elem; |
1959 | var type = match[1], node = elem; |
2301 | switch (type) { |
1960 | switch (type) { |
2302 | case 'only': |
1961 | case 'only': |
2303 | case 'first': |
1962 | case 'first': |
2304 | while ( (node = node.previousSibling) ) { |
1963 | while (node = node.previousSibling) { |
2305 | if ( node.nodeType === 1 ) return false; |
1964 | if ( node.nodeType === 1 ) return false; |
2306 | }
|
1965 | }
|
2307 | if ( type == 'first') return true; |
1966 | if ( type == 'first') return true; |
2308 | node = elem; |
1967 | node = elem; |
2309 | case 'last': |
1968 | case 'last': |
2310 | while ( (node = node.nextSibling) ) { |
1969 | while (node = node.nextSibling) { |
2311 | if ( node.nodeType === 1 ) return false; |
1970 | if ( node.nodeType === 1 ) return false; |
2312 | }
|
1971 | }
|
2313 | return true; |
1972 | return true; |
2314 | case 'nth': |
1973 | case 'nth': |
2315 | var first = match[2], last = match[3]; |
1974 | var first = match[2], last = match[3]; |
Строка 2353... | Строка 2012... | ||
2353 | var name = match[1], |
2012 | var name = match[1], |
2354 | result = Expr.attrHandle[ name ] ? |
2013 | result = Expr.attrHandle[ name ] ? |
2355 | Expr.attrHandle[ name ]( elem ) : |
2014 | Expr.attrHandle[ name ]( elem ) : |
2356 | elem[ name ] != null ? |
2015 | elem[ name ] != null ? |
2357 | elem[ name ] : |
2016 | elem[ name ] : |
2358 | elem.getAttribute( name ), |
2017 | elem.getAttribute( name ), |
2359 | value = result + "", |
2018 | value = result + "", |
2360 | type = match[2], |
2019 | type = match[2], |
2361 | check = match[4]; |
2020 | check = match[4]; |
2362 | - | ||
2363 | return result == null ? |
- | |
2364 | type === "!=" : |
- | |
2365 | type === "=" ? |
- | |
2366 | value === check : |
- | |
2367 | type === "*=" ? |
- | |
2368 | value.indexOf(check) >= 0 : |
- | |
2369 | type === "~=" ? |
- | |
2370 | (" " + value + " ").indexOf(check) >= 0 : |
- | |
2371 | !check ? |
- | |
2372 | value && result !== false : |
- | |
2373 | type === "!=" ? |
- | |
2374 | value != check : |
- | |
2375 | type === "^=" ? |
- | |
2376 | value.indexOf(check) === 0 : |
- | |
2377 | type === "$=" ? |
- | |
2378 | value.substr(value.length - check.length) === check : |
- | |
2379 | type === "|=" ? |
- | |
2380 | value === check || value.substr(0, check.length + 1) === check + "-" : |
- | |
2381 | false; |
- | |
2382 | }, |
- | |
2383 | POS: function(elem, match, i, array){ |
- | |
2384 | var name = match[2], filter = Expr.setFilters[ name ]; |
- | |
2385 | - | ||
2386 | if ( filter ) { |
- | |
2387 | return filter( elem, i, match, array ); |
- | |
2388 | }
|
- | |
2389 | }
|
- | |
2390 | }
|
- | |
2391 | }; |
- | |
2392 | - | ||
2393 | var origPOS = Expr.match.POS; |
- | |
2394 | - | ||
2395 | for ( var type in Expr.match ) { |
- | |
2396 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
- | |
2397 | }
|
- | |
2398 | - | ||
2399 | var makeArray = function(array, results) { |
- | |
2400 | array = Array.prototype.slice.call( array, 0 ); |
- | |
2401 | - | ||
2402 | if ( results ) { |
- | |
2403 | results.push.apply( results, array ); |
- | |
2404 | return results; |
- | |
2405 | }
|
- | |
2406 | - | ||
2407 | return array; |
- | |
2408 | }; |
- | |
2409 | - | ||
2410 | // Perform a simple check to determine if the browser is capable of
|
- | |
2411 | // converting a NodeList to an array using builtin methods.
|
- | |
2412 | try { |
- | |
2413 | Array.prototype.slice.call( document.documentElement.childNodes, 0 ); |
- | |
2414 | - | ||
2415 | // Provide a fallback method if it does not work
|
- | |
2416 | } catch(e){ |
- | |
2417 | makeArray = function(array, results) { |
- | |
2418 | var ret = results || []; |
- | |
2419 | - | ||
2420 | if ( toString.call(array) === "[object Array]" ) { |
- | |
2421 | Array.prototype.push.apply( ret, array ); |
- | |
2422 | } else { |
- | |
2423 | if ( typeof array.length === "number" ) { |
- | |
2424 | for ( var i = 0, l = array.length; i < l; i++ ) { |
- | |
2425 | ret.push( array[i] ); |
- | |
2426 | }
|
- | |
2427 | } else { |
- | |
2428 | for ( var i = 0; array[i]; i++ ) { |
- | |
2429 | ret.push( array[i] ); |
- | |
2430 | }
|
- | |
2431 | }
|
- | |
2432 | }
|
- | |
2433 | - | ||
2434 | return ret; |
- | |
2435 | }; |
- | |
2436 | }
|
- | |
2437 | - | ||
2438 | var sortOrder; |
- | |
2439 | - | ||
2440 | if ( document.documentElement.compareDocumentPosition ) { |
- | |
2441 | sortOrder = function( a, b ) { |
- | |
2442 | if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
- | |
2443 | if ( a == b ) { |
- | |
2444 | hasDuplicate = true; |
- | |
2445 | }
|
- | |
2446 | return 0; |
- | |
2447 | }
|
- | |
2448 | - | ||
2449 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
- | |
2450 | if ( ret === 0 ) { |
- | |
2451 | hasDuplicate = true; |
- | |
2452 | }
|
- | |
2453 | return ret; |
- | |
2454 | }; |
- | |
2455 | } else if ( "sourceIndex" in document.documentElement ) { |
- | |
2456 | sortOrder = function( a, b ) { |
- | |
2457 | if ( !a.sourceIndex || !b.sourceIndex ) { |
- | |
2458 | if ( a == b ) { |
- | |
2459 | hasDuplicate = true; |
- | |
2460 | }
|
- | |
2461 | return 0; |
- | |
2462 | }
|
- | |
2463 | - | ||
2464 | var ret = a.sourceIndex - b.sourceIndex; |
- | |
2465 | if ( ret === 0 ) { |
- | |
2466 | hasDuplicate = true; |
- | |
2467 | }
|
- | |
2468 | return ret; |
- | |
2469 | }; |
- | |
2470 | } else if ( document.createRange ) { |
- | |
2471 | sortOrder = function( a, b ) { |
- | |
2472 | if ( !a.ownerDocument || !b.ownerDocument ) { |
- | |
2473 | if ( a == b ) { |
- | |
2474 | hasDuplicate = true; |
- | |
2475 | }
|
- | |
2476 | return 0; |
- | |
2477 | }
|
- | |
2478 | - | ||
2479 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
- | |
2480 | aRange.selectNode(a); |
- | |
2481 | aRange.collapse(true); |
- | |
2482 | bRange.selectNode(b); |
- | |
2483 | bRange.collapse(true); |
- | |
2484 | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
- | |
2485 | if ( ret === 0 ) { |
- | |
2486 | hasDuplicate = true; |
- | |
2487 | }
|
- | |
2488 | return ret; |
- | |
2489 | }; |
- | |
2490 | }
|
- | |
2491 | - | ||
2492 | // Check to see if the browser returns elements by name when
|
- | |
2493 | // querying by getElementById (and provide a workaround)
|
- | |
2494 | (function(){ |
- | |
2495 | // We're going to inject a fake input element with a specified name
|
- | |
2496 | var form = document.createElement("div"), |
- | |
2497 | id = "script" + (new Date).getTime(); |
- | |
2498 | form.innerHTML = "<a name='" + id + "'/>"; |
- | |
2499 | - | ||
2500 | // Inject it into the root element, check its status, and remove it quickly
|
- | |
2501 | var root = document.documentElement; |
- | |
2502 | root.insertBefore( form, root.firstChild ); |
- | |
2503 | - | ||
2504 | // The workaround has to do additional checks after a getElementById
|
- | |
2505 | // Which slows things down for other browsers (hence the branching)
|
- | |
2506 | if ( !!document.getElementById( id ) ) { |
- | |
2507 | Expr.find.ID = function(match, context, isXML){ |
- | |
2508 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
- | |
2509 | var m = context.getElementById(match[1]); |
- | |
2510 | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
- | |
2511 | }
|
- | |
2512 | }; |
- | |
2513 | - | ||
2514 | Expr.filter.ID = function(elem, match){ |
- | |
2515 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
- | |
2516 | return elem.nodeType === 1 && node && node.nodeValue === match; |
- | |
2517 | }; |
- | |
2518 | }
|
- | |
2519 | - | ||
2520 | root.removeChild( form ); |
- | |
2521 | root = form = null; // release memory in IE |
- | |
2522 | })(); |
- | |
2523 | - | ||
2524 | (function(){ |
- | |
2525 | // Check to see if the browser returns only elements
|
- | |
2526 | // when doing getElementsByTagName("*")
|
- | |
2527 | - | ||
2528 | // Create a fake element
|
- | |
2529 | var div = document.createElement("div"); |
- | |
2530 | div.appendChild( document.createComment("") ); |
- | |
2531 | - | ||
2532 | // Make sure no comments are found
|
- | |
2533 | if ( div.getElementsByTagName("*").length > 0 ) { |
- | |
2534 | Expr.find.TAG = function(match, context){ |
- | |
2535 | var results = context.getElementsByTagName(match[1]); |
- | |
2536 | - | ||
2537 | // Filter out possible comments
|
- | |
2538 | if ( match[1] === "*" ) { |
- | |
2539 | var tmp = []; |
- | |
2540 | - | ||
2541 | for ( var i = 0; results[i]; i++ ) { |
- | |
2542 | if ( results[i].nodeType === 1 ) { |
- | |
2543 | tmp.push( results[i] ); |
- | |
2544 | }
|
- | |
2545 | }
|
- | |
2546 | - | ||
2547 | results = tmp; |
- | |
2548 | }
|
- | |
2549 | - | ||
2550 | return results; |
- | |
2551 | }; |
- | |
2552 | }
|
- | |
2553 | - | ||
2554 | // Check to see if an attribute returns normalized href attributes
|
- | |
2555 | div.innerHTML = "<a href='#'></a>"; |
- | |
2556 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
- | |
2557 | div.firstChild.getAttribute("href") !== "#" ) { |
- | |
2558 | Expr.attrHandle.href = function(elem){ |
- | |
2559 | return elem.getAttribute("href", 2); |
- | |
2560 | }; |
- | |
2561 | }
|
- | |
2562 | - | ||
2563 | div = null; // release memory in IE |
- | |
2564 | })(); |
- | |
2565 | - | ||
2566 | if ( document.querySelectorAll ) (function(){ |
- | |
2567 | var oldSizzle = Sizzle, div = document.createElement("div"); |
- | |
2568 | div.innerHTML = "<p class='TEST'></p>"; |
- | |
2569 | - | ||
2570 | // Safari can't handle uppercase or unicode characters when
|
- | |
2571 | // in quirks mode.
|
- | |
2572 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
- | |
2573 | return; |
- | |
2574 | }
|
- | |
2575 | - | ||
2576 | Sizzle = function(query, context, extra, seed){ |
- | |
2577 | context = context || document; |
- | |
2578 | - | ||
2579 | // Only use querySelectorAll on non-XML documents
|
- | |
2580 | // (ID selectors don't work in non-HTML documents)
|
- | |
2581 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
- | |
2582 | try { |
- | |
2583 | return makeArray( context.querySelectorAll(query), extra ); |
- | |
2584 | } catch(e){} |
- | |
2585 | }
|
- | |
2586 | - | ||
2587 | return oldSizzle(query, context, extra, seed); |
- | |
2588 | }; |
- | |
2589 | - | ||
2590 | for ( var prop in oldSizzle ) { |
- | |
2591 | Sizzle[ prop ] = oldSizzle[ prop ]; |
- | |
2592 | }
|
- | |
2593 | - | ||
2594 | div = null; // release memory in IE |
- | |
2595 | })(); |
- | |
2596 | - | ||
2597 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
- | |
2598 | var div = document.createElement("div"); |
- | |
2599 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
- | |
2600 | - | ||
2601 | // Opera can't find a second classname (in 9.6)
|
- | |
2602 | if ( div.getElementsByClassName("e").length === 0 ) |
- | |
2603 | return; |
- | |
2604 | - | ||
2605 | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
- | |
2606 | div.lastChild.className = "e"; |
- | |
2607 | - | ||
2608 | if ( div.getElementsByClassName("e").length === 1 ) |
- | |
2609 | return; |
- | |
2610 | - | ||
2611 | Expr.order.splice(1, 0, "CLASS"); |
- | |
2612 | Expr.find.CLASS = function(match, context, isXML) { |
- | |
2613 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
- | |
2614 | return context.getElementsByClassName(match[1]); |
- | |
2615 | }
|
- | |
2616 | }; |
- | |
2617 | - | ||
2618 | div = null; // release memory in IE |
- | |
2619 | })(); |
- | |
2620 | - | ||
2621 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
- | |
2622 | var sibDir = dir == "previousSibling" && !isXML; |
- | |
2623 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
- | |
2624 | var elem = checkSet[i]; |
- | |
2625 | if ( elem ) { |
- | |
2626 | if ( sibDir && elem.nodeType === 1 ){ |
- | |
2627 | elem.sizcache = doneName; |
- | |
2628 | elem.sizset = i; |
- | |
2629 | }
|
- | |
2630 | elem = elem[dir]; |
- | |
2631 | var match = false; |
- | |
2632 | - | ||
2633 | while ( elem ) { |
- | |
2634 | if ( elem.sizcache === doneName ) { |
- | |
2635 | match = checkSet[elem.sizset]; |
- | |
2636 | break; |
- | |
2637 | }
|
- | |
2638 | - | ||
2639 | if ( elem.nodeType === 1 && !isXML ){ |
- | |
2640 | elem.sizcache = doneName; |
- | |
2641 | elem.sizset = i; |
- | |
2642 | }
|
- | |
2643 | - | ||
2644 | if ( elem.nodeName === cur ) { |
- | |
2645 | match = elem; |
- | |
2646 | break; |
- | |
2647 | }
|
- | |
2648 | - | ||
2649 | elem = elem[dir]; |
- | |
2650 | }
|
- | |
2651 | - | ||
2652 | checkSet[i] = match; |
- | |
2653 | }
|
- | |
2654 | }
|
- | |
2655 | }
|
- | |
2656 | - | ||
2657 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
- | |
2658 | var sibDir = dir == "previousSibling" && !isXML; |
- | |
2659 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
- | |
2660 | var elem = checkSet[i]; |
- | |
2661 | if ( elem ) { |
- | |
2662 | if ( sibDir && elem.nodeType === 1 ) { |
- | |
2663 | elem.sizcache = doneName; |
- | |
2664 | elem.sizset = i; |
- | |
2665 | }
|
- | |
2666 | elem = elem[dir]; |
- | |
2667 | var match = false; |
- | |
2668 | - | ||
2669 | while ( elem ) { |
- | |
2670 | if ( elem.sizcache === doneName ) { |
- | |
2671 | match = checkSet[elem.sizset]; |
- | |
2672 | break; |
- | |
2673 | }
|
- | |
2674 | - | ||
2675 | if ( elem.nodeType === 1 ) { |
- | |
2676 | if ( !isXML ) { |
- | |
2677 | elem.sizcache = doneName; |
- | |
2678 | elem.sizset = i; |
- | |
2679 | }
|
- | |
2680 | if ( typeof cur !== "string" ) { |
- | |
2681 | if ( elem === cur ) { |
- | |
2682 | match = true; |
- | |
2683 | break; |
- | |
2684 | }
|
- | |
2685 | - | ||
2686 | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
- | |
2687 | match = elem; |
- | |
2688 | break; |
- | |
2689 | }
|
- | |
2690 | }
|
- | |
2691 | - | ||
2692 | elem = elem[dir]; |
- | |
2693 | }
|
- | |
2694 | - | ||
2695 | checkSet[i] = match; |
- | |
2696 | }
|
- | |
2697 | }
|
- | |
2698 | }
|
- | |
2699 | - | ||
2700 | var contains = document.compareDocumentPosition ? function(a, b){ |
- | |
2701 | return a.compareDocumentPosition(b) & 16; |
- | |
2702 | } : function(a, b){ |
- | |
2703 | return a !== b && (a.contains ? a.contains(b) : true); |
- | |
2704 | }; |
- | |
2705 | - | ||
2706 | var isXML = function(elem){ |
- | |
2707 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
- | |
2708 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
- | |
2709 | }; |
- | |
2710 | - | ||
2711 | var posProcess = function(selector, context){ |
- | |
2712 | var tmpSet = [], later = "", match, |
- | |
2713 | root = context.nodeType ? [context] : context; |
- | |
2714 | - | ||
2715 | // Position selectors must be done after the filter
|
- | |
2716 | // And so must :not(positional) so we move all PSEUDOs to the end
|
- | |
2717 | while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
- | |
2718 | later += match[0]; |
- | |
2719 | selector = selector.replace( Expr.match.PSEUDO, "" ); |
- | |
2720 | }
|
- | |
2721 | - | ||
2722 | selector = Expr.relative[selector] ? selector + "*" : selector; |
- | |
2723 | - | ||
2724 | for ( var i = 0, l = root.length; i < l; i++ ) { |
- | |
2725 | Sizzle( selector, root[i], tmpSet ); |
- | |
2726 | }
|
- | |
2727 | - | ||
2728 | return Sizzle.filter( later, tmpSet ); |
- | |
2729 | }; |
- | |
2730 | - | ||
2731 | // EXPOSE
|
- | |
2732 | jQuery.find = Sizzle; |
- | |
2733 | jQuery.expr = Sizzle.selectors; |
- | |
2734 | jQuery.expr[":"] = jQuery.expr.filters; |
- | |
2735 | - | ||
2736 | Sizzle.selectors.filters.hidden = function(elem){ |
- | |
2737 | var width = elem.offsetWidth, height = elem.offsetHeight, |
- | |
2738 | force = /^tr$/i.test( elem.nodeName ); // ticket #4512 |
- | |
2739 | return ( width === 0 && height === 0 && !force ) ? |
- | |
2740 | true : |
- | |
2741 | ( width !== 0 && height !== 0 && !force ) ? |
- | |
2742 | false : |
- | |
2743 | !!( jQuery.curCSS(elem, "display") === "none" ); |
- | |
2744 | }; |
- | |
2745 | - | ||
2746 | Sizzle.selectors.filters.visible = function(elem){ |
- | |
2747 | return !Sizzle.selectors.filters.hidden(elem); |
- | |
2748 | }; |
- | |
2749 | - | ||
2750 | Sizzle.selectors.filters.animated = function(elem){ |
- | |
2751 | return jQuery.grep(jQuery.timers, function(fn){ |
- | |
2752 | return elem === fn.elem; |
- | |
2753 | }).length; |
- | |
2754 | }; |
- | |
2755 | - | ||
2756 | jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) { |
- | |
2757 | if ( not ) { |
- | |
2758 | expr = ":not(" + expr + ")"; |
- | |
2759 | }
|
- | |
2760 | 2021 | ||
2761 | return Sizzle.matches(expr, elems); |
2022 | return result == null ? |
- | 2023 | type === "!=" : |
|
- | 2024 | type === "=" ? |
|
- | 2025 | value === check : |
|
- | 2026 | type === "*=" ? |
|
- | 2027 | value.indexOf(check) >= 0 : |
|
- | 2028 | type === "~=" ? |
|
- | 2029 | (" " + value + " ").indexOf(check) >= 0 : |
|
- | 2030 | !check ? |
|
- | 2031 | value && result !== false : |
|
- | 2032 | type === "!=" ? |
|
- | 2033 | value != check : |
|
- | 2034 | type === "^=" ? |
|
- | 2035 | value.indexOf(check) === 0 : |
|
- | 2036 | type === "$=" ? |
|
- | 2037 | value.substr(value.length - check.length) === check : |
|
- | 2038 | type === "|=" ? |
|
- | 2039 | value === check || value.substr(0, check.length + 1) === check + "-" : |
|
- | 2040 | false; |
|
2762 | }; |
2041 | }, |
- | 2042 | POS: function(elem, match, i, array){ |
|
- | 2043 | var name = match[2], filter = Expr.setFilters[ name ]; |
|
2763 | 2044 | ||
2764 | jQuery.dir = function( elem, dir ){ |
2045 | if ( filter ) { |
2765 | var matched = [], cur = elem[dir]; |
- | |
2766 | while ( cur && cur != document ) { |
2046 | return filter( elem, i, match, array ); |
2767 | if ( cur.nodeType == 1 ) |
- | |
2768 | matched.push( cur ); |
2047 | }
|
2769 | cur = cur[dir]; |
2048 | }
|
2770 | }
|
2049 | }
|
2771 | return matched; |
- | |
2772 | }; |
2050 | }; |
2773 | 2051 | ||
2774 | jQuery.nth = function(cur, result, dir, elem){ |
- | |
2775 | result = result || 1; |
2052 | var origPOS = Expr.match.POS; |
2776 | var num = 0; |
- | |
2777 | - | ||
2778 | for ( ; cur; cur = cur[dir] ) |
- | |
2779 | if ( cur.nodeType == 1 && ++num == result ) |
- | |
2780 | break; |
- | |
2781 | 2053 | ||
2782 | return cur; |
2054 | for ( var type in Expr.match ) { |
- | 2055 | Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
|
2783 | }; |
2056 | }
|
2784 | 2057 | ||
2785 | jQuery.sibling = function(n, elem){ |
2058 | var makeArray = function(array, results) { |
2786 | var r = []; |
2059 | array = Array.prototype.slice.call( array ); |
2787 | 2060 | ||
2788 | for ( ; n; n = n.nextSibling ) { |
2061 | if ( results ) { |
2789 | if ( n.nodeType == 1 && n != elem ) |
2062 | results.push.apply( results, array ); |
2790 | r.push( n ); |
2063 | return results; |
2791 | }
|
2064 | }
|
2792 | 2065 | ||
2793 | return r; |
2066 | return array; |
2794 | }; |
2067 | }; |
2795 | 2068 | ||
2796 | jQuery.unique = Sizzle.uniqueSort; |
- | |
2797 | - | ||
2798 | return; |
- | |
2799 | - | ||
2800 | window.Sizzle = Sizzle; |
- | |
2801 | - | ||
2802 | })(); |
- | |
2803 | var winnow = function( elements, qualifier, keep ) { |
2069 | // Perform a simple check to determine if the browser is capable of
|
2804 | if(jQuery.isFunction( qualifier )) { |
- | |
2805 | return jQuery.grep(elements, function(elem, i) { |
2070 | // converting a NodeList to an array using builtin methods.
|
2806 | return !!qualifier.call( elem, i ) === keep; |
- | |
2807 | }); |
2071 | try { |
2808 | } else if( qualifier.nodeType ) { |
- | |
2809 | return jQuery.grep(elements, function(elem, i) { |
- | |
2810 | return (elem === qualifier) === keep; |
- | |
2811 | }) |
- | |
2812 | } else if( typeof qualifier === "string" ) { |
- | |
2813 | var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 }); |
2072 | Array.prototype.slice.call( document.documentElement.childNodes ); |
2814 | - | ||
2815 | if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep); |
- | |
2816 | else qualifier = jQuery.multiFilter( qualifier, elements ); |
- | |
2817 | }
|
- | |
2818 | - | ||
2819 | return jQuery.grep(elements, function(elem, i) { |
- | |
2820 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
- | |
2821 | }); |
- | |
2822 | }
|
- | |
2823 | 2073 | ||
- | 2074 | // Provide a fallback method if it does not work
|
|
2824 | jQuery.fn.extend({ |
2075 | } catch(e){ |
2825 | find: function( selector ) { |
2076 | makeArray = function(array, results) { |
2826 | var ret = this.pushStack( "", "find", selector ), length = 0; |
2077 | var ret = results || []; |
2827 | 2078 | ||
2828 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2079 | if ( toString.call(array) === "[object Array]" ) { |
2829 | length = ret.length; |
- | |
2830 | jQuery.find( selector, this[i], ret ); |
2080 | Array.prototype.push.apply( ret, array ); |
2831 | - | ||
2832 | if ( i > 0 ) { |
2081 | } else { |
2833 | // Make sure that the results are unique
|
- | |
2834 | for ( var n = length; n < ret.length; n++ ) { |
2082 | if ( typeof array.length === "number" ) { |
2835 | for ( var r = 0; r < length; r++ ) { |
2083 | for ( var i = 0, l = array.length; i < l; i++ ) { |
2836 | if ( ret[r] === ret[n] ) { |
- | |
2837 | ret.splice(n--, 1); |
2084 | ret.push( array[i] ); |
2838 | break; |
- | |
2839 | }
|
2085 | }
|
2840 | }
|
2086 | } else { |
- | 2087 | for ( var i = 0; array[i]; i++ ) { |
|
- | 2088 | ret.push( array[i] ); |
|
2841 | }
|
2089 | }
|
2842 | }
|
2090 | }
|
2843 | }
|
2091 | }
|
2844 | 2092 | ||
2845 | return ret; |
2093 | return ret; |
2846 | }, |
2094 | }; |
2847 | - | ||
2848 | not: function( selector ) { |
- | |
2849 | return this.pushStack( winnow(this, selector, false), "not", selector); |
- | |
2850 | }, |
- | |
2851 | - | ||
2852 | filter: function( selector ) { |
- | |
2853 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
- | |
2854 | }, |
- | |
2855 | - | ||
2856 | closest: function( selector, context ) { |
- | |
2857 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
- | |
2858 | closer = 0; |
- | |
2859 | - | ||
2860 | return this.map(function(){ |
- | |
2861 | var cur = this; |
- | |
2862 | while ( cur && cur.ownerDocument && cur !== context ) { |
- | |
2863 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
- | |
2864 | jQuery.data(cur, "closest", closer); |
- | |
2865 | return cur; |
- | |
2866 | }
|
- | |
2867 | cur = cur.parentNode; |
- | |
2868 | closer++;
|
- | |
2869 | }
|
- | |
2870 | }); |
- | |
2871 | }, |
- | |
2872 | - | ||
2873 | add: function( selector ) { |
- | |
2874 | var set = typeof selector === "string" ? |
- | |
2875 | jQuery( selector ) : |
- | |
2876 | jQuery.makeArray( selector ), |
- | |
2877 | all = jQuery.merge( this.get(), set ); |
- | |
2878 | - | ||
2879 | return this.pushStack( set[0] && (set[0].setInterval || set[0].nodeType === 9 || (set[0].parentNode && set[0].parentNode.nodeType !== 11)) ? |
- | |
2880 | jQuery.unique( all ) : |
- | |
2881 | all ); |
- | |
2882 | }, |
- | |
2883 | 2095 | }
|
|
2884 | eq: function( i ) { |
- | |
2885 | return i === -1 ? |
- | |
2886 | this.slice( i ) : |
- | |
2887 | this.slice( i, +i + 1 ); |
- | |
2888 | }, |
- | |
2889 | 2096 | ||
2890 | first: function() { |
- | |
2891 | return this.eq( 0 ); |
2097 | var sortOrder; |
2892 | }, |
- | |
2893 | 2098 | ||
- | 2099 | if ( document.documentElement.compareDocumentPosition ) { |
|
2894 | last: function() { |
2100 | sortOrder = function( a, b ) { |
- | 2101 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
|
- | 2102 | if ( ret === 0 ) { |
|
- | 2103 | hasDuplicate = true; |
|
- | 2104 | }
|
|
- | 2105 | return ret; |
|
- | 2106 | }; |
|
- | 2107 | } else if ( "sourceIndex" in document.documentElement ) { |
|
- | 2108 | sortOrder = function( a, b ) { |
|
- | 2109 | var ret = a.sourceIndex - b.sourceIndex; |
|
- | 2110 | if ( ret === 0 ) { |
|
- | 2111 | hasDuplicate = true; |
|
- | 2112 | }
|
|
- | 2113 | return ret; |
|
- | 2114 | }; |
|
- | 2115 | } else if ( document.createRange ) { |
|
- | 2116 | sortOrder = function( a, b ) { |
|
- | 2117 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
|
- | 2118 | aRange.selectNode(a); |
|
- | 2119 | aRange.collapse(true); |
|
- | 2120 | bRange.selectNode(b); |
|
- | 2121 | bRange.collapse(true); |
|
- | 2122 | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
|
- | 2123 | if ( ret === 0 ) { |
|
- | 2124 | hasDuplicate = true; |
|
- | 2125 | }
|
|
2895 | return this.eq( -1 ); |
2126 | return ret; |
2896 | }, |
2127 | }; |
- | 2128 | }
|
|
2897 | 2129 | ||
- | 2130 | // Check to see if the browser returns elements by name when
|
|
- | 2131 | // querying by getElementById (and provide a workaround)
|
|
2898 | slice: function() { |
2132 | (function(){ |
2899 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
2133 | // We're going to inject a fake input element with a specified name
|
2900 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
2134 | var form = document.createElement("form"), |
2901 | }, |
- | |
- | 2135 | id = "script" + (new Date).getTime(); |
|
- | 2136 | form.innerHTML = "<input name='" + id + "'/>"; |
|
2902 | 2137 | ||
2903 | map: function( callback ) { |
2138 | // Inject it into the root element, check its status, and remove it quickly
|
2904 | return this.pushStack( jQuery.map(this, function(elem, i){ |
2139 | var root = document.documentElement; |
2905 | return callback.call( elem, i, elem ); |
2140 | root.insertBefore( form, root.firstChild ); |
2906 | })); |
- | |
2907 | }, |
- | |
2908 | 2141 | ||
- | 2142 | // The workaround has to do additional checks after a getElementById
|
|
- | 2143 | // Which slows things down for other browsers (hence the branching)
|
|
- | 2144 | if ( !!document.getElementById( id ) ) { |
|
2909 | andSelf: function() { |
2145 | Expr.find.ID = function(match, context, isXML){ |
- | 2146 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
|
2910 | return this.add( this.prevObject ); |
2147 | var m = context.getElementById(match[1]); |
- | 2148 | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
|
- | 2149 | }
|
|
2911 | }, |
2150 | }; |
2912 | 2151 | ||
2913 | end: function() { |
2152 | Expr.filter.ID = function(elem, match){ |
- | 2153 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
|
2914 | return this.prevObject || jQuery(null); |
2154 | return elem.nodeType === 1 && node && node.nodeValue === match; |
- | 2155 | }; |
|
2915 | }
|
2156 | }
|
2916 | }); |
- | |
2917 | - | ||
2918 | jQuery.each({ |
- | |
2919 | parent: function(elem){return elem.parentNode;}, |
- | |
2920 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
- | |
2921 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
- | |
2922 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
- | |
2923 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
- | |
2924 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
- | |
2925 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
- | |
2926 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
- | |
2927 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
- | |
2928 | }, function(name, fn){ |
- | |
2929 | jQuery.fn[ name ] = function( selector ) { |
- | |
2930 | var ret = jQuery.map( this, fn ); |
- | |
2931 | - | ||
2932 | if ( selector && typeof selector === "string" ) { |
- | |
2933 | ret = jQuery.multiFilter( selector, ret ); |
- | |
2934 | }
|
- | |
2935 | 2157 | ||
2936 | ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
2158 | root.removeChild( form ); |
- | 2159 | })(); |
|
2937 | 2160 | ||
- | 2161 | (function(){ |
|
2938 | if ( name === "parents" && this.length > 1 ) { |
2162 | // Check to see if the browser returns only elements
|
2939 | ret = ret.reverse(); |
2163 | // when doing getElementsByTagName("*")
|
2940 | }
|
- | |
2941 | 2164 | ||
2942 | return this.pushStack( ret, name, selector ); |
- | |
2943 | }; |
- | |
2944 | }); |
- | |
2945 | jQuery.fn.extend({ |
2165 | // Create a fake element
|
2946 | attr: function( name, value ) { |
2166 | var div = document.createElement("div"); |
2947 | return access(this, name, value, true, jQuery.attr); |
2167 | div.appendChild( document.createComment("") ); |
2948 | }, |
- | |
2949 | 2168 | ||
2950 | addClass: function( value ) { |
2169 | // Make sure no comments are found
|
2951 | if ( value && typeof value === "string" ) { |
2170 | if ( div.getElementsByTagName("*").length > 0 ) { |
- | 2171 | Expr.find.TAG = function(match, context){ |
|
2952 | var classNames = (value || "").split(/\s+/); |
2172 | var results = context.getElementsByTagName(match[1]); |
2953 | 2173 | ||
- | 2174 | // Filter out possible comments
|
|
2954 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2175 | if ( match[1] === "*" ) { |
2955 | var elem = this[i]; |
2176 | var tmp = []; |
2956 | 2177 | ||
2957 | if ( elem.nodeType === 1 ) { |
2178 | for ( var i = 0; results[i]; i++ ) { |
2958 | if ( !elem.className ) { |
2179 | if ( results[i].nodeType === 1 ) { |
2959 | elem.className = value; |
2180 | tmp.push( results[i] ); |
2960 | } else { |
- | |
2961 | var className = " " + elem.className + " "; |
- | |
2962 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
- | |
2963 | if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
- | |
2964 | elem.className += " " + classNames[c]; |
- | |
2965 | }
|
- | |
2966 | }
|
- | |
2967 | }
|
2181 | }
|
2968 | }
|
2182 | }
|
- | 2183 | ||
- | 2184 | results = tmp; |
|
2969 | }
|
2185 | }
|
2970 | }
|
- | |
2971 | 2186 | ||
2972 | return this; |
2187 | return results; |
- | 2188 | }; |
|
- | 2189 | }
|
|
- | 2190 | ||
- | 2191 | // Check to see if an attribute returns normalized href attributes
|
|
- | 2192 | div.innerHTML = "<a href='#'></a>"; |
|
- | 2193 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
|
- | 2194 | div.firstChild.getAttribute("href") !== "#" ) { |
|
- | 2195 | Expr.attrHandle.href = function(elem){ |
|
- | 2196 | return elem.getAttribute("href", 2); |
|
- | 2197 | }; |
|
2973 | }, |
2198 | }
|
- | 2199 | })(); |
|
2974 | 2200 | ||
2975 | removeClass: function( value ) { |
- | |
2976 | if ( (value && typeof value === "string") || value === undefined ) { |
- | |
2977 | var classNames = (value || "").split(/\s+/); |
- | |
2978 | - | ||
2979 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | |
2980 | var elem = this[i]; |
- | |
2981 | - | ||
2982 | if ( elem.nodeType === 1 && elem.className ) { |
2201 | if ( document.querySelectorAll ) (function(){ |
2983 | if ( value ) { |
- | |
2984 | var className = " " + elem.className + " "; |
2202 | var oldSizzle = Sizzle, div = document.createElement("div"); |
2985 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
- | |
2986 | className = className.replace(" " + classNames[c] + " ", " "); |
- | |
2987 | }
|
- | |
2988 | elem.className = className.substring(1, className.length - 1); |
- | |
2989 | } else { |
- | |
2990 | elem.className = ""; |
2203 | div.innerHTML = "<p class='TEST'></p>"; |
2991 | }
|
- | |
2992 | }
|
- | |
2993 | }
|
- | |
2994 | }
|
- | |
2995 | 2204 | ||
- | 2205 | // Safari can't handle uppercase or unicode characters when
|
|
- | 2206 | // in quirks mode.
|
|
- | 2207 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
|
2996 | return this; |
2208 | return; |
2997 | }, |
2209 | }
|
- | 2210 | ||
- | 2211 | Sizzle = function(query, context, extra, seed){ |
|
- | 2212 | context = context || document; |
|
2998 | 2213 | ||
2999 | hasClass: function( selector ) { |
- | |
3000 | var className = " " + selector + " "; |
2214 | // Only use querySelectorAll on non-XML documents
|
3001 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2215 | // (ID selectors don't work in non-HTML documents)
|
3002 | if ( (" " + this[i].className + " ").indexOf( className ) > -1 ) { |
2216 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
3003 | return true; |
2217 | try { |
- | 2218 | return makeArray( context.querySelectorAll(query), extra ); |
|
3004 | }
|
2219 | } catch(e){} |
3005 | }
|
2220 | }
|
- | 2221 | ||
- | 2222 | return oldSizzle(query, context, extra, seed); |
|
- | 2223 | }; |
|
3006 | 2224 | ||
3007 | return false; |
2225 | Sizzle.find = oldSizzle.find; |
3008 | }, |
- | |
3009 | - | ||
3010 | val: function( value ) { |
2226 | Sizzle.filter = oldSizzle.filter; |
3011 | if ( value === undefined ) { |
2227 | Sizzle.selectors = oldSizzle.selectors; |
3012 | var elem = this[0]; |
2228 | Sizzle.matches = oldSizzle.matches; |
- | 2229 | })(); |
|
3013 | 2230 | ||
3014 | if ( elem ) { |
2231 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
3015 | if( jQuery.nodeName( elem, 'option' ) ) |
2232 | var div = document.createElement("div"); |
3016 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
2233 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
3017 | 2234 | ||
3018 | // We need to handle select boxes special
|
2235 | // Opera can't find a second classname (in 9.6)
|
3019 | if ( jQuery.nodeName( elem, "select" ) ) { |
2236 | if ( div.getElementsByClassName("e").length === 0 ) |
3020 | var index = elem.selectedIndex, |
- | |
3021 | values = [], |
2237 | return; |
3022 | options = elem.options, |
- | |
3023 | one = elem.type == "select-one"; |
- | |
3024 | 2238 | ||
3025 | // Nothing was selected
|
2239 | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
3026 | if ( index < 0 ) |
2240 | div.lastChild.className = "e"; |
3027 | return null; |
- | |
3028 | 2241 | ||
3029 | // Loop through all the selected options
|
2242 | if ( div.getElementsByClassName("e").length === 1 ) |
3030 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
- | |
3031 | var option = options[ i ]; |
2243 | return; |
3032 | 2244 | ||
3033 | if ( option.selected ) { |
2245 | Expr.order.splice(1, 0, "CLASS"); |
3034 | // Get the specifc value for the option
|
2246 | Expr.find.CLASS = function(match, context, isXML) { |
- | 2247 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
|
3035 | value = jQuery(option).val(); |
2248 | return context.getElementsByClassName(match[1]); |
- | 2249 | }
|
|
- | 2250 | }; |
|
- | 2251 | })(); |
|
3036 | 2252 | ||
- | 2253 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
|
3037 | // We don't need an array for one selects
|
2254 | var sibDir = dir == "previousSibling" && !isXML; |
- | 2255 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
|
- | 2256 | var elem = checkSet[i]; |
|
3038 | if ( one ) |
2257 | if ( elem ) { |
- | 2258 | if ( sibDir && elem.nodeType === 1 ){ |
|
- | 2259 | elem.sizcache = doneName; |
|
- | 2260 | elem.sizset = i; |
|
- | 2261 | }
|
|
- | 2262 | elem = elem[dir]; |
|
3039 | return value; |
2263 | var match = false; |
3040 | 2264 | ||
- | 2265 | while ( elem ) { |
|
3041 | // Multi-Selects return an array
|
2266 | if ( elem.sizcache === doneName ) { |
3042 | values.push( value ); |
2267 | match = checkSet[elem.sizset]; |
3043 | }
|
2268 | break; |
3044 | }
|
2269 | }
|
3045 | 2270 | ||
- | 2271 | if ( elem.nodeType === 1 && !isXML ){ |
|
- | 2272 | elem.sizcache = doneName; |
|
3046 | return values; |
2273 | elem.sizset = i; |
3047 | }
|
2274 | }
|
3048 | 2275 | ||
3049 | // Everything else, we just grab the value
|
2276 | if ( elem.nodeName === cur ) { |
3050 | return (elem.value || "").replace(/\r/g, ""); |
2277 | match = elem; |
- | 2278 | break; |
|
- | 2279 | }
|
|
3051 | 2280 | ||
- | 2281 | elem = elem[dir]; |
|
3052 | }
|
2282 | }
|
3053 | 2283 | ||
3054 | return undefined; |
2284 | checkSet[i] = match; |
3055 | }
|
2285 | }
|
- | 2286 | }
|
|
- | 2287 | }
|
|
3056 | 2288 | ||
3057 | // Typecast once if the value is a number
|
2289 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
3058 | if ( typeof value === "number" ) |
2290 | var sibDir = dir == "previousSibling" && !isXML; |
3059 | value += ''; |
2291 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
3060 | - | ||
3061 | var val = value; |
2292 | var elem = checkSet[i]; |
3062 | - | ||
3063 | return this.each(function(){ |
2293 | if ( elem ) { |
3064 | if(jQuery.isFunction(value)) { |
2294 | if ( sibDir && elem.nodeType === 1 ) { |
3065 | val = value.call(this); |
2295 | elem.sizcache = doneName; |
3066 | // Typecast each time if the value is a Function and the appended
|
- | |
3067 | // value is therefore different each time.
|
2296 | elem.sizset = i; |
3068 | if( typeof val === "number" ) val += ''; |
- | |
3069 | }
|
2297 | }
|
3070 | - | ||
3071 | if ( this.nodeType != 1 ) |
2298 | elem = elem[dir]; |
3072 | return; |
2299 | var match = false; |
3073 | 2300 | ||
- | 2301 | while ( elem ) { |
|
3074 | if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) |
2302 | if ( elem.sizcache === doneName ) { |
3075 | this.checked = jQuery.inArray(this.value || this.name, val) >= 0; |
2303 | match = checkSet[elem.sizset]; |
- | 2304 | break; |
|
- | 2305 | }
|
|
3076 | 2306 | ||
3077 | else if ( jQuery.nodeName( this, "select" ) ) { |
2307 | if ( elem.nodeType === 1 ) { |
- | 2308 | if ( !isXML ) { |
|
- | 2309 | elem.sizcache = doneName; |
|
- | 2310 | elem.sizset = i; |
|
- | 2311 | }
|
|
3078 | var values = jQuery.makeArray(val); |
2312 | if ( typeof cur !== "string" ) { |
- | 2313 | if ( elem === cur ) { |
|
- | 2314 | match = true; |
|
- | 2315 | break; |
|
- | 2316 | }
|
|
3079 | 2317 | ||
3080 | jQuery( "option", this ).each(function(){ |
2318 | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
3081 | this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; |
2319 | match = elem; |
- | 2320 | break; |
|
- | 2321 | }
|
|
3082 | }); |
2322 | }
|
3083 | 2323 | ||
3084 | if ( !values.length ) |
2324 | elem = elem[dir]; |
3085 | this.selectedIndex = -1; |
2325 | }
|
3086 | 2326 | ||
3087 | } else |
- | |
3088 | this.value = val; |
2327 | checkSet[i] = match; |
3089 | }); |
2328 | }
|
3090 | }
|
2329 | }
|
3091 | }); |
2330 | }
|
3092 | 2331 | ||
3093 | jQuery.each({ |
- | |
3094 | removeAttr: function( name ) { |
2332 | var contains = document.compareDocumentPosition ? function(a, b){ |
3095 | jQuery.attr( this, name, "" ); |
2333 | return a.compareDocumentPosition(b) & 16; |
3096 | if (this.nodeType == 1) |
2334 | } : function(a, b){ |
3097 | this.removeAttribute( name ); |
2335 | return a !== b && (a.contains ? a.contains(b) : true); |
3098 | }, |
2336 | }; |
3099 | 2337 | ||
3100 | toggleClass: function( classNames, state ) { |
- | |
3101 | var type = typeof classNames; |
2338 | var isXML = function(elem){ |
3102 | if ( type === "string" ) { |
- | |
3103 | // toggle individual class names
|
- | |
3104 | var isBool = typeof state === "boolean", className, i = 0, |
- | |
3105 | classNames = classNames.split( /\s+/ ); |
- | |
3106 | while ( (className = classNames[ i++ ]) ) { |
- | |
3107 | // check each className given, space seperated list
|
- | |
3108 | state = isBool ? state : !jQuery(this).hasClass( className ); |
- | |
3109 | jQuery(this)[ state ? "addClass" : "removeClass" ]( className ); |
- | |
3110 | }
|
- | |
3111 | } else if ( type === "undefined" || type === "boolean" ) { |
2339 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
3112 | if ( this.className ) { |
- | |
3113 | // store className if set
|
- | |
3114 | jQuery.data( this, "__className__", this.className ); |
- | |
3115 | }
|
- | |
3116 | // toggle whole className
|
- | |
3117 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
- | |
3118 | }
|
- | |
3119 | }
|
- | |
3120 | }, function(name, fn){ |
- | |
3121 | jQuery.fn[ name ] = function(){ |
- | |
3122 | return this.each( fn, arguments ); |
2340 | !!elem.ownerDocument && isXML( elem.ownerDocument ); |
3123 | }; |
- | |
3124 | }); |
2341 | }; |
3125 | 2342 | ||
3126 | jQuery.extend({ |
- | |
3127 | attr: function( elem, name, value ) { |
2343 | var posProcess = function(selector, context){ |
3128 | // don't set attributes on text and comment nodes
|
2344 | var tmpSet = [], later = "", match, |
3129 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
2345 | root = context.nodeType ? [context] : context; |
3130 | return undefined; |
- | |
3131 | 2346 | ||
3132 | if ( name in jQuery.fn && name !== "attr" ) { |
2347 | // Position selectors must be done after the filter
|
3133 | return jQuery(elem)[name](value); |
2348 | // And so must :not(positional) so we move all PSEUDOs to the end
|
3134 | }
|
- | |
3135 | - | ||
3136 | var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
2349 | while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
3137 | // Whether we are setting (or getting)
|
2350 | later += match[0]; |
3138 | set = value !== undefined; |
2351 | selector = selector.replace( Expr.match.PSEUDO, "" ); |
- | 2352 | }
|
|
3139 | 2353 | ||
3140 | // Try to normalize/fix the name
|
- | |
3141 | name = notxml && jQuery.props[ name ] || name; |
2354 | selector = Expr.relative[selector] ? selector + "*" : selector; |
3142 | 2355 | ||
3143 | // Only do all the following if this is a node (faster for style)
|
2356 | for ( var i = 0, l = root.length; i < l; i++ ) { |
3144 | if ( elem.nodeType === 1 ) { |
2357 | Sizzle( selector, root[i], tmpSet ); |
- | 2358 | }
|
|
3145 | 2359 | ||
3146 | // These attributes require special treatment
|
- | |
3147 | var special = /href|src|style/.test( name ); |
2360 | return Sizzle.filter( later, tmpSet ); |
- | 2361 | }; |
|
3148 | 2362 | ||
- | 2363 | // EXPOSE
|
|
3149 | // Safari mis-reports the default selected property of a hidden option
|
2364 | jQuery.find = Sizzle; |
3150 | // Accessing the parent's selectedIndex property fixes it
|
2365 | jQuery.filter = Sizzle.filter; |
3151 | if ( name == "selected" && elem.parentNode ) |
2366 | jQuery.expr = Sizzle.selectors; |
3152 | elem.parentNode.selectedIndex; |
2367 | jQuery.expr[":"] = jQuery.expr.filters; |
3153 | 2368 | ||
3154 | // If applicable, access the attribute via the DOM 0 way
|
2369 | Sizzle.selectors.filters.hidden = function(elem){ |
3155 | if ( name in elem && notxml && !special ) { |
2370 | return elem.offsetWidth === 0 || elem.offsetHeight === 0; |
3156 | if ( set ){ |
2371 | }; |
3157 | // We can't allow the type property to be changed (since it causes problems in IE)
|
- | |
3158 | if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) |
- | |
3159 | throw "type property can't be changed"; |
- | |
3160 | 2372 | ||
- | 2373 | Sizzle.selectors.filters.visible = function(elem){ |
|
3161 | elem[ name ] = value; |
2374 | return elem.offsetWidth > 0 || elem.offsetHeight > 0; |
3162 | }
|
2375 | }; |
3163 | 2376 | ||
3164 | // browsers index elements by id/name on forms, give priority to attributes.
|
2377 | Sizzle.selectors.filters.animated = function(elem){ |
3165 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
2378 | return jQuery.grep(jQuery.timers, function(fn){ |
3166 | return elem.getAttributeNode( name ).nodeValue; |
2379 | return elem === fn.elem; |
- | 2380 | }).length; |
|
- | 2381 | }; |
|
3167 | 2382 | ||
3168 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
- | |
3169 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
- | |
3170 | if ( name == "tabIndex" ) { |
- | |
3171 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
2383 | jQuery.multiFilter = function( expr, elems, not ) { |
3172 | return attributeNode && attributeNode.specified |
- | |
3173 | ? attributeNode.value |
- | |
3174 | : /(button|input|object|select|textarea)/i.test(elem.nodeName) |
- | |
3175 | ? 0 |
- | |
3176 | : /^(a|area)$/i.test(elem.nodeName) && elem.href |
- | |
3177 | ? 0 |
2384 | if ( not ) { |
3178 | : undefined; |
2385 | expr = ":not(" + expr + ")"; |
3179 | }
|
2386 | }
|
3180 | 2387 | ||
3181 | return elem[ name ]; |
2388 | return Sizzle.matches(expr, elems); |
3182 | }
|
2389 | }; |
3183 | 2390 | ||
- | 2391 | jQuery.dir = function( elem, dir ){ |
|
- | 2392 | var matched = [], cur = elem[dir]; |
|
3184 | if ( !jQuery.support.style && notxml && name == "style" ) { |
2393 | while ( cur && cur != document ) { |
3185 | if ( set ) |
2394 | if ( cur.nodeType == 1 ) |
3186 | elem.style.cssText = "" + value; |
2395 | matched.push( cur ); |
- | 2396 | cur = cur[dir]; |
|
- | 2397 | }
|
|
- | 2398 | return matched; |
|
- | 2399 | }; |
|
3187 | 2400 | ||
- | 2401 | jQuery.nth = function(cur, result, dir, elem){ |
|
3188 | return elem.style.cssText; |
2402 | result = result || 1; |
3189 | }
|
2403 | var num = 0; |
3190 | 2404 | ||
3191 | if ( set ) |
2405 | for ( ; cur; cur = cur[dir] ) |
3192 | // convert the value to a string (all browsers do this but IE) see #1070
|
2406 | if ( cur.nodeType == 1 && ++num == result ) |
3193 | elem.setAttribute( name, "" + value ); |
2407 | break; |
3194 | 2408 | ||
3195 | var attr = !jQuery.support.hrefNormalized && notxml && special |
- | |
3196 | // Some attributes require a special call on IE
|
- | |
3197 | ? elem.getAttribute( name, 2 ) |
- | |
3198 | : elem.getAttribute( name ); |
2409 | return cur; |
- | 2410 | }; |
|
3199 | 2411 | ||
3200 | // Non-existent attributes return null, we normalize to undefined
|
- | |
3201 | return attr === null ? undefined : attr; |
2412 | jQuery.sibling = function(n, elem){ |
3202 | }
|
2413 | var r = []; |
3203 | 2414 | ||
3204 | // elem is actually elem.style ... set the style
|
2415 | for ( ; n; n = n.nextSibling ) { |
3205 | // Using attr for specific style information is now deprecated. Use style insead.
|
2416 | if ( n.nodeType == 1 && n != elem ) |
3206 | return jQuery.style(elem, name, value); |
2417 | r.push( n ); |
3207 | }
|
2418 | }
|
3208 | }); |
- | |
3209 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
- | |
3210 | rleadingWhitespace = /^\s+/, |
- | |
3211 | rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
- | |
3212 | rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
- | |
3213 | rtagName = /<([\w:]+)/, |
- | |
3214 | rtbody = /<tbody/i, |
- | |
3215 | rhtml = /</, |
- | |
3216 | fcloseTag = function(all, front, tag){ |
- | |
3217 | return rselfClosing.test(tag) ? |
- | |
3218 | all :
|
- | |
3219 | front + "></" + tag + ">"; |
- | |
3220 | }, |
- | |
3221 | wrapMap = { |
- | |
3222 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
- | |
3223 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
- | |
3224 | thead: [ 1, "<table>", "</table>" ], |
- | |
3225 | tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
- | |
3226 | td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
- | |
3227 | col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
- | |
3228 | _default: [ 0, "", "" ] |
- | |
3229 | }; |
- | |
3230 | - | ||
3231 | wrapMap.optgroup = wrapMap.option; |
- | |
3232 | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
- | |
3233 | wrapMap.th = wrapMap.td; |
- | |
3234 | - | ||
3235 | // IE can't serialize <link> and <script> tags normally
|
- | |
3236 | if ( !jQuery.support.htmlSerialize ) { |
- | |
3237 | wrapMap._default = [ 1, "div<div>", "</div>" ]; |
- | |
3238 | }
|
- | |
3239 | 2419 | ||
3240 | jQuery.fn.extend({ |
2420 | return r; |
3241 | text: function( text ) { |
- | |
3242 | if ( typeof text !== "object" && text !== undefined ) |
- | |
3243 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
- | |
- | 2421 | }; |
|
3244 | 2422 | ||
3245 | var ret = ""; |
2423 | return; |
3246 | 2424 | ||
3247 | jQuery.each( text || this, function(){ |
- | |
3248 | jQuery.each( this.childNodes, function(){ |
- | |
3249 | if ( this.nodeType !== 8 ) { |
- | |
3250 | ret += this.nodeType !== 1 ? |
- | |
3251 | this.nodeValue : |
2425 | window.Sizzle = Sizzle; |
3252 | jQuery.fn.text( [ this ] ); |
- | |
3253 | }
|
- | |
3254 | }); |
- | |
3255 | }); |
- | |
3256 | 2426 | ||
3257 | return ret; |
2427 | })(); |
- | 2428 | /*
|
|
- | 2429 | * A number of helper functions used for managing events.
|
|
- | 2430 | * Many of the ideas behind this code originated from
|
|
- | 2431 | * Dean Edwards' addEvent library.
|
|
3258 | }, |
2432 | */
|
- | 2433 | jQuery.event = { |
|
3259 | 2434 | ||
3260 | wrapAll: function( html ) { |
2435 | // Bind an event to an element
|
3261 | if ( jQuery.isFunction( html ) ) { |
2436 | // Original by Dean Edwards
|
3262 | return this.each(function() { |
2437 | add: function(elem, types, handler, data) { |
3263 | jQuery(this).wrapAll( html.apply(this, arguments) ); |
2438 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
3264 | }); |
2439 | return; |
3265 | }
|
- | |
3266 | 2440 | ||
3267 | if ( this[0] ) { |
2441 | // For whatever reason, IE has trouble passing the window object
|
3268 | // The elements to wrap the target around
|
2442 | // around, causing it to be cloned in the process
|
3269 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); |
2443 | if ( elem.setInterval && elem != window ) |
- | 2444 | elem = window; |
|
3270 | 2445 | ||
- | 2446 | // Make sure that the function being executed has a unique ID
|
|
3271 | if ( this[0].parentNode ) { |
2447 | if ( !handler.guid ) |
3272 | wrap.insertBefore( this[0] ); |
2448 | handler.guid = this.guid++; |
3273 | }
|
- | |
3274 | 2449 | ||
- | 2450 | // if data is passed, bind to handler
|
|
3275 | wrap.map(function(){ |
2451 | if ( data !== undefined ) { |
- | 2452 | // Create temporary function pointer to original handler
|
|
3276 | var elem = this; |
2453 | var fn = handler; |
3277 | 2454 | ||
3278 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
2455 | // Create unique handler function, wrapped around original handler
|
3279 | elem = elem.firstChild; |
2456 | handler = this.proxy( fn ); |
3280 | }
|
- | |
3281 | 2457 | ||
3282 | return elem; |
2458 | // Store data in unique handler
|
3283 | }).append(this); |
2459 | handler.data = data; |
3284 | }
|
2460 | }
|
3285 | 2461 | ||
- | 2462 | // Init the element's event structure
|
|
- | 2463 | var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), |
|
- | 2464 | handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ |
|
- | 2465 | // Handle the second event of a trigger and when
|
|
- | 2466 | // an event is called after a page has unloaded
|
|
- | 2467 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
|
- | 2468 | jQuery.event.handle.apply(arguments.callee.elem, arguments) : |
|
3286 | return this; |
2469 | undefined; |
3287 | }, |
2470 | }); |
- | 2471 | // Add elem as a property of the handle function
|
|
- | 2472 | // This is to prevent a memory leak with non-native
|
|
- | 2473 | // event in IE.
|
|
- | 2474 | handle.elem = elem; |
|
3288 | 2475 | ||
- | 2476 | // Handle multiple events separated by a space
|
|
- | 2477 | // jQuery(...).bind("mouseover mouseout", fn);
|
|
3289 | wrapInner: function( html ) { |
2478 | jQuery.each(types.split(/\s+/), function(index, type) { |
3290 | return this.each(function(){ |
2479 | // Namespaced event handlers
|
3291 | jQuery( this ).contents().wrapAll( html ); |
2480 | var namespaces = type.split("."); |
3292 | }); |
2481 | type = namespaces.shift(); |
3293 | }, |
- | |
- | 2482 | handler.type = namespaces.slice().sort().join("."); |
|
3294 | 2483 | ||
3295 | wrap: function( html ) { |
2484 | // Get the current list of functions bound to this event
|
3296 | return this.each(function(){ |
2485 | var handlers = events[type]; |
- | 2486 | ||
3297 | jQuery( this ).wrapAll( html ); |
2487 | if ( jQuery.event.specialAll[type] ) |
3298 | }); |
- | |
3299 | }, |
- | |
- | 2488 | jQuery.event.specialAll[type].setup.call(elem, data, namespaces); |
|
3300 | 2489 | ||
3301 | unwrap: function() { |
- | |
3302 | return this.parent().each(function(){ |
2490 | // Init the event handler queue
|
3303 | if ( !jQuery.nodeName( this, "body" ) ) { |
- | |
3304 | jQuery( this ).replaceWith( this.childNodes ); |
- | |
3305 | }
|
- | |
3306 | }).end(); |
- | |
3307 | }, |
- | |
3308 | - | ||
3309 | append: function() { |
- | |
3310 | return this.domManip(arguments, true, function(elem){ |
- | |
3311 | if ( this.nodeType === 1 ) { |
2491 | if (!handlers) { |
3312 | this.appendChild( elem ); |
2492 | handlers = events[type] = {}; |
3313 | }
|
- | |
3314 | }); |
- | |
3315 | }, |
- | |
3316 | 2493 | ||
- | 2494 | // Check for a special event handler
|
|
- | 2495 | // Only use addEventListener/attachEvent if the special
|
|
3317 | prepend: function() { |
2496 | // events handler returns false
|
- | 2497 | if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) { |
|
3318 | return this.domManip(arguments, true, function(elem){ |
2498 | // Bind the global event handler to the element
|
3319 | if ( this.nodeType === 1 ) { |
2499 | if (elem.addEventListener) |
3320 | this.insertBefore( elem, this.firstChild ); |
2500 | elem.addEventListener(type, handle, false); |
- | 2501 | else if (elem.attachEvent) |
|
- | 2502 | elem.attachEvent("on" + type, handle); |
|
- | 2503 | }
|
|
3321 | }
|
2504 | }
|
3322 | }); |
- | |
3323 | }, |
- | |
3324 | - | ||
3325 | before: function() { |
- | |
3326 | if ( this[0] && this[0].parentNode ) { |
- | |
3327 | return this.domManip(arguments, false, function(elem){ |
- | |
3328 | this.parentNode.insertBefore( elem, this ); |
- | |
3329 | }); |
- | |
3330 | } else if ( arguments.length ) { |
- | |
3331 | var set = jQuery(arguments[0]); |
- | |
3332 | set.push.apply( set, this.toArray() ); |
- | |
3333 | return this.pushStack( set, "before", arguments ); |
- | |
3334 | }
|
- | |
3335 | }, |
- | |
3336 | - | ||
3337 | after: function() { |
- | |
3338 | if ( this[0] && this[0].parentNode ) { |
- | |
3339 | return this.domManip(arguments, false, function(elem){ |
- | |
3340 | this.parentNode.insertBefore( elem, this.nextSibling ); |
- | |
3341 | }); |
- | |
3342 | } else if ( arguments.length ) { |
- | |
3343 | var set = this.pushStack( this, "after", arguments ); |
- | |
3344 | set.push.apply( set, jQuery(arguments[0]).toArray() ); |
- | |
3345 | return set; |
- | |
3346 | }
|
- | |
3347 | }, |
- | |
3348 | 2505 | ||
3349 | clone: function( events ) { |
- | |
3350 | // Do the clone
|
- | |
3351 | var ret = this.map(function(){ |
- | |
3352 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
- | |
3353 | // IE copies events bound via attachEvent when
|
- | |
3354 | // using cloneNode. Calling detachEvent on the
|
- | |
3355 | // clone will also remove the events from the orignal
|
2506 | // Add the function to the element's handler list
|
3356 | // In order to get around this, we use innerHTML.
|
- | |
3357 | // Unfortunately, this means some modifications to
|
- | |
3358 | // attributes in IE that are actually only stored
|
- | |
3359 | // as properties will not be copied (such as the
|
- | |
3360 | // the name attribute on an input).
|
2507 | handlers[handler.guid] = handler; |
3361 | var html = this.outerHTML, ownerDocument = this.ownerDocument; |
- | |
3362 | if ( !html ) { |
- | |
3363 | var div = ownerDocument.createElement("div"); |
- | |
3364 | div.appendChild( this.cloneNode(true) ); |
- | |
3365 | html = div.innerHTML; |
- | |
3366 | }
|
- | |
3367 | 2508 | ||
3368 | return jQuery.clean([html.replace(rinlinejQuery, "") |
- | |
3369 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
2509 | // Keep track of which events have been used, for global triggering
|
3370 | } else { |
- | |
3371 | return this.cloneNode(true); |
2510 | jQuery.event.global[type] = true; |
3372 | }
|
- | |
3373 | }); |
2511 | }); |
3374 | 2512 | ||
3375 | // Copy the events from the original to the clone
|
2513 | // Nullify elem to prevent memory leaks in IE
|
3376 | if ( events === true ) { |
2514 | elem = null; |
3377 | var orig = this.find("*").andSelf(), i = 0; |
- | |
- | 2515 | }, |
|
3378 | 2516 | ||
3379 | ret.find("*").andSelf().each(function(){ |
2517 | guid: 1, |
3380 | if ( this.nodeName !== orig[i].nodeName ) { return; } |
2518 | global: {}, |
3381 | 2519 | ||
3382 | var events = jQuery.data( orig[i], "events" ); |
2520 | // Detach an event or set of events from an element
|
- | 2521 | remove: function(elem, types, handler) { |
|
- | 2522 | // don't do events on text and comment nodes
|
|
- | 2523 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
|
- | 2524 | return; |
|
3383 | 2525 | ||
- | 2526 | var events = jQuery.data(elem, "events"), ret, index; |
|
- | 2527 | ||
3384 | for ( var type in events ) { |
2528 | if ( events ) { |
- | 2529 | // Unbind all events for the element
|
|
- | 2530 | if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") ) |
|
3385 | for ( var handler in events[ type ] ) { |
2531 | for ( var type in events ) |
3386 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
2532 | this.remove( elem, type + (types || "") ); |
3387 | }
|
2533 | else { |
- | 2534 | // types is actually an event object here
|
|
- | 2535 | if ( types.type ) { |
|
- | 2536 | handler = types.handler; |
|
- | 2537 | types = types.type; |
|
3388 | }
|
2538 | }
|
3389 | 2539 | ||
- | 2540 | // Handle multiple events seperated by a space
|
|
- | 2541 | // jQuery(...).unbind("mouseover mouseout", fn);
|
|
- | 2542 | jQuery.each(types.split(/\s+/), function(index, type){ |
|
- | 2543 | // Namespaced event handlers
|
|
3390 | i++;
|
2544 | var namespaces = type.split("."); |
3391 | }); |
2545 | type = namespaces.shift(); |
3392 | }
|
- | |
- | 2546 | var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
|
3393 | 2547 | ||
3394 | // Return the cloned set
|
2548 | if ( events[type] ) { |
- | 2549 | // remove the given handler for the given type
|
|
3395 | return ret; |
2550 | if ( handler ) |
3396 | }, |
- | |
- | 2551 | delete events[type][handler.guid]; |
|
3397 | 2552 | ||
3398 | html: function( value ) { |
2553 | // remove all handlers for the given type
|
- | 2554 | else
|
|
3399 | if ( value === undefined ) { |
2555 | for ( var handle in events[type] ) |
3400 | return this[0] ? |
2556 | // Handle the removal of namespaced events
|
3401 | this[0].innerHTML.replace(rinlinejQuery, "") : |
2557 | if ( namespace.test(events[type][handle].type) ) |
3402 | null; |
2558 | delete events[type][handle]; |
3403 | 2559 | ||
3404 | // See if we can take a shortcut and just use innerHTML
|
2560 | if ( jQuery.event.specialAll[type] ) |
3405 | } else if ( typeof value === "string" && !/<script/i.test( value ) && |
- | |
3406 | (!jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
2561 | jQuery.event.specialAll[type].teardown.call(elem, namespaces); |
3407 | !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
- | |
3408 | 2562 | ||
- | 2563 | // remove generic event handler if no more handlers exist
|
|
- | 2564 | for ( ret in events[type] ) break; |
|
3409 | try { |
2565 | if ( !ret ) { |
- | 2566 | if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) { |
|
3410 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2567 | if (elem.removeEventListener) |
3411 | // Remove element nodes and prevent memory leaks
|
2568 | elem.removeEventListener(type, jQuery.data(elem, "handle"), false); |
3412 | if ( this[i].nodeType === 1 ) { |
2569 | else if (elem.detachEvent) |
3413 | cleanData( this[i].getElementsByTagName("*") ); |
2570 | elem.detachEvent("on" + type, jQuery.data(elem, "handle")); |
- | 2571 | }
|
|
3414 | this[i].innerHTML = value; |
2572 | ret = null; |
- | 2573 | delete events[type]; |
|
- | 2574 | }
|
|
3415 | }
|
2575 | }
|
3416 | }
|
2576 | }); |
3417 | - | ||
3418 | // If using innerHTML throws an exception, use the fallback method
|
- | |
3419 | } catch(e) { |
- | |
3420 | this.empty().append( value ); |
- | |
3421 | }
|
2577 | }
|
3422 | 2578 | ||
- | 2579 | // Remove the expando if it's no longer used
|
|
- | 2580 | for ( ret in events ) break; |
|
3423 | } else { |
2581 | if ( !ret ) { |
- | 2582 | var handle = jQuery.data( elem, "handle" ); |
|
- | 2583 | if ( handle ) handle.elem = null; |
|
- | 2584 | jQuery.removeData( elem, "events" ); |
|
3424 | this.empty().append( value ); |
2585 | jQuery.removeData( elem, "handle" ); |
- | 2586 | }
|
|
3425 | }
|
2587 | }
|
3426 | - | ||
3427 | return this; |
- | |
3428 | }, |
2588 | }, |
3429 | 2589 | ||
3430 | replaceWith: function( value ) { |
2590 | // bubbling is internal
|
3431 | if ( this[0] && this[0].parentNode ) { |
2591 | trigger: function( event, data, elem, bubbling ) { |
3432 | return this.after( value ).remove(); |
2592 | // Event object or event type
|
3433 | } else { |
2593 | var type = event.type || event; |
3434 | return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
- | |
3435 | }
|
- | |
3436 | }, |
- | |
3437 | 2594 | ||
- | 2595 | if( !bubbling ){ |
|
- | 2596 | event = typeof event === "object" ? |
|
- | 2597 | // jQuery.Event object
|
|
- | 2598 | event[expando] ? event : |
|
- | 2599 | // Object literal
|
|
- | 2600 | jQuery.extend( jQuery.Event(type), event ) : |
|
- | 2601 | // Just the event type (string)
|
|
- | 2602 | jQuery.Event(type); |
|
- | 2603 | ||
- | 2604 | if ( type.indexOf("!") >= 0 ) { |
|
- | 2605 | event.type = type = type.slice(0, -1); |
|
- | 2606 | event.exclusive = true; |
|
- | 2607 | }
|
|
- | 2608 | ||
- | 2609 | // Handle a global trigger
|
|
3438 | detach: function( selector ) { |
2610 | if ( !elem ) { |
- | 2611 | // Don't bubble custom events when global (to avoid too much overhead)
|
|
- | 2612 | event.stopPropagation(); |
|
- | 2613 | // Only trigger if we've ever bound an event for it
|
|
- | 2614 | if ( this.global[type] ) |
|
- | 2615 | jQuery.each( jQuery.cache, function(){ |
|
3439 | return this.remove( selector, true ); |
2616 | if ( this.events && this.events[type] ) |
- | 2617 | jQuery.event.trigger( event, data, this.handle.elem ); |
|
- | 2618 | }); |
|
3440 | }, |
2619 | }
|
3441 | 2620 | ||
3442 | domManip: function( args, table, callback ) { |
2621 | // Handle triggering a single element
|
3443 | var results, first, value = args[0], scripts = []; |
- | |
3444 | 2622 | ||
3445 | if ( jQuery.isFunction(value) ) { |
2623 | // don't do events on text and comment nodes
|
- | 2624 | if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 ) |
|
3446 | return this.each(function() { |
2625 | return undefined; |
- | 2626 | ||
- | 2627 | // Clean up in case it is reused
|
|
3447 | args[0] = value.call(this); |
2628 | event.result = undefined; |
- | 2629 | event.target = elem; |
|
- | 2630 | ||
- | 2631 | // Clone the incoming data, if any
|
|
3448 | return jQuery(this).domManip( args, table, callback ); |
2632 | data = jQuery.makeArray(data); |
3449 | }); |
2633 | data.unshift( event ); |
3450 | }
|
2634 | }
|
3451 | 2635 | ||
3452 | if ( this[0] ) { |
- | |
3453 | // If we're in a fragment, just use that instead of building a new one
|
- | |
3454 | if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) { |
- | |
3455 | results = { fragment: args[0].parentNode }; |
- | |
3456 | } else { |
- | |
3457 | results = buildFragment( args, this, scripts ); |
- | |
3458 | }
|
- | |
3459 | - | ||
3460 | first = results.fragment.firstChild; |
2636 | event.currentTarget = elem; |
3461 | 2637 | ||
- | 2638 | // Trigger the event, it is assumed that "handle" is a function
|
|
- | 2639 | var handle = jQuery.data(elem, "handle"); |
|
3462 | if ( first ) { |
2640 | if ( handle ) |
3463 | table = table && jQuery.nodeName( first, "tr" ); |
2641 | handle.apply( elem, data ); |
3464 | 2642 | ||
3465 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2643 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
3466 | callback.call( |
- | |
3467 | table ?
|
- | |
3468 | root(this[i], first) : |
- | |
3469 | this[i], |
- | |
3470 | results.cacheable || this.length > 1 || i > 0 ? |
2644 | if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) |
3471 | results.fragment.cloneNode(true) : |
- | |
3472 | results.fragment
|
2645 | event.result = false; |
3473 | ); |
- | |
3474 | }
|
- | |
3475 | }
|
- | |
3476 | 2646 | ||
3477 | if ( scripts ) { |
2647 | // Trigger the native events (except for clicks on links)
|
- | 2648 | if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) { |
|
3478 | jQuery.each( scripts, evalScript ); |
2649 | this.triggered = true; |
3479 | }
|
2650 | try { |
- | 2651 | elem[ type ](); |
|
- | 2652 | // prevent IE from throwing an error for some hidden elements
|
|
- | 2653 | } catch (e) {} |
|
3480 | }
|
2654 | }
|
3481 | 2655 | ||
3482 | return this; |
2656 | this.triggered = false; |
3483 | 2657 | ||
3484 | function root( elem, cur ) { |
2658 | if ( !event.isPropagationStopped() ) { |
3485 | return jQuery.nodeName(elem, "table") ? |
2659 | var parent = elem.parentNode || elem.ownerDocument; |
3486 | (elem.getElementsByTagName("tbody")[0] || |
2660 | if ( parent ) |
3487 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2661 | jQuery.event.trigger(event, data, parent, true); |
3488 | elem;
|
- | |
3489 | }
|
2662 | }
|
3490 | }
|
2663 | }, |
3491 | }); |
- | |
3492 | 2664 | ||
3493 | function buildFragment(args, nodes, scripts){ |
2665 | handle: function(event) { |
3494 | var fragment, cacheable, cached, cacheresults, doc; |
2666 | // returned undefined or false
|
- | 2667 | var all, handlers; |
|
3495 | 2668 | ||
3496 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
2669 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
3497 | cacheable = true; |
2670 | event.currentTarget = this; |
3498 | cacheresults = jQuery.fragments[ args[0] ]; |
- | |
- | 2671 | ||
3499 | if ( cacheresults ) { |
2672 | // Namespaced event handlers
|
3500 | if ( cacheresults !== 1 ) { |
2673 | var namespaces = event.type.split("."); |
3501 | fragment = cacheresults; |
2674 | event.type = namespaces.shift(); |
3502 | }
|
- | |
3503 | cached = true; |
- | |
3504 | }
|
- | |
3505 | }
|
- | |
3506 | 2675 | ||
3507 | if ( !fragment ) { |
- | |
3508 | doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
- | |
3509 | fragment = doc.createDocumentFragment(); |
2676 | // Cache this now, all = true means, any handler
|
3510 | jQuery.clean( args, doc, fragment, scripts ); |
2677 | all = !namespaces.length && !event.exclusive; |
3511 | }
|
2678 | |
- | 2679 | var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
|
3512 | 2680 | ||
3513 | if ( cacheable ) { |
- | |
3514 | jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
2681 | handlers = ( jQuery.data(this, "events") || {} )[event.type]; |
3515 | }
|
- | |
3516 | 2682 | ||
3517 | return { fragment: fragment, cacheable: cacheable }; |
2683 | for ( var j in handlers ) { |
3518 | }
|
- | |
- | 2684 | var handler = handlers[j]; |
|
3519 | 2685 | ||
- | 2686 | // Filter the functions by class
|
|
- | 2687 | if ( all || namespace.test(handler.type) ) { |
|
- | 2688 | // Pass in a reference to the handler function itself
|
|
- | 2689 | // So that we can later remove it
|
|
3520 | jQuery.fragments = {}; |
2690 | event.handler = handler; |
- | 2691 | event.data = handler.data; |
|
3521 | 2692 | ||
3522 | jQuery.each({ |
- | |
3523 | appendTo: "append", |
- | |
3524 | prependTo: "prepend", |
- | |
3525 | insertBefore: "before", |
- | |
3526 | insertAfter: "after", |
- | |
3527 | replaceAll: "replaceWith" |
- | |
3528 | }, function(name, original){ |
- | |
3529 | jQuery.fn[ name ] = function( selector ) { |
- | |
3530 | var ret = [], insert = jQuery( selector ); |
2693 | var ret = handler.apply(this, arguments); |
3531 | 2694 | ||
3532 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
2695 | if( ret !== undefined ){ |
3533 | var elems = (i > 0 ? this.clone(true) : this).get(); |
2696 | event.result = ret; |
3534 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
2697 | if ( ret === false ) { |
3535 | ret = ret.concat( elems ); |
2698 | event.preventDefault(); |
3536 | }
|
- | |
3537 | return this.pushStack( ret, name, insert.selector ); |
2699 | event.stopPropagation(); |
3538 | }; |
2700 | }
|
3539 | }); |
2701 | }
|
3540 | 2702 | ||
3541 | jQuery.each({ |
- | |
3542 | // keepData is for internal use only--do not document
|
- | |
3543 | remove: function( selector, keepData ) { |
- | |
3544 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
- | |
3545 | if ( !keepData && this.nodeType === 1 ) { |
2703 | if( event.isImmediatePropagationStopped() ) |
3546 | cleanData( this.getElementsByTagName("*") ); |
- | |
3547 | cleanData( [ this ] ); |
- | |
3548 | }
|
2704 | break; |
3549 | 2705 | ||
3550 | if ( this.parentNode ) { |
- | |
3551 | this.parentNode.removeChild( this ); |
- | |
3552 | }
|
2706 | }
|
3553 | }
|
2707 | }
|
3554 | }, |
2708 | }, |
3555 | 2709 | ||
3556 | empty: function() { |
- | |
3557 | // Remove element nodes and prevent memory leaks
|
2710 | props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
3558 | if ( this.nodeType === 1 ) { |
- | |
3559 | cleanData( this.getElementsByTagName("*") ); |
- | |
3560 | }
|
- | |
3561 | 2711 | ||
3562 | // Remove any remaining nodes
|
- | |
3563 | while ( this.firstChild ) { |
- | |
3564 | this.removeChild( this.firstChild ); |
- | |
3565 | }
|
- | |
3566 | }
|
- | |
3567 | }, function(name, fn){ |
2712 | fix: function(event) { |
3568 | jQuery.fn[ name ] = function(){ |
2713 | if ( event[expando] ) |
3569 | return this.each( fn, arguments ); |
2714 | return event; |
3570 | }; |
- | |
3571 | }); |
- | |
3572 | 2715 | ||
3573 | jQuery.extend({ |
2716 | // store a copy of the original event object
|
3574 | clean: function( elems, context, fragment, scripts ) { |
2717 | // and "clone" to set read-only properties
|
3575 | context = context || document; |
2718 | var originalEvent = event; |
- | 2719 | event = jQuery.Event( originalEvent ); |
|
3576 | 2720 | ||
3577 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
2721 | for ( var i = this.props.length, prop; i; ){ |
3578 | if ( typeof context.createElement === "undefined" ) { |
2722 | prop = this.props[ --i ]; |
3579 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
2723 | event[ prop ] = originalEvent[ prop ]; |
3580 | }
|
2724 | }
|
3581 | 2725 | ||
3582 | var ret = [], div = context.createElement("div"); |
2726 | // Fix target property, if necessary
|
- | 2727 | if ( !event.target ) |
|
- | 2728 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
|
3583 | 2729 | ||
3584 | jQuery.each(elems, function(i, elem){ |
2730 | // check if target is a textnode (safari)
|
3585 | if ( typeof elem === "number" ) { |
2731 | if ( event.target.nodeType == 3 ) |
3586 | elem += ''; |
2732 | event.target = event.target.parentNode; |
3587 | }
|
- | |
3588 | 2733 | ||
3589 | if ( !elem ) { return; } |
2734 | // Add relatedTarget, if necessary
|
- | 2735 | if ( !event.relatedTarget && event.fromElement ) |
|
- | 2736 | event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; |
|
3590 | 2737 | ||
3591 | // Convert html string into DOM nodes
|
2738 | // Calculate pageX/Y if missing and clientX/Y available
|
3592 | if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
2739 | if ( event.pageX == null && event.clientX != null ) { |
3593 | elem = context.createTextNode( elem ); |
2740 | var doc = document.documentElement, body = document.body; |
- | 2741 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); |
|
- | 2742 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); |
|
- | 2743 | }
|
|
3594 | 2744 | ||
3595 | } else if ( typeof elem === "string" ) { |
2745 | // Add which for key events
|
3596 | // Fix "XHTML"-style tags in all browsers
|
2746 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) |
3597 | elem = elem.replace(rxhtmlTag, fcloseTag); |
2747 | event.which = event.charCode || event.keyCode; |
3598 | 2748 | ||
3599 | // Trim whitespace, otherwise indexOf won't work as expected
|
2749 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
3600 | var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
- | |
3601 | wrap = wrapMap[ tag ] || wrapMap._default, |
2750 | if ( !event.metaKey && event.ctrlKey ) |
3602 | depth = wrap[0]; |
2751 | event.metaKey = event.ctrlKey; |
3603 | 2752 | ||
3604 | // Go to html and back, then peel off extra wrappers
|
2753 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
- | 2754 | // Note: button is not normalized, so don't use it
|
|
3605 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2755 | if ( !event.which && event.button ) |
- | 2756 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
|
3606 | 2757 | ||
3607 | // Move to the right depth
|
- | |
3608 | while ( depth-- ) { |
2758 | return event; |
3609 | div = div.lastChild; |
- | |
3610 | }
|
2759 | }, |
3611 | 2760 | ||
- | 2761 | proxy: function( fn, proxy ){ |
|
- | 2762 | proxy = proxy || function(){ return fn.apply(this, arguments); }; |
|
- | 2763 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
|
- | 2764 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
|
3612 | // Remove IE's autoinserted <tbody> from table fragments
|
2765 | // So proxy can be declared as an argument
|
3613 | if ( !jQuery.support.tbody ) { |
2766 | return proxy; |
- | 2767 | }, |
|
3614 | 2768 | ||
- | 2769 | special: { |
|
- | 2770 | ready: { |
|
3615 | // String was a <table>, *may* have spurious <tbody>
|
2771 | // Make sure the ready event is setup
|
- | 2772 | setup: bindReady, |
|
- | 2773 | teardown: function() {} |
|
- | 2774 | }
|
|
- | 2775 | }, |
|
- | 2776 | ||
- | 2777 | specialAll: { |
|
- | 2778 | live: { |
|
- | 2779 | setup: function( selector, namespaces ){ |
|
- | 2780 | jQuery.event.add( this, namespaces[0], liveHandler ); |
|
- | 2781 | }, |
|
3616 | var hasBody = rtbody.test(elem), |
2782 | teardown: function( namespaces ){ |
- | 2783 | if ( namespaces.length ) { |
|
- | 2784 | var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
|
- | 2785 | ||
- | 2786 | jQuery.each( (jQuery.data(this, "events").live || {}), function(){ |
|
3617 | tbody = tag === "table" && !hasBody ? |
2787 | if ( name.test(this.type) ) |
- | 2788 | remove++;
|
|
- | 2789 | }); |
|
- | 2790 | ||
- | 2791 | if ( remove < 1 ) |
|
3618 | div.firstChild && div.firstChild.childNodes : |
2792 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
- | 2793 | }
|
|
- | 2794 | }
|
|
- | 2795 | }
|
|
- | 2796 | }
|
|
- | 2797 | }; |
|
3619 | 2798 | ||
- | 2799 | jQuery.Event = function( src ){ |
|
3620 | // String was a bare <thead> or <tfoot>
|
2800 | // Allow instantiation without the 'new' keyword
|
- | 2801 | if( !this.preventDefault ) |
|
3621 | wrap[1] == "<table>" && !hasBody ? |
2802 | return new jQuery.Event(src); |
- | 2803 | ||
- | 2804 | // Event object
|
|
- | 2805 | if( src && src.type ){ |
|
3622 | div.childNodes : |
2806 | this.originalEvent = src; |
- | 2807 | this.type = src.type; |
|
3623 | []; |
2808 | // Event type
|
- | 2809 | }else |
|
- | 2810 | this.type = src; |
|
3624 | 2811 | ||
3625 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
2812 | // timeStamp is buggy for some events on Firefox(#3843)
|
3626 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
2813 | // So we won't rely on the native value
|
3627 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
2814 | this.timeStamp = now(); |
- | 2815 | ||
3628 | }
|
2816 | // Mark it as fixed
|
- | 2817 | this[expando] = true; |
|
3629 | }
|
2818 | }; |
3630 | 2819 | ||
- | 2820 | function returnFalse(){ |
|
- | 2821 | return false; |
|
- | 2822 | }
|
|
- | 2823 | function returnTrue(){ |
|
- | 2824 | return true; |
|
3631 | }
|
2825 | }
|
3632 | 2826 | ||
3633 | // IE completely kills leading whitespace when innerHTML is used
|
2827 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
3634 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
2828 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
- | 2829 | jQuery.Event.prototype = { |
|
- | 2830 | preventDefault: function() { |
|
3635 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
2831 | this.isDefaultPrevented = returnTrue; |
3636 | }
|
- | |
3637 | 2832 | ||
- | 2833 | var e = this.originalEvent; |
|
- | 2834 | if( !e ) |
|
- | 2835 | return; |
|
- | 2836 | // if preventDefault exists run it on the original event
|
|
- | 2837 | if (e.preventDefault) |
|
- | 2838 | e.preventDefault(); |
|
- | 2839 | // otherwise set the returnValue property of the original event to false (IE)
|
|
- | 2840 | e.returnValue = false; |
|
- | 2841 | }, |
|
- | 2842 | stopPropagation: function() { |
|
- | 2843 | this.isPropagationStopped = returnTrue; |
|
- | 2844 | ||
- | 2845 | var e = this.originalEvent; |
|
- | 2846 | if( !e ) |
|
- | 2847 | return; |
|
- | 2848 | // if stopPropagation exists run it on the original event
|
|
- | 2849 | if (e.stopPropagation) |
|
- | 2850 | e.stopPropagation(); |
|
- | 2851 | // otherwise set the cancelBubble property of the original event to true (IE)
|
|
- | 2852 | e.cancelBubble = true; |
|
- | 2853 | }, |
|
- | 2854 | stopImmediatePropagation:function(){ |
|
- | 2855 | this.isImmediatePropagationStopped = returnTrue; |
|
- | 2856 | this.stopPropagation(); |
|
- | 2857 | }, |
|
- | 2858 | isDefaultPrevented: returnFalse, |
|
- | 2859 | isPropagationStopped: returnFalse, |
|
- | 2860 | isImmediatePropagationStopped: returnFalse
|
|
- | 2861 | }; |
|
- | 2862 | // Checks if an event happened on an element within another element
|
|
- | 2863 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
|
- | 2864 | var withinElement = function(event) { |
|
- | 2865 | // Check if mouse(over|out) are still within the same parent element
|
|
- | 2866 | var parent = event.relatedTarget; |
|
- | 2867 | // Traverse up the tree
|
|
- | 2868 | while ( parent && parent != this ) |
|
- | 2869 | try { parent = parent.parentNode; } |
|
- | 2870 | catch(e) { parent = this; } |
|
- | 2871 | ||
- | 2872 | if( parent != this ){ |
|
- | 2873 | // set the correct event type
|
|
- | 2874 | event.type = event.data; |
|
- | 2875 | // handle event if we actually just moused on to a non sub-element
|
|
3638 | elem = jQuery.makeArray( div.childNodes ); |
2876 | jQuery.event.handle.apply( this, arguments ); |
- | 2877 | }
|
|
- | 2878 | }; |
|
- | 2879 | ||
- | 2880 | jQuery.each({ |
|
- | 2881 | mouseover: 'mouseenter', |
|
- | 2882 | mouseout: 'mouseleave' |
|
- | 2883 | }, function( orig, fix ){ |
|
- | 2884 | jQuery.event.special[ fix ] = { |
|
- | 2885 | setup: function(){ |
|
- | 2886 | jQuery.event.add( this, orig, withinElement, fix ); |
|
- | 2887 | }, |
|
- | 2888 | teardown: function(){ |
|
- | 2889 | jQuery.event.remove( this, orig, withinElement ); |
|
3639 | }
|
2890 | }
|
- | 2891 | }; |
|
- | 2892 | }); |
|
3640 | 2893 | ||
3641 | if ( elem.nodeType ) { |
2894 | jQuery.fn.extend({ |
3642 | ret.push( elem ); |
2895 | bind: function( type, data, fn ) { |
3643 | } else { |
2896 | return type == "unload" ? this.one(type, data, fn) : this.each(function(){ |
3644 | ret = jQuery.merge( ret, elem ); |
2897 | jQuery.event.add( this, type, fn || data, fn && data ); |
3645 | }
|
2898 | }); |
- | 2899 | }, |
|
3646 | 2900 | ||
- | 2901 | one: function( type, data, fn ) { |
|
- | 2902 | var one = jQuery.event.proxy( fn || data, function(event) { |
|
- | 2903 | jQuery(this).unbind(event, one); |
|
- | 2904 | return (fn || data).apply( this, arguments ); |
|
- | 2905 | }); |
|
- | 2906 | return this.each(function(){ |
|
- | 2907 | jQuery.event.add( this, type, one, fn && data); |
|
3647 | }); |
2908 | }); |
- | 2909 | }, |
|
3648 | 2910 | ||
3649 | if ( fragment ) { |
- | |
3650 | for ( var i = 0; ret[i]; i++ ) { |
2911 | unbind: function( type, fn ) { |
3651 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
- | |
3652 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
- | |
3653 | } else { |
- | |
3654 | if ( ret[i].nodeType === 1 ) { |
2912 | return this.each(function(){ |
3655 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
- | |
3656 | }
|
- | |
3657 | fragment.appendChild( ret[i] ); |
2913 | jQuery.event.remove( this, type, fn ); |
3658 | }
|
2914 | }); |
3659 | }
|
- | |
3660 | }
|
2915 | }, |
3661 | 2916 | ||
- | 2917 | trigger: function( type, data ) { |
|
3662 | return ret; |
2918 | return this.each(function(){ |
- | 2919 | jQuery.event.trigger( type, data, this ); |
|
3663 | }
|
2920 | }); |
3664 | }); |
2921 | }, |
3665 | 2922 | ||
3666 | function cleanData( elems ) { |
2923 | triggerHandler: function( type, data ) { |
3667 | for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) { |
- | |
3668 | if ( (id = elem[expando]) ) { |
2924 | if( this[0] ){ |
3669 | delete jQuery.cache[ id ]; |
2925 | var event = jQuery.Event(type); |
3670 | }
|
- | |
3671 | }
|
- | |
3672 | }
|
- | |
3673 | // exclude the following css properties to add px
|
- | |
3674 | var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
- | |
3675 | ralpha = /alpha\([^)]*\)/, |
2926 | event.preventDefault(); |
3676 | ropacity = /opacity=([^)]*)/, |
2927 | event.stopPropagation(); |
3677 | rfloat = /float/i, |
- | |
3678 | rdashAlpha = /-([a-z])/ig, |
2928 | jQuery.event.trigger( event, data, this[0] ); |
3679 | rupper = /([A-Z])/g, |
2929 | return event.result; |
3680 | rnumpx = /^\d+(?:px)?$/i, |
- | |
3681 | rnum = /^\d/, |
- | |
3682 | 2930 | }
|
|
3683 | // cache check for defaultView.getComputedStyle
|
- | |
3684 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
- | |
3685 | // normalize float css property
|
- | |
3686 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
- | |
3687 | fcamelCase = function(all, letter){ |
- | |
3688 | return letter.toUpperCase(); |
- | |
3689 | }; |
2931 | }, |
3690 | 2932 | ||
3691 | jQuery.fn.css = function( name, value ) { |
2933 | toggle: function( fn ) { |
3692 | return access( this, name, value, true, function( elem, name, value ) { |
2934 | // Save reference to arguments for access in closure
|
3693 | if (value === undefined) { |
- | |
3694 | return jQuery.css( elem, name ); |
2935 | var args = arguments, i = 1; |
3695 | }
|
- | |
3696 | - | ||
3697 | if ( typeof value === "number" && !rexclude.test(name) ) { |
- | |
3698 | value += "px"; |
- | |
3699 | }
|
- | |
3700 | 2936 | ||
- | 2937 | // link all the functions, so any of them can unbind this click handler
|
|
- | 2938 | while( i < args.length ) |
|
3701 | jQuery.style( elem, name, value ); |
2939 | jQuery.event.proxy( fn, args[i++] ); |
3702 | }); |
- | |
3703 | }; |
- | |
3704 | 2940 | ||
3705 | jQuery.extend({ |
- | |
3706 | style: function( elem, name, value ) { |
2941 | return this.click( jQuery.event.proxy( fn, function(event) { |
3707 | // don't set styles on text and comment nodes
|
2942 | // Figure out which function to execute
|
3708 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
2943 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
3709 | return undefined; |
- | |
3710 | }
|
- | |
3711 | 2944 | ||
3712 | // ignore negative width and height values #1599
|
2945 | // Make sure that clicks stop
|
3713 | if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
- | |
3714 | value = undefined; |
2946 | event.preventDefault(); |
3715 | }
|
- | |
3716 | 2947 | ||
- | 2948 | // and execute the function
|
|
3717 | var style = elem.style || elem, set = value !== undefined; |
2949 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
- | 2950 | })); |
|
- | 2951 | }, |
|
3718 | 2952 | ||
3719 | // IE uses filters for opacity
|
2953 | hover: function(fnOver, fnOut) { |
3720 | if ( !jQuery.support.opacity && name === "opacity" ) { |
2954 | return this.mouseenter(fnOver).mouseleave(fnOut); |
3721 | if ( set ) { |
2955 | }, |
3722 | // IE has trouble with opacity if it does not have layout
|
- | |
3723 | // Force it by setting the zoom level
|
- | |
3724 | style.zoom = 1; |
- | |
3725 | 2956 | ||
3726 | // Set the alpha filter to set the opacity
|
2957 | ready: function(fn) { |
3727 | style.filter = (style.filter || "").replace( ralpha, "" ) + |
2958 | // Attach the listeners
|
3728 | (parseInt( value ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
- | |
3729 | }
|
2959 | bindReady(); |
3730 | 2960 | ||
3731 | return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
2961 | // If the DOM is already ready
|
- | 2962 | if ( jQuery.isReady ) |
|
3732 | (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '': |
2963 | // Execute the function immediately
|
3733 | ""; |
2964 | fn.call( document, jQuery ); |
3734 | }
|
- | |
3735 | 2965 | ||
3736 | // Make sure we're using the right name for getting the float value
|
2966 | // Otherwise, remember the function for later
|
- | 2967 | else
|
|
3737 | if ( rfloat.test( name ) ) { |
2968 | // Add the function to the wait list
|
3738 | name = styleFloat; |
2969 | jQuery.readyList.push( fn ); |
3739 | }
|
- | |
3740 | 2970 | ||
- | 2971 | return this; |
|
- | 2972 | }, |
|
- | 2973 | ||
- | 2974 | live: function( type, fn ){ |
|
3741 | name = name.replace(rdashAlpha, fcamelCase); |
2975 | var proxy = jQuery.event.proxy( fn ); |
- | 2976 | proxy.guid += this.selector + type; |
|
3742 | 2977 | ||
3743 | if ( set ) { |
- | |
3744 | style[ name ] = value; |
2978 | jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy ); |
3745 | }
|
- | |
3746 | 2979 | ||
3747 | return style[ name ]; |
2980 | return this; |
3748 | }, |
2981 | }, |
- | 2982 | ||
- | 2983 | die: function( type, fn ){ |
|
- | 2984 | jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null ); |
|
- | 2985 | return this; |
|
- | 2986 | }
|
|
- | 2987 | }); |
|
3749 | 2988 | ||
3750 | css: function( elem, name, force, extra ) { |
2989 | function liveHandler( event ){ |
3751 | if ( name === "width" || name === "height" ) { |
2990 | var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"), |
- | 2991 | stop = true, |
|
- | 2992 | elems = []; |
|
- | 2993 | ||
3752 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
2994 | jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){ |
- | 2995 | if ( check.test(fn.type) ) { |
|
- | 2996 | var elem = jQuery(event.target).closest(fn.data)[0]; |
|
- | 2997 | if ( elem ) |
|
- | 2998 | elems.push({ elem: elem, fn: fn }); |
|
- | 2999 | }
|
|
- | 3000 | }); |
|
3753 | 3001 | ||
3754 | function getWH() { |
3002 | elems.sort(function(a,b) { |
3755 | val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
3003 | return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest"); |
- | 3004 | }); |
|
- | 3005 | ||
- | 3006 | jQuery.each(elems, function(){ |
|
- | 3007 | if ( this.fn.call(this.elem, event, this.fn.data) === false ) |
|
- | 3008 | return (stop = false); |
|
- | 3009 | }); |
|
3756 | 3010 | ||
3757 | if ( extra === "border" ) { return; } |
3011 | return stop; |
- | 3012 | }
|
|
3758 | 3013 | ||
3759 | jQuery.each( which, function() { |
3014 | function liveConvert(type, selector){ |
3760 | if ( !extra ) { |
- | |
3761 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
3015 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
3762 | }
|
3016 | }
|
3763 | 3017 | ||
- | 3018 | jQuery.extend({ |
|
- | 3019 | isReady: false, |
|
- | 3020 | readyList: [], |
|
- | 3021 | // Handle when the DOM is ready
|
|
- | 3022 | ready: function() { |
|
- | 3023 | // Make sure that the DOM is not already loaded
|
|
3764 | if ( extra === "margin" ) { |
3024 | if ( !jQuery.isReady ) { |
- | 3025 | // Remember that the DOM is ready
|
|
- | 3026 | jQuery.isReady = true; |
|
- | 3027 | ||
3765 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
3028 | // If there are functions bound, to execute
|
- | 3029 | if ( jQuery.readyList ) { |
|
3766 | } else { |
3030 | // Execute all of them
|
3767 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
3031 | jQuery.each( jQuery.readyList, function(){ |
3768 | }
|
3032 | this.call( document, jQuery ); |
3769 | }); |
3033 | }); |
3770 | }
|
- | |
3771 | 3034 | ||
3772 | if ( elem.offsetWidth !== 0 ) { |
3035 | // Reset the list of functions
|
3773 | getWH(); |
- | |
3774 | } else { |
- | |
3775 | jQuery.swap( elem, props, getWH ); |
3036 | jQuery.readyList = null; |
3776 | }
|
3037 | }
|
3777 | 3038 | ||
- | 3039 | // Trigger any bound ready events
|
|
3778 | return Math.max(0, Math.round(val)); |
3040 | jQuery(document).triggerHandler("ready"); |
3779 | }
|
3041 | }
|
- | 3042 | }
|
|
- | 3043 | }); |
|
3780 | 3044 | ||
3781 | return jQuery.curCSS( elem, name, force ); |
3045 | var readyBound = false; |
3782 | }, |
- | |
3783 | 3046 | ||
3784 | curCSS: function( elem, name, force ) { |
3047 | function bindReady(){ |
3785 | var ret, style = elem.style, filter; |
3048 | if ( readyBound ) return; |
- | 3049 | readyBound = true; |
|
3786 | 3050 | ||
- | 3051 | // Mozilla, Opera and webkit nightlies currently support this event
|
|
- | 3052 | if ( document.addEventListener ) { |
|
3787 | // IE uses filters for opacity
|
3053 | // Use the handy event callback
|
3788 | if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
3054 | document.addEventListener( "DOMContentLoaded", function(){ |
3789 | ret = ropacity.test(elem.currentStyle.filter || "") ? |
3055 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
3790 | (parseFloat(RegExp.$1) / 100) + "" : |
3056 | jQuery.ready(); |
3791 | ""; |
3057 | }, false ); |
3792 | 3058 | ||
3793 | return ret === "" ? |
3059 | // If IE event model is used
|
- | 3060 | } else if ( document.attachEvent ) { |
|
- | 3061 | // ensure firing before onload,
|
|
- | 3062 | // maybe late but safe also for iframes
|
|
- | 3063 | document.attachEvent("onreadystatechange", function(){ |
|
- | 3064 | if ( document.readyState === "complete" ) { |
|
- | 3065 | document.detachEvent( "onreadystatechange", arguments.callee ); |
|
3794 | "1" : |
3066 | jQuery.ready(); |
3795 | ret;
|
3067 | }
|
3796 | }
|
3068 | }); |
3797 | 3069 | ||
- | 3070 | // If IE and not an iframe
|
|
3798 | // Make sure we're using the right name for getting the float value
|
3071 | // continually check to see if the document is ready
|
3799 | if ( rfloat.test( name ) ) { |
3072 | if ( document.documentElement.doScroll && window == window.top ) (function(){ |
3800 | name = styleFloat; |
3073 | if ( jQuery.isReady ) return; |
3801 | }
|
- | |
3802 | 3074 | ||
- | 3075 | try { |
|
3803 | if ( !force && style && style[ name ] ) { |
3076 | // If IE is used, use the trick by Diego Perini
|
- | 3077 | // http://javascript.nwbox.com/IEContentLoaded/
|
|
- | 3078 | document.documentElement.doScroll("left"); |
|
3804 | ret = style[ name ]; |
3079 | } catch( error ) { |
- | 3080 | setTimeout( arguments.callee, 0 ); |
|
- | 3081 | return; |
|
- | 3082 | }
|
|
3805 | 3083 | ||
3806 | } else if ( getComputedStyle ) { |
3084 | // and execute any waiting functions
|
- | 3085 | jQuery.ready(); |
|
- | 3086 | })(); |
|
- | 3087 | }
|
|
3807 | 3088 | ||
3808 | // Only "float" is needed here
|
3089 | // A fallback to window.onload, that will always work
|
3809 | if ( rfloat.test( name ) ) { |
3090 | jQuery.event.add( window, "load", jQuery.ready ); |
3810 | name = "float"; |
- | |
3811 | }
|
3091 | }
|
3812 | 3092 | ||
- | 3093 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
|
3813 | name = name.replace( rupper, "-$1" ).toLowerCase(); |
3094 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
- | 3095 | "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){ |
|
3814 | 3096 | ||
- | 3097 | // Handle event binding
|
|
- | 3098 | jQuery.fn[name] = function(fn){ |
|
3815 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3099 | return fn ? this.bind(name, fn) : this.trigger(name); |
- | 3100 | }; |
|
- | 3101 | }); |
|
3816 | 3102 | ||
- | 3103 | // Prevent memory leaks in IE
|
|
- | 3104 | // And prevent errors on refresh with events like mouseover in other browsers
|
|
- | 3105 | // Window isn't included so as not to unbind existing unload events
|
|
- | 3106 | jQuery( window ).bind( 'unload', function(){ |
|
- | 3107 | for ( var id in jQuery.cache ) |
|
3817 | if ( computedStyle ) { |
3108 | // Skip the window
|
- | 3109 | if ( id != 1 && jQuery.cache[ id ].handle ) |
|
3818 | ret = computedStyle.getPropertyValue( name ); |
3110 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
3819 | }
|
3111 | }); |
- | 3112 | (function(){ |
|
3820 | 3113 | ||
3821 | // We should always get a number back from opacity
|
- | |
3822 | if ( name === "opacity" && ret === "" ) { |
- | |
3823 | ret = "1"; |
3114 | jQuery.support = {}; |
3824 | }
|
- | |
3825 | 3115 | ||
3826 | } else if ( elem.currentStyle ) { |
3116 | var root = document.documentElement, |
3827 | var camelCase = name.replace(rdashAlpha, fcamelCase); |
3117 | script = document.createElement("script"), |
- | 3118 | div = document.createElement("div"), |
|
- | 3119 | id = "script" + (new Date).getTime(); |
|
3828 | 3120 | ||
- | 3121 | div.style.display = "none"; |
|
3829 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
3122 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>'; |
3830 | 3123 | ||
3831 | // From the awesome hack by Dean Edwards
|
3124 | var all = div.getElementsByTagName("*"), |
3832 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
3125 | a = div.getElementsByTagName("a")[0]; |
3833 | 3126 | ||
3834 | // If we're not dealing with a regular pixel number
|
3127 | // Can't get basic test support
|
3835 | // but a number that has a weird ending, we need to convert it to pixels
|
- | |
3836 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
3128 | if ( !all || !all.length || !a ) { |
3837 | // Remember the original values
|
3129 | return; |
3838 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
- | |
- | 3130 | }
|
|
3839 | 3131 | ||
- | 3132 | jQuery.support = { |
|
- | 3133 | // IE strips leading whitespace when .innerHTML is used
|
|
- | 3134 | leadingWhitespace: div.firstChild.nodeType == 3, |
|
- | 3135 | ||
- | 3136 | // Make sure that tbody elements aren't automatically inserted
|
|
- | 3137 | // IE will insert them into empty tables
|
|
- | 3138 | tbody: !div.getElementsByTagName("tbody").length, |
|
- | 3139 | ||
- | 3140 | // Make sure that you can get all elements in an <object> element
|
|
- | 3141 | // IE 7 always returns no results
|
|
- | 3142 | objectAll: !!div.getElementsByTagName("object")[0] |
|
- | 3143 | .getElementsByTagName("*").length, |
|
- | 3144 | ||
- | 3145 | // Make sure that link elements get serialized correctly by innerHTML
|
|
- | 3146 | // This requires a wrapper element in IE
|
|
- | 3147 | htmlSerialize: !!div.getElementsByTagName("link").length, |
|
- | 3148 | ||
3840 | // Put in the new values to get a computed value out
|
3149 | // Get the style information from getAttribute
|
- | 3150 | // (IE uses .cssText insted)
|
|
3841 | elem.runtimeStyle.left = elem.currentStyle.left; |
3151 | style: /red/.test( a.getAttribute("style") ), |
- | 3152 | ||
- | 3153 | // Make sure that URLs aren't manipulated
|
|
- | 3154 | // (IE normalizes it by default)
|
|
- | 3155 | hrefNormalized: a.getAttribute("href") === "/a", |
|
- | 3156 | ||
- | 3157 | // Make sure that element opacity exists
|
|
3842 | style.left = ret || 0; |
3158 | // (IE uses filter instead)
|
3843 | ret = style.pixelLeft + "px"; |
3159 | opacity: a.style.opacity === "0.5", |
- | 3160 | ||
- | 3161 | // Verify style float existence
|
|
- | 3162 | // (IE uses styleFloat instead of cssFloat)
|
|
- | 3163 | cssFloat: !!a.style.cssFloat, |
|
3844 | 3164 | ||
3845 | // Revert the changed values
|
3165 | // Will be defined later
|
3846 | style.left = left; |
3166 | scriptEval: false, |
3847 | elem.runtimeStyle.left = rsLeft; |
3167 | noCloneEvent: true, |
- | 3168 | boxModel: null |
|
3848 | }
|
3169 | }; |
- | 3170 | ||
- | 3171 | script.type = "text/javascript"; |
|
3849 | }
|
3172 | try { |
- | 3173 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
|
- | 3174 | } catch(e){} |
|
3850 | 3175 | ||
- | 3176 | root.insertBefore( script, root.firstChild ); |
|
- | 3177 | ||
- | 3178 | // Make sure that the execution of code works by injecting a script
|
|
- | 3179 | // tag with appendChild/createTextNode
|
|
- | 3180 | // (IE doesn't support this, fails, and uses .text instead)
|
|
- | 3181 | if ( window[ id ] ) { |
|
- | 3182 | jQuery.support.scriptEval = true; |
|
3851 | return ret; |
3183 | delete window[ id ]; |
3852 | }, |
3184 | }
|
3853 | 3185 | ||
3854 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
- | |
3855 | swap: function( elem, options, callback ) { |
- | |
3856 | var old = {}; |
3186 | root.removeChild( script ); |
3857 | 3187 | ||
- | 3188 | if ( div.attachEvent && div.fireEvent ) { |
|
- | 3189 | div.attachEvent("onclick", function(){ |
|
3858 | // Remember the old values, and insert the new ones
|
3190 | // Cloning a node shouldn't copy over any
|
3859 | for ( var name in options ) { |
3191 | // bound event handlers (IE does this)
|
3860 | old[ name ] = elem.style[ name ]; |
3192 | jQuery.support.noCloneEvent = false; |
3861 | elem.style[ name ] = options[ name ]; |
3193 | div.detachEvent("onclick", arguments.callee); |
- | 3194 | }); |
|
- | 3195 | div.cloneNode(true).fireEvent("onclick"); |
|
3862 | }
|
3196 | }
|
3863 | 3197 | ||
- | 3198 | // Figure out if the W3C box model works as expected
|
|
- | 3199 | // document.body must exist before we can do this
|
|
- | 3200 | jQuery(function(){ |
|
3864 | callback.call( elem ); |
3201 | var div = document.createElement("div"); |
- | 3202 | div.style.width = div.style.paddingLeft = "1px"; |
|
3865 | 3203 | ||
3866 | // Revert the old values
|
3204 | document.body.appendChild( div ); |
3867 | for ( var name in options ) { |
3205 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3868 | elem.style[ name ] = old[ name ]; |
3206 | document.body.removeChild( div ).style.display = 'none'; |
3869 | }
|
3207 | }); |
3870 | }
|
3208 | })(); |
3871 | }); |
3209 | |
3872 | var jsc = now(), |
- | |
3873 | rscript = /<script(.|\s)*?\/script>/g, |
- | |
3874 | rselectTextarea = /select|textarea/i, |
3210 | var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
3875 | rinput = /text|hidden|password|search/i, |
- | |
3876 | jsre = /=\?(&|$)/, |
- | |
3877 | rquery = /\?/, |
- | |
3878 | rts = /(\?|&)_=.*?(&|$)/, |
- | |
3879 | rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
- | |
3880 | r20 = /%20/g; |
- | |
3881 | 3211 | ||
- | 3212 | jQuery.props = { |
|
- | 3213 | "for": "htmlFor", |
|
- | 3214 | "class": "className", |
|
- | 3215 | "float": styleFloat, |
|
- | 3216 | cssFloat: styleFloat, |
|
- | 3217 | styleFloat: styleFloat, |
|
- | 3218 | readonly: "readOnly", |
|
- | 3219 | maxlength: "maxLength", |
|
- | 3220 | cellspacing: "cellSpacing", |
|
- | 3221 | rowspan: "rowSpan", |
|
- | 3222 | tabindex: "tabIndex" |
|
- | 3223 | }; |
|
3882 | jQuery.fn.extend({ |
3224 | jQuery.fn.extend({ |
3883 | // Keep a copy of the old load
|
3225 | // Keep a copy of the old load
|
3884 | _load: jQuery.fn.load, |
3226 | _load: jQuery.fn.load, |
3885 | 3227 | ||
3886 | load: function( url, params, callback ) { |
3228 | load: function( url, params, callback ) { |
3887 | if ( typeof url !== "string" ) { |
3229 | if ( typeof url !== "string" ) |
3888 | return this._load( url ); |
3230 | return this._load( url ); |
3889 | }
|
- | |
3890 | 3231 | ||
3891 | var off = url.indexOf(" "); |
3232 | var off = url.indexOf(" "); |
3892 | if ( off >= 0 ) { |
3233 | if ( off >= 0 ) { |
3893 | var selector = url.slice(off, url.length); |
3234 | var selector = url.slice(off, url.length); |
3894 | url = url.slice(0, off); |
3235 | url = url.slice(0, off); |
Строка 3896... | Строка 3237... | ||
3896 | 3237 | ||
3897 | // Default to a GET request
|
3238 | // Default to a GET request
|
3898 | var type = "GET"; |
3239 | var type = "GET"; |
3899 | 3240 | ||
3900 | // If the second parameter was provided
|
3241 | // If the second parameter was provided
|
3901 | if ( params ) { |
3242 | if ( params ) |
3902 | // If it's a function
|
3243 | // If it's a function
|
3903 | if ( jQuery.isFunction( params ) ) { |
3244 | if ( jQuery.isFunction( params ) ) { |
3904 | // We assume that it's the callback
|
3245 | // We assume that it's the callback
|
3905 | callback = params; |
3246 | callback = params; |
3906 | params = null; |
3247 | params = null; |
3907 | 3248 | ||
3908 | // Otherwise, build a param string
|
3249 | // Otherwise, build a param string
|
3909 | } else if ( typeof params === "object" ) { |
3250 | } else if( typeof params === "object" ) { |
3910 | params = jQuery.param( params ); |
3251 | params = jQuery.param( params ); |
3911 | type = "POST"; |
3252 | type = "POST"; |
3912 | }
|
3253 | }
|
3913 | }
|
3254 | |
- | 3255 | var self = this; |
|
3914 | 3256 | ||
3915 | // Request the remote document
|
3257 | // Request the remote document
|
3916 | jQuery.ajax({ |
3258 | jQuery.ajax({ |
3917 | url: url, |
3259 | url: url, |
3918 | type: type, |
3260 | type: type, |
3919 | dataType: "html", |
3261 | dataType: "html", |
3920 | data: params, |
3262 | data: params, |
3921 | context:this, |
- | |
3922 | complete: function(res, status){ |
3263 | complete: function(res, status){ |
3923 | // If successful, inject the HTML into all the matched elements
|
3264 | // If successful, inject the HTML into all the matched elements
|
3924 | if ( status === "success" || status === "notmodified" ) { |
3265 | if ( status == "success" || status == "notmodified" ) |
3925 | // See if a selector was specified
|
3266 | // See if a selector was specified
|
3926 | this.html( selector ? |
3267 | self.html( selector ? |
3927 | // Create a dummy div to hold the results
|
3268 | // Create a dummy div to hold the results
|
3928 | jQuery("<div />") |
3269 | jQuery("<div/>") |
3929 | // inject the contents of the document in, removing the scripts
|
3270 | // inject the contents of the document in, removing the scripts
|
3930 | // to avoid any 'Permission Denied' errors in IE
|
3271 | // to avoid any 'Permission Denied' errors in IE
|
3931 | .append(res.responseText.replace(rscript, "")) |
3272 | .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) |
3932 | 3273 | ||
3933 | // Locate the specified elements
|
3274 | // Locate the specified elements
|
3934 | .find(selector) : |
3275 | .find(selector) : |
3935 | 3276 | ||
3936 | // If not, just inject the full result
|
3277 | // If not, just inject the full result
|
3937 | res.responseText ); |
3278 | res.responseText ); |
3938 | }
|
- | |
3939 | 3279 | ||
3940 | if ( callback ) { |
3280 | if( callback ) |
3941 | this.each( callback, [res.responseText, status, res] ); |
3281 | self.each( callback, [res.responseText, status, res] ); |
3942 | }
|
- | |
3943 | }
|
3282 | }
|
3944 | }); |
3283 | }); |
3945 | - | ||
3946 | return this; |
3284 | return this; |
3947 | }, |
3285 | }, |
3948 | 3286 | ||
3949 | serialize: function() { |
3287 | serialize: function() { |
3950 | return jQuery.param(this.serializeArray()); |
3288 | return jQuery.param(this.serializeArray()); |
Строка 3953... | Строка 3291... | ||
3953 | return this.map(function(){ |
3291 | return this.map(function(){ |
3954 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3292 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3955 | }) |
3293 | }) |
3956 | .filter(function(){ |
3294 | .filter(function(){ |
3957 | return this.name && !this.disabled && |
3295 | return this.name && !this.disabled && |
3958 | (this.checked || rselectTextarea.test(this.nodeName) || |
3296 | (this.checked || /select|textarea/i.test(this.nodeName) || |
3959 | rinput.test(this.type)); |
3297 | /text|hidden|password|search/i.test(this.type)); |
3960 | }) |
3298 | }) |
3961 | .map(function(i, elem){ |
3299 | .map(function(i, elem){ |
3962 | var val = jQuery(this).val(); |
3300 | var val = jQuery(this).val(); |
3963 | - | ||
3964 | return val == null ? |
3301 | return val == null ? null : |
3965 | null : |
- | |
3966 | jQuery.isArray(val) ? |
3302 | jQuery.isArray(val) ? |
3967 | jQuery.map( val, function(val, i){ |
3303 | jQuery.map( val, function(val, i){ |
3968 | return {name: elem.name, value: val}; |
3304 | return {name: elem.name, value: val}; |
3969 | }) : |
3305 | }) : |
3970 | {name: elem.name, value: val}; |
3306 | {name: elem.name, value: val}; |
Строка 3977... | Строка 3313... | ||
3977 | jQuery.fn[o] = function(f){ |
3313 | jQuery.fn[o] = function(f){ |
3978 | return this.bind(o, f); |
3314 | return this.bind(o, f); |
3979 | }; |
3315 | }; |
3980 | }); |
3316 | }); |
3981 | 3317 | ||
3982 | jQuery.extend({ |
3318 | var jsc = now(); |
3983 | 3319 | ||
- | 3320 | jQuery.extend({ |
|
- | 3321 | ||
3984 | get: function( url, data, callback, type ) { |
3322 | get: function( url, data, callback, type ) { |
3985 | // shift arguments if data argument was omited
|
3323 | // shift arguments if data argument was ommited
|
3986 | if ( jQuery.isFunction( data ) ) { |
3324 | if ( jQuery.isFunction( data ) ) { |
3987 | type = type || callback; |
- | |
3988 | callback = data; |
3325 | callback = data; |
3989 | data = null; |
3326 | data = null; |
3990 | }
|
3327 | }
|
3991 | 3328 | ||
3992 | return jQuery.ajax({ |
3329 | return jQuery.ajax({ |
Строка 4005... | Строка 3342... | ||
4005 | getJSON: function( url, data, callback ) { |
3342 | getJSON: function( url, data, callback ) { |
4006 | return jQuery.get(url, data, callback, "json"); |
3343 | return jQuery.get(url, data, callback, "json"); |
4007 | }, |
3344 | }, |
4008 | 3345 | ||
4009 | post: function( url, data, callback, type ) { |
3346 | post: function( url, data, callback, type ) { |
4010 | // shift arguments if data argument was omited
|
- | |
4011 | if ( jQuery.isFunction( data ) ) { |
3347 | if ( jQuery.isFunction( data ) ) { |
4012 | type = type || callback; |
- | |
4013 | callback = data; |
3348 | callback = data; |
4014 | data = {}; |
3349 | data = {}; |
4015 | }
|
3350 | }
|
4016 | 3351 | ||
4017 | return jQuery.ajax({ |
3352 | return jQuery.ajax({ |
Строка 4041... | Строка 3376... | ||
4041 | password: null,
|
3376 | password: null,
|
4042 | */
|
3377 | */
|
4043 | // Create the request object; Microsoft failed to properly
|
3378 | // Create the request object; Microsoft failed to properly
|
4044 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
3379 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
4045 | // This function can be overriden by calling jQuery.ajaxSetup
|
3380 | // This function can be overriden by calling jQuery.ajaxSetup
|
4046 | xhr: function(){ |
3381 | xhr:function(){ |
4047 | return window.ActiveXObject ? |
- | |
4048 | new ActiveXObject("Microsoft.XMLHTTP") : |
3382 | return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); |
4049 | new XMLHttpRequest(); |
- | |
4050 | }, |
3383 | }, |
4051 | accepts: { |
3384 | accepts: { |
4052 | xml: "application/xml, text/xml", |
3385 | xml: "application/xml, text/xml", |
4053 | html: "text/html", |
3386 | html: "text/html", |
4054 | script: "text/javascript, application/javascript", |
3387 | script: "text/javascript, application/javascript", |
Строка 4058... | Строка 3391... | ||
4058 | }
|
3391 | }
|
4059 | }, |
3392 | }, |
4060 | 3393 | ||
4061 | // Last-Modified header cache for next request
|
3394 | // Last-Modified header cache for next request
|
4062 | lastModified: {}, |
3395 | lastModified: {}, |
4063 | etag: {}, |
- | |
4064 | 3396 | ||
4065 | ajax: function( s ) { |
3397 | ajax: function( s ) { |
4066 | // Extend the settings, but re-extend 's' so that it can be
|
3398 | // Extend the settings, but re-extend 's' so that it can be
|
4067 | // checked again later (in the test suite, specifically)
|
3399 | // checked again later (in the test suite, specifically)
|
4068 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3400 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
4069 | 3401 | ||
4070 | var jsonp, status, data, |
3402 | var jsonp, jsre = /=\?(&|$)/g, status, data, |
4071 | callbackContext = s.context || window, |
- | |
4072 | type = s.type.toUpperCase(); |
3403 | type = s.type.toUpperCase(); |
4073 | 3404 | ||
4074 | // convert data if not already a string
|
3405 | // convert data if not already a string
|
4075 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
3406 | if ( s.data && s.processData && typeof s.data !== "string" ) |
4076 | s.data = jQuery.param(s.data); |
3407 | s.data = jQuery.param(s.data); |
4077 | }
|
- | |
4078 | 3408 | ||
4079 | // Handle JSONP Parameter Callbacks
|
3409 | // Handle JSONP Parameter Callbacks
|
4080 | if ( s.dataType === "jsonp" ) { |
3410 | if ( s.dataType == "jsonp" ) { |
4081 | if ( type === "GET" ) { |
3411 | if ( type == "GET" ) { |
4082 | if ( !jsre.test( s.url ) ) { |
3412 | if ( !s.url.match(jsre) ) |
4083 | s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
3413 | s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
4084 | }
|
- | |
4085 | } else if ( !s.data || !jsre.test(s.data) ) { |
3414 | } else if ( !s.data || !s.data.match(jsre) ) |
4086 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
3415 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
4087 | }
|
- | |
4088 | s.dataType = "json"; |
3416 | s.dataType = "json"; |
4089 | }
|
3417 | }
|
4090 | 3418 | ||
4091 | // Build temporary JSONP function
|
3419 | // Build temporary JSONP function
|
4092 | if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
3420 | if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { |
4093 | jsonp = "jsonp" + jsc++; |
3421 | jsonp = "jsonp" + jsc++; |
4094 | 3422 | ||
4095 | // Replace the =? sequence both in the query string and the data
|
3423 | // Replace the =? sequence both in the query string and the data
|
4096 | if ( s.data ) { |
3424 | if ( s.data ) |
4097 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
3425 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
4098 | }
|
- | |
4099 | - | ||
4100 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
3426 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
4101 | 3427 | ||
4102 | // We need to make sure
|
3428 | // We need to make sure
|
4103 | // that a JSONP style response is executed properly
|
3429 | // that a JSONP style response is executed properly
|
4104 | s.dataType = "script"; |
3430 | s.dataType = "script"; |
Строка 4109... | Строка 3435... | ||
4109 | success(); |
3435 | success(); |
4110 | complete(); |
3436 | complete(); |
4111 | // Garbage collect
|
3437 | // Garbage collect
|
4112 | window[ jsonp ] = undefined; |
3438 | window[ jsonp ] = undefined; |
4113 | try{ delete window[ jsonp ]; } catch(e){} |
3439 | try{ delete window[ jsonp ]; } catch(e){} |
4114 | if ( head ) { |
3440 | if ( head ) |
4115 | head.removeChild( script ); |
3441 | head.removeChild( script ); |
4116 | }
|
- | |
4117 | }; |
3442 | }; |
4118 | }
|
3443 | }
|
4119 | 3444 | ||
4120 | if ( s.dataType === "script" && s.cache === null ) { |
3445 | if ( s.dataType == "script" && s.cache == null ) |
4121 | s.cache = false; |
3446 | s.cache = false; |
4122 | }
|
- | |
4123 | 3447 | ||
4124 | if ( s.cache === false && type === "GET" ) { |
3448 | if ( s.cache === false && type == "GET" ) { |
4125 | var ts = now(); |
3449 | var ts = now(); |
4126 | - | ||
4127 | // try replacing _= if it is there
|
3450 | // try replacing _= if it is there
|
4128 | var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
3451 | var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); |
4129 | - | ||
4130 | // if nothing was replaced, add timestamp to the end
|
3452 | // if nothing was replaced, add timestamp to the end
|
4131 | s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
3453 | s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); |
4132 | }
|
3454 | }
|
4133 | 3455 | ||
4134 | // If data is available, append data to url for get requests
|
3456 | // If data is available, append data to url for get requests
|
4135 | if ( s.data && type === "GET" ) { |
3457 | if ( s.data && type == "GET" ) { |
4136 | s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
3458 | s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; |
- | 3459 | ||
- | 3460 | // IE likes to send both get and post data, prevent this
|
|
- | 3461 | s.data = null; |
|
4137 | }
|
3462 | }
|
4138 | 3463 | ||
4139 | // Watch for a new set of requests
|
3464 | // Watch for a new set of requests
|
4140 | if ( s.global && ! jQuery.active++ ) { |
3465 | if ( s.global && ! jQuery.active++ ) |
4141 | jQuery.event.trigger( "ajaxStart" ); |
3466 | jQuery.event.trigger( "ajaxStart" ); |
4142 | }
|
- | |
4143 | 3467 | ||
4144 | // Matches an absolute URL, and saves the domain
|
3468 | // Matches an absolute URL, and saves the domain
|
4145 | var parts = rurl.exec( s.url ); |
3469 | var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url ); |
4146 | 3470 | ||
4147 | // If we're requesting a remote document
|
3471 | // If we're requesting a remote document
|
4148 | // and trying to load JSON or Script with a GET
|
3472 | // and trying to load JSON or Script with a GET
|
4149 | if ( s.dataType === "script" && type === "GET" && parts |
3473 | if ( s.dataType == "script" && type == "GET" && parts |
4150 | && ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
3474 | && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){ |
4151 | 3475 | ||
4152 | var head = document.getElementsByTagName("head")[0] || document.documentElement; |
3476 | var head = document.getElementsByTagName("head")[0]; |
4153 | var script = document.createElement("script"); |
3477 | var script = document.createElement("script"); |
4154 | script.src = s.url; |
3478 | script.src = s.url; |
4155 | if ( s.scriptCharset ) { |
3479 | if (s.scriptCharset) |
4156 | script.charset = s.scriptCharset; |
3480 | script.charset = s.scriptCharset; |
4157 | }
|
- | |
4158 | 3481 | ||
4159 | // Handle Script loading
|
3482 | // Handle Script loading
|
4160 | if ( !jsonp ) { |
3483 | if ( !jsonp ) { |
4161 | var done = false; |
3484 | var done = false; |
4162 | 3485 | ||
4163 | // Attach handlers for all browsers
|
3486 | // Attach handlers for all browsers
|
4164 | script.onload = script.onreadystatechange = function(){ |
3487 | script.onload = script.onreadystatechange = function(){ |
4165 | if ( !done && (!this.readyState || |
3488 | if ( !done && (!this.readyState || |
4166 | this.readyState === "loaded" || this.readyState === "complete") ) { |
3489 | this.readyState == "loaded" || this.readyState == "complete") ) { |
4167 | done = true; |
3490 | done = true; |
4168 | success(); |
3491 | success(); |
4169 | complete(); |
3492 | complete(); |
4170 | 3493 | ||
4171 | // Handle memory leak in IE
|
3494 | // Handle memory leak in IE
|
4172 | script.onload = script.onreadystatechange = null; |
3495 | script.onload = script.onreadystatechange = null; |
4173 | if ( head && script.parentNode ) { |
- | |
4174 | head.removeChild( script ); |
3496 | head.removeChild( script ); |
4175 | }
|
- | |
4176 | }
|
3497 | }
|
4177 | }; |
3498 | }; |
4178 | }
|
3499 | }
|
4179 | 3500 | ||
4180 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
- | |
4181 | // This arises when a base node is used (#2709 and #4378).
|
- | |
4182 | head.insertBefore( script, head.firstChild ); |
3501 | head.appendChild(script); |
4183 | 3502 | ||
4184 | // We handle everything using the script element injection
|
3503 | // We handle everything using the script element injection
|
4185 | return undefined; |
3504 | return undefined; |
4186 | }
|
3505 | }
|
4187 | 3506 | ||
Строка 4190... | Строка 3509... | ||
4190 | // Create the request object
|
3509 | // Create the request object
|
4191 | var xhr = s.xhr(); |
3510 | var xhr = s.xhr(); |
4192 | 3511 | ||
4193 | // Open the socket
|
3512 | // Open the socket
|
4194 | // Passing null username, generates a login popup on Opera (#2865)
|
3513 | // Passing null username, generates a login popup on Opera (#2865)
|
4195 | if ( s.username ) { |
3514 | if( s.username ) |
4196 | xhr.open(type, s.url, s.async, s.username, s.password); |
3515 | xhr.open(type, s.url, s.async, s.username, s.password); |
4197 | } else { |
3516 | else
|
4198 | xhr.open(type, s.url, s.async); |
3517 | xhr.open(type, s.url, s.async); |
4199 | }
|
- | |
4200 | 3518 | ||
4201 | // Need an extra try/catch for cross domain requests in Firefox 3
|
3519 | // Need an extra try/catch for cross domain requests in Firefox 3
|
4202 | try { |
3520 | try { |
4203 | // Set the correct header, if data is being sent
|
3521 | // Set the correct header, if data is being sent
|
4204 | if ( s.data ) { |
3522 | if ( s.data ) |
4205 | xhr.setRequestHeader("Content-Type", s.contentType); |
3523 | xhr.setRequestHeader("Content-Type", s.contentType); |
4206 | }
|
- | |
4207 | - | ||
4208 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
- | |
4209 | if ( s.ifModified ) { |
- | |
4210 | if ( jQuery.lastModified[s.url] ) { |
- | |
4211 | xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
- | |
4212 | }
|
- | |
4213 | 3524 | ||
- | 3525 | // Set the If-Modified-Since header, if ifModified mode.
|
|
4214 | if ( jQuery.etag[s.url] ) { |
3526 | if ( s.ifModified ) |
4215 | xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
3527 | xhr.setRequestHeader("If-Modified-Since", |
4216 | }
|
- | |
4217 | }
|
- | |
- | 3528 | jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); |
|
4218 | 3529 | ||
4219 | // Set header so the called script knows that it's an XMLHttpRequest
|
3530 | // Set header so the called script knows that it's an XMLHttpRequest
|
4220 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
3531 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
4221 | 3532 | ||
4222 | // Set the Accepts header for the server, depending on the dataType
|
3533 | // Set the Accepts header for the server, depending on the dataType
|
Строка 4224... | Строка 3535... | ||
4224 | s.accepts[ s.dataType ] + ", */*" : |
3535 | s.accepts[ s.dataType ] + ", */*" : |
4225 | s.accepts._default ); |
3536 | s.accepts._default ); |
4226 | } catch(e){} |
3537 | } catch(e){} |
4227 | 3538 | ||
4228 | // Allow custom headers/mimetypes and early abort
|
3539 | // Allow custom headers/mimetypes and early abort
|
4229 | if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
3540 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
4230 | // Handle the global AJAX counter
|
3541 | // Handle the global AJAX counter
|
4231 | if ( s.global && ! --jQuery.active ) { |
3542 | if ( s.global && ! --jQuery.active ) |
4232 | jQuery.event.trigger( "ajaxStop" ); |
3543 | jQuery.event.trigger( "ajaxStop" ); |
4233 | }
|
- | |
4234 | - | ||
4235 | // close opended socket
|
3544 | // close opended socket
|
4236 | xhr.abort(); |
3545 | xhr.abort(); |
4237 | return false; |
3546 | return false; |
4238 | }
|
3547 | }
|
4239 | 3548 | ||
4240 | if ( s.global ) { |
3549 | if ( s.global ) |
4241 | trigger("ajaxSend", [xhr, s]); |
3550 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
4242 | }
|
- | |
4243 | 3551 | ||
4244 | // Wait for a response to come back
|
3552 | // Wait for a response to come back
|
4245 | var onreadystatechange = function(isTimeout){ |
3553 | var onreadystatechange = function(isTimeout){ |
4246 | // The request was aborted, clear the interval and decrement jQuery.active
|
3554 | // The request was aborted, clear the interval and decrement jQuery.active
|
4247 | if ( !xhr || xhr.readyState === 0 ) { |
3555 | if (xhr.readyState == 0) { |
4248 | if ( ival ) { |
3556 | if (ival) { |
4249 | // clear poll interval
|
3557 | // clear poll interval
|
4250 | clearInterval( ival ); |
3558 | clearInterval(ival); |
4251 | ival = null; |
3559 | ival = null; |
4252 | - | ||
4253 | // Handle the global AJAX counter
|
3560 | // Handle the global AJAX counter
|
4254 | if ( s.global && ! --jQuery.active ) { |
3561 | if ( s.global && ! --jQuery.active ) |
4255 | jQuery.event.trigger( "ajaxStop" ); |
3562 | jQuery.event.trigger( "ajaxStop" ); |
4256 | }
|
- | |
4257 | }
|
3563 | }
|
4258 | - | ||
4259 | // The transfer is complete and the data is available, or the request timed out
|
3564 | // The transfer is complete and the data is available, or the request timed out
|
4260 | } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
3565 | } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { |
4261 | requestDone = true; |
3566 | requestDone = true; |
4262 | 3567 | ||
4263 | // clear poll interval
|
3568 | // clear poll interval
|
4264 | if (ival) { |
3569 | if (ival) { |
4265 | clearInterval(ival); |
3570 | clearInterval(ival); |
4266 | ival = null; |
3571 | ival = null; |
4267 | }
|
3572 | }
|
4268 | 3573 | ||
4269 | status = isTimeout === "timeout" ? |
3574 | status = isTimeout == "timeout" ? "timeout" : |
4270 | "timeout" : |
- | |
4271 | !jQuery.httpSuccess( xhr ) ? |
3575 | !jQuery.httpSuccess( xhr ) ? "error" : |
4272 | "error" : |
- | |
4273 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
3576 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : |
4274 | "notmodified" : |
- | |
4275 | "success"; |
3577 | "success"; |
4276 | 3578 | ||
4277 | if ( status === "success" ) { |
3579 | if ( status == "success" ) { |
4278 | // Watch for, and catch, XML document parse errors
|
3580 | // Watch for, and catch, XML document parse errors
|
4279 | try { |
3581 | try { |
4280 | // process the data (runs the xml through httpData regardless of callback)
|
3582 | // process the data (runs the xml through httpData regardless of callback)
|
4281 | data = jQuery.httpData( xhr, s.dataType, s ); |
3583 | data = jQuery.httpData( xhr, s.dataType, s ); |
4282 | } catch(e) { |
3584 | } catch(e) { |
4283 | status = "parsererror"; |
3585 | status = "parsererror"; |
4284 | }
|
3586 | }
|
4285 | }
|
3587 | }
|
4286 | 3588 | ||
4287 | // Make sure that the request was successful or notmodified
|
3589 | // Make sure that the request was successful or notmodified
|
4288 | if ( status === "success" || status === "notmodified" ) { |
3590 | if ( status == "success" ) { |
- | 3591 | // Cache Last-Modified header, if ifModified mode.
|
|
- | 3592 | var modRes; |
|
- | 3593 | try { |
|
- | 3594 | modRes = xhr.getResponseHeader("Last-Modified"); |
|
- | 3595 | } catch(e) {} // swallow exception thrown by FF if header is not available |
|
- | 3596 | ||
- | 3597 | if ( s.ifModified && modRes ) |
|
- | 3598 | jQuery.lastModified[s.url] = modRes; |
|
- | 3599 | ||
4289 | // JSONP handles its own success callback
|
3600 | // JSONP handles its own success callback
|
4290 | if ( !jsonp ) { |
3601 | if ( !jsonp ) |
4291 | success(); |
3602 | success(); |
4292 | }
|
- | |
4293 | } else { |
3603 | } else |
4294 | jQuery.handleError(s, xhr, status); |
3604 | jQuery.handleError(s, xhr, status); |
4295 | }
|
- | |
4296 | 3605 | ||
4297 | // Fire the complete handlers
|
3606 | // Fire the complete handlers
|
4298 | complete(); |
3607 | complete(); |
4299 | 3608 | ||
4300 | if ( isTimeout ) { |
3609 | if ( isTimeout ) |
4301 | xhr.abort(); |
3610 | xhr.abort(); |
4302 | }
|
- | |
4303 | 3611 | ||
4304 | // Stop memory leaks
|
3612 | // Stop memory leaks
|
4305 | if ( s.async ) { |
3613 | if ( s.async ) |
4306 | xhr = null; |
3614 | xhr = null; |
4307 | }
|
- | |
4308 | }
|
3615 | }
|
4309 | }; |
3616 | }; |
4310 | 3617 | ||
4311 | if ( s.async ) { |
3618 | if ( s.async ) { |
4312 | // don't attach the handler to the request, just poll it instead
|
3619 | // don't attach the handler to the request, just poll it instead
|
4313 | var ival = setInterval(onreadystatechange, 13); |
3620 | var ival = setInterval(onreadystatechange, 13); |
4314 | 3621 | ||
4315 | // Timeout checker
|
3622 | // Timeout checker
|
4316 | if ( s.timeout > 0 ) { |
3623 | if ( s.timeout > 0 ) |
4317 | setTimeout(function(){ |
3624 | setTimeout(function(){ |
4318 | // Check to see if the request is still happening
|
3625 | // Check to see if the request is still happening
|
4319 | if ( xhr && !requestDone ) { |
3626 | if ( xhr && !requestDone ) |
4320 | onreadystatechange( "timeout" ); |
3627 | onreadystatechange( "timeout" ); |
4321 | }
|
- | |
4322 | }, s.timeout); |
3628 | }, s.timeout); |
4323 | }
|
- | |
4324 | }
|
3629 | }
|
4325 | 3630 | ||
4326 | // Send the data
|
3631 | // Send the data
|
4327 | try { |
3632 | try { |
4328 | xhr.send( type === "POST" || type === "PUT" ? s.data : null ); |
3633 | xhr.send(s.data); |
4329 | } catch(e) { |
3634 | } catch(e) { |
4330 | jQuery.handleError(s, xhr, null, e); |
3635 | jQuery.handleError(s, xhr, null, e); |
4331 | }
|
3636 | }
|
4332 | 3637 | ||
4333 | // firefox 1.5 doesn't fire statechange for sync requests
|
3638 | // firefox 1.5 doesn't fire statechange for sync requests
|
4334 | if ( !s.async ) { |
3639 | if ( !s.async ) |
4335 | onreadystatechange(); |
3640 | onreadystatechange(); |
4336 | }
|
- | |
4337 | 3641 | ||
4338 | function success(){ |
3642 | function success(){ |
4339 | // If a local callback was specified, fire it and pass it the data
|
3643 | // If a local callback was specified, fire it and pass it the data
|
4340 | if ( s.success ) { |
3644 | if ( s.success ) |
4341 | s.success.call( callbackContext, data, status ); |
3645 | s.success( data, status ); |
4342 | }
|
- | |
4343 | 3646 | ||
4344 | // Fire the global callback
|
3647 | // Fire the global callback
|
4345 | if ( s.global ) { |
3648 | if ( s.global ) |
4346 | trigger( "ajaxSuccess", [xhr, s] ); |
3649 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
4347 | }
|
- | |
4348 | }
|
3650 | }
|
4349 | 3651 | ||
4350 | function complete(){ |
3652 | function complete(){ |
4351 | // Process result
|
3653 | // Process result
|
4352 | if ( s.complete ) { |
3654 | if ( s.complete ) |
4353 | s.complete.call( callbackContext, xhr, status); |
3655 | s.complete(xhr, status); |
4354 | }
|
- | |
4355 | 3656 | ||
4356 | // The request was completed
|
3657 | // The request was completed
|
4357 | if ( s.global ) { |
3658 | if ( s.global ) |
4358 | trigger( "ajaxComplete", [xhr, s] ); |
3659 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
4359 | }
|
- | |
4360 | 3660 | ||
4361 | // Handle the global AJAX counter
|
3661 | // Handle the global AJAX counter
|
4362 | if ( s.global && ! --jQuery.active ) { |
3662 | if ( s.global && ! --jQuery.active ) |
4363 | jQuery.event.trigger( "ajaxStop" ); |
3663 | jQuery.event.trigger( "ajaxStop" ); |
4364 | }
|
- | |
4365 | }
|
- | |
4366 | - | ||
4367 | function trigger(type, args){ |
- | |
4368 | (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
- | |
4369 | }
|
3664 | }
|
4370 | 3665 | ||
4371 | // return XMLHttpRequest to allow aborting the request etc.
|
3666 | // return XMLHttpRequest to allow aborting the request etc.
|
4372 | return xhr; |
3667 | return xhr; |
4373 | }, |
3668 | }, |
4374 | 3669 | ||
4375 | handleError: function( s, xhr, status, e ) { |
3670 | handleError: function( s, xhr, status, e ) { |
4376 | // If a local callback was specified, fire it
|
3671 | // If a local callback was specified, fire it
|
4377 | if ( s.error ) { |
- | |
4378 | s.error.call( s.context || window, xhr, status, e ); |
3672 | if ( s.error ) s.error( xhr, status, e ); |
4379 | }
|
- | |
4380 | 3673 | ||
4381 | // Fire the global callback
|
3674 | // Fire the global callback
|
4382 | if ( s.global ) { |
3675 | if ( s.global ) |
4383 | (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
3676 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
4384 | }
|
- | |
4385 | }, |
3677 | }, |
4386 | 3678 | ||
4387 | // Counter for holding the number of active queries
|
3679 | // Counter for holding the number of active queries
|
4388 | active: 0, |
3680 | active: 0, |
4389 | 3681 | ||
4390 | // Determines if an XMLHttpRequest was successful or not
|
3682 | // Determines if an XMLHttpRequest was successful or not
|
4391 | httpSuccess: function( xhr ) { |
3683 | httpSuccess: function( xhr ) { |
4392 | try { |
3684 | try { |
4393 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
3685 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
4394 | return !xhr.status && location.protocol === "file:" || |
3686 | return !xhr.status && location.protocol == "file:" || |
4395 | // Opera returns 0 when status is 304
|
- | |
4396 | ( xhr.status >= 200 && xhr.status < 300 ) || |
- | |
4397 | xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
3687 | ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; |
4398 | } catch(e){} |
3688 | } catch(e){} |
4399 | - | ||
4400 | return false; |
3689 | return false; |
4401 | }, |
3690 | }, |
4402 | 3691 | ||
4403 | // Determines if an XMLHttpRequest returns NotModified
|
3692 | // Determines if an XMLHttpRequest returns NotModified
|
4404 | httpNotModified: function( xhr, url ) { |
3693 | httpNotModified: function( xhr, url ) { |
4405 | var lastModified = xhr.getResponseHeader("Last-Modified"), |
- | |
4406 | etag = xhr.getResponseHeader("Etag"); |
- | |
4407 | - | ||
4408 | if ( lastModified ) { |
- | |
4409 | jQuery.lastModified[url] = lastModified; |
- | |
4410 | }
|
3694 | try { |
4411 | - | ||
4412 | if ( etag ) { |
- | |
4413 | jQuery.etag[url] = etag; |
3695 | var xhrRes = xhr.getResponseHeader("Last-Modified"); |
4414 | }
|
- | |
4415 | 3696 | ||
4416 | // Opera returns 0 when status is 304
|
3697 | // Firefox always returns 200. check Last-Modified date
|
4417 | return xhr.status === 304 || xhr.status === 0; |
3698 | return xhr.status == 304 || xhrRes == jQuery.lastModified[url]; |
- | 3699 | } catch(e){} |
|
- | 3700 | return false; |
|
4418 | }, |
3701 | }, |
4419 | 3702 | ||
4420 | httpData: function( xhr, type, s ) { |
3703 | httpData: function( xhr, type, s ) { |
4421 | var ct = xhr.getResponseHeader("content-type"), |
3704 | var ct = xhr.getResponseHeader("content-type"), |
4422 | xml = type === "xml" || !type && ct && ct.indexOf("xml") >= 0, |
3705 | xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, |
4423 | data = xml ? xhr.responseXML : xhr.responseText; |
3706 | data = xml ? xhr.responseXML : xhr.responseText; |
4424 | 3707 | ||
4425 | if ( xml && data.documentElement.nodeName === "parsererror" ) { |
3708 | if ( xml && data.documentElement.tagName == "parsererror" ) |
4426 | throw "parsererror"; |
3709 | throw "parsererror"; |
4427 | }
|
- | |
4428 | 3710 | ||
4429 | // Allow a pre-filtering function to sanitize the response
|
3711 | // Allow a pre-filtering function to sanitize the response
|
4430 | // s is checked to keep backwards compatibility
|
3712 | // s != null is checked to keep backwards compatibility
|
4431 | if ( s && s.dataFilter ) { |
3713 | if( s && s.dataFilter ) |
4432 | data = s.dataFilter( data, type ); |
3714 | data = s.dataFilter( data, type ); |
4433 | }
|
- | |
4434 | 3715 | ||
4435 | // The filter can actually parse the response
|
3716 | // The filter can actually parse the response
|
4436 | if ( typeof data === "string" ) { |
3717 | if( typeof data === "string" ){ |
4437 | 3718 | ||
4438 | // If the type is "script", eval it in global context
|
3719 | // If the type is "script", eval it in global context
|
4439 | if ( type === "script" ) { |
3720 | if ( type == "script" ) |
4440 | jQuery.globalEval( data ); |
3721 | jQuery.globalEval( data ); |
4441 | }
|
- | |
4442 | 3722 | ||
4443 | // Get the JavaScript object, if JSON is used.
|
3723 | // Get the JavaScript object, if JSON is used.
|
4444 | if ( type === "json" ) { |
3724 | if ( type == "json" ) |
4445 | if ( typeof JSON === "object" && JSON.parse ) { |
- | |
4446 | data = JSON.parse( data ); |
- | |
4447 | } else { |
- | |
4448 | data = (new Function("return " + data))(); |
3725 | data = window["eval"]("(" + data + ")"); |
4449 | }
|
- | |
4450 | }
|
- | |
4451 | }
|
3726 | }
|
4452 | 3727 | ||
4453 | return data; |
3728 | return data; |
4454 | }, |
3729 | }, |
4455 | 3730 | ||
4456 | // Serialize an array of form elements or a set of
|
3731 | // Serialize an array of form elements or a set of
|
4457 | // key/values into a query string
|
3732 | // key/values into a query string
|
4458 | param: function( a ) { |
3733 | param: function( a ) { |
4459 | var s = [], |
3734 | var s = [ ]; |
4460 | param_traditional = jQuery.param.traditional; |
- | |
4461 | 3735 | ||
4462 | function add( key, value ){ |
3736 | function add( key, value ){ |
4463 | // If value is a function, invoke it and return its value
|
- | |
4464 | value = jQuery.isFunction(value) ? value() : value; |
- | |
4465 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
3737 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4466 | }
|
3738 | }; |
4467 | 3739 | ||
4468 | // If an array was passed in, assume that it is an array
|
3740 | // If an array was passed in, assume that it is an array
|
4469 | // of form elements
|
3741 | // of form elements
|
4470 | if ( jQuery.isArray(a) || a.jquery ) |
3742 | if ( jQuery.isArray(a) || a.jquery ) |
4471 | // Serialize the form elements
|
3743 | // Serialize the form elements
|
4472 | jQuery.each( a, function() { |
3744 | jQuery.each( a, function(){ |
4473 | add( this.name, this.value ); |
3745 | add( this.name, this.value ); |
4474 | }); |
3746 | }); |
4475 | 3747 | ||
- | 3748 | // Otherwise, assume that it's an object of key/value pairs
|
|
4476 | else
|
3749 | else
|
4477 | // Encode parameters from object, recursively. If
|
3750 | // Serialize the key/values
|
4478 | // jQuery.param.traditional is set, encode the "old" way
|
- | |
4479 | // (the way 1.3.2 or older did it)
|
3751 | for ( var j in a ) |
4480 | jQuery.each( a, function buildParams( prefix, obj ) { |
3752 | // If the value is an array then the key names need to be repeated
|
4481 | - | ||
4482 | if ( jQuery.isArray(obj) ) |
3753 | if ( jQuery.isArray(a[j]) ) |
4483 | jQuery.each( obj, function(i,v){ |
3754 | jQuery.each( a[j], function(){ |
4484 | // Due to rails' limited request param syntax, numeric array
|
- | |
4485 | // indices are not supported. To avoid serialization ambiguity
|
- | |
4486 | // issues, serialized arrays can only contain scalar values. php
|
- | |
4487 | // does not have this issue, but we should go with the lowest
|
- | |
4488 | // common denominator
|
3755 | add( j, this ); |
4489 | add( prefix + ( param_traditional ? "" : "[]" ), v ); |
- | |
4490 | }); |
3756 | }); |
4491 | - | ||
4492 | else if ( typeof obj == "object" ) |
- | |
4493 | if ( param_traditional ) |
- | |
4494 | add( prefix, obj ); |
- | |
4495 | - | ||
4496 | else
|
- | |
4497 | jQuery.each( obj, function(k,v){ |
- | |
4498 | buildParams( prefix ? prefix + "[" + k + "]" : k, v ); |
- | |
4499 | }); |
- | |
4500 | - | ||
4501 | else
|
3757 | else
|
4502 | add( prefix, obj ); |
3758 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
4503 | - | ||
4504 | }); |
- | |
4505 | 3759 | ||
4506 | // Return the resulting serialization
|
3760 | // Return the resulting serialization
|
4507 | return s.join("&").replace(r20, "+"); |
3761 | return s.join("&").replace(/%20/g, "+"); |
4508 | }
|
3762 | }
|
4509 | 3763 | ||
4510 | }); |
3764 | }); |
4511 | var elemdisplay = {}, |
3765 | var elemdisplay = {}, |
4512 | timerId,
|
3766 | timerId,
|
Строка 4527... | Строка 3781... | ||
4527 | return obj; |
3781 | return obj; |
4528 | }
|
3782 | }
|
4529 | 3783 | ||
4530 | jQuery.fn.extend({ |
3784 | jQuery.fn.extend({ |
4531 | show: function(speed,callback){ |
3785 | show: function(speed,callback){ |
4532 | if ( speed !== undefined ) { |
3786 | if ( speed ) { |
4533 | return this.animate( genFx("show", 3), speed, callback); |
3787 | return this.animate( genFx("show", 3), speed, callback); |
4534 | } else { |
3788 | } else { |
4535 | for ( var i = 0, l = this.length; i < l; i++ ){ |
3789 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4536 | var old = jQuery.data(this[i], "olddisplay"); |
3790 | var old = jQuery.data(this[i], "olddisplay"); |
4537 | 3791 | ||
4538 | this[i].style.display = old || ""; |
3792 | this[i].style.display = old || ""; |
4539 | 3793 | ||
4540 | if ( jQuery.css(this[i], "display") === "none" ) { |
3794 | if ( jQuery.css(this[i], "display") === "none" ) { |
4541 | var nodeName = this[i].nodeName, display; |
3795 | var tagName = this[i].tagName, display; |
4542 | 3796 | ||
4543 | if ( elemdisplay[ nodeName ] ) { |
3797 | if ( elemdisplay[ tagName ] ) { |
4544 | display = elemdisplay[ nodeName ]; |
3798 | display = elemdisplay[ tagName ]; |
4545 | } else { |
3799 | } else { |
4546 | var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
3800 | var elem = jQuery("<" + tagName + " />").appendTo("body"); |
4547 | 3801 | ||
4548 | display = elem.css("display"); |
3802 | display = elem.css("display"); |
4549 | if ( display === "none" ) |
3803 | if ( display === "none" ) |
4550 | display = "block"; |
3804 | display = "block"; |
4551 | 3805 | ||
4552 | elem.remove(); |
3806 | elem.remove(); |
4553 | 3807 | ||
4554 | elemdisplay[ nodeName ] = display; |
3808 | elemdisplay[ tagName ] = display; |
4555 | }
|
3809 | }
|
4556 | 3810 | ||
4557 | jQuery.data(this[i], "olddisplay", display); |
3811 | jQuery.data(this[i], "olddisplay", display); |
4558 | }
|
3812 | }
|
4559 | }
|
3813 | }
|
4560 | 3814 | ||
4561 | // Set the display of the elements in a second loop
|
3815 | // Set the display of the elements in a second loop
|
4562 | // to avoid the constant reflow
|
3816 | // to avoid the constant reflow
|
4563 | for ( var i = 0, l = this.length; i < l; i++ ){ |
3817 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4564 | this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; |
3818 | this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; |
4565 | }
|
3819 | }
|
4566 | 3820 | ||
4567 | return this; |
3821 | return this; |
4568 | }
|
3822 | }
|
4569 | }, |
3823 | }, |
4570 | 3824 | ||
4571 | hide: function(speed,callback){ |
3825 | hide: function(speed,callback){ |
4572 | if ( speed !== undefined ) { |
3826 | if ( speed ) { |
4573 | return this.animate( genFx("hide", 3), speed, callback); |
3827 | return this.animate( genFx("hide", 3), speed, callback); |
4574 | } else { |
3828 | } else { |
4575 | for ( var i = 0, l = this.length; i < l; i++ ){ |
3829 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4576 | var old = jQuery.data(this[i], "olddisplay"); |
3830 | var old = jQuery.data(this[i], "olddisplay"); |
4577 | if ( !old && old !== "none" ) |
3831 | if ( !old && old !== "none" ) |
Строка 4603... | Строка 3857... | ||
4603 | }) : |
3857 | }) : |
4604 | this.animate(genFx("toggle", 3), fn, fn2); |
3858 | this.animate(genFx("toggle", 3), fn, fn2); |
4605 | }, |
3859 | }, |
4606 | 3860 | ||
4607 | fadeTo: function(speed,to,callback){ |
3861 | fadeTo: function(speed,to,callback){ |
4608 | return this.filter(":hidden").css('opacity', 0).show().end() |
- | |
4609 | .animate({opacity: to}, speed, callback); |
3862 | return this.animate({opacity: to}, speed, callback); |
4610 | }, |
3863 | }, |
4611 | 3864 | ||
4612 | animate: function( prop, speed, easing, callback ) { |
3865 | animate: function( prop, speed, easing, callback ) { |
4613 | var optall = jQuery.speed(speed, easing, callback); |
3866 | var optall = jQuery.speed(speed, easing, callback); |
4614 | 3867 | ||
4615 | return this[ optall.queue === false ? "each" : "queue" ](function(){ |
3868 | return this[ optall.queue === false ? "each" : "queue" ](function(){ |
4616 | 3869 | ||
4617 | var opt = jQuery.extend({}, optall), p, |
3870 | var opt = jQuery.extend({}, optall), p, |
4618 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
3871 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
4619 | self = this; |
3872 | self = this; |
4620 | 3873 | ||
4621 | for ( p in prop ) { |
3874 | for ( p in prop ) { |
4622 | var name = p.replace(rdashAlpha, fcamelCase); |
- | |
4623 | - | ||
4624 | if ( p !== name ) { |
- | |
4625 | prop[ name ] = prop[ p ]; |
- | |
4626 | delete prop[ p ]; |
- | |
4627 | p = name; |
- | |
4628 | }
|
- | |
4629 | - | ||
4630 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
3875 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
4631 | return opt.complete.call(this); |
3876 | return opt.complete.call(this); |
4632 | 3877 | ||
4633 | if ( ( p == "height" || p == "width" ) && this.style ) { |
3878 | if ( ( p == "height" || p == "width" ) && this.style ) { |
4634 | // Store display property
|
3879 | // Store display property
|
Строка 4648... | Строка 3893... | ||
4648 | var e = new jQuery.fx( self, opt, name ); |
3893 | var e = new jQuery.fx( self, opt, name ); |
4649 | 3894 | ||
4650 | if ( /toggle|show|hide/.test(val) ) |
3895 | if ( /toggle|show|hide/.test(val) ) |
4651 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
3896 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
4652 | else { |
3897 | else { |
4653 | var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val), |
3898 | var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), |
4654 | start = e.cur(true) || 0; |
3899 | start = e.cur(true) || 0; |
4655 | 3900 | ||
4656 | if ( parts ) { |
3901 | if ( parts ) { |
4657 | var end = parseFloat(parts[2]), |
3902 | var end = parseFloat(parts[2]), |
4658 | unit = parts[3] || "px"; |
3903 | unit = parts[3] || "px"; |
Строка 4802... | Строка 4047... | ||
4802 | return self.step(gotoEnd); |
4047 | return self.step(gotoEnd); |
4803 | }
|
4048 | }
|
4804 | 4049 | ||
4805 | t.elem = this.elem; |
4050 | t.elem = this.elem; |
4806 | 4051 | ||
4807 | if ( t() && jQuery.timers.push(t) && !timerId ) |
4052 | if ( t() && jQuery.timers.push(t) && !timerId ) { |
4808 | timerId = setInterval(jQuery.fx.tick, 13); |
4053 | timerId = setInterval(function(){ |
- | 4054 | var timers = jQuery.timers; |
|
- | 4055 | ||
- | 4056 | for ( var i = 0; i < timers.length; i++ ) |
|
- | 4057 | if ( !timers[i]() ) |
|
- | 4058 | timers.splice(i--, 1); |
|
- | 4059 | ||
- | 4060 | if ( !timers.length ) { |
|
- | 4061 | clearInterval( timerId ); |
|
- | 4062 | timerId = undefined; |
|
- | 4063 | }
|
|
- | 4064 | }, 13); |
|
- | 4065 | }
|
|
4809 | }, |
4066 | }, |
4810 | 4067 | ||
4811 | // Simple 'show' function
|
4068 | // Simple 'show' function
|
4812 | show: function(){ |
4069 | show: function(){ |
4813 | // Remember where we started, so that we can go back to it later
|
4070 | // Remember where we started, so that we can go back to it later
|
4814 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4071 | this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
4815 | this.options.show = true; |
4072 | this.options.show = true; |
4816 | 4073 | ||
4817 | // Begin the animation
|
4074 | // Begin the animation
|
4818 | // Make sure that we start at a small width/height to avoid any
|
4075 | // Make sure that we start at a small width/height to avoid any
|
4819 | // flash of content
|
4076 | // flash of content
|
Строка 4824... | Строка 4081... | ||
4824 | }, |
4081 | }, |
4825 | 4082 | ||
4826 | // Simple 'hide' function
|
4083 | // Simple 'hide' function
|
4827 | hide: function(){ |
4084 | hide: function(){ |
4828 | // Remember where we started, so that we can go back to it later
|
4085 | // Remember where we started, so that we can go back to it later
|
4829 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4086 | this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
4830 | this.options.hide = true; |
4087 | this.options.hide = true; |
4831 | 4088 | ||
4832 | // Begin the animation
|
4089 | // Begin the animation
|
4833 | this.custom(this.cur(), 0); |
4090 | this.custom(this.cur(), 0); |
4834 | }, |
4091 | }, |
Строка 4865... | Строка 4122... | ||
4865 | jQuery(this.elem).hide(); |
4122 | jQuery(this.elem).hide(); |
4866 | 4123 | ||
4867 | // Reset the properties, if the item has been hidden or shown
|
4124 | // Reset the properties, if the item has been hidden or shown
|
4868 | if ( this.options.hide || this.options.show ) |
4125 | if ( this.options.hide || this.options.show ) |
4869 | for ( var p in this.options.curAnim ) |
4126 | for ( var p in this.options.curAnim ) |
4870 | jQuery.style(this.elem, p, this.options.orig[p]); |
4127 | jQuery.attr(this.elem.style, p, this.options.orig[p]); |
4871 | 4128 | ||
4872 | // Execute the complete function
|
4129 | // Execute the complete function
|
4873 | this.options.complete.call( this.elem ); |
4130 | this.options.complete.call( this.elem ); |
4874 | }
|
4131 | }
|
4875 | 4132 | ||
4876 | return false; |
4133 | return false; |
Строка 4890... | Строка 4147... | ||
4890 | }
|
4147 | }
|
4891 | 4148 | ||
4892 | }; |
4149 | }; |
4893 | 4150 | ||
4894 | jQuery.extend( jQuery.fx, { |
4151 | jQuery.extend( jQuery.fx, { |
4895 | - | ||
4896 | tick:function(){ |
- | |
4897 | var timers = jQuery.timers; |
- | |
4898 | - | ||
4899 | for ( var i = 0; i < timers.length; i++ ) |
- | |
4900 | if ( !timers[i]() ) |
- | |
4901 | timers.splice(i--, 1); |
- | |
4902 | - | ||
4903 | if ( !timers.length ) |
- | |
4904 | jQuery.fx.stop(); |
- | |
4905 | }, |
- | |
4906 | - | ||
4907 | stop:function(){ |
- | |
4908 | clearInterval( timerId ); |
- | |
4909 | timerId = null; |
- | |
4910 | }, |
- | |
4911 | - | ||
4912 | speeds:{ |
4152 | speeds:{ |
4913 | slow: 600, |
4153 | slow: 600, |
4914 | fast: 200, |
4154 | fast: 200, |
4915 | // Default speed
|
4155 | // Default speed
|
4916 | _default: 400 |
4156 | _default: 400 |
4917 | }, |
4157 | }, |
4918 | - | ||
4919 | step: { |
4158 | step: { |
4920 | 4159 | ||
4921 | opacity: function(fx){ |
4160 | opacity: function(fx){ |
4922 | jQuery.style(fx.elem, "opacity", fx.now); |
4161 | jQuery.attr(fx.elem.style, "opacity", fx.now); |
4923 | }, |
4162 | }, |
4924 | 4163 | ||
4925 | _default: function(fx){ |
4164 | _default: function(fx){ |
4926 | if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
4165 | if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
4927 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
4166 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
4928 | else
|
4167 | else
|
4929 | fx.elem[ fx.prop ] = fx.now; |
4168 | fx.elem[ fx.prop ] = fx.now; |
4930 | }
|
4169 | }
|
4931 | }
|
4170 | }
|
4932 | }); |
4171 | }); |
4933 | if ( "getBoundingClientRect" in document.documentElement ) { |
4172 | if ( document.documentElement["getBoundingClientRect"] ) |
4934 | jQuery.fn.offset = function( options ) { |
4173 | jQuery.fn.offset = function() { |
4935 | var elem = this[0]; |
- | |
4936 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | |
4937 | if ( options ) { |
- | |
4938 | return this.each(function() { |
- | |
4939 | jQuery.offset.setOffset( this, options ); |
- | |
4940 | }); |
- | |
4941 | }
|
- | |
4942 | if ( elem === elem.ownerDocument.body ) { |
4174 | if ( !this[0] ) return { top: 0, left: 0 }; |
4943 | return jQuery.offset.bodyOffset( elem ); |
4175 | if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); |
4944 | }
|
- | |
4945 | - | ||
4946 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4176 | var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement, |
4947 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4177 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4948 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4178 | top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4949 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4179 | left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4950 | return { top: top, left: left }; |
4180 | return { top: top, left: left }; |
4951 | }; |
4181 | }; |
4952 | } else { |
4182 | else
|
4953 | jQuery.fn.offset = function( options ) { |
4183 | jQuery.fn.offset = function() { |
4954 | var elem = this[0]; |
- | |
4955 | if ( !elem || !elem.ownerDocument ) { return null; } |
4184 | if ( !this[0] ) return { top: 0, left: 0 }; |
4956 | if ( options ) { |
- | |
4957 | return this.each(function() { |
- | |
4958 | jQuery.offset.setOffset( this, options ); |
- | |
4959 | }); |
- | |
4960 | }
|
- | |
4961 | if ( elem === elem.ownerDocument.body ) { |
4185 | if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); |
4962 | return jQuery.offset.bodyOffset( elem ); |
4186 | jQuery.offset.initialized || jQuery.offset.initialize(); |
4963 | }
|
- | |
4964 | 4187 | ||
4965 | jQuery.offset.initialize(); |
- | |
4966 | - | ||
4967 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4188 | var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4968 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4189 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4969 | body = doc.body, defaultView = doc.defaultView, |
4190 | body = doc.body, defaultView = doc.defaultView, |
4970 | prevComputedStyle = defaultView.getComputedStyle( elem, null ), |
4191 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4971 | top = elem.offsetTop, left = elem.offsetLeft; |
4192 | top = elem.offsetTop, left = elem.offsetLeft; |
4972 | 4193 | ||
4973 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4194 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4974 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } |
- | |
4975 | - | ||
4976 | computedStyle = defaultView.getComputedStyle(elem, null); |
4195 | computedStyle = defaultView.getComputedStyle(elem, null); |
4977 | top -= elem.scrollTop; |
- | |
4978 | left -= elem.scrollLeft; |
4196 | top -= elem.scrollTop, left -= elem.scrollLeft; |
4979 | - | ||
4980 | if ( elem === offsetParent ) { |
4197 | if ( elem === offsetParent ) { |
4981 | top += elem.offsetTop; |
- | |
4982 | left += elem.offsetLeft; |
4198 | top += elem.offsetTop, left += elem.offsetLeft; |
4983 | - | ||
4984 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
4199 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
4985 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4200 | top += parseInt( computedStyle.borderTopWidth, 10) || 0, |
4986 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4201 | left += parseInt( computedStyle.borderLeftWidth, 10) || 0; |
4987 | }
|
- | |
4988 | - | ||
4989 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4202 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4990 | }
|
4203 | }
|
4991 | - | ||
4992 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
4204 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
4993 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4205 | top += parseInt( computedStyle.borderTopWidth, 10) || 0, |
4994 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4206 | left += parseInt( computedStyle.borderLeftWidth, 10) || 0; |
4995 | }
|
- | |
4996 | - | ||
4997 | prevComputedStyle = computedStyle; |
4207 | prevComputedStyle = computedStyle; |
4998 | }
|
4208 | }
|
4999 | 4209 | ||
5000 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
4210 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
5001 | top += body.offsetTop; |
4211 | top += body.offsetTop, |
5002 | left += body.offsetLeft; |
4212 | left += body.offsetLeft; |
5003 | }
|
- | |
5004 | 4213 | ||
5005 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
4214 | if ( prevComputedStyle.position === "fixed" ) |
5006 | top += Math.max( docElem.scrollTop, body.scrollTop ); |
4215 | top += Math.max(docElem.scrollTop, body.scrollTop), |
5007 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
4216 | left += Math.max(docElem.scrollLeft, body.scrollLeft); |
5008 | }
|
- | |
5009 | 4217 | ||
5010 | return { top: top, left: left }; |
4218 | return { top: top, left: left }; |
5011 | }; |
4219 | }; |
5012 | }
|
- | |
5013 | 4220 | ||
5014 | jQuery.offset = { |
4221 | jQuery.offset = { |
5015 | initialize: function() { |
4222 | initialize: function() { |
- | 4223 | if ( this.initialized ) return; |
|
5016 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4224 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop, |
5017 | 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>'; |
4225 | 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>'; |
5018 | 4226 | ||
5019 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4227 | rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' }; |
- | 4228 | for ( prop in rules ) container.style[prop] = rules[prop]; |
|
5020 | 4229 | ||
5021 | container.innerHTML = html; |
4230 | container.innerHTML = html; |
5022 | body.insertBefore( container, body.firstChild ); |
4231 | body.insertBefore(container, body.firstChild); |
5023 | innerDiv = container.firstChild; |
- | |
5024 | checkDiv = innerDiv.firstChild; |
- | |
5025 | td = innerDiv.nextSibling.firstChild.firstChild; |
4232 | innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
5026 | 4233 | ||
5027 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4234 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
5028 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4235 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
5029 | 4236 | ||
5030 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
- | |
5031 | // safari subtracts parent border width here which is 5px
|
- | |
5032 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
- | |
5033 | checkDiv.style.position = checkDiv.style.top = ''; |
- | |
5034 | - | ||
5035 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4237 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
5036 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4238 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
5037 | 4239 | ||
- | 4240 | body.style.marginTop = '1px'; |
|
5038 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4241 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0); |
- | 4242 | body.style.marginTop = bodyMarginTop; |
|
5039 | 4243 | ||
5040 | body.removeChild( container ); |
4244 | body.removeChild(container); |
5041 | body = container = innerDiv = checkDiv = table = td = null; |
- | |
5042 | jQuery.offset.initialize = function(){}; |
4245 | this.initialized = true; |
5043 | }, |
4246 | }, |
5044 | 4247 | ||
5045 | bodyOffset: function( body ) { |
4248 | bodyOffset: function(body) { |
- | 4249 | jQuery.offset.initialized || jQuery.offset.initialize(); |
|
5046 | var top = body.offsetTop, left = body.offsetLeft; |
4250 | var top = body.offsetTop, left = body.offsetLeft; |
5047 | - | ||
5048 | jQuery.offset.initialize(); |
- | |
5049 | - | ||
5050 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
4251 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
5051 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; |
4252 | top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0, |
5052 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
4253 | left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0; |
5053 | }
|
- | |
5054 | - | ||
5055 | return { top: top, left: left }; |
4254 | return { top: top, left: left }; |
5056 | }, |
- | |
5057 | - | ||
5058 | setOffset: function( elem, options ) { |
- | |
5059 | // set position first, in-case top/left are set even on static elem
|
- | |
5060 | if ( /static/.test( jQuery.curCSS( elem, 'position' ) ) ) { |
- | |
5061 | elem.style.position = 'relative'; |
- | |
5062 | }
|
- | |
5063 | var curElem = jQuery( elem ), |
- | |
5064 | curOffset = curElem.offset(), |
- | |
5065 | curTop = parseInt( jQuery.curCSS( elem, 'top', true ), 10 ) || 0, |
- | |
5066 | curLeft = parseInt( jQuery.curCSS( elem, 'left', true ), 10) || 0, |
- | |
5067 | props = { |
- | |
5068 | top: (options.top - curOffset.top) + curTop, |
- | |
5069 | left: (options.left - curOffset.left) + curLeft |
- | |
5070 | }; |
- | |
5071 | - | ||
5072 | if ( 'using' in options ) { |
- | |
5073 | options.using.call( elem, props ); |
- | |
5074 | } else { |
- | |
5075 | curElem.css( props ); |
- | |
5076 | }
|
- | |
5077 | }
|
4255 | }
|
5078 | }; |
4256 | }; |
5079 | 4257 | ||
5080 | 4258 | ||
5081 | jQuery.fn.extend({ |
4259 | jQuery.fn.extend({ |
5082 | position: function() { |
4260 | position: function() { |
5083 | if ( !this[0] ) { return null; } |
4261 | var left = 0, top = 0, results; |
5084 | 4262 | ||
5085 | var elem = this[0], |
4263 | if ( this[0] ) { |
- | 4264 | // Get *real* offsetParent
|
|
- | 4265 | var offsetParent = this.offsetParent(), |
|
5086 | 4266 | ||
5087 | // Get *real* offsetParent
|
4267 | // Get correct offsets
|
5088 | offsetParent = this.offsetParent(), |
4268 | offset = this.offset(), |
- | 4269 | parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
|
- | 4270 | ||
- | 4271 | // Subtract element margins
|
|
- | 4272 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
|
- | 4273 | // are the same in Safari causing offset.left to incorrectly be 0
|
|
- | 4274 | offset.top -= num( this, 'marginTop' ); |
|
- | 4275 | offset.left -= num( this, 'marginLeft' ); |
|
- | 4276 | ||
- | 4277 | // Add offsetParent borders
|
|
- | 4278 | parentOffset.top += num( offsetParent, 'borderTopWidth' ); |
|
- | 4279 | parentOffset.left += num( offsetParent, 'borderLeftWidth' ); |
|
- | 4280 | ||
- | 4281 | // Subtract the two offsets
|
|
- | 4282 | results = { |
|
- | 4283 | top: offset.top - parentOffset.top, |
|
- | 4284 | left: offset.left - parentOffset.left |
|
- | 4285 | }; |
|
- | 4286 | }
|
|
5089 | 4287 | ||
5090 | // Get correct offsets
|
- | |
5091 | offset = this.offset(), |
- | |
5092 | parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
- | |
5093 | - | ||
5094 | // Subtract element margins
|
- | |
5095 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
- | |
5096 | // are the same in Safari causing offset.left to incorrectly be 0
|
- | |
5097 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
- | |
5098 | offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; |
- | |
5099 | - | ||
5100 | // Add offsetParent borders
|
- | |
5101 | parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; |
- | |
5102 | parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; |
- | |
5103 | - | ||
5104 | // Subtract the two offsets
|
- | |
5105 | return { |
4288 | return results; |
5106 | top: offset.top - parentOffset.top, |
- | |
5107 | left: offset.left - parentOffset.left |
- | |
5108 | }; |
- | |
5109 | }, |
4289 | }, |
5110 | 4290 | ||
5111 | offsetParent: function() { |
4291 | offsetParent: function() { |
5112 | return this.map(function(){ |
- | |
5113 | var offsetParent = this.offsetParent || document.body; |
4292 | var offsetParent = this[0].offsetParent || document.body; |
5114 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) { |
4293 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') ) |
5115 | offsetParent = offsetParent.offsetParent; |
4294 | offsetParent = offsetParent.offsetParent; |
5116 | }
|
- | |
5117 | return offsetParent; |
4295 | return jQuery(offsetParent); |
5118 | }); |
- | |
5119 | }
|
4296 | }
|
5120 | }); |
4297 | }); |
5121 | 4298 | ||
5122 | 4299 | ||
5123 | // Create scrollLeft and scrollTop methods
|
4300 | // Create scrollLeft and scrollTop methods
|
5124 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4301 | jQuery.each( ['Left', 'Top'], function(i, name) { |
5125 | var method = 'scroll' + name; |
4302 | var method = 'scroll' + name; |
5126 | 4303 | ||
5127 | jQuery.fn[ method ] = function(val) { |
4304 | jQuery.fn[ method ] = function(val) { |
5128 | var elem = this[0], win; |
- | |
5129 | - | ||
5130 | if ( !elem ) { return null; } |
4305 | if (!this[0]) return null; |
5131 | 4306 | ||
5132 | if ( val !== undefined ) { |
4307 | return val !== undefined ? |
5133 | // Set the scroll offset
|
- | |
5134 | return this.each(function() { |
- | |
5135 | win = getWindow( this ); |
- | |
5136 | 4308 | ||
- | 4309 | // Set the scroll offset
|
|
5137 | win ?
|
4310 | this.each(function() { |
- | 4311 | this == window || this == document ? |
|
5138 | win.scrollTo( |
4312 | window.scrollTo( |
5139 | !i ? val : jQuery(win).scrollLeft(), |
4313 | !i ? val : jQuery(window).scrollLeft(), |
5140 | i ? val : jQuery(win).scrollTop() |
4314 | i ? val : jQuery(window).scrollTop() |
5141 | ) : |
4315 | ) : |
5142 | this[ method ] = val; |
4316 | this[ method ] = val; |
5143 | }); |
4317 | }) : |
5144 | } else { |
- | |
5145 | win = getWindow( elem ); |
- | |
5146 | 4318 | ||
5147 | // Return the scroll offset
|
4319 | // Return the scroll offset
|
- | 4320 | this[0] == window || this[0] == document ? |
|
5148 | return win ? ('pageXOffset' in win) ? win[ i ? 'pageYOffset' : 'pageXOffset' ] : |
4321 | self[ i ? 'pageYOffset' : 'pageXOffset' ] || |
5149 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4322 | jQuery.boxModel && document.documentElement[ method ] || |
5150 | win.document.body[ method ] : |
4323 | document.body[ method ] : |
5151 | elem[ method ]; |
4324 | this[0][ method ]; |
5152 | }
|
- | |
5153 | }; |
4325 | }; |
5154 | }); |
4326 | }); |
5155 | - | ||
5156 | function getWindow( elem ) { |
- | |
5157 | return ("scrollTo" in elem && elem.document) ? |
- | |
5158 | elem :
|
- | |
5159 | elem.nodeType === 9 ? |
- | |
5160 | elem.defaultView || elem.parentWindow : |
- | |
5161 | false; |
- | |
5162 | }
|
- | |
5163 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4327 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
5164 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4328 | jQuery.each([ "Height", "Width" ], function(i, name){ |
5165 | 4329 | ||
- | 4330 | var tl = i ? "Left" : "Top", // top or left |
|
- | 4331 | br = i ? "Right" : "Bottom", // bottom or right |
|
5166 | var type = name.toLowerCase(); |
4332 | lower = name.toLowerCase(); |
5167 | 4333 | ||
5168 | // innerHeight and innerWidth
|
4334 | // innerHeight and innerWidth
|
5169 | jQuery.fn["inner" + name] = function(){ |
4335 | jQuery.fn["inner" + name] = function(){ |
5170 | return this[0] ? |
4336 | return this[0] ? |
5171 | jQuery.css( this[0], type, false, "padding" ) : |
4337 | jQuery.css( this[0], lower, false, "padding" ) : |
5172 | null; |
4338 | null; |
5173 | }; |
4339 | }; |
5174 | 4340 | ||
5175 | // outerHeight and outerWidth
|
4341 | // outerHeight and outerWidth
|
5176 | jQuery.fn["outer" + name] = function(margin) { |
4342 | jQuery.fn["outer" + name] = function(margin) { |
5177 | return this[0] ? |
4343 | return this[0] ? |
5178 | jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
4344 | jQuery.css( this[0], lower, false, margin ? "margin" : "border" ) : |
5179 | null; |
4345 | null; |
5180 | }; |
4346 | }; |
- | 4347 | ||
- | 4348 | var type = name.toLowerCase(); |
|
5181 | 4349 | ||
5182 | jQuery.fn[ type ] = function( size ) { |
4350 | jQuery.fn[ type ] = function( size ) { |
5183 | // Get window width or height
|
4351 | // Get window width or height
|
5184 | var elem = this[0]; |
4352 | return this[0] == window ? |
5185 | if ( !elem ) return null; |
- | |
5186 | return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
- | |
5187 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4353 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
5188 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4354 | document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || |
5189 | elem.document.body[ "client" + name ] : |
4355 | document.body[ "client" + name ] : |
5190 | 4356 | ||
5191 | // Get document width or height
|
4357 | // Get document width or height
|
5192 | (elem.nodeType === 9) ? // is it a document |
4358 | this[0] == document ? |
5193 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4359 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
5194 | Math.max( |
4360 | Math.max( |
5195 | elem.documentElement["client" + name], |
4361 | document.documentElement["client" + name], |
5196 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4362 | document.body["scroll" + name], document.documentElement["scroll" + name], |
5197 | elem.body["offset" + name], elem.documentElement["offset" + name] |
4363 | document.body["offset" + name], document.documentElement["offset" + name] |
5198 | ) : |
4364 | ) : |
5199 | 4365 | ||
5200 | // Get or set width or height on the element
|
4366 | // Get or set width or height on the element
|
5201 | size === undefined ? |
4367 | size === undefined ? |
5202 | // Get width or height on the element
|
4368 | // Get width or height on the element
|
5203 | jQuery.css( elem, type ) : |
4369 | (this.length ? jQuery.css( this[0], type ) : null) : |
5204 | 4370 | ||
5205 | // Set the width or height on the element (default to pixels if value is unitless)
|
4371 | // Set the width or height on the element (default to pixels if value is unitless)
|
5206 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4372 | this.css( type, typeof size === "string" ? size : size + "px" ); |
5207 | }; |
4373 | }; |
5208 | 4374 | ||
5209 | }); |
4375 | }); |
5210 | // Expose jQuery to the global object
|
- | |
5211 | window.jQuery = window.$ = jQuery; |
- | |
5212 | - | ||
5213 | })(window); |
4376 | })(); |