jquery.js
上传用户:linhai
上传日期:2022-07-24
资源大小:184k
文件大小:178k
- * @before <p>Hello</p>
- * @result [ <p style="display: none">Hello</p> ]
- *
- * var pass = true, div = $("div");
- * div.hide().each(function(){
- * if ( this.style.display != "none" ) pass = false;
- * });
- * ok( pass, "Hide" );
- *
- * @name hide
- * @type jQuery
- * @cat Effects
- */
- hide: function(){
- this.oldblock = this.oldblock || jQuery.css(this,"display");
- if ( this.oldblock == "none" )
- this.oldblock = "block";
- this.style.display = "none";
- },
- /**
- * Toggles each of the set of matched elements. If they are shown,
- * toggle makes them hidden. If they are hidden, toggle
- * makes them shown.
- *
- * @example $("p").toggle()
- * @before <p>Hello</p><p style="display: none">Hello Again</p>
- * @result [ <p style="display: none">Hello</p>, <p style="display: block">Hello Again</p> ]
- *
- * @name toggle
- * @type jQuery
- * @cat Effects
- */
- toggle: function(){
- jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ].apply( jQuery(this), arguments );
- },
- /**
- * Adds the specified class to each of the set of matched elements.
- *
- * @example $("p").addClass("selected")
- * @before <p>Hello</p>
- * @result [ <p class="selected">Hello</p> ]
- *
- * @test var div = $("div");
- * div.addClass("test");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
- * }
- * ok( pass, "Add Class" );
- *
- * @name addClass
- * @type jQuery
- * @param String class A CSS class to add to the elements
- * @cat DOM
- */
- addClass: function(c){
- jQuery.className.add(this,c);
- },
- /**
- * Removes the specified class from the set of matched elements.
- *
- * @example $("p").removeClass("selected")
- * @before <p class="selected">Hello</p>
- * @result [ <p>Hello</p> ]
- *
- * @test var div = $("div").addClass("test");
- * div.removeClass("test");
- * var pass = true;
- * for ( var i = 0; i < div.size(); i++ ) {
- * if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
- * }
- * ok( pass, "Remove Class" );
- *
- * @name removeClass
- * @type jQuery
- * @param String class A CSS class to remove from the elements
- * @cat DOM
- */
- removeClass: function(c){
- jQuery.className.remove(this,c);
- },
- /**
- * Adds the specified class if it is present, removes it if it is
- * not present.
- *
- * @example $("p").toggleClass("selected")
- * @before <p>Hello</p><p class="selected">Hello Again</p>
- * @result [ <p class="selected">Hello</p>, <p>Hello Again</p> ]
- *
- * @name toggleClass
- * @type jQuery
- * @param String class A CSS class with which to toggle the elements
- * @cat DOM
- */
- toggleClass: function( c ){
- jQuery.className[ jQuery.className.has(this,c) ? "remove" : "add" ](this,c);
- },
- /**
- * Removes all matched elements from the DOM. This does NOT remove them from the
- * jQuery object, allowing you to use the matched elements further.
- *
- * @example $("p").remove();
- * @before <p>Hello</p> how are <p>you?</p>
- * @result how are
- *
- * @name remove
- * @type jQuery
- * @cat DOM/Manipulation
- */
- /**
- * Removes only elements (out of the list of matched elements) that match
- * the specified jQuery expression. This does NOT remove them from the
- * jQuery object, allowing you to use the matched elements further.
- *
- * @example $("p").remove(".hello");
- * @before <p class="hello">Hello</p> how are <p>you?</p>
- * @result how are <p>you?</p>
- *
- * @name remove
- * @type jQuery
- * @param String expr A jQuery expression to filter elements by.
- * @cat DOM/Manipulation
- */
- remove: function(a){
- if ( !a || jQuery.filter( a, [this] ).r )
- this.parentNode.removeChild( this );
- },
- /**
- * Removes all child nodes from the set of matched elements.
- *
- * @example $("p").empty()
- * @before <p>Hello, <span>Person</span> <a href="#">and person</a></p>
- * @result [ <p></p> ]
- *
- * @name empty
- * @type jQuery
- * @cat DOM/Manipulation
- */
- empty: function(){
- while ( this.firstChild )
- this.removeChild( this.firstChild );
- },
- /**
- * Binds a particular event (like click) to a each of a set of match elements.
- *
- * @example $("p").bind( "click", function() { alert("Hello"); } )
- * @before <p>Hello</p>
- * @result [ <p>Hello</p> ]
- *
- * Cancel a default action and prevent it from bubbling by returning false
- * from your function.
- *
- * @example $("form").bind( "submit", function() { return false; } )
- *
- * Cancel a default action by using the preventDefault method.
- *
- * @example $("form").bind( "submit", function() { e.preventDefault(); } )
- *
- * Stop an event from bubbling by using the stopPropogation method.
- *
- * @example $("form").bind( "submit", function() { e.stopPropogation(); } )
- *
- * @name bind
- * @type jQuery
- * @param String type An event type
- * @param Function fn A function to bind to the event on each of the set of matched elements
- * @cat Events
- */
- bind: function( type, fn ) {
- if ( fn.constructor == String )
- fn = new Function("e", ( !fn.indexOf(".") ? "jQuery(this)" : "return " ) + fn);
- jQuery.event.add( this, type, fn );
- },
- /**
- * The opposite of bind, removes a bound event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unbind( "click", function() { alert("Hello"); } )
- * @before <p onclick="alert('Hello');">Hello</p>
- * @result [ <p>Hello</p> ]
- *
- * @name unbind
- * @type jQuery
- * @param String type An event type
- * @param Function fn A function to unbind from the event on each of the set of matched elements
- * @cat Events
- */
- /**
- * Removes all bound events of a particular type from each of the matched
- * elements.
- *
- * @example $("p").unbind( "click" )
- * @before <p onclick="alert('Hello');">Hello</p>
- * @result [ <p>Hello</p> ]
- *
- * @name unbind
- * @type jQuery
- * @param String type An event type
- * @cat Events
- */
- /**
- * Removes all bound events from each of the matched elements.
- *
- * @example $("p").unbind()
- * @before <p onclick="alert('Hello');">Hello</p>
- * @result [ <p>Hello</p> ]
- *
- * @name unbind
- * @type jQuery
- * @cat Events
- */
- unbind: function( type, fn ) {
- jQuery.event.remove( this, type, fn );
- },
- /**
- * Trigger a type of event on every matched element.
- *
- * @example $("p").trigger("click")
- * @before <p click="alert('hello')">Hello</p>
- * @result alert('hello')
- *
- * @name trigger
- * @type jQuery
- * @param String type An event type to trigger.
- * @cat Events
- */
- trigger: function( type, data ) {
- jQuery.event.trigger( type, data, this );
- }
- }
- };
- jQuery.init();
- jQuery.fn.extend({
- // We're overriding the old toggle function, so
- // remember it for later
- _toggle: jQuery.fn.toggle,
-
- /**
- * Toggle between two function calls every other click.
- * Whenever a matched element is clicked, the first specified function
- * is fired, when clicked again, the second is fired. All subsequent
- * clicks continue to rotate through the two functions.
- *
- * @example $("p").toggle(function(){
- * $(this).addClass("selected");
- * },function(){
- * $(this).removeClass("selected");
- * });
- *
- * var count = 0;
- * var fn1 = function() { count++; }
- * var fn2 = function() { count--; }
- * var link = $('#mark');
- * link.click().toggle(fn1, fn2).click().click().click().click().click();
- * ok( count == 1, "Check for toggle(fn, fn)" );
- *
- * @name toggle
- * @type jQuery
- * @param Function even The function to execute on every even click.
- * @param Function odd The function to execute on every odd click.
- * @cat Events
- */
- toggle: function(a,b) {
- // If two functions are passed in, we're
- // toggling on a click
- return a && b && a.constructor == Function && b.constructor == Function ? this.click(function(e){
- // Figure out which function to execute
- this.last = this.last == a ? b : a;
-
- // Make sure that clicks stop
- e.preventDefault();
-
- // and execute the function
- return this.last.apply( this, [e] ) || false;
- }) :
-
- // Otherwise, execute the old toggle function
- this._toggle.apply( this, arguments );
- },
-
- /**
- * A method for simulating hovering (moving the mouse on, and off,
- * an object). This is a custom method which provides an 'in' to a
- * frequent task.
- *
- * Whenever the mouse cursor is moved over a matched
- * element, the first specified function is fired. Whenever the mouse
- * moves off of the element, the second specified function fires.
- * Additionally, checks are in place to see if the mouse is still within
- * the specified element itself (for example, an image inside of a div),
- * and if it is, it will continue to 'hover', and not move out
- * (a common error in using a mouseout event handler).
- *
- * @example $("p").hover(function(){
- * $(this).addClass("over");
- * },function(){
- * $(this).addClass("out");
- * });
- *
- * @name hover
- * @type jQuery
- * @param Function over The function to fire whenever the mouse is moved over a matched element.
- * @param Function out The function to fire whenever the mouse is moved off of a matched element.
- * @cat Events
- */
- hover: function(f,g) {
-
- // A private function for haandling mouse 'hovering'
- function handleHover(e) {
- // Check if mouse(over|out) are still within the same parent element
- var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
-
- // Traverse up the tree
- while ( p && p != this ) p = p.parentNode;
-
- // If we actually just moused on to a sub-element, ignore it
- if ( p == this ) return false;
-
- // Execute the right function
- return (e.type == "mouseover" ? f : g).apply(this, [e]);
- }
-
- // Bind the function to the two event listeners
- return this.mouseover(handleHover).mouseout(handleHover);
- },
-
- /**
- * Bind a function to be executed whenever the DOM is ready to be
- * traversed and manipulated. This is probably the most important
- * function included in the event module, as it can greatly improve
- * the response times of your web applications.
- *
- * In a nutshell, this is a solid replacement for using window.onload,
- * and attaching a function to that. By using this method, your bound Function
- * will be called the instant the DOM is ready to be read and manipulated,
- * which is exactly what 99.99% of all Javascript code needs to run.
- *
- * Please ensure you have no code in your <body> onload event handler,
- * otherwise $(document).ready() may not fire.
- *
- * @example $(document).ready(function(){ Your code here... });
- *
- * @name ready
- * @type jQuery
- * @param Function fn The function to be executed when the DOM is ready.
- * @cat Events
- */
- ready: function(f) {
- // If the DOM is already ready
- if ( jQuery.isReady )
- // Execute the function immediately
- f.apply( document );
-
- // Otherwise, remember the function for later
- else {
- // Add the function to the wait list
- jQuery.readyList.push( f );
- }
-
- return this;
- }
- });
- jQuery.extend({
- /*
- * All the code that makes DOM Ready work nicely.
- */
- isReady: false,
- readyList: [],
-
- // Handle when the DOM is ready
- ready: function() {
- // Make sure that the DOM is not already loaded
- if ( !jQuery.isReady ) {
- // Remember that the DOM is ready
- jQuery.isReady = true;
-
- // If there are functions bound, to execute
- if ( jQuery.readyList ) {
- // Execute all of them
- for ( var i = 0; i < jQuery.readyList.length; i++ )
- jQuery.readyList[i].apply( document );
-
- // Reset the list of functions
- jQuery.readyList = null;
- }
- }
- }
- });
- new function(){
- /**
- * Bind a function to the scroll event of each matched element.
- *
- * @example $("p").scroll( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onscroll="alert('Hello');">Hello</p>
- *
- * @name scroll
- * @type jQuery
- * @param Function fn A function to bind to the scroll event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Trigger the scroll event of each matched element. This causes all of the functions
- * that have been bound to thet scroll event to be executed.
- *
- * @example $("p").scroll();
- * @before <p onscroll="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name scroll
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the scroll event of each matched element, which will only be executed once.
- * Unlike a call to the normal .scroll() method, calling .onescroll() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onescroll( function() { alert("Hello"); } );
- * @before <p onscroll="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first scroll
- *
- * @name onescroll
- * @type jQuery
- * @param Function fn A function to bind to the scroll event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes a bound scroll event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unscroll( myFunction );
- * @before <p onscroll="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unscroll
- * @type jQuery
- * @param Function fn A function to unbind from the scroll event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes all bound scroll events from each of the matched elements.
- *
- * @example $("p").unscroll();
- * @before <p onscroll="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unscroll
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the submit event of each matched element.
- *
- * @example $("p").submit( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onsubmit="alert('Hello');">Hello</p>
- *
- * @name submit
- * @type jQuery
- * @param Function fn A function to bind to the submit event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Trigger the submit event of each matched element. This causes all of the functions
- * that have been bound to thet submit event to be executed.
- *
- * @example $("p").submit();
- * @before <p onsubmit="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name submit
- * @type jQuery
- * @cat Events/Form
- */
- /**
- * Bind a function to the submit event of each matched element, which will only be executed once.
- * Unlike a call to the normal .submit() method, calling .onesubmit() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onesubmit( function() { alert("Hello"); } );
- * @before <p onsubmit="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first submit
- *
- * @name onesubmit
- * @type jQuery
- * @param Function fn A function to bind to the submit event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Removes a bound submit event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unsubmit( myFunction );
- * @before <p onsubmit="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unsubmit
- * @type jQuery
- * @param Function fn A function to unbind from the submit event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Removes all bound submit events from each of the matched elements.
- *
- * @example $("p").unsubmit();
- * @before <p onsubmit="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unsubmit
- * @type jQuery
- * @cat Events/Form
- */
- /**
- * Bind a function to the focus event of each matched element.
- *
- * @example $("p").focus( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onfocus="alert('Hello');">Hello</p>
- *
- * @name focus
- * @type jQuery
- * @param Function fn A function to bind to the focus event on each of the matched elements.
- * @cat Events/UI
- */
- /**
- * Trigger the focus event of each matched element. This causes all of the functions
- * that have been bound to thet focus event to be executed.
- *
- * @example $("p").focus();
- * @before <p onfocus="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name focus
- * @type jQuery
- * @cat Events/UI
- */
- /**
- * Bind a function to the focus event of each matched element, which will only be executed once.
- * Unlike a call to the normal .focus() method, calling .onefocus() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onefocus( function() { alert("Hello"); } );
- * @before <p onfocus="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first focus
- *
- * @name onefocus
- * @type jQuery
- * @param Function fn A function to bind to the focus event on each of the matched elements.
- * @cat Events/UI
- */
- /**
- * Removes a bound focus event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unfocus( myFunction );
- * @before <p onfocus="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unfocus
- * @type jQuery
- * @param Function fn A function to unbind from the focus event on each of the matched elements.
- * @cat Events/UI
- */
- /**
- * Removes all bound focus events from each of the matched elements.
- *
- * @example $("p").unfocus();
- * @before <p onfocus="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unfocus
- * @type jQuery
- * @cat Events/UI
- */
- /**
- * Bind a function to the keydown event of each matched element.
- *
- * @example $("p").keydown( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onkeydown="alert('Hello');">Hello</p>
- *
- * @name keydown
- * @type jQuery
- * @param Function fn A function to bind to the keydown event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Trigger the keydown event of each matched element. This causes all of the functions
- * that have been bound to thet keydown event to be executed.
- *
- * @example $("p").keydown();
- * @before <p onkeydown="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name keydown
- * @type jQuery
- * @cat Events/Keyboard
- */
- /**
- * Bind a function to the keydown event of each matched element, which will only be executed once.
- * Unlike a call to the normal .keydown() method, calling .onekeydown() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onekeydown( function() { alert("Hello"); } );
- * @before <p onkeydown="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first keydown
- *
- * @name onekeydown
- * @type jQuery
- * @param Function fn A function to bind to the keydown event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Removes a bound keydown event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unkeydown( myFunction );
- * @before <p onkeydown="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unkeydown
- * @type jQuery
- * @param Function fn A function to unbind from the keydown event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Removes all bound keydown events from each of the matched elements.
- *
- * @example $("p").unkeydown();
- * @before <p onkeydown="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unkeydown
- * @type jQuery
- * @cat Events/Keyboard
- */
- /**
- * Bind a function to the dblclick event of each matched element.
- *
- * @example $("p").dblclick( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p ondblclick="alert('Hello');">Hello</p>
- *
- * @name dblclick
- * @type jQuery
- * @param Function fn A function to bind to the dblclick event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Trigger the dblclick event of each matched element. This causes all of the functions
- * that have been bound to thet dblclick event to be executed.
- *
- * @example $("p").dblclick();
- * @before <p ondblclick="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name dblclick
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the dblclick event of each matched element, which will only be executed once.
- * Unlike a call to the normal .dblclick() method, calling .onedblclick() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onedblclick( function() { alert("Hello"); } );
- * @before <p ondblclick="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first dblclick
- *
- * @name onedblclick
- * @type jQuery
- * @param Function fn A function to bind to the dblclick event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes a bound dblclick event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").undblclick( myFunction );
- * @before <p ondblclick="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name undblclick
- * @type jQuery
- * @param Function fn A function to unbind from the dblclick event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes all bound dblclick events from each of the matched elements.
- *
- * @example $("p").undblclick();
- * @before <p ondblclick="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name undblclick
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the keypress event of each matched element.
- *
- * @example $("p").keypress( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onkeypress="alert('Hello');">Hello</p>
- *
- * @name keypress
- * @type jQuery
- * @param Function fn A function to bind to the keypress event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Trigger the keypress event of each matched element. This causes all of the functions
- * that have been bound to thet keypress event to be executed.
- *
- * @example $("p").keypress();
- * @before <p onkeypress="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name keypress
- * @type jQuery
- * @cat Events/Keyboard
- */
- /**
- * Bind a function to the keypress event of each matched element, which will only be executed once.
- * Unlike a call to the normal .keypress() method, calling .onekeypress() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onekeypress( function() { alert("Hello"); } );
- * @before <p onkeypress="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first keypress
- *
- * @name onekeypress
- * @type jQuery
- * @param Function fn A function to bind to the keypress event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Removes a bound keypress event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unkeypress( myFunction );
- * @before <p onkeypress="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unkeypress
- * @type jQuery
- * @param Function fn A function to unbind from the keypress event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Removes all bound keypress events from each of the matched elements.
- *
- * @example $("p").unkeypress();
- * @before <p onkeypress="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unkeypress
- * @type jQuery
- * @cat Events/Keyboard
- */
- /**
- * Bind a function to the error event of each matched element.
- *
- * @example $("p").error( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onerror="alert('Hello');">Hello</p>
- *
- * @name error
- * @type jQuery
- * @param Function fn A function to bind to the error event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Trigger the error event of each matched element. This causes all of the functions
- * that have been bound to thet error event to be executed.
- *
- * @example $("p").error();
- * @before <p onerror="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name error
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the error event of each matched element, which will only be executed once.
- * Unlike a call to the normal .error() method, calling .oneerror() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneerror( function() { alert("Hello"); } );
- * @before <p onerror="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first error
- *
- * @name oneerror
- * @type jQuery
- * @param Function fn A function to bind to the error event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes a bound error event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unerror( myFunction );
- * @before <p onerror="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unerror
- * @type jQuery
- * @param Function fn A function to unbind from the error event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes all bound error events from each of the matched elements.
- *
- * @example $("p").unerror();
- * @before <p onerror="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unerror
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the blur event of each matched element.
- *
- * @example $("p").blur( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onblur="alert('Hello');">Hello</p>
- *
- * @name blur
- * @type jQuery
- * @param Function fn A function to bind to the blur event on each of the matched elements.
- * @cat Events/UI
- */
- /**
- * Trigger the blur event of each matched element. This causes all of the functions
- * that have been bound to thet blur event to be executed.
- *
- * @example $("p").blur();
- * @before <p onblur="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name blur
- * @type jQuery
- * @cat Events/UI
- */
- /**
- * Bind a function to the blur event of each matched element, which will only be executed once.
- * Unlike a call to the normal .blur() method, calling .oneblur() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneblur( function() { alert("Hello"); } );
- * @before <p onblur="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first blur
- *
- * @name oneblur
- * @type jQuery
- * @param Function fn A function to bind to the blur event on each of the matched elements.
- * @cat Events/UI
- */
- /**
- * Removes a bound blur event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unblur( myFunction );
- * @before <p onblur="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unblur
- * @type jQuery
- * @param Function fn A function to unbind from the blur event on each of the matched elements.
- * @cat Events/UI
- */
- /**
- * Removes all bound blur events from each of the matched elements.
- *
- * @example $("p").unblur();
- * @before <p onblur="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unblur
- * @type jQuery
- * @cat Events/UI
- */
- /**
- * Bind a function to the load event of each matched element.
- *
- * @example $("p").load( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onload="alert('Hello');">Hello</p>
- *
- * @name load
- * @type jQuery
- * @param Function fn A function to bind to the load event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Trigger the load event of each matched element. This causes all of the functions
- * that have been bound to thet load event to be executed.
- *
- * @example $("p").load();
- * @before <p onload="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name load
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the load event of each matched element, which will only be executed once.
- * Unlike a call to the normal .load() method, calling .oneload() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneload( function() { alert("Hello"); } );
- * @before <p onload="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first load
- *
- * @name oneload
- * @type jQuery
- * @param Function fn A function to bind to the load event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes a bound load event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unload( myFunction );
- * @before <p onload="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unload
- * @type jQuery
- * @param Function fn A function to unbind from the load event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes all bound load events from each of the matched elements.
- *
- * @example $("p").unload();
- * @before <p onload="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unload
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the select event of each matched element.
- *
- * @example $("p").select( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onselect="alert('Hello');">Hello</p>
- *
- * @name select
- * @type jQuery
- * @param Function fn A function to bind to the select event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Trigger the select event of each matched element. This causes all of the functions
- * that have been bound to thet select event to be executed.
- *
- * @example $("p").select();
- * @before <p onselect="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name select
- * @type jQuery
- * @cat Events/Form
- */
- /**
- * Bind a function to the select event of each matched element, which will only be executed once.
- * Unlike a call to the normal .select() method, calling .oneselect() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneselect( function() { alert("Hello"); } );
- * @before <p onselect="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first select
- *
- * @name oneselect
- * @type jQuery
- * @param Function fn A function to bind to the select event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Removes a bound select event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unselect( myFunction );
- * @before <p onselect="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unselect
- * @type jQuery
- * @param Function fn A function to unbind from the select event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Removes all bound select events from each of the matched elements.
- *
- * @example $("p").unselect();
- * @before <p onselect="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unselect
- * @type jQuery
- * @cat Events/Form
- */
- /**
- * Bind a function to the mouseup event of each matched element.
- *
- * @example $("p").mouseup( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onmouseup="alert('Hello');">Hello</p>
- *
- * @name mouseup
- * @type jQuery
- * @param Function fn A function to bind to the mouseup event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Trigger the mouseup event of each matched element. This causes all of the functions
- * that have been bound to thet mouseup event to be executed.
- *
- * @example $("p").mouseup();
- * @before <p onmouseup="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name mouseup
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the mouseup event of each matched element, which will only be executed once.
- * Unlike a call to the normal .mouseup() method, calling .onemouseup() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onemouseup( function() { alert("Hello"); } );
- * @before <p onmouseup="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first mouseup
- *
- * @name onemouseup
- * @type jQuery
- * @param Function fn A function to bind to the mouseup event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes a bound mouseup event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unmouseup( myFunction );
- * @before <p onmouseup="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmouseup
- * @type jQuery
- * @param Function fn A function to unbind from the mouseup event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes all bound mouseup events from each of the matched elements.
- *
- * @example $("p").unmouseup();
- * @before <p onmouseup="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmouseup
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the unload event of each matched element.
- *
- * @example $("p").unload( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onunload="alert('Hello');">Hello</p>
- *
- * @name unload
- * @type jQuery
- * @param Function fn A function to bind to the unload event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Trigger the unload event of each matched element. This causes all of the functions
- * that have been bound to thet unload event to be executed.
- *
- * @example $("p").unload();
- * @before <p onunload="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name unload
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the unload event of each matched element, which will only be executed once.
- * Unlike a call to the normal .unload() method, calling .oneunload() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneunload( function() { alert("Hello"); } );
- * @before <p onunload="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first unload
- *
- * @name oneunload
- * @type jQuery
- * @param Function fn A function to bind to the unload event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes a bound unload event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").ununload( myFunction );
- * @before <p onunload="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name ununload
- * @type jQuery
- * @param Function fn A function to unbind from the unload event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes all bound unload events from each of the matched elements.
- *
- * @example $("p").ununload();
- * @before <p onunload="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name ununload
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the change event of each matched element.
- *
- * @example $("p").change( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onchange="alert('Hello');">Hello</p>
- *
- * @name change
- * @type jQuery
- * @param Function fn A function to bind to the change event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Trigger the change event of each matched element. This causes all of the functions
- * that have been bound to thet change event to be executed.
- *
- * @example $("p").change();
- * @before <p onchange="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name change
- * @type jQuery
- * @cat Events/Form
- */
- /**
- * Bind a function to the change event of each matched element, which will only be executed once.
- * Unlike a call to the normal .change() method, calling .onechange() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onechange( function() { alert("Hello"); } );
- * @before <p onchange="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first change
- *
- * @name onechange
- * @type jQuery
- * @param Function fn A function to bind to the change event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Removes a bound change event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unchange( myFunction );
- * @before <p onchange="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unchange
- * @type jQuery
- * @param Function fn A function to unbind from the change event on each of the matched elements.
- * @cat Events/Form
- */
- /**
- * Removes all bound change events from each of the matched elements.
- *
- * @example $("p").unchange();
- * @before <p onchange="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unchange
- * @type jQuery
- * @cat Events/Form
- */
- /**
- * Bind a function to the mouseout event of each matched element.
- *
- * @example $("p").mouseout( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onmouseout="alert('Hello');">Hello</p>
- *
- * @name mouseout
- * @type jQuery
- * @param Function fn A function to bind to the mouseout event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Trigger the mouseout event of each matched element. This causes all of the functions
- * that have been bound to thet mouseout event to be executed.
- *
- * @example $("p").mouseout();
- * @before <p onmouseout="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name mouseout
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the mouseout event of each matched element, which will only be executed once.
- * Unlike a call to the normal .mouseout() method, calling .onemouseout() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onemouseout( function() { alert("Hello"); } );
- * @before <p onmouseout="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first mouseout
- *
- * @name onemouseout
- * @type jQuery
- * @param Function fn A function to bind to the mouseout event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes a bound mouseout event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unmouseout( myFunction );
- * @before <p onmouseout="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmouseout
- * @type jQuery
- * @param Function fn A function to unbind from the mouseout event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes all bound mouseout events from each of the matched elements.
- *
- * @example $("p").unmouseout();
- * @before <p onmouseout="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmouseout
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the keyup event of each matched element.
- *
- * @example $("p").keyup( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onkeyup="alert('Hello');">Hello</p>
- *
- * @name keyup
- * @type jQuery
- * @param Function fn A function to bind to the keyup event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Trigger the keyup event of each matched element. This causes all of the functions
- * that have been bound to thet keyup event to be executed.
- *
- * @example $("p").keyup();
- * @before <p onkeyup="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name keyup
- * @type jQuery
- * @cat Events/Keyboard
- */
- /**
- * Bind a function to the keyup event of each matched element, which will only be executed once.
- * Unlike a call to the normal .keyup() method, calling .onekeyup() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onekeyup( function() { alert("Hello"); } );
- * @before <p onkeyup="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first keyup
- *
- * @name onekeyup
- * @type jQuery
- * @param Function fn A function to bind to the keyup event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Removes a bound keyup event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unkeyup( myFunction );
- * @before <p onkeyup="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unkeyup
- * @type jQuery
- * @param Function fn A function to unbind from the keyup event on each of the matched elements.
- * @cat Events/Keyboard
- */
- /**
- * Removes all bound keyup events from each of the matched elements.
- *
- * @example $("p").unkeyup();
- * @before <p onkeyup="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unkeyup
- * @type jQuery
- * @cat Events/Keyboard
- */
- /**
- * Bind a function to the click event of each matched element.
- *
- * @example $("p").click( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onclick="alert('Hello');">Hello</p>
- *
- * @name click
- * @type jQuery
- * @param Function fn A function to bind to the click event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Trigger the click event of each matched element. This causes all of the functions
- * that have been bound to thet click event to be executed.
- *
- * @example $("p").click();
- * @before <p onclick="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name click
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the click event of each matched element, which will only be executed once.
- * Unlike a call to the normal .click() method, calling .oneclick() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneclick( function() { alert("Hello"); } );
- * @before <p onclick="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first click
- *
- * @name oneclick
- * @type jQuery
- * @param Function fn A function to bind to the click event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes a bound click event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unclick( myFunction );
- * @before <p onclick="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unclick
- * @type jQuery
- * @param Function fn A function to unbind from the click event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes all bound click events from each of the matched elements.
- *
- * @example $("p").unclick();
- * @before <p onclick="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unclick
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the resize event of each matched element.
- *
- * @example $("p").resize( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onresize="alert('Hello');">Hello</p>
- *
- * @name resize
- * @type jQuery
- * @param Function fn A function to bind to the resize event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Trigger the resize event of each matched element. This causes all of the functions
- * that have been bound to thet resize event to be executed.
- *
- * @example $("p").resize();
- * @before <p onresize="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name resize
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the resize event of each matched element, which will only be executed once.
- * Unlike a call to the normal .resize() method, calling .oneresize() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").oneresize( function() { alert("Hello"); } );
- * @before <p onresize="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first resize
- *
- * @name oneresize
- * @type jQuery
- * @param Function fn A function to bind to the resize event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes a bound resize event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unresize( myFunction );
- * @before <p onresize="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unresize
- * @type jQuery
- * @param Function fn A function to unbind from the resize event on each of the matched elements.
- * @cat Events/Browser
- */
- /**
- * Removes all bound resize events from each of the matched elements.
- *
- * @example $("p").unresize();
- * @before <p onresize="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unresize
- * @type jQuery
- * @cat Events/Browser
- */
- /**
- * Bind a function to the mousemove event of each matched element.
- *
- * @example $("p").mousemove( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onmousemove="alert('Hello');">Hello</p>
- *
- * @name mousemove
- * @type jQuery
- * @param Function fn A function to bind to the mousemove event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Trigger the mousemove event of each matched element. This causes all of the functions
- * that have been bound to thet mousemove event to be executed.
- *
- * @example $("p").mousemove();
- * @before <p onmousemove="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name mousemove
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the mousemove event of each matched element, which will only be executed once.
- * Unlike a call to the normal .mousemove() method, calling .onemousemove() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onemousemove( function() { alert("Hello"); } );
- * @before <p onmousemove="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first mousemove
- *
- * @name onemousemove
- * @type jQuery
- * @param Function fn A function to bind to the mousemove event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes a bound mousemove event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unmousemove( myFunction );
- * @before <p onmousemove="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmousemove
- * @type jQuery
- * @param Function fn A function to unbind from the mousemove event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes all bound mousemove events from each of the matched elements.
- *
- * @example $("p").unmousemove();
- * @before <p onmousemove="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmousemove
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the mousedown event of each matched element.
- *
- * @example $("p").mousedown( function() { alert("Hello"); } );
- * @before <p>Hello</p>
- * @result <p onmousedown="alert('Hello');">Hello</p>
- *
- * @name mousedown
- * @type jQuery
- * @param Function fn A function to bind to the mousedown event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Trigger the mousedown event of each matched element. This causes all of the functions
- * that have been bound to thet mousedown event to be executed.
- *
- * @example $("p").mousedown();
- * @before <p onmousedown="alert('Hello');">Hello</p>
- * @result alert('Hello');
- *
- * @name mousedown
- * @type jQuery
- * @cat Events/Mouse
- */
- /**
- * Bind a function to the mousedown event of each matched element, which will only be executed once.
- * Unlike a call to the normal .mousedown() method, calling .onemousedown() causes the bound function to be
- * only executed the first time it is triggered, and never again (unless it is re-bound).
- *
- * @example $("p").onemousedown( function() { alert("Hello"); } );
- * @before <p onmousedown="alert('Hello');">Hello</p>
- * @result alert('Hello'); // Only executed for the first mousedown
- *
- * @name onemousedown
- * @type jQuery
- * @param Function fn A function to bind to the mousedown event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes a bound mousedown event from each of the matched
- * elements. You must pass the identical function that was used in the original
- * bind method.
- *
- * @example $("p").unmousedown( myFunction );
- * @before <p onmousedown="myFunction">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmousedown
- * @type jQuery
- * @param Function fn A function to unbind from the mousedown event on each of the matched elements.
- * @cat Events/Mouse
- */
- /**
- * Removes all bound mousedown events from each of the matched elements.
- *
- * @example $("p").unmousedown();
- * @before <p onmousedown="alert('Hello');">Hello</p>
- * @result <p>Hello</p>
- *
- * @name unmousedown
- * @type jQuery
- * @cat Events/Mouse
- */
-
- /**
- * @test var count;
- * var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
- * "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," +
- * "submit,keydown,keypress,keyup,error").split(",");
- * var handler1 = function(event) {
- * count++;
- * };
- * var handler2 = function(event) {
- * count++;
- * };
- * for( var i=0; i < e.length; i++) {
- * var event = e[i];
- * count = 0;
- * // bind handler
- * $(document)[event](handler1);
- * $(document)[event](handler2);
- * $(document)["one"+event](handler1);
- *
- * // call event two times
- * $(document)[event]();
- * $(document)[event]();
- *
- * // unbind events
- * $(document)["un"+event](handler1);
- * // call once more
- * $(document)[event]();
- *
- * // remove all handlers
- * $(document)["un"+event]();
- *
- * // call once more
- * $(document)[event]();
- *
- * // assert count
- * @test ok( count == 6, 'Checking event ' + event);
- * }
- *
- * @private
- * @name eventTesting
- */
- var e = ("blur,focus,load,resize,scroll,unload,click,dblclick," +
- "mousedown,mouseup,mousemove,mouseover,mouseout,change,reset,select," +
- "submit,keydown,keypress,keyup,error").split(",");
- // Go through all the event names, but make sure that
- // it is enclosed properly
- for ( var i = 0; i < e.length; i++ ) new function(){
-
- var o = e[i];
-
- // Handle event binding
- jQuery.fn[o] = function(f){
- return f ? this.bind(o, f) : this.trigger(o);
- };
-
- // Handle event unbinding
- jQuery.fn["un"+o] = function(f){ return this.unbind(o, f); };
-
- // Finally, handle events that only fire once
- jQuery.fn["one"+o] = function(f){
- // Attach the event listener
- return this.each(function(){
- var count = 0;
- // Add the event
- jQuery.event.add( this, o, function(e){
- // If this function has already been executed, stop
- if ( count++ ) return;
-
- // And execute the bound function
- return f.apply(this, [e]);
- });
- });
- };
-
- };
-
- // If Mozilla is used
- if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
-
- // If IE is used, use the excellent hack by Matthias Miller
- // http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
- } else if ( jQuery.browser.msie ) {
-
- // Only works if you document.write() it
- document.write("<scr" + "ipt id=__ie_init defer=true " +
- "src=//:></script>");
-
- // Use the defer script hack
- var script = document.getElementById("__ie_init");
- script.onreadystatechange = function() {
- if ( this.readyState != "complete" ) return;
- this.parentNode.removeChild( this );
- jQuery.ready();
- };
-
- // Clear from memory
- script = null;
-
- // If Safari is used
- } else if ( jQuery.browser.safari ) {
- // Continually check to see if the document.readyState is valid
- jQuery.safariTimer = setInterval(function(){
- // loaded and complete are both valid states
- if ( document.readyState == "loaded" ||
- document.readyState == "complete" ) {
-
- // If either one are found, remove the timer
- clearInterval( jQuery.safariTimer );
- jQuery.safariTimer = null;
-
- // and execute any waiting functions
- jQuery.ready();
- }
- }, 10);
- }
- // A fallback to window.onload, that will always work
- jQuery.event.add( window, "load", jQuery.ready );
-
- };
- jQuery.fn.extend({
- // overwrite the old show method
- _show: jQuery.fn.show,
-
- /**
- * Show all matched elements using a graceful animation.
- * The height, width, and opacity of each of the matched elements
- * are changed dynamically according to the specified speed.
- *
- * @example $("p").show("slow");
- *
- * @name show
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Show all matched elements using a graceful animation and firing a callback
- * function after completion.
- * The height, width, and opacity of each of the matched elements
- * are changed dynamically according to the specified speed.
- *
- * @example $("p").show("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name show
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- show: function(speed,callback){
- return speed ? this.animate({
- height: "show", width: "show", opacity: "show"
- }, speed, callback) : this._show();
- },
-
- // Overwrite the old hide method
- _hide: jQuery.fn.hide,
-
- /**
- * Hide all matched elements using a graceful animation.
- * The height, width, and opacity of each of the matched elements
- * are changed dynamically according to the specified speed.
- *
- * @example $("p").hide("slow");
- *
- * @name hide
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Hide all matched elements using a graceful animation and firing a callback
- * function after completion.
- * The height, width, and opacity of each of the matched elements
- * are changed dynamically according to the specified speed.
- *
- * @example $("p").hide("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name hide
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- hide: function(speed,callback){
- return speed ? this.animate({
- height: "hide", width: "hide", opacity: "hide"
- }, speed, callback) : this._hide();
- },
-
- /**
- * Reveal all matched elements by adjusting their height.
- * Only the height is adjusted for this animation, causing all matched
- * elements to be revealed in a "sliding" manner.
- *
- * @example $("p").slideDown("slow");
- *
- * @name slideDown
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Reveal all matched elements by adjusting their height and firing a callback
- * function after completion.
- * Only the height is adjusted for this animation, causing all matched
- * elements to be revealed in a "sliding" manner.
- *
- * @example $("p").slideDown("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name slideDown
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- slideDown: function(speed,callback){
- return this.animate({height: "show"}, speed, callback);
- },
-
- /**
- * Hide all matched elements by adjusting their height.
- * Only the height is adjusted for this animation, causing all matched
- * elements to be hidden in a "sliding" manner.
- *
- * @example $("p").slideUp("slow");
- *
- * @name slideUp
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Hide all matched elements by adjusting their height and firing a callback
- * function after completion.
- * Only the height is adjusted for this animation, causing all matched
- * elements to be hidden in a "sliding" manner.
- *
- * @example $("p").slideUp("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name slideUp
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- slideUp: function(speed,callback){
- return this.animate({height: "hide"}, speed, callback);
- },
- /**
- * Toggle the visibility of all matched elements by adjusting their height.
- * Only the height is adjusted for this animation, causing all matched
- * elements to be hidden in a "sliding" manner.
- *
- * @example $("p").slideToggle("slow");
- *
- * @name slideToggle
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Toggle the visibility of all matched elements by adjusting their height
- * and firing a callback function after completion.
- * Only the height is adjusted for this animation, causing all matched
- * elements to be hidden in a "sliding" manner.
- *
- * @example $("p").slideToggle("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name slideToggle
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- slideToggle: function(speed,callback){
- return this.each(function(){
- var state = $(this).is(":hidden") ? "show" : "hide";
- $(this).animate({height: state}, speed, callback);
- });
- },
-
- /**
- * Fade in all matched elements by adjusting their opacity.
- * Only the opacity is adjusted for this animation, meaning that
- * all of the matched elements should already have some form of height
- * and width associated with them.
- *
- * @example $("p").fadeIn("slow");
- *
- * @name fadeIn
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Fade in all matched elements by adjusting their opacity and firing a
- * callback function after completion.
- * Only the opacity is adjusted for this animation, meaning that
- * all of the matched elements should already have some form of height
- * and width associated with them.
- *
- * @example $("p").fadeIn("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name fadeIn
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- fadeIn: function(speed,callback){
- return this.animate({opacity: "show"}, speed, callback);
- },
-
- /**
- * Fade out all matched elements by adjusting their opacity.
- * Only the opacity is adjusted for this animation, meaning that
- * all of the matched elements should already have some form of height
- * and width associated with them.
- *
- * @example $("p").fadeOut("slow");
- *
- * @name fadeOut
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @cat Effects/Animations
- */
-
- /**
- * Fade out all matched elements by adjusting their opacity and firing a
- * callback function after completion.
- * Only the opacity is adjusted for this animation, meaning that
- * all of the matched elements should already have some form of height
- * and width associated with them.
- *
- * @example $("p").fadeOut("slow",function(){
- * alert("Animation Done.");
- * });
- *
- * @name fadeOut
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- fadeOut: function(speed,callback){
- return this.animate({opacity: "hide"}, speed, callback);
- },
-
- /**
- * Fade the opacity of all matched elements to a specified opacity.
- * Only the opacity is adjusted for this animation, meaning that
- * all of the matched elements should already have some form of height
- * and width associated with them.
- *
- * @example $("p").fadeTo("slow", 0.5);
- *
- * @name fadeTo
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Number opacity The opacity to fade to (a number from 0 to 1).
- * @cat Effects/Animations
- */
-
- /**
- * Fade the opacity of all matched elements to a specified opacity and
- * firing a callback function after completion.
- * Only the opacity is adjusted for this animation, meaning that
- * all of the matched elements should already have some form of height
- * and width associated with them.
- *
- * @example $("p").fadeTo("slow", 0.5, function(){
- * alert("Animation Done.");
- * });
- *
- * @name fadeTo
- * @type jQuery
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Number opacity The opacity to fade to (a number from 0 to 1).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- fadeTo: function(speed,to,callback){
- return this.animate({opacity: to}, speed, callback);
- },
-
- /**
- * A function for making your own, custom, animations. The key aspect of
- * this function is the object of style properties that will be animated,
- * and to what end. Each key within the object represents a style property
- * that will also be animated (for example: "height", "top", or "opacity").
- *
- * The value associated with the key represents to what end the property
- * will be animated. If a number is provided as the value, then the style
- * property will be transitioned from its current state to that new number.
- * Oterwise if the string "hide", "show", or "toggle" is provided, a default
- * animation will be constructed for that property.
- *
- * @example $("p").animate({
- * height: 'toggle', opacity: 'toggle'
- * }, "slow");
- *
- * @example $("p").animate({
- * left: 50, opacity: 'show'
- * }, 500);
- *
- * @name animate
- * @type jQuery
- * @param Hash params A set of style attributes that you wish to animate, and to what end.
- * @param Object speed A string representing one of the three predefined speeds ("slow", "normal", or "fast") or the number of milliseconds to run the animation (e.g. 1000).
- * @param Function callback A function to be executed whenever the animation completes.
- * @cat Effects/Animations
- */
- animate: function(prop,speed,callback) {
- return this.queue(function(){
-
- this.curAnim = prop;
-
- for ( var p in prop ) {
- var e = new jQuery.fx( this, jQuery.speed(speed,callback), p );
- if ( prop[p].constructor == Number )
- e.custom( e.cur(), prop[p] );
- else
- e[ prop[p] ]( prop );
- }
-
- });
- },
-
- /**
- *
- * @private
- */
- queue: function(type,fn){
- if ( !fn ) {
- fn = type;
- type = "fx";
- }
-
- return this.each(function(){
- if ( !this.queue )
- this.queue = {};
-
- if ( !this.queue[type] )
- this.queue[type] = [];
-
- this.queue[type].push( fn );
-
- if ( this.queue[type].length == 1 )
- fn.apply(this);
- });
- }
- });
- jQuery.extend({
- setAuto: function(e,p) {
- if ( e.notAuto ) return;
- if ( p == "height" && e.scrollHeight != parseInt(jQuery.curCSS(e,p)) ) return;
- if ( p == "width" && e.scrollWidth != parseInt(jQuery.curCSS(e,p)) ) return;
- // Remember the original height
- var a = e.style[p];
- // Figure out the size of the height right now
- var o = jQuery.curCSS(e,p,1);
- if ( p == "height" && e.scrollHeight != o ||
- p == "width" && e.scrollWidth != o ) return;
- // Set the height to auto
- e.style[p] = e.currentStyle ? "" : "auto";
- // See what the size of "auto" is
- var n = jQuery.curCSS(e,p,1);
- // Revert back to the original size
- if ( o != n && n != "auto" ) {
- e.style[p] = a;
- e.notAuto = true;
- }
- },
-
- speed: function(s,o) {
- o = o || {};
-
- if ( o.constructor == Function )
- o = { complete: o };
-
- var ss = { slow: 600, fast: 200 };
- o.duration = (s && s.constructor == Number ? s : ss[s]) || 400;
-
- // Queueing
- o.oldComplete = o.complete;
- o.complete = function(){
- jQuery.dequeue(this, "fx");
- if ( o.oldComplete && o.oldComplete.constructor == Function )
- o.oldComplete.apply( this );
- };
-
- return o;
- },
-
- queue: {},
-
- dequeue: function(elem,type){
- type = type || "fx";
-
- if ( elem.queue && elem.queue[type] ) {
- // Remove self
- elem.queue[type].shift();
-
- // Get next function
- var f = elem.queue[type][0];
-
- if ( f ) f.apply( elem );
- }
- },
- /*
- * I originally wrote fx() as a clone of moo.fx and in the process
- * of making it small in size the code became illegible to sane
- * people. You've been warned.
- */
-
- fx: function( elem, options, prop ){
-
- var z = this;
-
- // The users options
- z.o = {
- duration: options.duration || 400,
- complete: options.complete,
- step: options.step
- };
-
- // The element
- z.el = elem;
-
- // The styles
- var y = z.el.style;
-
- // Simple function for setting a style value
- z.a = function(){
- if ( options.step )
- options.step.apply( elem, [ z.now ] );
- if ( prop == "opacity" ) {
- if (jQuery.browser.mozilla && z.now == 1) z.now = 0.9999;
- if (window.ActiveXObject)
- y.filter = "alpha(opacity=" + z.now*100 + ")";
- else
- y.opacity = z.now;
- // My hate for IE will never die
- } else if ( parseInt(z.now) )
- y[prop] = parseInt(z.now) + "px";
-
- y.display = "block";
- };
-
- // Figure out the maximum number to run to
- z.max = function(){
- return parseFloat( jQuery.css(z.el,prop) );
- };
-
- // Get the current size
- z.cur = function(){
- var r = parseFloat( jQuery.curCSS(z.el, prop) );
- return r && r > -10000 ? r : z.max();
- };
-
- // Start an animation from one number to another
- z.custom = function(from,to){
- z.startTime = (new Date()).getTime();
- z.now = from;
- z.a();
-
- z.timer = setInterval(function(){
- z.step(from, to);
- }, 13);
- };
-
- // Simple 'show' function
- z.show = function( p ){
- if ( !z.el.orig ) z.el.orig = {};
- // Remember where we started, so that we can go back to it later
- z.el.orig[prop] = this.cur();
- z.custom( 0, z.el.orig[prop] );
- // Stupid IE, look what you made me do
- if ( prop != "opacity" )
- y[prop] = "1px";
- };
-
- // Simple 'hide' function
- z.hide = function(){
- if ( !z.el.orig ) z.el.orig = {};
- // Remember where we started, so that we can go back to it later
- z.el.orig[prop] = this.cur();
- z.o.hide = true;
- // Begin the animation
- z.custom(z.el.orig[prop], 0);
- };
-
- // IE has trouble with opacity if it does not have layout
- if ( jQuery.browser.msie && !z.el.currentStyle.hasLayout )
- y.zoom = "1";
-
- // Remember the overflow of the element
- if ( !z.el.oldOverlay )
- z.el.oldOverflow = jQuery.css( z.el, "overflow" );
-
- // Make sure that nothing sneaks out
- y.overflow = "hidden";
-
- // Each step of an animation
- z.step = function(firstNum, lastNum){
- var t = (new Date()).getTime();
-
- if (t > z.o.duration + z.startTime) {
- // Stop the timer
- clearInterval(z.timer);
- z.timer = null;
- z.now = lastNum;
- z.a();
- z.el.curAnim[ prop ] = true;
-
- var done = true;
- for ( var i in z.el.curAnim )
- if ( z.el.curAnim[i] !== true )
- done = false;
-
- if ( done ) {
- // Reset the overflow
- y.overflow = z.el.oldOverflow;
-
- // Hide the element if the "hide" operation was done
- if ( z.o.hide )
- y.display = 'none';
-
- // Reset the property, if the item has been hidden
- if ( z.o.hide ) {
- for ( var p in z.el.curAnim ) {
- y[ p ] = z.el.orig[p] + ( p == "opacity" ? "" : "px" );
-
- // set its height and/or width to auto
- if ( p == 'height' || p == 'width' )
- jQuery.setAuto( z.el, p );
- }
- }
- }
- // If a callback was provided, execute it
- if( done && z.o.complete && z.o.complete.constructor == Function )
- // Execute the complete function
- z.o.complete.apply( z.el );
- } else {
- // Figure out where in the animation we are and set the number
- var p = (t - this.startTime) / z.o.duration;
- z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
-
- // Perform the next step of the animation
- z.a();
- }
- };
-
- }
- });
- // AJAX Plugin
- // Docs Here:
- // http://jquery.com/docs/ajax/
- /**
- * Load HTML from a remote file and inject it into the DOM, only if it's
- * been modified by the server.
- *
- * @example $("#feeds").loadIfModified("feeds.html")
- * @before <div id="feeds"></div>
- * @result <div id="feeds"><b>45</b> feeds found.</div>
- *
- * @name loadIfModified
- * @type jQuery
- * @param String url The URL of the HTML file to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- jQuery.fn.loadIfModified = function( url, params, callback ) {
- this.load( url, params, callback, 1 );
- };
- /**
- * Load HTML from a remote file and inject it into the DOM.
- *
- * @example $("#feeds").load("feeds.html")
- * @before <div id="feeds"></div>
- * @result <div id="feeds"><b>45</b> feeds found.</div>
- *
- * @name load
- * @type jQuery
- * @param String url The URL of the HTML file to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- jQuery.fn.load = function( url, params, callback, ifModified ) {
- if ( url.constructor == Function )
- return this.bind("load", url);
- callback = callback || function(){};
- // Default to a GET request
- var type = "GET";
- // If the second parameter was provided
- if ( params ) {
- // If it's a function
- if ( params.constructor == Function ) {
- // We assume that it's the callback
- callback = params;
- params = null;
-
- // Otherwise, build a param string
- } else {
- params = jQuery.param( params );
- type = "POST";
- }
- }
-
- var self = this;
-
- // Request the remote document
- jQuery.ajax( type, url, params,function(res, status){
-
- if ( status == "success" || !ifModified && status == "notmodified" ) {
- // Inject the HTML into all the matched elements
- self.html(res.responseText).each( callback, [res.responseText, status] );
-
- // Execute all the scripts inside of the newly-injected HTML
- $("script", self).each(function(){
- if ( this.src )
- $.getScript( this.src );
- else
- eval.call( window, this.text || this.textContent || this.innerHTML || "" );
- });
- } else
- callback.apply( self, [res.responseText, status] );
- }, ifModified);
-
- return this;
- };
- /**
- * A function for serializing a set of input elements into
- * a string of data.
- *
- * @example $("input[@type=text]").serialize();
- * @before <input type='text' name='name' value='John'/>
- * <input type='text' name='location' value='Boston'/>
- * @after name=John&location=Boston
- * @desc Serialize a selection of input elements to a string
- *
- * @name serialize
- * @type String
- * @cat AJAX
- */
- jQuery.fn.serialize = function(){
- return $.param( this );
- };
- // If IE is used, create a wrapper for the XMLHttpRequest object
- if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
- XMLHttpRequest = function(){
- return new ActiveXObject(
- navigator.userAgent.indexOf("MSIE 5") >= 0 ?
- "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP"
- );
- };
- // Attach a bunch of functions for handling common AJAX events
- /**
- * Attach a function to be executed whenever an AJAX request begins.
- *
- * @example $("#loading").ajaxStart(function(){
- * $(this).show();
- * });
- * @desc Show a loading message whenever an AJAX request starts.
- *
- * @name ajaxStart
- * @type jQuery
- * @param Function callback The function to execute.
- * @cat AJAX
- */
-
- /**
- * Attach a function to be executed whenever all AJAX requests have ended.
- *
- * @example $("#loading").ajaxStop(function(){
- * $(this).hide();
- * });
- * @desc Hide a loading message after all the AJAX requests have stopped.
- *
- * @name ajaxStop
- * @type jQuery
- * @param Function callback The function to execute.
- * @cat AJAX
- */
-
- /**
- * Attach a function to be executed whenever an AJAX request completes.
- *
- * @example $("#msg").ajaxComplete(function(){
- * $(this).append("<li>Request Complete.</li>");
- * });
- * @desc Show a message when an AJAX request completes.
- *
- * @name ajaxComplete
- * @type jQuery
- * @param Function callback The function to execute.
- * @cat AJAX
- */
-
- /**
- * Attach a function to be executed whenever an AJAX request completes
- * successfully.
- *
- * @example $("#msg").ajaxSuccess(function(){
- * $(this).append("<li>Successful Request!</li>");
- * });
- * @desc Show a message when an AJAX request completes successfully.
- *
- * @name ajaxSuccess
- * @type jQuery
- * @param Function callback The function to execute.
- * @cat AJAX
- */
-
- /**
- * Attach a function to be executed whenever an AJAX request fails.
- *
- * @example $("#msg").ajaxError(function(){
- * $(this).append("<li>Error requesting page.</li>");
- * });
- * @desc Show a message when an AJAX request fails.
- *
- * @name ajaxError
- * @type jQuery
- * @param Function callback The function to execute.
- * @cat AJAX
- */
- new function(){
- var e = "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess".split(",");
-
- for ( var i = 0; i < e.length; i++ ) new function(){
- var o = e[i];
- jQuery.fn[o] = function(f){
- return this.bind(o, f);
- };
- };
- };
- jQuery.extend({
- /**
- * Load a remote page using an HTTP GET request. All of the arguments to
- * the method (except URL) are optional.
- *
- * @example $.get("test.cgi")
- *
- * @example $.get("test.cgi", { name: "John", time: "2pm" } )
- *
- * @example $.get("test.cgi", function(data){
- * alert("Data Loaded: " + data);
- * })
- *
- * @example $.get("test.cgi",
- * { name: "John", time: "2pm" },
- * function(data){
- * alert("Data Loaded: " + data);
- * }
- * )
- *
- * @name $.get
- * @type jQuery
- * @param String url The URL of the page to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- get: function( url, data, callback, type, ifModified ) {
- if ( data.constructor == Function ) {
- type = callback;
- callback = data;
- data = null;
- }
-
- if ( data ) url += "?" + jQuery.param(data);
-
- // Build and start the HTTP Request
- jQuery.ajax( "GET", url, null, function(r, status) {
- if ( callback ) callback( jQuery.httpData(r,type), status );
- }, ifModified);
- },
-
- /**
- * Load a remote page using an HTTP GET request, only if it hasn't
- * been modified since it was last retrieved. All of the arguments to
- * the method (except URL) are optional.
- *
- * @example $.getIfModified("test.html")
- *
- * @example $.getIfModified("test.html", { name: "John", time: "2pm" } )
- *
- * @example $.getIfModified("test.cgi", function(data){
- * alert("Data Loaded: " + data);
- * })
- *
- * @example $.getifModified("test.cgi",
- * { name: "John", time: "2pm" },
- * function(data){
- * alert("Data Loaded: " + data);
- * }
- * )
- *
- * @name $.getIfModified
- * @type jQuery
- * @param String url The URL of the page to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- getIfModified: function( url, data, callback, type ) {
- jQuery.get(url, data, callback, type, 1);
- },
- /**
- * Loads, and executes, a remote JavaScript file using an HTTP GET request.
- * All of the arguments to the method (except URL) are optional.
- *
- * @example $.getScript("test.js")
- *
- * @example $.getScript("test.js", function(){
- * alert("Script loaded and executed.");
- * })
- *
- *
- * @name $.getScript
- * @type jQuery
- * @param String url The URL of the page to load.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- getScript: function( url, data, callback ) {
- jQuery.get(url, data, callback, "script");
- },
-
- /**
- * Load a remote JSON object using an HTTP GET request.
- * All of the arguments to the method (except URL) are optional.
- *
- * @example $.getJSON("test.js", function(json){
- * alert("JSON Data: " + json.users[3].name);
- * })
- *
- * @example $.getJSON("test.js",
- * { name: "John", time: "2pm" },
- * function(json){
- * alert("JSON Data: " + json.users[3].name);
- * }
- * )
- *
- * @name $.getJSON
- * @type jQuery
- * @param String url The URL of the page to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- getJSON: function( url, data, callback ) {
- jQuery.get(url, data, callback, "json");
- },
-
- /**
- * Load a remote page using an HTTP POST request. All of the arguments to
- * the method (except URL) are optional.
- *
- * @example $.post("test.cgi")
- *
- * @example $.post("test.cgi", { name: "John", time: "2pm" } )
- *
- * @example $.post("test.cgi", function(data){
- * alert("Data Loaded: " + data);
- * })
- *
- * @example $.post("test.cgi",
- * { name: "John", time: "2pm" },
- * function(data){
- * alert("Data Loaded: " + data);
- * }
- * )
- *
- * @name $.post
- * @type jQuery
- * @param String url The URL of the page to load.
- * @param Hash params A set of key/value pairs that will be sent to the server.
- * @param Function callback A function to be executed whenever the data is loaded.
- * @cat AJAX
- */
- post: function( url, data, callback, type ) {
- // Build and start the HTTP Request
- jQuery.ajax( "POST", url, jQuery.param(data), function(r, status) {
- if ( callback ) callback( jQuery.httpData(r,type), status );
- });
- },
-
- // timeout (ms)
- timeout: 0,
- /**
- * Set the timeout of all AJAX requests to a specific amount of time.
- * This will make all future AJAX requests timeout after a specified amount
- * of time (the default is no timeout).
- *
- * @example $.ajaxTimeout( 5000 );
- * @desc Make all AJAX requests timeout after 5 seconds.
- *
- * @name $.ajaxTimeout
- * @type jQuery
- * @param Number time How long before an AJAX request times out.
- * @cat AJAX
- */
- ajaxTimeout: function(timeout) {
- jQuery.timeout = timeout;
- },
- // Last-Modified header cache for next request
- lastModified: {},
-
- /**
- * Load a remote page using an HTTP request. This function is the primary
- * means of making AJAX requests using jQuery. $.ajax() takes one property,
- * an object of key/value pairs, that're are used to initalize the request.
- *
- * These are all the key/values that can be passed in to 'prop':
- *
- * (String) type - The type of request to make (e.g. "POST" or "GET").
- *
- * (String) url - The URL of the page to request.
- *
- * (String) data - A string of data to be sent to the server (POST only).
- *
- * (String) dataType - The type of data that you're expecting back from
- * the server (e.g. "xml", "html", "script", or "json").
- *
- * (Function) error - A function to be called if the request fails. The
- * function gets passed two arguments: The XMLHttpRequest object and a
- * string describing the type of error that occurred.
- *
- * (Function) success - A function to be called if the request succeeds. The
- * function gets passed one argument: The data returned from the server,
- * formatted according to the 'dataType' parameter.
- *
- * (Function) complete - A function to be called when the request finishes. The
- * function gets passed two arguments: The XMLHttpRequest object and a
- * string describing the type the success of the request.
- *
- * @example $.ajax({
- * type: "GET",
- * url: "test.js",
- * dataType: "script"
- * })
- * @desc Load and execute a JavaScript file.
- *
- * @example $.ajax({
- * type: "POST",
- * url: "some.php",
- * data: "name=John&location=Boston",
- * success: function(msg){
- * alert( "Data Saved: " + msg );
- * }
- * });
- * @desc Save some data to the server and notify the user once its complete.
- *
- * @name $.ajax
- * @type jQuery
- * @param Hash prop A set of properties to initialize the request with.
- * @cat AJAX
- */
- ajax: function( type, url, data, ret, ifModified ) {
- // If only a single argument was passed in,
- // assume that it is a object of key/value pairs
- if ( !url ) {
- ret = type.complete;
- var success = type.success;
- var error = type.error;
- var dataType = type.dataType;
- data = type.data;
- url = type.url;
- type = type.type;
- }
-
- // Watch for a new set of requests
- if ( ! jQuery.active++ )
- jQuery.event.trigger( "ajaxStart" );
- var requestDone = false;
-
- // Create the request object
- var xml = new XMLHttpRequest();
-
- // Open the socket
- xml.open(type || "GET", url, true);
-
- // Set the correct header, if data is being sent
- if ( data )
- xml.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-
- // Set the If-Modified-Since header, if ifModified mode.
- if ( ifModified )
- xml.setRequestHeader("If-Modified-Since",
- jQuery.lastModified[url] || "Thu, 01 Jan 1970 00:00:00 GMT" );
-
- // Set header so calling script knows that it's an XMLHttpRequest
- xml.setRequestHeader("X-Requested-With", "XMLHttpRequest");
-
- // Make sure the browser sends the right content length
- if ( xml.overrideMimeType )
- xml.setRequestHeader("Connection", "close");
-
- // Wait for a response to come back
- var onreadystatechange = function(istimeout){
- // The transfer is complete and the data is available, or the request timed out
- if ( xml && (xml.readyState == 4 || istimeout == "timeout") ) {
- requestDone = true;
- var status = jQuery.httpSuccess( xml ) && istimeout != "timeout" ?
- ifModified && jQuery.httpNotModified( xml, url ) ? "notmodified" : "success" : "error";
-
- // Make sure that the request was successful or notmodified
- if ( status != "error" ) {
- // Cache Last-Modified header, if ifModified mode.
- var modRes = xml.getResponseHeader("Last-Modified");
- if ( ifModified && modRes ) jQuery.lastModified[url] = modRes;
-
- // If a local callback was specified, fire it
- if ( success )
- success( jQuery.httpData( xml, dataType ), status );
-
- // Fire the global callback
- jQuery.event.trigger( "ajaxSuccess" );
-
- // Otherwise, the request was not successful
- } else {
- // If a local callback was specified, fire it
- if ( error ) error( xml, status );
-
- // Fire the global callback
- jQuery.event.trigger( "ajaxError" );
- }
-
- // The request was completed
- jQuery.event.trigger( "ajaxComplete" );
-
- // Handle the global AJAX counter
- if ( ! --jQuery.active )
- jQuery.event.trigger( "ajaxStop" );
-
- // Process result
- if ( ret ) ret(xml, status);
-
- // Stop memory leaks
- xml.onreadystatechange = function(){};
- xml = null;
-
- }
- };
- xml.onreadystatechange = onreadystatechange;
-
- // Timeout checker
- if(jQuery.timeout > 0)
- setTimeout(function(){
- // Check to see if the request is still happening
- if (xml) {
- // Cancel the request
- xml.abort();
- if ( !requestDone ) onreadystatechange( "timeout" );
- // Clear from memory
- xml = null;
- }
- }, jQuery.timeout);
-
- // Send the data
- xml.send(data);
- },
-
- // Counter for holding the number of active queries
- active: 0,
-
- // Determines if an XMLHttpRequest was successful or not
- httpSuccess: function(r) {
- try {
- return !r.status && location.protocol == "file:" ||
- ( r.status >= 200 && r.status < 300 ) || r.status == 304 ||
- jQuery.browser.safari && r.status == undefined;
- } catch(e){}
- return false;
- },
- // Determines if an XMLHttpRequest returns NotModified
- httpNotModified: function(xml, url) {
- try {
- var xmlRes = xml.getResponseHeader("Last-Modified");
- // Firefox always returns 200. check Last-Modified date
- return xml.status == 304 || xmlRes == jQuery.lastModified[url] ||
- jQuery.browser.safari && xml.status == undefined;
- } catch(e){}
- return false;
- },
-
- /* Get the data out of an XMLHttpRequest.
- * Return parsed XML if content-type header is "xml" and type is "xml" or omitted,
- * otherwise return plain text.
- * (String) data - The type of data that you're expecting back,
- * (e.g. "xml", "html", "script")
- */
- httpData: function(r,type) {
- var ct = r.getResponseHeader("content-type");
- var data = !type && ct && ct.indexOf("xml") >= 0;
- data = type == "xml" || data ? r.responseXML : r.responseText;
- // If the type is "script", eval it
- if ( type == "script" ) eval.call( window, data );
- // Get the JavaScript object, if JSON is used.
- if ( type == "json" ) eval( "data = " + data );
- return data;
- },
-
- // Serialize an array of form elements or a set of
- // key/values into a query string
- param: function(a) {
- var s = [];
-
- // If an array was passed in, assume that it is an array
- // of form elements
- if ( a.constructor == Array || a.jquery ) {
- // Serialize the form elements
- for ( var i = 0; i < a.length; i++ )
- s.push( a[i].name + "=" + encodeURIComponent( a[i].value ) );
-
- // Otherwise, assume that it's an object of key/value pairs
- } else {
- // Serialize the key/values
- for ( var j in a )
- s.push( j + "=" + encodeURIComponent( a[j] ) );
- }
-
- // Return the resulting serialization
- return s.join("&");
- }
- });