Редакция 175 | Редакция 289 | К новейшей редакции | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 175 | Редакция 283 | ||
---|---|---|---|
Строка 4... | Строка 4... | ||
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-04-01 00:35:20 +0700 (Срд, 01 Апр 2009)
|
9 | * Date: 2009-05-12 22:43:51 +0700 (Втр, 12 Май 2009)
|
10 | * Revision: 6303
|
10 | * Revision: 6348
|
11 | */
|
11 | */
|
12 | (function(){ |
12 | (function(){ |
13 | 13 | ||
14 | // Will speed up references to window, and allows munging its name.
|
14 | // Will speed up references to window, and allows munging its name.
|
15 | var window = this, |
15 | var window = this, |
Строка 29... | Строка 29... | ||
29 | // A central reference to the root jQuery(document)
|
29 | // A central reference to the root jQuery(document)
|
30 | rootjQuery,
|
30 | rootjQuery,
|
31 | 31 | ||
32 | jQuery = window.jQuery = window.$ = function( selector, context ) { |
32 | jQuery = window.jQuery = window.$ = function( selector, context ) { |
33 | // The jQuery object is actually just the init constructor 'enhanced'
|
33 | // The jQuery object is actually just the init constructor 'enhanced'
|
34 | return selector === undefined ? |
34 | return arguments.length === 0 ? |
35 | rootjQuery :
|
35 | rootjQuery :
|
36 | new jQuery.fn.init( selector, context ); |
36 | new jQuery.fn.init( selector, context ); |
37 | }, |
37 | }, |
38 | 38 | ||
39 | // A simple way to check for HTML strings or ID strings
|
39 | // A simple way to check for HTML strings or ID strings
|
Строка 47... | Строка 47... | ||
47 | userAgent = navigator.userAgent.toLowerCase(), |
47 | userAgent = navigator.userAgent.toLowerCase(), |
48 | 48 | ||
49 | // Save a reference to the core toString method
|
49 | // Save a reference to the core toString method
|
50 | toString = Object.prototype.toString; |
50 | toString = Object.prototype.toString; |
51 | 51 | ||
52 | // Define the main jQuery method
|
- | |
53 | jQuery = window.jQuery = window.$ = function( selector, context ) { |
- | |
54 | // The jQuery object is actually just the init constructor 'enhanced'
|
- | |
55 | return new jQuery.fn.init( selector, context ); |
- | |
56 | }; |
- | |
57 | - | ||
58 | jQuery.fn = jQuery.prototype = { |
52 | jQuery.fn = jQuery.prototype = { |
59 | init: function( selector, context ) { |
53 | init: function( selector, context ) { |
60 | var match, elem, ret; |
54 | var match, elem, ret; |
61 | 55 | ||
62 | // Handle $(""), $(null), or $(undefined)
|
56 | // Handle $(""), $(null), or $(undefined)
|
Строка 193... | Строка 187... | ||
193 | }, |
187 | }, |
194 | 188 | ||
195 | // Determine the position of an element within
|
189 | // Determine the position of an element within
|
196 | // the matched set of elements
|
190 | // the matched set of elements
|
197 | index: function( elem ) { |
191 | index: function( elem ) { |
- | 192 | if ( !elem || typeof elem === "string" ) { |
|
- | 193 | return jQuery.inArray( this[0], |
|
- | 194 | // If it receives a string, the selector is used
|
|
- | 195 | // If it receives nothing, the siblings are used
|
|
- | 196 | elem ? jQuery( elem ) : this.parent().children() ); |
|
- | 197 | }
|
|
198 | // Locate the position of the desired element
|
198 | // Locate the position of the desired element
|
199 | return jQuery.inArray( |
199 | return jQuery.inArray( |
200 | // If it receives a jQuery object, the first element is used
|
200 | // If it receives a jQuery object, the first element is used
|
201 | elem && elem.jquery ? elem[0] : elem, this ); |
201 | elem.jquery ? elem[0] : elem, this ); |
202 | }, |
202 | }, |
203 | 203 | ||
204 | is: function( selector ) { |
204 | is: function( selector ) { |
205 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
205 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
206 | }, |
206 | }, |
Строка 366... | Строка 366... | ||
366 | makeArray: function( array ) { |
366 | makeArray: function( array ) { |
367 | var ret = [], i; |
367 | var ret = [], i; |
368 | 368 | ||
369 | if ( array != null ) { |
369 | if ( array != null ) { |
370 | i = array.length; |
370 | i = array.length; |
371 | 371 | ||
372 | // The window, strings (and functions) also have 'length'
|
372 | // The window, strings (and functions) also have 'length'
|
373 | if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
373 | if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
374 | ret[0] = array; |
374 | ret[0] = array; |
375 | } else { |
375 | } else { |
376 | while ( i ) { |
376 | while ( i ) { |
Строка 394... | Строка 394... | ||
394 | 394 | ||
395 | merge: function( first, second ) { |
395 | merge: function( first, second ) { |
396 | // We have to loop this way because IE & Opera overwrite the length
|
396 | // We have to loop this way because IE & Opera overwrite the length
|
397 | // expando of getElementsByTagName
|
397 | // expando of getElementsByTagName
|
398 | var i = 0, elem, pos = first.length; |
398 | var i = 0, elem, pos = first.length; |
399 | 399 | ||
400 | // Also, we need to make sure that the correct elements are being returned
|
400 | // Also, we need to make sure that the correct elements are being returned
|
401 | // (IE returns comment nodes in a '*' query)
|
401 | // (IE returns comment nodes in a '*' query)
|
402 | if ( !jQuery.support.getAll ) { |
402 | if ( !jQuery.support.getAll ) { |
403 | while ( (elem = second[ i++ ]) != null ) { |
403 | while ( (elem = second[ i++ ]) != null ) { |
404 | if ( elem.nodeType !== 8 ) { |
404 | if ( elem.nodeType !== 8 ) { |
Строка 650... | Строка 650... | ||
650 | */
|
650 | */
|
651 | (function(){ |
651 | (function(){ |
652 | 652 | ||
653 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
653 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
654 | done = 0, |
654 | done = 0, |
655 | toString = Object.prototype.toString; |
655 | toString = Object.prototype.toString, |
- | 656 | hasDuplicate = false; |
|
656 | 657 | ||
657 | var Sizzle = function(selector, context, results, seed) { |
658 | var Sizzle = function(selector, context, results, seed) { |
658 | results = results || []; |
659 | results = results || []; |
659 | var origContext = context = context || document; |
660 | var origContext = context = context || document; |
660 | 661 | ||
661 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
662 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
662 | return []; |
663 | return []; |
663 | }
|
664 | }
|
664 | 665 | ||
665 | if ( !selector || typeof selector !== "string" ) { |
666 | if ( !selector || typeof selector !== "string" ) { |
666 | return results; |
667 | return results; |
667 | }
|
668 | }
|
668 | 669 | ||
669 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
670 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
670 | 671 | ||
671 | // Reset the position of the chunker regexp (start from head)
|
672 | // Reset the position of the chunker regexp (start from head)
|
672 | chunker.lastIndex = 0; |
673 | chunker.lastIndex = 0; |
673 | 674 | ||
674 | while ( (m = chunker.exec(selector)) !== null ) { |
675 | while ( (m = chunker.exec(selector)) !== null ) { |
675 | parts.push( m[1] ); |
676 | parts.push( m[1] ); |
676 | 677 | ||
677 | if ( m[2] ) { |
678 | if ( m[2] ) { |
678 | extra = RegExp.rightContext; |
679 | extra = RegExp.rightContext; |
679 | break; |
680 | break; |
680 | }
|
681 | }
|
681 | }
|
682 | }
|
Строка 800... | Строка 801... | ||
800 | return []; |
801 | return []; |
801 | }
|
802 | }
|
802 | 803 | ||
803 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
804 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
804 | var type = Expr.order[i], match; |
805 | var type = Expr.order[i], match; |
805 | 806 | ||
806 | if ( (match = Expr.match[ type ].exec( expr )) ) { |
807 | if ( (match = Expr.match[ type ].exec( expr )) ) { |
807 | var left = RegExp.leftContext; |
808 | var left = RegExp.leftContext; |
808 | 809 | ||
809 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
810 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
810 | match[1] = (match[1] || "").replace(/\\/g, ""); |
811 | match[1] = (match[1] || "").replace(/\\/g, ""); |
Строка 1062... | Строка 1063... | ||
1062 | 1063 | ||
1063 | return match; |
1064 | return match; |
1064 | }, |
1065 | }, |
1065 | ATTR: function(match, curLoop, inplace, result, not, isXML){ |
1066 | ATTR: function(match, curLoop, inplace, result, not, isXML){ |
1066 | var name = match[1].replace(/\\/g, ""); |
1067 | var name = match[1].replace(/\\/g, ""); |
1067 | 1068 | ||
1068 | if ( !isXML && Expr.attrMap[name] ) { |
1069 | if ( !isXML && Expr.attrMap[name] ) { |
1069 | match[1] = Expr.attrMap[name]; |
1070 | match[1] = Expr.attrMap[name]; |
1070 | }
|
1071 | }
|
1071 | 1072 | ||
1072 | if ( match[2] === "~=" ) { |
1073 | if ( match[2] === "~=" ) { |
Строка 1088... | Строка 1089... | ||
1088 | return false; |
1089 | return false; |
1089 | }
|
1090 | }
|
1090 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
1091 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
1091 | return true; |
1092 | return true; |
1092 | }
|
1093 | }
|
1093 | 1094 | ||
1094 | return match; |
1095 | return match; |
1095 | }, |
1096 | }, |
1096 | POS: function(match){ |
1097 | POS: function(match){ |
1097 | match.unshift( true ); |
1098 | match.unshift( true ); |
1098 | return match; |
1099 | return match; |
Строка 1222... | Строка 1223... | ||
1222 | var first = match[2], last = match[3]; |
1223 | var first = match[2], last = match[3]; |
1223 | 1224 | ||
1224 | if ( first == 1 && last == 0 ) { |
1225 | if ( first == 1 && last == 0 ) { |
1225 | return true; |
1226 | return true; |
1226 | }
|
1227 | }
|
1227 | 1228 | ||
1228 | var doneName = match[0], |
1229 | var doneName = match[0], |
1229 | parent = elem.parentNode; |
1230 | parent = elem.parentNode; |
1230 | 1231 | ||
1231 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
1232 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
1232 | var count = 0; |
1233 | var count = 0; |
1233 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
1234 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
1234 | if ( node.nodeType === 1 ) { |
1235 | if ( node.nodeType === 1 ) { |
1235 | node.nodeIndex = ++count; |
1236 | node.nodeIndex = ++count; |
1236 | }
|
1237 | }
|
1237 | }
|
1238 | }
|
1238 | parent.sizcache = doneName; |
1239 | parent.sizcache = doneName; |
1239 | }
|
1240 | }
|
1240 | 1241 | ||
1241 | var diff = elem.nodeIndex - last; |
1242 | var diff = elem.nodeIndex - last; |
1242 | if ( first == 0 ) { |
1243 | if ( first == 0 ) { |
1243 | return diff == 0; |
1244 | return diff == 0; |
1244 | } else { |
1245 | } else { |
1245 | return ( diff % first == 0 && diff / first >= 0 ); |
1246 | return ( diff % first == 0 && diff / first >= 0 ); |
Строка 1308... | Строка 1309... | ||
1308 | 1309 | ||
1309 | if ( results ) { |
1310 | if ( results ) { |
1310 | results.push.apply( results, array ); |
1311 | results.push.apply( results, array ); |
1311 | return results; |
1312 | return results; |
1312 | }
|
1313 | }
|
1313 | 1314 | ||
1314 | return array; |
1315 | return array; |
1315 | }; |
1316 | }; |
1316 | 1317 | ||
1317 | // Perform a simple check to determine if the browser is capable of
|
1318 | // Perform a simple check to determine if the browser is capable of
|
1318 | // converting a NodeList to an array using builtin methods.
|
1319 | // converting a NodeList to an array using builtin methods.
|
Строка 1402... | Строка 1403... | ||
1402 | return elem.nodeType === 1 && node && node.nodeValue === match; |
1403 | return elem.nodeType === 1 && node && node.nodeValue === match; |
1403 | }; |
1404 | }; |
1404 | }
|
1405 | }
|
1405 | 1406 | ||
1406 | root.removeChild( form ); |
1407 | root.removeChild( form ); |
- | 1408 | root = form = null; // release memory in IE |
|
1407 | })(); |
1409 | })(); |
1408 | 1410 | ||
1409 | (function(){ |
1411 | (function(){ |
1410 | // Check to see if the browser returns only elements
|
1412 | // Check to see if the browser returns only elements
|
1411 | // when doing getElementsByTagName("*")
|
1413 | // when doing getElementsByTagName("*")
|
Строка 1442... | Строка 1444... | ||
1442 | div.firstChild.getAttribute("href") !== "#" ) { |
1444 | div.firstChild.getAttribute("href") !== "#" ) { |
1443 | Expr.attrHandle.href = function(elem){ |
1445 | Expr.attrHandle.href = function(elem){ |
1444 | return elem.getAttribute("href", 2); |
1446 | return elem.getAttribute("href", 2); |
1445 | }; |
1447 | }; |
1446 | }
|
1448 | }
|
- | 1449 | ||
- | 1450 | div = null; // release memory in IE |
|
1447 | })(); |
1451 | })(); |
1448 | 1452 | ||
1449 | if ( document.querySelectorAll ) (function(){ |
1453 | if ( document.querySelectorAll ) (function(){ |
1450 | var oldSizzle = Sizzle, div = document.createElement("div"); |
1454 | var oldSizzle = Sizzle, div = document.createElement("div"); |
1451 | div.innerHTML = "<p class='TEST'></p>"; |
1455 | div.innerHTML = "<p class='TEST'></p>"; |
Строка 1453... | Строка 1457... | ||
1453 | // Safari can't handle uppercase or unicode characters when
|
1457 | // Safari can't handle uppercase or unicode characters when
|
1454 | // in quirks mode.
|
1458 | // in quirks mode.
|
1455 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
1459 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
1456 | return; |
1460 | return; |
1457 | }
|
1461 | }
|
1458 | 1462 | ||
1459 | Sizzle = function(query, context, extra, seed){ |
1463 | Sizzle = function(query, context, extra, seed){ |
1460 | context = context || document; |
1464 | context = context || document; |
1461 | 1465 | ||
1462 | // Only use querySelectorAll on non-XML documents
|
1466 | // Only use querySelectorAll on non-XML documents
|
1463 | // (ID selectors don't work in non-HTML documents)
|
1467 | // (ID selectors don't work in non-HTML documents)
|
1464 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
1468 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
1465 | try { |
1469 | try { |
1466 | return makeArray( context.querySelectorAll(query), extra ); |
1470 | return makeArray( context.querySelectorAll(query), extra ); |
1467 | } catch(e){} |
1471 | } catch(e){} |
1468 | }
|
1472 | }
|
1469 | 1473 | ||
1470 | return oldSizzle(query, context, extra, seed); |
1474 | return oldSizzle(query, context, extra, seed); |
1471 | }; |
1475 | }; |
1472 | 1476 | ||
1473 | for ( var prop in oldSizzle ) { |
1477 | for ( var prop in oldSizzle ) { |
1474 | Sizzle[ prop ] = oldSizzle[ prop ]; |
1478 | Sizzle[ prop ] = oldSizzle[ prop ]; |
1475 | }
|
1479 | }
|
- | 1480 | ||
- | 1481 | div = null; // release memory in IE |
|
1476 | })(); |
1482 | })(); |
1477 | 1483 | ||
1478 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
1484 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
1479 | var div = document.createElement("div"); |
1485 | var div = document.createElement("div"); |
1480 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
1486 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
Строка 1493... | Строка 1499... | ||
1493 | Expr.find.CLASS = function(match, context, isXML) { |
1499 | Expr.find.CLASS = function(match, context, isXML) { |
1494 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
1500 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
1495 | return context.getElementsByClassName(match[1]); |
1501 | return context.getElementsByClassName(match[1]); |
1496 | }
|
1502 | }
|
1497 | }; |
1503 | }; |
- | 1504 | ||
- | 1505 | div = null; // release memory in IE |
|
1498 | })(); |
1506 | })(); |
1499 | 1507 | ||
1500 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1508 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1501 | var sibDir = dir == "previousSibling" && !isXML; |
1509 | var sibDir = dir == "previousSibling" && !isXML; |
1502 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1510 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
Строка 1920... | Строка 1928... | ||
1920 | removeClass: function( classNames ) { |
1928 | removeClass: function( classNames ) { |
1921 | jQuery.className.remove( this, classNames ); |
1929 | jQuery.className.remove( this, classNames ); |
1922 | }, |
1930 | }, |
1923 | 1931 | ||
1924 | toggleClass: function( classNames, state ) { |
1932 | toggleClass: function( classNames, state ) { |
- | 1933 | var type = typeof classNames; |
|
1925 | if( typeof state !== "boolean" ) |
1934 | if ( type === "string" ) { |
- | 1935 | // toggle individual class names
|
|
- | 1936 | var isBool = typeof state === "boolean", className, i = 0, |
|
- | 1937 | classNames = classNames.split( /\s+/ ); |
|
- | 1938 | while ( (className = classNames[ i++ ]) ) { |
|
- | 1939 | // check each className given, space seperated list
|
|
1926 | state = !jQuery.className.has( this, classNames ); |
1940 | state = isBool ? state : !jQuery.className.has( this, className ); |
1927 | jQuery.className[ state ? "add" : "remove" ]( this, classNames ); |
1941 | jQuery.className[ state ? "add" : "remove" ]( this, className ); |
- | 1942 | }
|
|
- | 1943 | } else if ( type === "undefined" || type === "boolean" ) { |
|
- | 1944 | if ( this.className ) { |
|
- | 1945 | // store className if set
|
|
- | 1946 | jQuery.data( this, "__className__", this.className ); |
|
- | 1947 | }
|
|
- | 1948 | // toggle whole className
|
|
- | 1949 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
|
- | 1950 | }
|
|
1928 | }
|
1951 | }
|
1929 | }, function(name, fn){ |
1952 | }, function(name, fn){ |
1930 | jQuery.fn[ name ] = function(){ |
1953 | jQuery.fn[ name ] = function(){ |
1931 | return this.each( fn, arguments ); |
1954 | return this.each( fn, arguments ); |
1932 | }; |
1955 | }; |
Строка 2387... | Строка 2410... | ||
2387 | */
|
2410 | */
|
2388 | jQuery.event = { |
2411 | jQuery.event = { |
2389 | 2412 | ||
2390 | // Bind an event to an element
|
2413 | // Bind an event to an element
|
2391 | // Original by Dean Edwards
|
2414 | // Original by Dean Edwards
|
2392 | add: function(elem, types, handler, data) { |
2415 | add: function( elem, types, handler, data ) { |
2393 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
2416 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2394 | return; |
2417 | return; |
- | 2418 | }
|
|
2395 | 2419 | ||
2396 | // For whatever reason, IE has trouble passing the window object
|
2420 | // For whatever reason, IE has trouble passing the window object
|
2397 | // around, causing it to be cloned in the process
|
2421 | // around, causing it to be cloned in the process
|
2398 | if ( elem.setInterval && elem != window ) |
2422 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
2399 | elem = window; |
2423 | elem = window; |
- | 2424 | }
|
|
2400 | 2425 | ||
2401 | // Make sure that the function being executed has a unique ID
|
2426 | // Make sure that the function being executed has a unique ID
|
2402 | if ( !handler.guid ) |
2427 | if ( !handler.guid ) { |
2403 | handler.guid = this.guid++; |
2428 | handler.guid = this.guid++; |
- | 2429 | }
|
|
2404 | 2430 | ||
2405 | // if data is passed, bind to handler
|
2431 | // if data is passed, bind to handler
|
2406 | if ( data !== undefined ) { |
2432 | if ( data !== undefined ) { |
2407 | // Create temporary function pointer to original handler
|
2433 | // Create temporary function pointer to original handler
|
2408 | var fn = handler; |
2434 | var fn = handler; |
Строка 2413... | Строка 2439... | ||
2413 | // Store data in unique handler
|
2439 | // Store data in unique handler
|
2414 | handler.data = data; |
2440 | handler.data = data; |
2415 | }
|
2441 | }
|
2416 | 2442 | ||
2417 | // Init the element's event structure
|
2443 | // Init the element's event structure
|
2418 | var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), |
2444 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
2419 | handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ |
2445 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
2420 | // Handle the second event of a trigger and when
|
2446 | // Handle the second event of a trigger and when
|
2421 | // an event is called after a page has unloaded
|
2447 | // an event is called after a page has unloaded
|
2422 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
2448 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
2423 | jQuery.event.handle.apply(arguments.callee.elem, arguments) : |
2449 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
2424 | undefined; |
2450 | undefined; |
2425 | }); |
2451 | }); |
2426 | // Add elem as a property of the handle function
|
2452 | // Add elem as a property of the handle function
|
2427 | // This is to prevent a memory leak with non-native
|
2453 | // This is to prevent a memory leak with non-native
|
2428 | // event in IE.
|
2454 | // event in IE.
|
2429 | handle.elem = elem; |
2455 | handle.elem = elem; |
2430 | 2456 | ||
2431 | // Handle multiple events separated by a space
|
2457 | // Handle multiple events separated by a space
|
2432 | // jQuery(...).bind("mouseover mouseout", fn);
|
2458 | // jQuery(...).bind("mouseover mouseout", fn);
|
2433 | jQuery.each(types.split(/\s+/), function(index, type) { |
2459 | types = types.split( /\s+/ ); |
- | 2460 | var type, i=0; |
|
- | 2461 | while ( (type = types[ i++ ]) ) { |
|
2434 | // Namespaced event handlers
|
2462 | // Namespaced event handlers
|
2435 | var namespaces = type.split("."); |
2463 | var namespaces = type.split("."); |
2436 | type = namespaces.shift(); |
2464 | type = namespaces.shift(); |
2437 | handler.type = namespaces.slice().sort().join("."); |
2465 | handler.type = namespaces.slice().sort().join("."); |
2438 | 2466 | ||
2439 | // Get the current list of functions bound to this event
|
2467 | // Get the current list of functions bound to this event
|
2440 | var handlers = events[type]; |
2468 | var handlers = events[ type ], |
- | 2469 | special = this.special[ type ] || {}; |
|
2441 | 2470 | ||
2442 | if ( jQuery.event.specialAll[type] ) |
2471 | if ( special.add ) { |
2443 | jQuery.event.specialAll[type].setup.call(elem, data, namespaces); |
2472 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
- | 2473 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
|
- | 2474 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
|
- | 2475 | handler = modifiedHandler; |
|
- | 2476 | }
|
|
- | 2477 | }
|
|
2444 | 2478 | ||
2445 | // Init the event handler queue
|
2479 | // Init the event handler queue
|
2446 | if (!handlers) { |
2480 | if ( !handlers ) { |
2447 | handlers = events[type] = {}; |
2481 | handlers = events[ type ] = {}; |
2448 | 2482 | ||
2449 | // Check for a special event handler
|
2483 | // Check for a special event handler
|
2450 | // Only use addEventListener/attachEvent if the special
|
2484 | // Only use addEventListener/attachEvent if the special
|
2451 | // events handler returns false
|
2485 | // events handler returns false
|
2452 | if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) { |
2486 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
2453 | // Bind the global event handler to the element
|
2487 | // Bind the global event handler to the element
|
2454 | if (elem.addEventListener) |
2488 | if ( elem.addEventListener ) { |
2455 | elem.addEventListener(type, handle, false); |
2489 | elem.addEventListener( type, handle, false ); |
2456 | else if (elem.attachEvent) |
2490 | } else if ( elem.attachEvent ) { |
2457 | elem.attachEvent("on" + type, handle); |
2491 | elem.attachEvent( "on" + type, handle ); |
- | 2492 | }
|
|
2458 | }
|
2493 | }
|
2459 | }
|
2494 | }
|
2460 | 2495 | ||
2461 | // Add the function to the element's handler list
|
2496 | // Add the function to the element's handler list
|
2462 | handlers[handler.guid] = handler; |
2497 | handlers[ handler.guid ] = handler; |
2463 | 2498 | ||
2464 | // Keep track of which events have been used, for global triggering
|
2499 | // Keep track of which events have been used, for global triggering
|
2465 | jQuery.event.global[type] = true; |
2500 | this.global[ type ] = true; |
2466 | }); |
2501 | }
|
2467 | 2502 | ||
2468 | // Nullify elem to prevent memory leaks in IE
|
2503 | // Nullify elem to prevent memory leaks in IE
|
2469 | elem = null; |
2504 | elem = null; |
2470 | }, |
2505 | }, |
2471 | 2506 | ||
2472 | guid: 1, |
2507 | guid: 1, |
2473 | global: {}, |
2508 | global: {}, |
2474 | 2509 | ||
2475 | // Detach an event or set of events from an element
|
2510 | // Detach an event or set of events from an element
|
2476 | remove: function(elem, types, handler) { |
2511 | remove: function( elem, types, handler ) { |
2477 | // don't do events on text and comment nodes
|
2512 | // don't do events on text and comment nodes
|
2478 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
2513 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2479 | return; |
2514 | return; |
- | 2515 | }
|
|
2480 | 2516 | ||
2481 | var events = jQuery.data(elem, "events"), ret, index; |
2517 | var events = jQuery.data( elem, "events" ), ret, type; |
2482 | 2518 | ||
2483 | if ( events ) { |
2519 | if ( events ) { |
2484 | // Unbind all events for the element
|
2520 | // Unbind all events for the element
|
2485 | if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") ) |
2521 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
2486 | for ( var type in events ) |
2522 | for ( type in events ) { |
2487 | this.remove( elem, type + (types || "") ); |
2523 | this.remove( elem, type + (types || "") ); |
- | 2524 | }
|
|
2488 | else { |
2525 | } else { |
2489 | // types is actually an event object here
|
2526 | // types is actually an event object here
|
2490 | if ( types.type ) { |
2527 | if ( types.type ) { |
2491 | handler = types.handler; |
2528 | handler = types.handler; |
2492 | types = types.type; |
2529 | types = types.type; |
2493 | }
|
2530 | }
|
2494 | 2531 | ||
2495 | // Handle multiple events seperated by a space
|
2532 | // Handle multiple events seperated by a space
|
2496 | // jQuery(...).unbind("mouseover mouseout", fn);
|
2533 | // jQuery(...).unbind("mouseover mouseout", fn);
|
2497 | jQuery.each(types.split(/\s+/), function(index, type){ |
2534 | types = types.split(/\s+/); |
- | 2535 | var i = 0; |
|
- | 2536 | while ( (type = types[ i++ ]) ) { |
|
2498 | // Namespaced event handlers
|
2537 | // Namespaced event handlers
|
2499 | var namespaces = type.split("."); |
2538 | var namespaces = type.split("."); |
2500 | type = namespaces.shift(); |
2539 | type = namespaces.shift(); |
- | 2540 | var all = !namespaces.length, |
|
2501 | var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
2541 | namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"), |
- | 2542 | special = this.special[ type ] || {}; |
|
2502 | 2543 | ||
2503 | if ( events[type] ) { |
2544 | if ( events[ type ] ) { |
2504 | // remove the given handler for the given type
|
2545 | // remove the given handler for the given type
|
2505 | if ( handler ) |
2546 | if ( handler ) { |
2506 | delete events[type][handler.guid]; |
2547 | delete events[ type ][ handler.guid ]; |
2507 | 2548 | ||
2508 | // remove all handlers for the given type
|
2549 | // remove all handlers for the given type
|
2509 | else
|
2550 | } else { |
2510 | for ( var handle in events[type] ) |
2551 | for ( var handle in events[ type ] ) { |
2511 | // Handle the removal of namespaced events
|
2552 | // Handle the removal of namespaced events
|
2512 | if ( namespace.test(events[type][handle].type) ) |
2553 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
2513 | delete events[type][handle]; |
2554 | delete events[ type ][ handle ]; |
- | 2555 | }
|
|
- | 2556 | }
|
|
- | 2557 | }
|
|
2514 | 2558 | ||
2515 | if ( jQuery.event.specialAll[type] ) |
2559 | if ( special.remove ) { |
2516 | jQuery.event.specialAll[type].teardown.call(elem, namespaces); |
2560 | special.remove.call( elem, namespaces ); |
- | 2561 | }
|
|
2517 | 2562 | ||
2518 | // remove generic event handler if no more handlers exist
|
2563 | // remove generic event handler if no more handlers exist
|
2519 | for ( ret in events[type] ) break; |
2564 | for ( ret in events[ type ] ) { |
- | 2565 | break; |
|
- | 2566 | }
|
|
2520 | if ( !ret ) { |
2567 | if ( !ret ) { |
2521 | if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) { |
2568 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
2522 | if (elem.removeEventListener) |
2569 | if ( elem.removeEventListener ) { |
2523 | elem.removeEventListener(type, jQuery.data(elem, "handle"), false); |
2570 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
2524 | else if (elem.detachEvent) |
2571 | } else if ( elem.detachEvent ) { |
2525 | elem.detachEvent("on" + type, jQuery.data(elem, "handle")); |
2572 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
- | 2573 | }
|
|
2526 | }
|
2574 | }
|
2527 | ret = null; |
2575 | ret = null; |
2528 | delete events[type]; |
2576 | delete events[ type ]; |
2529 | }
|
2577 | }
|
2530 | }
|
2578 | }
|
2531 | }); |
2579 | }
|
2532 | }
|
2580 | }
|
2533 | 2581 | ||
2534 | // Remove the expando if it's no longer used
|
2582 | // Remove the expando if it's no longer used
|
2535 | for ( ret in events ) break; |
2583 | for ( ret in events ) { |
- | 2584 | break; |
|
- | 2585 | }
|
|
2536 | if ( !ret ) { |
2586 | if ( !ret ) { |
2537 | var handle = jQuery.data( elem, "handle" ); |
2587 | var handle = jQuery.data( elem, "handle" ); |
- | 2588 | if ( handle ) { |
|
2538 | if ( handle ) handle.elem = null; |
2589 | handle.elem = null; |
- | 2590 | }
|
|
2539 | jQuery.removeData( elem, "events" ); |
2591 | jQuery.removeData( elem, "events" ); |
2540 | jQuery.removeData( elem, "handle" ); |
2592 | jQuery.removeData( elem, "handle" ); |
2541 | }
|
2593 | }
|
2542 | }
|
2594 | }
|
2543 | }, |
2595 | }, |
2544 | 2596 | ||
2545 | // bubbling is internal
|
2597 | // bubbling is internal
|
2546 | trigger: function( event, data, elem, bubbling ) { |
2598 | trigger: function( event, data, elem /*, bubbling */ ) { |
2547 | // Event object or event type
|
2599 | // Event object or event type
|
2548 | var type = event.type || event; |
2600 | var type = event.type || event, |
- | 2601 | bubbling = arguments[3]; |
|
2549 | 2602 | ||
2550 | if( !bubbling ){ |
2603 | if ( !bubbling ) { |
2551 | event = typeof event === "object" ? |
2604 | event = typeof event === "object" ? |
2552 | // jQuery.Event object
|
2605 | // jQuery.Event object
|
2553 | event[expando] ? event : |
2606 | event[expando] ? event : |
2554 | // Object literal
|
2607 | // Object literal
|
2555 | jQuery.extend( jQuery.Event(type), event ) : |
2608 | jQuery.extend( jQuery.Event(type), event ) : |
Строка 2564... | Строка 2617... | ||
2564 | // Handle a global trigger
|
2617 | // Handle a global trigger
|
2565 | if ( !elem ) { |
2618 | if ( !elem ) { |
2566 | // Don't bubble custom events when global (to avoid too much overhead)
|
2619 | // Don't bubble custom events when global (to avoid too much overhead)
|
2567 | event.stopPropagation(); |
2620 | event.stopPropagation(); |
2568 | // Only trigger if we've ever bound an event for it
|
2621 | // Only trigger if we've ever bound an event for it
|
2569 | if ( this.global[type] ) |
2622 | if ( this.global[ type ] ) { |
2570 | jQuery.each( jQuery.cache, function(){ |
2623 | jQuery.each( jQuery.cache, function() { |
2571 | if ( this.events && this.events[type] ) |
2624 | if ( this.events && this.events[type] ) { |
2572 | jQuery.event.trigger( event, data, this.handle.elem ); |
2625 | jQuery.event.trigger( event, data, this.handle.elem ); |
- | 2626 | }
|
|
2573 | }); |
2627 | }); |
- | 2628 | }
|
|
2574 | }
|
2629 | }
|
2575 | 2630 | ||
2576 | // Handle triggering a single element
|
2631 | // Handle triggering a single element
|
2577 | 2632 | ||
2578 | // don't do events on text and comment nodes
|
2633 | // don't do events on text and comment nodes
|
2579 | if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 ) |
2634 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
2580 | return undefined; |
2635 | return undefined; |
- | 2636 | }
|
|
2581 | 2637 | ||
2582 | // Clean up in case it is reused
|
2638 | // Clean up in case it is reused
|
2583 | event.result = undefined; |
2639 | event.result = undefined; |
2584 | event.target = elem; |
2640 | event.target = elem; |
2585 | 2641 | ||
2586 | // Clone the incoming data, if any
|
2642 | // Clone the incoming data, if any
|
2587 | data = jQuery.makeArray(data); |
2643 | data = jQuery.makeArray( data ); |
2588 | data.unshift( event ); |
2644 | data.unshift( event ); |
2589 | }
|
2645 | }
|
2590 | 2646 | ||
2591 | event.currentTarget = elem; |
2647 | event.currentTarget = elem; |
2592 | 2648 | ||
2593 | // Trigger the event, it is assumed that "handle" is a function
|
2649 | // Trigger the event, it is assumed that "handle" is a function
|
2594 | var handle = jQuery.data(elem, "handle"); |
2650 | var handle = jQuery.data( elem, "handle" ); |
2595 | if ( handle ) |
2651 | if ( handle ) { |
2596 | handle.apply( elem, data ); |
2652 | handle.apply( elem, data ); |
- | 2653 | }
|
|
2597 | 2654 | ||
2598 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
2655 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
2599 | if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) |
2656 | if ( (!elem[ type ] || (jQuery.nodeName(elem, 'a') && type === "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) { |
2600 | event.result = false; |
2657 | event.result = false; |
- | 2658 | }
|
|
2601 | 2659 | ||
2602 | // Trigger the native events (except for clicks on links)
|
2660 | // Trigger the native events (except for clicks on links)
|
2603 | if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) { |
2661 | if ( !bubbling && elem[ type ] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
2604 | this.triggered = true; |
2662 | this.triggered = true; |
2605 | try { |
2663 | try { |
2606 | elem[ type ](); |
2664 | elem[ type ](); |
2607 | // prevent IE from throwing an error for some hidden elements
|
2665 | // prevent IE from throwing an error for some hidden elements
|
2608 | } catch (e) {} |
2666 | } catch (e) {} |
Строка 2610... | Строка 2668... | ||
2610 | 2668 | ||
2611 | this.triggered = false; |
2669 | this.triggered = false; |
2612 | 2670 | ||
2613 | if ( !event.isPropagationStopped() ) { |
2671 | if ( !event.isPropagationStopped() ) { |
2614 | var parent = elem.parentNode || elem.ownerDocument; |
2672 | var parent = elem.parentNode || elem.ownerDocument; |
2615 | if ( parent ) |
2673 | if ( parent ) { |
2616 | jQuery.event.trigger(event, data, parent, true); |
2674 | jQuery.event.trigger( event, data, parent, true ); |
- | 2675 | }
|
|
2617 | }
|
2676 | }
|
2618 | }, |
2677 | }, |
2619 | 2678 | ||
2620 | handle: function(event) { |
2679 | handle: function( event ) { |
2621 | // returned undefined or false
|
2680 | // returned undefined or false
|
2622 | var all, handlers; |
2681 | var all, handlers; |
2623 | 2682 | ||
2624 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
2683 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
2625 | event.currentTarget = this; |
2684 | event.currentTarget = this; |
Строка 2631... | Строка 2690... | ||
2631 | // Cache this now, all = true means, any handler
|
2690 | // Cache this now, all = true means, any handler
|
2632 | all = !namespaces.length && !event.exclusive; |
2691 | all = !namespaces.length && !event.exclusive; |
2633 | 2692 | ||
2634 | var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
2693 | var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
2635 | 2694 | ||
2636 | handlers = ( jQuery.data(this, "events") || {} )[event.type]; |
2695 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
2637 | 2696 | ||
2638 | for ( var j in handlers ) { |
2697 | for ( var j in handlers ) { |
2639 | var handler = handlers[j]; |
2698 | var handler = handlers[ j ]; |
2640 | 2699 | ||
2641 | // Filter the functions by class
|
2700 | // Filter the functions by class
|
2642 | if ( all || namespace.test(handler.type) ) { |
2701 | if ( all || namespace.test(handler.type) ) { |
2643 | // Pass in a reference to the handler function itself
|
2702 | // Pass in a reference to the handler function itself
|
2644 | // So that we can later remove it
|
2703 | // So that we can later remove it
|
2645 | event.handler = handler; |
2704 | event.handler = handler; |
2646 | event.data = handler.data; |
2705 | event.data = handler.data; |
2647 | 2706 | ||
2648 | var ret = handler.apply(this, arguments); |
2707 | var ret = handler.apply( this, arguments ); |
2649 | 2708 | ||
2650 | if( ret !== undefined ){ |
2709 | if ( ret !== undefined ) { |
2651 | event.result = ret; |
2710 | event.result = ret; |
2652 | if ( ret === false ) { |
2711 | if ( ret === false ) { |
2653 | event.preventDefault(); |
2712 | event.preventDefault(); |
2654 | event.stopPropagation(); |
2713 | event.stopPropagation(); |
2655 | }
|
2714 | }
|
2656 | }
|
2715 | }
|
2657 | 2716 | ||
2658 | if( event.isImmediatePropagationStopped() ) |
2717 | if ( event.isImmediatePropagationStopped() ) { |
2659 | break; |
2718 | break; |
- | 2719 | }
|
|
2660 | 2720 | ||
2661 | }
|
2721 | }
|
2662 | }
|
2722 | }
|
2663 | }, |
2723 | }, |
2664 | 2724 | ||
2665 | 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(" "), |
2725 | 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(" "), |
2666 | 2726 | ||
2667 | fix: function(event) { |
2727 | fix: function( event ) { |
2668 | if ( event[expando] ) |
2728 | if ( event[ expando ] ) { |
2669 | return event; |
2729 | return event; |
- | 2730 | }
|
|
2670 | 2731 | ||
2671 | // store a copy of the original event object
|
2732 | // store a copy of the original event object
|
2672 | // and "clone" to set read-only properties
|
2733 | // and "clone" to set read-only properties
|
2673 | var originalEvent = event; |
2734 | var originalEvent = event; |
2674 | event = jQuery.Event( originalEvent ); |
2735 | event = jQuery.Event( originalEvent ); |
2675 | 2736 | ||
2676 | for ( var i = this.props.length, prop; i; ){ |
2737 | for ( var i = this.props.length, prop; i; ) { |
2677 | prop = this.props[ --i ]; |
2738 | prop = this.props[ --i ]; |
2678 | event[ prop ] = originalEvent[ prop ]; |
2739 | event[ prop ] = originalEvent[ prop ]; |
2679 | }
|
2740 | }
|
2680 | 2741 | ||
2681 | // Fix target property, if necessary
|
2742 | // Fix target property, if necessary
|
2682 | if ( !event.target ) |
2743 | if ( !event.target ) { |
2683 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
2744 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
- | 2745 | }
|
|
2684 | 2746 | ||
2685 | // check if target is a textnode (safari)
|
2747 | // check if target is a textnode (safari)
|
2686 | if ( event.target.nodeType == 3 ) |
2748 | if ( event.target.nodeType === 3 ) { |
2687 | event.target = event.target.parentNode; |
2749 | event.target = event.target.parentNode; |
- | 2750 | }
|
|
2688 | 2751 | ||
2689 | // Add relatedTarget, if necessary
|
2752 | // Add relatedTarget, if necessary
|
2690 | if ( !event.relatedTarget && event.fromElement ) |
2753 | if ( !event.relatedTarget && event.fromElement ) { |
2691 | event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; |
2754 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
- | 2755 | }
|
|
2692 | 2756 | ||
2693 | // Calculate pageX/Y if missing and clientX/Y available
|
2757 | // Calculate pageX/Y if missing and clientX/Y available
|
2694 | if ( event.pageX == null && event.clientX != null ) { |
2758 | if ( event.pageX == null && event.clientX != null ) { |
2695 | var doc = document.documentElement, body = document.body; |
2759 | var doc = document.documentElement, body = document.body; |
2696 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); |
2760 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
2697 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); |
2761 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
2698 | }
|
2762 | }
|
2699 | 2763 | ||
2700 | // Add which for key events
|
2764 | // Add which for key events
|
2701 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) |
2765 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
2702 | event.which = event.charCode || event.keyCode; |
2766 | event.which = event.charCode || event.keyCode; |
- | 2767 | }
|
|
2703 | 2768 | ||
2704 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2769 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2705 | if ( !event.metaKey && event.ctrlKey ) |
2770 | if ( !event.metaKey && event.ctrlKey ) { |
2706 | event.metaKey = event.ctrlKey; |
2771 | event.metaKey = event.ctrlKey; |
- | 2772 | }
|
|
2707 | 2773 | ||
2708 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
2774 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
2709 | // Note: button is not normalized, so don't use it
|
2775 | // Note: button is not normalized, so don't use it
|
2710 | if ( !event.which && event.button ) |
2776 | if ( !event.which && event.button ) { |
2711 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
2777 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
- | 2778 | }
|
|
2712 | 2779 | ||
2713 | return event; |
2780 | return event; |
2714 | }, |
2781 | }, |
2715 | 2782 | ||
2716 | proxy: function( fn, proxy ){ |
2783 | proxy: function( fn, proxy, thisObject ) { |
- | 2784 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
|
- | 2785 | thisObject = proxy; |
|
- | 2786 | proxy = undefined; |
|
- | 2787 | }
|
|
- | 2788 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
|
2717 | proxy = proxy || function(){ return fn.apply(this, arguments); }; |
2789 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
2718 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
2790 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
2719 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
2791 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
2720 | // So proxy can be declared as an argument
|
2792 | // So proxy can be declared as an argument
|
2721 | return proxy; |
2793 | return proxy; |
2722 | }, |
2794 | }, |
Строка 2724... | Строка 2796... | ||
2724 | special: { |
2796 | special: { |
2725 | ready: { |
2797 | ready: { |
2726 | // Make sure the ready event is setup
|
2798 | // Make sure the ready event is setup
|
2727 | setup: bindReady, |
2799 | setup: bindReady, |
2728 | teardown: function() {} |
2800 | teardown: function() {} |
2729 | }
|
- | |
2730 | }, |
2801 | }, |
2731 | 2802 | ||
2732 | specialAll: { |
- | |
2733 | live: { |
2803 | live: { |
2734 | setup: function( selector, namespaces ){ |
2804 | add: function( proxy, data, namespaces ) { |
- | 2805 | jQuery.extend( proxy, data || {} ); |
|
- | 2806 | proxy.guid += data.selector + data.live; |
|
2735 | jQuery.event.add( this, namespaces[0], liveHandler ); |
2807 | jQuery.event.add( this, data.live, liveHandler ); |
2736 | }, |
2808 | }, |
- | 2809 | ||
2737 | teardown: function( namespaces ){ |
2810 | remove: function( namespaces ) { |
2738 | if ( namespaces.length ) { |
2811 | if ( namespaces.length ) { |
2739 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
2812 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
2740 | 2813 | ||
2741 | jQuery.each( (jQuery.data(this, "events").live || {}), function(){ |
2814 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
2742 | if ( name.test(this.type) ) |
2815 | if ( name.test(this.type) ) { |
2743 | remove++;
|
2816 | remove++;
|
- | 2817 | }
|
|
2744 | }); |
2818 | }); |
2745 | 2819 | ||
2746 | if ( remove < 1 ) |
2820 | if ( remove < 1 ) { |
2747 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
2821 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
- | 2822 | }
|
|
2748 | }
|
2823 | }
|
2749 | }
|
2824 | }
|
2750 | }
|
2825 | }
|
2751 | }
|
2826 | }
|
2752 | }; |
2827 | }; |
2753 | 2828 | ||
2754 | jQuery.Event = function( src ){ |
2829 | jQuery.Event = function( src ){ |
2755 | // Allow instantiation without the 'new' keyword
|
2830 | // Allow instantiation without the 'new' keyword
|
2756 | if( !this.preventDefault ) |
2831 | if ( !this.preventDefault ) { |
2757 | return new jQuery.Event(src); |
2832 | return new jQuery.Event( src ); |
- | 2833 | }
|
|
2758 | 2834 | ||
2759 | // Event object
|
2835 | // Event object
|
2760 | if( src && src.type ){ |
2836 | if ( src && src.type ) { |
2761 | this.originalEvent = src; |
2837 | this.originalEvent = src; |
2762 | this.type = src.type; |
2838 | this.type = src.type; |
2763 | // Event type
|
2839 | // Event type
|
2764 | }else |
2840 | } else { |
2765 | this.type = src; |
2841 | this.type = src; |
- | 2842 | }
|
|
2766 | 2843 | ||
2767 | // timeStamp is buggy for some events on Firefox(#3843)
|
2844 | // timeStamp is buggy for some events on Firefox(#3843)
|
2768 | // So we won't rely on the native value
|
2845 | // So we won't rely on the native value
|
2769 | this.timeStamp = now(); |
2846 | this.timeStamp = now(); |
2770 | 2847 | ||
2771 | // Mark it as fixed
|
2848 | // Mark it as fixed
|
2772 | this[expando] = true; |
2849 | this[ expando ] = true; |
2773 | }; |
2850 | }; |
2774 | 2851 | ||
2775 | function returnFalse(){ |
2852 | function returnFalse() { |
2776 | return false; |
2853 | return false; |
2777 | }
|
2854 | }
|
2778 | function returnTrue(){ |
2855 | function returnTrue() { |
2779 | return true; |
2856 | return true; |
2780 | }
|
2857 | }
|
2781 | 2858 | ||
2782 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
2859 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
2783 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
2860 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
2784 | jQuery.Event.prototype = { |
2861 | jQuery.Event.prototype = { |
2785 | preventDefault: function() { |
2862 | preventDefault: function() { |
2786 | this.isDefaultPrevented = returnTrue; |
2863 | this.isDefaultPrevented = returnTrue; |
2787 | 2864 | ||
2788 | var e = this.originalEvent; |
2865 | var e = this.originalEvent; |
2789 | if( !e ) |
2866 | if ( !e ) { |
2790 | return; |
2867 | return; |
- | 2868 | }
|
|
2791 | // if preventDefault exists run it on the original event
|
2869 | // if preventDefault exists run it on the original event
|
2792 | if (e.preventDefault) |
2870 | if ( e.preventDefault ) { |
2793 | e.preventDefault(); |
2871 | e.preventDefault(); |
- | 2872 | }
|
|
2794 | // otherwise set the returnValue property of the original event to false (IE)
|
2873 | // otherwise set the returnValue property of the original event to false (IE)
|
2795 | e.returnValue = false; |
2874 | e.returnValue = false; |
2796 | }, |
2875 | }, |
2797 | stopPropagation: function() { |
2876 | stopPropagation: function() { |
2798 | this.isPropagationStopped = returnTrue; |
2877 | this.isPropagationStopped = returnTrue; |
2799 | 2878 | ||
2800 | var e = this.originalEvent; |
2879 | var e = this.originalEvent; |
2801 | if( !e ) |
2880 | if ( !e ) { |
2802 | return; |
2881 | return; |
- | 2882 | }
|
|
2803 | // if stopPropagation exists run it on the original event
|
2883 | // if stopPropagation exists run it on the original event
|
2804 | if (e.stopPropagation) |
2884 | if ( e.stopPropagation ) { |
2805 | e.stopPropagation(); |
2885 | e.stopPropagation(); |
- | 2886 | }
|
|
2806 | // otherwise set the cancelBubble property of the original event to true (IE)
|
2887 | // otherwise set the cancelBubble property of the original event to true (IE)
|
2807 | e.cancelBubble = true; |
2888 | e.cancelBubble = true; |
2808 | }, |
2889 | }, |
2809 | stopImmediatePropagation:function(){ |
2890 | stopImmediatePropagation: function(){ |
2810 | this.isImmediatePropagationStopped = returnTrue; |
2891 | this.isImmediatePropagationStopped = returnTrue; |
2811 | this.stopPropagation(); |
2892 | this.stopPropagation(); |
2812 | }, |
2893 | }, |
2813 | isDefaultPrevented: returnFalse, |
2894 | isDefaultPrevented: returnFalse, |
2814 | isPropagationStopped: returnFalse, |
2895 | isPropagationStopped: returnFalse, |
2815 | isImmediatePropagationStopped: returnFalse
|
2896 | isImmediatePropagationStopped: returnFalse
|
2816 | }; |
2897 | }; |
2817 | // Checks if an event happened on an element within another element
|
2898 | // Checks if an event happened on an element within another element
|
2818 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
2899 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
2819 | var withinElement = function(event) { |
2900 | var withinElement = function( event ) { |
2820 | // Check if mouse(over|out) are still within the same parent element
|
2901 | // Check if mouse(over|out) are still within the same parent element
|
2821 | var parent = event.relatedTarget; |
2902 | var parent = event.relatedTarget; |
2822 | // Traverse up the tree
|
2903 | // Traverse up the tree
|
2823 | while ( parent && parent != this ) |
2904 | while ( parent && parent != this ) { |
- | 2905 | // Firefox sometimes assigns relatedTarget a XUL element
|
|
- | 2906 | // which we cannot access the parentNode property of
|
|
2824 | try { parent = parent.parentNode; } |
2907 | try { parent = parent.parentNode; } |
- | 2908 | // assuming we've left the element since we most likely mousedover a xul element
|
|
2825 | catch(e) { parent = this; } |
2909 | catch(e) { break; } |
- | 2910 | }
|
|
2826 | 2911 | ||
2827 | if( parent != this ){ |
2912 | if ( parent != this ) { |
2828 | // set the correct event type
|
2913 | // set the correct event type
|
2829 | event.type = event.data; |
2914 | event.type = event.data; |
2830 | // handle event if we actually just moused on to a non sub-element
|
2915 | // handle event if we actually just moused on to a non sub-element
|
2831 | jQuery.event.handle.apply( this, arguments ); |
2916 | jQuery.event.handle.apply( this, arguments ); |
2832 | }
|
2917 | }
|
2833 | }; |
2918 | }; |
2834 | 2919 | ||
2835 | jQuery.each({ |
2920 | jQuery.each({ |
2836 | mouseover: 'mouseenter', |
2921 | mouseover: 'mouseenter', |
2837 | mouseout: 'mouseleave' |
2922 | mouseout: 'mouseleave' |
2838 | }, function( orig, fix ){ |
2923 | }, function( orig, fix ) { |
2839 | jQuery.event.special[ fix ] = { |
2924 | jQuery.event.special[ fix ] = { |
2840 | setup: function(){ |
2925 | setup: function(){ |
2841 | jQuery.event.add( this, orig, withinElement, fix ); |
2926 | jQuery.event.add( this, orig, withinElement, fix ); |
2842 | }, |
2927 | }, |
2843 | teardown: function(){ |
2928 | teardown: function(){ |
Строка 2845... | Строка 2930... | ||
2845 | }
|
2930 | }
|
2846 | }; |
2931 | }; |
2847 | }); |
2932 | }); |
2848 | 2933 | ||
2849 | jQuery.fn.extend({ |
2934 | jQuery.fn.extend({ |
2850 | bind: function( type, data, fn ) { |
2935 | bind: function( type, data, fn, thisObject ) { |
- | 2936 | if ( jQuery.isFunction( data ) ) { |
|
- | 2937 | if ( fn !== undefined ) { |
|
- | 2938 | thisObject = fn; |
|
- | 2939 | }
|
|
- | 2940 | fn = data; |
|
- | 2941 | data = undefined; |
|
- | 2942 | }
|
|
- | 2943 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
|
2851 | return type == "unload" ? this.one(type, data, fn) : this.each(function(){ |
2944 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
2852 | jQuery.event.add( this, type, fn || data, fn && data ); |
2945 | jQuery.event.add( this, type, fn, data ); |
2853 | }); |
2946 | }); |
2854 | }, |
2947 | }, |
2855 | 2948 | ||
2856 | one: function( type, data, fn ) { |
2949 | one: function( type, data, fn, thisObject ) { |
- | 2950 | if ( jQuery.isFunction( data ) ) { |
|
- | 2951 | if ( fn !== undefined ) { |
|
- | 2952 | thisObject = fn; |
|
- | 2953 | }
|
|
- | 2954 | fn = data; |
|
- | 2955 | data = undefined; |
|
- | 2956 | }
|
|
- | 2957 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
|
2857 | var one = jQuery.event.proxy( fn || data, function(event) { |
2958 | var one = jQuery.event.proxy( fn, function( event ) { |
2858 | jQuery(this).unbind(event, one); |
2959 | jQuery( this ).unbind( event, one ); |
2859 | return (fn || data).apply( this, arguments ); |
2960 | return fn.apply( this, arguments ); |
2860 | }); |
2961 | }); |
2861 | return this.each(function(){ |
2962 | return this.each(function() { |
2862 | jQuery.event.add( this, type, one, fn && data); |
2963 | jQuery.event.add( this, type, one, data ); |
2863 | }); |
2964 | }); |
2864 | }, |
2965 | }, |
2865 | 2966 | ||
2866 | unbind: function( type, fn ) { |
2967 | unbind: function( type, fn ) { |
2867 | return this.each(function(){ |
2968 | return this.each(function() { |
2868 | jQuery.event.remove( this, type, fn ); |
2969 | jQuery.event.remove( this, type, fn ); |
2869 | }); |
2970 | }); |
2870 | }, |
2971 | }, |
2871 | 2972 | ||
2872 | trigger: function( type, data ) { |
2973 | trigger: function( type, data ) { |
2873 | return this.each(function(){ |
2974 | return this.each(function() { |
2874 | jQuery.event.trigger( type, data, this ); |
2975 | jQuery.event.trigger( type, data, this ); |
2875 | }); |
2976 | }); |
2876 | }, |
2977 | }, |
2877 | 2978 | ||
2878 | triggerHandler: function( type, data ) { |
2979 | triggerHandler: function( type, data ) { |
2879 | if( this[0] ){ |
2980 | if ( this[0] ) { |
2880 | var event = jQuery.Event(type); |
2981 | var event = jQuery.Event( type ); |
2881 | event.preventDefault(); |
2982 | event.preventDefault(); |
2882 | event.stopPropagation(); |
2983 | event.stopPropagation(); |
2883 | jQuery.event.trigger( event, data, this[0] ); |
2984 | jQuery.event.trigger( event, data, this[0] ); |
2884 | return event.result; |
2985 | return event.result; |
2885 | }
|
2986 | }
|
Строка 2888... | Строка 2989... | ||
2888 | toggle: function( fn ) { |
2989 | toggle: function( fn ) { |
2889 | // Save reference to arguments for access in closure
|
2990 | // Save reference to arguments for access in closure
|
2890 | var args = arguments, i = 1; |
2991 | var args = arguments, i = 1; |
2891 | 2992 | ||
2892 | // link all the functions, so any of them can unbind this click handler
|
2993 | // link all the functions, so any of them can unbind this click handler
|
2893 | while( i < args.length ) |
2994 | while( i < args.length ) { |
2894 | jQuery.event.proxy( fn, args[i++] ); |
2995 | jQuery.event.proxy( fn, args[ i++ ] ); |
- | 2996 | }
|
|
2895 | 2997 | ||
2896 | return this.click( jQuery.event.proxy( fn, function(event) { |
2998 | return this.click( jQuery.event.proxy( fn, function( event ) { |
2897 | // Figure out which function to execute
|
2999 | // Figure out which function to execute
|
2898 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
3000 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
2899 | 3001 | ||
2900 | // Make sure that clicks stop
|
3002 | // Make sure that clicks stop
|
2901 | event.preventDefault(); |
3003 | event.preventDefault(); |
Строка 2903... | Строка 3005... | ||
2903 | // and execute the function
|
3005 | // and execute the function
|
2904 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
3006 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
2905 | })); |
3007 | })); |
2906 | }, |
3008 | }, |
2907 | 3009 | ||
2908 | hover: function(fnOver, fnOut) { |
3010 | hover: function( fnOver, fnOut ) { |
2909 | return this.mouseenter(fnOver).mouseleave(fnOut); |
3011 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
2910 | }, |
3012 | }, |
2911 | 3013 | ||
2912 | ready: function(fn) { |
3014 | ready: function( fn ) { |
2913 | // Attach the listeners
|
3015 | // Attach the listeners
|
2914 | bindReady(); |
3016 | bindReady(); |
2915 | 3017 | ||
2916 | // If the DOM is already ready
|
3018 | // If the DOM is already ready
|
2917 | if ( jQuery.isReady ) |
3019 | if ( jQuery.isReady ) { |
2918 | // Execute the function immediately
|
3020 | // Execute the function immediately
|
2919 | fn.call( document, jQuery ); |
3021 | fn.call( document, jQuery ); |
2920 | 3022 | ||
2921 | // Otherwise, remember the function for later
|
3023 | // Otherwise, remember the function for later
|
2922 | else
|
3024 | } else { |
2923 | // Add the function to the wait list
|
3025 | // Add the function to the wait list
|
2924 | jQuery.readyList.push( fn ); |
3026 | jQuery.readyList.push( fn ); |
- | 3027 | }
|
|
2925 | 3028 | ||
2926 | return this; |
3029 | return this; |
2927 | }, |
3030 | }, |
2928 | 3031 | ||
2929 | live: function( type, fn ){ |
3032 | live: function( type, data, fn, thisObject ) { |
2930 | var proxy = jQuery.event.proxy( fn ); |
3033 | if ( jQuery.isFunction( data ) ) { |
- | 3034 | if ( fn !== undefined ) { |
|
2931 | proxy.guid += this.selector + type; |
3035 | thisObject = fn; |
- | 3036 | }
|
|
- | 3037 | fn = data; |
|
- | 3038 | data = undefined; |
|
2932 | 3039 | }
|
|
2933 | jQuery( this.context ).bind( liveConvert(type, this.selector), this.selector, proxy ); |
3040 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
2934 | - | ||
- | 3041 | data: data, selector: this.selector, live: type |
|
- | 3042 | }, fn, thisObject ); |
|
2935 | return this; |
3043 | return this; |
2936 | }, |
3044 | }, |
2937 | 3045 | ||
2938 | die: function( type, fn ){ |
3046 | die: function( type, fn ) { |
2939 | jQuery( this.context ).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null ); |
3047 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
2940 | return this; |
3048 | return this; |
2941 | }
|
3049 | }
|
2942 | }); |
3050 | }); |
2943 | 3051 | ||
2944 | function liveHandler( event ){ |
3052 | function liveHandler( event ) { |
2945 | var check = new RegExp("(^|\\.)" + event.type + "(\\.|$)"), |
3053 | var stop = true, elems = [], args = arguments; |
2946 | stop = true, |
- | |
2947 | elems = []; |
- | |
2948 | 3054 | ||
2949 | jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){ |
3055 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
2950 | if ( check.test(fn.type) ) { |
3056 | if ( fn.live === event.type ) { |
2951 | var elem = jQuery(event.target).closest(fn.data)[0]; |
3057 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
2952 | if ( elem ) |
3058 | if ( elem ) { |
2953 | elems.push({ elem: elem, fn: fn }); |
3059 | elems.push({ elem: elem, fn: fn }); |
- | 3060 | }
|
|
2954 | }
|
3061 | }
|
2955 | }); |
3062 | }); |
2956 | 3063 | ||
2957 | elems.sort(function(a,b) { |
3064 | elems.sort(function( a, b ) { |
2958 | return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest"); |
3065 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
2959 | }); |
3066 | }); |
2960 | 3067 | ||
2961 | jQuery.each(elems, function(){ |
3068 | jQuery.each(elems, function() { |
2962 | event.currentTarget = this.elem; |
3069 | event.currentTarget = this.elem; |
- | 3070 | event.data = this.fn.data; |
|
2963 | if ( this.fn.call(this.elem, event, this.fn.data) === false ) |
3071 | if ( this.fn.apply( this.elem, args ) === false ) { |
2964 | return (stop = false); |
3072 | return (stop = false); |
- | 3073 | }
|
|
2965 | }); |
3074 | }); |
2966 | 3075 | ||
2967 | return stop; |
3076 | return stop; |
2968 | }
|
3077 | }
|
2969 | 3078 | ||
2970 | function liveConvert(type, selector){ |
3079 | function liveConvert( type, selector ) { |
2971 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
3080 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
2972 | }
|
3081 | }
|
2973 | 3082 | ||
2974 | jQuery.extend({ |
3083 | jQuery.extend({ |
2975 | isReady: false, |
3084 | isReady: false, |
Строка 2982... | Строка 3091... | ||
2982 | jQuery.isReady = true; |
3091 | jQuery.isReady = true; |
2983 | 3092 | ||
2984 | // If there are functions bound, to execute
|
3093 | // If there are functions bound, to execute
|
2985 | if ( jQuery.readyList ) { |
3094 | if ( jQuery.readyList ) { |
2986 | // Execute all of them
|
3095 | // Execute all of them
|
- | 3096 | var fn, i = 0; |
|
2987 | jQuery.each( jQuery.readyList, function(){ |
3097 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
2988 | this.call( document, jQuery ); |
3098 | fn.call( document, jQuery ); |
2989 | }); |
3099 | }
|
2990 | 3100 | ||
2991 | // Reset the list of functions
|
3101 | // Reset the list of functions
|
2992 | jQuery.readyList = null; |
3102 | jQuery.readyList = null; |
2993 | }
|
3103 | }
|
2994 | 3104 | ||
2995 | // Trigger any bound ready events
|
3105 | // Trigger any bound ready events
|
2996 | jQuery(document).triggerHandler("ready"); |
3106 | jQuery( document ).triggerHandler( "ready" ); |
2997 | }
|
3107 | }
|
2998 | }
|
3108 | }
|
2999 | }); |
3109 | }); |
3000 | 3110 | ||
3001 | var readyBound = false; |
3111 | var readyBound = false; |
3002 | 3112 | ||
3003 | function bindReady(){ |
3113 | function bindReady() { |
3004 | if ( readyBound ) return; |
3114 | if ( readyBound ) return; |
3005 | readyBound = true; |
3115 | readyBound = true; |
3006 | 3116 | ||
3007 | // Mozilla, Opera and webkit nightlies currently support this event
|
3117 | // Mozilla, Opera and webkit nightlies currently support this event
|
3008 | if ( document.addEventListener ) { |
3118 | if ( document.addEventListener ) { |
3009 | // Use the handy event callback
|
3119 | // Use the handy event callback
|
3010 | document.addEventListener( "DOMContentLoaded", function(){ |
3120 | document.addEventListener( "DOMContentLoaded", function() { |
3011 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
3121 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
3012 | jQuery.ready(); |
3122 | jQuery.ready(); |
3013 | }, false ); |
3123 | }, false ); |
3014 | 3124 | ||
3015 | // If IE event model is used
|
3125 | // If IE event model is used
|
3016 | } else if ( document.attachEvent ) { |
3126 | } else if ( document.attachEvent ) { |
3017 | // ensure firing before onload,
|
3127 | // ensure firing before onload,
|
3018 | // maybe late but safe also for iframes
|
3128 | // maybe late but safe also for iframes
|
3019 | document.attachEvent("onreadystatechange", function(){ |
3129 | document.attachEvent("onreadystatechange", function() { |
3020 | if ( document.readyState === "complete" ) { |
3130 | if ( document.readyState === "complete" ) { |
3021 | document.detachEvent( "onreadystatechange", arguments.callee ); |
3131 | document.detachEvent( "onreadystatechange", arguments.callee ); |
3022 | jQuery.ready(); |
3132 | jQuery.ready(); |
3023 | }
|
3133 | }
|
3024 | }); |
3134 | }); |
3025 | 3135 | ||
3026 | // If IE and not an iframe
|
3136 | // If IE and not an iframe
|
3027 | // continually check to see if the document is ready
|
3137 | // continually check to see if the document is ready
|
3028 | if ( document.documentElement.doScroll && window == window.top ) (function(){ |
3138 | if ( document.documentElement.doScroll && window === window.top ) (function() { |
3029 | if ( jQuery.isReady ) return; |
3139 | if ( jQuery.isReady ) { |
- | 3140 | return; |
|
- | 3141 | }
|
|
3030 | 3142 | ||
3031 | try { |
3143 | try { |
3032 | // If IE is used, use the trick by Diego Perini
|
3144 | // If IE is used, use the trick by Diego Perini
|
3033 | // http://javascript.nwbox.com/IEContentLoaded/
|
3145 | // http://javascript.nwbox.com/IEContentLoaded/
|
3034 | document.documentElement.doScroll("left"); |
3146 | document.documentElement.doScroll("left"); |
Строка 3046... | Строка 3158... | ||
3046 | jQuery.event.add( window, "load", jQuery.ready ); |
3158 | jQuery.event.add( window, "load", jQuery.ready ); |
3047 | }
|
3159 | }
|
3048 | 3160 | ||
3049 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
3161 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
3050 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
3162 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
3051 | "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){ |
3163 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
3052 | 3164 | ||
3053 | // Handle event binding
|
3165 | // Handle event binding
|
3054 | jQuery.fn[name] = function(fn){ |
3166 | jQuery.fn[ name ] = function( fn ) { |
3055 | return fn ? this.bind(name, fn) : this.trigger(name); |
3167 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
3056 | }; |
3168 | }; |
3057 | }); |
3169 | }); |
3058 | 3170 | ||
3059 | // Prevent memory leaks in IE
|
3171 | // Prevent memory leaks in IE
|
3060 | // And prevent errors on refresh with events like mouseover in other browsers
|
3172 | // And prevent errors on refresh with events like mouseover in other browsers
|
3061 | // Window isn't included so as not to unbind existing unload events
|
3173 | // Window isn't included so as not to unbind existing unload events
|
3062 | // More info:
|
3174 | // More info:
|
3063 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
3175 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
3064 | // - https://bugzilla.mozilla.org/show_bug.cgi?id=252542
|
3176 | // - https://bugzilla.mozilla.org/show_bug.cgi?id=252542
|
3065 | jQuery( window ).bind( 'unload', function(){ |
3177 | jQuery( window ).bind( 'unload', function() { |
3066 | for ( var id in jQuery.cache ) |
3178 | for ( var id in jQuery.cache ) { |
3067 | // Skip the window
|
3179 | // Skip the window
|
3068 | if ( id != 1 && jQuery.cache[ id ].handle ) |
3180 | if ( id != 1 && jQuery.cache[ id ].handle ) { |
3069 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
3181 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
- | 3182 | }
|
|
- | 3183 | }
|
|
3070 | }); |
3184 | }); |
3071 | (function(){ |
3185 | (function(){ |
3072 | 3186 | ||
3073 | jQuery.support = {}; |
3187 | jQuery.support = {}; |
3074 | 3188 | ||
Строка 3156... | Строка 3270... | ||
3156 | div.style.width = div.style.paddingLeft = "1px"; |
3270 | div.style.width = div.style.paddingLeft = "1px"; |
3157 | 3271 | ||
3158 | document.body.appendChild( div ); |
3272 | document.body.appendChild( div ); |
3159 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3273 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3160 | document.body.removeChild( div ).style.display = 'none'; |
3274 | document.body.removeChild( div ).style.display = 'none'; |
- | 3275 | div = null; |
|
3161 | }); |
3276 | }); |
- | 3277 | ||
- | 3278 | // release memory in IE
|
|
- | 3279 | root = script = div = all = a = null; |
|
3162 | })(); |
3280 | })(); |
3163 | 3281 | ||
3164 | jQuery.props = { |
3282 | jQuery.props = { |
3165 | "for": "htmlFor", |
3283 | "for": "htmlFor", |
3166 | "class": "className", |
3284 | "class": "className", |
Строка 3170... | Строка 3288... | ||
3170 | rowspan: "rowSpan", |
3288 | rowspan: "rowSpan", |
3171 | tabindex: "tabIndex" |
3289 | tabindex: "tabIndex" |
3172 | }; |
3290 | }; |
3173 | // exclude the following css properties to add px
|
3291 | // exclude the following css properties to add px
|
3174 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
3292 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
3175 | // cache defaultView
|
3293 | // cache check for defaultView.getComputedStyle
|
3176 | defaultView = document.defaultView || {}, |
3294 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
3177 | // normalize float css property
|
3295 | // normalize float css property
|
3178 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
3296 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
3179 | 3297 | ||
3180 | jQuery.fn.css = function( name, value ) { |
3298 | jQuery.fn.css = function( name, value ) { |
3181 | var options = name, isFunction = jQuery.isFunction( value ); |
3299 | var options = name, isFunction = jQuery.isFunction( value ); |
3182 | 3300 | ||
3183 | // ignore negative width and height values
|
- | |
3184 | if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 ) |
- | |
3185 | value = undefined; |
- | |
3186 | - | ||
3187 | if ( typeof name === "string" ) { |
3301 | if ( typeof name === "string" ) { |
3188 | // Are we setting the style?
|
3302 | // Are we setting the style?
|
3189 | if ( value === undefined ) { |
3303 | if ( value === undefined ) { |
3190 | return this.length ? |
3304 | return this.length ? |
3191 | jQuery.css( this[0], name ) : |
3305 | jQuery.css( this[0], name ) : |
Строка 3225... | Строка 3339... | ||
3225 | style: function( elem, name, value ) { |
3339 | style: function( elem, name, value ) { |
3226 | // don't set styles on text and comment nodes
|
3340 | // don't set styles on text and comment nodes
|
3227 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
3341 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
3228 | return undefined; |
3342 | return undefined; |
3229 | 3343 | ||
- | 3344 | // ignore negative width and height values #1599
|
|
- | 3345 | if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 ) |
|
- | 3346 | value = undefined; |
|
- | 3347 | ||
3230 | var style = elem.style || elem, set = value !== undefined; |
3348 | var style = elem.style || elem, set = value !== undefined; |
3231 | 3349 | ||
3232 | // IE uses filters for opacity
|
3350 | // IE uses filters for opacity
|
3233 | if ( !jQuery.support.opacity && name == "opacity" ) { |
3351 | if ( !jQuery.support.opacity && name == "opacity" ) { |
3234 | if ( set ) { |
3352 | if ( set ) { |
Строка 3310... | Строка 3428... | ||
3310 | name = styleFloat; |
3428 | name = styleFloat; |
3311 | 3429 | ||
3312 | if ( !force && style && style[ name ] ) { |
3430 | if ( !force && style && style[ name ] ) { |
3313 | ret = style[ name ]; |
3431 | ret = style[ name ]; |
3314 | 3432 | ||
3315 | } else if ( defaultView.getComputedStyle ) { |
3433 | } else if ( getComputedStyle ) { |
3316 | 3434 | ||
3317 | // Only "float" is needed here
|
3435 | // Only "float" is needed here
|
3318 | if ( /float/i.test( name ) ) |
3436 | if ( /float/i.test( name ) ) |
3319 | name = "float"; |
3437 | name = "float"; |
3320 | 3438 | ||
3321 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
3439 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
3322 | 3440 | ||
3323 | var computedStyle = defaultView.getComputedStyle( elem, null ); |
3441 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3324 | 3442 | ||
3325 | if ( computedStyle ) |
3443 | if ( computedStyle ) |
3326 | ret = computedStyle.getPropertyValue( name ); |
3444 | ret = computedStyle.getPropertyValue( name ); |
3327 | 3445 | ||
3328 | // We should always get a number back from opacity
|
3446 | // We should always get a number back from opacity
|
Строка 4326... | Строка 4444... | ||
4326 | }
|
4444 | }
|
4327 | }); |
4445 | }); |
4328 | if ( "getBoundingClientRect" in document.documentElement ) |
4446 | if ( "getBoundingClientRect" in document.documentElement ) |
4329 | jQuery.fn.offset = function() { |
4447 | jQuery.fn.offset = function() { |
4330 | var elem = this[0]; |
4448 | var elem = this[0]; |
4331 | if ( !elem ) return null; |
4449 | if ( !elem || !elem.ownerDocument ) return null; |
4332 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4450 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4333 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4451 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4334 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4452 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4335 | top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4453 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4336 | left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4454 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4337 | return { top: top, left: left }; |
4455 | return { top: top, left: left }; |
4338 | }; |
4456 | }; |
4339 | else
|
4457 | else
|
4340 | jQuery.fn.offset = function() { |
4458 | jQuery.fn.offset = function() { |
4341 | var elem = this[0]; |
4459 | var elem = this[0]; |
4342 | if ( !elem ) return null; |
4460 | if ( !elem || !elem.ownerDocument ) return null; |
4343 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4461 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4344 | jQuery.offset.initialize(); |
4462 | jQuery.offset.initialize(); |
4345 | 4463 | ||
4346 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4464 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4347 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4465 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
Строка 4354... | Строка 4472... | ||
4354 | computedStyle = defaultView.getComputedStyle(elem, null); |
4472 | computedStyle = defaultView.getComputedStyle(elem, null); |
4355 | top -= elem.scrollTop, left -= elem.scrollLeft; |
4473 | top -= elem.scrollTop, left -= elem.scrollLeft; |
4356 | if ( elem === offsetParent ) { |
4474 | if ( elem === offsetParent ) { |
4357 | top += elem.offsetTop, left += elem.offsetLeft; |
4475 | top += elem.offsetTop, left += elem.offsetLeft; |
4358 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
4476 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
4359 | top += parseFloat( computedStyle.borderTopWidth, 10) || 0, |
4477 | top += parseFloat( computedStyle.borderTopWidth ) || 0, |
4360 | left += parseFloat( computedStyle.borderLeftWidth, 10) || 0; |
4478 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4361 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4479 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4362 | }
|
4480 | }
|
4363 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
4481 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
4364 | top += parseFloat( computedStyle.borderTopWidth, 10) || 0, |
4482 | top += parseFloat( computedStyle.borderTopWidth ) || 0, |
4365 | left += parseFloat( computedStyle.borderLeftWidth, 10) || 0; |
4483 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4366 | prevComputedStyle = computedStyle; |
4484 | prevComputedStyle = computedStyle; |
4367 | }
|
4485 | }
|
4368 | 4486 | ||
4369 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
4487 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
4370 | top += body.offsetTop, |
4488 | top += body.offsetTop, |
4371 | left += body.offsetLeft; |
4489 | left += body.offsetLeft; |
4372 | 4490 | ||
4373 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) |
4491 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) |
4374 | top += Math.max(docElem.scrollTop, body.scrollTop), |
4492 | top += Math.max( docElem.scrollTop, body.scrollTop ), |
4375 | left += Math.max(docElem.scrollLeft, body.scrollLeft); |
4493 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
4376 | 4494 | ||
4377 | return { top: top, left: left }; |
4495 | return { top: top, left: left }; |
4378 | }; |
4496 | }; |
4379 | 4497 | ||
4380 | jQuery.offset = { |
4498 | jQuery.offset = { |
4381 | initialize: function() { |
4499 | initialize: function() { |
4382 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = parseFloat(jQuery.curCSS(body, 'marginTop', true), 10) || 0, |
4500 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4383 | 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>'; |
4501 | 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>'; |
4384 | 4502 | ||
4385 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4503 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4386 | 4504 | ||
4387 | container.innerHTML = html; |
4505 | container.innerHTML = html; |
4388 | body.insertBefore(container, body.firstChild); |
4506 | body.insertBefore( container, body.firstChild ); |
4389 | innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
4507 | innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
4390 | 4508 | ||
4391 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4509 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4392 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4510 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4393 | 4511 | ||
4394 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
4512 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
4395 | this.supportsFixedPosition = (checkDiv.offsetTop >= 15); // safari subtracts parent border width here which is 5px |
4513 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); // safari subtracts parent border width here which is 5px |
4396 | checkDiv.style.position = '', checkDiv.style.top = ''; |
4514 | checkDiv.style.position = '', checkDiv.style.top = ''; |
4397 | 4515 | ||
4398 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4516 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4399 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4517 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4400 | 4518 | ||
4401 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4519 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4402 | 4520 | ||
4403 | body.removeChild(container); |
4521 | body.removeChild( container ); |
4404 | jQuery.offset.initialize = function(){}; |
4522 | jQuery.offset.initialize = function(){}; |
- | 4523 | ||
- | 4524 | body = container = innerDiv = checkDiv = table = td = null; |
|
4405 | }, |
4525 | }, |
4406 | 4526 | ||
4407 | bodyOffset: function(body) { |
4527 | bodyOffset: function(body) { |
4408 | jQuery.offset.initialize(); |
4528 | jQuery.offset.initialize(); |
4409 | var top = body.offsetTop, left = body.offsetLeft; |
4529 | var top = body.offsetTop, left = body.offsetLeft; |
4410 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
4530 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
4411 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0, |
4531 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4412 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0; |
4532 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
4413 | return { top: top, left: left }; |
4533 | return { top: top, left: left }; |
4414 | }
|
4534 | }
|
4415 | }; |
4535 | }; |
4416 | 4536 | ||
4417 | 4537 | ||
4418 | jQuery.fn.extend({ |
4538 | jQuery.fn.extend({ |
4419 | position: function() { |
4539 | position: function() { |
4420 | if ( !this[0] ) return null; |
4540 | if ( !this[0] ) return null; |
4421 | 4541 | ||
4422 | var elem = this[0], left = 0, top = 0, results, |
4542 | var elem = this[0], |
4423 | 4543 | ||
4424 | // Get *real* offsetParent
|
4544 | // Get *real* offsetParent
|
4425 | offsetParent = this.offsetParent(), |
4545 | offsetParent = this.offsetParent(), |
4426 | 4546 | ||
4427 | // Get correct offsets
|
4547 | // Get correct offsets
|
Строка 4429... | Строка 4549... | ||
4429 | parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4549 | parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4430 | 4550 | ||
4431 | // Subtract element margins
|
4551 | // Subtract element margins
|
4432 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4552 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4433 | // are the same in Safari causing offset.left to incorrectly be 0
|
4553 | // are the same in Safari causing offset.left to incorrectly be 0
|
4434 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true), 10 ) || 0; |
4554 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
4435 | offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true), 10 ) || 0; |
4555 | offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; |
4436 | 4556 | ||
4437 | // Add offsetParent borders
|
4557 | // Add offsetParent borders
|
4438 | parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true), 10 ) || 0; |
4558 | parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; |
4439 | parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true), 10 ) || 0; |
4559 | parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; |
4440 | 4560 | ||
4441 | // Subtract the two offsets
|
4561 | // Subtract the two offsets
|
4442 | results = { |
4562 | return { |
4443 | top: offset.top - parentOffset.top, |
4563 | top: offset.top - parentOffset.top, |
4444 | left: offset.left - parentOffset.left |
4564 | left: offset.left - parentOffset.left |
4445 | }; |
4565 | }; |
4446 | - | ||
4447 | return results; |
- | |
4448 | }, |
4566 | }, |
4449 | 4567 | ||
4450 | offsetParent: function() { |
4568 | offsetParent: function() { |
4451 | var offsetParent = this[0].offsetParent || document.body; |
4569 | var offsetParent = this[0].offsetParent || document.body; |
4452 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') ) |
4570 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') === 'static') ) |
4453 | offsetParent = offsetParent.offsetParent; |
4571 | offsetParent = offsetParent.offsetParent; |
4454 | return jQuery(offsetParent); |
4572 | return jQuery( offsetParent ); |
4455 | }
|
4573 | }
|
4456 | }); |
4574 | }); |
4457 | 4575 | ||
4458 | 4576 | ||
4459 | // Create scrollLeft and scrollTop methods
|
4577 | // Create scrollLeft and scrollTop methods
|
4460 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4578 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4461 | var method = 'scroll' + name; |
4579 | var method = 'scroll' + name; |
4462 | 4580 | ||
4463 | jQuery.fn[ method ] = function(val) { |
4581 | jQuery.fn[ method ] = function(val) { |
4464 | if ( !this[0] ) return null; |
4582 | if ( !this[0] ) return null; |
- | 4583 | ||
- | 4584 | var elem = this[0], win = ("scrollTo" in elem && elem.document) ? elem : |
|
- | 4585 | (elem.nodeName === "#document") ? elem.defaultView || elem.parentWindow : |
|
- | 4586 | false; |
|
4465 | 4587 | ||
4466 | return val !== undefined ? |
4588 | return val !== undefined ? |
4467 | 4589 | ||
4468 | // Set the scroll offset
|
4590 | // Set the scroll offset
|
4469 | this.each(function() { |
4591 | this.each(function() { |
4470 | this == window || this == document ? |
4592 | win = ("scrollTo" in this && this.document) ? this : |
- | 4593 | (this.nodeName === "#document") ? this.defaultView || this.parentWindow : |
|
- | 4594 | false; |
|
- | 4595 | ||
- | 4596 | win ?
|
|
4471 | window.scrollTo( |
4597 | win.scrollTo( |
4472 | !i ? val : jQuery(window).scrollLeft(), |
4598 | !i ? val : jQuery(win).scrollLeft(), |
4473 | i ? val : jQuery(window).scrollTop() |
4599 | i ? val : jQuery(win).scrollTop() |
4474 | ) : |
4600 | ) : |
4475 | this[ method ] = val; |
4601 | this[ method ] = val; |
4476 | }) : |
4602 | }) : |
4477 | 4603 | ||
4478 | // Return the scroll offset
|
4604 | // Return the scroll offset
|
4479 | this[0] == window || this[0] == document ? |
4605 | win ?
|
4480 | self[ i ? 'pageYOffset' : 'pageXOffset' ] || |
4606 | win[ i ? 'pageYOffset' : 'pageXOffset' ] || |
4481 | jQuery.boxModel && document.documentElement[ method ] || |
4607 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4482 | document.body[ method ] : |
4608 | win.document.body[ method ] : |
4483 | this[0][ method ]; |
4609 | elem[ method ]; |
4484 | }; |
4610 | }; |
4485 | }); |
4611 | }); |
4486 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4612 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4487 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4613 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4488 | 4614 | ||
Строка 4502... | Строка 4628... | ||
4502 | null; |
4628 | null; |
4503 | }; |
4629 | }; |
4504 | 4630 | ||
4505 | jQuery.fn[ type ] = function( size ) { |
4631 | jQuery.fn[ type ] = function( size ) { |
4506 | // Get window width or height
|
4632 | // Get window width or height
|
4507 | return this[0] == window ? |
4633 | var elem = this[0]; |
- | 4634 | if ( !elem ) return null; |
|
- | 4635 | return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
|
4508 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4636 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4509 | document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || |
4637 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4510 | document.body[ "client" + name ] : |
4638 | elem.document.body[ "client" + name ] : |
4511 | 4639 | ||
4512 | // Get document width or height
|
4640 | // Get document width or height
|
4513 | this[0] == document ? |
4641 | (elem.nodeName === "#document") ? // is it a document |
4514 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4642 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4515 | Math.max( |
4643 | Math.max( |
4516 | document.documentElement["client" + name], |
4644 | elem.documentElement["client" + name], |
4517 | document.body["scroll" + name], document.documentElement["scroll" + name], |
4645 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4518 | document.body["offset" + name], document.documentElement["offset" + name] |
4646 | elem.body["offset" + name], elem.documentElement["offset" + name] |
4519 | ) : |
4647 | ) : |
4520 | 4648 | ||
4521 | // Get or set width or height on the element
|
4649 | // Get or set width or height on the element
|
4522 | size === undefined ? |
4650 | size === undefined ? |
4523 | // Get width or height on the element
|
4651 | // Get width or height on the element
|
4524 | (this.length ? jQuery.css( this[0], type ) : null) : |
4652 | jQuery.css( elem, type ) : |
4525 | 4653 | ||
4526 | // Set the width or height on the element (default to pixels if value is unitless)
|
4654 | // Set the width or height on the element (default to pixels if value is unitless)
|
4527 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4655 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4528 | }; |
4656 | }; |
4529 | 4657 |