Редакция 290 | Весь файл | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 290 | Редакция 293 | ||
---|---|---|---|
Строка 1... | Строка 1... | ||
1 | /*!
|
1 | /*!
|
2 | * jQuery JavaScript Library v1.3.3pre
|
2 | * jQuery JavaScript Library v1.4pre
|
3 | * http://jquery.com/
|
3 | * http://jquery.com/
|
4 | *
|
4 | *
|
5 | * Copyright (c) 2009 John Resig
|
5 | * Copyright (c) 2009 John Resig
|
6 | * Dual licensed under the MIT and GPL licenses.
|
6 | * Dual licensed under the MIT and GPL licenses.
|
7 | * http://docs.jquery.com/License
|
7 | * http://docs.jquery.com/License
|
8 | *
|
8 | *
|
9 | * Date: 2009-07-28 03:48:42 +0700 (Втр, 28 Июл 2009)
|
9 | * Date: 2009-10-12 23:26:01 +0700 (Пнд, 12 Окт 2009)
|
10 | * Revision: 6514
|
10 | * Revision: 6617
|
11 | */
|
11 | */
|
12 | (function(window, undefined){ |
12 | (function(window, undefined){ |
13 | 13 | ||
14 | // Define a local copy of jQuery
|
14 | // Define a local copy of jQuery
|
15 | var jQuery = function( selector, context ) { |
15 | var jQuery = function( selector, context ) { |
Строка 42... | Строка 42... | ||
42 | rnotwhite = /\S/, |
42 | rnotwhite = /\S/, |
43 | 43 | ||
44 | // Used for trimming whitespace
|
44 | // Used for trimming whitespace
|
45 | rtrim = /^\s+|\s+$/g, |
45 | rtrim = /^\s+|\s+$/g, |
46 | 46 | ||
- | 47 | // Match a standalone tag
|
|
- | 48 | rsingleTag = /^<(\w+)\s*\/?>$/, |
|
- | 49 | ||
47 | // Keep a UserAgent string for use with jQuery.browser
|
50 | // Keep a UserAgent string for use with jQuery.browser
|
48 | userAgent = navigator.userAgent.toLowerCase(), |
51 | userAgent = navigator.userAgent.toLowerCase(), |
49 | 52 | ||
50 | // Save a reference to some core methods
|
53 | // Save a reference to some core methods
|
51 | toString = Object.prototype.toString, |
54 | toString = Object.prototype.toString, |
52 | push = Array.prototype.push, |
55 | push = Array.prototype.push, |
53 | slice = Array.prototype.slice; |
56 | slice = Array.prototype.slice, |
54 | - | ||
55 | // Expose jQuery to the global object
|
- | |
56 | window.jQuery = window.$ = jQuery; |
57 | indexOf = Array.prototype.indexOf; |
57 | 58 | ||
58 | jQuery.fn = jQuery.prototype = { |
59 | jQuery.fn = jQuery.prototype = { |
59 | init: function( selector, context ) { |
60 | init: function( selector, context ) { |
60 | var match, elem, ret; |
61 | var match, elem, ret, doc; |
61 | 62 | ||
62 | // Handle $(""), $(null), or $(undefined)
|
63 | // Handle $(""), $(null), or $(undefined)
|
63 | if ( !selector ) { |
64 | if ( !selector ) { |
64 | return this; |
65 | return this; |
65 | }
|
66 | }
|
Строка 79... | Строка 80... | ||
79 | // Verify a match, and that no context was specified for #id
|
80 | // Verify a match, and that no context was specified for #id
|
80 | if ( match && (match[1] || !context) ) { |
81 | if ( match && (match[1] || !context) ) { |
81 | 82 | ||
82 | // HANDLE: $(html) -> $(array)
|
83 | // HANDLE: $(html) -> $(array)
|
83 | if ( match[1] ) { |
84 | if ( match[1] ) { |
- | 85 | doc = (context ? context.ownerDocument || context : document); |
|
- | 86 | ||
- | 87 | // If a single string is passed in and it's a single tag
|
|
- | 88 | // just do a createElement and skip the rest
|
|
- | 89 | ret = rsingleTag.exec( selector ); |
|
- | 90 | ||
- | 91 | if ( ret ) { |
|
- | 92 | selector = [ doc.createElement( ret[1] ) ]; |
|
- | 93 | ||
- | 94 | } else { |
|
84 | selector = jQuery.clean( [ match[1] ], context ); |
95 | ret = buildFragment( [ match[1] ], [ doc ] ); |
- | 96 | selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
|
- | 97 | }
|
|
85 | 98 | ||
86 | // HANDLE: $("#id")
|
99 | // HANDLE: $("#id")
|
87 | } else { |
100 | } else { |
88 | elem = document.getElementById( match[2] ); |
101 | elem = document.getElementById( match[2] ); |
89 | 102 | ||
Строка 102... | Строка 115... | ||
102 | this.context = document; |
115 | this.context = document; |
103 | this.selector = selector; |
116 | this.selector = selector; |
104 | return this; |
117 | return this; |
105 | }
|
118 | }
|
106 | 119 | ||
- | 120 | // HANDLE: $("TAG")
|
|
- | 121 | } else if ( !context && /^\w+$/.test( selector ) ) { |
|
- | 122 | this.selector = selector; |
|
- | 123 | this.context = document; |
|
- | 124 | selector = document.getElementsByTagName( selector ); |
|
- | 125 | ||
107 | // HANDLE: $(expr, $(...))
|
126 | // HANDLE: $(expr, $(...))
|
108 | } else if ( !context || context.jquery ) { |
127 | } else if ( !context || context.jquery ) { |
109 | return (context || rootjQuery).find( selector ); |
128 | return (context || rootjQuery).find( selector ); |
110 | 129 | ||
111 | // HANDLE: $(expr, context)
|
130 | // HANDLE: $(expr, context)
|
Строка 118... | Строка 137... | ||
118 | // Shortcut for document ready
|
137 | // Shortcut for document ready
|
119 | } else if ( jQuery.isFunction( selector ) ) { |
138 | } else if ( jQuery.isFunction( selector ) ) { |
120 | return rootjQuery.ready( selector ); |
139 | return rootjQuery.ready( selector ); |
121 | }
|
140 | }
|
122 | 141 | ||
123 | // Make sure that old selector state is passed along
|
- | |
124 | if ( selector.selector && selector.context ) { |
142 | if (selector.selector !== undefined) { |
125 | this.selector = selector.selector; |
143 | this.selector = selector.selector; |
126 | this.context = selector.context; |
144 | this.context = selector.context; |
127 | }
|
145 | }
|
128 | 146 | ||
129 | return this.setArray(jQuery.isArray( selector ) ? |
147 | return this.setArray(jQuery.isArray( selector ) ? |
Строка 133... | Строка 151... | ||
133 | 151 | ||
134 | // Start with an empty selector
|
152 | // Start with an empty selector
|
135 | selector: "", |
153 | selector: "", |
136 | 154 | ||
137 | // The current version of jQuery being used
|
155 | // The current version of jQuery being used
|
138 | jquery: "1.3.3pre", |
156 | jquery: "1.4pre", |
139 | 157 | ||
140 | // The default length of a jQuery object is 0
|
158 | // The default length of a jQuery object is 0
|
141 | length: 0, |
159 | length: 0, |
142 | 160 | ||
143 | // The number of elements contained in the matched element set
|
161 | // The number of elements contained in the matched element set
|
Строка 330... | Строка 348... | ||
330 | 348 | ||
331 | // check if an element is in a (or is an) XML document
|
349 | // check if an element is in a (or is an) XML document
|
332 | isXMLDoc: function( elem ) { |
350 | isXMLDoc: function( elem ) { |
333 | // documentElement is verified for cases where it doesn't yet exist
|
351 | // documentElement is verified for cases where it doesn't yet exist
|
334 | // (such as loading iframes in IE - #4833)
|
352 | // (such as loading iframes in IE - #4833)
|
- | 353 | var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
|
335 | return ((elem.ownerDocument || elem).documentElement || 0).nodeName !== "HTML"; |
354 | return documentElement ? documentElement.nodeName !== "HTML" : false; |
336 | }, |
355 | }, |
337 | 356 | ||
338 | // Evalulates a script in a global context
|
357 | // Evalulates a script in a global context
|
339 | globalEval: function( data ) { |
358 | globalEval: function( data ) { |
340 | if ( data && rnotwhite.test(data) ) { |
359 | if ( data && rnotwhite.test(data) ) { |
Строка 454... | Строка 473... | ||
454 | }
|
473 | }
|
455 | 474 | ||
456 | return first; |
475 | return first; |
457 | }, |
476 | }, |
458 | 477 | ||
459 | unique: function( array ) { |
- | |
460 | var ret = [], done = {}, id; |
- | |
461 | - | ||
462 | try { |
- | |
463 | for ( var i = 0, length = array.length; i < length; i++ ) { |
- | |
464 | id = jQuery.data( array[ i ] ); |
- | |
465 | - | ||
466 | if ( !done[ id ] ) { |
- | |
467 | done[ id ] = true; |
- | |
468 | ret.push( array[ i ] ); |
- | |
469 | }
|
- | |
470 | }
|
- | |
471 | } catch( e ) { |
- | |
472 | ret = array; |
- | |
473 | }
|
- | |
474 | - | ||
475 | return ret; |
- | |
476 | }, |
- | |
477 | - | ||
478 | grep: function( elems, callback, inv ) { |
478 | grep: function( elems, callback, inv ) { |
479 | var ret = []; |
479 | var ret = []; |
480 | 480 | ||
481 | // Go through the array, only saving the items
|
481 | // Go through the array, only saving the items
|
482 | // that pass the validator function
|
482 | // that pass the validator function
|
Строка 515... | Строка 515... | ||
515 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
515 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
516 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
516 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
517 | }
|
517 | }
|
518 | }); |
518 | }); |
519 | 519 | ||
- | 520 | if ( indexOf ) { |
|
- | 521 | jQuery.inArray = function( elem, array ) { |
|
- | 522 | return indexOf.call( array, elem ); |
|
- | 523 | }; |
|
- | 524 | }
|
|
- | 525 | ||
520 | // All jQuery objects should point back to these
|
526 | // All jQuery objects should point back to these
|
521 | rootjQuery = jQuery(document); |
527 | rootjQuery = jQuery(document); |
522 | 528 | ||
523 | function evalScript( i, elem ) { |
529 | function evalScript( i, elem ) { |
524 | if ( elem.src ) { |
530 | if ( elem.src ) { |
Строка 534... | Строка 540... | ||
534 | if ( elem.parentNode ) { |
540 | if ( elem.parentNode ) { |
535 | elem.parentNode.removeChild( elem ); |
541 | elem.parentNode.removeChild( elem ); |
536 | }
|
542 | }
|
537 | }
|
543 | }
|
538 | 544 | ||
- | 545 | // Mutifunctional method to get and set values to a collection
|
|
- | 546 | // The value/s can be optionally by executed if its a function
|
|
- | 547 | function access( elems, key, value, exec, fn ) { |
|
- | 548 | var l = elems.length; |
|
- | 549 | ||
- | 550 | // Setting many attributes
|
|
- | 551 | if ( typeof key === "object" ) { |
|
- | 552 | for (var k in key) { |
|
- | 553 | access(elems, k, key[k], exec, fn); |
|
- | 554 | }
|
|
- | 555 | return elems; |
|
- | 556 | }
|
|
- | 557 | ||
- | 558 | // Setting one attribute
|
|
- | 559 | if (value !== undefined) { |
|
- | 560 | // Optionally, function values get executed if exec is true
|
|
- | 561 | exec = exec && jQuery.isFunction(value); |
|
- | 562 | ||
- | 563 | for (var i = 0; i < l; i++) { |
|
- | 564 | var elem = elems[i], |
|
- | 565 | val = exec ? value.call(elem, i) : value; |
|
- | 566 | fn(elem, key, val); |
|
- | 567 | }
|
|
- | 568 | return elems; |
|
- | 569 | }
|
|
- | 570 | ||
- | 571 | // Getting an attribute
|
|
- | 572 | return l ? fn(elems[0], key) : null; |
|
- | 573 | }
|
|
- | 574 | ||
539 | function now() { |
575 | function now() { |
540 | return (new Date).getTime(); |
576 | return (new Date).getTime(); |
541 | }
|
577 | }
|
542 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
578 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
- | 579 | var emptyObject = {}; |
|
543 | 580 | ||
544 | jQuery.extend({ |
581 | jQuery.extend({ |
545 | cache: {}, |
582 | cache: {}, |
- | 583 | ||
- | 584 | expando:expando, |
|
546 | 585 | ||
547 | data: function( elem, name, data ) { |
586 | data: function( elem, name, data ) { |
548 | elem = elem == window ? |
587 | elem = elem == window ? |
549 | windowData :
|
588 | windowData :
|
550 | elem;
|
589 | elem;
|
551 | 590 | ||
552 | var id = elem[ expando ], cache = jQuery.cache; |
591 | var id = elem[ expando ], cache = jQuery.cache, thisCache; |
553 | - | ||
554 | // Compute a unique ID for the element
|
- | |
555 | if(!id) id = elem[ expando ] = ++uuid; |
- | |
556 | 592 | ||
557 | // Only generate the data cache if we're
|
593 | // Handle the case where there's no name immediately
|
558 | // trying to access or manipulate it
|
- | |
559 | if ( name && !cache[ id ] ) |
594 | if ( !name && !id ) { |
560 | cache[ id ] = {}; |
595 | return null; |
- | 596 | }
|
|
561 | 597 | ||
- | 598 | // Compute a unique ID for the element
|
|
- | 599 | if ( !id ) { |
|
562 | var thisCache = cache[ id ]; |
600 | id = ++uuid; |
- | 601 | }
|
|
563 | 602 | ||
- | 603 | // Avoid generating a new cache unless none exists and we
|
|
- | 604 | // want to manipulate it.
|
|
- | 605 | if ( cache[ id ] ) { |
|
- | 606 | thisCache = cache[ id ]; |
|
- | 607 | } else if ( typeof data === "undefined" ) { |
|
- | 608 | thisCache = emptyObject; |
|
- | 609 | } else { |
|
- | 610 | thisCache = cache[ id ] = {}; |
|
- | 611 | }
|
|
- | 612 | ||
564 | // Prevent overriding the named cache with undefined values
|
613 | // Prevent overriding the named cache with undefined values
|
565 | if ( data !== undefined ) thisCache[ name ] = data; |
614 | if ( data !== undefined ) { |
- | 615 | elem[ expando ] = id; |
|
- | 616 | thisCache[ name ] = data; |
|
- | 617 | }
|
|
566 | 618 | ||
567 | if(name === true) return thisCache |
619 | return name ? thisCache[ name ] : thisCache; |
568 | else if(name) return thisCache[name] |
- | |
569 | else return id |
- | |
570 | }, |
620 | }, |
571 | 621 | ||
572 | removeData: function( elem, name ) { |
622 | removeData: function( elem, name ) { |
573 | elem = elem == window ? |
623 | elem = elem == window ? |
574 | windowData :
|
624 | windowData :
|
Строка 581... | Строка 631... | ||
581 | if ( thisCache ) { |
631 | if ( thisCache ) { |
582 | // Remove the section of cache data
|
632 | // Remove the section of cache data
|
583 | delete thisCache[ name ]; |
633 | delete thisCache[ name ]; |
584 | 634 | ||
585 | // If we've removed all the data, remove the element's cache
|
635 | // If we've removed all the data, remove the element's cache
|
586 | if( jQuery.isEmptyObject(thisCache) ) |
636 | if ( jQuery.isEmptyObject(thisCache) ) { |
587 | jQuery.removeData( elem ); |
637 | jQuery.removeData( elem ); |
- | 638 | }
|
|
588 | }
|
639 | }
|
589 | 640 | ||
590 | // Otherwise, we want to remove all of the element's data
|
641 | // Otherwise, we want to remove all of the element's data
|
591 | } else { |
642 | } else { |
592 | // Clean up the element expando
|
643 | // Clean up the element expando
|
593 | try { |
644 | try { |
594 | delete elem[ expando ]; |
645 | delete elem[ expando ]; |
595 | } catch(e){ |
646 | } catch( e ) { |
596 | // IE has trouble directly removing the expando
|
647 | // IE has trouble directly removing the expando
|
597 | // but it's ok with using removeAttribute
|
648 | // but it's ok with using removeAttribute
|
598 | if ( elem.removeAttribute ) |
649 | if ( elem.removeAttribute ) { |
599 | elem.removeAttribute( expando ); |
650 | elem.removeAttribute( expando ); |
- | 651 | }
|
|
600 | }
|
652 | }
|
601 | 653 | ||
602 | // Completely remove the data cache
|
654 | // Completely remove the data cache
|
603 | delete cache[ id ]; |
655 | delete cache[ id ]; |
604 | }
|
656 | }
|
605 | }, |
657 | }, |
- | 658 | ||
606 | queue: function( elem, type, data ) { |
659 | queue: function( elem, type, data ) { |
607 | if( !elem ) return; |
660 | if( !elem ) return; |
608 | 661 | ||
609 | type = (type || "fx") + "queue"; |
662 | type = (type || "fx") + "queue"; |
610 | var q = jQuery.data( elem, type ); |
663 | var q = jQuery.data( elem, type ); |
Строка 638... | Строка 691... | ||
638 | }
|
691 | }
|
639 | }); |
692 | }); |
640 | 693 | ||
641 | jQuery.fn.extend({ |
694 | jQuery.fn.extend({ |
642 | data: function( key, value ){ |
695 | data: function( key, value ){ |
643 | if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true); |
696 | if ( typeof key === "undefined" && this.length ) { |
- | 697 | return jQuery.data( this[0] ); |
|
- | 698 | }
|
|
644 | 699 | ||
645 | var parts = key.split("."); |
700 | var parts = key.split("."); |
646 | parts[1] = parts[1] ? "." + parts[1] : ""; |
701 | parts[1] = parts[1] ? "." + parts[1] : ""; |
647 | 702 | ||
648 | if ( value === undefined ) { |
703 | if ( value === undefined ) { |
Строка 687... | Строка 742... | ||
687 | }); |
742 | }); |
688 | }, |
743 | }, |
689 | clearQueue: function(type){ |
744 | clearQueue: function(type){ |
690 | return this.queue( type || "fx", [] ); |
745 | return this.queue( type || "fx", [] ); |
691 | }
|
746 | }
|
692 | });/*! |
747 | }); |
- | 748 | /*
|
|
693 | * Sizzle CSS Selector Engine - v1.0
|
749 | * A number of helper functions used for managing events.
|
694 | * Copyright 2009, The Dojo Foundation
|
- | |
695 | * Released under the MIT, BSD, and GPL Licenses.
|
750 | * Many of the ideas behind this code originated from
|
696 | * More information: http://sizzlejs.com/
|
751 | * Dean Edwards' addEvent library.
|
697 | */
|
752 | */
|
698 | (function(){ |
753 | jQuery.event = { |
699 | - | ||
700 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
- | |
701 | done = 0, |
- | |
702 | toString = Object.prototype.toString, |
- | |
703 | hasDuplicate = false; |
- | |
704 | - | ||
705 | var Sizzle = function(selector, context, results, seed) { |
- | |
706 | results = results || []; |
- | |
707 | var origContext = context = context || document; |
- | |
708 | 754 | ||
709 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
755 | // Bind an event to an element
|
710 | return []; |
756 | // Original by Dean Edwards
|
711 | }
|
- | |
712 | - | ||
- | 757 | add: function( elem, types, handler, data ) { |
|
713 | if ( !selector || typeof selector !== "string" ) { |
758 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
714 | return results; |
759 | return; |
715 | }
|
760 | }
|
716 | 761 | ||
717 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
762 | // For whatever reason, IE has trouble passing the window object
|
718 | - | ||
719 | // Reset the position of the chunker regexp (start from head)
|
763 | // around, causing it to be cloned in the process
|
720 | chunker.lastIndex = 0; |
- | |
721 | - | ||
722 | while ( (m = chunker.exec(selector)) !== null ) { |
764 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
723 | parts.push( m[1] ); |
- | |
724 | - | ||
725 | if ( m[2] ) { |
765 | elem = window; |
726 | extra = RegExp.rightContext; |
- | |
727 | break; |
- | |
728 | }
|
766 | }
|
729 | }
|
- | |
730 | 767 | ||
731 | if ( parts.length > 1 && origPOS.exec( selector ) ) { |
768 | // Make sure that the function being executed has a unique ID
|
732 | if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
769 | if ( !handler.guid ) { |
733 | set = posProcess( parts[0] + parts[1], context ); |
770 | handler.guid = this.guid++; |
734 | } else { |
771 | }
|
735 | set = Expr.relative[ parts[0] ] ? |
- | |
736 | [ context ] : |
- | |
737 | Sizzle( parts.shift(), context ); |
- | |
738 | 772 | ||
- | 773 | // if data is passed, bind to handler
|
|
739 | while ( parts.length ) { |
774 | if ( data !== undefined ) { |
- | 775 | // Create temporary function pointer to original handler
|
|
740 | selector = parts.shift(); |
776 | var fn = handler; |
741 | 777 | ||
742 | if ( Expr.relative[ selector ] ) |
778 | // Create unique handler function, wrapped around original handler
|
743 | selector += parts.shift(); |
779 | handler = this.proxy( fn ); |
744 | 780 | ||
745 | set = posProcess( selector, set ); |
781 | // Store data in unique handler
|
746 | }
|
- | |
747 | }
|
- | |
748 | } else { |
782 | handler.data = data; |
749 | // Take a shortcut and set the context if the root selector is an ID
|
- | |
750 | // (but not if it'll be faster if the inner selector is an ID)
|
- | |
751 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
- | |
752 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
- | |
753 | var ret = Sizzle.find( parts.shift(), context, contextXML ); |
- | |
754 | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
- | |
755 | }
|
783 | }
|
756 | 784 | ||
757 | if ( context ) { |
785 | // Init the element's event structure
|
- | 786 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
|
- | 787 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
|
758 | var ret = seed ? |
788 | // Handle the second event of a trigger and when
|
759 | { expr: parts.pop(), set: makeArray(seed) } : |
789 | // an event is called after a page has unloaded
|
760 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
790 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
761 | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
791 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
- | 792 | undefined; |
|
762 | 793 | }); |
|
763 | if ( parts.length > 0 ) { |
794 | // Add elem as a property of the handle function
|
764 | checkSet = makeArray(set); |
795 | // This is to prevent a memory leak with non-native
|
765 | } else { |
796 | // event in IE.
|
766 | prune = false; |
797 | handle.elem = elem; |
767 | }
|
- | |
768 | 798 | ||
- | 799 | // Handle multiple events separated by a space
|
|
- | 800 | // jQuery(...).bind("mouseover mouseout", fn);
|
|
- | 801 | types = types.split( /\s+/ ); |
|
- | 802 | var type, i=0; |
|
769 | while ( parts.length ) { |
803 | while ( (type = types[ i++ ]) ) { |
- | 804 | // Namespaced event handlers
|
|
770 | var cur = parts.pop(), pop = cur; |
805 | var namespaces = type.split("."); |
- | 806 | type = namespaces.shift(); |
|
- | 807 | handler.type = namespaces.slice(0).sort().join("."); |
|
771 | 808 | ||
772 | if ( !Expr.relative[ cur ] ) { |
809 | // Get the current list of functions bound to this event
|
773 | cur = ""; |
810 | var handlers = events[ type ], |
774 | } else { |
- | |
775 | pop = parts.pop(); |
811 | special = this.special[ type ] || {}; |
776 | }
|
- | |
777 | 812 | ||
778 | if ( pop == null ) { |
813 | if ( special.add ) { |
- | 814 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
|
- | 815 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
|
- | 816 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
|
779 | pop = context; |
817 | handler = modifiedHandler; |
780 | }
|
818 | }
|
781 | - | ||
782 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
- | |
783 | }
|
819 | }
|
784 | } else { |
- | |
785 | checkSet = parts = []; |
- | |
786 | }
|
- | |
787 | }
|
- | |
788 | - | ||
789 | if ( !checkSet ) { |
- | |
790 | checkSet = set; |
- | |
791 | }
|
- | |
792 | 820 | ||
- | 821 | // Init the event handler queue
|
|
793 | if ( !checkSet ) { |
822 | if ( !handlers ) { |
794 | throw "Syntax error, unrecognized expression: " + (cur || selector); |
823 | handlers = events[ type ] = {}; |
795 | }
|
- | |
796 | 824 | ||
797 | if ( toString.call(checkSet) === "[object Array]" ) { |
825 | // Check for a special event handler
|
798 | if ( !prune ) { |
826 | // Only use addEventListener/attachEvent if the special
|
799 | results.push.apply( results, checkSet ); |
827 | // events handler returns false
|
800 | } else if ( context && context.nodeType === 1 ) { |
828 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
801 | for ( var i = 0; checkSet[i] != null; i++ ) { |
829 | // Bind the global event handler to the element
|
802 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
- | |
803 | results.push( set[i] ); |
830 | if ( elem.addEventListener ) { |
804 | }
|
- | |
805 | }
|
- | |
806 | } else { |
- | |
807 | for ( var i = 0; checkSet[i] != null; i++ ) { |
831 | elem.addEventListener( type, handle, false ); |
808 | if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
832 | } else if ( elem.attachEvent ) { |
809 | results.push( set[i] ); |
833 | elem.attachEvent( "on" + type, handle ); |
- | 834 | }
|
|
810 | }
|
835 | }
|
811 | }
|
836 | }
|
812 | }
|
- | |
813 | } else { |
- | |
814 | makeArray( checkSet, results ); |
- | |
815 | }
|
- | |
816 | - | ||
817 | if ( extra ) { |
- | |
818 | Sizzle( extra, origContext, results, seed ); |
- | |
819 | Sizzle.uniqueSort( results ); |
- | |
820 | }
|
- | |
821 | 837 | ||
822 | return results; |
- | |
823 | }; |
- | |
824 | - | ||
825 | Sizzle.uniqueSort = function(results){ |
838 | // Add the function to the element's handler list
|
826 | if ( sortOrder ) { |
- | |
827 | hasDuplicate = false; |
839 | handlers[ handler.guid ] = handler; |
828 | results.sort(sortOrder); |
- | |
829 | 840 | ||
830 | if ( hasDuplicate ) { |
- | |
831 | for ( var i = 1; i < results.length; i++ ) { |
841 | // Keep track of which events have been used, for global triggering
|
832 | if ( results[i] === results[i-1] ) { |
- | |
833 | results.splice(i--, 1); |
842 | this.global[ type ] = true; |
834 | }
|
- | |
835 | }
|
- | |
836 | }
|
843 | }
|
837 | }
|
- | |
838 | }; |
- | |
839 | 844 | ||
840 | Sizzle.matches = function(expr, set){ |
845 | // Nullify elem to prevent memory leaks in IE
|
841 | return Sizzle(expr, null, null, set); |
846 | elem = null; |
842 | }; |
847 | }, |
843 | 848 | ||
844 | Sizzle.find = function(expr, context, isXML){ |
849 | guid: 1, |
845 | var set, match; |
850 | global: {}, |
846 | 851 | ||
847 | if ( !expr ) { |
- | |
848 | return []; |
- | |
849 | }
|
- | |
850 | - | ||
851 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
852 | // Detach an event or set of events from an element
|
852 | var type = Expr.order[i], match; |
- | |
853 | - | ||
854 | if ( (match = Expr.match[ type ].exec( expr )) ) { |
853 | remove: function( elem, types, handler ) { |
855 | var left = RegExp.leftContext; |
854 | // don't do events on text and comment nodes
|
856 | - | ||
857 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
855 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
858 | match[1] = (match[1] || "").replace(/\\/g, ""); |
- | |
859 | set = Expr.find[ type ]( match, context, isXML ); |
- | |
860 | if ( set != null ) { |
- | |
861 | expr = expr.replace( Expr.match[ type ], "" ); |
- | |
862 | break; |
856 | return; |
863 | }
|
- | |
864 | }
|
- | |
865 | }
|
857 | }
|
866 | }
|
- | |
867 | - | ||
868 | if ( !set ) { |
- | |
869 | set = context.getElementsByTagName("*"); |
- | |
870 | }
|
- | |
871 | - | ||
872 | return {set: set, expr: expr}; |
- | |
873 | }; |
- | |
874 | - | ||
875 | Sizzle.filter = function(expr, set, inplace, not){ |
- | |
876 | var old = expr, result = [], curLoop = set, match, anyFound, |
- | |
877 | isXMLFilter = set && set[0] && isXML(set[0]); |
- | |
878 | 858 | ||
879 | while ( expr && set.length ) { |
- | |
880 | for ( var type in Expr.filter ) { |
- | |
881 | if ( (match = Expr.match[ type ].exec( expr )) != null ) { |
- | |
882 | var filter = Expr.filter[ type ], found, item; |
859 | var events = jQuery.data( elem, "events" ), ret, type; |
883 | anyFound = false; |
- | |
884 | 860 | ||
885 | if ( curLoop == result ) { |
861 | if ( events ) { |
- | 862 | // Unbind all events for the element
|
|
- | 863 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
|
886 | result = []; |
864 | for ( type in events ) { |
- | 865 | this.remove( elem, type + (types || "") ); |
|
887 | }
|
866 | }
|
888 | - | ||
889 | if ( Expr.preFilter[ type ] ) { |
867 | } else { |
890 | match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
868 | // types is actually an event object here
|
891 | - | ||
892 | if ( !match ) { |
869 | if ( types.type ) { |
893 | anyFound = found = true; |
870 | handler = types.handler; |
894 | } else if ( match === true ) { |
- | |
895 | continue; |
871 | types = types.type; |
896 | }
|
- | |
897 | }
|
872 | }
|
898 | 873 | ||
- | 874 | // Handle multiple events seperated by a space
|
|
- | 875 | // jQuery(...).unbind("mouseover mouseout", fn);
|
|
- | 876 | types = types.split(/\s+/); |
|
899 | if ( match ) { |
877 | var i = 0; |
900 | for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
878 | while ( (type = types[ i++ ]) ) { |
901 | if ( item ) { |
879 | // Namespaced event handlers
|
902 | found = filter( item, match, i, curLoop ); |
880 | var namespaces = type.split("."); |
- | 881 | type = namespaces.shift(); |
|
903 | var pass = not ^ !!found; |
882 | var all = !namespaces.length, |
- | 883 | namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
|
- | 884 | special = this.special[ type ] || {}; |
|
904 | 885 | ||
905 | if ( inplace && found != null ) { |
886 | if ( events[ type ] ) { |
- | 887 | // remove the given handler for the given type
|
|
906 | if ( pass ) { |
888 | if ( handler ) { |
907 | anyFound = true; |
889 | delete events[ type ][ handler.guid ]; |
- | 890 | ||
- | 891 | // remove all handlers for the given type
|
|
908 | } else { |
892 | } else { |
- | 893 | for ( var handle in events[ type ] ) { |
|
- | 894 | // Handle the removal of namespaced events
|
|
- | 895 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
|
909 | curLoop[i] = false; |
896 | delete events[ type ][ handle ]; |
910 | }
|
897 | }
|
911 | } else if ( pass ) { |
- | |
912 | result.push( item ); |
- | |
913 | anyFound = true; |
- | |
914 | }
|
898 | }
|
915 | }
|
899 | }
|
916 | }
|
- | |
917 | }
|
- | |
918 | 900 | ||
919 | if ( found !== undefined ) { |
- | |
920 | if ( !inplace ) { |
901 | if ( special.remove ) { |
921 | curLoop = result; |
902 | special.remove.call( elem, namespaces ); |
922 | }
|
903 | }
|
923 | - | ||
924 | expr = expr.replace( Expr.match[ type ], "" ); |
- | |
925 | 904 | ||
- | 905 | // remove generic event handler if no more handlers exist
|
|
- | 906 | for ( ret in events[ type ] ) { |
|
- | 907 | break; |
|
- | 908 | }
|
|
926 | if ( !anyFound ) { |
909 | if ( !ret ) { |
- | 910 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
|
- | 911 | if ( elem.removeEventListener ) { |
|
- | 912 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
|
- | 913 | } else if ( elem.detachEvent ) { |
|
- | 914 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
|
- | 915 | }
|
|
- | 916 | }
|
|
927 | return []; |
917 | ret = null; |
- | 918 | delete events[ type ]; |
|
- | 919 | }
|
|
928 | }
|
920 | }
|
929 | - | ||
930 | break; |
- | |
931 | }
|
921 | }
|
932 | }
|
922 | }
|
933 | }
|
- | |
934 | 923 | ||
935 | // Improper expression
|
924 | // Remove the expando if it's no longer used
|
936 | if ( expr == old ) { |
925 | for ( ret in events ) { |
937 | if ( anyFound == null ) { |
- | |
938 | throw "Syntax error, unrecognized expression: " + expr; |
- | |
939 | } else { |
- | |
940 | break; |
926 | break; |
941 | }
|
927 | }
|
- | 928 | if ( !ret ) { |
|
- | 929 | var handle = jQuery.data( elem, "handle" ); |
|
- | 930 | if ( handle ) { |
|
- | 931 | handle.elem = null; |
|
- | 932 | }
|
|
- | 933 | jQuery.removeData( elem, "events" ); |
|
- | 934 | jQuery.removeData( elem, "handle" ); |
|
- | 935 | }
|
|
942 | }
|
936 | }
|
- | 937 | }, |
|
943 | 938 | ||
944 | old = expr; |
939 | // bubbling is internal
|
945 | }
|
- | |
946 | - | ||
- | 940 | trigger: function( event, data, elem /*, bubbling */ ) { |
|
- | 941 | // Event object or event type
|
|
- | 942 | var type = event.type || event, |
|
947 | return curLoop; |
943 | bubbling = arguments[3]; |
948 | }; |
- | |
949 | 944 | ||
950 | var Expr = Sizzle.selectors = { |
945 | if ( !bubbling ) { |
951 | order: [ "ID", "NAME", "TAG" ], |
946 | event = typeof event === "object" ? |
952 | match: { |
- | |
953 | ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
- | |
954 | CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
- | |
955 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, |
- | |
956 | ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
- | |
957 | TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, |
- | |
958 | CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
- | |
959 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
- | |
960 | PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ |
- | |
961 | }, |
- | |
962 | attrMap: { |
- | |
963 | "class": "className", |
947 | // jQuery.Event object
|
964 | "for": "htmlFor" |
- | |
965 | }, |
- | |
966 | attrHandle: { |
948 | event[expando] ? event : |
967 | href: function(elem){ |
949 | // Object literal
|
968 | return elem.getAttribute("href"); |
950 | jQuery.extend( jQuery.Event(type), event ) : |
969 | }
|
- | |
970 | }, |
- | |
971 | relative: { |
- | |
972 | "+": function(checkSet, part, isXML){ |
- | |
973 | var isPartStr = typeof part === "string", |
951 | // Just the event type (string)
|
974 | isTag = isPartStr && !/\W/.test(part), |
952 | jQuery.Event(type); |
975 | isPartStrNotTag = isPartStr && !isTag; |
- | |
976 | 953 | ||
977 | if ( isTag && !isXML ) { |
954 | if ( type.indexOf("!") >= 0 ) { |
978 | part = part.toUpperCase(); |
955 | event.type = type = type.slice(0, -1); |
- | 956 | event.exclusive = true; |
|
979 | }
|
957 | }
|
980 | 958 | ||
- | 959 | // Handle a global trigger
|
|
- | 960 | if ( !elem ) { |
|
- | 961 | // Don't bubble custom events when global (to avoid too much overhead)
|
|
- | 962 | event.stopPropagation(); |
|
981 | for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
963 | // Only trigger if we've ever bound an event for it
|
982 | if ( (elem = checkSet[i]) ) { |
964 | if ( this.global[ type ] ) { |
- | 965 | jQuery.each( jQuery.cache, function() { |
|
983 | while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
966 | if ( this.events && this.events[type] ) { |
984 | - | ||
985 | checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? |
967 | jQuery.event.trigger( event, data, this.handle.elem ); |
986 | elem || false : |
968 | }
|
987 | elem === part; |
969 | }); |
988 | }
|
970 | }
|
989 | }
|
971 | }
|
990 | 972 | ||
991 | if ( isPartStrNotTag ) { |
- | |
992 | Sizzle.filter( part, checkSet, true ); |
973 | // Handle triggering a single element
|
993 | }
|
- | |
994 | }, |
- | |
995 | ">": function(checkSet, part, isXML){ |
- | |
996 | var isPartStr = typeof part === "string"; |
- | |
997 | 974 | ||
998 | if ( isPartStr && !/\W/.test(part) ) { |
975 | // don't do events on text and comment nodes
|
999 | part = isXML ? part : part.toUpperCase(); |
976 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
- | 977 | return undefined; |
|
- | 978 | }
|
|
1000 | 979 | ||
1001 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
- | |
1002 | var elem = checkSet[i]; |
- | |
1003 | if ( elem ) { |
- | |
1004 | var parent = elem.parentNode; |
980 | // Clean up in case it is reused
|
1005 | checkSet[i] = parent.nodeName === part ? parent : false; |
- | |
1006 | }
|
- | |
1007 | }
|
- | |
1008 | } else { |
- | |
1009 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
- | |
1010 | var elem = checkSet[i]; |
981 | event.result = undefined; |
1011 | if ( elem ) { |
- | |
1012 | checkSet[i] = isPartStr ? |
- | |
1013 | elem.parentNode : |
982 | event.target = elem; |
1014 | elem.parentNode === part; |
- | |
1015 | }
|
- | |
1016 | }
|
- | |
1017 | 983 | ||
1018 | if ( isPartStr ) { |
984 | // Clone the incoming data, if any
|
1019 | Sizzle.filter( part, checkSet, true ); |
985 | data = jQuery.makeArray( data ); |
1020 | }
|
986 | data.unshift( event ); |
1021 | }
|
- | |
1022 | }, |
987 | }
|
1023 | "": function(checkSet, part, isXML){ |
- | |
1024 | var doneName = done++, checkFn = dirCheck; |
- | |
1025 | 988 | ||
1026 | if ( !/\W/.test(part) ) { |
- | |
1027 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
- | |
1028 | checkFn = dirNodeCheck; |
989 | event.currentTarget = elem; |
1029 | }
|
- | |
1030 | 990 | ||
1031 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
991 | // Trigger the event, it is assumed that "handle" is a function
|
1032 | }, |
- | |
1033 | "~": function(checkSet, part, isXML){ |
992 | var handle = jQuery.data( elem, "handle" ); |
- | 993 | if ( handle ) { |
|
1034 | var doneName = done++, checkFn = dirCheck; |
994 | handle.apply( elem, data ); |
- | 995 | }
|
|
1035 | 996 | ||
- | 997 | var nativeFn, nativeHandler; |
|
- | 998 | try { |
|
- | 999 | nativeFn = elem[ type ]; |
|
1036 | if ( typeof part === "string" && !/\W/.test(part) ) { |
1000 | nativeHandler = elem[ "on" + type ]; |
1037 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1001 | // prevent IE from throwing an error for some elements with some event types, see #3533
|
- | 1002 | } catch (e) {} |
|
- | 1003 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
|
- | 1004 | if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
|
1038 | checkFn = dirNodeCheck; |
1005 | event.result = false; |
1039 | }
|
1006 | }
|
1040 | 1007 | ||
- | 1008 | // Trigger the native events (except for clicks on links)
|
|
- | 1009 | if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
|
- | 1010 | this.triggered = true; |
|
- | 1011 | try { |
|
- | 1012 | nativeFn(); |
|
1041 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
1013 | // prevent IE from throwing an error for some hidden elements
|
- | 1014 | } catch (e) {} |
|
1042 | }
|
1015 | }
|
1043 | }, |
- | |
1044 | find: { |
- | |
1045 | ID: function(match, context, isXML){ |
- | |
1046 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
- | |
1047 | var m = context.getElementById(match[1]); |
- | |
1048 | return m ? [m] : []; |
- | |
1049 | }
|
- | |
1050 | }, |
- | |
1051 | NAME: function(match, context, isXML){ |
- | |
1052 | if ( typeof context.getElementsByName !== "undefined" ) { |
- | |
1053 | var ret = [], results = context.getElementsByName(match[1]); |
- | |
1054 | 1016 | ||
1055 | for ( var i = 0, l = results.length; i < l; i++ ) { |
- | |
1056 | if ( results[i].getAttribute("name") === match[1] ) { |
- | |
1057 | ret.push( results[i] ); |
1017 | this.triggered = false; |
1058 | }
|
- | |
1059 | }
|
- | |
1060 | 1018 | ||
- | 1019 | if ( !event.isPropagationStopped() ) { |
|
- | 1020 | var parent = elem.parentNode || elem.ownerDocument; |
|
- | 1021 | if ( parent ) { |
|
1061 | return ret.length === 0 ? null : ret; |
1022 | jQuery.event.trigger( event, data, parent, true ); |
1062 | }
|
1023 | }
|
1063 | }, |
- | |
1064 | TAG: function(match, context){ |
- | |
1065 | return context.getElementsByTagName(match[1]); |
- | |
1066 | }
|
1024 | }
|
1067 | }, |
1025 | }, |
1068 | preFilter: { |
- | |
1069 | CLASS: function(match, curLoop, inplace, result, not, isXML){ |
- | |
1070 | match = " " + match[1].replace(/\\/g, "") + " "; |
- | |
1071 | 1026 | ||
1072 | if ( isXML ) { |
1027 | handle: function( event ) { |
1073 | return match; |
1028 | // returned undefined or false
|
1074 | }
|
1029 | var all, handlers; |
1075 | 1030 | ||
1076 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
1031 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
- | 1032 | event.currentTarget = this; |
|
- | 1033 | ||
- | 1034 | // Namespaced event handlers
|
|
- | 1035 | var namespaces = event.type.split("."); |
|
- | 1036 | event.type = namespaces.shift(); |
|
- | 1037 | ||
- | 1038 | // Cache this now, all = true means, any handler
|
|
- | 1039 | all = !namespaces.length && !event.exclusive; |
|
- | 1040 | ||
- | 1041 | var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
|
- | 1042 | ||
- | 1043 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
|
- | 1044 | ||
1077 | if ( elem ) { |
1045 | for ( var j in handlers ) { |
- | 1046 | var handler = handlers[ j ]; |
|
- | 1047 | ||
- | 1048 | // Filter the functions by class
|
|
- | 1049 | if ( all || namespace.test(handler.type) ) { |
|
1078 | if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { |
1050 | // Pass in a reference to the handler function itself
|
- | 1051 | // So that we can later remove it
|
|
- | 1052 | event.handler = handler; |
|
- | 1053 | event.data = handler.data; |
|
- | 1054 | ||
- | 1055 | var ret = handler.apply( this, arguments ); |
|
- | 1056 | ||
1079 | if ( !inplace ) |
1057 | if ( ret !== undefined ) { |
1080 | result.push( elem ); |
1058 | event.result = ret; |
1081 | } else if ( inplace ) { |
1059 | if ( ret === false ) { |
1082 | curLoop[i] = false; |
1060 | event.preventDefault(); |
- | 1061 | event.stopPropagation(); |
|
1083 | }
|
1062 | }
|
1084 | }
|
1063 | }
|
1085 | }
|
- | |
1086 | 1064 | ||
1087 | return false; |
- | |
1088 | }, |
- | |
1089 | ID: function(match){ |
- | |
1090 | return match[1].replace(/\\/g, ""); |
1065 | if ( event.isImmediatePropagationStopped() ) { |
1091 | }, |
1066 | break; |
1092 | TAG: function(match, curLoop){ |
- | |
1093 | for ( var i = 0; curLoop[i] === false; i++ ){} |
- | |
1094 | return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); |
- | |
1095 | }, |
1067 | }
|
1096 | CHILD: function(match){ |
- | |
1097 | if ( match[1] == "nth" ) { |
- | |
1098 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
- | |
1099 | var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
- | |
1100 | match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || |
- | |
1101 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
- | |
1102 | 1068 | ||
1103 | // calculate the numbers (first)n+(last) including if they are negative
|
- | |
1104 | match[2] = (test[1] + (test[2] || 1)) - 0; |
- | |
1105 | match[3] = test[3] - 0; |
- | |
1106 | }
|
1069 | }
|
- | 1070 | }
|
|
- | 1071 | }, |
|
1107 | 1072 | ||
1108 | // TODO: Move to normal caching system
|
1073 | props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
1109 | match[0] = done++; |
- | |
1110 | 1074 | ||
1111 | return match; |
1075 | fix: function( event ) { |
1112 | }, |
- | |
1113 | ATTR: function(match, curLoop, inplace, result, not, isXML){ |
- | |
1114 | var name = match[1].replace(/\\/g, ""); |
- | |
1115 | - | ||
1116 | if ( !isXML && Expr.attrMap[name] ) { |
1076 | if ( event[ expando ] ) { |
1117 | match[1] = Expr.attrMap[name]; |
1077 | return event; |
1118 | }
|
1078 | }
|
1119 | 1079 | ||
1120 | if ( match[2] === "~=" ) { |
1080 | // store a copy of the original event object
|
1121 | match[4] = " " + match[4] + " "; |
1081 | // and "clone" to set read-only properties
|
1122 | }
|
1082 | var originalEvent = event; |
- | 1083 | event = jQuery.Event( originalEvent ); |
|
1123 | 1084 | ||
- | 1085 | for ( var i = this.props.length, prop; i; ) { |
|
- | 1086 | prop = this.props[ --i ]; |
|
- | 1087 | event[ prop ] = originalEvent[ prop ]; |
|
- | 1088 | }
|
|
- | 1089 | ||
- | 1090 | // Fix target property, if necessary
|
|
- | 1091 | if ( !event.target ) { |
|
- | 1092 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
|
- | 1093 | }
|
|
- | 1094 | ||
- | 1095 | // check if target is a textnode (safari)
|
|
- | 1096 | if ( event.target.nodeType === 3 ) { |
|
- | 1097 | event.target = event.target.parentNode; |
|
- | 1098 | }
|
|
- | 1099 | ||
- | 1100 | // Add relatedTarget, if necessary
|
|
- | 1101 | if ( !event.relatedTarget && event.fromElement ) { |
|
- | 1102 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
|
- | 1103 | }
|
|
- | 1104 | ||
- | 1105 | // Calculate pageX/Y if missing and clientX/Y available
|
|
- | 1106 | if ( event.pageX == null && event.clientX != null ) { |
|
- | 1107 | var doc = document.documentElement, body = document.body; |
|
- | 1108 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
|
- | 1109 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
|
- | 1110 | }
|
|
- | 1111 | ||
- | 1112 | // Add which for key events
|
|
- | 1113 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
|
- | 1114 | event.which = event.charCode || event.keyCode; |
|
- | 1115 | }
|
|
- | 1116 | ||
- | 1117 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
|
- | 1118 | if ( !event.metaKey && event.ctrlKey ) { |
|
- | 1119 | event.metaKey = event.ctrlKey; |
|
- | 1120 | }
|
|
- | 1121 | ||
- | 1122 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
|
- | 1123 | // Note: button is not normalized, so don't use it
|
|
- | 1124 | if ( !event.which && event.button !== undefined ) { |
|
- | 1125 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
|
- | 1126 | }
|
|
- | 1127 | ||
- | 1128 | return event; |
|
- | 1129 | }, |
|
- | 1130 | ||
- | 1131 | proxy: function( fn, proxy, thisObject ) { |
|
- | 1132 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
|
- | 1133 | thisObject = proxy; |
|
- | 1134 | proxy = undefined; |
|
- | 1135 | }
|
|
- | 1136 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
|
- | 1137 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
|
- | 1138 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
|
- | 1139 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
|
- | 1140 | // So proxy can be declared as an argument
|
|
1124 | return match; |
1141 | return proxy; |
- | 1142 | }, |
|
- | 1143 | ||
- | 1144 | special: { |
|
- | 1145 | ready: { |
|
- | 1146 | // Make sure the ready event is setup
|
|
- | 1147 | setup: bindReady, |
|
- | 1148 | teardown: function() {} |
|
1125 | }, |
1149 | }, |
- | 1150 | ||
- | 1151 | live: { |
|
1126 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1152 | add: function( proxy, data, namespaces ) { |
1127 | if ( match[1] === "not" ) { |
1153 | jQuery.extend( proxy, data || {} ); |
1128 | // If we're dealing with a complex expression, or a simple one
|
1154 | proxy.guid += data.selector + data.live; |
1129 | if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) { |
1155 | jQuery.event.add( this, data.live, liveHandler, data ); |
- | 1156 | }, |
|
- | 1157 | ||
1130 | match[3] = Sizzle(match[3], null, null, curLoop); |
1158 | remove: function( namespaces ) { |
1131 | } else { |
1159 | if ( namespaces.length ) { |
1132 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1160 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
- | 1161 | ||
- | 1162 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
|
- | 1163 | if ( name.test(this.type) ) { |
|
- | 1164 | remove++;
|
|
- | 1165 | }
|
|
- | 1166 | }); |
|
- | 1167 | ||
1133 | if ( !inplace ) { |
1168 | if ( remove < 1 ) { |
1134 | result.push.apply( result, ret ); |
1169 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
1135 | }
|
1170 | }
|
1136 | return false; |
- | |
1137 | }
|
1171 | }
|
1138 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
- | |
1139 | return true; |
- | |
1140 | }
|
1172 | }
|
1141 | - | ||
1142 | return match; |
- | |
1143 | }, |
- | |
1144 | POS: function(match){ |
- | |
1145 | match.unshift( true ); |
- | |
1146 | return match; |
- | |
1147 | }
|
1173 | }
|
1148 | }, |
1174 | }
|
1149 | filters: { |
- | |
1150 | enabled: function(elem){ |
- | |
1151 | return elem.disabled === false && elem.type !== "hidden"; |
- | |
1152 | }, |
1175 | }; |
- | 1176 | ||
1153 | disabled: function(elem){ |
1177 | jQuery.Event = function( src ){ |
1154 | return elem.disabled === true; |
1178 | // Allow instantiation without the 'new' keyword
|
1155 | }, |
- | |
1156 | checked: function(elem){ |
1179 | if ( !this.preventDefault ) { |
1157 | return elem.checked === true; |
1180 | return new jQuery.Event( src ); |
1158 | }, |
1181 | }
|
- | 1182 | ||
1159 | selected: function(elem){ |
1183 | // Event object
|
1160 | // Accessing this property makes selected-by-default
|
1184 | if ( src && src.type ) { |
1161 | // options in Safari work properly
|
1185 | this.originalEvent = src; |
1162 | elem.parentNode.selectedIndex; |
1186 | this.type = src.type; |
1163 | return elem.selected === true; |
1187 | // Event type
|
1164 | }, |
1188 | } else { |
1165 | parent: function(elem){ |
- | |
1166 | return !!elem.firstChild; |
1189 | this.type = src; |
1167 | }, |
1190 | }
|
1168 | empty: function(elem){ |
- | |
1169 | return !elem.firstChild; |
- | |
1170 | }, |
1191 | |
1171 | has: function(elem, i, match){ |
1192 | // timeStamp is buggy for some events on Firefox(#3843)
|
1172 | return !!Sizzle( match[3], elem ).length; |
1193 | // So we won't rely on the native value
|
1173 | }, |
- | |
1174 | header: function(elem){ |
1194 | this.timeStamp = now(); |
1175 | return /h\d/i.test( elem.nodeName ); |
- | |
1176 | }, |
1195 | |
1177 | text: function(elem){ |
1196 | // Mark it as fixed
|
1178 | return "text" === elem.type; |
1197 | this[ expando ] = true; |
1179 | }, |
1198 | }; |
1180 | radio: function(elem){ |
- | |
1181 | return "radio" === elem.type; |
- | |
1182 | }, |
1199 | |
1183 | checkbox: function(elem){ |
1200 | function returnFalse() { |
1184 | return "checkbox" === elem.type; |
1201 | return false; |
1185 | }, |
1202 | }
|
1186 | file: function(elem){ |
1203 | function returnTrue() { |
1187 | return "file" === elem.type; |
1204 | return true; |
1188 | }, |
1205 | }
|
1189 | password: function(elem){ |
- | |
1190 | return "password" === elem.type; |
- | |
1191 | }, |
1206 | |
1192 | submit: function(elem){ |
1207 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
1193 | return "submit" === elem.type; |
1208 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
1194 | }, |
- | |
1195 | image: function(elem){ |
1209 | jQuery.Event.prototype = { |
1196 | return "image" === elem.type; |
- | |
1197 | }, |
- | |
1198 | reset: function(elem){ |
1210 | preventDefault: function() { |
1199 | return "reset" === elem.type; |
1211 | this.isDefaultPrevented = returnTrue; |
1200 | }, |
1212 | |
1201 | button: function(elem){ |
1213 | var e = this.originalEvent; |
1202 | return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; |
- | |
1203 | }, |
1214 | if ( !e ) { |
1204 | input: function(elem){ |
1215 | return; |
1205 | return /input|select|textarea|button/i.test(elem.nodeName); |
- | |
1206 | }
|
1216 | }
|
1207 | }, |
1217 | |
1208 | setFilters: { |
- | |
1209 | first: function(elem, i){ |
- | |
1210 | return i === 0; |
- | |
1211 | }, |
- | |
1212 | last: function(elem, i, match, array){ |
1218 | // if preventDefault exists run it on the original event
|
1213 | return i === array.length - 1; |
- | |
1214 | }, |
- | |
1215 | even: function(elem, i){ |
- | |
1216 | return i % 2 === 0; |
- | |
1217 | }, |
- | |
1218 | odd: function(elem, i){ |
1219 | if ( e.preventDefault ) { |
1219 | return i % 2 === 1; |
1220 | e.preventDefault(); |
1220 | }, |
- | |
1221 | lt: function(elem, i, match){ |
- | |
1222 | return i < match[3] - 0; |
- | |
1223 | }, |
- | |
1224 | gt: function(elem, i, match){ |
- | |
1225 | return i > match[3] - 0; |
- | |
1226 | }, |
- | |
1227 | nth: function(elem, i, match){ |
- | |
1228 | return match[3] - 0 == i; |
- | |
1229 | }, |
- | |
1230 | eq: function(elem, i, match){ |
- | |
1231 | return match[3] - 0 == i; |
- | |
1232 | }
|
1221 | }
|
- | 1222 | // otherwise set the returnValue property of the original event to false (IE)
|
|
- | 1223 | e.returnValue = false; |
|
1233 | }, |
1224 | }, |
1234 | filter: { |
- | |
1235 | PSEUDO: function(elem, match, i, array){ |
1225 | stopPropagation: function() { |
1236 | var name = match[1], filter = Expr.filters[ name ]; |
1226 | this.isPropagationStopped = returnTrue; |
1237 | 1227 | ||
- | 1228 | var e = this.originalEvent; |
|
1238 | if ( filter ) { |
1229 | if ( !e ) { |
- | 1230 | return; |
|
- | 1231 | }
|
|
1239 | return filter( elem, i, match, array ); |
1232 | // if stopPropagation exists run it on the original event
|
1240 | } else if ( name === "contains" ) { |
1233 | if ( e.stopPropagation ) { |
- | 1234 | e.stopPropagation(); |
|
- | 1235 | }
|
|
1241 | return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; |
1236 | // otherwise set the cancelBubble property of the original event to true (IE)
|
- | 1237 | e.cancelBubble = true; |
|
- | 1238 | }, |
|
- | 1239 | stopImmediatePropagation: function(){ |
|
- | 1240 | this.isImmediatePropagationStopped = returnTrue; |
|
- | 1241 | this.stopPropagation(); |
|
- | 1242 | }, |
|
- | 1243 | isDefaultPrevented: returnFalse, |
|
- | 1244 | isPropagationStopped: returnFalse, |
|
- | 1245 | isImmediatePropagationStopped: returnFalse
|
|
- | 1246 | }; |
|
- | 1247 | // Checks if an event happened on an element within another element
|
|
- | 1248 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
|
- | 1249 | var withinElement = function( event ) { |
|
- | 1250 | // Check if mouse(over|out) are still within the same parent element
|
|
- | 1251 | var parent = event.relatedTarget; |
|
- | 1252 | // Traverse up the tree
|
|
1242 | } else if ( name === "not" ) { |
1253 | while ( parent && parent != this ) { |
- | 1254 | // Firefox sometimes assigns relatedTarget a XUL element
|
|
- | 1255 | // which we cannot access the parentNode property of
|
|
- | 1256 | try { parent = parent.parentNode; } |
|
- | 1257 | // assuming we've left the element since we most likely mousedover a xul element
|
|
1243 | var not = match[3]; |
1258 | catch(e) { break; } |
- | 1259 | }
|
|
1244 | 1260 | ||
1245 | for ( i = 0, l = not.length; i < l; i++ ) { |
1261 | if ( parent != this ) { |
1246 | if ( not[i] === elem ) { |
1262 | // set the correct event type
|
1247 | return false; |
1263 | event.type = event.data; |
- | 1264 | // handle event if we actually just moused on to a non sub-element
|
|
- | 1265 | jQuery.event.handle.apply( this, arguments ); |
|
1248 | }
|
1266 | }
|
1249 | }
|
1267 | }; |
1250 | 1268 | ||
- | 1269 | // Create mouseenter and mouseleave events
|
|
- | 1270 | jQuery.each({ |
|
- | 1271 | mouseover: "mouseenter", |
|
1251 | return true; |
1272 | mouseout: "mouseleave" |
- | 1273 | }, function( orig, fix ) { |
|
- | 1274 | jQuery.event.special[ fix ] = { |
|
1252 | }
|
1275 | setup: function(){ |
- | 1276 | jQuery.event.add( this, orig, withinElement, fix ); |
|
1253 | }, |
1277 | }, |
1254 | CHILD: function(elem, match){ |
1278 | teardown: function(){ |
1255 | var type = match[1], node = elem; |
- | |
1256 | switch (type) { |
- | |
1257 | case 'only': |
- | |
1258 | case 'first': |
- | |
1259 | while ( (node = node.previousSibling) ) { |
1279 | jQuery.event.remove( this, orig, withinElement ); |
1260 | if ( node.nodeType === 1 ) return false; |
- | |
1261 | }
|
1280 | }
|
1262 | if ( type == 'first') return true; |
- | |
1263 | node = elem; |
- | |
1264 | case 'last': |
- | |
1265 | while ( (node = node.nextSibling) ) { |
- | |
1266 | if ( node.nodeType === 1 ) return false; |
- | |
1267 | }
|
1281 | }; |
1268 | return true; |
1282 | }); |
1269 | case 'nth': |
- | |
1270 | var first = match[2], last = match[3]; |
- | |
1271 | 1283 | ||
1272 | if ( first == 1 && last == 0 ) { |
- | |
1273 | return true; |
1284 | (function() { |
1274 | }
|
- | |
1275 | - | ||
1276 | var doneName = match[0], |
- | |
1277 | parent = elem.parentNode; |
- | |
1278 | 1285 | ||
1279 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
1286 | var event = jQuery.event, |
1280 | var count = 0; |
1287 | special = event.special, |
1281 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
1288 | handle = event.handle; |
- | 1289 | ||
1282 | if ( node.nodeType === 1 ) { |
1290 | special.submit = { |
1283 | node.nodeIndex = ++count; |
1291 | setup: function(data, namespaces) { |
1284 | }
|
1292 | if(data.selector) { |
- | 1293 | event.add(this, 'click.specialSubmit', function(e, eventData) { |
|
- | 1294 | if(jQuery(e.target).filter(":submit, :image").closest(data.selector).length) { |
|
1285 | }
|
1295 | e.type = "submit"; |
1286 | parent.sizcache = doneName; |
1296 | return handle.call( this, e, eventData ); |
1287 | }
|
1297 | }
|
- | 1298 | }); |
|
1288 | 1299 | ||
1289 | var diff = elem.nodeIndex - last; |
1300 | event.add(this, 'keypress.specialSubmit', function( e, eventData ) { |
1290 | if ( first == 0 ) { |
1301 | if(jQuery(e.target).filter(":text, :password").closest(data.selector).length) { |
1291 | return diff == 0; |
1302 | e.type = "submit"; |
1292 | } else { |
- | |
1293 | return ( diff % first == 0 && diff / first >= 0 ); |
1303 | return handle.call( this, e, eventData ); |
1294 | }
|
1304 | }
|
- | 1305 | }); |
|
- | 1306 | } else { |
|
- | 1307 | return false; |
|
1295 | }
|
1308 | }
|
1296 | }, |
1309 | }, |
- | 1310 | ||
1297 | ID: function(elem, match){ |
1311 | remove: function(namespaces) { |
1298 | return elem.nodeType === 1 && elem.getAttribute("id") === match; |
1312 | event.remove(this, 'click.specialSubmit'); |
1299 | }, |
- | |
1300 | TAG: function(elem, match){ |
- | |
1301 | return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; |
1313 | event.remove(this, 'keypress.specialSubmit'); |
1302 | }, |
1314 | }
|
1303 | CLASS: function(elem, match){ |
- | |
1304 | return (" " + (elem.className || elem.getAttribute("class")) + " ") |
- | |
1305 | .indexOf( match ) > -1; |
- | |
1306 | }, |
1315 | }; |
1307 | ATTR: function(elem, match){ |
- | |
1308 | var name = match[1], |
- | |
1309 | result = Expr.attrHandle[ name ] ? |
- | |
1310 | Expr.attrHandle[ name ]( elem ) : |
- | |
1311 | elem[ name ] != null ? |
- | |
1312 | elem[ name ] : |
- | |
1313 | elem.getAttribute( name ), |
- | |
1314 | value = result + "", |
- | |
1315 | type = match[2], |
- | |
- | 1316 | ||
1316 | check = match[4]; |
1317 | })(); |
1317 | 1318 | ||
1318 | return result == null ? |
1319 | // Create "bubbling" focus and blur events
|
- | 1320 | jQuery.each({ |
|
1319 | type === "!=" : |
1321 | focus: "focusin", |
1320 | type === "=" ? |
1322 | blur: "focusout" |
- | 1323 | }, function( orig, fix ){ |
|
- | 1324 | var event = jQuery.event, |
|
1321 | value === check : |
1325 | special = event.special, |
1322 | type === "*=" ? |
1326 | handle = event.handle; |
- | 1327 | ||
- | 1328 | function ieHandler() { |
|
1323 | value.indexOf(check) >= 0 : |
1329 | arguments[0].type = orig; |
- | 1330 | return handle.apply(this, arguments); |
|
- | 1331 | }
|
|
- | 1332 | ||
- | 1333 | special[orig] = { |
|
1324 | type === "~=" ? |
1334 | setup:function() { |
- | 1335 | if ( this.addEventListener ) |
|
1325 | (" " + value + " ").indexOf(check) >= 0 : |
1336 | this.addEventListener( orig, handle, true ); |
1326 | !check ? |
1337 | else
|
1327 | value && result !== false : |
1338 | jQuery.event.add( this, fix, ieHandler ); |
- | 1339 | }, |
|
1328 | type === "!=" ? |
1340 | teardown:function() { |
1329 | value != check : |
1341 | if ( this.removeEventListener ) |
- | 1342 | this.removeEventListener( orig, handle, true ); |
|
- | 1343 | else
|
|
- | 1344 | jQuery.event.remove( this, fix, ieHandler ); |
|
- | 1345 | }
|
|
- | 1346 | }; |
|
- | 1347 | }); |
|
- | 1348 | ||
1330 | type === "^=" ? |
1349 | jQuery.fn.extend({ |
- | 1350 | // TODO: make bind(), unbind() and one() DRY!
|
|
- | 1351 | bind: function( type, data, fn, thisObject ) { |
|
1331 | value.indexOf(check) === 0 : |
1352 | // Handle object literals
|
1332 | type === "$=" ? |
1353 | if ( typeof type === "object" ) { |
- | 1354 | for ( var key in type ) { |
|
1333 | value.substr(value.length - check.length) === check : |
1355 | this.bind(key, data, type[key], fn); |
- | 1356 | }
|
|
1334 | type === "|=" ? |
1357 | return this; |
- | 1358 | }
|
|
- | 1359 | ||
1335 | value === check || value.substr(0, check.length + 1) === check + "-" : |
1360 | if ( jQuery.isFunction( data ) ) { |
- | 1361 | thisObject = fn; |
|
1336 | false; |
1362 | fn = data; |
- | 1363 | data = undefined; |
|
1337 | }, |
1364 | }
|
- | 1365 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
|
1338 | POS: function(elem, match, i, array){ |
1366 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
1339 | var name = match[2], filter = Expr.setFilters[ name ]; |
1367 | jQuery.event.add( this, type, fn, data ); |
- | 1368 | }); |
|
- | 1369 | }, |
|
1340 | 1370 | ||
- | 1371 | one: function( type, data, fn, thisObject ) { |
|
- | 1372 | // Handle object literals
|
|
- | 1373 | if ( typeof type === "object" ) { |
|
1341 | if ( filter ) { |
1374 | for ( var key in type ) { |
1342 | return filter( elem, i, match, array ); |
1375 | this.one(key, data, type[key], fn); |
1343 | }
|
1376 | }
|
- | 1377 | return this; |
|
1344 | }
|
1378 | }
|
- | 1379 | ||
- | 1380 | if ( jQuery.isFunction( data ) ) { |
|
- | 1381 | thisObject = fn; |
|
- | 1382 | fn = data; |
|
- | 1383 | data = undefined; |
|
1345 | }
|
1384 | }
|
- | 1385 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
|
- | 1386 | var one = jQuery.event.proxy( fn, function( event ) { |
|
- | 1387 | jQuery( this ).unbind( event, one ); |
|
- | 1388 | return fn.apply( this, arguments ); |
|
- | 1389 | }); |
|
- | 1390 | return this.each(function() { |
|
- | 1391 | jQuery.event.add( this, type, one, data ); |
|
- | 1392 | }); |
|
1346 | }; |
1393 | }, |
1347 | 1394 | ||
- | 1395 | unbind: function( type, fn ) { |
|
- | 1396 | // Handle object literals
|
|
- | 1397 | if ( typeof type === "object" && !type.preventDefault ) { |
|
1348 | var origPOS = Expr.match.POS; |
1398 | for ( var key in type ) { |
- | 1399 | this.unbind(key, type[key]); |
|
- | 1400 | }
|
|
- | 1401 | return this; |
|
- | 1402 | }
|
|
- | 1403 | ||
- | 1404 | return this.each(function() { |
|
- | 1405 | jQuery.event.remove( this, type, fn ); |
|
- | 1406 | }); |
|
- | 1407 | }, |
|
1349 | 1408 | ||
1350 | for ( var type in Expr.match ) { |
1409 | trigger: function( type, data ) { |
- | 1410 | return this.each(function() { |
|
1351 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
1411 | jQuery.event.trigger( type, data, this ); |
- | 1412 | }); |
|
1352 | }
|
1413 | }, |
1353 | 1414 | ||
1354 | var makeArray = function(array, results) { |
1415 | triggerHandler: function( type, data ) { |
- | 1416 | if ( this[0] ) { |
|
- | 1417 | var event = jQuery.Event( type ); |
|
- | 1418 | event.preventDefault(); |
|
- | 1419 | event.stopPropagation(); |
|
1355 | array = Array.prototype.slice.call( array, 0 ); |
1420 | jQuery.event.trigger( event, data, this[0] ); |
- | 1421 | return event.result; |
|
- | 1422 | }
|
|
- | 1423 | }, |
|
1356 | 1424 | ||
1357 | if ( results ) { |
1425 | toggle: function( fn ) { |
1358 | results.push.apply( results, array ); |
1426 | // Save reference to arguments for access in closure
|
1359 | return results; |
1427 | var args = arguments, i = 1; |
1360 | }
|
- | |
1361 | - | ||
1362 | return array; |
- | |
1363 | }; |
- | |
1364 | 1428 | ||
1365 | // Perform a simple check to determine if the browser is capable of
|
1429 | // link all the functions, so any of them can unbind this click handler
|
- | 1430 | while( i < args.length ) { |
|
1366 | // converting a NodeList to an array using builtin methods.
|
1431 | jQuery.event.proxy( fn, args[ i++ ] ); |
1367 | try { |
1432 | }
|
1368 | Array.prototype.slice.call( document.documentElement.childNodes, 0 ); |
- | |
1369 | 1433 | ||
1370 | // Provide a fallback method if it does not work
|
1434 | return this.click( jQuery.event.proxy( fn, function( event ) { |
1371 | } catch(e){ |
- | |
1372 | makeArray = function(array, results) { |
1435 | // Figure out which function to execute
|
1373 | var ret = results || []; |
1436 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
1374 | 1437 | ||
1375 | if ( toString.call(array) === "[object Array]" ) { |
- | |
1376 | Array.prototype.push.apply( ret, array ); |
- | |
1377 | } else { |
- | |
1378 | if ( typeof array.length === "number" ) { |
- | |
1379 | for ( var i = 0, l = array.length; i < l; i++ ) { |
- | |
1380 | ret.push( array[i] ); |
1438 | // Make sure that clicks stop
|
1381 | }
|
- | |
1382 | } else { |
- | |
1383 | for ( var i = 0; array[i]; i++ ) { |
- | |
1384 | ret.push( array[i] ); |
1439 | event.preventDefault(); |
1385 | }
|
- | |
1386 | }
|
- | |
1387 | }
|
- | |
1388 | 1440 | ||
1389 | return ret; |
1441 | // and execute the function
|
- | 1442 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
|
1390 | }; |
1443 | })); |
1391 | }
|
1444 | }, |
1392 | 1445 | ||
1393 | var sortOrder; |
1446 | hover: function( fnOver, fnOut ) { |
- | 1447 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
|
- | 1448 | }, |
|
1394 | 1449 | ||
1395 | if ( document.documentElement.compareDocumentPosition ) { |
- | |
1396 | sortOrder = function( a, b ) { |
1450 | ready: function( fn ) { |
1397 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
- | |
1398 | if ( ret === 0 ) { |
- | |
1399 | hasDuplicate = true; |
- | |
1400 | }
|
- | |
1401 | return ret; |
- | |
1402 | }; |
- | |
1403 | } else if ( "sourceIndex" in document.documentElement ) { |
- | |
1404 | sortOrder = function( a, b ) { |
- | |
1405 | var ret = a.sourceIndex - b.sourceIndex; |
- | |
1406 | if ( ret === 0 ) { |
- | |
1407 | hasDuplicate = true; |
1451 | // Attach the listeners
|
1408 | }
|
- | |
1409 | return ret; |
- | |
1410 | }; |
- | |
1411 | } else if ( document.createRange ) { |
- | |
1412 | sortOrder = function( a, b ) { |
- | |
1413 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
- | |
1414 | aRange.selectNode(a); |
- | |
1415 | aRange.collapse(true); |
- | |
1416 | bRange.selectNode(b); |
1452 | bindReady(); |
1417 | bRange.collapse(true); |
- | |
1418 | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
- | |
1419 | if ( ret === 0 ) { |
- | |
1420 | hasDuplicate = true; |
- | |
1421 | }
|
- | |
1422 | return ret; |
- | |
1423 | }; |
- | |
1424 | }
|
- | |
1425 | 1453 | ||
1426 | // Check to see if the browser returns elements by name when
|
1454 | // If the DOM is already ready
|
1427 | // querying by getElementById (and provide a workaround)
|
- | |
1428 | (function(){ |
- | |
1429 | // We're going to inject a fake input element with a specified name
|
- | |
1430 | var form = document.createElement("div"), |
1455 | if ( jQuery.isReady ) { |
1431 | id = "script" + (new Date).getTime(); |
1456 | // Execute the function immediately
|
1432 | form.innerHTML = "<a name='" + id + "'/>"; |
1457 | fn.call( document, jQuery ); |
1433 | 1458 | ||
1434 | // Inject it into the root element, check its status, and remove it quickly
|
1459 | // Otherwise, remember the function for later
|
- | 1460 | } else { |
|
1435 | var root = document.documentElement; |
1461 | // Add the function to the wait list
|
1436 | root.insertBefore( form, root.firstChild ); |
1462 | jQuery.readyList.push( fn ); |
- | 1463 | }
|
|
1437 | 1464 | ||
1438 | // The workaround has to do additional checks after a getElementById
|
1465 | return this; |
- | 1466 | }, |
|
- | 1467 | ||
1439 | // Which slows things down for other browsers (hence the branching)
|
1468 | live: function( type, data, fn, thisObject ) { |
1440 | if ( !!document.getElementById( id ) ) { |
1469 | if ( jQuery.isFunction( data ) ) { |
1441 | Expr.find.ID = function(match, context, isXML){ |
- | |
1442 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
1470 | if ( fn !== undefined ) { |
1443 | var m = context.getElementById(match[1]); |
1471 | thisObject = fn; |
1444 | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
- | |
1445 | }
|
1472 | }
|
- | 1473 | fn = data; |
|
- | 1474 | data = undefined; |
|
1446 | }; |
1475 | }
|
- | 1476 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
|
- | 1477 | data: data, selector: this.selector, live: type |
|
- | 1478 | }, fn, thisObject ); |
|
- | 1479 | return this; |
|
- | 1480 | }, |
|
1447 | 1481 | ||
1448 | Expr.filter.ID = function(elem, match){ |
1482 | die: function( type, fn ) { |
1449 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
1483 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
1450 | return elem.nodeType === 1 && node && node.nodeValue === match; |
- | |
1451 | }; |
1484 | return this; |
1452 | }
|
1485 | }
|
- | 1486 | }); |
|
1453 | 1487 | ||
1454 | root.removeChild( form ); |
1488 | function liveHandler( event ) { |
1455 | root = form = null; // release memory in IE |
1489 | var stop = true, elems = [], args = arguments; |
1456 | })(); |
- | |
1457 | 1490 | ||
- | 1491 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
|
1458 | (function(){ |
1492 | if ( fn.live === event.type ) { |
1459 | // Check to see if the browser returns only elements
|
1493 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
- | 1494 | if ( elem ) { |
|
1460 | // when doing getElementsByTagName("*")
|
1495 | elems.push({ elem: elem, fn: fn }); |
- | 1496 | }
|
|
- | 1497 | }
|
|
- | 1498 | }); |
|
1461 | 1499 | ||
1462 | // Create a fake element
|
1500 | elems.sort(function( a, b ) { |
1463 | var div = document.createElement("div"); |
- | |
1464 | div.appendChild( document.createComment("") ); |
1501 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
- | 1502 | }); |
|
1465 | 1503 | ||
1466 | // Make sure no comments are found
|
1504 | jQuery.each(elems, function() { |
1467 | if ( div.getElementsByTagName("*").length > 0 ) { |
1505 | event.currentTarget = this.elem; |
1468 | Expr.find.TAG = function(match, context){ |
1506 | event.data = this.fn.data; |
1469 | var results = context.getElementsByTagName(match[1]); |
1507 | if ( this.fn.apply( this.elem, args ) === false ) { |
- | 1508 | return (stop = false); |
|
- | 1509 | }
|
|
- | 1510 | }); |
|
1470 | 1511 | ||
1471 | // Filter out possible comments
|
- | |
1472 | if ( match[1] === "*" ) { |
- | |
1473 | var tmp = []; |
1512 | return stop; |
- | 1513 | }
|
|
1474 | 1514 | ||
1475 | for ( var i = 0; results[i]; i++ ) { |
1515 | function liveConvert( type, selector ) { |
- | 1516 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
|
- | 1517 | }
|
|
- | 1518 | ||
- | 1519 | jQuery.extend({ |
|
- | 1520 | isReady: false, |
|
- | 1521 | readyList: [], |
|
- | 1522 | // Handle when the DOM is ready
|
|
- | 1523 | ready: function() { |
|
- | 1524 | // Make sure that the DOM is not already loaded
|
|
1476 | if ( results[i].nodeType === 1 ) { |
1525 | if ( !jQuery.isReady ) { |
- | 1526 | // Remember that the DOM is ready
|
|
- | 1527 | jQuery.isReady = true; |
|
- | 1528 | ||
- | 1529 | // If there are functions bound, to execute
|
|
1477 | tmp.push( results[i] ); |
1530 | if ( jQuery.readyList ) { |
- | 1531 | // Execute all of them
|
|
1478 | }
|
1532 | var fn, i = 0; |
- | 1533 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
|
- | 1534 | fn.call( document, jQuery ); |
|
1479 | }
|
1535 | }
|
1480 | 1536 | ||
- | 1537 | // Reset the list of functions
|
|
1481 | results = tmp; |
1538 | jQuery.readyList = null; |
1482 | }
|
1539 | }
|
1483 | 1540 | ||
1484 | return results; |
- | |
1485 | }; |
- | |
1486 | }
|
- | |
1487 | - | ||
1488 | // Check to see if an attribute returns normalized href attributes
|
- | |
1489 | div.innerHTML = "<a href='#'></a>"; |
1541 | // Trigger any bound ready events
|
1490 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
- | |
1491 | div.firstChild.getAttribute("href") !== "#" ) { |
- | |
1492 | Expr.attrHandle.href = function(elem){ |
- | |
1493 | return elem.getAttribute("href", 2); |
1542 | jQuery( document ).triggerHandler( "ready" ); |
1494 | }; |
1543 | }
|
1495 | }
|
1544 | }
|
- | 1545 | }); |
|
1496 | 1546 | ||
1497 | div = null; // release memory in IE |
1547 | var readyBound = false; |
1498 | })(); |
- | |
1499 | 1548 | ||
1500 | if ( document.querySelectorAll ) (function(){ |
1549 | function bindReady() { |
1501 | var oldSizzle = Sizzle, div = document.createElement("div"); |
1550 | if ( readyBound ) return; |
1502 | div.innerHTML = "<p class='TEST'></p>"; |
1551 | readyBound = true; |
1503 | 1552 | ||
1504 | // Safari can't handle uppercase or unicode characters when
|
1553 | // Catch cases where $(document).ready() is called after the
|
1505 | // in quirks mode.
|
1554 | // browser event has already occurred.
|
1506 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
1555 | if ( document.readyState === "complete" ) { |
1507 | return; |
1556 | return jQuery.ready(); |
1508 | }
|
1557 | }
|
1509 | - | ||
1510 | Sizzle = function(query, context, extra, seed){ |
- | |
1511 | context = context || document; |
- | |
1512 | 1558 | ||
1513 | // Only use querySelectorAll on non-XML documents
|
1559 | // Mozilla, Opera and webkit nightlies currently support this event
|
- | 1560 | if ( document.addEventListener ) { |
|
1514 | // (ID selectors don't work in non-HTML documents)
|
1561 | // Use the handy event callback
|
1515 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
1562 | document.addEventListener( "DOMContentLoaded", function() { |
1516 | try { |
- | |
1517 | return makeArray( context.querySelectorAll(query), extra ); |
1563 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
1518 | } catch(e){} |
1564 | jQuery.ready(); |
1519 | }
|
- | |
1520 | - | ||
1521 | return oldSizzle(query, context, extra, seed); |
- | |
1522 | }; |
1565 | }, false ); |
1523 | 1566 | ||
- | 1567 | // If IE event model is used
|
|
1524 | for ( var prop in oldSizzle ) { |
1568 | } else if ( document.attachEvent ) { |
1525 | Sizzle[ prop ] = oldSizzle[ prop ]; |
1569 | // ensure firing before onload,
|
- | 1570 | // maybe late but safe also for iframes
|
|
- | 1571 | document.attachEvent("onreadystatechange", function() { |
|
- | 1572 | if ( document.readyState === "complete" ) { |
|
- | 1573 | document.detachEvent( "onreadystatechange", arguments.callee ); |
|
- | 1574 | jQuery.ready(); |
|
1526 | }
|
1575 | }
|
- | 1576 | }); |
|
1527 | 1577 | ||
- | 1578 | // If IE and not an iframe
|
|
- | 1579 | // continually check to see if the document is ready
|
|
- | 1580 | // NOTE: DO NOT CHANGE TO ===, FAILS IN IE.
|
|
- | 1581 | if ( document.documentElement.doScroll && window == window.top ) (function() { |
|
1528 | div = null; // release memory in IE |
1582 | if ( jQuery.isReady ) { |
- | 1583 | return; |
|
1529 | })(); |
1584 | }
|
1530 | 1585 | ||
- | 1586 | try { |
|
- | 1587 | // If IE is used, use the trick by Diego Perini
|
|
1531 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
1588 | // http://javascript.nwbox.com/IEContentLoaded/
|
1532 | var div = document.createElement("div"); |
1589 | document.documentElement.doScroll("left"); |
- | 1590 | } catch( error ) { |
|
1533 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
1591 | setTimeout( arguments.callee, 0 ); |
- | 1592 | return; |
|
- | 1593 | }
|
|
1534 | 1594 | ||
1535 | // Opera can't find a second classname (in 9.6)
|
1595 | // and execute any waiting functions
|
1536 | if ( div.getElementsByClassName("e").length === 0 ) |
1596 | jQuery.ready(); |
1537 | return; |
1597 | })(); |
- | 1598 | }
|
|
1538 | 1599 | ||
1539 | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
1600 | // A fallback to window.onload, that will always work
|
1540 | div.lastChild.className = "e"; |
1601 | jQuery.event.add( window, "load", jQuery.ready ); |
- | 1602 | }
|
|
1541 | 1603 | ||
- | 1604 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
|
- | 1605 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
|
1542 | if ( div.getElementsByClassName("e").length === 1 ) |
1606 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
1543 | return; |
- | |
1544 | 1607 | ||
1545 | Expr.order.splice(1, 0, "CLASS"); |
1608 | // Handle event binding
|
1546 | Expr.find.CLASS = function(match, context, isXML) { |
1609 | jQuery.fn[ name ] = function( fn ) { |
1547 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
- | |
1548 | return context.getElementsByClassName(match[1]); |
1610 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
1549 | }
|
- | |
1550 | }; |
1611 | }; |
- | 1612 | }); |
|
1551 | 1613 | ||
1552 | div = null; // release memory in IE |
1614 | // Prevent memory leaks in IE
|
1553 | })(); |
- | |
1554 | - | ||
1555 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1615 | // Window isn't included so as not to unbind existing unload events
|
- | 1616 | // More info:
|
|
1556 | var sibDir = dir == "previousSibling" && !isXML; |
1617 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
- | 1618 | /*@cc_on
|
|
1557 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1619 | jQuery( window ).bind( 'unload', function() {
|
1558 | var elem = checkSet[i]; |
1620 | for ( var id in jQuery.cache ) {
|
1559 | if ( elem ) { |
1621 | // Skip the window
|
1560 | if ( sibDir && elem.nodeType === 1 ){ |
1622 | if ( id != 1 && jQuery.cache[ id ].handle ) {
|
1561 | elem.sizcache = doneName; |
1623 | jQuery.event.remove( jQuery.cache[ id ].handle.elem );
|
1562 | elem.sizset = i; |
1624 | }
|
1563 | }
|
1625 | }
|
1564 | elem = elem[dir]; |
1626 | });
|
- | 1627 | @*/
|
|
1565 | var match = false; |
1628 | (function(){ |
1566 | 1629 | ||
1567 | while ( elem ) { |
1630 | jQuery.support = {}; |
1568 | if ( elem.sizcache === doneName ) { |
- | |
1569 | match = checkSet[elem.sizset]; |
- | |
1570 | break; |
- | |
1571 | }
|
- | |
1572 | 1631 | ||
- | 1632 | var root = document.documentElement, |
|
1573 | if ( elem.nodeType === 1 && !isXML ){ |
1633 | script = document.createElement("script"), |
1574 | elem.sizcache = doneName; |
1634 | div = document.createElement("div"), |
1575 | elem.sizset = i; |
1635 | id = "script" + (new Date).getTime(); |
1576 | }
|
- | |
1577 | 1636 | ||
1578 | if ( elem.nodeName === cur ) { |
1637 | div.style.display = "none"; |
1579 | match = elem; |
- | |
1580 | break; |
- | |
1581 | }
|
- | |
- | 1638 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
|
1582 | 1639 | ||
- | 1640 | var all = div.getElementsByTagName("*"), |
|
1583 | elem = elem[dir]; |
1641 | a = div.getElementsByTagName("a")[0]; |
1584 | }
|
- | |
1585 | 1642 | ||
1586 | checkSet[i] = match; |
1643 | // Can't get basic test support
|
- | 1644 | if ( !all || !all.length || !a ) { |
|
1587 | }
|
1645 | return; |
1588 | }
|
1646 | }
|
1589 | }
|
- | |
1590 | 1647 | ||
1591 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
- | |
1592 | var sibDir = dir == "previousSibling" && !isXML; |
- | |
1593 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
- | |
1594 | var elem = checkSet[i]; |
- | |
1595 | if ( elem ) { |
1648 | jQuery.support = { |
1596 | if ( sibDir && elem.nodeType === 1 ) { |
1649 | // IE strips leading whitespace when .innerHTML is used
|
1597 | elem.sizcache = doneName; |
1650 | leadingWhitespace: div.firstChild.nodeType == 3, |
1598 | elem.sizset = i; |
- | |
1599 | }
|
- | |
1600 | elem = elem[dir]; |
- | |
1601 | var match = false; |
- | |
1602 | 1651 | ||
1603 | while ( elem ) { |
1652 | // Make sure that tbody elements aren't automatically inserted
|
1604 | if ( elem.sizcache === doneName ) { |
1653 | // IE will insert them into empty tables
|
1605 | match = checkSet[elem.sizset]; |
1654 | tbody: !div.getElementsByTagName("tbody").length, |
1606 | break; |
- | |
1607 | }
|
- | |
1608 | 1655 | ||
1609 | if ( elem.nodeType === 1 ) { |
1656 | // Make sure that link elements get serialized correctly by innerHTML
|
1610 | if ( !isXML ) { |
- | |
1611 | elem.sizcache = doneName; |
1657 | // This requires a wrapper element in IE
|
1612 | elem.sizset = i; |
- | |
1613 | }
|
- | |
1614 | if ( typeof cur !== "string" ) { |
1658 | htmlSerialize: !!div.getElementsByTagName("link").length, |
1615 | if ( elem === cur ) { |
- | |
1616 | match = true; |
- | |
1617 | break; |
- | |
1618 | }
|
- | |
1619 | 1659 | ||
1620 | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
1660 | // Get the style information from getAttribute
|
1621 | match = elem; |
1661 | // (IE uses .cssText insted)
|
1622 | break; |
1662 | style: /red/.test( a.getAttribute("style") ), |
1623 | }
|
- | |
1624 | }
|
- | |
1625 | 1663 | ||
1626 | elem = elem[dir]; |
1664 | // Make sure that URLs aren't manipulated
|
1627 | }
|
1665 | // (IE normalizes it by default)
|
- | 1666 | hrefNormalized: a.getAttribute("href") === "/a", |
|
1628 | 1667 | ||
- | 1668 | // Make sure that element opacity exists
|
|
1629 | checkSet[i] = match; |
1669 | // (IE uses filter instead)
|
1630 | }
|
1670 | opacity: a.style.opacity === "0.5", |
1631 | }
|
- | |
1632 | }
|
- | |
1633 | 1671 | ||
1634 | var contains = document.compareDocumentPosition ? function(a, b){ |
1672 | // Verify style float existence
|
1635 | return a.compareDocumentPosition(b) & 16; |
1673 | // (IE uses styleFloat instead of cssFloat)
|
1636 | } : function(a, b){ |
- | |
1637 | return a !== b && (a.contains ? a.contains(b) : true); |
1674 | cssFloat: !!a.style.cssFloat, |
1638 | }; |
- | |
1639 | 1675 | ||
1640 | var isXML = function(elem){ |
1676 | // Will be defined later
|
1641 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
1677 | scriptEval: false, |
1642 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
1678 | noCloneEvent: true, |
- | 1679 | boxModel: null |
|
1643 | }; |
1680 | }; |
1644 | 1681 | ||
1645 | var posProcess = function(selector, context){ |
1682 | script.type = "text/javascript"; |
1646 | var tmpSet = [], later = "", match, |
1683 | try { |
1647 | root = context.nodeType ? [context] : context; |
1684 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
- | 1685 | } catch(e){} |
|
1648 | 1686 | ||
1649 | // Position selectors must be done after the filter
|
1687 | root.insertBefore( script, root.firstChild ); |
- | 1688 | ||
1650 | // And so must :not(positional) so we move all PSEUDOs to the end
|
1689 | // Make sure that the execution of code works by injecting a script
|
- | 1690 | // tag with appendChild/createTextNode
|
|
1651 | while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
1691 | // (IE doesn't support this, fails, and uses .text instead)
|
1652 | later += match[0]; |
1692 | if ( window[ id ] ) { |
1653 | selector = selector.replace( Expr.match.PSEUDO, "" ); |
1693 | jQuery.support.scriptEval = true; |
- | 1694 | delete window[ id ]; |
|
1654 | }
|
1695 | }
|
1655 | 1696 | ||
1656 | selector = Expr.relative[selector] ? selector + "*" : selector; |
1697 | root.removeChild( script ); |
1657 | 1698 | ||
- | 1699 | if ( div.attachEvent && div.fireEvent ) { |
|
- | 1700 | div.attachEvent("onclick", function click(){ |
|
1658 | for ( var i = 0, l = root.length; i < l; i++ ) { |
1701 | // Cloning a node shouldn't copy over any
|
- | 1702 | // bound event handlers (IE does this)
|
|
- | 1703 | jQuery.support.noCloneEvent = false; |
|
1659 | Sizzle( selector, root[i], tmpSet ); |
1704 | div.detachEvent("onclick", click); |
- | 1705 | }); |
|
- | 1706 | div.cloneNode(true).fireEvent("onclick"); |
|
1660 | }
|
1707 | }
|
1661 | 1708 | ||
1662 | return Sizzle.filter( later, tmpSet ); |
1709 | // Figure out if the W3C box model works as expected
|
1663 | }; |
- | |
1664 | - | ||
1665 | // EXPOSE
|
1710 | // document.body must exist before we can do this
|
1666 | jQuery.find = Sizzle; |
1711 | jQuery(function(){ |
1667 | jQuery.expr = Sizzle.selectors; |
1712 | var div = document.createElement("div"); |
1668 | jQuery.expr[":"] = jQuery.expr.filters; |
1713 | div.style.width = div.style.paddingLeft = "1px"; |
1669 | 1714 | ||
1670 | Sizzle.selectors.filters.hidden = function(elem){ |
1715 | document.body.appendChild( div ); |
1671 | var width = elem.offsetWidth, height = elem.offsetHeight, |
1716 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
1672 | force = /^tr$/i.test( elem.nodeName ); // ticket #4512 |
1717 | document.body.removeChild( div ).style.display = 'none'; |
1673 | return ( width === 0 && height === 0 && !force ) ? |
- | |
1674 | true : |
- | |
1675 | ( width !== 0 && height !== 0 && !force ) ? |
- | |
1676 | false : |
1718 | div = null; |
1677 | !!( jQuery.curCSS(elem, "display") === "none" ); |
- | |
1678 | }; |
1719 | }); |
1679 | 1720 | ||
1680 | Sizzle.selectors.filters.visible = function(elem){ |
1721 | // release memory in IE
|
1681 | return !Sizzle.selectors.filters.hidden(elem); |
1722 | root = script = div = all = a = null; |
1682 | }; |
1723 | })(); |
1683 | 1724 | ||
1684 | Sizzle.selectors.filters.animated = function(elem){ |
1725 | jQuery.props = { |
- | 1726 | "for": "htmlFor", |
|
1685 | return jQuery.grep(jQuery.timers, function(fn){ |
1727 | "class": "className", |
1686 | return elem === fn.elem; |
1728 | readonly: "readOnly", |
1687 | }).length; |
1729 | maxlength: "maxLength", |
- | 1730 | cellspacing: "cellSpacing", |
|
- | 1731 | rowspan: "rowSpan", |
|
- | 1732 | colspan: "colSpan", |
|
- | 1733 | tabindex: "tabIndex" |
|
1688 | }; |
1734 | }; |
- | 1735 | /*!
|
|
- | 1736 | * Sizzle CSS Selector Engine - v1.0
|
|
- | 1737 | * Copyright 2009, The Dojo Foundation
|
|
- | 1738 | * Released under the MIT, BSD, and GPL Licenses.
|
|
- | 1739 | * More information: http://sizzlejs.com/
|
|
- | 1740 | */
|
|
- | 1741 | (function(){ |
|
1689 | 1742 | ||
1690 | jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) { |
1743 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
1691 | if ( not ) { |
1744 | done = 0, |
1692 | expr = ":not(" + expr + ")"; |
1745 | toString = Object.prototype.toString, |
1693 | }
|
1746 | hasDuplicate = false; |
1694 | 1747 | ||
- | 1748 | var Sizzle = function(selector, context, results, seed) { |
|
1695 | return Sizzle.matches(expr, elems); |
1749 | results = results || []; |
1696 | }; |
- | |
- | 1750 | var origContext = context = context || document; |
|
1697 | 1751 | ||
1698 | jQuery.dir = function( elem, dir ){ |
1752 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
1699 | var matched = [], cur = elem[dir]; |
1753 | return []; |
- | 1754 | }
|
|
- | 1755 | ||
1700 | while ( cur && cur != document ) { |
1756 | if ( !selector || typeof selector !== "string" ) { |
1701 | if ( cur.nodeType == 1 ) |
- | |
1702 | matched.push( cur ); |
- | |
1703 | cur = cur[dir]; |
1757 | return results; |
1704 | }
|
1758 | }
|
1705 | return matched; |
- | |
1706 | }; |
- | |
1707 | - | ||
1708 | jQuery.nth = function(cur, result, dir, elem){ |
- | |
1709 | result = result || 1; |
- | |
1710 | var num = 0; |
- | |
1711 | 1759 | ||
- | 1760 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
|
- | 1761 | ||
- | 1762 | // Reset the position of the chunker regexp (start from head)
|
|
1712 | for ( ; cur; cur = cur[dir] ) |
1763 | chunker.lastIndex = 0; |
- | 1764 | ||
1713 | if ( cur.nodeType == 1 && ++num == result ) |
1765 | while ( (m = chunker.exec(selector)) !== null ) { |
- | 1766 | parts.push( m[1] ); |
|
- | 1767 | ||
- | 1768 | if ( m[2] ) { |
|
- | 1769 | extra = RegExp.rightContext; |
|
1714 | break; |
1770 | break; |
1715 | - | ||
1716 | return cur; |
- | |
1717 | }; |
1771 | }
|
1718 | - | ||
1719 | jQuery.sibling = function(n, elem){ |
- | |
1720 | var r = []; |
- | |
1721 | - | ||
1722 | for ( ; n; n = n.nextSibling ) { |
- | |
1723 | if ( n.nodeType == 1 && n != elem ) |
- | |
1724 | r.push( n ); |
- | |
1725 | }
|
1772 | }
|
1726 | 1773 | ||
- | 1774 | if ( parts.length > 1 && origPOS.exec( selector ) ) { |
|
- | 1775 | if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
|
- | 1776 | set = posProcess( parts[0] + parts[1], context ); |
|
1727 | return r; |
1777 | } else { |
- | 1778 | set = Expr.relative[ parts[0] ] ? |
|
1728 | }; |
1779 | [ context ] : |
- | 1780 | Sizzle( parts.shift(), context ); |
|
1729 | 1781 | ||
- | 1782 | while ( parts.length ) { |
|
1730 | return; |
1783 | selector = parts.shift(); |
1731 | 1784 | ||
- | 1785 | if ( Expr.relative[ selector ] ) |
|
1732 | window.Sizzle = Sizzle; |
1786 | selector += parts.shift(); |
1733 | 1787 | ||
- | 1788 | set = posProcess( selector, set ); |
|
1734 | })(); |
1789 | }
|
- | 1790 | }
|
|
1735 | jQuery.winnow = function( elements, qualifier, keep ) { |
1791 | } else { |
1736 | if(jQuery.isFunction( qualifier )) { |
1792 | // Take a shortcut and set the context if the root selector is an ID
|
1737 | return jQuery.grep(elements, function(elem, i) { |
1793 | // (but not if it'll be faster if the inner selector is an ID)
|
1738 | return !!qualifier.call( elem, i ) === keep; |
1794 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
1739 | }); |
- | |
1740 | } else if( qualifier.nodeType ) { |
1795 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
1741 | return jQuery.grep(elements, function(elem, i) { |
1796 | var ret = Sizzle.find( parts.shift(), context, contextXML ); |
1742 | return (elem === qualifier) === keep; |
1797 | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
1743 | }) |
1798 | }
|
1744 | } else if( typeof qualifier === "string" ) { |
- | |
1745 | var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 }); |
- | |
1746 | 1799 | ||
- | 1800 | if ( context ) { |
|
- | 1801 | var ret = seed ? |
|
1747 | if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep); |
1802 | { expr: parts.pop(), set: makeArray(seed) } : |
- | 1803 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
|
1748 | else qualifier = jQuery.multiFilter( qualifier, elements ); |
1804 | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
1749 | }
|
- | |
1750 | 1805 | ||
1751 | return jQuery.grep(elements, function(elem, i) { |
1806 | if ( parts.length > 0 ) { |
1752 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
1807 | checkSet = makeArray(set); |
1753 | }); |
1808 | } else { |
- | 1809 | prune = false; |
|
1754 | }
|
1810 | }
|
1755 | 1811 | ||
1756 | jQuery.fn.extend({ |
- | |
1757 | find: function( selector ) { |
1812 | while ( parts.length ) { |
1758 | var ret = this.pushStack( "", "find", selector ), length = 0; |
1813 | var cur = parts.pop(), pop = cur; |
1759 | 1814 | ||
1760 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1815 | if ( !Expr.relative[ cur ] ) { |
1761 | length = ret.length; |
1816 | cur = ""; |
- | 1817 | } else { |
|
1762 | jQuery.find( selector, this[i], ret ); |
1818 | pop = parts.pop(); |
- | 1819 | }
|
|
1763 | 1820 | ||
1764 | if ( i > 0 ) { |
1821 | if ( pop == null ) { |
1765 | // Make sure that the results are unique
|
- | |
1766 | for ( var n = length; n < ret.length; n++ ) { |
- | |
1767 | for ( var r = 0; r < length; r++ ) { |
- | |
1768 | if ( ret[r] === ret[n] ) { |
- | |
1769 | ret.splice(n--, 1); |
- | |
1770 | break; |
1822 | pop = context; |
1771 | }
|
- | |
1772 | }
|
- | |
1773 | }
|
1823 | }
|
- | 1824 | ||
- | 1825 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
|
1774 | }
|
1826 | }
|
- | 1827 | } else { |
|
- | 1828 | checkSet = parts = []; |
|
1775 | }
|
1829 | }
|
- | 1830 | }
|
|
1776 | 1831 | ||
1777 | return ret; |
- | |
1778 | }, |
- | |
1779 | - | ||
1780 | not: function( selector ) { |
1832 | if ( !checkSet ) { |
1781 | return this.pushStack( jQuery.winnow(this, selector, false), "not", selector); |
- | |
1782 | }, |
- | |
1783 | - | ||
1784 | filter: function( selector ) { |
1833 | checkSet = set; |
1785 | return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector ); |
- | |
1786 | }, |
1834 | }
|
1787 | 1835 | ||
1788 | closest: function( selector ) { |
1836 | if ( !checkSet ) { |
1789 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
1837 | throw "Syntax error, unrecognized expression: " + (cur || selector); |
1790 | closer = 0, |
1838 | }
|
1791 | context = this.context; |
- | |
1792 | 1839 | ||
1793 | return this.map(function(){ |
1840 | if ( toString.call(checkSet) === "[object Array]" ) { |
1794 | var cur = this; |
1841 | if ( !prune ) { |
1795 | while ( cur && cur.ownerDocument && cur !== context ) { |
1842 | results.push.apply( results, checkSet ); |
1796 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
1843 | } else if ( context && context.nodeType === 1 ) { |
1797 | jQuery.data(cur, "closest", closer); |
1844 | for ( var i = 0; checkSet[i] != null; i++ ) { |
- | 1845 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
|
1798 | return cur; |
1846 | results.push( set[i] ); |
1799 | }
|
1847 | }
|
1800 | cur = cur.parentNode; |
- | |
1801 | closer++;
|
- | |
1802 | }
|
1848 | }
|
- | 1849 | } else { |
|
- | 1850 | for ( var i = 0; checkSet[i] != null; i++ ) { |
|
- | 1851 | if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
|
- | 1852 | results.push( set[i] ); |
|
- | 1853 | }
|
|
- | 1854 | }
|
|
1803 | }); |
1855 | }
|
- | 1856 | } else { |
|
- | 1857 | makeArray( checkSet, results ); |
|
1804 | }, |
1858 | }
|
1805 | 1859 | ||
1806 | add: function( selector ) { |
1860 | if ( extra ) { |
1807 | return this.pushStack( jQuery.unique( jQuery.merge( |
- | |
1808 | this.get(), |
- | |
1809 | typeof selector === "string" ? |
1861 | Sizzle( extra, origContext, results, seed ); |
1810 | jQuery( selector ) : |
- | |
1811 | jQuery.makeArray( selector ) |
1862 | Sizzle.uniqueSort( results ); |
1812 | ))); |
- | |
1813 | }, |
1863 | }
|
1814 | 1864 | ||
1815 | eq: function( i ) { |
- | |
1816 | return this.slice( i, +i + 1 ); |
1865 | return results; |
1817 | }, |
1866 | }; |
1818 | 1867 | ||
- | 1868 | Sizzle.uniqueSort = function(results){ |
|
1819 | slice: function() { |
1869 | if ( sortOrder ) { |
1820 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
1870 | hasDuplicate = false; |
1821 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
1871 | results.sort(sortOrder); |
1822 | }, |
- | |
1823 | 1872 | ||
1824 | map: function( callback ) { |
1873 | if ( hasDuplicate ) { |
1825 | return this.pushStack( jQuery.map(this, function(elem, i){ |
1874 | for ( var i = 1; i < results.length; i++ ) { |
- | 1875 | if ( results[i] === results[i-1] ) { |
|
1826 | return callback.call( elem, i, elem ); |
1876 | results.splice(i--, 1); |
- | 1877 | }
|
|
- | 1878 | }
|
|
1827 | })); |
1879 | }
|
1828 | }, |
1880 | }
|
1829 | 1881 | ||
1830 | andSelf: function() { |
- | |
1831 | return this.add( this.prevObject ); |
1882 | return results; |
1832 | }, |
1883 | }; |
1833 | 1884 | ||
1834 | end: function() { |
1885 | Sizzle.matches = function(expr, set){ |
1835 | return this.prevObject || jQuery(null); |
1886 | return Sizzle(expr, null, null, set); |
1836 | }
|
- | |
1837 | }); |
1887 | }; |
1838 | 1888 | ||
1839 | jQuery.each({ |
- | |
1840 | parent: function(elem){return elem.parentNode;}, |
- | |
1841 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
- | |
1842 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
- | |
1843 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
- | |
1844 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
- | |
1845 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
- | |
1846 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
- | |
1847 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
- | |
1848 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
- | |
1849 | }, function(name, fn){ |
- | |
1850 | jQuery.fn[ name ] = function( selector ) { |
1889 | Sizzle.find = function(expr, context, isXML){ |
1851 | var ret = jQuery.map( this, fn ); |
1890 | var set, match; |
1852 | 1891 | ||
1853 | if ( selector && typeof selector == "string" ) |
1892 | if ( !expr ) { |
1854 | ret = jQuery.multiFilter( selector, ret ); |
1893 | return []; |
- | 1894 | }
|
|
1855 | 1895 | ||
1856 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
1896 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
1857 | }; |
1897 | var type = Expr.order[i], match; |
1858 | }); |
1898 | |
1859 | jQuery.fn.extend({ |
- | |
1860 | attr: function( name, value ) { |
1899 | if ( (match = Expr.match[ type ].exec( expr )) ) { |
1861 | var elem, options, isFunction = jQuery.isFunction(value); |
1900 | var left = RegExp.leftContext; |
1862 | 1901 | ||
1863 | if ( typeof name === "string" ) { // A single attribute |
1902 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
1864 | if ( value === undefined ) { // Query it on first element |
- | |
1865 | return this.length ? |
- | |
1866 | jQuery.attr( this[0], name ) : |
1903 | match[1] = (match[1] || "").replace(/\\/g, ""); |
1867 | null; |
- | |
1868 | } else { // Set it on all elements |
- | |
1869 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1904 | set = Expr.find[ type ]( match, context, isXML ); |
1870 | elem = this[i]; |
- | |
1871 | if ( isFunction ) |
1905 | if ( set != null ) { |
1872 | value = value.call(elem,i); |
- | |
1873 | jQuery.attr( elem, name, value ); |
1906 | expr = expr.replace( Expr.match[ type ], "" ); |
1874 | }
|
1907 | break; |
1875 | }
|
- | |
1876 | } else { // Multiple attributes to set on all |
- | |
1877 | options = name; |
- | |
1878 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | |
1879 | elem = this[i]; |
- | |
1880 | for ( name in options ) { |
- | |
1881 | value = options[name]; |
- | |
1882 | if ( jQuery.isFunction(value) ) |
- | |
1883 | value = value.call(elem,i); |
- | |
1884 | jQuery.attr( elem, name, value ); |
- | |
1885 | }
|
1908 | }
|
1886 | }
|
1909 | }
|
1887 | }
|
1910 | }
|
- | 1911 | }
|
|
1888 | 1912 | ||
1889 | return this; |
1913 | if ( !set ) { |
1890 | }, |
- | |
1891 | - | ||
1892 | hasClass: function( selector ) { |
- | |
1893 | return !!selector && this.is( "." + selector ); |
1914 | set = context.getElementsByTagName("*"); |
1894 | }, |
1915 | }
|
1895 | 1916 | ||
1896 | val: function( value ) { |
- | |
1897 | if ( value === undefined ) { |
1917 | return {set: set, expr: expr}; |
1898 | var elem = this[0]; |
1918 | }; |
1899 | 1919 | ||
1900 | if ( elem ) { |
1920 | Sizzle.filter = function(expr, set, inplace, not){ |
1901 | if( jQuery.nodeName( elem, 'option' ) ) |
1921 | var old = expr, result = [], curLoop = set, match, anyFound, |
1902 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
1922 | isXMLFilter = set && set[0] && isXML(set[0]); |
1903 | 1923 | ||
1904 | // We need to handle select boxes special
|
1924 | while ( expr && set.length ) { |
1905 | if ( jQuery.nodeName( elem, "select" ) ) { |
1925 | for ( var type in Expr.filter ) { |
1906 | var index = elem.selectedIndex, |
1926 | if ( (match = Expr.match[ type ].exec( expr )) != null ) { |
1907 | values = [], |
- | |
1908 | options = elem.options, |
1927 | var filter = Expr.filter[ type ], found, item; |
1909 | one = elem.type == "select-one"; |
1928 | anyFound = false; |
1910 | 1929 | ||
1911 | // Nothing was selected
|
1930 | if ( curLoop == result ) { |
1912 | if ( index < 0 ) |
1931 | result = []; |
1913 | return null; |
1932 | }
|
1914 | 1933 | ||
1915 | // Loop through all the selected options
|
1934 | if ( Expr.preFilter[ type ] ) { |
1916 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
1935 | match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
1917 | var option = options[ i ]; |
- | |
1918 | 1936 | ||
1919 | if ( option.selected ) { |
1937 | if ( !match ) { |
- | 1938 | anyFound = found = true; |
|
1920 | // Get the specifc value for the option
|
1939 | } else if ( match === true ) { |
1921 | value = jQuery(option).val(); |
1940 | continue; |
- | 1941 | }
|
|
- | 1942 | }
|
|
1922 | 1943 | ||
- | 1944 | if ( match ) { |
|
1923 | // We don't need an array for one selects
|
1945 | for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
1924 | if ( one ) |
1946 | if ( item ) { |
- | 1947 | found = filter( item, match, i, curLoop ); |
|
1925 | return value; |
1948 | var pass = not ^ !!found; |
1926 | 1949 | ||
1927 | // Multi-Selects return an array
|
1950 | if ( inplace && found != null ) { |
- | 1951 | if ( pass ) { |
|
- | 1952 | anyFound = true; |
|
- | 1953 | } else { |
|
- | 1954 | curLoop[i] = false; |
|
- | 1955 | }
|
|
- | 1956 | } else if ( pass ) { |
|
1928 | values.push( value ); |
1957 | result.push( item ); |
- | 1958 | anyFound = true; |
|
- | 1959 | }
|
|
1929 | }
|
1960 | }
|
1930 | }
|
1961 | }
|
1931 | - | ||
1932 | return values; |
- | |
1933 | }
|
1962 | }
|
1934 | 1963 | ||
1935 | // Everything else, we just grab the value
|
1964 | if ( found !== undefined ) { |
1936 | return (elem.value || "").replace(/\r/g, ""); |
1965 | if ( !inplace ) { |
- | 1966 | curLoop = result; |
|
- | 1967 | }
|
|
1937 | 1968 | ||
1938 | }
|
- | |
- | 1969 | expr = expr.replace( Expr.match[ type ], "" ); |
|
1939 | 1970 | ||
- | 1971 | if ( !anyFound ) { |
|
1940 | return undefined; |
1972 | return []; |
1941 | }
|
1973 | }
|
1942 | 1974 | ||
1943 | // Typecast once if the value is a number
|
- | |
1944 | if ( typeof value === "number" ) |
1975 | break; |
1945 | value += ''; |
1976 | }
|
1946 | 1977 | }
|
|
1947 | var val = value; |
1978 | }
|
1948 | 1979 | ||
1949 | return this.each(function(){ |
1980 | // Improper expression
|
1950 | if(jQuery.isFunction(value)) { |
1981 | if ( expr == old ) { |
1951 | val = value.call(this); |
1982 | if ( anyFound == null ) { |
1952 | // Typecast each time if the value is a Function and the appended
|
1983 | throw "Syntax error, unrecognized expression: " + expr; |
1953 | // value is therefore different each time.
|
1984 | } else { |
1954 | if( typeof val === "number" ) val += ''; |
1985 | break; |
1955 | }
|
1986 | }
|
1956 | 1987 | }
|
|
1957 | if ( this.nodeType != 1 ) |
- | |
1958 | return; |
- | |
1959 | 1988 | ||
1960 | if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) |
- | |
1961 | this.checked = jQuery.inArray(this.value || this.name, val) >= 0; |
1989 | old = expr; |
- | 1990 | }
|
|
1962 | 1991 | ||
1963 | else if ( jQuery.nodeName( this, "select" ) ) { |
- | |
1964 | var values = jQuery.makeArray(val); |
1992 | return curLoop; |
- | 1993 | }; |
|
1965 | 1994 | ||
- | 1995 | var Expr = Sizzle.selectors = { |
|
- | 1996 | order: [ "ID", "NAME", "TAG" ], |
|
- | 1997 | match: { |
|
- | 1998 | ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
|
- | 1999 | CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
|
- | 2000 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, |
|
- | 2001 | ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
|
1966 | jQuery( "option", this ).each(function(){ |
2002 | TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, |
1967 | this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; |
2003 | CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
- | 2004 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
|
- | 2005 | PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ |
|
- | 2006 | }, |
|
- | 2007 | attrMap: { |
|
- | 2008 | "class": "className", |
|
- | 2009 | "for": "htmlFor" |
|
- | 2010 | }, |
|
- | 2011 | attrHandle: { |
|
- | 2012 | href: function(elem){ |
|
- | 2013 | return elem.getAttribute("href"); |
|
1968 | }); |
2014 | }
|
- | 2015 | }, |
|
- | 2016 | relative: { |
|
- | 2017 | "+": function(checkSet, part, isXML){ |
|
- | 2018 | var isPartStr = typeof part === "string", |
|
- | 2019 | isTag = isPartStr && !/\W/.test(part), |
|
- | 2020 | isPartStrNotTag = isPartStr && !isTag; |
|
1969 | 2021 | ||
1970 | if ( !values.length ) |
2022 | if ( isTag && !isXML ) { |
1971 | this.selectedIndex = -1; |
2023 | part = part.toUpperCase(); |
- | 2024 | }
|
|
1972 | 2025 | ||
1973 | } else |
2026 | for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
1974 | this.value = val; |
2027 | if ( (elem = checkSet[i]) ) { |
1975 | }); |
- | |
1976 | }
|
- | |
1977 | }); |
- | |
- | 2028 | while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
|
1978 | 2029 | ||
1979 | jQuery.each({ |
- | |
1980 | removeAttr: function( name ) { |
2030 | checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? |
1981 | jQuery.attr( this, name, "" ); |
2031 | elem || false : |
1982 | if (this.nodeType == 1) |
2032 | elem === part; |
1983 | this.removeAttribute( name ); |
2033 | }
|
1984 | }, |
2034 | }
|
1985 | 2035 | ||
1986 | addClass: function( classNames ) { |
2036 | if ( isPartStrNotTag ) { |
1987 | jQuery.className.add( this, classNames ); |
2037 | Sizzle.filter( part, checkSet, true ); |
- | 2038 | }
|
|
1988 | }, |
2039 | }, |
- | 2040 | ">": function(checkSet, part, isXML){ |
|
- | 2041 | var isPartStr = typeof part === "string"; |
|
- | 2042 | ||
- | 2043 | if ( isPartStr && !/\W/.test(part) ) { |
|
- | 2044 | part = isXML ? part : part.toUpperCase(); |
|
1989 | 2045 | ||
- | 2046 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
|
- | 2047 | var elem = checkSet[i]; |
|
- | 2048 | if ( elem ) { |
|
1990 | removeClass: function( classNames ) { |
2049 | var parent = elem.parentNode; |
- | 2050 | checkSet[i] = parent.nodeName === part ? parent : false; |
|
- | 2051 | }
|
|
- | 2052 | }
|
|
- | 2053 | } else { |
|
- | 2054 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
|
- | 2055 | var elem = checkSet[i]; |
|
- | 2056 | if ( elem ) { |
|
- | 2057 | checkSet[i] = isPartStr ? |
|
- | 2058 | elem.parentNode : |
|
1991 | jQuery.className.remove( this, classNames ); |
2059 | elem.parentNode === part; |
- | 2060 | }
|
|
1992 | }, |
2061 | }
|
1993 | 2062 | ||
1994 | toggleClass: function( classNames, state ) { |
- | |
1995 | var type = typeof classNames; |
- | |
1996 | if ( type === "string" ) { |
2063 | if ( isPartStr ) { |
1997 | // toggle individual class names
|
2064 | Sizzle.filter( part, checkSet, true ); |
1998 | var isBool = typeof state === "boolean", className, i = 0, |
- | |
1999 | classNames = classNames.split( /\s+/ ); |
2065 | }
|
2000 | while ( (className = classNames[ i++ ]) ) { |
- | |
2001 | // check each className given, space seperated list
|
- | |
2002 | state = isBool ? state : !jQuery.className.has( this, className ); |
- | |
2003 | jQuery.className[ state ? "add" : "remove" ]( this, className ); |
- | |
2004 | }
|
2066 | }
|
- | 2067 | }, |
|
- | 2068 | "": function(checkSet, part, isXML){ |
|
2005 | } else if ( type === "undefined" || type === "boolean" ) { |
2069 | var doneName = done++, checkFn = dirCheck; |
- | 2070 | ||
2006 | if ( this.className ) { |
2071 | if ( !/\W/.test(part) ) { |
2007 | // store className if set
|
2072 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
2008 | jQuery.data( this, "__className__", this.className ); |
2073 | checkFn = dirNodeCheck; |
2009 | }
|
2074 | }
|
2010 | // toggle whole className
|
- | |
2011 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
- | |
2012 | }
|
- | |
2013 | }
|
- | |
2014 | }, function(name, fn){ |
- | |
2015 | jQuery.fn[ name ] = function(){ |
- | |
2016 | return this.each( fn, arguments ); |
- | |
2017 | }; |
- | |
2018 | }); |
- | |
2019 | 2075 | ||
2020 | jQuery.extend({ |
- | |
2021 | className: { |
- | |
2022 | // internal only, use addClass("class")
|
- | |
2023 | add: function( elem, classNames ) { |
- | |
2024 | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
- | |
2025 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
- | |
2026 | elem.className += (elem.className ? " " : "") + className; |
2076 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
2027 | }); |
- | |
2028 | }, |
2077 | }, |
- | 2078 | "~": function(checkSet, part, isXML){ |
|
- | 2079 | var doneName = done++, checkFn = dirCheck; |
|
2029 | 2080 | ||
2030 | // internal only, use removeClass("class")
|
- | |
2031 | remove: function( elem, classNames ) { |
- | |
2032 | if (elem.nodeType == 1) |
- | |
2033 | elem.className = classNames !== undefined ? |
2081 | if ( typeof part === "string" && !/\W/.test(part) ) { |
2034 | jQuery.grep(elem.className.split(/\s+/), function(className){ |
- | |
2035 | return !jQuery.className.has( classNames, className ); |
2082 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
2036 | }).join(" ") : |
2083 | checkFn = dirNodeCheck; |
2037 | ""; |
- | |
2038 | }, |
2084 | }
|
2039 | 2085 | ||
2040 | // internal only, use hasClass("class")
|
- | |
2041 | has: function( elem, className ) { |
- | |
2042 | return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
2086 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
2043 | }
|
2087 | }
|
2044 | }, |
2088 | }, |
- | 2089 | find: { |
|
- | 2090 | ID: function(match, context, isXML){ |
|
- | 2091 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
|
- | 2092 | var m = context.getElementById(match[1]); |
|
- | 2093 | return m ? [m] : []; |
|
- | 2094 | }
|
|
- | 2095 | }, |
|
- | 2096 | NAME: function(match, context, isXML){ |
|
- | 2097 | if ( typeof context.getElementsByName !== "undefined" ) { |
|
- | 2098 | var ret = [], results = context.getElementsByName(match[1]); |
|
2045 | 2099 | ||
2046 | attr: function( elem, name, value ) { |
2100 | for ( var i = 0, l = results.length; i < l; i++ ) { |
2047 | // don't set attributes on text and comment nodes
|
2101 | if ( results[i].getAttribute("name") === match[1] ) { |
2048 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
- | |
2049 | return undefined; |
2102 | ret.push( results[i] ); |
2050 | 2103 | }
|
|
2051 | var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
- | |
2052 | // Whether we are setting (or getting)
|
- | |
2053 | set = value !== undefined; |
- | |
2054 | - | ||
2055 | // Try to normalize/fix the name
|
- | |
2056 | name = notxml && jQuery.props[ name ] || name; |
- | |
2057 | - | ||
2058 | // Only do all the following if this is a node (faster for style)
|
- | |
2059 | if ( elem.nodeType === 1 ) { |
- | |
2060 | 2104 | }
|
|
2061 | // These attributes require special treatment
|
- | |
2062 | var special = /href|src|style/.test( name ); |
- | |
2063 | 2105 | ||
2064 | // Safari mis-reports the default selected property of a hidden option
|
2106 | return ret.length === 0 ? null : ret; |
- | 2107 | }
|
|
- | 2108 | }, |
|
- | 2109 | TAG: function(match, context){ |
|
2065 | // Accessing the parent's selectedIndex property fixes it
|
2110 | return context.getElementsByTagName(match[1]); |
- | 2111 | }
|
|
- | 2112 | }, |
|
- | 2113 | preFilter: { |
|
2066 | if ( name == "selected" && elem.parentNode ) |
2114 | CLASS: function(match, curLoop, inplace, result, not, isXML){ |
2067 | elem.parentNode.selectedIndex; |
2115 | match = " " + match[1].replace(/\\/g, "") + " "; |
2068 | 2116 | ||
2069 | // If applicable, access the attribute via the DOM 0 way
|
- | |
2070 | if ( name in elem && notxml && !special ) { |
- | |
2071 | if ( set ){ |
2117 | if ( isXML ) { |
2072 | // We can't allow the type property to be changed (since it causes problems in IE)
|
- | |
2073 | if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) |
- | |
2074 | throw "type property can't be changed"; |
2118 | return match; |
- | 2119 | }
|
|
2075 | 2120 | ||
- | 2121 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
|
- | 2122 | if ( elem ) { |
|
- | 2123 | if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { |
|
- | 2124 | if ( !inplace ) |
|
- | 2125 | result.push( elem ); |
|
- | 2126 | } else if ( inplace ) { |
|
2076 | elem[ name ] = value; |
2127 | curLoop[i] = false; |
- | 2128 | }
|
|
2077 | }
|
2129 | }
|
- | 2130 | }
|
|
2078 | 2131 | ||
2079 | // browsers index elements by id/name on forms, give priority to attributes.
|
2132 | return false; |
- | 2133 | }, |
|
2080 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
2134 | ID: function(match){ |
2081 | return elem.getAttributeNode( name ).nodeValue; |
2135 | return match[1].replace(/\\/g, ""); |
2082 | 2136 | }, |
|
- | 2137 | TAG: function(match, curLoop){ |
|
2083 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
2138 | for ( var i = 0; curLoop[i] === false; i++ ){} |
2084 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
2139 | return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); |
- | 2140 | }, |
|
- | 2141 | CHILD: function(match){ |
|
2085 | if ( name == "tabIndex" ) { |
2142 | if ( match[1] == "nth" ) { |
2086 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
2143 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
2087 | return attributeNode && attributeNode.specified |
2144 | var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
2088 | ? attributeNode.value |
- | |
2089 | : /(button|input|object|select|textarea)/i.test(elem.nodeName) |
2145 | match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || |
2090 | ? 0 |
- | |
2091 | : /^(a|area)$/i.test(elem.nodeName) && elem.href |
2146 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
2092 | ? 0 |
- | |
2093 | : undefined; |
- | |
2094 | }
|
- | |
2095 | 2147 | ||
- | 2148 | // calculate the numbers (first)n+(last) including if they are negative
|
|
- | 2149 | match[2] = (test[1] + (test[2] || 1)) - 0; |
|
2096 | return elem[ name ]; |
2150 | match[3] = test[3] - 0; |
2097 | }
|
2151 | }
|
2098 | 2152 | ||
2099 | if ( !jQuery.support.style && notxml && name == "style" ) { |
2153 | // TODO: Move to normal caching system
|
2100 | if ( set ) |
2154 | match[0] = done++; |
2101 | elem.style.cssText = "" + value; |
- | |
2102 | 2155 | ||
2103 | return elem.style.cssText; |
2156 | return match; |
- | 2157 | }, |
|
- | 2158 | ATTR: function(match, curLoop, inplace, result, not, isXML){ |
|
- | 2159 | var name = match[1].replace(/\\/g, ""); |
|
- | 2160 | ||
- | 2161 | if ( !isXML && Expr.attrMap[name] ) { |
|
- | 2162 | match[1] = Expr.attrMap[name]; |
|
2104 | }
|
2163 | }
|
2105 | 2164 | ||
2106 | if ( set ) |
2165 | if ( match[2] === "~=" ) { |
2107 | // convert the value to a string (all browsers do this but IE) see #1070
|
- | |
2108 | elem.setAttribute( name, "" + value ); |
2166 | match[4] = " " + match[4] + " "; |
2109 | 2167 | }
|
|
2110 | var attr = !jQuery.support.hrefNormalized && notxml && special |
- | |
2111 | // Some attributes require a special call on IE
|
- | |
2112 | ? elem.getAttribute( name, 2 ) |
- | |
2113 | : elem.getAttribute( name ); |
- | |
2114 | 2168 | ||
- | 2169 | return match; |
|
- | 2170 | }, |
|
- | 2171 | PSEUDO: function(match, curLoop, inplace, result, not){ |
|
- | 2172 | if ( match[1] === "not" ) { |
|
- | 2173 | // If we're dealing with a complex expression, or a simple one
|
|
- | 2174 | if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) { |
|
- | 2175 | match[3] = Sizzle(match[3], null, null, curLoop); |
|
- | 2176 | } else { |
|
- | 2177 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
|
- | 2178 | if ( !inplace ) { |
|
- | 2179 | result.push.apply( result, ret ); |
|
- | 2180 | }
|
|
- | 2181 | return false; |
|
- | 2182 | }
|
|
- | 2183 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
|
- | 2184 | return true; |
|
- | 2185 | }
|
|
- | 2186 | ||
- | 2187 | return match; |
|
- | 2188 | }, |
|
- | 2189 | POS: function(match){ |
|
- | 2190 | match.unshift( true ); |
|
- | 2191 | return match; |
|
- | 2192 | }
|
|
- | 2193 | }, |
|
- | 2194 | filters: { |
|
- | 2195 | enabled: function(elem){ |
|
- | 2196 | return elem.disabled === false && elem.type !== "hidden"; |
|
- | 2197 | }, |
|
- | 2198 | disabled: function(elem){ |
|
- | 2199 | return elem.disabled === true; |
|
- | 2200 | }, |
|
- | 2201 | checked: function(elem){ |
|
- | 2202 | return elem.checked === true; |
|
- | 2203 | }, |
|
- | 2204 | selected: function(elem){ |
|
2115 | // Non-existent attributes return null, we normalize to undefined
|
2205 | // Accessing this property makes selected-by-default
|
- | 2206 | // options in Safari work properly
|
|
- | 2207 | elem.parentNode.selectedIndex; |
|
- | 2208 | return elem.selected === true; |
|
- | 2209 | }, |
|
- | 2210 | parent: function(elem){ |
|
- | 2211 | return !!elem.firstChild; |
|
- | 2212 | }, |
|
- | 2213 | empty: function(elem){ |
|
- | 2214 | return !elem.firstChild; |
|
- | 2215 | }, |
|
- | 2216 | has: function(elem, i, match){ |
|
- | 2217 | return !!Sizzle( match[3], elem ).length; |
|
- | 2218 | }, |
|
- | 2219 | header: function(elem){ |
|
- | 2220 | return /h\d/i.test( elem.nodeName ); |
|
- | 2221 | }, |
|
- | 2222 | text: function(elem){ |
|
2116 | return attr === null ? undefined : attr; |
2223 | return "text" === elem.type; |
- | 2224 | }, |
|
- | 2225 | radio: function(elem){ |
|
- | 2226 | return "radio" === elem.type; |
|
- | 2227 | }, |
|
- | 2228 | checkbox: function(elem){ |
|
- | 2229 | return "checkbox" === elem.type; |
|
- | 2230 | }, |
|
- | 2231 | file: function(elem){ |
|
- | 2232 | return "file" === elem.type; |
|
- | 2233 | }, |
|
- | 2234 | password: function(elem){ |
|
- | 2235 | return "password" === elem.type; |
|
- | 2236 | }, |
|
- | 2237 | submit: function(elem){ |
|
- | 2238 | return "submit" === elem.type; |
|
- | 2239 | }, |
|
- | 2240 | image: function(elem){ |
|
- | 2241 | return "image" === elem.type; |
|
- | 2242 | }, |
|
- | 2243 | reset: function(elem){ |
|
- | 2244 | return "reset" === elem.type; |
|
- | 2245 | }, |
|
- | 2246 | button: function(elem){ |
|
- | 2247 | return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; |
|
- | 2248 | }, |
|
- | 2249 | input: function(elem){ |
|
- | 2250 | return /input|select|textarea|button/i.test(elem.nodeName); |
|
2117 | }
|
2251 | }
|
2118 | - | ||
2119 | // elem is actually elem.style ... set the style
|
- | |
2120 | // Using attr for specific style information is now deprecated. Use style insead.
|
- | |
2121 | return jQuery.style(elem, name, value); |
- | |
2122 | }
|
- | |
2123 | }); |
- | |
2124 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
- | |
2125 | rleadingWhitespace = /^\s+/, |
- | |
2126 | rsingleTag = /^<(\w+)\s*\/?>$/, |
- | |
2127 | rxhtmlTag = /(<(\w+)[^>]*?)\/>/g, |
- | |
2128 | rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
- | |
2129 | rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, |
- | |
2130 | rtbody = /<tbody/i, |
- | |
2131 | fcloseTag = function(all, front, tag){ |
- | |
2132 | return rselfClosing.test(tag) ? |
- | |
2133 | all :
|
- | |
2134 | front + "></" + tag + ">"; |
- | |
2135 | }; |
- | |
2136 | - | ||
2137 | jQuery.fn.extend({ |
- | |
2138 | text: function( text ) { |
- | |
2139 | if ( typeof text !== "object" && text !== undefined ) |
- | |
2140 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
- | |
2141 | - | ||
2142 | var ret = ""; |
- | |
2143 | - | ||
2144 | jQuery.each( text || this, function(){ |
- | |
2145 | jQuery.each( this.childNodes, function(){ |
- | |
2146 | if ( this.nodeType !== 8 ) { |
- | |
2147 | ret += this.nodeType !== 1 ? |
- | |
2148 | this.nodeValue : |
- | |
2149 | jQuery.fn.text( [ this ] ); |
- | |
2150 | }
|
- | |
2151 | }); |
- | |
2152 | }); |
- | |
2153 | - | ||
2154 | return ret; |
- | |
2155 | }, |
2252 | }, |
- | 2253 | setFilters: { |
|
- | 2254 | first: function(elem, i){ |
|
- | 2255 | return i === 0; |
|
- | 2256 | }, |
|
- | 2257 | last: function(elem, i, match, array){ |
|
- | 2258 | return i === array.length - 1; |
|
2156 | 2259 | }, |
|
2157 | wrapAll: function( html ) { |
2260 | even: function(elem, i){ |
- | 2261 | return i % 2 === 0; |
|
- | 2262 | }, |
|
2158 | if ( jQuery.isFunction( html ) ) { |
2263 | odd: function(elem, i){ |
- | 2264 | return i % 2 === 1; |
|
- | 2265 | }, |
|
- | 2266 | lt: function(elem, i, match){ |
|
- | 2267 | return i < match[3] - 0; |
|
- | 2268 | }, |
|
- | 2269 | gt: function(elem, i, match){ |
|
2159 | return this.each(function() { |
2270 | return i > match[3] - 0; |
- | 2271 | }, |
|
2160 | jQuery(this).wrapAll( html.apply(this, arguments) ); |
2272 | nth: function(elem, i, match){ |
- | 2273 | return match[3] - 0 == i; |
|
2161 | }); |
2274 | }, |
- | 2275 | eq: function(elem, i, match){ |
|
- | 2276 | return match[3] - 0 == i; |
|
2162 | }
|
2277 | }
|
- | 2278 | }, |
|
- | 2279 | filter: { |
|
- | 2280 | PSEUDO: function(elem, match, i, array){ |
|
- | 2281 | var name = match[1], filter = Expr.filters[ name ]; |
|
2163 | 2282 | ||
2164 | if ( this[0] ) { |
2283 | if ( filter ) { |
2165 | // The elements to wrap the target around
|
2284 | return filter( elem, i, match, array ); |
2166 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); |
- | |
2167 | - | ||
2168 | if ( this[0].parentNode ) { |
2285 | } else if ( name === "contains" ) { |
2169 | wrap.insertBefore( this[0] ); |
2286 | return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; |
2170 | }
|
- | |
2171 | - | ||
2172 | wrap.map(function(){ |
2287 | } else if ( name === "not" ) { |
2173 | var elem = this; |
2288 | var not = match[3]; |
2174 | 2289 | ||
2175 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
2290 | for ( var i = 0, l = not.length; i < l; i++ ) { |
- | 2291 | if ( not[i] === elem ) { |
|
2176 | elem = elem.firstChild; |
2292 | return false; |
- | 2293 | }
|
|
2177 | }
|
2294 | }
|
2178 | 2295 | ||
2179 | return elem; |
2296 | return true; |
- | 2297 | }
|
|
- | 2298 | }, |
|
- | 2299 | CHILD: function(elem, match){ |
|
- | 2300 | var type = match[1], node = elem; |
|
2180 | }).append(this); |
2301 | switch (type) { |
- | 2302 | case 'only': |
|
- | 2303 | case 'first': |
|
- | 2304 | while ( (node = node.previousSibling) ) { |
|
- | 2305 | if ( node.nodeType === 1 ) return false; |
|
2181 | }
|
2306 | }
|
- | 2307 | if ( type == 'first') return true; |
|
- | 2308 | node = elem; |
|
- | 2309 | case 'last': |
|
- | 2310 | while ( (node = node.nextSibling) ) { |
|
- | 2311 | if ( node.nodeType === 1 ) return false; |
|
2182 | 2312 | }
|
|
2183 | return this; |
2313 | return true; |
2184 | }, |
2314 | case 'nth': |
- | 2315 | var first = match[2], last = match[3]; |
|
2185 | 2316 | ||
- | 2317 | if ( first == 1 && last == 0 ) { |
|
- | 2318 | return true; |
|
- | 2319 | }
|
|
- | 2320 | ||
- | 2321 | var doneName = match[0], |
|
- | 2322 | parent = elem.parentNode; |
|
- | 2323 | ||
- | 2324 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
|
- | 2325 | var count = 0; |
|
- | 2326 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
|
- | 2327 | if ( node.nodeType === 1 ) { |
|
- | 2328 | node.nodeIndex = ++count; |
|
- | 2329 | }
|
|
- | 2330 | }
|
|
- | 2331 | parent.sizcache = doneName; |
|
- | 2332 | }
|
|
- | 2333 | ||
- | 2334 | var diff = elem.nodeIndex - last; |
|
- | 2335 | if ( first == 0 ) { |
|
- | 2336 | return diff == 0; |
|
- | 2337 | } else { |
|
- | 2338 | return ( diff % first == 0 && diff / first >= 0 ); |
|
- | 2339 | }
|
|
- | 2340 | }
|
|
- | 2341 | }, |
|
2186 | wrapInner: function( html ) { |
2342 | ID: function(elem, match){ |
- | 2343 | return elem.nodeType === 1 && elem.getAttribute("id") === match; |
|
- | 2344 | }, |
|
2187 | return this.each(function(){ |
2345 | TAG: function(elem, match){ |
2188 | jQuery( this ).contents().wrapAll( html ); |
2346 | return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; |
2189 | }); |
2347 | }, |
- | 2348 | CLASS: function(elem, match){ |
|
- | 2349 | return (" " + (elem.className || elem.getAttribute("class")) + " ") |
|
- | 2350 | .indexOf( match ) > -1; |
|
2190 | }, |
2351 | }, |
- | 2352 | ATTR: function(elem, match){ |
|
- | 2353 | var name = match[1], |
|
- | 2354 | result = Expr.attrHandle[ name ] ? |
|
- | 2355 | Expr.attrHandle[ name ]( elem ) : |
|
- | 2356 | elem[ name ] != null ? |
|
- | 2357 | elem[ name ] : |
|
- | 2358 | elem.getAttribute( name ), |
|
- | 2359 | value = result + "", |
|
- | 2360 | type = match[2], |
|
- | 2361 | check = match[4]; |
|
2191 | 2362 | ||
2192 | wrap: function( html ) { |
2363 | return result == null ? |
- | 2364 | type === "!=" : |
|
- | 2365 | type === "=" ? |
|
- | 2366 | value === check : |
|
- | 2367 | type === "*=" ? |
|
2193 | return this.each(function(){ |
2368 | value.indexOf(check) >= 0 : |
- | 2369 | type === "~=" ? |
|
- | 2370 | (" " + value + " ").indexOf(check) >= 0 : |
|
- | 2371 | !check ? |
|
2194 | jQuery( this ).wrapAll( html ); |
2372 | value && result !== false : |
- | 2373 | type === "!=" ? |
|
- | 2374 | value != check : |
|
- | 2375 | type === "^=" ? |
|
- | 2376 | value.indexOf(check) === 0 : |
|
- | 2377 | type === "$=" ? |
|
- | 2378 | value.substr(value.length - check.length) === check : |
|
- | 2379 | type === "|=" ? |
|
- | 2380 | value === check || value.substr(0, check.length + 1) === check + "-" : |
|
2195 | }); |
2381 | false; |
2196 | }, |
2382 | }, |
- | 2383 | POS: function(elem, match, i, array){ |
|
- | 2384 | var name = match[2], filter = Expr.setFilters[ name ]; |
|
2197 | 2385 | ||
2198 | append: function() { |
2386 | if ( filter ) { |
2199 | return this.domManip(arguments, true, function(elem){ |
2387 | return filter( elem, i, match, array ); |
2200 | if ( this.nodeType === 1 ) { |
- | |
2201 | this.appendChild( elem ); |
- | |
2202 | }
|
2388 | }
|
2203 | }); |
2389 | }
|
2204 | }, |
2390 | }
|
- | 2391 | }; |
|
2205 | 2392 | ||
2206 | prepend: function() { |
- | |
2207 | return this.domManip(arguments, true, function(elem){ |
- | |
2208 | if ( this.nodeType === 1 ) { |
2393 | var origPOS = Expr.match.POS; |
2209 | this.insertBefore( elem, this.firstChild ); |
- | |
2210 | }
|
- | |
2211 | }); |
- | |
2212 | }, |
- | |
2213 | 2394 | ||
2214 | before: function() { |
2395 | for ( var type in Expr.match ) { |
2215 | return this.domManip(arguments, false, function(elem){ |
2396 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
2216 | this.parentNode.insertBefore( elem, this ); |
- | |
2217 | }); |
- | |
2218 | }, |
2397 | }
|
2219 | 2398 | ||
2220 | after: function() { |
2399 | var makeArray = function(array, results) { |
2221 | return this.domManip(arguments, false, function(elem){ |
2400 | array = Array.prototype.slice.call( array, 0 ); |
2222 | this.parentNode.insertBefore( elem, this.nextSibling ); |
- | |
2223 | }); |
- | |
2224 | }, |
- | |
2225 | 2401 | ||
2226 | clone: function( events ) { |
2402 | if ( results ) { |
2227 | // Do the clone
|
- | |
2228 | var ret = this.map(function(){ |
- | |
2229 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
- | |
2230 | // IE copies events bound via attachEvent when
|
- | |
2231 | // using cloneNode. Calling detachEvent on the
|
- | |
2232 | // clone will also remove the events from the orignal
|
- | |
2233 | // In order to get around this, we use innerHTML.
|
- | |
2234 | // Unfortunately, this means some modifications to
|
- | |
2235 | // attributes in IE that are actually only stored
|
- | |
2236 | // as properties will not be copied (such as the
|
- | |
2237 | // the name attribute on an input).
|
2403 | results.push.apply( results, array ); |
2238 | var html = this.outerHTML, ownerDocument = this.ownerDocument; |
- | |
2239 | if ( !html ) { |
2404 | return results; |
2240 | var div = ownerDocument.createElement("div"); |
- | |
2241 | div.appendChild( this.cloneNode(true) ); |
- | |
- | 2405 | }
|
|
- | 2406 | ||
2242 | html = div.innerHTML; |
2407 | return array; |
2243 | }
|
2408 | }; |
2244 | 2409 | ||
- | 2410 | // Perform a simple check to determine if the browser is capable of
|
|
- | 2411 | // converting a NodeList to an array using builtin methods.
|
|
- | 2412 | try { |
|
- | 2413 | Array.prototype.slice.call( document.documentElement.childNodes, 0 ); |
|
- | 2414 | ||
- | 2415 | // Provide a fallback method if it does not work
|
|
- | 2416 | } catch(e){ |
|
- | 2417 | makeArray = function(array, results) { |
|
- | 2418 | var ret = results || []; |
|
- | 2419 | ||
- | 2420 | if ( toString.call(array) === "[object Array]" ) { |
|
2245 | return jQuery.clean([html.replace(rinlinejQuery, "") |
2421 | Array.prototype.push.apply( ret, array ); |
- | 2422 | } else { |
|
- | 2423 | if ( typeof array.length === "number" ) { |
|
2246 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
2424 | for ( var i = 0, l = array.length; i < l; i++ ) { |
- | 2425 | ret.push( array[i] ); |
|
- | 2426 | }
|
|
2247 | } else { |
2427 | } else { |
- | 2428 | for ( var i = 0; array[i]; i++ ) { |
|
2248 | return this.cloneNode(true); |
2429 | ret.push( array[i] ); |
- | 2430 | }
|
|
2249 | }
|
2431 | }
|
2250 | }); |
2432 | }
|
2251 | 2433 | ||
2252 | // Copy the events from the original to the clone
|
- | |
2253 | if ( events === true ) { |
2434 | return ret; |
2254 | var orig = this.find("*").andSelf(), i = 0; |
- | |
- | 2435 | }; |
|
- | 2436 | }
|
|
2255 | 2437 | ||
2256 | ret.find("*").andSelf().each(function(){ |
- | |
2257 | if ( this.nodeName !== orig[i].nodeName ) { return; } |
2438 | var sortOrder; |
2258 | 2439 | ||
2259 | var events = jQuery.data( orig[i], "events" ); |
2440 | if ( document.documentElement.compareDocumentPosition ) { |
- | 2441 | sortOrder = function( a, b ) { |
|
- | 2442 | if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
|
- | 2443 | if ( a == b ) { |
|
- | 2444 | hasDuplicate = true; |
|
- | 2445 | }
|
|
- | 2446 | return 0; |
|
- | 2447 | }
|
|
2260 | 2448 | ||
- | 2449 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
|
2261 | for ( var type in events ) { |
2450 | if ( ret === 0 ) { |
- | 2451 | hasDuplicate = true; |
|
- | 2452 | }
|
|
- | 2453 | return ret; |
|
- | 2454 | }; |
|
2262 | for ( var handler in events[ type ] ) { |
2455 | } else if ( "sourceIndex" in document.documentElement ) { |
- | 2456 | sortOrder = function( a, b ) { |
|
2263 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
2457 | if ( !a.sourceIndex || !b.sourceIndex ) { |
- | 2458 | if ( a == b ) { |
|
- | 2459 | hasDuplicate = true; |
|
2264 | }
|
2460 | }
|
- | 2461 | return 0; |
|
2265 | }
|
2462 | }
|
2266 | 2463 | ||
- | 2464 | var ret = a.sourceIndex - b.sourceIndex; |
|
- | 2465 | if ( ret === 0 ) { |
|
- | 2466 | hasDuplicate = true; |
|
- | 2467 | }
|
|
- | 2468 | return ret; |
|
2267 | i++;
|
2469 | }; |
- | 2470 | } else if ( document.createRange ) { |
|
- | 2471 | sortOrder = function( a, b ) { |
|
- | 2472 | if ( !a.ownerDocument || !b.ownerDocument ) { |
|
- | 2473 | if ( a == b ) { |
|
- | 2474 | hasDuplicate = true; |
|
2268 | }); |
2475 | }
|
- | 2476 | return 0; |
|
2269 | }
|
2477 | }
|
2270 | 2478 | ||
- | 2479 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
|
- | 2480 | aRange.selectNode(a); |
|
- | 2481 | aRange.collapse(true); |
|
2271 | // Return the cloned set
|
2482 | bRange.selectNode(b); |
- | 2483 | bRange.collapse(true); |
|
- | 2484 | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
|
- | 2485 | if ( ret === 0 ) { |
|
- | 2486 | hasDuplicate = true; |
|
- | 2487 | }
|
|
2272 | return ret; |
2488 | return ret; |
2273 | }, |
2489 | }; |
- | 2490 | }
|
|
2274 | 2491 | ||
2275 | html: function( value ) { |
2492 | // Check to see if the browser returns elements by name when
|
2276 | return value === undefined ? |
2493 | // querying by getElementById (and provide a workaround)
|
2277 | (this[0] ? |
2494 | (function(){ |
- | 2495 | // We're going to inject a fake input element with a specified name
|
|
2278 | this[0].innerHTML.replace(rinlinejQuery, "") : |
2496 | var form = document.createElement("div"), |
2279 | null) : |
2497 | id = "script" + (new Date).getTime(); |
2280 | this.empty().append( value ); |
2498 | form.innerHTML = "<a name='" + id + "'/>"; |
2281 | }, |
- | |
2282 | 2499 | ||
- | 2500 | // Inject it into the root element, check its status, and remove it quickly
|
|
2283 | replaceWith: function( value ) { |
2501 | var root = document.documentElement; |
2284 | return this.after( value ).remove(); |
2502 | root.insertBefore( form, root.firstChild ); |
2285 | }, |
- | |
2286 | 2503 | ||
- | 2504 | // The workaround has to do additional checks after a getElementById
|
|
- | 2505 | // Which slows things down for other browsers (hence the branching)
|
|
- | 2506 | if ( !!document.getElementById( id ) ) { |
|
2287 | detach: function( selector ) { |
2507 | Expr.find.ID = function(match, context, isXML){ |
- | 2508 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
|
2288 | return this.remove( selector, true ); |
2509 | var m = context.getElementById(match[1]); |
- | 2510 | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
|
- | 2511 | }
|
|
2289 | }, |
2512 | }; |
2290 | 2513 | ||
2291 | domManip: function( args, table, callback ) { |
2514 | Expr.filter.ID = function(elem, match){ |
- | 2515 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
|
2292 | var fragment, scripts, cacheable, cached, cacheresults, first, |
2516 | return elem.nodeType === 1 && node && node.nodeValue === match; |
2293 | value = args[0]; |
2517 | }; |
- | 2518 | }
|
|
2294 | 2519 | ||
2295 | if ( jQuery.isFunction(value) ) { |
- | |
2296 | return this.each(function() { |
- | |
2297 | args[0] = value.call(this); |
2520 | root.removeChild( form ); |
2298 | return jQuery(this).domManip( args, table, callback ); |
2521 | root = form = null; // release memory in IE |
2299 | }); |
2522 | })(); |
2300 | }
|
- | |
2301 | 2523 | ||
2302 | if ( this[0] ) { |
2524 | (function(){ |
2303 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
- | |
2304 | cacheable = true; |
- | |
2305 | cacheresults = jQuery.fragments[ args[0] ]; |
2525 | // Check to see if the browser returns only elements
|
2306 | if ( cacheresults ) { |
- | |
2307 | if ( cacheresults !== 1 ) { |
- | |
2308 | fragment = cacheresults; |
2526 | // when doing getElementsByTagName("*")
|
2309 | }
|
- | |
2310 | cached = true; |
- | |
2311 | }
|
- | |
2312 | }
|
- | |
2313 | 2527 | ||
2314 | if ( !fragment ) { |
2528 | // Create a fake element
|
2315 | fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(); |
2529 | var div = document.createElement("div"); |
2316 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ); |
2530 | div.appendChild( document.createComment("") ); |
2317 | }
|
- | |
2318 | 2531 | ||
2319 | first = fragment.firstChild; |
2532 | // Make sure no comments are found
|
- | 2533 | if ( div.getElementsByTagName("*").length > 0 ) { |
|
- | 2534 | Expr.find.TAG = function(match, context){ |
|
- | 2535 | var results = context.getElementsByTagName(match[1]); |
|
2320 | 2536 | ||
- | 2537 | // Filter out possible comments
|
|
2321 | if ( first ) { |
2538 | if ( match[1] === "*" ) { |
2322 | table = table && jQuery.nodeName( first, "tr" ); |
2539 | var tmp = []; |
2323 | 2540 | ||
2324 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2541 | for ( var i = 0; results[i]; i++ ) { |
2325 | callback.call( |
- | |
2326 | table ?
|
- | |
2327 | root(this[i], first) : |
- | |
2328 | this[i], |
- | |
2329 | cacheable || this.length > 1 || i > 0 ? |
2542 | if ( results[i].nodeType === 1 ) { |
2330 | fragment.cloneNode(true) : |
2543 | tmp.push( results[i] ); |
2331 | fragment |
- | |
2332 | ); |
2544 | }
|
2333 | }
|
2545 | }
|
2334 | }
|
- | |
2335 | 2546 | ||
2336 | if ( scripts ) { |
2547 | results = tmp; |
2337 | jQuery.each( scripts, evalScript ); |
- | |
2338 | }
|
2548 | }
|
2339 | 2549 | ||
2340 | if ( cacheable ) { |
2550 | return results; |
2341 | jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
- | |
2342 | }
|
2551 | }; |
2343 | }
|
2552 | }
|
2344 | 2553 | ||
- | 2554 | // Check to see if an attribute returns normalized href attributes
|
|
- | 2555 | div.innerHTML = "<a href='#'></a>"; |
|
- | 2556 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
|
- | 2557 | div.firstChild.getAttribute("href") !== "#" ) { |
|
- | 2558 | Expr.attrHandle.href = function(elem){ |
|
2345 | return this; |
2559 | return elem.getAttribute("href", 2); |
- | 2560 | }; |
|
- | 2561 | }
|
|
2346 | 2562 | ||
- | 2563 | div = null; // release memory in IE |
|
- | 2564 | })(); |
|
- | 2565 | ||
- | 2566 | if ( document.querySelectorAll ) (function(){ |
|
- | 2567 | var oldSizzle = Sizzle, div = document.createElement("div"); |
|
- | 2568 | div.innerHTML = "<p class='TEST'></p>"; |
|
- | 2569 | ||
- | 2570 | // Safari can't handle uppercase or unicode characters when
|
|
- | 2571 | // in quirks mode.
|
|
- | 2572 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
|
- | 2573 | return; |
|
- | 2574 | }
|
|
- | 2575 | ||
- | 2576 | Sizzle = function(query, context, extra, seed){ |
|
2347 | function root( elem, cur ) { |
2577 | context = context || document; |
- | 2578 | ||
2348 | return jQuery.nodeName(elem, "table") ? |
2579 | // Only use querySelectorAll on non-XML documents
|
2349 | (elem.getElementsByTagName("tbody")[0] || |
2580 | // (ID selectors don't work in non-HTML documents)
|
2350 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2581 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
2351 | elem;
|
2582 | try { |
- | 2583 | return makeArray( context.querySelectorAll(query), extra ); |
|
- | 2584 | } catch(e){} |
|
2352 | }
|
2585 | }
|
- | 2586 | ||
- | 2587 | return oldSizzle(query, context, extra, seed); |
|
- | 2588 | }; |
|
- | 2589 | ||
- | 2590 | for ( var prop in oldSizzle ) { |
|
- | 2591 | Sizzle[ prop ] = oldSizzle[ prop ]; |
|
2353 | }
|
2592 | }
|
2354 | }); |
- | |
2355 | 2593 | ||
2356 | jQuery.fragments = {}; |
2594 | div = null; // release memory in IE |
- | 2595 | })(); |
|
2357 | 2596 | ||
2358 | jQuery.each({ |
- | |
2359 | appendTo: "append", |
- | |
2360 | prependTo: "prepend", |
- | |
2361 | insertBefore: "before", |
- | |
2362 | insertAfter: "after", |
- | |
2363 | replaceAll: "replaceWith" |
- | |
2364 | }, function(name, original){ |
2597 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
2365 | jQuery.fn[ name ] = function( selector ) { |
2598 | var div = document.createElement("div"); |
2366 | var ret = [], insert = jQuery( selector ); |
2599 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
2367 | 2600 | ||
2368 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
- | |
2369 | var elems = (i > 0 ? this.clone(true) : this).get(); |
2601 | // Opera can't find a second classname (in 9.6)
|
2370 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
2602 | if ( div.getElementsByClassName("e").length === 0 ) |
2371 | ret = ret.concat( elems ); |
- | |
2372 | }
|
2603 | return; |
2373 | 2604 | ||
- | 2605 | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
|
- | 2606 | div.lastChild.className = "e"; |
|
- | 2607 | ||
- | 2608 | if ( div.getElementsByClassName("e").length === 1 ) |
|
- | 2609 | return; |
|
- | 2610 | ||
- | 2611 | Expr.order.splice(1, 0, "CLASS"); |
|
- | 2612 | Expr.find.CLASS = function(match, context, isXML) { |
|
- | 2613 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
|
2374 | return this.pushStack( ret, name, selector ); |
2614 | return context.getElementsByClassName(match[1]); |
- | 2615 | }
|
|
2375 | }; |
2616 | }; |
2376 | }); |
- | |
2377 | 2617 | ||
- | 2618 | div = null; // release memory in IE |
|
2378 | jQuery.each({ |
2619 | })(); |
- | 2620 | ||
2379 | // keepData is for internal use only--do not document
|
2621 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
2380 | remove: function( selector, keepData ) { |
2622 | var sibDir = dir == "previousSibling" && !isXML; |
2381 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
2623 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
- | 2624 | var elem = checkSet[i]; |
|
- | 2625 | if ( elem ) { |
|
2382 | if ( !keepData && this.nodeType === 1 ) { |
2626 | if ( sibDir && elem.nodeType === 1 ){ |
2383 | cleanData( jQuery("*", this).add(this) ); |
2627 | elem.sizcache = doneName; |
- | 2628 | elem.sizset = i; |
|
2384 | }
|
2629 | }
|
- | 2630 | elem = elem[dir]; |
|
- | 2631 | var match = false; |
|
2385 | 2632 | ||
- | 2633 | while ( elem ) { |
|
2386 | if ( this.parentNode ) { |
2634 | if ( elem.sizcache === doneName ) { |
2387 | this.parentNode.removeChild( this ); |
2635 | match = checkSet[elem.sizset]; |
2388 | }
|
2636 | break; |
2389 | }
|
2637 | }
|
2390 | }, |
- | |
2391 | 2638 | ||
2392 | empty: function() { |
- | |
2393 | // Remove element nodes and prevent memory leaks
|
2639 | if ( elem.nodeType === 1 && !isXML ){ |
2394 | if ( this.nodeType === 1 ) { |
2640 | elem.sizcache = doneName; |
2395 | cleanData( jQuery("*", this) ); |
2641 | elem.sizset = i; |
2396 | }
|
2642 | }
|
2397 | 2643 | ||
2398 | // Remove any remaining nodes
|
- | |
2399 | while ( this.firstChild ) { |
2644 | if ( elem.nodeName === cur ) { |
2400 | this.removeChild( this.firstChild ); |
2645 | match = elem; |
2401 | }
|
2646 | break; |
2402 | }
|
2647 | }
|
2403 | }, function(name, fn){ |
- | |
2404 | jQuery.fn[ name ] = function(){ |
- | |
2405 | return this.each( fn, arguments ); |
- | |
2406 | }; |
- | |
2407 | }); |
- | |
2408 | 2648 | ||
2409 | jQuery.extend({ |
2649 | elem = elem[dir]; |
2410 | clean: function( elems, context, fragment ) { |
- | |
2411 | context = context || document; |
2650 | }
|
2412 | 2651 | ||
2413 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
- | |
2414 | if ( typeof context.createElement === "undefined" ) { |
2652 | checkSet[i] = match; |
2415 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
- | |
2416 | }
|
2653 | }
|
- | 2654 | }
|
|
- | 2655 | }
|
|
2417 | 2656 | ||
2418 | // If a single string is passed in and it's a single tag
|
2657 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
2419 | // just do a createElement and skip the rest
|
2658 | var sibDir = dir == "previousSibling" && !isXML; |
2420 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
2659 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
2421 | var match = rsingleTag.exec(elems[0]); |
2660 | var elem = checkSet[i]; |
2422 | if ( match ) { |
2661 | if ( elem ) { |
2423 | return [ context.createElement( match[1] ) ]; |
2662 | if ( sibDir && elem.nodeType === 1 ) { |
- | 2663 | elem.sizcache = doneName; |
|
- | 2664 | elem.sizset = i; |
|
2424 | }
|
2665 | }
|
2425 | }
|
2666 | elem = elem[dir]; |
2426 | - | ||
2427 | var ret = [], scripts = [], div = context.createElement("div"); |
2667 | var match = false; |
2428 | 2668 | ||
2429 | jQuery.each(elems, function(i, elem){ |
2669 | while ( elem ) { |
2430 | if ( typeof elem === "number" ) { |
2670 | if ( elem.sizcache === doneName ) { |
- | 2671 | match = checkSet[elem.sizset]; |
|
2431 | elem += ''; |
2672 | break; |
2432 | }
|
2673 | }
|
2433 | 2674 | ||
- | 2675 | if ( elem.nodeType === 1 ) { |
|
- | 2676 | if ( !isXML ) { |
|
- | 2677 | elem.sizcache = doneName; |
|
- | 2678 | elem.sizset = i; |
|
- | 2679 | }
|
|
- | 2680 | if ( typeof cur !== "string" ) { |
|
2434 | if ( !elem ) { return; } |
2681 | if ( elem === cur ) { |
- | 2682 | match = true; |
|
- | 2683 | break; |
|
- | 2684 | }
|
|
2435 | 2685 | ||
2436 | // Convert html string into DOM nodes
|
2686 | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
2437 | if ( typeof elem === "string" ) { |
2687 | match = elem; |
2438 | // Fix "XHTML"-style tags in all browsers
|
2688 | break; |
2439 | elem = elem.replace(rxhtmlTag, fcloseTag); |
2689 | }
|
- | 2690 | }
|
|
2440 | 2691 | ||
2441 | // Trim whitespace, otherwise indexOf won't work as expected
|
- | |
2442 | var tags = elem.replace(rleadingWhitespace, "") |
2692 | elem = elem[dir]; |
2443 | .substring(0, 10).toLowerCase(); |
2693 | }
|
2444 | 2694 | ||
2445 | var wrap = |
- | |
2446 | // option or optgroup
|
2695 | checkSet[i] = match; |
2447 | !tags.indexOf("<opt") && |
2696 | }
|
2448 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
- | |
- | 2697 | }
|
|
- | 2698 | }
|
|
2449 | 2699 | ||
- | 2700 | var contains = document.compareDocumentPosition ? function(a, b){ |
|
2450 | !tags.indexOf("<leg") && |
2701 | return a.compareDocumentPosition(b) & 16; |
- | 2702 | } : function(a, b){ |
|
2451 | [ 1, "<fieldset>", "</fieldset>" ] || |
2703 | return a !== b && (a.contains ? a.contains(b) : true); |
- | 2704 | }; |
|
2452 | 2705 | ||
2453 | rinsideTable.test(tags) && |
2706 | var isXML = function(elem){ |
2454 | [ 1, "<table>", "</table>" ] || |
2707 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
- | 2708 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
|
- | 2709 | }; |
|
2455 | 2710 | ||
- | 2711 | var posProcess = function(selector, context){ |
|
2456 | !tags.indexOf("<tr") && |
2712 | var tmpSet = [], later = "", match, |
2457 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
2713 | root = context.nodeType ? [context] : context; |
2458 | 2714 | ||
2459 | // <thead> matched above
|
2715 | // Position selectors must be done after the filter
|
- | 2716 | // And so must :not(positional) so we move all PSEUDOs to the end
|
|
2460 | (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
2717 | while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
- | 2718 | later += match[0]; |
|
2461 | [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
2719 | selector = selector.replace( Expr.match.PSEUDO, "" ); |
- | 2720 | }
|
|
2462 | 2721 | ||
2463 | !tags.indexOf("<col") && |
- | |
2464 | [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
2722 | selector = Expr.relative[selector] ? selector + "*" : selector; |
2465 | 2723 | ||
2466 | // IE can't serialize <link> and <script> tags normally
|
2724 | for ( var i = 0, l = root.length; i < l; i++ ) { |
2467 | !jQuery.support.htmlSerialize && |
2725 | Sizzle( selector, root[i], tmpSet ); |
2468 | [ 1, "div<div>", "</div>" ] || |
- | |
- | 2726 | }
|
|
2469 | 2727 | ||
2470 | [ 0, "", "" ]; |
2728 | return Sizzle.filter( later, tmpSet ); |
- | 2729 | }; |
|
2471 | 2730 | ||
- | 2731 | // EXPOSE
|
|
- | 2732 | jQuery.find = Sizzle; |
|
2472 | // Go to html and back, then peel off extra wrappers
|
2733 | jQuery.expr = Sizzle.selectors; |
2473 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2734 | jQuery.expr[":"] = jQuery.expr.filters; |
2474 | 2735 | ||
- | 2736 | Sizzle.selectors.filters.hidden = function(elem){ |
|
2475 | // Move to the right depth
|
2737 | var width = elem.offsetWidth, height = elem.offsetHeight, |
- | 2738 | force = /^tr$/i.test( elem.nodeName ); // ticket #4512 |
|
2476 | while ( wrap[0]-- ) { |
2739 | return ( width === 0 && height === 0 && !force ) ? |
- | 2740 | true : |
|
2477 | div = div.lastChild; |
2741 | ( width !== 0 && height !== 0 && !force ) ? |
2478 | }
|
2742 | false : |
- | 2743 | !!( jQuery.curCSS(elem, "display") === "none" ); |
|
- | 2744 | }; |
|
2479 | 2745 | ||
2480 | // Remove IE's autoinserted <tbody> from table fragments
|
2746 | Sizzle.selectors.filters.visible = function(elem){ |
2481 | if ( !jQuery.support.tbody ) { |
2747 | return !Sizzle.selectors.filters.hidden(elem); |
- | 2748 | }; |
|
2482 | 2749 | ||
2483 | // String was a <table>, *may* have spurious <tbody>
|
2750 | Sizzle.selectors.filters.animated = function(elem){ |
2484 | var hasBody = rtbody.test(elem), |
2751 | return jQuery.grep(jQuery.timers, function(fn){ |
2485 | tbody = !tags.indexOf("<table") && !hasBody ? |
2752 | return elem === fn.elem; |
2486 | div.firstChild && div.firstChild.childNodes : |
2753 | }).length; |
- | 2754 | }; |
|
2487 | 2755 | ||
2488 | // String was a bare <thead> or <tfoot>
|
2756 | jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) { |
2489 | wrap[1] == "<table>" && !hasBody ? |
2757 | if ( not ) { |
2490 | div.childNodes : |
2758 | expr = ":not(" + expr + ")"; |
2491 | []; |
2759 | }
|
2492 | 2760 | ||
2493 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
- | |
2494 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
- | |
2495 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
2761 | return Sizzle.matches(expr, elems); |
2496 | }
|
- | |
2497 | }
|
2762 | }; |
2498 | 2763 | ||
- | 2764 | jQuery.dir = function( elem, dir ){ |
|
- | 2765 | var matched = [], cur = elem[dir]; |
|
- | 2766 | while ( cur && cur != document ) { |
|
- | 2767 | if ( cur.nodeType == 1 ) |
|
- | 2768 | matched.push( cur ); |
|
- | 2769 | cur = cur[dir]; |
|
2499 | }
|
2770 | }
|
- | 2771 | return matched; |
|
- | 2772 | }; |
|
2500 | 2773 | ||
2501 | // IE completely kills leading whitespace when innerHTML is used
|
2774 | jQuery.nth = function(cur, result, dir, elem){ |
2502 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
2775 | result = result || 1; |
2503 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
- | |
2504 | }
|
2776 | var num = 0; |
2505 | 2777 | ||
- | 2778 | for ( ; cur; cur = cur[dir] ) |
|
2506 | elem = jQuery.makeArray( div.childNodes ); |
2779 | if ( cur.nodeType == 1 && ++num == result ) |
2507 | }
|
2780 | break; |
2508 | 2781 | ||
2509 | if ( elem.nodeType ) { |
- | |
2510 | ret.push( elem ); |
2782 | return cur; |
2511 | } else { |
- | |
2512 | ret = jQuery.merge( ret, elem ); |
- | |
2513 | }
|
2783 | }; |
2514 | 2784 | ||
- | 2785 | jQuery.sibling = function(n, elem){ |
|
2515 | }); |
2786 | var r = []; |
2516 | 2787 | ||
2517 | if ( fragment ) { |
- | |
2518 | for ( var i = 0; ret[i]; i++ ) { |
2788 | for ( ; n; n = n.nextSibling ) { |
2519 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
- | |
2520 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
- | |
2521 | } else { |
- | |
2522 | if ( ret[i].nodeType === 1 ) { |
2789 | if ( n.nodeType == 1 && n != elem ) |
2523 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
- | |
2524 | }
|
- | |
2525 | fragment.appendChild( ret[i] ); |
2790 | r.push( n ); |
2526 | }
|
- | |
2527 | }
|
2791 | }
|
2528 | 2792 | ||
2529 | return scripts; |
2793 | return r; |
2530 | }
|
2794 | }; |
2531 | 2795 | ||
2532 | return ret; |
2796 | jQuery.unique = Sizzle.uniqueSort; |
2533 | }
|
- | |
2534 | }); |
- | |
2535 | 2797 | ||
2536 | function cleanData( elems ) { |
- | |
2537 | for ( var i = 0, l = elems.length; i < l; i++ ) { |
- | |
2538 | var id = elems[i][expando]; |
- | |
2539 | if ( id ) { |
- | |
2540 | delete jQuery.cache[ id ]; |
- | |
2541 | }
|
- | |
2542 | }
|
- | |
2543 | }
|
- | |
2544 | /*
|
- | |
2545 | * A number of helper functions used for managing events.
|
- | |
2546 | * Many of the ideas behind this code originated from
|
- | |
2547 | * Dean Edwards' addEvent library.
|
- | |
2548 | */
|
- | |
2549 | jQuery.event = { |
2798 | return; |
2550 | 2799 | ||
2551 | // Bind an event to an element
|
2800 | window.Sizzle = Sizzle; |
2552 | // Original by Dean Edwards
|
- | |
2553 | add: function( elem, types, handler, data ) { |
- | |
2554 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
- | |
2555 | return; |
- | |
2556 | }
|
- | |
2557 | 2801 | ||
- | 2802 | })(); |
|
- | 2803 | var winnow = function( elements, qualifier, keep ) { |
|
- | 2804 | if(jQuery.isFunction( qualifier )) { |
|
2558 | // For whatever reason, IE has trouble passing the window object
|
2805 | return jQuery.grep(elements, function(elem, i) { |
2559 | // around, causing it to be cloned in the process
|
2806 | return !!qualifier.call( elem, i ) === keep; |
- | 2807 | }); |
|
- | 2808 | } else if( qualifier.nodeType ) { |
|
2560 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
2809 | return jQuery.grep(elements, function(elem, i) { |
2561 | elem = window; |
2810 | return (elem === qualifier) === keep; |
2562 | }
|
2811 | }) |
- | 2812 | } else if( typeof qualifier === "string" ) { |
|
- | 2813 | var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 }); |
|
2563 | 2814 | ||
2564 | // Make sure that the function being executed has a unique ID
|
2815 | if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep); |
2565 | if ( !handler.guid ) { |
- | |
2566 | handler.guid = this.guid++; |
2816 | else qualifier = jQuery.multiFilter( qualifier, elements ); |
2567 | }
|
2817 | }
|
2568 | 2818 | ||
2569 | // if data is passed, bind to handler
|
2819 | return jQuery.grep(elements, function(elem, i) { |
2570 | if ( data !== undefined ) { |
- | |
2571 | // Create temporary function pointer to original handler
|
2820 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
2572 | var fn = handler; |
2821 | }); |
- | 2822 | }
|
|
2573 | 2823 | ||
- | 2824 | jQuery.fn.extend({ |
|
2574 | // Create unique handler function, wrapped around original handler
|
2825 | find: function( selector ) { |
2575 | handler = this.proxy( fn ); |
2826 | var ret = this.pushStack( "", "find", selector ), length = 0; |
2576 | 2827 | ||
- | 2828 | for ( var i = 0, l = this.length; i < l; i++ ) { |
|
- | 2829 | length = ret.length; |
|
- | 2830 | jQuery.find( selector, this[i], ret ); |
|
- | 2831 | ||
- | 2832 | if ( i > 0 ) { |
|
2577 | // Store data in unique handler
|
2833 | // Make sure that the results are unique
|
- | 2834 | for ( var n = length; n < ret.length; n++ ) { |
|
- | 2835 | for ( var r = 0; r < length; r++ ) { |
|
- | 2836 | if ( ret[r] === ret[n] ) { |
|
2578 | handler.data = data; |
2837 | ret.splice(n--, 1); |
- | 2838 | break; |
|
- | 2839 | }
|
|
- | 2840 | }
|
|
- | 2841 | }
|
|
- | 2842 | }
|
|
2579 | }
|
2843 | }
|
2580 | 2844 | ||
2581 | // Init the element's event structure
|
- | |
2582 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
- | |
2583 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
- | |
2584 | // Handle the second event of a trigger and when
|
- | |
2585 | // an event is called after a page has unloaded
|
- | |
2586 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
- | |
2587 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
- | |
2588 | undefined; |
2845 | return ret; |
2589 | }); |
2846 | }, |
2590 | // Add elem as a property of the handle function
|
- | |
2591 | // This is to prevent a memory leak with non-native
|
- | |
2592 | // event in IE.
|
- | |
2593 | handle.elem = elem; |
- | |
2594 | 2847 | ||
2595 | // Handle multiple events separated by a space
|
2848 | not: function( selector ) { |
2596 | // jQuery(...).bind("mouseover mouseout", fn);
|
2849 | return this.pushStack( winnow(this, selector, false), "not", selector); |
2597 | types = types.split( /\s+/ ); |
- | |
2598 | var type, i=0; |
2850 | }, |
2599 | while ( (type = types[ i++ ]) ) { |
- | |
2600 | // Namespaced event handlers
|
- | |
2601 | var namespaces = type.split("."); |
- | |
2602 | type = namespaces.shift(); |
- | |
2603 | handler.type = namespaces.slice(0).sort().join("."); |
- | |
2604 | 2851 | ||
2605 | // Get the current list of functions bound to this event
|
- | |
2606 | var handlers = events[ type ], |
2852 | filter: function( selector ) { |
2607 | special = this.special[ type ] || {}; |
2853 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
- | 2854 | }, |
|
2608 | 2855 | ||
2609 | if ( special.add ) { |
2856 | closest: function( selector, context ) { |
2610 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
2857 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
- | 2858 | closer = 0; |
|
- | 2859 | ||
- | 2860 | return this.map(function(){ |
|
- | 2861 | var cur = this; |
|
2611 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
2862 | while ( cur && cur.ownerDocument && cur !== context ) { |
2612 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
2863 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
2613 | handler = modifiedHandler; |
2864 | jQuery.data(cur, "closest", closer); |
- | 2865 | return cur; |
|
2614 | }
|
2866 | }
|
- | 2867 | cur = cur.parentNode; |
|
- | 2868 | closer++;
|
|
2615 | }
|
2869 | }
|
- | 2870 | }); |
|
- | 2871 | }, |
|
2616 | 2872 | ||
- | 2873 | add: function( selector ) { |
|
2617 | // Init the event handler queue
|
2874 | var set = typeof selector === "string" ? |
2618 | if ( !handlers ) { |
2875 | jQuery( selector ) : |
2619 | handlers = events[ type ] = {}; |
2876 | jQuery.makeArray( selector ), |
- | 2877 | all = jQuery.merge( this.get(), set ); |
|
2620 | 2878 | ||
2621 | // Check for a special event handler
|
- | |
2622 | // Only use addEventListener/attachEvent if the special
|
- | |
2623 | // events handler returns false
|
- | |
2624 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
2879 | return this.pushStack( set[0] && (set[0].setInterval || set[0].nodeType === 9 || (set[0].parentNode && set[0].parentNode.nodeType !== 11)) ? |
2625 | // Bind the global event handler to the element
|
- | |
2626 | if ( elem.addEventListener ) { |
2880 | jQuery.unique( all ) : |
2627 | elem.addEventListener( type, handle, false ); |
- | |
2628 | } else if ( elem.attachEvent ) { |
- | |
2629 | elem.attachEvent( "on" + type, handle ); |
- | |
2630 | }
|
2881 | all ); |
2631 | }
|
- | |
2632 | }
|
2882 | }, |
2633 | 2883 | ||
2634 | // Add the function to the element's handler list
|
2884 | eq: function( i ) { |
- | 2885 | return i === -1 ? |
|
- | 2886 | this.slice( i ) : |
|
2635 | handlers[ handler.guid ] = handler; |
2887 | this.slice( i, +i + 1 ); |
- | 2888 | }, |
|
2636 | 2889 | ||
2637 | // Keep track of which events have been used, for global triggering
|
2890 | first: function() { |
2638 | this.global[ type ] = true; |
2891 | return this.eq( 0 ); |
2639 | }
|
2892 | }, |
2640 | 2893 | ||
2641 | // Nullify elem to prevent memory leaks in IE
|
2894 | last: function() { |
2642 | elem = null; |
2895 | return this.eq( -1 ); |
2643 | }, |
2896 | }, |
2644 | 2897 | ||
2645 | guid: 1, |
2898 | slice: function() { |
- | 2899 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
|
- | 2900 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
|
2646 | global: {}, |
2901 | }, |
2647 | 2902 | ||
2648 | // Detach an event or set of events from an element
|
- | |
2649 | remove: function( elem, types, handler ) { |
2903 | map: function( callback ) { |
2650 | // don't do events on text and comment nodes
|
2904 | return this.pushStack( jQuery.map(this, function(elem, i){ |
2651 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2905 | return callback.call( elem, i, elem ); |
2652 | return; |
2906 | })); |
2653 | }
|
2907 | }, |
2654 | 2908 | ||
- | 2909 | andSelf: function() { |
|
2655 | var events = jQuery.data( elem, "events" ), ret, type; |
2910 | return this.add( this.prevObject ); |
- | 2911 | }, |
|
2656 | 2912 | ||
2657 | if ( events ) { |
2913 | end: function() { |
2658 | // Unbind all events for the element
|
- | |
2659 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
- | |
2660 | for ( type in events ) { |
- | |
2661 | this.remove( elem, type + (types || "") ); |
2914 | return this.prevObject || jQuery(null); |
2662 | }
|
2915 | }
|
2663 | } else { |
- | |
2664 | // types is actually an event object here
|
- | |
2665 | if ( types.type ) { |
- | |
2666 | handler = types.handler; |
- | |
2667 | types = types.type; |
- | |
2668 | }
|
2916 | }); |
2669 | 2917 | ||
- | 2918 | jQuery.each({ |
|
2670 | // Handle multiple events seperated by a space
|
2919 | parent: function(elem){return elem.parentNode;}, |
2671 | // jQuery(...).unbind("mouseover mouseout", fn);
|
2920 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
2672 | types = types.split(/\s+/); |
2921 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
2673 | var i = 0; |
2922 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
2674 | while ( (type = types[ i++ ]) ) { |
2923 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
2675 | // Namespaced event handlers
|
2924 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
2676 | var namespaces = type.split("."); |
2925 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
2677 | type = namespaces.shift(); |
2926 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
- | 2927 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
|
2678 | var all = !namespaces.length, |
2928 | }, function(name, fn){ |
2679 | namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
2929 | jQuery.fn[ name ] = function( selector ) { |
2680 | special = this.special[ type ] || {}; |
2930 | var ret = jQuery.map( this, fn ); |
2681 | 2931 | ||
2682 | if ( events[ type ] ) { |
2932 | if ( selector && typeof selector === "string" ) { |
2683 | // remove the given handler for the given type
|
2933 | ret = jQuery.multiFilter( selector, ret ); |
2684 | if ( handler ) { |
2934 | }
|
2685 | delete events[ type ][ handler.guid ]; |
- | |
2686 | 2935 | ||
2687 | // remove all handlers for the given type
|
- | |
2688 | } else { |
- | |
2689 | for ( var handle in events[ type ] ) { |
- | |
2690 | // Handle the removal of namespaced events
|
2936 | ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
2691 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
- | |
2692 | delete events[ type ][ handle ]; |
- | |
2693 | }
|
- | |
2694 | }
|
- | |
2695 | }
|
- | |
2696 | 2937 | ||
2697 | if ( special.remove ) { |
2938 | if ( name === "parents" && this.length > 1 ) { |
2698 | special.remove.call( elem, namespaces ); |
2939 | ret = ret.reverse(); |
2699 | }
|
2940 | }
|
2700 | 2941 | ||
2701 | // remove generic event handler if no more handlers exist
|
2942 | return this.pushStack( ret, name, selector ); |
- | 2943 | }; |
|
- | 2944 | }); |
|
- | 2945 | jQuery.fn.extend({ |
|
2702 | for ( ret in events[ type ] ) { |
2946 | attr: function( name, value ) { |
2703 | break; |
2947 | return access(this, name, value, true, jQuery.attr); |
2704 | }
|
2948 | }, |
- | 2949 | ||
2705 | if ( !ret ) { |
2950 | addClass: function( value ) { |
2706 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
2951 | if ( value && typeof value === "string" ) { |
2707 | if ( elem.removeEventListener ) { |
2952 | var classNames = (value || "").split(/\s+/); |
- | 2953 | ||
2708 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
2954 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | 2955 | var elem = this[i]; |
|
- | 2956 | ||
- | 2957 | if ( elem.nodeType === 1 ) { |
|
2709 | } else if ( elem.detachEvent ) { |
2958 | if ( !elem.className ) { |
2710 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
2959 | elem.className = value; |
2711 | }
|
2960 | } else { |
- | 2961 | var className = " " + elem.className + " "; |
|
- | 2962 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
|
- | 2963 | if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
|
- | 2964 | elem.className += " " + classNames[c]; |
|
2712 | }
|
2965 | }
|
2713 | ret = null; |
- | |
2714 | delete events[ type ]; |
- | |
2715 | }
|
2966 | }
|
2716 | }
|
2967 | }
|
2717 | }
|
2968 | }
|
2718 | }
|
2969 | }
|
2719 | - | ||
2720 | // Remove the expando if it's no longer used
|
- | |
2721 | for ( ret in events ) { |
- | |
2722 | break; |
- | |
2723 | }
|
- | |
2724 | if ( !ret ) { |
- | |
2725 | var handle = jQuery.data( elem, "handle" ); |
- | |
2726 | if ( handle ) { |
- | |
2727 | handle.elem = null; |
- | |
2728 | }
|
- | |
2729 | jQuery.removeData( elem, "events" ); |
- | |
2730 | jQuery.removeData( elem, "handle" ); |
- | |
2731 | }
|
- | |
2732 | }
|
2970 | }
|
2733 | }, |
- | |
2734 | - | ||
2735 | // bubbling is internal
|
- | |
2736 | trigger: function( event, data, elem /*, bubbling */ ) { |
- | |
2737 | // Event object or event type
|
- | |
2738 | var type = event.type || event, |
- | |
2739 | bubbling = arguments[3]; |
- | |
2740 | 2971 | ||
2741 | if ( !bubbling ) { |
2972 | return this; |
2742 | event = typeof event === "object" ? |
- | |
2743 | // jQuery.Event object
|
- | |
2744 | event[expando] ? event : |
- | |
2745 | // Object literal
|
2973 | }, |
2746 | jQuery.extend( jQuery.Event(type), event ) : |
- | |
2747 | // Just the event type (string)
|
- | |
2748 | jQuery.Event(type); |
- | |
2749 | 2974 | ||
2750 | if ( type.indexOf("!") >= 0 ) { |
2975 | removeClass: function( value ) { |
2751 | event.type = type = type.slice(0, -1); |
2976 | if ( (value && typeof value === "string") || value === undefined ) { |
2752 | event.exclusive = true; |
2977 | var classNames = (value || "").split(/\s+/); |
2753 | }
|
- | |
2754 | 2978 | ||
2755 | // Handle a global trigger
|
2979 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2756 | if ( !elem ) { |
2980 | var elem = this[i]; |
2757 | // Don't bubble custom events when global (to avoid too much overhead)
|
- | |
2758 | event.stopPropagation(); |
- | |
- | 2981 | ||
2759 | // Only trigger if we've ever bound an event for it
|
2982 | if ( elem.nodeType === 1 && elem.className ) { |
2760 | if ( this.global[ type ] ) { |
2983 | if ( value ) { |
2761 | jQuery.each( jQuery.cache, function() { |
2984 | var className = " " + elem.className + " "; |
2762 | if ( this.events && this.events[type] ) { |
2985 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
2763 | jQuery.event.trigger( event, data, this.handle.elem ); |
2986 | className = className.replace(" " + classNames[c] + " ", " "); |
2764 | }
|
2987 | }
|
- | 2988 | elem.className = className.substring(1, className.length - 1); |
|
- | 2989 | } else { |
|
- | 2990 | elem.className = ""; |
|
2765 | }); |
2991 | }
|
2766 | }
|
2992 | }
|
2767 | }
|
2993 | }
|
- | 2994 | }
|
|
2768 | 2995 | ||
2769 | // Handle triggering a single element
|
2996 | return this; |
- | 2997 | }, |
|
2770 | 2998 | ||
- | 2999 | hasClass: function( selector ) { |
|
- | 3000 | var className = " " + selector + " "; |
|
2771 | // don't do events on text and comment nodes
|
3001 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2772 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
3002 | if ( (" " + this[i].className + " ").indexOf( className ) > -1 ) { |
2773 | return undefined; |
3003 | return true; |
2774 | }
|
3004 | }
|
- | 3005 | }
|
|
2775 | 3006 | ||
2776 | // Clean up in case it is reused
|
- | |
2777 | event.result = undefined; |
- | |
2778 | event.target = elem; |
3007 | return false; |
- | 3008 | }, |
|
2779 | 3009 | ||
2780 | // Clone the incoming data, if any
|
3010 | val: function( value ) { |
2781 | data = jQuery.makeArray( data ); |
3011 | if ( value === undefined ) { |
2782 | data.unshift( event ); |
3012 | var elem = this[0]; |
2783 | }
|
- | |
2784 | 3013 | ||
- | 3014 | if ( elem ) { |
|
2785 | event.currentTarget = elem; |
3015 | if( jQuery.nodeName( elem, 'option' ) ) |
- | 3016 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
|
2786 | 3017 | ||
2787 | // Trigger the event, it is assumed that "handle" is a function
|
3018 | // We need to handle select boxes special
|
2788 | var handle = jQuery.data( elem, "handle" ); |
3019 | if ( jQuery.nodeName( elem, "select" ) ) { |
- | 3020 | var index = elem.selectedIndex, |
|
2789 | if ( handle ) { |
3021 | values = [], |
2790 | handle.apply( elem, data ); |
3022 | options = elem.options, |
2791 | }
|
- | |
- | 3023 | one = elem.type == "select-one"; |
|
2792 | 3024 | ||
2793 | var nativeFn, nativeHandler; |
3025 | // Nothing was selected
|
2794 | try { |
- | |
2795 | nativeFn = elem[ type ]; |
3026 | if ( index < 0 ) |
2796 | nativeHandler = elem[ "on" + type ]; |
- | |
2797 | // prevent IE from throwing an error for some elements with some event types, see #3533
|
- | |
2798 | } catch (e) {} |
- | |
2799 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
- | |
2800 | if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
- | |
2801 | event.result = false; |
3027 | return null; |
2802 | }
|
- | |
2803 | 3028 | ||
2804 | // Trigger the native events (except for clicks on links)
|
3029 | // Loop through all the selected options
|
2805 | if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
3030 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
2806 | this.triggered = true; |
3031 | var option = options[ i ]; |
2807 | try { |
- | |
2808 | nativeFn(); |
- | |
2809 | // prevent IE from throwing an error for some hidden elements
|
- | |
2810 | } catch (e) {} |
- | |
2811 | }
|
- | |
2812 | 3032 | ||
2813 | this.triggered = false; |
3033 | if ( option.selected ) { |
- | 3034 | // Get the specifc value for the option
|
|
- | 3035 | value = jQuery(option).val(); |
|
2814 | 3036 | ||
2815 | if ( !event.isPropagationStopped() ) { |
- | |
2816 | var parent = elem.parentNode || elem.ownerDocument; |
3037 | // We don't need an array for one selects
|
2817 | if ( parent ) { |
3038 | if ( one ) |
2818 | jQuery.event.trigger( event, data, parent, true ); |
3039 | return value; |
2819 | }
|
- | |
2820 | }
|
- | |
2821 | }, |
- | |
2822 | 3040 | ||
2823 | handle: function( event ) { |
3041 | // Multi-Selects return an array
|
2824 | // returned undefined or false
|
3042 | values.push( value ); |
2825 | var all, handlers; |
3043 | }
|
- | 3044 | }
|
|
2826 | 3045 | ||
2827 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
- | |
2828 | event.currentTarget = this; |
3046 | return values; |
- | 3047 | }
|
|
2829 | 3048 | ||
2830 | // Namespaced event handlers
|
3049 | // Everything else, we just grab the value
|
2831 | var namespaces = event.type.split("."); |
3050 | return (elem.value || "").replace(/\r/g, ""); |
2832 | event.type = namespaces.shift(); |
- | |
2833 | 3051 | ||
2834 | // Cache this now, all = true means, any handler
|
- | |
2835 | all = !namespaces.length && !event.exclusive; |
- | |
- | 3052 | }
|
|
2836 | 3053 | ||
2837 | var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
3054 | return undefined; |
- | 3055 | }
|
|
2838 | 3056 | ||
2839 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
3057 | // Typecast once if the value is a number
|
- | 3058 | if ( typeof value === "number" ) |
|
- | 3059 | value += ''; |
|
- | 3060 | ||
- | 3061 | var val = value; |
|
2840 | 3062 | ||
- | 3063 | return this.each(function(){ |
|
2841 | for ( var j in handlers ) { |
3064 | if(jQuery.isFunction(value)) { |
2842 | var handler = handlers[ j ]; |
3065 | val = value.call(this); |
- | 3066 | // Typecast each time if the value is a Function and the appended
|
|
- | 3067 | // value is therefore different each time.
|
|
- | 3068 | if( typeof val === "number" ) val += ''; |
|
- | 3069 | }
|
|
- | 3070 | ||
- | 3071 | if ( this.nodeType != 1 ) |
|
- | 3072 | return; |
|
2843 | 3073 | ||
2844 | // Filter the functions by class
|
- | |
2845 | if ( all || namespace.test(handler.type) ) { |
3074 | if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) |
2846 | // Pass in a reference to the handler function itself
|
3075 | this.checked = jQuery.inArray(this.value || this.name, val) >= 0; |
2847 | // So that we can later remove it
|
- | |
2848 | event.handler = handler; |
- | |
2849 | event.data = handler.data; |
- | |
2850 | 3076 | ||
2851 | var ret = handler.apply( this, arguments ); |
3077 | else if ( jQuery.nodeName( this, "select" ) ) { |
- | 3078 | var values = jQuery.makeArray(val); |
|
2852 | 3079 | ||
2853 | if ( ret !== undefined ) { |
3080 | jQuery( "option", this ).each(function(){ |
2854 | event.result = ret; |
- | |
2855 | if ( ret === false ) { |
- | |
2856 | event.preventDefault(); |
3081 | this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; |
2857 | event.stopPropagation(); |
- | |
2858 | }
|
- | |
2859 | }
|
3082 | }); |
2860 | 3083 | ||
2861 | if ( event.isImmediatePropagationStopped() ) { |
3084 | if ( !values.length ) |
- | 3085 | this.selectedIndex = -1; |
|
- | 3086 | ||
2862 | break; |
3087 | } else |
- | 3088 | this.value = val; |
|
2863 | }
|
3089 | }); |
- | 3090 | }
|
|
- | 3091 | }); |
|
- | 3092 | ||
- | 3093 | jQuery.each({ |
|
- | 3094 | removeAttr: function( name ) { |
|
- | 3095 | jQuery.attr( this, name, "" ); |
|
- | 3096 | if (this.nodeType == 1) |
|
- | 3097 | this.removeAttribute( name ); |
|
- | 3098 | }, |
|
2864 | 3099 | ||
- | 3100 | toggleClass: function( classNames, state ) { |
|
- | 3101 | var type = typeof classNames; |
|
- | 3102 | if ( type === "string" ) { |
|
- | 3103 | // toggle individual class names
|
|
- | 3104 | var isBool = typeof state === "boolean", className, i = 0, |
|
- | 3105 | classNames = classNames.split( /\s+/ ); |
|
- | 3106 | while ( (className = classNames[ i++ ]) ) { |
|
- | 3107 | // check each className given, space seperated list
|
|
- | 3108 | state = isBool ? state : !jQuery(this).hasClass( className ); |
|
- | 3109 | jQuery(this)[ state ? "addClass" : "removeClass" ]( className ); |
|
2865 | }
|
3110 | }
|
- | 3111 | } else if ( type === "undefined" || type === "boolean" ) { |
|
- | 3112 | if ( this.className ) { |
|
- | 3113 | // store className if set
|
|
- | 3114 | jQuery.data( this, "__className__", this.className ); |
|
- | 3115 | }
|
|
- | 3116 | // toggle whole className
|
|
- | 3117 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
|
2866 | }
|
3118 | }
|
- | 3119 | }
|
|
- | 3120 | }, function(name, fn){ |
|
- | 3121 | jQuery.fn[ name ] = function(){ |
|
- | 3122 | return this.each( fn, arguments ); |
|
2867 | }, |
3123 | }; |
- | 3124 | }); |
|
2868 | 3125 | ||
- | 3126 | jQuery.extend({ |
|
- | 3127 | attr: function( elem, name, value ) { |
|
- | 3128 | // don't set attributes on text and comment nodes
|
|
2869 | 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(" "), |
3129 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
- | 3130 | return undefined; |
|
2870 | 3131 | ||
2871 | fix: function( event ) { |
- | |
2872 | if ( event[ expando ] ) { |
3132 | if ( name in jQuery.fn && name !== "attr" ) { |
2873 | return event; |
3133 | return jQuery(elem)[name](value); |
2874 | }
|
3134 | }
|
- | 3135 | ||
- | 3136 | var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
|
- | 3137 | // Whether we are setting (or getting)
|
|
- | 3138 | set = value !== undefined; |
|
2875 | 3139 | ||
2876 | // store a copy of the original event object
|
- | |
2877 | // and "clone" to set read-only properties
|
- | |
2878 | var originalEvent = event; |
3140 | // Try to normalize/fix the name
|
2879 | event = jQuery.Event( originalEvent ); |
3141 | name = notxml && jQuery.props[ name ] || name; |
2880 | 3142 | ||
2881 | for ( var i = this.props.length, prop; i; ) { |
3143 | // Only do all the following if this is a node (faster for style)
|
2882 | prop = this.props[ --i ]; |
3144 | if ( elem.nodeType === 1 ) { |
2883 | event[ prop ] = originalEvent[ prop ]; |
- | |
2884 | }
|
- | |
2885 | 3145 | ||
2886 | // Fix target property, if necessary
|
3146 | // These attributes require special treatment
|
2887 | if ( !event.target ) { |
3147 | var special = /href|src|style/.test( name ); |
2888 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
- | |
2889 | }
|
- | |
2890 | 3148 | ||
- | 3149 | // Safari mis-reports the default selected property of a hidden option
|
|
2891 | // check if target is a textnode (safari)
|
3150 | // Accessing the parent's selectedIndex property fixes it
|
2892 | if ( event.target.nodeType === 3 ) { |
3151 | if ( name == "selected" && elem.parentNode ) |
2893 | event.target = event.target.parentNode; |
3152 | elem.parentNode.selectedIndex; |
2894 | }
|
- | |
2895 | 3153 | ||
2896 | // Add relatedTarget, if necessary
|
3154 | // If applicable, access the attribute via the DOM 0 way
|
2897 | if ( !event.relatedTarget && event.fromElement ) { |
3155 | if ( name in elem && notxml && !special ) { |
- | 3156 | if ( set ){ |
|
2898 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
3157 | // We can't allow the type property to be changed (since it causes problems in IE)
|
2899 | }
|
- | |
- | 3158 | if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) |
|
- | 3159 | throw "type property can't be changed"; |
|
2900 | 3160 | ||
- | 3161 | elem[ name ] = value; |
|
- | 3162 | }
|
|
- | 3163 | ||
2901 | // Calculate pageX/Y if missing and clientX/Y available
|
3164 | // browsers index elements by id/name on forms, give priority to attributes.
|
2902 | if ( event.pageX == null && event.clientX != null ) { |
3165 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
2903 | var doc = document.documentElement, body = document.body; |
3166 | return elem.getAttributeNode( name ).nodeValue; |
- | 3167 | ||
2904 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
3168 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
2905 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
3169 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
- | 3170 | if ( name == "tabIndex" ) { |
|
- | 3171 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
|
- | 3172 | return attributeNode && attributeNode.specified |
|
- | 3173 | ? attributeNode.value |
|
- | 3174 | : /(button|input|object|select|textarea)/i.test(elem.nodeName) |
|
- | 3175 | ? 0 |
|
- | 3176 | : /^(a|area)$/i.test(elem.nodeName) && elem.href |
|
- | 3177 | ? 0 |
|
- | 3178 | : undefined; |
|
2906 | }
|
3179 | }
|
2907 | 3180 | ||
2908 | // Add which for key events
|
3181 | return elem[ name ]; |
2909 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
- | |
2910 | event.which = event.charCode || event.keyCode; |
- | |
2911 | }
|
3182 | }
|
2912 | 3183 | ||
2913 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
3184 | if ( !jQuery.support.style && notxml && name == "style" ) { |
2914 | if ( !event.metaKey && event.ctrlKey ) { |
3185 | if ( set ) |
2915 | event.metaKey = event.ctrlKey; |
3186 | elem.style.cssText = "" + value; |
2916 | }
|
- | |
2917 | 3187 | ||
2918 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
- | |
2919 | // Note: button is not normalized, so don't use it
|
3188 | return elem.style.cssText; |
2920 | if ( !event.which && event.button !== undefined ) { |
- | |
2921 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
- | |
2922 | }
|
3189 | }
|
2923 | 3190 | ||
2924 | return event; |
3191 | if ( set ) |
2925 | }, |
- | |
- | 3192 | // convert the value to a string (all browsers do this but IE) see #1070
|
|
- | 3193 | elem.setAttribute( name, "" + value ); |
|
2926 | 3194 | ||
- | 3195 | var attr = !jQuery.support.hrefNormalized && notxml && special |
|
2927 | proxy: function( fn, proxy, thisObject ) { |
3196 | // Some attributes require a special call on IE
|
2928 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
3197 | ? elem.getAttribute( name, 2 ) |
2929 | thisObject = proxy; |
3198 | : elem.getAttribute( name ); |
- | 3199 | ||
- | 3200 | // Non-existent attributes return null, we normalize to undefined
|
|
2930 | proxy = undefined; |
3201 | return attr === null ? undefined : attr; |
2931 | }
|
3202 | }
|
2932 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
- | |
2933 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
- | |
2934 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
- | |
2935 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
- | |
2936 | // So proxy can be declared as an argument
|
- | |
2937 | return proxy; |
- | |
2938 | }, |
- | |
2939 | 3203 | ||
- | 3204 | // elem is actually elem.style ... set the style
|
|
- | 3205 | // Using attr for specific style information is now deprecated. Use style insead.
|
|
- | 3206 | return jQuery.style(elem, name, value); |
|
- | 3207 | }
|
|
- | 3208 | }); |
|
- | 3209 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
|
- | 3210 | rleadingWhitespace = /^\s+/, |
|
- | 3211 | rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
|
- | 3212 | rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
|
- | 3213 | rtagName = /<([\w:]+)/, |
|
- | 3214 | rtbody = /<tbody/i, |
|
- | 3215 | rhtml = /</, |
|
- | 3216 | fcloseTag = function(all, front, tag){ |
|
- | 3217 | return rselfClosing.test(tag) ? |
|
2940 | special: { |
3218 | all :
|
- | 3219 | front + "></" + tag + ">"; |
|
- | 3220 | }, |
|
2941 | ready: { |
3221 | wrapMap = { |
- | 3222 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
|
2942 | // Make sure the ready event is setup
|
3223 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
2943 | setup: bindReady, |
3224 | thead: [ 1, "<table>", "</table>" ], |
- | 3225 | tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
|
- | 3226 | td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
|
- | 3227 | col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
|
2944 | teardown: function() {} |
3228 | _default: [ 0, "", "" ] |
2945 | }, |
3229 | }; |
2946 | 3230 | ||
2947 | live: { |
3231 | wrapMap.optgroup = wrapMap.option; |
2948 | add: function( proxy, data, namespaces ) { |
3232 | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
- | 3233 | wrapMap.th = wrapMap.td; |
|
- | 3234 | ||
2949 | jQuery.extend( proxy, data || {} ); |
3235 | // IE can't serialize <link> and <script> tags normally
|
2950 | proxy.guid += data.selector + data.live; |
3236 | if ( !jQuery.support.htmlSerialize ) { |
2951 | jQuery.event.add( this, data.live, liveHandler ); |
3237 | wrapMap._default = [ 1, "div<div>", "</div>" ]; |
2952 | }, |
3238 | }
|
2953 | 3239 | ||
- | 3240 | jQuery.fn.extend({ |
|
2954 | remove: function( namespaces ) { |
3241 | text: function( text ) { |
2955 | if ( namespaces.length ) { |
3242 | if ( typeof text !== "object" && text !== undefined ) |
2956 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
3243 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
2957 | 3244 | ||
2958 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
- | |
2959 | if ( name.test(this.type) ) { |
- | |
2960 | remove++;
|
3245 | var ret = ""; |
2961 | }
|
- | |
2962 | }); |
- | |
2963 | 3246 | ||
- | 3247 | jQuery.each( text || this, function(){ |
|
- | 3248 | jQuery.each( this.childNodes, function(){ |
|
2964 | if ( remove < 1 ) { |
3249 | if ( this.nodeType !== 8 ) { |
2965 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
3250 | ret += this.nodeType !== 1 ? |
2966 | }
|
3251 | this.nodeValue : |
- | 3252 | jQuery.fn.text( [ this ] ); |
|
2967 | }
|
3253 | }
|
2968 | }
|
3254 | }); |
2969 | }
|
3255 | }); |
2970 | }
|
- | |
2971 | }; |
- | |
2972 | 3256 | ||
2973 | jQuery.Event = function( src ){ |
- | |
2974 | // Allow instantiation without the 'new' keyword
|
- | |
2975 | if ( !this.preventDefault ) { |
- | |
2976 | return new jQuery.Event( src ); |
3257 | return ret; |
2977 | }
|
3258 | }, |
2978 | 3259 | ||
2979 | // Event object
|
3260 | wrapAll: function( html ) { |
2980 | if ( src && src.type ) { |
3261 | if ( jQuery.isFunction( html ) ) { |
2981 | this.originalEvent = src; |
3262 | return this.each(function() { |
2982 | this.type = src.type; |
3263 | jQuery(this).wrapAll( html.apply(this, arguments) ); |
2983 | // Event type
|
- | |
2984 | } else { |
3264 | }); |
2985 | this.type = src; |
- | |
2986 | }
|
3265 | }
|
2987 | 3266 | ||
2988 | // timeStamp is buggy for some events on Firefox(#3843)
|
3267 | if ( this[0] ) { |
2989 | // So we won't rely on the native value
|
3268 | // The elements to wrap the target around
|
2990 | this.timeStamp = now(); |
3269 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); |
2991 | 3270 | ||
2992 | // Mark it as fixed
|
3271 | if ( this[0].parentNode ) { |
2993 | this[ expando ] = true; |
3272 | wrap.insertBefore( this[0] ); |
2994 | }; |
3273 | }
|
2995 | 3274 | ||
2996 | function returnFalse() { |
3275 | wrap.map(function(){ |
2997 | return false; |
- | |
2998 | }
|
- | |
2999 | function returnTrue() { |
- | |
3000 | return true; |
3276 | var elem = this; |
3001 | }
|
- | |
3002 | 3277 | ||
3003 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
3278 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
3004 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
- | |
3005 | jQuery.Event.prototype = { |
- | |
3006 | preventDefault: function() { |
3279 | elem = elem.firstChild; |
3007 | this.isDefaultPrevented = returnTrue; |
3280 | }
|
3008 | 3281 | ||
3009 | var e = this.originalEvent; |
- | |
3010 | if ( !e ) { |
- | |
3011 | return; |
3282 | return elem; |
3012 | }
|
- | |
3013 | // if preventDefault exists run it on the original event
|
- | |
3014 | if ( e.preventDefault ) { |
- | |
3015 | e.preventDefault(); |
3283 | }).append(this); |
3016 | }
|
3284 | }
|
3017 | // otherwise set the returnValue property of the original event to false (IE)
|
- | |
3018 | e.returnValue = false; |
- | |
3019 | }, |
- | |
3020 | stopPropagation: function() { |
- | |
3021 | this.isPropagationStopped = returnTrue; |
- | |
3022 | 3285 | ||
3023 | var e = this.originalEvent; |
- | |
3024 | if ( !e ) { |
- | |
3025 | return; |
3286 | return this; |
3026 | }
|
- | |
3027 | // if stopPropagation exists run it on the original event
|
- | |
3028 | if ( e.stopPropagation ) { |
- | |
3029 | e.stopPropagation(); |
- | |
3030 | }
|
- | |
3031 | // otherwise set the cancelBubble property of the original event to true (IE)
|
- | |
3032 | e.cancelBubble = true; |
- | |
3033 | }, |
- | |
3034 | stopImmediatePropagation: function(){ |
- | |
3035 | this.isImmediatePropagationStopped = returnTrue; |
- | |
3036 | this.stopPropagation(); |
- | |
3037 | }, |
3287 | }, |
3038 | isDefaultPrevented: returnFalse, |
- | |
3039 | isPropagationStopped: returnFalse, |
- | |
3040 | isImmediatePropagationStopped: returnFalse
|
- | |
3041 | }; |
- | |
3042 | // Checks if an event happened on an element within another element
|
- | |
3043 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
- | |
3044 | var withinElement = function( event ) { |
- | |
3045 | // Check if mouse(over|out) are still within the same parent element
|
- | |
3046 | var parent = event.relatedTarget; |
- | |
3047 | // Traverse up the tree
|
- | |
3048 | while ( parent && parent != this ) { |
- | |
3049 | // Firefox sometimes assigns relatedTarget a XUL element
|
- | |
3050 | // which we cannot access the parentNode property of
|
- | |
3051 | try { parent = parent.parentNode; } |
- | |
3052 | // assuming we've left the element since we most likely mousedover a xul element
|
- | |
3053 | catch(e) { break; } |
- | |
3054 | }
|
- | |
3055 | - | ||
3056 | if ( parent != this ) { |
- | |
3057 | // set the correct event type
|
- | |
3058 | event.type = event.data; |
- | |
3059 | // handle event if we actually just moused on to a non sub-element
|
- | |
3060 | jQuery.event.handle.apply( this, arguments ); |
- | |
3061 | }
|
- | |
3062 | }; |
- | |
3063 | - | ||
3064 | jQuery.each({ |
- | |
3065 | mouseover: 'mouseenter', |
- | |
3066 | mouseout: 'mouseleave' |
- | |
3067 | }, function( orig, fix ) { |
- | |
3068 | jQuery.event.special[ fix ] = { |
- | |
3069 | setup: function(){ |
- | |
3070 | jQuery.event.add( this, orig, withinElement, fix ); |
- | |
3071 | }, |
- | |
3072 | teardown: function(){ |
- | |
3073 | jQuery.event.remove( this, orig, withinElement ); |
- | |
3074 | }
|
- | |
3075 | }; |
- | |
3076 | }); |
- | |
3077 | 3288 | ||
3078 | jQuery.fn.extend({ |
- | |
3079 | bind: function( type, data, fn, thisObject ) { |
- | |
3080 | if ( jQuery.isFunction( data ) ) { |
3289 | wrapInner: function( html ) { |
3081 | if ( fn !== undefined ) { |
3290 | return this.each(function(){ |
3082 | thisObject = fn; |
- | |
3083 | }
|
- | |
3084 | fn = data; |
- | |
3085 | data = undefined; |
- | |
3086 | }
|
- | |
3087 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
- | |
3088 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
- | |
3089 | jQuery.event.add( this, type, fn, data ); |
3291 | jQuery( this ).contents().wrapAll( html ); |
3090 | }); |
3292 | }); |
3091 | }, |
3293 | }, |
3092 | 3294 | ||
3093 | one: function( type, data, fn, thisObject ) { |
- | |
3094 | if ( jQuery.isFunction( data ) ) { |
3295 | wrap: function( html ) { |
3095 | if ( fn !== undefined ) { |
- | |
3096 | thisObject = fn; |
- | |
3097 | }
|
- | |
3098 | fn = data; |
- | |
3099 | data = undefined; |
- | |
3100 | }
|
- | |
3101 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
- | |
3102 | var one = jQuery.event.proxy( fn, function( event ) { |
- | |
3103 | jQuery( this ).unbind( event, one ); |
- | |
3104 | return fn.apply( this, arguments ); |
- | |
3105 | }); |
- | |
3106 | return this.each(function() { |
3296 | return this.each(function(){ |
3107 | jQuery.event.add( this, type, one, data ); |
3297 | jQuery( this ).wrapAll( html ); |
3108 | }); |
3298 | }); |
3109 | }, |
3299 | }, |
3110 | 3300 | ||
3111 | unbind: function( type, fn ) { |
3301 | unwrap: function() { |
3112 | return this.each(function() { |
3302 | return this.parent().each(function(){ |
3113 | jQuery.event.remove( this, type, fn ); |
3303 | if ( !jQuery.nodeName( this, "body" ) ) { |
- | 3304 | jQuery( this ).replaceWith( this.childNodes ); |
|
- | 3305 | }
|
|
- | 3306 | }).end(); |
|
- | 3307 | }, |
|
- | 3308 | ||
- | 3309 | append: function() { |
|
- | 3310 | return this.domManip(arguments, true, function(elem){ |
|
- | 3311 | if ( this.nodeType === 1 ) { |
|
- | 3312 | this.appendChild( elem ); |
|
- | 3313 | }
|
|
3114 | }); |
3314 | }); |
3115 | }, |
3315 | }, |
3116 | 3316 | ||
3117 | trigger: function( type, data ) { |
3317 | prepend: function() { |
- | 3318 | return this.domManip(arguments, true, function(elem){ |
|
3118 | return this.each(function() { |
3319 | if ( this.nodeType === 1 ) { |
3119 | jQuery.event.trigger( type, data, this ); |
3320 | this.insertBefore( elem, this.firstChild ); |
- | 3321 | }
|
|
3120 | }); |
3322 | }); |
3121 | }, |
3323 | }, |
3122 | 3324 | ||
3123 | triggerHandler: function( type, data ) { |
3325 | before: function() { |
3124 | if ( this[0] ) { |
3326 | if ( this[0] && this[0].parentNode ) { |
- | 3327 | return this.domManip(arguments, false, function(elem){ |
|
3125 | var event = jQuery.Event( type ); |
3328 | this.parentNode.insertBefore( elem, this ); |
- | 3329 | }); |
|
3126 | event.preventDefault(); |
3330 | } else if ( arguments.length ) { |
3127 | event.stopPropagation(); |
3331 | var set = jQuery(arguments[0]); |
3128 | jQuery.event.trigger( event, data, this[0] ); |
3332 | set.push.apply( set, this.toArray() ); |
3129 | return event.result; |
3333 | return this.pushStack( set, "before", arguments ); |
3130 | }
|
3334 | }
|
3131 | }, |
3335 | }, |
3132 | 3336 | ||
3133 | toggle: function( fn ) { |
3337 | after: function() { |
3134 | // Save reference to arguments for access in closure
|
3338 | if ( this[0] && this[0].parentNode ) { |
3135 | var args = arguments, i = 1; |
3339 | return this.domManip(arguments, false, function(elem){ |
3136 | - | ||
3137 | // link all the functions, so any of them can unbind this click handler
|
3340 | this.parentNode.insertBefore( elem, this.nextSibling ); |
- | 3341 | }); |
|
3138 | while( i < args.length ) { |
3342 | } else if ( arguments.length ) { |
3139 | jQuery.event.proxy( fn, args[ i++ ] ); |
3343 | var set = this.pushStack( this, "after", arguments ); |
- | 3344 | set.push.apply( set, jQuery(arguments[0]).toArray() ); |
|
- | 3345 | return set; |
|
3140 | }
|
3346 | }
|
- | 3347 | }, |
|
3141 | 3348 | ||
- | 3349 | clone: function( events ) { |
|
- | 3350 | // Do the clone
|
|
- | 3351 | var ret = this.map(function(){ |
|
- | 3352 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
|
3142 | return this.click( jQuery.event.proxy( fn, function( event ) { |
3353 | // IE copies events bound via attachEvent when
|
- | 3354 | // using cloneNode. Calling detachEvent on the
|
|
- | 3355 | // clone will also remove the events from the orignal
|
|
- | 3356 | // In order to get around this, we use innerHTML.
|
|
- | 3357 | // Unfortunately, this means some modifications to
|
|
- | 3358 | // attributes in IE that are actually only stored
|
|
- | 3359 | // as properties will not be copied (such as the
|
|
3143 | // Figure out which function to execute
|
3360 | // the name attribute on an input).
|
- | 3361 | var html = this.outerHTML, ownerDocument = this.ownerDocument; |
|
- | 3362 | if ( !html ) { |
|
- | 3363 | var div = ownerDocument.createElement("div"); |
|
3144 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
3364 | div.appendChild( this.cloneNode(true) ); |
- | 3365 | html = div.innerHTML; |
|
- | 3366 | }
|
|
3145 | 3367 | ||
3146 | // Make sure that clicks stop
|
3368 | return jQuery.clean([html.replace(rinlinejQuery, "") |
- | 3369 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
|
- | 3370 | } else { |
|
3147 | event.preventDefault(); |
3371 | return this.cloneNode(true); |
- | 3372 | }
|
|
- | 3373 | }); |
|
3148 | 3374 | ||
- | 3375 | // Copy the events from the original to the clone
|
|
3149 | // and execute the function
|
3376 | if ( events === true ) { |
3150 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
3377 | var orig = this.find("*").andSelf(), i = 0; |
3151 | })); |
- | |
3152 | }, |
- | |
3153 | 3378 | ||
3154 | hover: function( fnOver, fnOut ) { |
3379 | ret.find("*").andSelf().each(function(){ |
3155 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
3380 | if ( this.nodeName !== orig[i].nodeName ) { return; } |
3156 | }, |
- | |
3157 | 3381 | ||
3158 | ready: function( fn ) { |
- | |
3159 | // Attach the listeners
|
3382 | var events = jQuery.data( orig[i], "events" ); |
3160 | bindReady(); |
- | |
3161 | 3383 | ||
3162 | // If the DOM is already ready
|
3384 | for ( var type in events ) { |
3163 | if ( jQuery.isReady ) { |
3385 | for ( var handler in events[ type ] ) { |
3164 | // Execute the function immediately
|
3386 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
3165 | fn.call( document, jQuery ); |
3387 | }
|
- | 3388 | }
|
|
3166 | 3389 | ||
3167 | // Otherwise, remember the function for later
|
- | |
3168 | } else { |
3390 | i++;
|
3169 | // Add the function to the wait list
|
- | |
3170 | jQuery.readyList.push( fn ); |
3391 | }); |
3171 | }
|
3392 | }
|
3172 | 3393 | ||
- | 3394 | // Return the cloned set
|
|
3173 | return this; |
3395 | return ret; |
3174 | }, |
3396 | }, |
3175 | 3397 | ||
3176 | live: function( type, data, fn, thisObject ) { |
3398 | html: function( value ) { |
3177 | if ( jQuery.isFunction( data ) ) { |
3399 | if ( value === undefined ) { |
- | 3400 | return this[0] ? |
|
- | 3401 | this[0].innerHTML.replace(rinlinejQuery, "") : |
|
- | 3402 | null; |
|
- | 3403 | ||
- | 3404 | // See if we can take a shortcut and just use innerHTML
|
|
- | 3405 | } else if ( typeof value === "string" && !/<script/i.test( value ) && |
|
- | 3406 | (!jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
|
- | 3407 | !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
|
- | 3408 | ||
- | 3409 | try { |
|
- | 3410 | for ( var i = 0, l = this.length; i < l; i++ ) { |
|
- | 3411 | // Remove element nodes and prevent memory leaks
|
|
3178 | if ( fn !== undefined ) { |
3412 | if ( this[i].nodeType === 1 ) { |
- | 3413 | cleanData( this[i].getElementsByTagName("*") ); |
|
3179 | thisObject = fn; |
3414 | this[i].innerHTML = value; |
- | 3415 | }
|
|
- | 3416 | }
|
|
- | 3417 | ||
- | 3418 | // If using innerHTML throws an exception, use the fallback method
|
|
- | 3419 | } catch(e) { |
|
- | 3420 | this.empty().append( value ); |
|
3180 | }
|
3421 | }
|
- | 3422 | ||
3181 | fn = data; |
3423 | } else { |
3182 | data = undefined; |
3424 | this.empty().append( value ); |
3183 | }
|
3425 | }
|
3184 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
- | |
3185 | data: data, selector: this.selector, live: type |
- | |
3186 | }, fn, thisObject ); |
- | |
3187 | return this; |
- | |
3188 | }, |
- | |
3189 | 3426 | ||
3190 | die: function( type, fn ) { |
- | |
3191 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
- | |
3192 | return this; |
3427 | return this; |
3193 | }
|
3428 | }, |
3194 | }); |
- | |
3195 | - | ||
3196 | function liveHandler( event ) { |
- | |
3197 | var stop = true, elems = [], args = arguments; |
- | |
3198 | 3429 | ||
3199 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
3430 | replaceWith: function( value ) { |
3200 | if ( fn.live === event.type ) { |
3431 | if ( this[0] && this[0].parentNode ) { |
3201 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
3432 | return this.after( value ).remove(); |
3202 | if ( elem ) { |
3433 | } else { |
3203 | elems.push({ elem: elem, fn: fn }); |
3434 | return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
3204 | }
|
- | |
3205 | }
|
3435 | }
|
3206 | }); |
3436 | }, |
3207 | 3437 | ||
3208 | elems.sort(function( a, b ) { |
3438 | detach: function( selector ) { |
3209 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
3439 | return this.remove( selector, true ); |
3210 | }); |
3440 | }, |
3211 | 3441 | ||
- | 3442 | domManip: function( args, table, callback ) { |
|
- | 3443 | var results, first, value = args[0], scripts = []; |
|
- | 3444 | ||
3212 | jQuery.each(elems, function() { |
3445 | if ( jQuery.isFunction(value) ) { |
3213 | event.currentTarget = this.elem; |
3446 | return this.each(function() { |
3214 | event.data = this.fn.data; |
3447 | args[0] = value.call(this); |
3215 | if ( this.fn.apply( this.elem, args ) === false ) { |
3448 | return jQuery(this).domManip( args, table, callback ); |
3216 | return (stop = false); |
3449 | }); |
3217 | }
|
3450 | }
|
3218 | }); |
- | |
3219 | 3451 | ||
- | 3452 | if ( this[0] ) { |
|
- | 3453 | // If we're in a fragment, just use that instead of building a new one
|
|
- | 3454 | if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) { |
|
- | 3455 | results = { fragment: args[0].parentNode }; |
|
3220 | return stop; |
3456 | } else { |
- | 3457 | results = buildFragment( args, this, scripts ); |
|
3221 | }
|
3458 | }
|
3222 | 3459 | ||
3223 | function liveConvert( type, selector ) { |
3460 | first = results.fragment.firstChild; |
3224 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
- | |
3225 | }
|
- | |
3226 | 3461 | ||
3227 | jQuery.extend({ |
- | |
3228 | isReady: false, |
- | |
3229 | readyList: [], |
- | |
3230 | // Handle when the DOM is ready
|
- | |
3231 | ready: function() { |
- | |
3232 | // Make sure that the DOM is not already loaded
|
- | |
3233 | if ( !jQuery.isReady ) { |
3462 | if ( first ) { |
3234 | // Remember that the DOM is ready
|
3463 | table = table && jQuery.nodeName( first, "tr" ); |
3235 | jQuery.isReady = true; |
- | |
3236 | 3464 | ||
3237 | // If there are functions bound, to execute
|
3465 | for ( var i = 0, l = this.length; i < l; i++ ) { |
3238 | if ( jQuery.readyList ) { |
3466 | callback.call( |
- | 3467 | table ?
|
|
3239 | // Execute all of them
|
3468 | root(this[i], first) : |
3240 | var fn, i = 0; |
3469 | this[i], |
3241 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
3470 | results.cacheable || this.length > 1 || i > 0 ? |
3242 | fn.call( document, jQuery ); |
3471 | results.fragment.cloneNode(true) : |
- | 3472 | results.fragment
|
|
- | 3473 | ); |
|
3243 | }
|
3474 | }
|
- | 3475 | }
|
|
3244 | 3476 | ||
3245 | // Reset the list of functions
|
3477 | if ( scripts ) { |
3246 | jQuery.readyList = null; |
3478 | jQuery.each( scripts, evalScript ); |
3247 | }
|
3479 | }
|
- | 3480 | }
|
|
3248 | 3481 | ||
- | 3482 | return this; |
|
- | 3483 | ||
- | 3484 | function root( elem, cur ) { |
|
3249 | // Trigger any bound ready events
|
3485 | return jQuery.nodeName(elem, "table") ? |
3250 | jQuery( document ).triggerHandler( "ready" ); |
3486 | (elem.getElementsByTagName("tbody")[0] || |
- | 3487 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
|
- | 3488 | elem;
|
|
3251 | }
|
3489 | }
|
3252 | }
|
3490 | }
|
3253 | }); |
3491 | }); |
3254 | 3492 | ||
- | 3493 | function buildFragment(args, nodes, scripts){ |
|
3255 | var readyBound = false; |
3494 | var fragment, cacheable, cached, cacheresults, doc; |
3256 | 3495 | ||
- | 3496 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
|
- | 3497 | cacheable = true; |
|
- | 3498 | cacheresults = jQuery.fragments[ args[0] ]; |
|
3257 | function bindReady() { |
3499 | if ( cacheresults ) { |
3258 | if ( readyBound ) return; |
3500 | if ( cacheresults !== 1 ) { |
- | 3501 | fragment = cacheresults; |
|
- | 3502 | }
|
|
3259 | readyBound = true; |
3503 | cached = true; |
- | 3504 | }
|
|
- | 3505 | }
|
|
3260 | 3506 | ||
3261 | // Catch cases where $(document).ready() is called after the
|
3507 | if ( !fragment ) { |
3262 | // browser event has already occurred.
|
3508 | doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
3263 | if ( document.readyState === "complete" ) { |
3509 | fragment = doc.createDocumentFragment(); |
3264 | return jQuery.ready(); |
3510 | jQuery.clean( args, doc, fragment, scripts ); |
3265 | }
|
3511 | }
|
3266 | 3512 | ||
3267 | // Mozilla, Opera and webkit nightlies currently support this event
|
- | |
3268 | if ( document.addEventListener ) { |
3513 | if ( cacheable ) { |
3269 | // Use the handy event callback
|
- | |
3270 | document.addEventListener( "DOMContentLoaded", function() { |
3514 | jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
3271 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
- | |
3272 | jQuery.ready(); |
- | |
3273 | }, false ); |
3515 | }
|
3274 | 3516 | ||
3275 | // If IE event model is used
|
- | |
3276 | } else if ( document.attachEvent ) { |
- | |
3277 | // ensure firing before onload,
|
- | |
3278 | // maybe late but safe also for iframes
|
- | |
3279 | document.attachEvent("onreadystatechange", function() { |
3517 | return { fragment: fragment, cacheable: cacheable }; |
3280 | if ( document.readyState === "complete" ) { |
- | |
3281 | document.detachEvent( "onreadystatechange", arguments.callee ); |
- | |
3282 | jQuery.ready(); |
- | |
3283 | }
|
3518 | }
|
3284 | }); |
- | |
3285 | 3519 | ||
- | 3520 | jQuery.fragments = {}; |
|
- | 3521 | ||
- | 3522 | jQuery.each({ |
|
- | 3523 | appendTo: "append", |
|
- | 3524 | prependTo: "prepend", |
|
- | 3525 | insertBefore: "before", |
|
- | 3526 | insertAfter: "after", |
|
- | 3527 | replaceAll: "replaceWith" |
|
- | 3528 | }, function(name, original){ |
|
- | 3529 | jQuery.fn[ name ] = function( selector ) { |
|
- | 3530 | var ret = [], insert = jQuery( selector ); |
|
- | 3531 | ||
- | 3532 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
|
- | 3533 | var elems = (i > 0 ? this.clone(true) : this).get(); |
|
- | 3534 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
|
3286 | // If IE and not an iframe
|
3535 | ret = ret.concat( elems ); |
- | 3536 | }
|
|
- | 3537 | return this.pushStack( ret, name, insert.selector ); |
|
- | 3538 | }; |
|
- | 3539 | }); |
|
- | 3540 | ||
- | 3541 | jQuery.each({ |
|
3287 | // continually check to see if the document is ready
|
3542 | // keepData is for internal use only--do not document
|
- | 3543 | remove: function( selector, keepData ) { |
|
3288 | if ( document.documentElement.doScroll && window === window.top ) (function() { |
3544 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
3289 | if ( jQuery.isReady ) { |
3545 | if ( !keepData && this.nodeType === 1 ) { |
- | 3546 | cleanData( this.getElementsByTagName("*") ); |
|
3290 | return; |
3547 | cleanData( [ this ] ); |
3291 | }
|
3548 | }
|
3292 | 3549 | ||
3293 | try { |
- | |
3294 | // If IE is used, use the trick by Diego Perini
|
- | |
3295 | // http://javascript.nwbox.com/IEContentLoaded/
|
- | |
3296 | document.documentElement.doScroll("left"); |
- | |
3297 | } catch( error ) { |
3550 | if ( this.parentNode ) { |
3298 | setTimeout( arguments.callee, 0 ); |
3551 | this.parentNode.removeChild( this ); |
3299 | return; |
- | |
3300 | }
|
3552 | }
|
- | 3553 | }
|
|
- | 3554 | }, |
|
3301 | 3555 | ||
3302 | // and execute any waiting functions
|
- | |
3303 | jQuery.ready(); |
3556 | empty: function() { |
3304 | })(); |
- | |
3305 | }
|
- | |
3306 | - | ||
3307 | // A fallback to window.onload, that will always work
|
- | |
3308 | jQuery.event.add( window, "load", jQuery.ready ); |
3557 | // Remove element nodes and prevent memory leaks
|
3309 | }
|
- | |
3310 | - | ||
3311 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
- | |
3312 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
- | |
3313 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
- | |
3314 | - | ||
3315 | // Handle event binding
|
- | |
3316 | jQuery.fn[ name ] = function( fn ) { |
3558 | if ( this.nodeType === 1 ) { |
3317 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
3559 | cleanData( this.getElementsByTagName("*") ); |
3318 | }; |
3560 | }
|
3319 | }); |
- | |
3320 | 3561 | ||
3321 | // Prevent memory leaks in IE
|
3562 | // Remove any remaining nodes
|
3322 | // And prevent errors on refresh with events like mouseover in other browsers
|
- | |
3323 | // Window isn't included so as not to unbind existing unload events
|
- | |
3324 | // More info:
|
- | |
3325 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
- | |
3326 | // - https://bugzilla.mozilla.org/show_bug.cgi?id=252542
|
- | |
3327 | jQuery( window ).bind( 'unload', function() { |
- | |
3328 | for ( var id in jQuery.cache ) { |
3563 | while ( this.firstChild ) { |
3329 | // Skip the window
|
- | |
3330 | if ( id != 1 && jQuery.cache[ id ].handle ) { |
- | |
3331 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
3564 | this.removeChild( this.firstChild ); |
3332 | }
|
3565 | }
|
3333 | }
|
3566 | }
|
- | 3567 | }, function(name, fn){ |
|
- | 3568 | jQuery.fn[ name ] = function(){ |
|
- | 3569 | return this.each( fn, arguments ); |
|
- | 3570 | }; |
|
3334 | }); |
3571 | }); |
3335 | (function(){ |
- | |
3336 | 3572 | ||
3337 | jQuery.support = {}; |
3573 | jQuery.extend({ |
- | 3574 | clean: function( elems, context, fragment, scripts ) { |
|
- | 3575 | context = context || document; |
|
3338 | 3576 | ||
3339 | var root = document.documentElement, |
- | |
3340 | script = document.createElement("script"), |
3577 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
3341 | div = document.createElement("div"), |
3578 | if ( typeof context.createElement === "undefined" ) { |
3342 | id = "script" + (new Date).getTime(); |
3579 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
- | 3580 | }
|
|
3343 | 3581 | ||
3344 | div.style.display = "none"; |
3582 | var ret = [], div = context.createElement("div"); |
3345 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
- | |
3346 | 3583 | ||
3347 | var all = div.getElementsByTagName("*"), |
3584 | jQuery.each(elems, function(i, elem){ |
3348 | a = div.getElementsByTagName("a")[0]; |
3585 | if ( typeof elem === "number" ) { |
- | 3586 | elem += ''; |
|
- | 3587 | }
|
|
3349 | 3588 | ||
3350 | // Can't get basic test support
|
- | |
3351 | if ( !all || !all.length || !a ) { |
3589 | if ( !elem ) { return; } |
3352 | return; |
- | |
3353 | }
|
- | |
3354 | 3590 | ||
3355 | jQuery.support = { |
3591 | // Convert html string into DOM nodes
|
3356 | // IE strips leading whitespace when .innerHTML is used
|
3592 | if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
3357 | leadingWhitespace: div.firstChild.nodeType == 3, |
3593 | elem = context.createTextNode( elem ); |
3358 | 3594 | ||
3359 | // Make sure that tbody elements aren't automatically inserted
|
3595 | } else if ( typeof elem === "string" ) { |
3360 | // IE will insert them into empty tables
|
3596 | // Fix "XHTML"-style tags in all browsers
|
3361 | tbody: !div.getElementsByTagName("tbody").length, |
3597 | elem = elem.replace(rxhtmlTag, fcloseTag); |
3362 | 3598 | ||
3363 | // Make sure that link elements get serialized correctly by innerHTML
|
3599 | // Trim whitespace, otherwise indexOf won't work as expected
|
3364 | // This requires a wrapper element in IE
|
3600 | var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
3365 | htmlSerialize: !!div.getElementsByTagName("link").length, |
3601 | wrap = wrapMap[ tag ] || wrapMap._default, |
- | 3602 | depth = wrap[0]; |
|
3366 | 3603 | ||
3367 | // Get the style information from getAttribute
|
3604 | // Go to html and back, then peel off extra wrappers
|
3368 | // (IE uses .cssText insted)
|
- | |
3369 | style: /red/.test( a.getAttribute("style") ), |
3605 | div.innerHTML = wrap[1] + elem + wrap[2]; |
3370 | 3606 | ||
3371 | // Make sure that URLs aren't manipulated
|
3607 | // Move to the right depth
|
3372 | // (IE normalizes it by default)
|
3608 | while ( depth-- ) { |
3373 | hrefNormalized: a.getAttribute("href") === "/a", |
3609 | div = div.lastChild; |
- | 3610 | }
|
|
3374 | 3611 | ||
3375 | // Make sure that element opacity exists
|
3612 | // Remove IE's autoinserted <tbody> from table fragments
|
3376 | // (IE uses filter instead)
|
3613 | if ( !jQuery.support.tbody ) { |
3377 | opacity: a.style.opacity === "0.5", |
- | |
3378 | 3614 | ||
- | 3615 | // String was a <table>, *may* have spurious <tbody>
|
|
3379 | // Verify style float existence
|
3616 | var hasBody = rtbody.test(elem), |
3380 | // (IE uses styleFloat instead of cssFloat)
|
3617 | tbody = tag === "table" && !hasBody ? |
3381 | cssFloat: !!a.style.cssFloat, |
3618 | div.firstChild && div.firstChild.childNodes : |
3382 | 3619 | ||
3383 | // Will be defined later
|
3620 | // String was a bare <thead> or <tfoot>
|
3384 | scriptEval: false, |
3621 | wrap[1] == "<table>" && !hasBody ? |
3385 | noCloneEvent: true, |
3622 | div.childNodes : |
3386 | boxModel: null |
3623 | []; |
3387 | }; |
- | |
3388 | 3624 | ||
- | 3625 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
|
- | 3626 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
|
3389 | script.type = "text/javascript"; |
3627 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
3390 | try { |
3628 | }
|
3391 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
- | |
3392 | } catch(e){} |
3629 | }
|
3393 | 3630 | ||
3394 | root.insertBefore( script, root.firstChild ); |
- | |
- | 3631 | }
|
|
3395 | 3632 | ||
3396 | // Make sure that the execution of code works by injecting a script
|
3633 | // IE completely kills leading whitespace when innerHTML is used
|
3397 | // tag with appendChild/createTextNode
|
- | |
3398 | // (IE doesn't support this, fails, and uses .text instead)
|
3634 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
3399 | if ( window[ id ] ) { |
- | |
3400 | jQuery.support.scriptEval = true; |
3635 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
3401 | delete window[ id ]; |
- | |
3402 | }
|
3636 | }
|
3403 | 3637 | ||
3404 | root.removeChild( script ); |
3638 | elem = jQuery.makeArray( div.childNodes ); |
- | 3639 | }
|
|
3405 | 3640 | ||
3406 | if ( div.attachEvent && div.fireEvent ) { |
- | |
3407 | div.attachEvent("onclick", function click(){ |
- | |
3408 | // Cloning a node shouldn't copy over any
|
- | |
3409 | // bound event handlers (IE does this)
|
3641 | if ( elem.nodeType ) { |
3410 | jQuery.support.noCloneEvent = false; |
- | |
3411 | div.detachEvent("onclick", click); |
3642 | ret.push( elem ); |
3412 | }); |
3643 | } else { |
3413 | div.cloneNode(true).fireEvent("onclick"); |
3644 | ret = jQuery.merge( ret, elem ); |
3414 | }
|
3645 | }
|
3415 | 3646 | ||
3416 | // Figure out if the W3C box model works as expected
|
- | |
3417 | // document.body must exist before we can do this
|
- | |
3418 | jQuery(function(){ |
3647 | }); |
3419 | var div = document.createElement("div"); |
- | |
3420 | div.style.width = div.style.paddingLeft = "1px"; |
- | |
3421 | 3648 | ||
- | 3649 | if ( fragment ) { |
|
3422 | document.body.appendChild( div ); |
3650 | for ( var i = 0; ret[i]; i++ ) { |
3423 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3651 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
3424 | document.body.removeChild( div ).style.display = 'none'; |
3652 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
3425 | div = null; |
3653 | } else { |
- | 3654 | if ( ret[i].nodeType === 1 ) { |
|
- | 3655 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
|
- | 3656 | }
|
|
- | 3657 | fragment.appendChild( ret[i] ); |
|
- | 3658 | }
|
|
3426 | }); |
3659 | }
|
- | 3660 | }
|
|
3427 | 3661 | ||
3428 | // release memory in IE
|
3662 | return ret; |
3429 | root = script = div = all = a = null; |
- | |
- | 3663 | }
|
|
3430 | })(); |
3664 | }); |
3431 | 3665 | ||
3432 | jQuery.props = { |
- | |
3433 | "for": "htmlFor", |
- | |
3434 | "class": "className", |
3666 | function cleanData( elems ) { |
3435 | readonly: "readOnly", |
3667 | for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) { |
3436 | maxlength: "maxLength", |
3668 | if ( (id = elem[expando]) ) { |
3437 | cellspacing: "cellSpacing", |
3669 | delete jQuery.cache[ id ]; |
3438 | rowspan: "rowSpan", |
3670 | }
|
3439 | colspan: "colSpan", |
3671 | }
|
3440 | tabindex: "tabIndex" |
- | |
3441 | }; |
3672 | }
|
3442 | // exclude the following css properties to add px
|
3673 | // exclude the following css properties to add px
|
3443 | var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
3674 | var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
3444 | ralpha = /alpha\([^)]*\)/, |
3675 | ralpha = /alpha\([^)]*\)/, |
3445 | ropacity = /opacity=([^)]*)/, |
3676 | ropacity = /opacity=([^)]*)/, |
3446 | rfloat = /float/i, |
3677 | rfloat = /float/i, |
Строка 3456... | Строка 3687... | ||
3456 | fcamelCase = function(all, letter){ |
3687 | fcamelCase = function(all, letter){ |
3457 | return letter.toUpperCase(); |
3688 | return letter.toUpperCase(); |
3458 | }; |
3689 | }; |
3459 | 3690 | ||
3460 | jQuery.fn.css = function( name, value ) { |
3691 | jQuery.fn.css = function( name, value ) { |
3461 | var options = name, isFunction = jQuery.isFunction( value ); |
3692 | return access( this, name, value, true, function( elem, name, value ) { |
3462 | - | ||
3463 | if ( typeof name === "string" ) { |
- | |
3464 | // Are we setting the style?
|
- | |
3465 | if ( value === undefined ) { |
3693 | if (value === undefined) { |
3466 | return this.length ? |
- | |
3467 | jQuery.css( this[0], name ) : |
3694 | return jQuery.css( elem, name ); |
3468 | null; |
- | |
3469 | - | ||
3470 | // Convert name, value params to options hash format
|
- | |
3471 | } else { |
- | |
3472 | options = {}; |
- | |
3473 | options[ name ] = value; |
- | |
3474 | }
|
3695 | }
|
3475 | }
|
- | |
3476 | 3696 | ||
3477 | var isFunction = {}; |
- | |
3478 | - | ||
3479 | // For each value, determine whether it's a Function so we don't
|
- | |
3480 | // need to determine it again for each element
|
- | |
3481 | for ( var prop in options ) { |
- | |
3482 | isFunction[prop] = jQuery.isFunction( options[prop] ); |
- | |
3483 | }
|
- | |
3484 | - | ||
3485 | // For each element...
|
- | |
3486 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | |
3487 | var elem = this[i]; |
- | |
3488 | - | ||
3489 | // Set all the styles
|
- | |
3490 | for ( var prop in options ) { |
- | |
3491 | value = options[prop]; |
- | |
3492 | - | ||
3493 | if ( isFunction[prop] ) { |
- | |
3494 | value = value.call( elem, i ); |
- | |
3495 | }
|
- | |
3496 | - | ||
3497 | if ( typeof value === "number" && !rexclude.test(prop) ) { |
3697 | if ( typeof value === "number" && !rexclude.test(name) ) { |
3498 | value = value + "px"; |
3698 | value += "px"; |
3499 | }
|
- | |
3500 | - | ||
3501 | jQuery.style( elem, prop, value ); |
- | |
3502 | }
|
3699 | }
|
3503 | }
|
- | |
3504 | 3700 | ||
- | 3701 | jQuery.style( elem, name, value ); |
|
3505 | return this; |
3702 | }); |
3506 | }; |
3703 | }; |
3507 | 3704 | ||
3508 | jQuery.extend({ |
3705 | jQuery.extend({ |
3509 | style: function( elem, name, value ) { |
3706 | style: function( elem, name, value ) { |
3510 | // don't set styles on text and comment nodes
|
3707 | // don't set styles on text and comment nodes
|
Строка 3713... | Строка 3910... | ||
3713 | params = jQuery.param( params ); |
3910 | params = jQuery.param( params ); |
3714 | type = "POST"; |
3911 | type = "POST"; |
3715 | }
|
3912 | }
|
3716 | }
|
3913 | }
|
3717 | 3914 | ||
3718 | var self = this; |
- | |
3719 | - | ||
3720 | // Request the remote document
|
3915 | // Request the remote document
|
3721 | jQuery.ajax({ |
3916 | jQuery.ajax({ |
3722 | url: url, |
3917 | url: url, |
3723 | type: type, |
3918 | type: type, |
3724 | dataType: "html", |
3919 | dataType: "html", |
3725 | data: params, |
3920 | data: params, |
- | 3921 | context:this, |
|
3726 | complete: function(res, status){ |
3922 | complete: function(res, status){ |
3727 | // If successful, inject the HTML into all the matched elements
|
3923 | // If successful, inject the HTML into all the matched elements
|
3728 | if ( status === "success" || status === "notmodified" ) { |
3924 | if ( status === "success" || status === "notmodified" ) { |
3729 | // See if a selector was specified
|
3925 | // See if a selector was specified
|
3730 | self.html( selector ? |
3926 | this.html( selector ? |
3731 | // Create a dummy div to hold the results
|
3927 | // Create a dummy div to hold the results
|
3732 | jQuery("<div/>") |
3928 | jQuery("<div />") |
3733 | // inject the contents of the document in, removing the scripts
|
3929 | // inject the contents of the document in, removing the scripts
|
3734 | // to avoid any 'Permission Denied' errors in IE
|
3930 | // to avoid any 'Permission Denied' errors in IE
|
3735 | .append(res.responseText.replace(rscript, "")) |
3931 | .append(res.responseText.replace(rscript, "")) |
3736 | 3932 | ||
3737 | // Locate the specified elements
|
3933 | // Locate the specified elements
|
Строка 3740... | Строка 3936... | ||
3740 | // If not, just inject the full result
|
3936 | // If not, just inject the full result
|
3741 | res.responseText ); |
3937 | res.responseText ); |
3742 | }
|
3938 | }
|
3743 | 3939 | ||
3744 | if ( callback ) { |
3940 | if ( callback ) { |
3745 | self.each( callback, [res.responseText, status, res] ); |
3941 | this.each( callback, [res.responseText, status, res] ); |
3746 | }
|
3942 | }
|
3747 | }
|
3943 | }
|
3748 | }); |
3944 | }); |
3749 | 3945 | ||
3750 | return this; |
3946 | return this; |
Строка 3784... | Строка 3980... | ||
3784 | }); |
3980 | }); |
3785 | 3981 | ||
3786 | jQuery.extend({ |
3982 | jQuery.extend({ |
3787 | 3983 | ||
3788 | get: function( url, data, callback, type ) { |
3984 | get: function( url, data, callback, type ) { |
3789 | // shift arguments if data argument was ommited
|
3985 | // shift arguments if data argument was omited
|
3790 | if ( jQuery.isFunction( data ) ) { |
3986 | if ( jQuery.isFunction( data ) ) { |
- | 3987 | type = type || callback; |
|
3791 | callback = data; |
3988 | callback = data; |
3792 | data = null; |
3989 | data = null; |
3793 | }
|
3990 | }
|
3794 | 3991 | ||
3795 | return jQuery.ajax({ |
3992 | return jQuery.ajax({ |
Строка 3808... | Строка 4005... | ||
3808 | getJSON: function( url, data, callback ) { |
4005 | getJSON: function( url, data, callback ) { |
3809 | return jQuery.get(url, data, callback, "json"); |
4006 | return jQuery.get(url, data, callback, "json"); |
3810 | }, |
4007 | }, |
3811 | 4008 | ||
3812 | post: function( url, data, callback, type ) { |
4009 | post: function( url, data, callback, type ) { |
- | 4010 | // shift arguments if data argument was omited
|
|
3813 | if ( jQuery.isFunction( data ) ) { |
4011 | if ( jQuery.isFunction( data ) ) { |
- | 4012 | type = type || callback; |
|
3814 | callback = data; |
4013 | callback = data; |
3815 | data = {}; |
4014 | data = {}; |
3816 | }
|
4015 | }
|
3817 | 4016 | ||
3818 | return jQuery.ajax({ |
4017 | return jQuery.ajax({ |
Строка 3865... | Строка 4064... | ||
3865 | 4064 | ||
3866 | ajax: function( s ) { |
4065 | ajax: function( s ) { |
3867 | // Extend the settings, but re-extend 's' so that it can be
|
4066 | // Extend the settings, but re-extend 's' so that it can be
|
3868 | // checked again later (in the test suite, specifically)
|
4067 | // checked again later (in the test suite, specifically)
|
3869 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
4068 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3870 | 4069 | ||
3871 | var jsonp, status, data, |
4070 | var jsonp, status, data, |
- | 4071 | callbackContext = s.context || window, |
|
3872 | type = s.type.toUpperCase(); |
4072 | type = s.type.toUpperCase(); |
3873 | 4073 | ||
3874 | // convert data if not already a string
|
4074 | // convert data if not already a string
|
3875 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
4075 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
3876 | s.data = jQuery.param(s.data); |
4076 | s.data = jQuery.param(s.data); |
Строка 3947... | Строка 4147... | ||
3947 | // If we're requesting a remote document
|
4147 | // If we're requesting a remote document
|
3948 | // and trying to load JSON or Script with a GET
|
4148 | // and trying to load JSON or Script with a GET
|
3949 | if ( s.dataType === "script" && type === "GET" && parts |
4149 | if ( s.dataType === "script" && type === "GET" && parts |
3950 | && ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
4150 | && ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
3951 | 4151 | ||
3952 | var head = document.getElementsByTagName("head")[0]; |
4152 | var head = document.getElementsByTagName("head")[0] || document.documentElement; |
3953 | var script = document.createElement("script"); |
4153 | var script = document.createElement("script"); |
3954 | script.src = s.url; |
4154 | script.src = s.url; |
3955 | if ( s.scriptCharset ) { |
4155 | if ( s.scriptCharset ) { |
3956 | script.charset = s.scriptCharset; |
4156 | script.charset = s.scriptCharset; |
3957 | }
|
4157 | }
|
Строка 4024... | Строка 4224... | ||
4024 | s.accepts[ s.dataType ] + ", */*" : |
4224 | s.accepts[ s.dataType ] + ", */*" : |
4025 | s.accepts._default ); |
4225 | s.accepts._default ); |
4026 | } catch(e){} |
4226 | } catch(e){} |
4027 | 4227 | ||
4028 | // Allow custom headers/mimetypes and early abort
|
4228 | // Allow custom headers/mimetypes and early abort
|
4029 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
4229 | if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
4030 | // Handle the global AJAX counter
|
4230 | // Handle the global AJAX counter
|
4031 | if ( s.global && ! --jQuery.active ) { |
4231 | if ( s.global && ! --jQuery.active ) { |
4032 | jQuery.event.trigger( "ajaxStop" ); |
4232 | jQuery.event.trigger( "ajaxStop" ); |
4033 | }
|
4233 | }
|
4034 | 4234 | ||
Строка 4036... | Строка 4236... | ||
4036 | xhr.abort(); |
4236 | xhr.abort(); |
4037 | return false; |
4237 | return false; |
4038 | }
|
4238 | }
|
4039 | 4239 | ||
4040 | if ( s.global ) { |
4240 | if ( s.global ) { |
4041 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
4241 | trigger("ajaxSend", [xhr, s]); |
4042 | }
|
4242 | }
|
4043 | 4243 | ||
4044 | // Wait for a response to come back
|
4244 | // Wait for a response to come back
|
4045 | var onreadystatechange = function(isTimeout){ |
4245 | var onreadystatechange = function(isTimeout){ |
4046 | // The request was aborted, clear the interval and decrement jQuery.active
|
4246 | // The request was aborted, clear the interval and decrement jQuery.active
|
4047 | if ( xhr.readyState === 0 ) { |
4247 | if ( !xhr || xhr.readyState === 0 ) { |
4048 | if ( ival ) { |
4248 | if ( ival ) { |
4049 | // clear poll interval
|
4249 | // clear poll interval
|
4050 | clearInterval( ival ); |
4250 | clearInterval( ival ); |
4051 | ival = null; |
4251 | ival = null; |
4052 | 4252 | ||
Строка 4136... | Строка 4336... | ||
4136 | }
|
4336 | }
|
4137 | 4337 | ||
4138 | function success(){ |
4338 | function success(){ |
4139 | // If a local callback was specified, fire it and pass it the data
|
4339 | // If a local callback was specified, fire it and pass it the data
|
4140 | if ( s.success ) { |
4340 | if ( s.success ) { |
4141 | s.success( data, status ); |
4341 | s.success.call( callbackContext, data, status ); |
4142 | }
|
4342 | }
|
4143 | 4343 | ||
4144 | // Fire the global callback
|
4344 | // Fire the global callback
|
4145 | if ( s.global ) { |
4345 | if ( s.global ) { |
4146 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
4346 | trigger( "ajaxSuccess", [xhr, s] ); |
4147 | }
|
4347 | }
|
4148 | }
|
4348 | }
|
4149 | 4349 | ||
4150 | function complete(){ |
4350 | function complete(){ |
4151 | // Process result
|
4351 | // Process result
|
4152 | if ( s.complete ) { |
4352 | if ( s.complete ) { |
4153 | s.complete(xhr, status); |
4353 | s.complete.call( callbackContext, xhr, status); |
4154 | }
|
4354 | }
|
4155 | 4355 | ||
4156 | // The request was completed
|
4356 | // The request was completed
|
4157 | if ( s.global ) { |
4357 | if ( s.global ) { |
4158 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
4358 | trigger( "ajaxComplete", [xhr, s] ); |
4159 | }
|
4359 | }
|
4160 | 4360 | ||
4161 | // Handle the global AJAX counter
|
4361 | // Handle the global AJAX counter
|
4162 | if ( s.global && ! --jQuery.active ) { |
4362 | if ( s.global && ! --jQuery.active ) { |
4163 | jQuery.event.trigger( "ajaxStop" ); |
4363 | jQuery.event.trigger( "ajaxStop" ); |
4164 | }
|
4364 | }
|
4165 | }
|
4365 | }
|
- | 4366 | ||
- | 4367 | function trigger(type, args){ |
|
- | 4368 | (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
|
- | 4369 | }
|
|
4166 | 4370 | ||
4167 | // return XMLHttpRequest to allow aborting the request etc.
|
4371 | // return XMLHttpRequest to allow aborting the request etc.
|
4168 | return xhr; |
4372 | return xhr; |
4169 | }, |
4373 | }, |
4170 | 4374 | ||
4171 | handleError: function( s, xhr, status, e ) { |
4375 | handleError: function( s, xhr, status, e ) { |
4172 | // If a local callback was specified, fire it
|
4376 | // If a local callback was specified, fire it
|
4173 | if ( s.error ) { |
4377 | if ( s.error ) { |
4174 | s.error( xhr, status, e ); |
4378 | s.error.call( s.context || window, xhr, status, e ); |
4175 | }
|
4379 | }
|
4176 | 4380 | ||
4177 | // Fire the global callback
|
4381 | // Fire the global callback
|
4178 | if ( s.global ) { |
4382 | if ( s.global ) { |
4179 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
4383 | (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
4180 | }
|
4384 | }
|
4181 | }, |
4385 | }, |
4182 | 4386 | ||
4183 | // Counter for holding the number of active queries
|
4387 | // Counter for holding the number of active queries
|
4184 | active: 0, |
4388 | active: 0, |
Строка 4196... | Строка 4400... | ||
4196 | return false; |
4400 | return false; |
4197 | }, |
4401 | }, |
4198 | 4402 | ||
4199 | // Determines if an XMLHttpRequest returns NotModified
|
4403 | // Determines if an XMLHttpRequest returns NotModified
|
4200 | httpNotModified: function( xhr, url ) { |
4404 | httpNotModified: function( xhr, url ) { |
4201 | var last_modified = xhr.getResponseHeader("Last-Modified"), |
4405 | var lastModified = xhr.getResponseHeader("Last-Modified"), |
4202 | etag = xhr.getResponseHeader("Etag"); |
4406 | etag = xhr.getResponseHeader("Etag"); |
4203 | 4407 | ||
4204 | if ( last_modified ) { |
4408 | if ( lastModified ) { |
4205 | jQuery.lastModified[url] = last_modified; |
4409 | jQuery.lastModified[url] = lastModified; |
4206 | }
|
4410 | }
|
4207 | 4411 | ||
4208 | if ( etag ) { |
4412 | if ( etag ) { |
4209 | jQuery.etag[url] = etag; |
4413 | jQuery.etag[url] = etag; |
4210 | }
|
4414 | }
|
Строка 4250... | Строка 4454... | ||
4250 | }, |
4454 | }, |
4251 | 4455 | ||
4252 | // Serialize an array of form elements or a set of
|
4456 | // Serialize an array of form elements or a set of
|
4253 | // key/values into a query string
|
4457 | // key/values into a query string
|
4254 | param: function( a ) { |
4458 | param: function( a ) { |
4255 | var s = []; |
4459 | var s = [], |
- | 4460 | param_traditional = jQuery.param.traditional; |
|
4256 | 4461 | ||
4257 | function add( key, value ){ |
4462 | function add( key, value ){ |
- | 4463 | // If value is a function, invoke it and return its value
|
|
- | 4464 | value = jQuery.isFunction(value) ? value() : value; |
|
4258 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4465 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4259 | }
|
4466 | }
|
4260 | 4467 | ||
4261 | // If an array was passed in, assume that it is an array
|
4468 | // If an array was passed in, assume that it is an array
|
4262 | // of form elements
|
4469 | // of form elements
|
4263 | if ( jQuery.isArray(a) || a.jquery ) { |
4470 | if ( jQuery.isArray(a) || a.jquery ) |
4264 | // Serialize the form elements
|
4471 | // Serialize the form elements
|
4265 | jQuery.each( a, function(){ |
4472 | jQuery.each( a, function() { |
4266 | add( this.name, this.value ); |
4473 | add( this.name, this.value ); |
4267 | }); |
4474 | }); |
4268 | 4475 | ||
4269 | // Otherwise, assume that it's an object of key/value pairs
|
- | |
4270 | } else { |
4476 | else
|
4271 | // Serialize the key/values
|
4477 | // Encode parameters from object, recursively. If
|
- | 4478 | // jQuery.param.traditional is set, encode the "old" way
|
|
4272 | for ( var j in a ) { |
4479 | // (the way 1.3.2 or older did it)
|
4273 | // If the value is an array then the key names need to be repeated
|
4480 | jQuery.each( a, function buildParams( prefix, obj ) { |
- | 4481 | ||
4274 | if ( jQuery.isArray(a[j]) ) { |
4482 | if ( jQuery.isArray(obj) ) |
4275 | jQuery.each( a[j], function(){ |
4483 | jQuery.each( obj, function(i,v){ |
- | 4484 | // Due to rails' limited request param syntax, numeric array
|
|
- | 4485 | // indices are not supported. To avoid serialization ambiguity
|
|
- | 4486 | // issues, serialized arrays can only contain scalar values. php
|
|
- | 4487 | // does not have this issue, but we should go with the lowest
|
|
4276 | add( j, this ); |
4488 | // common denominator
|
- | 4489 | add( prefix + ( param_traditional ? "" : "[]" ), v ); |
|
4277 | }); |
4490 | }); |
- | 4491 | ||
- | 4492 | else if ( typeof obj == "object" ) |
|
- | 4493 | if ( param_traditional ) |
|
- | 4494 | add( prefix, obj ); |
|
- | 4495 | ||
4278 | } else { |
4496 | else
|
- | 4497 | jQuery.each( obj, function(k,v){ |
|
4279 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
4498 | buildParams( prefix ? prefix + "[" + k + "]" : k, v ); |
4280 | }
|
4499 | }); |
- | 4500 | ||
4281 | }
|
4501 | else
|
- | 4502 | add( prefix, obj ); |
|
- | 4503 | ||
4282 | }
|
4504 | }); |
4283 | 4505 | ||
4284 | // Return the resulting serialization
|
4506 | // Return the resulting serialization
|
4285 | return s.join("&").replace(r20, "+"); |
4507 | return s.join("&").replace(r20, "+"); |
4286 | }
|
4508 | }
|
4287 | 4509 | ||
Строка 4305... | Строка 4527... | ||
4305 | return obj; |
4527 | return obj; |
4306 | }
|
4528 | }
|
4307 | 4529 | ||
4308 | jQuery.fn.extend({ |
4530 | jQuery.fn.extend({ |
4309 | show: function(speed,callback){ |
4531 | show: function(speed,callback){ |
4310 | if ( speed ) { |
4532 | if ( speed !== undefined ) { |
4311 | return this.animate( genFx("show", 3), speed, callback); |
4533 | return this.animate( genFx("show", 3), speed, callback); |
4312 | } else { |
4534 | } else { |
4313 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4535 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4314 | var old = jQuery.data(this[i], "olddisplay"); |
4536 | var old = jQuery.data(this[i], "olddisplay"); |
4315 | 4537 | ||
Строка 4345... | Строка 4567... | ||
4345 | return this; |
4567 | return this; |
4346 | }
|
4568 | }
|
4347 | }, |
4569 | }, |
4348 | 4570 | ||
4349 | hide: function(speed,callback){ |
4571 | hide: function(speed,callback){ |
4350 | if ( speed ) { |
4572 | if ( speed !== undefined ) { |
4351 | return this.animate( genFx("hide", 3), speed, callback); |
4573 | return this.animate( genFx("hide", 3), speed, callback); |
4352 | } else { |
4574 | } else { |
4353 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4575 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4354 | var old = jQuery.data(this[i], "olddisplay"); |
4576 | var old = jQuery.data(this[i], "olddisplay"); |
4355 | if ( !old && old !== "none" ) |
4577 | if ( !old && old !== "none" ) |
Строка 4707... | Строка 4929... | ||
4707 | fx.elem[ fx.prop ] = fx.now; |
4929 | fx.elem[ fx.prop ] = fx.now; |
4708 | }
|
4930 | }
|
4709 | }
|
4931 | }
|
4710 | }); |
4932 | }); |
4711 | if ( "getBoundingClientRect" in document.documentElement ) { |
4933 | if ( "getBoundingClientRect" in document.documentElement ) { |
4712 | jQuery.fn.offset = function() { |
4934 | jQuery.fn.offset = function( options ) { |
4713 | var elem = this[0]; |
4935 | var elem = this[0]; |
4714 | if ( !elem || !elem.ownerDocument ) { return null; } |
4936 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | 4937 | if ( options ) { |
|
- | 4938 | return this.each(function() { |
|
- | 4939 | jQuery.offset.setOffset( this, options ); |
|
- | 4940 | }); |
|
- | 4941 | }
|
|
4715 | if ( elem === elem.ownerDocument.body ) { |
4942 | if ( elem === elem.ownerDocument.body ) { |
4716 | return jQuery.offset.bodyOffset( elem ); |
4943 | return jQuery.offset.bodyOffset( elem ); |
4717 | }
|
4944 | }
|
4718 | 4945 | ||
4719 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4946 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
Строка 4721... | Строка 4948... | ||
4721 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4948 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4722 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4949 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4723 | return { top: top, left: left }; |
4950 | return { top: top, left: left }; |
4724 | }; |
4951 | }; |
4725 | } else { |
4952 | } else { |
4726 | jQuery.fn.offset = function() { |
4953 | jQuery.fn.offset = function( options ) { |
4727 | var elem = this[0]; |
4954 | var elem = this[0]; |
4728 | if ( !elem || !elem.ownerDocument ) { return null; } |
4955 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | 4956 | if ( options ) { |
|
- | 4957 | return this.each(function() { |
|
- | 4958 | jQuery.offset.setOffset( this, options ); |
|
- | 4959 | }); |
|
- | 4960 | }
|
|
4729 | if ( elem === elem.ownerDocument.body ) { |
4961 | if ( elem === elem.ownerDocument.body ) { |
4730 | return jQuery.offset.bodyOffset( elem ); |
4962 | return jQuery.offset.bodyOffset( elem ); |
4731 | }
|
4963 | }
|
4732 | 4964 | ||
4733 | jQuery.offset.initialize(); |
4965 | jQuery.offset.initialize(); |
4734 | 4966 | ||
4735 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4967 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4736 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4968 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4737 | body = doc.body, defaultView = doc.defaultView, |
4969 | body = doc.body, defaultView = doc.defaultView, |
4738 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4970 | prevComputedStyle = defaultView.getComputedStyle( elem, null ), |
4739 | top = elem.offsetTop, left = elem.offsetLeft; |
4971 | top = elem.offsetTop, left = elem.offsetLeft; |
4740 | 4972 | ||
4741 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4973 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4742 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } |
4974 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } |
4743 | 4975 | ||
4744 | computedStyle = defaultView.getComputedStyle(elem, null); |
4976 | computedStyle = defaultView.getComputedStyle(elem, null); |
4745 | top -= elem.scrollTop; |
4977 | top -= elem.scrollTop; |
4746 | left -= elem.scrollLeft; |
4978 | left -= elem.scrollLeft; |
4747 | 4979 | ||
4748 | if ( elem === offsetParent ) { |
4980 | if ( elem === offsetParent ) { |
4749 | top += elem.offsetTop; |
4981 | top += elem.offsetTop; |
4750 | left += elem.offsetLeft; |
4982 | left += elem.offsetLeft; |
4751 | 4983 | ||
4752 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
4984 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
4753 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4985 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4754 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4986 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
Строка 4808... | Строка 5040... | ||
4808 | body.removeChild( container ); |
5040 | body.removeChild( container ); |
4809 | body = container = innerDiv = checkDiv = table = td = null; |
5041 | body = container = innerDiv = checkDiv = table = td = null; |
4810 | jQuery.offset.initialize = function(){}; |
5042 | jQuery.offset.initialize = function(){}; |
4811 | }, |
5043 | }, |
4812 | 5044 | ||
4813 | bodyOffset: function(body) { |
5045 | bodyOffset: function( body ) { |
4814 | var top = body.offsetTop, left = body.offsetLeft; |
5046 | var top = body.offsetTop, left = body.offsetLeft; |
4815 | 5047 | ||
4816 | jQuery.offset.initialize(); |
5048 | jQuery.offset.initialize(); |
4817 | 5049 | ||
4818 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
5050 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
4819 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; |
5051 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; |
4820 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
5052 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
4821 | }
|
5053 | }
|
4822 | 5054 | ||
4823 | return { top: top, left: left }; |
5055 | return { top: top, left: left }; |
- | 5056 | }, |
|
- | 5057 | ||
- | 5058 | setOffset: function( elem, options ) { |
|
- | 5059 | // set position first, in-case top/left are set even on static elem
|
|
- | 5060 | if ( /static/.test( jQuery.curCSS( elem, 'position' ) ) ) { |
|
- | 5061 | elem.style.position = 'relative'; |
|
- | 5062 | }
|
|
- | 5063 | var curElem = jQuery( elem ), |
|
- | 5064 | curOffset = curElem.offset(), |
|
- | 5065 | curTop = parseInt( jQuery.curCSS( elem, 'top', true ), 10 ) || 0, |
|
- | 5066 | curLeft = parseInt( jQuery.curCSS( elem, 'left', true ), 10) || 0, |
|
- | 5067 | props = { |
|
- | 5068 | top: (options.top - curOffset.top) + curTop, |
|
- | 5069 | left: (options.left - curOffset.left) + curLeft |
|
- | 5070 | }; |
|
- | 5071 | ||
- | 5072 | if ( 'using' in options ) { |
|
- | 5073 | options.using.call( elem, props ); |
|
- | 5074 | } else { |
|
- | 5075 | curElem.css( props ); |
|
- | 5076 | }
|
|
4824 | }
|
5077 | }
|
4825 | }; |
5078 | }; |
4826 | 5079 | ||
4827 | 5080 | ||
4828 | jQuery.fn.extend({ |
5081 | jQuery.fn.extend({ |
Строка 4952... | Строка 5205... | ||
4952 | // Set the width or height on the element (default to pixels if value is unitless)
|
5205 | // Set the width or height on the element (default to pixels if value is unitless)
|
4953 | this.css( type, typeof size === "string" ? size : size + "px" ); |
5206 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4954 | }; |
5207 | }; |
4955 | 5208 | ||
4956 | }); |
5209 | }); |
- | 5210 | // Expose jQuery to the global object
|
|
- | 5211 | window.jQuery = window.$ = jQuery; |
|
- | 5212 | ||
4957 | })(window); |
5213 | })(window); |