Aluf

jQuery JavaScript Library v1.6.1

Jan 25th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 69.57 KB | None | 0 0
  1. /*!
  2.  * jQuery JavaScript Library v1.6.1
  3.  * http://jquery.com/
  4.  * BY ALUF  @2015
  5.  * Dual licensed under the MIT or GPL Version 2 licenses.
  6.  * http://jquery.org/license
  7.  *
  8.  * Includes Sizzle.js
  9.  * http://sizzlejs.com/
  10.  * Copyright 2011, The Dojo Foundation
  11.  * Released under the MIT, BSD, and GPL Licenses.
  12.  *
  13.  * Date: Thu May 12 15:04:36 2011 -0400
  14.  */
  15.  
  16. (function( window, undefined ) {
  17.  
  18. // Use the correct document accordingly with window argument (sandbox)
  19. var document = window.document,
  20.         navigator = window.navigator,
  21.         location = window.location;
  22. var jQuery = (function() {
  23.  
  24. // Define a local copy of jQuery
  25. var jQuery = function( selector, context ) {
  26.                 // The jQuery object is actually just the init constructor 'enhanced'
  27.                 return new jQuery.fn.init( selector, context, rootjQuery );
  28.         },
  29.  
  30.         // Map over jQuery in case of overwrite
  31.         _jQuery = window.jQuery,
  32.  
  33.         // Map over the $ in case of overwrite
  34.         _$ = window.$,
  35.  
  36.         // A central reference to the root jQuery(document)
  37.         rootjQuery,
  38.  
  39.         // A simple way to check for HTML strings or ID strings
  40.         // (both of which we optimize for)
  41.         quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
  42.  
  43.         // Check if a string has a non-whitespace character in it
  44.         rnotwhite = /\S/,
  45.  
  46.         // Used for trimming whitespace
  47.         trimLeft = /^\s+/,
  48.         trimRight = /\s+$/,
  49.  
  50.         // Check for digits
  51.         rdigit = /\d/,
  52.  
  53.         // Match a standalone tag
  54.         rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  55.  
  56.         // JSON RegExp
  57.         rvalidchars = /^[\],:{}\s]*$/,
  58.         rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  59.         rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  60.         rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  61.  
  62.         // Useragent RegExp
  63.         rwebkit = /(webkit)[ \/]([\w.]+)/,
  64.         ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  65.         rmsie = /(msie) ([\w.]+)/,
  66.         rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  67.  
  68.         // Keep a UserAgent string for use with jQuery.browser
  69.         userAgent = navigator.userAgent,
  70.  
  71.         // For matching the engine and version of the browser
  72.         browserMatch,
  73.  
  74.         // The deferred used on DOM ready
  75.         readyList,
  76.  
  77.         // The ready event handler
  78.         DOMContentLoaded,
  79.  
  80.         // Save a reference to some core methods
  81.         toString = Object.prototype.toString,
  82.         hasOwn = Object.prototype.hasOwnProperty,
  83.         push = Array.prototype.push,
  84.         slice = Array.prototype.slice,
  85.         trim = String.prototype.trim,
  86.         indexOf = Array.prototype.indexOf,
  87.  
  88.         // [[Class]] -> type pairs
  89.         class2type = {};
  90.  
  91. jQuery.fn = jQuery.prototype = {
  92.         constructor: jQuery,
  93.         init: function( selector, context, rootjQuery ) {
  94.                 var match, elem, ret, doc;
  95.  
  96.                 // Handle $(""), $(null), or $(undefined)
  97.                 if ( !selector ) {
  98.                         return this;
  99.                 }
  100.  
  101.                 // Handle $(DOMElement)
  102.                 if ( selector.nodeType ) {
  103.                         this.context = this[0] = selector;
  104.                         this.length = 1;
  105.                         return this;
  106.                 }
  107.  
  108.                 // The body element only exists once, optimize finding it
  109.                 if ( selector === "body" && !context && document.body ) {
  110.                         this.context = document;
  111.                         this[0] = document.body;
  112.                         this.selector = selector;
  113.                         this.length = 1;
  114.                         return this;
  115.                 }
  116.  
  117.                 // Handle HTML strings
  118.                 if ( typeof selector === "string" ) {
  119.                         // Are we dealing with HTML string or an ID?
  120.                         if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  121.                                 // Assume that strings that start and end with <> are HTML and skip the regex check
  122.                                 match = [ null, selector, null ];
  123.  
  124.                         } else {
  125.                                 match = quickExpr.exec( selector );
  126.                         }
  127.  
  128.                         // Verify a match, and that no context was specified for #id
  129.                         if ( match && (match[1] || !context) ) {
  130.  
  131.                                 // HANDLE: $(html) -> $(array)
  132.                                 if ( match[1] ) {
  133.                                         context = context instanceof jQuery ? context[0] : context;
  134.                                         doc = (context ? context.ownerDocument || context : document);
  135.  
  136.                                         // If a single string is passed in and it's a single tag
  137.                                         // just do a createElement and skip the rest
  138.                                         ret = rsingleTag.exec( selector );
  139.  
  140.                                         if ( ret ) {
  141.                                                 if ( jQuery.isPlainObject( context ) ) {
  142.                                                         selector = [ document.createElement( ret[1] ) ];
  143.                                                         jQuery.fn.attr.call( selector, context, true );
  144.  
  145.                                                 } else {
  146.                                                         selector = [ doc.createElement( ret[1] ) ];
  147.                                                 }
  148.  
  149.                                         } else {
  150.                                                 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  151.                                                 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
  152.                                         }
  153.  
  154.                                         return jQuery.merge( this, selector );
  155.  
  156.                                 // HANDLE: $("#id")
  157.                                 } else {
  158.                                         elem = document.getElementById( match[2] );
  159.  
  160.                                         // Check parentNode to catch when Blackberry 4.6 returns
  161.                                         // nodes that are no longer in the document #6963
  162.                                         if ( elem && elem.parentNode ) {
  163.                                                 // Handle the case where IE and Opera return items
  164.                                                 // by name instead of ID
  165.                                                 if ( elem.id !== match[2] ) {
  166.                                                         return rootjQuery.find( selector );
  167.                                                 }
  168.  
  169.                                                 // Otherwise, we inject the element directly into the jQuery object
  170.                                                 this.length = 1;
  171.                                                 this[0] = elem;
  172.                                         }
  173.  
  174.                                         this.context = document;
  175.                                         this.selector = selector;
  176.                                         return this;
  177.                                 }
  178.  
  179.                         // HANDLE: $(expr, $(...))
  180.                         } else if ( !context || context.jquery ) {
  181.                                 return (context || rootjQuery).find( selector );
  182.  
  183.                         // HANDLE: $(expr, context)
  184.                         // (which is just equivalent to: $(context).find(expr)
  185.                         } else {
  186.                                 return this.constructor( context ).find( selector );
  187.                         }
  188.  
  189.                 // HANDLE: $(function)
  190.                 // Shortcut for document ready
  191.                 } else if ( jQuery.isFunction( selector ) ) {
  192.                         return rootjQuery.ready( selector );
  193.                 }
  194.  
  195.                 if (selector.selector !== undefined) {
  196.                         this.selector = selector.selector;
  197.                         this.context = selector.context;
  198.                 }
  199.  
  200.                 return jQuery.makeArray( selector, this );
  201.         },
  202.  
  203.         // Start with an empty selector
  204.         selector: "",
  205.  
  206.         // The current version of jQuery being used
  207.         jquery: "1.6.1",
  208.  
  209.         // The default length of a jQuery object is 0
  210.         length: 0,
  211.  
  212.         // The number of elements contained in the matched element set
  213.         size: function() {
  214.                 return this.length;
  215.         },
  216.  
  217.         toArray: function() {
  218.                 return slice.call( this, 0 );
  219.         },
  220.  
  221.         // Get the Nth element in the matched element set OR
  222.         // Get the whole matched element set as a clean array
  223.         get: function( num ) {
  224.                 return num == null ?
  225.  
  226.                         // Return a 'clean' array
  227.                         this.toArray() :
  228.  
  229.                         // Return just the object
  230.                         ( num < 0 ? this[ this.length + num ] : this[ num ] );
  231.         },
  232.  
  233.         // Take an array of elements and push it onto the stack
  234.         // (returning the new matched element set)
  235.         pushStack: function( elems, name, selector ) {
  236.                 // Build a new jQuery matched element set
  237.                 var ret = this.constructor();
  238.  
  239.                 if ( jQuery.isArray( elems ) ) {
  240.                         push.apply( ret, elems );
  241.  
  242.                 } else {
  243.                         jQuery.merge( ret, elems );
  244.                 }
  245.  
  246.                 // Add the old object onto the stack (as a reference)
  247.                 ret.prevObject = this;
  248.  
  249.                 ret.context = this.context;
  250.  
  251.                 if ( name === "find" ) {
  252.                         ret.selector = this.selector + (this.selector ? " " : "") + selector;
  253.                 } else if ( name ) {
  254.                         ret.selector = this.selector + "." + name + "(" + selector + ")";
  255.                 }
  256.  
  257.                 // Return the newly-formed element set
  258.                 return ret;
  259.         },
  260.  
  261.         // Execute a callback for every element in the matched set.
  262.         // (You can seed the arguments with an array of args, but this is
  263.         // only used internally.)
  264.         each: function( callback, args ) {
  265.                 return jQuery.each( this, callback, args );
  266.         },
  267.  
  268.         ready: function( fn ) {
  269.                 // Attach the listeners
  270.                 jQuery.bindReady();
  271.  
  272.                 // Add the callback
  273.                 readyList.done( fn );
  274.  
  275.                 return this;
  276.         },
  277.  
  278.         eq: function( i ) {
  279.                 return i === -1 ?
  280.                         this.slice( i ) :
  281.                         this.slice( i, +i + 1 );
  282.         },
  283.  
  284.         first: function() {
  285.                 return this.eq( 0 );
  286.         },
  287.  
  288.         last: function() {
  289.                 return this.eq( -1 );
  290.         },
  291.  
  292.         slice: function() {
  293.                 return this.pushStack( slice.apply( this, arguments ),
  294.                         "slice", slice.call(arguments).join(",") );
  295.         },
  296.  
  297.         map: function( callback ) {
  298.                 return this.pushStack( jQuery.map(this, function( elem, i ) {
  299.                         return callback.call( elem, i, elem );
  300.                 }));
  301.         },
  302.  
  303.         end: function() {
  304.                 return this.prevObject || this.constructor(null);
  305.         },
  306.  
  307.         // For internal use only.
  308.         // Behaves like an Array's method, not like a jQuery method.
  309.         push: push,
  310.         sort: [].sort,
  311.         splice: [].splice
  312. };
  313.  
  314. // Give the init function the jQuery prototype for later instantiation
  315. jQuery.fn.init.prototype = jQuery.fn;
  316.  
  317. jQuery.extend = jQuery.fn.extend = function() {
  318.         var options, name, src, copy, copyIsArray, clone,
  319.                 target = arguments[0] || {},
  320.                 i = 1,
  321.                 length = arguments.length,
  322.                 deep = false;
  323.  
  324.         // Handle a deep copy situation
  325.         if ( typeof target === "boolean" ) {
  326.                 deep = target;
  327.                 target = arguments[1] || {};
  328.                 // skip the boolean and the target
  329.                 i = 2;
  330.         }
  331.  
  332.         // Handle case when target is a string or something (possible in deep copy)
  333.         if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  334.                 target = {};
  335.         }
  336.  
  337.         // extend jQuery itself if only one argument is passed
  338.         if ( length === i ) {
  339.                 target = this;
  340.                 --i;
  341.         }
  342.  
  343.         for ( ; i < length; i++ ) {
  344.                 // Only deal with non-null/undefined values
  345.                 if ( (options = arguments[ i ]) != null ) {
  346.                         // Extend the base object
  347.                         for ( name in options ) {
  348.                                 src = target[ name ];
  349.                                 copy = options[ name ];
  350.  
  351.                                 // Prevent never-ending loop
  352.                                 if ( target === copy ) {
  353.                                         continue;
  354.                                 }
  355.  
  356.                                 // Recurse if we're merging plain objects or arrays
  357.                                 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  358.                                         if ( copyIsArray ) {
  359.                                                 copyIsArray = false;
  360.                                                 clone = src && jQuery.isArray(src) ? src : [];
  361.  
  362.                                         } else {
  363.                                                 clone = src && jQuery.isPlainObject(src) ? src : {};
  364.                                         }
  365.  
  366.                                         // Never move original objects, clone them
  367.                                         target[ name ] = jQuery.extend( deep, clone, copy );
  368.  
  369.                                 // Don't bring in undefined values
  370.                                 } else if ( copy !== undefined ) {
  371.                                         target[ name ] = copy;
  372.                                 }
  373.                         }
  374.                 }
  375.         }
  376.  
  377.         // Return the modified object
  378.         return target;
  379. };
  380.  
  381. jQuery.extend({
  382.         noConflict: function( deep ) {
  383.                 if ( window.$ === jQuery ) {
  384.                         window.$ = _$;
  385.                 }
  386.  
  387.                 if ( deep && window.jQuery === jQuery ) {
  388.                         window.jQuery = _jQuery;
  389.                 }
  390.  
  391.                 return jQuery;
  392.         },
  393.  
  394.         // Is the DOM ready to be used? Set to true once it occurs.
  395.         isReady: false,
  396.  
  397.         // A counter to track how many items to wait for before
  398.         // the ready event fires. See #6781
  399.         readyWait: 1,
  400.  
  401.         // Hold (or release) the ready event
  402.         holdReady: function( hold ) {
  403.                 if ( hold ) {
  404.                         jQuery.readyWait++;
  405.                 } else {
  406.                         jQuery.ready( true );
  407.                 }
  408.         },
  409.  
  410.         // Handle when the DOM is ready
  411.         ready: function( wait ) {
  412.                 // Either a released hold or an DOMready/load event and not yet ready
  413.                 if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
  414.                         // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  415.                         if ( !document.body ) {
  416.                                 return setTimeout( jQuery.ready, 1 );
  417.                         }
  418.  
  419.                         // Remember that the DOM is ready
  420.                         jQuery.isReady = true;
  421.  
  422.                         // If a normal DOM Ready event fired, decrement, and wait if need be
  423.                         if ( wait !== true && --jQuery.readyWait > 0 ) {
  424.                                 return;
  425.                         }
  426.  
  427.                         // If there are functions bound, to execute
  428.                         readyList.resolveWith( document, [ jQuery ] );
  429.  
  430.                         // Trigger any bound ready events
  431.                         if ( jQuery.fn.trigger ) {
  432.                                 jQuery( document ).trigger( "ready" ).unbind( "ready" );
  433.                         }
  434.                 }
  435.         },
  436.  
  437.         bindReady: function() {
  438.                 if ( readyList ) {
  439.                         return;
  440.                 }
  441.  
  442.                 readyList = jQuery._Deferred();
  443.  
  444.                 // Catch cases where $(document).ready() is called after the
  445.                 // browser event has already occurred.
  446.                 if ( document.readyState === "complete" ) {
  447.                         // Handle it asynchronously to allow scripts the opportunity to delay ready
  448.                         return setTimeout( jQuery.ready, 1 );
  449.                 }
  450.  
  451.                 // Mozilla, Opera and webkit nightlies currently support this event
  452.                 if ( document.addEventListener ) {
  453.                         // Use the handy event callback
  454.                         document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  455.  
  456.                         // A fallback to window.onload, that will always work
  457.                         window.addEventListener( "load", jQuery.ready, false );
  458.  
  459.                 // If IE event model is used
  460.                 } else if ( document.attachEvent ) {
  461.                         // ensure firing before onload,
  462.                         // maybe late but safe also for iframes
  463.                         document.attachEvent( "onreadystatechange", DOMContentLoaded );
  464.  
  465.                         // A fallback to window.onload, that will always work
  466.                         window.attachEvent( "onload", jQuery.ready );
  467.  
  468.                         // If IE and not a frame
  469.                         // continually check to see if the document is ready
  470.                         var toplevel = false;
  471.  
  472.                         try {
  473.                                 toplevel = window.frameElement == null;
  474.                         } catch(e) {}
  475.  
  476.                         if ( document.documentElement.doScroll && toplevel ) {
  477.                                 doScrollCheck();
  478.                         }
  479.                 }
  480.         },
  481.  
  482.         // See test/unit/core.js for details concerning isFunction.
  483.         // Since version 1.3, DOM methods and functions like alert
  484.         // aren't supported. They return false on IE (#2968).
  485.         isFunction: function( obj ) {
  486.                 return jQuery.type(obj) === "function";
  487.         },
  488.  
  489.         isArray: Array.isArray || function( obj ) {
  490.                 return jQuery.type(obj) === "array";
  491.         },
  492.  
  493.         // A crude way of determining if an object is a window
  494.         isWindow: function( obj ) {
  495.                 return obj && typeof obj === "object" && "setInterval" in obj;
  496.         },
  497.  
  498.         isNaN: function( obj ) {
  499.                 return obj == null || !rdigit.test( obj ) || isNaN( obj );
  500.         },
  501.  
  502.         type: function( obj ) {
  503.                 return obj == null ?
  504.                         String( obj ) :
  505.                         class2type[ toString.call(obj) ] || "object";
  506.         },
  507.  
  508.         isPlainObject: function( obj ) {
  509.                 // Must be an Object.
  510.                 // Because of IE, we also have to check the presence of the constructor property.
  511.                 // Make sure that DOM nodes and window objects don't pass through, as well
  512.                 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  513.                         return false;
  514.                 }
  515.  
  516.                 // Not own constructor property must be Object
  517.                 if ( obj.constructor &&
  518.                         !hasOwn.call(obj, "constructor") &&
  519.                         !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  520.                         return false;
  521.                 }
  522.  
  523.                 // Own properties are enumerated firstly, so to speed up,
  524.                 // if last one is own, then all properties are own.
  525.  
  526.                 var key;
  527.                 for ( key in obj ) {}
  528.  
  529.                 return key === undefined || hasOwn.call( obj, key );
  530.         },
  531.  
  532.         isEmptyObject: function( obj ) {
  533.                 for ( var name in obj ) {
  534.                         return false;
  535.                 }
  536.                 return true;
  537.         },
  538.  
  539.         error: function( msg ) {
  540.                 throw msg;
  541.         },
  542.  
  543.         parseJSON: function( data ) {
  544.                 if ( typeof data !== "string" || !data ) {
  545.                         return null;
  546.                 }
  547.  
  548.                 // Make sure leading/trailing whitespace is removed (IE can't handle it)
  549.                 data = jQuery.trim( data );
  550.  
  551.                 // Attempt to parse using the native JSON parser first
  552.                 if ( window.JSON && window.JSON.parse ) {
  553.                         return window.JSON.parse( data );
  554.                 }
  555.  
  556.                 // Make sure the incoming data is actual JSON
  557.                 // Logic borrowed from http://json.org/json2.js
  558.                 if ( rvalidchars.test( data.replace( rvalidescape, "@" )
  559.                         .replace( rvalidtokens, "]" )
  560.                         .replace( rvalidbraces, "")) ) {
  561.  
  562.                         return (new Function( "return " + data ))();
  563.  
  564.                 }
  565.                 jQuery.error( "Invalid JSON: " + data );
  566.         },
  567.  
  568.         // Cross-browser xml parsing
  569.         // (xml & tmp used internally)
  570.         parseXML: function( data , xml , tmp ) {
  571.  
  572.                 if ( window.DOMParser ) { // Standard
  573.                         tmp = new DOMParser();
  574.                         xml = tmp.parseFromString( data , "text/xml" );
  575.                 } else { // IE
  576.                         xml = new ActiveXObject( "Microsoft.XMLDOM" );
  577.                         xml.async = "false";
  578.                         xml.loadXML( data );
  579.                 }
  580.  
  581.                 tmp = xml.documentElement;
  582.  
  583.                 if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
  584.                         jQuery.error( "Invalid XML: " + data );
  585.                 }
  586.  
  587.                 return xml;
  588.         },
  589.  
  590.         noop: function() {},
  591.  
  592.         // Evaluates a script in a global context
  593.         // Workarounds based on findings by Jim Driscoll
  594.         // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  595.         globalEval: function( data ) {
  596.                 if ( data && rnotwhite.test( data ) ) {
  597.                         // We use execScript on Internet Explorer
  598.                         // We use an anonymous function so that context is window
  599.                         // rather than jQuery in Firefox
  600.                         ( window.execScript || function( data ) {
  601.                                 window[ "eval" ].call( window, data );
  602.                         } )( data );
  603.                 }
  604.         },
  605.  
  606.         nodeName: function( elem, name ) {
  607.                 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  608.         },
  609.  
  610.         // args is for internal usage only
  611.         each: function( object, callback, args ) {
  612.                 var name, i = 0,
  613.                         length = object.length,
  614.                         isObj = length === undefined || jQuery.isFunction( object );
  615.  
  616.                 if ( args ) {
  617.                         if ( isObj ) {
  618.                                 for ( name in object ) {
  619.                                         if ( callback.apply( object[ name ], args ) === false ) {
  620.                                                 break;
  621.                                         }
  622.                                 }
  623.                         } else {
  624.                                 for ( ; i < length; ) {
  625.                                         if ( callback.apply( object[ i++ ], args ) === false ) {
  626.                                                 break;
  627.                                         }
  628.                                 }
  629.                         }
  630.  
  631.                 // A special, fast, case for the most common use of each
  632.                 } else {
  633.                         if ( isObj ) {
  634.                                 for ( name in object ) {
  635.                                         if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  636.                                                 break;
  637.                                         }
  638.                                 }
  639.                         } else {
  640.                                 for ( ; i < length; ) {
  641.                                         if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
  642.                                                 break;
  643.                                         }
  644.                                 }
  645.                         }
  646.                 }
  647.  
  648.                 return object;
  649.         },
  650.  
  651.         // Use native String.trim function wherever possible
  652.         trim: trim ?
  653.                 function( text ) {
  654.                         return text == null ?
  655.                                 "" :
  656.                                 trim.call( text );
  657.                 } :
  658.  
  659.                 // Otherwise use our own trimming functionality
  660.                 function( text ) {
  661.                         return text == null ?
  662.                                 "" :
  663.                                 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  664.                 },
  665.  
  666.         // results is for internal usage only
  667.         makeArray: function( array, results ) {
  668.                 var ret = results || [];
  669.  
  670.                 if ( array != null ) {
  671.                         // The window, strings (and functions) also have 'length'
  672.                         // The extra typeof function check is to prevent crashes
  673.                         // in Safari 2 (See: #3039)
  674.                         // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  675.                         var type = jQuery.type( array );
  676.  
  677.                         if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  678.                                 push.call( ret, array );
  679.                         } else {
  680.                                 jQuery.merge( ret, array );
  681.                         }
  682.                 }
  683.  
  684.                 return ret;
  685.         },
  686.  
  687.         inArray: function( elem, array ) {
  688.  
  689.                 if ( indexOf ) {
  690.                         return indexOf.call( array, elem );
  691.                 }
  692.  
  693.                 for ( var i = 0, length = array.length; i < length; i++ ) {
  694.                         if ( array[ i ] === elem ) {
  695.                                 return i;
  696.                         }
  697.                 }
  698.  
  699.                 return -1;
  700.         },
  701.  
  702.         merge: function( first, second ) {
  703.                 var i = first.length,
  704.                         j = 0;
  705.  
  706.                 if ( typeof second.length === "number" ) {
  707.                         for ( var l = second.length; j < l; j++ ) {
  708.                                 first[ i++ ] = second[ j ];
  709.                         }
  710.  
  711.                 } else {
  712.                         while ( second[j] !== undefined ) {
  713.                                 first[ i++ ] = second[ j++ ];
  714.                         }
  715.                 }
  716.  
  717.                 first.length = i;
  718.  
  719.                 return first;
  720.         },
  721.  
  722.         grep: function( elems, callback, inv ) {
  723.                 var ret = [], retVal;
  724.                 inv = !!inv;
  725.  
  726.                 // Go through the array, only saving the items
  727.                 // that pass the validator function
  728.                 for ( var i = 0, length = elems.length; i < length; i++ ) {
  729.                         retVal = !!callback( elems[ i ], i );
  730.                         if ( inv !== retVal ) {
  731.                                 ret.push( elems[ i ] );
  732.                         }
  733.                 }
  734.  
  735.                 return ret;
  736.         },
  737.  
  738.         // arg is for internal usage only
  739.         map: function( elems, callback, arg ) {
  740.                 var value, key, ret = [],
  741.                         i = 0,
  742.                         length = elems.length,
  743.                         // jquery objects are treated as arrays
  744.                         isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
  745.  
  746.                 // Go through the array, translating each of the items to their
  747.                 if ( isArray ) {
  748.                         for ( ; i < length; i++ ) {
  749.                                 value = callback( elems[ i ], i, arg );
  750.  
  751.                                 if ( value != null ) {
  752.                                         ret[ ret.length ] = value;
  753.                                 }
  754.                         }
  755.  
  756.                 // Go through every key on the object,
  757.                 } else {
  758.                         for ( key in elems ) {
  759.                                 value = callback( elems[ key ], key, arg );
  760.  
  761.                                 if ( value != null ) {
  762.                                         ret[ ret.length ] = value;
  763.                                 }
  764.                         }
  765.                 }
  766.  
  767.                 // Flatten any nested arrays
  768.                 return ret.concat.apply( [], ret );
  769.         },
  770.  
  771.         // A global GUID counter for objects
  772.         guid: 1,
  773.  
  774.         // Bind a function to a context, optionally partially applying any
  775.         // arguments.
  776.         proxy: function( fn, context ) {
  777.                 if ( typeof context === "string" ) {
  778.                         var tmp = fn[ context ];
  779.                         context = fn;
  780.                         fn = tmp;
  781.                 }
  782.  
  783.                 // Quick check to determine if target is callable, in the spec
  784.                 // this throws a TypeError, but we will just return undefined.
  785.                 if ( !jQuery.isFunction( fn ) ) {
  786.                         return undefined;
  787.                 }
  788.  
  789.                 // Simulated bind
  790.                 var args = slice.call( arguments, 2 ),
  791.                         proxy = function() {
  792.                                 return fn.apply( context, args.concat( slice.call( arguments ) ) );
  793.                         };
  794.  
  795.                 // Set the guid of unique handler to the same of original handler, so it can be removed
  796.                 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  797.  
  798.                 return proxy;
  799.         },
  800.  
  801.         // Mutifunctional method to get and set values to a collection
  802.         // The value/s can be optionally by executed if its a function
  803.         access: function( elems, key, value, exec, fn, pass ) {
  804.                 var length = elems.length;
  805.  
  806.                 // Setting many attributes
  807.                 if ( typeof key === "object" ) {
  808.                         for ( var k in key ) {
  809.                                 jQuery.access( elems, k, key[k], exec, fn, value );
  810.                         }
  811.                         return elems;
  812.                 }
  813.  
  814.                 // Setting one attribute
  815.                 if ( value !== undefined ) {
  816.                         // Optionally, function values get executed if exec is true
  817.                         exec = !pass && exec && jQuery.isFunction(value);
  818.  
  819.                         for ( var i = 0; i < length; i++ ) {
  820.                                 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  821.                         }
  822.  
  823.                         return elems;
  824.                 }
  825.  
  826.                 // Getting an attribute
  827.                 return length ? fn( elems[0], key ) : undefined;
  828.         },
  829.  
  830.         now: function() {
  831.                 return (new Date()).getTime();
  832.         },
  833.  
  834.         // Use of jQuery.browser is frowned upon.
  835.         // More details: http://docs.jquery.com/Utilities/jQuery.browser
  836.         uaMatch: function( ua ) {
  837.                 ua = ua.toLowerCase();
  838.  
  839.                 var match = rwebkit.exec( ua ) ||
  840.                         ropera.exec( ua ) ||
  841.                         rmsie.exec( ua ) ||
  842.                         ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  843.                         [];
  844.  
  845.                 return { browser: match[1] || "", version: match[2] || "0" };
  846.         },
  847.  
  848.         sub: function() {
  849.                 function jQuerySub( selector, context ) {
  850.                         return new jQuerySub.fn.init( selector, context );
  851.                 }
  852.                 jQuery.extend( true, jQuerySub, this );
  853.                 jQuerySub.superclass = this;
  854.                 jQuerySub.fn = jQuerySub.prototype = this();
  855.                 jQuerySub.fn.constructor = jQuerySub;
  856.                 jQuerySub.sub = this.sub;
  857.                 jQuerySub.fn.init = function init( selector, context ) {
  858.                         if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
  859.                                 context = jQuerySub( context );
  860.                         }
  861.  
  862.                         return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
  863.                 };
  864.                 jQuerySub.fn.init.prototype = jQuerySub.fn;
  865.                 var rootjQuerySub = jQuerySub(document);
  866.                 return jQuerySub;
  867.         },
  868.  
  869.         browser: {}
  870. });
  871.  
  872. // Populate the class2type map
  873. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  874.         class2type[ "[object " + name + "]" ] = name.toLowerCase();
  875. });
  876.  
  877. browserMatch = jQuery.uaMatch( userAgent );
  878. if ( browserMatch.browser ) {
  879.         jQuery.browser[ browserMatch.browser ] = true;
  880.         jQuery.browser.version = browserMatch.version;
  881. }
  882.  
  883. // Deprecated, use jQuery.browser.webkit instead
  884. if ( jQuery.browser.webkit ) {
  885.         jQuery.browser.safari = true;
  886. }
  887.  
  888. // IE doesn't match non-breaking spaces with \s
  889. if ( rnotwhite.test( "\xA0" ) ) {
  890.         trimLeft = /^[\s\xA0]+/;
  891.         trimRight = /[\s\xA0]+$/;
  892. }
  893.  
  894. // All jQuery objects should point back to these
  895. rootjQuery = jQuery(document);
  896.  
  897. // Cleanup functions for the document ready method
  898. if ( document.addEventListener ) {
  899.         DOMContentLoaded = function() {
  900.                 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  901.                 jQuery.ready();
  902.         };
  903.  
  904. } else if ( document.attachEvent ) {
  905.         DOMContentLoaded = function() {
  906.                 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  907.                 if ( document.readyState === "complete" ) {
  908.                         document.detachEvent( "onreadystatechange", DOMContentLoaded );
  909.                         jQuery.ready();
  910.                 }
  911.         };
  912. }
  913.  
  914. // The DOM ready check for Internet Explorer
  915. function doScrollCheck() {
  916.         if ( jQuery.isReady ) {
  917.                 return;
  918.         }
  919.  
  920.         try {
  921.                 // If IE is used, use the trick by Diego Perini
  922.                 // http://javascript.nwbox.com/IEContentLoaded/
  923.                 document.documentElement.doScroll("left");
  924.         } catch(e) {
  925.                 setTimeout( doScrollCheck, 1 );
  926.                 return;
  927.         }
  928.  
  929.         // and execute any waiting functions
  930.         jQuery.ready();
  931. }
  932.  
  933. // Expose jQuery to the global object
  934. return jQuery;
  935.  
  936. })();
  937.  
  938.  
  939. var // Promise methods
  940.         promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
  941.         // Static reference to slice
  942.         sliceDeferred = [].slice;
  943.  
  944. jQuery.extend({
  945.         // Create a simple deferred (one callbacks list)
  946.         _Deferred: function() {
  947.                 var // callbacks list
  948.                         callbacks = [],
  949.                         // stored [ context , args ]
  950.                         fired,
  951.                         // to avoid firing when already doing so
  952.                         firing,
  953.                         // flag to know if the deferred has been cancelled
  954.                         cancelled,
  955.                         // the deferred itself
  956.                         deferred  = {
  957.  
  958.                                 // done( f1, f2, ...)
  959.                                 done: function() {
  960.                                         if ( !cancelled ) {
  961.                                                 var args = arguments,
  962.                                                         i,
  963.                                                         length,
  964.                                                         elem,
  965.                                                         type,
  966.                                                         _fired;
  967.                                                 if ( fired ) {
  968.                                                         _fired = fired;
  969.                                                         fired = 0;
  970.                                                 }
  971.                                                 for ( i = 0, length = args.length; i < length; i++ ) {
  972.                                                         elem = args[ i ];
  973.                                                         type = jQuery.type( elem );
  974.                                                         if ( type === "array" ) {
  975.                                                                 deferred.done.apply( deferred, elem );
  976.                                                         } else if ( type === "function" ) {
  977.                                                                 callbacks.push( elem );
  978.                                                         }
  979.                                                 }
  980.                                                 if ( _fired ) {
  981.                                                         deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
  982.                                                 }
  983.                                         }
  984.                                         return this;
  985.                                 },
  986.  
  987.                                 // resolve with given context and args
  988.                                 resolveWith: function( context, args ) {
  989.                                         if ( !cancelled && !fired && !firing ) {
  990.                                                 // make sure args are available (#8421)
  991.                                                 args = args || [];
  992.                                                 firing = 1;
  993.                                                 try {
  994.                                                         while( callbacks[ 0 ] ) {
  995.                                                                 callbacks.shift().apply( context, args );
  996.                                                         }
  997.                                                 }
  998.                                                 finally {
  999.                                                         fired = [ context, args ];
  1000.                                                         firing = 0;
  1001.                                                 }
  1002.                                         }
  1003.                                         return this;
  1004.                                 },
  1005.  
  1006.                                 // resolve with this as context and given arguments
  1007.                                 resolve: function() {
  1008.                                         deferred.resolveWith( this, arguments );
  1009.                                         return this;
  1010.                                 },
  1011.  
  1012.                                 // Has this deferred been resolved?
  1013.                                 isResolved: function() {
  1014.                                         return !!( firing || fired );
  1015.                                 },
  1016.  
  1017.                                 // Cancel
  1018.                                 cancel: function() {
  1019.                                         cancelled = 1;
  1020.                                         callbacks = [];
  1021.                                         return this;
  1022.                                 }
  1023.                         };
  1024.  
  1025.                 return deferred;
  1026.         },
  1027.  
  1028.         // Full fledged deferred (two callbacks list)
  1029.         Deferred: function( func ) {
  1030.                 var deferred = jQuery._Deferred(),
  1031.                         failDeferred = jQuery._Deferred(),
  1032.                         promise;
  1033.                 // Add errorDeferred methods, then and promise
  1034.                 jQuery.extend( deferred, {
  1035.                         then: function( doneCallbacks, failCallbacks ) {
  1036.                                 deferred.done( doneCallbacks ).fail( failCallbacks );
  1037.                                 return this;
  1038.                         },
  1039.                         always: function() {
  1040.                                 return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
  1041.                         },
  1042.                         fail: failDeferred.done,
  1043.                         rejectWith: failDeferred.resolveWith,
  1044.                         reject: failDeferred.resolve,
  1045.                         isRejected: failDeferred.isResolved,
  1046.                         pipe: function( fnDone, fnFail ) {
  1047.                                 return jQuery.Deferred(function( newDefer ) {
  1048.                                         jQuery.each( {
  1049.                                                 done: [ fnDone, "resolve" ],
  1050.                                                 fail: [ fnFail, "reject" ]
  1051.                                         }, function( handler, data ) {
  1052.                                                 var fn = data[ 0 ],
  1053.                                                         action = data[ 1 ],
  1054.                                                         returned;
  1055.                                                 if ( jQuery.isFunction( fn ) ) {
  1056.                                                         deferred[ handler ](function() {
  1057.                                                                 returned = fn.apply( this, arguments );
  1058.                                                                 if ( returned && jQuery.isFunction( returned.promise ) ) {
  1059.                                                                         returned.promise().then( newDefer.resolve, newDefer.reject );
  1060.                                                                 } else {
  1061.                                                                         newDefer[ action ]( returned );
  1062.                                                                 }
  1063.                                                         });
  1064.                                                 } else {
  1065.                                                         deferred[ handler ]( newDefer[ action ] );
  1066.                                                 }
  1067.                                         });
  1068.                                 }).promise();
  1069.                         },
  1070.                         // Get a promise for this deferred
  1071.                         // If obj is provided, the promise aspect is added to the object
  1072.                         promise: function( obj ) {
  1073.                                 if ( obj == null ) {
  1074.                                         if ( promise ) {
  1075.                                                 return promise;
  1076.                                         }
  1077.                                         promise = obj = {};
  1078.                                 }
  1079.                                 var i = promiseMethods.length;
  1080.                                 while( i-- ) {
  1081.                                         obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
  1082.                                 }
  1083.                                 return obj;
  1084.                         }
  1085.                 });
  1086.                 // Make sure only one callback list will be used
  1087.                 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
  1088.                 // Unexpose cancel
  1089.                 delete deferred.cancel;
  1090.                 // Call given func if any
  1091.                 if ( func ) {
  1092.                         func.call( deferred, deferred );
  1093.                 }
  1094.                 return deferred;
  1095.         },
  1096.  
  1097.         // Deferred helper
  1098.         when: function( firstParam ) {
  1099.                 var args = arguments,
  1100.                         i = 0,
  1101.                         length = args.length,
  1102.                         count = length,
  1103.                         deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
  1104.                                 firstParam :
  1105.                                 jQuery.Deferred();
  1106.                 function resolveFunc( i ) {
  1107.                         return function( value ) {
  1108.                                 args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
  1109.                                 if ( !( --count ) ) {
  1110.                                         // Strange bug in FF4:
  1111.                                         // Values changed onto the arguments object sometimes end up as undefined values
  1112.                                         // outside the $.when method. Cloning the object into a fresh array solves the issue
  1113.                                         deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
  1114.                                 }
  1115.                         };
  1116.                 }
  1117.                 if ( length > 1 ) {
  1118.                         for( ; i < length; i++ ) {
  1119.                                 if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
  1120.                                         args[ i ].promise().then( resolveFunc(i), deferred.reject );
  1121.                                 } else {
  1122.                                         --count;
  1123.                                 }
  1124.                         }
  1125.                         if ( !count ) {
  1126.                                 deferred.resolveWith( deferred, args );
  1127.                         }
  1128.                 } else if ( deferred !== firstParam ) {
  1129.                         deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
  1130.                 }
  1131.                 return deferred.promise();
  1132.         }
  1133. });
  1134.  
  1135.  
  1136.  
  1137. jQuery.support = (function() {
  1138.  
  1139.         var div = document.createElement( "div" ),
  1140.                 documentElement = document.documentElement,
  1141.                 all,
  1142.                 a,
  1143.                 select,
  1144.                 opt,
  1145.                 input,
  1146.                 marginDiv,
  1147.                 support,
  1148.                 fragment,
  1149.                 body,
  1150.                 bodyStyle,
  1151.                 tds,
  1152.                 events,
  1153.                 eventName,
  1154.                 i,
  1155.                 isSupported;
  1156.  
  1157.         // Preliminary tests
  1158.         div.setAttribute("className", "t");
  1159.         div.innerHTML = "   <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  1160.  
  1161.         all = div.getElementsByTagName( "*" );
  1162.         a = div.getElementsByTagName( "a" )[ 0 ];
  1163.  
  1164.         // Can't get basic test support
  1165.         if ( !all || !all.length || !a ) {
  1166.                 return {};
  1167.         }
  1168.  
  1169.         // First batch of supports tests
  1170.         select = document.createElement( "select" );
  1171.         opt = select.appendChild( document.createElement("option") );
  1172.         input = div.getElementsByTagName( "input" )[ 0 ];
  1173.  
  1174.         support = {
  1175.                 // IE strips leading whitespace when .innerHTML is used
  1176.                 leadingWhitespace: ( div.firstChild.nodeType === 3 ),
  1177.  
  1178.                 // Make sure that tbody elements aren't automatically inserted
  1179.                 // IE will insert them into empty tables
  1180.                 tbody: !div.getElementsByTagName( "tbody" ).length,
  1181.  
  1182.                 // Make sure that link elements get serialized correctly by innerHTML
  1183.                 // This requires a wrapper element in IE
  1184.                 htmlSerialize: !!div.getElementsByTagName( "link" ).length,
  1185.  
  1186.                 // Get the style information from getAttribute
  1187.                 // (IE uses .cssText instead)
  1188.                 style: /top/.test( a.getAttribute("style") ),
  1189.  
  1190.                 // Make sure that URLs aren't manipulated
  1191.                 // (IE normalizes it by default)
  1192.                 hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
  1193.  
  1194.                 // Make sure that element opacity exists
  1195.                 // (IE uses filter instead)
  1196.                 // Use a regex to work around a WebKit issue. See #5145
  1197.                 opacity: /^0.55$/.test( a.style.opacity ),
  1198.  
  1199.                 // Verify style float existence
  1200.                 // (IE uses styleFloat instead of cssFloat)
  1201.                 cssFloat: !!a.style.cssFloat,
  1202.  
  1203.                 // Make sure that if no value is specified for a checkbox
  1204.                 // that it defaults to "on".
  1205.                 // (WebKit defaults to "" instead)
  1206.                 checkOn: ( input.value === "on" ),
  1207.  
  1208.                 // Make sure that a selected-by-default option has a working selected property.
  1209.                 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  1210.                 optSelected: opt.selected,
  1211.  
  1212.                 // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  1213.                 getSetAttribute: div.className !== "t",
  1214.  
  1215.                 // Will be defined later
  1216.                 submitBubbles: true,
  1217.                 changeBubbles: true,
  1218.                 focusinBubbles: false,
  1219.                 deleteExpando: true,
  1220.                 noCloneEvent: true,
  1221.                 inlineBlockNeedsLayout: false,
  1222.                 shrinkWrapBlocks: false,
  1223.                 reliableMarginRight: true
  1224.         };
  1225.  
  1226.         // Make sure checked status is properly cloned
  1227.         input.checked = true;
  1228.         support.noCloneChecked = input.cloneNode( true ).checked;
  1229.  
  1230.         // Make sure that the options inside disabled selects aren't marked as disabled
  1231.         // (WebKit marks them as disabled)
  1232.         select.disabled = true;
  1233.         support.optDisabled = !opt.disabled;
  1234.  
  1235.         // Test to see if it's possible to delete an expando from an element
  1236.         // Fails in Internet Explorer
  1237.         try {
  1238.                 delete div.test;
  1239.         } catch( e ) {
  1240.                 support.deleteExpando = false;
  1241.         }
  1242.  
  1243.         if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  1244.                 div.attachEvent( "onclick", function click() {
  1245.                         // Cloning a node shouldn't copy over any
  1246.                         // bound event handlers (IE does this)
  1247.                         support.noCloneEvent = false;
  1248.                         div.detachEvent( "onclick", click );
  1249.                 });
  1250.                 div.cloneNode( true ).fireEvent( "onclick" );
  1251.         }
  1252.  
  1253.         // Check if a radio maintains it's value
  1254.         // after being appended to the DOM
  1255.         input = document.createElement("input");
  1256.         input.value = "t";
  1257.         input.setAttribute("type", "radio");
  1258.         support.radioValue = input.value === "t";
  1259.  
  1260.         input.setAttribute("checked", "checked");
  1261.         div.appendChild( input );
  1262.         fragment = document.createDocumentFragment();
  1263.         fragment.appendChild( div.firstChild );
  1264.  
  1265.         // WebKit doesn't clone checked state correctly in fragments
  1266.         support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
  1267.  
  1268.         div.innerHTML = "";
  1269.  
  1270.         // Figure out if the W3C box model works as expected
  1271.         div.style.width = div.style.paddingLeft = "1px";
  1272.  
  1273.         // We use our own, invisible, body
  1274.         body = document.createElement( "body" );
  1275.         bodyStyle = {
  1276.                 visibility: "hidden",
  1277.                 width: 0,
  1278.                 height: 0,
  1279.                 border: 0,
  1280.                 margin: 0,
  1281.                 // Set background to avoid IE crashes when removing (#9028)
  1282.                 background: "none"
  1283.         };
  1284.         for ( i in bodyStyle ) {
  1285.                 body.style[ i ] = bodyStyle[ i ];
  1286.         }
  1287.         body.appendChild( div );
  1288.         documentElement.insertBefore( body, documentElement.firstChild );
  1289.  
  1290.         // Check if a disconnected checkbox will retain its checked
  1291.         // value of true after appended to the DOM (IE6/7)
  1292.         support.appendChecked = input.checked;
  1293.  
  1294.         support.boxModel = div.offsetWidth === 2;
  1295.  
  1296.         if ( "zoom" in div.style ) {
  1297.                 // Check if natively block-level elements act like inline-block
  1298.                 // elements when setting their display to 'inline' and giving
  1299.                 // them layout
  1300.                 // (IE < 8 does this)
  1301.                 div.style.display = "inline";
  1302.                 div.style.zoom = 1;
  1303.                 support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
  1304.  
  1305.                 // Check if elements with layout shrink-wrap their children
  1306.                 // (IE 6 does this)
  1307.                 div.style.display = "";
  1308.                 div.innerHTML = "<div style='width:4px;'></div>";
  1309.                 support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
  1310.         }
  1311.  
  1312.         div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1313.         tds = div.getElementsByTagName( "td" );
  1314.  
  1315.         // Check if table cells still have offsetWidth/Height when they are set
  1316.         // to display:none and there are still other visible table cells in a
  1317.         // table row; if so, offsetWidth/Height are not reliable for use when
  1318.         // determining if an element has been hidden directly using
  1319.         // display:none (it is still safe to use offsets if a parent element is
  1320.         // hidden; don safety goggles and see bug #4512 for more information).
  1321.         // (only IE 8 fails this test)
  1322.         isSupported = ( tds[ 0 ].offsetHeight === 0 );
  1323.  
  1324.         tds[ 0 ].style.display = "";
  1325.         tds[ 1 ].style.display = "none";
  1326.  
  1327.         // Check if empty table cells still have offsetWidth/Height
  1328.         // (IE < 8 fail this test)
  1329.         support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
  1330.         div.innerHTML = "";
  1331.  
  1332.         // Check if div with explicit width and no margin-right incorrectly
  1333.         // gets computed margin-right based on width of container. For more
  1334.         // info see bug #3333
  1335.         // Fails in WebKit before Feb 2011 nightlies
  1336.         // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  1337.         if ( document.defaultView && document.defaultView.getComputedStyle ) {
  1338.                 marginDiv = document.createElement( "div" );
  1339.                 marginDiv.style.width = "0";
  1340.                 marginDiv.style.marginRight = "0";
  1341.                 div.appendChild( marginDiv );
  1342.                 support.reliableMarginRight =
  1343.                         ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
  1344.         }
  1345.  
  1346.         // Remove the body element we added
  1347.         body.innerHTML = "";
  1348.         documentElement.removeChild( body );
  1349.  
  1350.         // Technique from Juriy Zaytsev
  1351.         // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  1352.         // We only care about the case where non-standard event systems
  1353.         // are used, namely in IE. Short-circuiting here helps us to
  1354.         // avoid an eval call (in setAttribute) which can cause CSP
  1355.         // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1356.         if ( div.attachEvent ) {
  1357.                 for( i in {
  1358.                         submit: 1,
  1359.                         change: 1,
  1360.                         focusin: 1
  1361.                 } ) {
  1362.                         eventName = "on" + i;
  1363.                         isSupported = ( eventName in div );
  1364.                         if ( !isSupported ) {
  1365.                                 div.setAttribute( eventName, "return;" );
  1366.                                 isSupported = ( typeof div[ eventName ] === "function" );
  1367.                         }
  1368.                         support[ i + "Bubbles" ] = isSupported;
  1369.                 }
  1370.         }
  1371.  
  1372.         return support;
  1373. })();
  1374.  
  1375. // Keep track of boxModel
  1376. jQuery.boxModel = jQuery.support.boxModel;
  1377.  
  1378.  
  1379.  
  1380.  
  1381. var rbrace = /^(?:\{.*\}|\[.*\])$/,
  1382.         rmultiDash = /([a-z])([A-Z])/g;
  1383.  
  1384. jQuery.extend({
  1385.         cache: {},
  1386.  
  1387.         // Please use with caution
  1388.         uuid: 0,
  1389.  
  1390.         // Unique for each copy of jQuery on the page
  1391.         // Non-digits removed to match rinlinejQuery
  1392.         expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1393.  
  1394.         // The following elements throw uncatchable exceptions if you
  1395.         // attempt to add expando properties to them.
  1396.         noData: {
  1397.                 "embed": true,
  1398.                 // Ban all objects except for Flash (which handle expandos)
  1399.                 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1400.                 "applet": true
  1401.         },
  1402.  
  1403.         hasData: function( elem ) {
  1404.                 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1405.  
  1406.                 return !!elem && !isEmptyDataObject( elem );
  1407.         },
  1408.  
  1409.         data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1410.                 if ( !jQuery.acceptData( elem ) ) {
  1411.                         return;
  1412.                 }
  1413.  
  1414.                 var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
  1415.  
  1416.                         // We have to handle DOM nodes and JS objects differently because IE6-7
  1417.                         // can't GC object references properly across the DOM-JS boundary
  1418.                         isNode = elem.nodeType,
  1419.  
  1420.                         // Only DOM nodes need the global jQuery cache; JS object data is
  1421.                         // attached directly to the object so GC can occur automatically
  1422.                         cache = isNode ? jQuery.cache : elem,
  1423.  
  1424.                         // Only defining an ID for JS objects if its cache already exists allows
  1425.                         // the code to shortcut on the same path as a DOM node with no cache
  1426.                         id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  1427.  
  1428.                 // Avoid doing any more work than we need to when trying to get data on an
  1429.                 // object that has no data at all
  1430.                 if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
  1431.                         return;
  1432.                 }
  1433.  
  1434.                 if ( !id ) {
  1435.                         // Only DOM nodes need a new unique ID for each element since their data
  1436.                         // ends up in the global cache
  1437.                         if ( isNode ) {
  1438.                                 elem[ jQuery.expando ] = id = ++jQuery.uuid;
  1439.                         } else {
  1440.                                 id = jQuery.expando;
  1441.                         }
  1442.                 }
  1443.  
  1444.                 if ( !cache[ id ] ) {
  1445.                         cache[ id ] = {};
  1446.  
  1447.                         // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1448.                         // metadata on plain JS objects when the object is serialized using
  1449.                         // JSON.stringify
  1450.                         if ( !isNode ) {
  1451.                                 cache[ id ].toJSON = jQuery.noop;
  1452.                         }
  1453.                 }
  1454.  
  1455.                 // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1456.                 // shallow copied over onto the existing cache
  1457.                 if ( typeof name === "object" || typeof name === "function" ) {
  1458.                         if ( pvt ) {
  1459.                                 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
  1460.                         } else {
  1461.                                 cache[ id ] = jQuery.extend(cache[ id ], name);
  1462.                         }
  1463.                 }
  1464.  
  1465.                 thisCache = cache[ id ];
  1466.  
  1467.                 // Internal jQuery data is stored in a separate object inside the object's data
  1468.                 // cache in order to avoid key collisions between internal data and user-defined
  1469.                 // data
  1470.                 if ( pvt ) {
  1471.                         if ( !thisCache[ internalKey ] ) {
  1472.                                 thisCache[ internalKey ] = {};
  1473.                         }
  1474.  
  1475.                         thisCache = thisCache[ internalKey ];
  1476.                 }
  1477.  
  1478.                 if ( data !== undefined ) {
  1479.                         thisCache[ jQuery.camelCase( name ) ] = data;
  1480.                 }
  1481.  
  1482.                 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
  1483.                 // not attempt to inspect the internal events object using jQuery.data, as this
  1484.                 // internal data object is undocumented and subject to change.
  1485.                 if ( name === "events" && !thisCache[name] ) {
  1486.                         return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  1487.                 }
  1488.  
  1489.                 return getByName ? thisCache[ jQuery.camelCase( name ) ] : thisCache;
  1490.         },
  1491.  
  1492.         removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1493.                 if ( !jQuery.acceptData( elem ) ) {
  1494.                         return;
  1495.                 }
  1496.  
  1497.                 var internalKey = jQuery.expando, isNode = elem.nodeType,
  1498.  
  1499.                         // See jQuery.data for more information
  1500.                         cache = isNode ? jQuery.cache : elem,
  1501.  
  1502.                         // See jQuery.data for more information
  1503.                         id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1504.  
  1505.                 // If there is already no cache entry for this object, there is no
  1506.                 // purpose in continuing
  1507.                 if ( !cache[ id ] ) {
  1508.                         return;
  1509.                 }
  1510.  
  1511.                 if ( name ) {
  1512.                         var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
  1513.  
  1514.                         if ( thisCache ) {
  1515.                                 delete thisCache[ name ];
  1516.  
  1517.                                 // If there is no data left in the cache, we want to continue
  1518.                                 // and let the cache object itself get destroyed
  1519.                                 if ( !isEmptyDataObject(thisCache) ) {
  1520.                                         return;
  1521.                                 }
  1522.                         }
  1523.                 }
  1524.  
  1525.                 // See jQuery.data for more information
  1526.                 if ( pvt ) {
  1527.                         delete cache[ id ][ internalKey ];
  1528.  
  1529.                         // Don't destroy the parent cache unless the internal data object
  1530.                         // had been the only thing left in it
  1531.                         if ( !isEmptyDataObject(cache[ id ]) ) {
  1532.                                 return;
  1533.                         }
  1534.                 }
  1535.  
  1536.                 var internalCache = cache[ id ][ internalKey ];
  1537.  
  1538.                 // Browsers that fail expando deletion also refuse to delete expandos on
  1539.                 // the window, but it will allow it on all other JS objects; other browsers
  1540.                 // don't care
  1541.                 if ( jQuery.support.deleteExpando || cache != window ) {
  1542.                         delete cache[ id ];
  1543.                 } else {
  1544.                         cache[ id ] = null;
  1545.                 }
  1546.  
  1547.                 // We destroyed the entire user cache at once because it's faster than
  1548.                 // iterating through each key, but we need to continue to persist internal
  1549.                 // data if it existed
  1550.                 if ( internalCache ) {
  1551.                         cache[ id ] = {};
  1552.                         // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1553.                         // metadata on plain JS objects when the object is serialized using
  1554.                         // JSON.stringify
  1555.                         if ( !isNode ) {
  1556.                                 cache[ id ].toJSON = jQuery.noop;
  1557.                         }
  1558.  
  1559.                         cache[ id ][ internalKey ] = internalCache;
  1560.  
  1561.                 // Otherwise, we need to eliminate the expando on the node to avoid
  1562.                 // false lookups in the cache for entries that no longer exist
  1563.                 } else if ( isNode ) {
  1564.                         // IE does not allow us to delete expando properties from nodes,
  1565.                         // nor does it have a removeAttribute function on Document nodes;
  1566.                         // we must handle all of these cases
  1567.                         if ( jQuery.support.deleteExpando ) {
  1568.                                 delete elem[ jQuery.expando ];
  1569.                         } else if ( elem.removeAttribute ) {
  1570.                                 elem.removeAttribute( jQuery.expando );
  1571.                         } else {
  1572.                                 elem[ jQuery.expando ] = null;
  1573.                         }
  1574.                 }
  1575.         },
  1576.  
  1577.         // For internal use only.
  1578.         _data: function( elem, name, data ) {
  1579.                 return jQuery.data( elem, name, data, true );
  1580.         },
  1581.  
  1582.         // A method for determining if a DOM node can handle the data expando
  1583.         acceptData: function( elem ) {
  1584.                 if ( elem.nodeName ) {
  1585.                         var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1586.  
  1587.                         if ( match ) {
  1588.                                 return !(match === true || elem.getAttribute("classid") !== match);
  1589.                         }
  1590.                 }
  1591.  
  1592.                 return true;
  1593.         }
  1594. });
  1595.  
  1596. jQuery.fn.extend({
  1597.         data: function( key, value ) {
  1598.                 var data = null;
  1599.  
  1600.                 if ( typeof key === "undefined" ) {
  1601.                         if ( this.length ) {
  1602.                                 data = jQuery.data( this[0] );
  1603.  
  1604.                                 if ( this[0].nodeType === 1 ) {
  1605.                             var attr = this[0].attributes, name;
  1606.                                         for ( var i = 0, l = attr.length; i < l; i++ ) {
  1607.                                                 name = attr[i].name;
  1608.  
  1609.                                                 if ( name.indexOf( "data-" ) === 0 ) {
  1610.                                                         name = jQuery.camelCase( name.substring(5) );
  1611.  
  1612.                                                         dataAttr( this[0], name, data[ name ] );
  1613.                                                 }
  1614.                                         }
  1615.                                 }
  1616.                         }
  1617.  
  1618.                         return data;
  1619.  
  1620.                 } else if ( typeof key === "object" ) {
  1621.                         return this.each(function() {
  1622.                                 jQuery.data( this, key );
  1623.                         });
  1624.                 }
  1625.  
  1626.                 var parts = key.split(".");
  1627.                 parts[1] = parts[1] ? "." + parts[1] : "";
  1628.  
  1629.                 if ( value === undefined ) {
  1630.                         data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1631.  
  1632.                         // Try to fetch any internally stored data first
  1633.                         if ( data === undefined && this.length ) {
  1634.                                 data = jQuery.data( this[0], key );
  1635.                                 data = dataAttr( this[0], key, data );
  1636.                         }
  1637.  
  1638.                         return data === undefined && parts[1] ?
  1639.                                 this.data( parts[0] ) :
  1640.                                 data;
  1641.  
  1642.                 } else {
  1643.                         return this.each(function() {
  1644.                                 var $this = jQuery( this ),
  1645.                                         args = [ parts[0], value ];
  1646.  
  1647.                                 $this.triggerHandler( "setData" + parts[1] + "!", args );
  1648.                                 jQuery.data( this, key, value );
  1649.                                 $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1650.                         });
  1651.                 }
  1652.         },
  1653.  
  1654.         removeData: function( key ) {
  1655.                 return this.each(function() {
  1656.                         jQuery.removeData( this, key );
  1657.                 });
  1658.         }
  1659. });
  1660.  
  1661. function dataAttr( elem, key, data ) {
  1662.         // If nothing was found internally, try to fetch any
  1663.         // data from the HTML5 data-* attribute
  1664.         if ( data === undefined && elem.nodeType === 1 ) {
  1665.                 var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
  1666.  
  1667.                 data = elem.getAttribute( name );
  1668.  
  1669.                 if ( typeof data === "string" ) {
  1670.                         try {
  1671.                                 data = data === "true" ? true :
  1672.                                 data === "false" ? false :
  1673.                                 data === "null" ? null :
  1674.                                 !jQuery.isNaN( data ) ? parseFloat( data ) :
  1675.                                         rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1676.                                         data;
  1677.                         } catch( e ) {}
  1678.  
  1679.                         // Make sure we set the data so it isn't changed later
  1680.                         jQuery.data( elem, key, data );
  1681.  
  1682.                 } else {
  1683.                         data = undefined;
  1684.                 }
  1685.         }
  1686.  
  1687.         return data;
  1688. }
  1689.  
  1690. // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
  1691. // p
Advertisement
Add Comment
Please, Sign In to add comment