Редакция 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 | }, |
Строка 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 | ||
Строка 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>"; |
Строка 1471... | Строка 1475... | ||
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 | }; |
Строка 2388... | Строка 2411... | ||
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; |
Строка 2428... | Строка 2454... | ||
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 ); |
2458 | }
|
2492 | }
|
2459 | }
|
2493 | }
|
- | 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 | ||
Строка 2473... | Строка 2508... | ||
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" ) ); |
2526 | }
|
2573 | }
|
- | 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 : |
Строка 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 | }); |
2574 | }
|
2628 | }
|
- | 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 | ||
Строка 2590... | Строка 2646... | ||
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 ); |
2617 | }
|
2675 | }
|
- | 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; |
Строка 2653... | Строка 2712... | ||
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 ); |
Строка 2677... | Строка 2738... | ||
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 ); |
2748 | }
|
2822 | }
|
2749 | }
|
2823 | }
|
2750 | }
|
2824 | }
|
2751 | }
|
2825 | }
|
- | 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 | ||
Строка 2784... | Строка 2861... | ||
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; |
Строка 2818... | Строка 2899... | ||
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
|
Строка 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() { |
Строка 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 | ||
Строка 2904... | Строка 3006... | ||
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 }); |
2954 | }
|
3060 | }
|
- | 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 | ||
Строка 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 | ||
Строка 3023... | Строка 3133... | ||
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"); |
Строка 3061... | Строка 3173... | ||
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, |
Строка 4377... | Строка 4495... | ||
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; |
Строка 4390... | Строка 4508... | ||
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 | ||
Строка 4461... | Строка 4579... | ||
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; |
4465 | 4583 | ||
- | 4584 | var elem = this[0], win = ("scrollTo" in elem && elem.document) ? elem : |
|
- | 4585 | (elem.nodeName === "#document") ? elem.defaultView || elem.parentWindow : |
|
- | 4586 | false; |
|
- | 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 |