/Plugins/Jquery rotate/js/jquery.js

https://bitbucket.org/sgospodarets/cross-browser-rotate-box · JavaScript · 6866 lines · 5357 code · 834 blank · 675 comment · 978 complexity · 2d3c6ca006d09feef9f0f75a33f85753 MD5 · raw file

Large files are truncated click here to view the full file

  1. /*!
  2. * jQuery JavaScript Library v1.4.3
  3. * http://jquery.com/
  4. *
  5. * Copyright 2010, John Resig
  6. * Dual licensed under the MIT or GPL Version 2 licenses.
  7. * http://jquery.org/license
  8. *
  9. * Includes Sizzle.js
  10. * http://sizzlejs.com/
  11. * Copyright 2010, The Dojo Foundation
  12. * Released under the MIT, BSD, and GPL Licenses.
  13. *
  14. * Date: Mon Oct 11 00:37:46 2010 -0400
  15. */
  16. (function( window, undefined ) {
  17. // Use the correct document accordingly with window argument (sandbox)
  18. var document = window.document;
  19. var jQuery = (function() {
  20. // Define a local copy of jQuery
  21. var jQuery = function( selector, context ) {
  22. // The jQuery object is actually just the init constructor 'enhanced'
  23. return new jQuery.fn.init( selector, context );
  24. },
  25. // Map over jQuery in case of overwrite
  26. _jQuery = window.jQuery,
  27. // Map over the $ in case of overwrite
  28. _$ = window.$,
  29. // A central reference to the root jQuery(document)
  30. rootjQuery,
  31. // A simple way to check for HTML strings or ID strings
  32. // (both of which we optimize for)
  33. quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
  34. // Is it a simple selector
  35. isSimple = /^.[^:#\[\.,]*$/,
  36. // Check if a string has a non-whitespace character in it
  37. rnotwhite = /\S/,
  38. rwhite = /\s/,
  39. // Used for trimming whitespace
  40. trimLeft = /^\s+/,
  41. trimRight = /\s+$/,
  42. // Check for non-word characters
  43. rnonword = /\W/,
  44. // Check for digits
  45. rdigit = /\d/,
  46. // Match a standalone tag
  47. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  48. // JSON RegExp
  49. rvalidchars = /^[\],:{}\s]*$/,
  50. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  51. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  52. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  53. // Useragent RegExp
  54. rwebkit = /(webkit)[ \/]([\w.]+)/,
  55. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  56. rmsie = /(msie) ([\w.]+)/,
  57. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  58. // Keep a UserAgent string for use with jQuery.browser
  59. userAgent = navigator.userAgent,
  60. // For matching the engine and version of the browser
  61. browserMatch,
  62. // Has the ready events already been bound?
  63. readyBound = false,
  64. // The functions to execute on DOM ready
  65. readyList = [],
  66. // The ready event handler
  67. DOMContentLoaded,
  68. // Save a reference to some core methods
  69. toString = Object.prototype.toString,
  70. hasOwn = Object.prototype.hasOwnProperty,
  71. push = Array.prototype.push,
  72. slice = Array.prototype.slice,
  73. trim = String.prototype.trim,
  74. indexOf = Array.prototype.indexOf,
  75. // [[Class]] -> type pairs
  76. class2type = {};
  77. jQuery.fn = jQuery.prototype = {
  78. init: function( selector, context ) {
  79. var match, elem, ret, doc;
  80. // Handle $(""), $(null), or $(undefined)
  81. if ( !selector ) {
  82. return this;
  83. }
  84. // Handle $(DOMElement)
  85. if ( selector.nodeType ) {
  86. this.context = this[0] = selector;
  87. this.length = 1;
  88. return this;
  89. }
  90. // The body element only exists once, optimize finding it
  91. if ( selector === "body" && !context && document.body ) {
  92. this.context = document;
  93. this[0] = document.body;
  94. this.selector = "body";
  95. this.length = 1;
  96. return this;
  97. }
  98. // Handle HTML strings
  99. if ( typeof selector === "string" ) {
  100. // Are we dealing with HTML string or an ID?
  101. match = quickExpr.exec( selector );
  102. // Verify a match, and that no context was specified for #id
  103. if ( match && (match[1] || !context) ) {
  104. // HANDLE: $(html) -> $(array)
  105. if ( match[1] ) {
  106. doc = (context ? context.ownerDocument || context : document);
  107. // If a single string is passed in and it's a single tag
  108. // just do a createElement and skip the rest
  109. ret = rsingleTag.exec( selector );
  110. if ( ret ) {
  111. if ( jQuery.isPlainObject( context ) ) {
  112. selector = [ document.createElement( ret[1] ) ];
  113. jQuery.fn.attr.call( selector, context, true );
  114. } else {
  115. selector = [ doc.createElement( ret[1] ) ];
  116. }
  117. } else {
  118. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  119. selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
  120. }
  121. return jQuery.merge( this, selector );
  122. // HANDLE: $("#id")
  123. } else {
  124. elem = document.getElementById( match[2] );
  125. // Check parentNode to catch when Blackberry 4.6 returns
  126. // nodes that are no longer in the document #6963
  127. if ( elem && elem.parentNode ) {
  128. // Handle the case where IE and Opera return items
  129. // by name instead of ID
  130. if ( elem.id !== match[2] ) {
  131. return rootjQuery.find( selector );
  132. }
  133. // Otherwise, we inject the element directly into the jQuery object
  134. this.length = 1;
  135. this[0] = elem;
  136. }
  137. this.context = document;
  138. this.selector = selector;
  139. return this;
  140. }
  141. // HANDLE: $("TAG")
  142. } else if ( !context && !rnonword.test( selector ) ) {
  143. this.selector = selector;
  144. this.context = document;
  145. selector = document.getElementsByTagName( selector );
  146. return jQuery.merge( this, selector );
  147. // HANDLE: $(expr, $(...))
  148. } else if ( !context || context.jquery ) {
  149. return (context || rootjQuery).find( selector );
  150. // HANDLE: $(expr, context)
  151. // (which is just equivalent to: $(context).find(expr)
  152. } else {
  153. return jQuery( context ).find( selector );
  154. }
  155. // HANDLE: $(function)
  156. // Shortcut for document ready
  157. } else if ( jQuery.isFunction( selector ) ) {
  158. return rootjQuery.ready( selector );
  159. }
  160. if (selector.selector !== undefined) {
  161. this.selector = selector.selector;
  162. this.context = selector.context;
  163. }
  164. return jQuery.makeArray( selector, this );
  165. },
  166. // Start with an empty selector
  167. selector: "",
  168. // The current version of jQuery being used
  169. jquery: "1.4.3",
  170. // The default length of a jQuery object is 0
  171. length: 0,
  172. // The number of elements contained in the matched element set
  173. size: function() {
  174. return this.length;
  175. },
  176. toArray: function() {
  177. return slice.call( this, 0 );
  178. },
  179. // Get the Nth element in the matched element set OR
  180. // Get the whole matched element set as a clean array
  181. get: function( num ) {
  182. return num == null ?
  183. // Return a 'clean' array
  184. this.toArray() :
  185. // Return just the object
  186. ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
  187. },
  188. // Take an array of elements and push it onto the stack
  189. // (returning the new matched element set)
  190. pushStack: function( elems, name, selector ) {
  191. // Build a new jQuery matched element set
  192. var ret = jQuery();
  193. if ( jQuery.isArray( elems ) ) {
  194. push.apply( ret, elems );
  195. } else {
  196. jQuery.merge( ret, elems );
  197. }
  198. // Add the old object onto the stack (as a reference)
  199. ret.prevObject = this;
  200. ret.context = this.context;
  201. if ( name === "find" ) {
  202. ret.selector = this.selector + (this.selector ? " " : "") + selector;
  203. } else if ( name ) {
  204. ret.selector = this.selector + "." + name + "(" + selector + ")";
  205. }
  206. // Return the newly-formed element set
  207. return ret;
  208. },
  209. // Execute a callback for every element in the matched set.
  210. // (You can seed the arguments with an array of args, but this is
  211. // only used internally.)
  212. each: function( callback, args ) {
  213. return jQuery.each( this, callback, args );
  214. },
  215. ready: function( fn ) {
  216. // Attach the listeners
  217. jQuery.bindReady();
  218. // If the DOM is already ready
  219. if ( jQuery.isReady ) {
  220. // Execute the function immediately
  221. fn.call( document, jQuery );
  222. // Otherwise, remember the function for later
  223. } else if ( readyList ) {
  224. // Add the function to the wait list
  225. readyList.push( fn );
  226. }
  227. return this;
  228. },
  229. eq: function( i ) {
  230. return i === -1 ?
  231. this.slice( i ) :
  232. this.slice( i, +i + 1 );
  233. },
  234. first: function() {
  235. return this.eq( 0 );
  236. },
  237. last: function() {
  238. return this.eq( -1 );
  239. },
  240. slice: function() {
  241. return this.pushStack( slice.apply( this, arguments ),
  242. "slice", slice.call(arguments).join(",") );
  243. },
  244. map: function( callback ) {
  245. return this.pushStack( jQuery.map(this, function( elem, i ) {
  246. return callback.call( elem, i, elem );
  247. }));
  248. },
  249. end: function() {
  250. return this.prevObject || jQuery(null);
  251. },
  252. // For internal use only.
  253. // Behaves like an Array's method, not like a jQuery method.
  254. push: push,
  255. sort: [].sort,
  256. splice: [].splice
  257. };
  258. // Give the init function the jQuery prototype for later instantiation
  259. jQuery.fn.init.prototype = jQuery.fn;
  260. jQuery.extend = jQuery.fn.extend = function() {
  261. // copy reference to target object
  262. var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy, copyIsArray;
  263. // Handle a deep copy situation
  264. if ( typeof target === "boolean" ) {
  265. deep = target;
  266. target = arguments[1] || {};
  267. // skip the boolean and the target
  268. i = 2;
  269. }
  270. // Handle case when target is a string or something (possible in deep copy)
  271. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  272. target = {};
  273. }
  274. // extend jQuery itself if only one argument is passed
  275. if ( length === i ) {
  276. target = this;
  277. --i;
  278. }
  279. for ( ; i < length; i++ ) {
  280. // Only deal with non-null/undefined values
  281. if ( (options = arguments[ i ]) != null ) {
  282. // Extend the base object
  283. for ( name in options ) {
  284. src = target[ name ];
  285. copy = options[ name ];
  286. // Prevent never-ending loop
  287. if ( target === copy ) {
  288. continue;
  289. }
  290. // Recurse if we're merging plain objects or arrays
  291. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  292. if ( copyIsArray ) {
  293. copyIsArray = false;
  294. clone = src && jQuery.isArray(src) ? src : [];
  295. } else {
  296. clone = src && jQuery.isPlainObject(src) ? src : {};
  297. }
  298. // Never move original objects, clone them
  299. target[ name ] = jQuery.extend( deep, clone, copy );
  300. // Don't bring in undefined values
  301. } else if ( copy !== undefined ) {
  302. target[ name ] = copy;
  303. }
  304. }
  305. }
  306. }
  307. // Return the modified object
  308. return target;
  309. };
  310. jQuery.extend({
  311. noConflict: function( deep ) {
  312. window.$ = _$;
  313. if ( deep ) {
  314. window.jQuery = _jQuery;
  315. }
  316. return jQuery;
  317. },
  318. // Is the DOM ready to be used? Set to true once it occurs.
  319. isReady: false,
  320. // A counter to track how many items to wait for before
  321. // the ready event fires. See #6781
  322. readyWait: 1,
  323. // Handle when the DOM is ready
  324. ready: function( wait ) {
  325. // A third-party is pushing the ready event forwards
  326. if ( wait === true ) {
  327. jQuery.readyWait--;
  328. }
  329. // Make sure that the DOM is not already loaded
  330. if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
  331. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  332. if ( !document.body ) {
  333. return setTimeout( jQuery.ready, 1 );
  334. }
  335. // Remember that the DOM is ready
  336. jQuery.isReady = true;
  337. // If a normal DOM Ready event fired, decrement, and wait if need be
  338. if ( wait !== true && --jQuery.readyWait > 0 ) {
  339. return;
  340. }
  341. // If there are functions bound, to execute
  342. if ( readyList ) {
  343. // Execute all of them
  344. var fn, i = 0;
  345. while ( (fn = readyList[ i++ ]) ) {
  346. fn.call( document, jQuery );
  347. }
  348. // Reset the list of functions
  349. readyList = null;
  350. }
  351. // Trigger any bound ready events
  352. if ( jQuery.fn.triggerHandler ) {
  353. jQuery( document ).triggerHandler( "ready" );
  354. }
  355. }
  356. },
  357. bindReady: function() {
  358. if ( readyBound ) {
  359. return;
  360. }
  361. readyBound = true;
  362. // Catch cases where $(document).ready() is called after the
  363. // browser event has already occurred.
  364. if ( document.readyState === "complete" ) {
  365. // Handle it asynchronously to allow scripts the opportunity to delay ready
  366. return setTimeout( jQuery.ready, 1 );
  367. }
  368. // Mozilla, Opera and webkit nightlies currently support this event
  369. if ( document.addEventListener ) {
  370. // Use the handy event callback
  371. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  372. // A fallback to window.onload, that will always work
  373. window.addEventListener( "load", jQuery.ready, false );
  374. // If IE event model is used
  375. } else if ( document.attachEvent ) {
  376. // ensure firing before onload,
  377. // maybe late but safe also for iframes
  378. document.attachEvent("onreadystatechange", DOMContentLoaded);
  379. // A fallback to window.onload, that will always work
  380. window.attachEvent( "onload", jQuery.ready );
  381. // If IE and not a frame
  382. // continually check to see if the document is ready
  383. var toplevel = false;
  384. try {
  385. toplevel = window.frameElement == null;
  386. } catch(e) {}
  387. if ( document.documentElement.doScroll && toplevel ) {
  388. doScrollCheck();
  389. }
  390. }
  391. },
  392. // See test/unit/core.js for details concerning isFunction.
  393. // Since version 1.3, DOM methods and functions like alert
  394. // aren't supported. They return false on IE (#2968).
  395. isFunction: function( obj ) {
  396. return jQuery.type(obj) === "function";
  397. },
  398. isArray: Array.isArray || function( obj ) {
  399. return jQuery.type(obj) === "array";
  400. },
  401. // A crude way of determining if an object is a window
  402. isWindow: function( obj ) {
  403. return obj && typeof obj === "object" && "setInterval" in obj;
  404. },
  405. isNaN: function( obj ) {
  406. return obj == null || !rdigit.test( obj ) || isNaN( obj );
  407. },
  408. type: function( obj ) {
  409. return obj == null ?
  410. String( obj ) :
  411. class2type[ toString.call(obj) ] || "object";
  412. },
  413. isPlainObject: function( obj ) {
  414. // Must be an Object.
  415. // Because of IE, we also have to check the presence of the constructor property.
  416. // Make sure that DOM nodes and window objects don't pass through, as well
  417. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  418. return false;
  419. }
  420. // Not own constructor property must be Object
  421. if ( obj.constructor &&
  422. !hasOwn.call(obj, "constructor") &&
  423. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  424. return false;
  425. }
  426. // Own properties are enumerated firstly, so to speed up,
  427. // if last one is own, then all properties are own.
  428. var key;
  429. for ( key in obj ) {}
  430. return key === undefined || hasOwn.call( obj, key );
  431. },
  432. isEmptyObject: function( obj ) {
  433. for ( var name in obj ) {
  434. return false;
  435. }
  436. return true;
  437. },
  438. error: function( msg ) {
  439. throw msg;
  440. },
  441. parseJSON: function( data ) {
  442. if ( typeof data !== "string" || !data ) {
  443. return null;
  444. }
  445. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  446. data = jQuery.trim( data );
  447. // Make sure the incoming data is actual JSON
  448. // Logic borrowed from http://json.org/json2.js
  449. if ( rvalidchars.test(data.replace(rvalidescape, "@")
  450. .replace(rvalidtokens, "]")
  451. .replace(rvalidbraces, "")) ) {
  452. // Try to use the native JSON parser first
  453. return window.JSON && window.JSON.parse ?
  454. window.JSON.parse( data ) :
  455. (new Function("return " + data))();
  456. } else {
  457. jQuery.error( "Invalid JSON: " + data );
  458. }
  459. },
  460. noop: function() {},
  461. // Evalulates a script in a global context
  462. globalEval: function( data ) {
  463. if ( data && rnotwhite.test(data) ) {
  464. // Inspired by code by Andrea Giammarchi
  465. // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
  466. var head = document.getElementsByTagName("head")[0] || document.documentElement,
  467. script = document.createElement("script");
  468. script.type = "text/javascript";
  469. if ( jQuery.support.scriptEval ) {
  470. script.appendChild( document.createTextNode( data ) );
  471. } else {
  472. script.text = data;
  473. }
  474. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  475. // This arises when a base node is used (#2709).
  476. head.insertBefore( script, head.firstChild );
  477. head.removeChild( script );
  478. }
  479. },
  480. nodeName: function( elem, name ) {
  481. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  482. },
  483. // args is for internal usage only
  484. each: function( object, callback, args ) {
  485. var name, i = 0,
  486. length = object.length,
  487. isObj = length === undefined || jQuery.isFunction(object);
  488. if ( args ) {
  489. if ( isObj ) {
  490. for ( name in object ) {
  491. if ( callback.apply( object[ name ], args ) === false ) {
  492. break;
  493. }
  494. }
  495. } else {
  496. for ( ; i < length; ) {
  497. if ( callback.apply( object[ i++ ], args ) === false ) {
  498. break;
  499. }
  500. }
  501. }
  502. // A special, fast, case for the most common use of each
  503. } else {
  504. if ( isObj ) {
  505. for ( name in object ) {
  506. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  507. break;
  508. }
  509. }
  510. } else {
  511. for ( var value = object[0];
  512. i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
  513. }
  514. }
  515. return object;
  516. },
  517. // Use native String.trim function wherever possible
  518. trim: trim ?
  519. function( text ) {
  520. return text == null ?
  521. "" :
  522. trim.call( text );
  523. } :
  524. // Otherwise use our own trimming functionality
  525. function( text ) {
  526. return text == null ?
  527. "" :
  528. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  529. },
  530. // results is for internal usage only
  531. makeArray: function( array, results ) {
  532. var ret = results || [];
  533. if ( array != null ) {
  534. // The window, strings (and functions) also have 'length'
  535. // The extra typeof function check is to prevent crashes
  536. // in Safari 2 (See: #3039)
  537. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  538. var type = jQuery.type(array);
  539. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  540. push.call( ret, array );
  541. } else {
  542. jQuery.merge( ret, array );
  543. }
  544. }
  545. return ret;
  546. },
  547. inArray: function( elem, array ) {
  548. if ( array.indexOf ) {
  549. return array.indexOf( elem );
  550. }
  551. for ( var i = 0, length = array.length; i < length; i++ ) {
  552. if ( array[ i ] === elem ) {
  553. return i;
  554. }
  555. }
  556. return -1;
  557. },
  558. merge: function( first, second ) {
  559. var i = first.length, j = 0;
  560. if ( typeof second.length === "number" ) {
  561. for ( var l = second.length; j < l; j++ ) {
  562. first[ i++ ] = second[ j ];
  563. }
  564. } else {
  565. while ( second[j] !== undefined ) {
  566. first[ i++ ] = second[ j++ ];
  567. }
  568. }
  569. first.length = i;
  570. return first;
  571. },
  572. grep: function( elems, callback, inv ) {
  573. var ret = [], retVal;
  574. inv = !!inv;
  575. // Go through the array, only saving the items
  576. // that pass the validator function
  577. for ( var i = 0, length = elems.length; i < length; i++ ) {
  578. retVal = !!callback( elems[ i ], i );
  579. if ( inv !== retVal ) {
  580. ret.push( elems[ i ] );
  581. }
  582. }
  583. return ret;
  584. },
  585. // arg is for internal usage only
  586. map: function( elems, callback, arg ) {
  587. var ret = [], value;
  588. // Go through the array, translating each of the items to their
  589. // new value (or values).
  590. for ( var i = 0, length = elems.length; i < length; i++ ) {
  591. value = callback( elems[ i ], i, arg );
  592. if ( value != null ) {
  593. ret[ ret.length ] = value;
  594. }
  595. }
  596. return ret.concat.apply( [], ret );
  597. },
  598. // A global GUID counter for objects
  599. guid: 1,
  600. proxy: function( fn, proxy, thisObject ) {
  601. if ( arguments.length === 2 ) {
  602. if ( typeof proxy === "string" ) {
  603. thisObject = fn;
  604. fn = thisObject[ proxy ];
  605. proxy = undefined;
  606. } else if ( proxy && !jQuery.isFunction( proxy ) ) {
  607. thisObject = proxy;
  608. proxy = undefined;
  609. }
  610. }
  611. if ( !proxy && fn ) {
  612. proxy = function() {
  613. return fn.apply( thisObject || this, arguments );
  614. };
  615. }
  616. // Set the guid of unique handler to the same of original handler, so it can be removed
  617. if ( fn ) {
  618. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  619. }
  620. // So proxy can be declared as an argument
  621. return proxy;
  622. },
  623. // Mutifunctional method to get and set values to a collection
  624. // The value/s can be optionally by executed if its a function
  625. access: function( elems, key, value, exec, fn, pass ) {
  626. var length = elems.length;
  627. // Setting many attributes
  628. if ( typeof key === "object" ) {
  629. for ( var k in key ) {
  630. jQuery.access( elems, k, key[k], exec, fn, value );
  631. }
  632. return elems;
  633. }
  634. // Setting one attribute
  635. if ( value !== undefined ) {
  636. // Optionally, function values get executed if exec is true
  637. exec = !pass && exec && jQuery.isFunction(value);
  638. for ( var i = 0; i < length; i++ ) {
  639. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  640. }
  641. return elems;
  642. }
  643. // Getting an attribute
  644. return length ? fn( elems[0], key ) : undefined;
  645. },
  646. now: function() {
  647. return (new Date()).getTime();
  648. },
  649. // Use of jQuery.browser is frowned upon.
  650. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  651. uaMatch: function( ua ) {
  652. ua = ua.toLowerCase();
  653. var match = rwebkit.exec( ua ) ||
  654. ropera.exec( ua ) ||
  655. rmsie.exec( ua ) ||
  656. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  657. [];
  658. return { browser: match[1] || "", version: match[2] || "0" };
  659. },
  660. browser: {}
  661. });
  662. // Populate the class2type map
  663. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  664. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  665. });
  666. browserMatch = jQuery.uaMatch( userAgent );
  667. if ( browserMatch.browser ) {
  668. jQuery.browser[ browserMatch.browser ] = true;
  669. jQuery.browser.version = browserMatch.version;
  670. }
  671. // Deprecated, use jQuery.browser.webkit instead
  672. if ( jQuery.browser.webkit ) {
  673. jQuery.browser.safari = true;
  674. }
  675. if ( indexOf ) {
  676. jQuery.inArray = function( elem, array ) {
  677. return indexOf.call( array, elem );
  678. };
  679. }
  680. // Verify that \s matches non-breaking spaces
  681. // (IE fails on this test)
  682. if ( !rwhite.test( "\xA0" ) ) {
  683. trimLeft = /^[\s\xA0]+/;
  684. trimRight = /[\s\xA0]+$/;
  685. }
  686. // All jQuery objects should point back to these
  687. rootjQuery = jQuery(document);
  688. // Cleanup functions for the document ready method
  689. if ( document.addEventListener ) {
  690. DOMContentLoaded = function() {
  691. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  692. jQuery.ready();
  693. };
  694. } else if ( document.attachEvent ) {
  695. DOMContentLoaded = function() {
  696. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  697. if ( document.readyState === "complete" ) {
  698. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  699. jQuery.ready();
  700. }
  701. };
  702. }
  703. // The DOM ready check for Internet Explorer
  704. function doScrollCheck() {
  705. if ( jQuery.isReady ) {
  706. return;
  707. }
  708. try {
  709. // If IE is used, use the trick by Diego Perini
  710. // http://javascript.nwbox.com/IEContentLoaded/
  711. document.documentElement.doScroll("left");
  712. } catch(e) {
  713. setTimeout( doScrollCheck, 1 );
  714. return;
  715. }
  716. // and execute any waiting functions
  717. jQuery.ready();
  718. }
  719. // Expose jQuery to the global object
  720. return (window.jQuery = window.$ = jQuery);
  721. })();
  722. (function() {
  723. jQuery.support = {};
  724. var root = document.documentElement,
  725. script = document.createElement("script"),
  726. div = document.createElement("div"),
  727. id = "script" + jQuery.now();
  728. div.style.display = "none";
  729. div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
  730. var all = div.getElementsByTagName("*"),
  731. a = div.getElementsByTagName("a")[0],
  732. select = document.createElement("select"),
  733. opt = select.appendChild( document.createElement("option") );
  734. // Can't get basic test support
  735. if ( !all || !all.length || !a ) {
  736. return;
  737. }
  738. jQuery.support = {
  739. // IE strips leading whitespace when .innerHTML is used
  740. leadingWhitespace: div.firstChild.nodeType === 3,
  741. // Make sure that tbody elements aren't automatically inserted
  742. // IE will insert them into empty tables
  743. tbody: !div.getElementsByTagName("tbody").length,
  744. // Make sure that link elements get serialized correctly by innerHTML
  745. // This requires a wrapper element in IE
  746. htmlSerialize: !!div.getElementsByTagName("link").length,
  747. // Get the style information from getAttribute
  748. // (IE uses .cssText insted)
  749. style: /red/.test( a.getAttribute("style") ),
  750. // Make sure that URLs aren't manipulated
  751. // (IE normalizes it by default)
  752. hrefNormalized: a.getAttribute("href") === "/a",
  753. // Make sure that element opacity exists
  754. // (IE uses filter instead)
  755. // Use a regex to work around a WebKit issue. See #5145
  756. opacity: /^0.55$/.test( a.style.opacity ),
  757. // Verify style float existence
  758. // (IE uses styleFloat instead of cssFloat)
  759. cssFloat: !!a.style.cssFloat,
  760. // Make sure that if no value is specified for a checkbox
  761. // that it defaults to "on".
  762. // (WebKit defaults to "" instead)
  763. checkOn: div.getElementsByTagName("input")[0].value === "on",
  764. // Make sure that a selected-by-default option has a working selected property.
  765. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  766. optSelected: opt.selected,
  767. // Will be defined later
  768. optDisabled: false,
  769. checkClone: false,
  770. scriptEval: false,
  771. noCloneEvent: true,
  772. boxModel: null,
  773. inlineBlockNeedsLayout: false,
  774. shrinkWrapBlocks: false,
  775. reliableHiddenOffsets: true
  776. };
  777. // Make sure that the options inside disabled selects aren't marked as disabled
  778. // (WebKit marks them as diabled)
  779. select.disabled = true;
  780. jQuery.support.optDisabled = !opt.disabled;
  781. script.type = "text/javascript";
  782. try {
  783. script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
  784. } catch(e) {}
  785. root.insertBefore( script, root.firstChild );
  786. // Make sure that the execution of code works by injecting a script
  787. // tag with appendChild/createTextNode
  788. // (IE doesn't support this, fails, and uses .text instead)
  789. if ( window[ id ] ) {
  790. jQuery.support.scriptEval = true;
  791. delete window[ id ];
  792. }
  793. root.removeChild( script );
  794. if ( div.attachEvent && div.fireEvent ) {
  795. div.attachEvent("onclick", function click() {
  796. // Cloning a node shouldn't copy over any
  797. // bound event handlers (IE does this)
  798. jQuery.support.noCloneEvent = false;
  799. div.detachEvent("onclick", click);
  800. });
  801. div.cloneNode(true).fireEvent("onclick");
  802. }
  803. div = document.createElement("div");
  804. div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
  805. var fragment = document.createDocumentFragment();
  806. fragment.appendChild( div.firstChild );
  807. // WebKit doesn't clone checked state correctly in fragments
  808. jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
  809. // Figure out if the W3C box model works as expected
  810. // document.body must exist before we can do this
  811. jQuery(function() {
  812. var div = document.createElement("div");
  813. div.style.width = div.style.paddingLeft = "1px";
  814. document.body.appendChild( div );
  815. jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
  816. if ( "zoom" in div.style ) {
  817. // Check if natively block-level elements act like inline-block
  818. // elements when setting their display to 'inline' and giving
  819. // them layout
  820. // (IE < 8 does this)
  821. div.style.display = "inline";
  822. div.style.zoom = 1;
  823. jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
  824. // Check if elements with layout shrink-wrap their children
  825. // (IE 6 does this)
  826. div.style.display = "";
  827. div.innerHTML = "<div style='width:4px;'></div>";
  828. jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
  829. }
  830. div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>";
  831. var tds = div.getElementsByTagName("td");
  832. // Check if table cells still have offsetWidth/Height when they are set
  833. // to display:none and there are still other visible table cells in a
  834. // table row; if so, offsetWidth/Height are not reliable for use when
  835. // determining if an element has been hidden directly using
  836. // display:none (it is still safe to use offsets if a parent element is
  837. // hidden; don safety goggles and see bug #4512 for more information).
  838. // (only IE 8 fails this test)
  839. jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
  840. tds[0].style.display = "";
  841. tds[1].style.display = "none";
  842. // Check if empty table cells still have offsetWidth/Height
  843. // (IE < 8 fail this test)
  844. jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
  845. div.innerHTML = "";
  846. document.body.removeChild( div ).style.display = "none";
  847. div = tds = null;
  848. });
  849. // Technique from Juriy Zaytsev
  850. // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  851. var eventSupported = function( eventName ) {
  852. var el = document.createElement("div");
  853. eventName = "on" + eventName;
  854. var isSupported = (eventName in el);
  855. if ( !isSupported ) {
  856. el.setAttribute(eventName, "return;");
  857. isSupported = typeof el[eventName] === "function";
  858. }
  859. el = null;
  860. return isSupported;
  861. };
  862. jQuery.support.submitBubbles = eventSupported("submit");
  863. jQuery.support.changeBubbles = eventSupported("change");
  864. // release memory in IE
  865. root = script = div = all = a = null;
  866. })();
  867. jQuery.props = {
  868. "for": "htmlFor",
  869. "class": "className",
  870. readonly: "readOnly",
  871. maxlength: "maxLength",
  872. cellspacing: "cellSpacing",
  873. rowspan: "rowSpan",
  874. colspan: "colSpan",
  875. tabindex: "tabIndex",
  876. usemap: "useMap",
  877. frameborder: "frameBorder"
  878. };
  879. var windowData = {},
  880. rbrace = /^(?:\{.*\}|\[.*\])$/;
  881. jQuery.extend({
  882. cache: {},
  883. // Please use with caution
  884. uuid: 0,
  885. // Unique for each copy of jQuery on the page
  886. expando: "jQuery" + jQuery.now(),
  887. // The following elements throw uncatchable exceptions if you
  888. // attempt to add expando properties to them.
  889. noData: {
  890. "embed": true,
  891. // Ban all objects except for Flash (which handle expandos)
  892. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  893. "applet": true
  894. },
  895. data: function( elem, name, data ) {
  896. if ( !jQuery.acceptData( elem ) ) {
  897. return;
  898. }
  899. elem = elem == window ?
  900. windowData :
  901. elem;
  902. var isNode = elem.nodeType,
  903. id = isNode ? elem[ jQuery.expando ] : null,
  904. cache = jQuery.cache, thisCache;
  905. if ( isNode && !id && typeof name === "string" && data === undefined ) {
  906. return;
  907. }
  908. // Get the data from the object directly
  909. if ( !isNode ) {
  910. cache = elem;
  911. // Compute a unique ID for the element
  912. } else if ( !id ) {
  913. elem[ jQuery.expando ] = id = ++jQuery.uuid;
  914. }
  915. // Avoid generating a new cache unless none exists and we
  916. // want to manipulate it.
  917. if ( typeof name === "object" ) {
  918. if ( isNode ) {
  919. cache[ id ] = jQuery.extend(cache[ id ], name);
  920. } else {
  921. jQuery.extend( cache, name );
  922. }
  923. } else if ( isNode && !cache[ id ] ) {
  924. cache[ id ] = {};
  925. }
  926. thisCache = isNode ? cache[ id ] : cache;
  927. // Prevent overriding the named cache with undefined values
  928. if ( data !== undefined ) {
  929. thisCache[ name ] = data;
  930. }
  931. return typeof name === "string" ? thisCache[ name ] : thisCache;
  932. },
  933. removeData: function( elem, name ) {
  934. if ( !jQuery.acceptData( elem ) ) {
  935. return;
  936. }
  937. elem = elem == window ?
  938. windowData :
  939. elem;
  940. var isNode = elem.nodeType,
  941. id = isNode ? elem[ jQuery.expando ] : elem,
  942. cache = jQuery.cache,
  943. thisCache = isNode ? cache[ id ] : id;
  944. // If we want to remove a specific section of the element's data
  945. if ( name ) {
  946. if ( thisCache ) {
  947. // Remove the section of cache data
  948. delete thisCache[ name ];
  949. // If we've removed all the data, remove the element's cache
  950. if ( isNode && jQuery.isEmptyObject(thisCache) ) {
  951. jQuery.removeData( elem );
  952. }
  953. }
  954. // Otherwise, we want to remove all of the element's data
  955. } else {
  956. if ( isNode && jQuery.support.deleteExpando ) {
  957. delete elem[ jQuery.expando ];
  958. } else if ( elem.removeAttribute ) {
  959. elem.removeAttribute( jQuery.expando );
  960. // Completely remove the data cache
  961. } else if ( isNode ) {
  962. delete cache[ id ];
  963. // Remove all fields from the object
  964. } else {
  965. for ( var n in elem ) {
  966. delete elem[ n ];
  967. }
  968. }
  969. }
  970. },
  971. // A method for determining if a DOM node can handle the data expando
  972. acceptData: function( elem ) {
  973. if ( elem.nodeName ) {
  974. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  975. if ( match ) {
  976. return !(match === true || elem.getAttribute("classid") !== match);
  977. }
  978. }
  979. return true;
  980. }
  981. });
  982. jQuery.fn.extend({
  983. data: function( key, value ) {
  984. if ( typeof key === "undefined" ) {
  985. return this.length ? jQuery.data( this[0] ) : null;
  986. } else if ( typeof key === "object" ) {
  987. return this.each(function() {
  988. jQuery.data( this, key );
  989. });
  990. }
  991. var parts = key.split(".");
  992. parts[1] = parts[1] ? "." + parts[1] : "";
  993. if ( value === undefined ) {
  994. var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  995. // Try to fetch any internally stored data first
  996. if ( data === undefined && this.length ) {
  997. data = jQuery.data( this[0], key );
  998. // If nothing was found internally, try to fetch any
  999. // data from the HTML5 data-* attribute
  1000. if ( data === undefined && this[0].nodeType === 1 ) {
  1001. data = this[0].getAttribute( "data-" + key );
  1002. if ( typeof data === "string" ) {
  1003. try {
  1004. data = data === "true" ? true :
  1005. data === "false" ? false :
  1006. data === "null" ? null :
  1007. !jQuery.isNaN( data ) ? parseFloat( data ) :
  1008. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1009. data;
  1010. } catch( e ) {}
  1011. } else {
  1012. data = undefined;
  1013. }
  1014. }
  1015. }
  1016. return data === undefined && parts[1] ?
  1017. this.data( parts[0] ) :
  1018. data;
  1019. } else {
  1020. return this.each(function() {
  1021. var $this = jQuery( this ), args = [ parts[0], value ];
  1022. $this.triggerHandler( "setData" + parts[1] + "!", args );
  1023. jQuery.data( this, key, value );
  1024. $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1025. });
  1026. }
  1027. },
  1028. removeData: function( key ) {
  1029. return this.each(function() {
  1030. jQuery.removeData( this, key );
  1031. });
  1032. }
  1033. });
  1034. jQuery.extend({
  1035. queue: function( elem, type, data ) {
  1036. if ( !elem ) {
  1037. return;
  1038. }
  1039. type = (type || "fx") + "queue";
  1040. var q = jQuery.data( elem, type );
  1041. // Speed up dequeue by getting out quickly if this is just a lookup
  1042. if ( !data ) {
  1043. return q || [];
  1044. }
  1045. if ( !q || jQuery.isArray(data) ) {
  1046. q = jQuery.data( elem, type, jQuery.makeArray(data) );
  1047. } else {
  1048. q.push( data );
  1049. }
  1050. return q;
  1051. },
  1052. dequeue: function( elem, type ) {
  1053. type = type || "fx";
  1054. var queue = jQuery.queue( elem, type ), fn = queue.shift();
  1055. // If the fx queue is dequeued, always remove the progress sentinel
  1056. if ( fn === "inprogress" ) {
  1057. fn = queue.shift();
  1058. }
  1059. if ( fn ) {
  1060. // Add a progress sentinel to prevent the fx queue from being
  1061. // automatically dequeued
  1062. if ( type === "fx" ) {
  1063. queue.unshift("inprogress");
  1064. }
  1065. fn.call(elem, function() {
  1066. jQuery.dequeue(elem, type);
  1067. });
  1068. }
  1069. }
  1070. });
  1071. jQuery.fn.extend({
  1072. queue: function( type, data ) {
  1073. if ( typeof type !== "string" ) {
  1074. data = type;
  1075. type = "fx";
  1076. }
  1077. if ( data === undefined ) {
  1078. return jQuery.queue( this[0], type );
  1079. }
  1080. return this.each(function( i ) {
  1081. var queue = jQuery.queue( this, type, data );
  1082. if ( type === "fx" && queue[0] !== "inprogress" ) {
  1083. jQuery.dequeue( this, type );
  1084. }
  1085. });
  1086. },
  1087. dequeue: function( type ) {
  1088. return this.each(function() {
  1089. jQuery.dequeue( this, type );
  1090. });
  1091. },
  1092. // Based off of the plugin by Clint Helfers, with permission.
  1093. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  1094. delay: function( time, type ) {
  1095. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1096. type = type || "fx";
  1097. return this.queue( type, function() {
  1098. var elem = this;
  1099. setTimeout(function() {
  1100. jQuery.dequeue( elem, type );
  1101. }, time );
  1102. });
  1103. },
  1104. clearQueue: function( type ) {
  1105. return this.queue( type || "fx", [] );
  1106. }
  1107. });
  1108. var rclass = /[\n\t]/g,
  1109. rspaces = /\s+/,
  1110. rreturn = /\r/g,
  1111. rspecialurl = /^(?:href|src|style)$/,
  1112. rtype = /^(?:button|input)$/i,
  1113. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1114. rclickable = /^a(?:rea)?$/i,
  1115. rradiocheck = /^(?:radio|checkbox)$/i;
  1116. jQuery.fn.extend({
  1117. attr: function( name, value ) {
  1118. return jQuery.access( this, name, value, true, jQuery.attr );
  1119. },
  1120. removeAttr: function( name, fn ) {
  1121. return this.each(function(){
  1122. jQuery.attr( this, name, "" );
  1123. if ( this.nodeType === 1 ) {
  1124. this.removeAttribute( name );
  1125. }
  1126. });
  1127. },
  1128. addClass: function( value ) {
  1129. if ( jQuery.isFunction(value) ) {
  1130. return this.each(function(i) {
  1131. var self = jQuery(this);
  1132. self.addClass( value.call(this, i, self.attr("class")) );
  1133. });
  1134. }
  1135. if ( value && typeof value === "string" ) {
  1136. var classNames = (value || "").split( rspaces );
  1137. for ( var i = 0, l = this.length; i < l; i++ ) {
  1138. var elem = this[i];
  1139. if ( elem.nodeType === 1 ) {
  1140. if ( !elem.className ) {
  1141. elem.className = value;
  1142. } else {
  1143. var className = " " + elem.className + " ", setClass = elem.className;
  1144. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1145. if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
  1146. setClass += " " + classNames[c];
  1147. }
  1148. }
  1149. elem.className = jQuery.trim( setClass );
  1150. }
  1151. }
  1152. }
  1153. }
  1154. return this;
  1155. },
  1156. removeClass: function( value ) {
  1157. if ( jQuery.isFunction(value) ) {
  1158. return this.each(function(i) {
  1159. var self = jQuery(this);
  1160. self.removeClass( value.call(this, i, self.attr("class")) );
  1161. });
  1162. }
  1163. if ( (value && typeof value === "string") || value === undefined ) {
  1164. var classNames = (value || "").split( rspaces );
  1165. for ( var i = 0, l = this.length; i < l; i++ ) {
  1166. var elem = this[i];
  1167. if ( elem.nodeType === 1 && elem.className ) {
  1168. if ( value ) {
  1169. var className = (" " + elem.className + " ").replace(rclass, " ");
  1170. for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
  1171. className = className.replace(" " + classNames[c] + " ", " ");
  1172. }
  1173. elem.className = jQuery.trim( className );
  1174. } else {
  1175. elem.className = "";
  1176. }
  1177. }
  1178. }
  1179. }
  1180. return this;
  1181. },
  1182. toggleClass: function( value, stateVal ) {
  1183. var type = typeof value, isBool = typeof stateVal === "boolean";
  1184. if ( jQuery.isFunction( value ) ) {
  1185. return this.each(function(i) {
  1186. var self = jQuery(this);
  1187. self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
  1188. });
  1189. }
  1190. return this.each(function() {
  1191. if ( type === "string" ) {
  1192. // toggle individual class names
  1193. var className, i = 0, self = jQuery(this),
  1194. state = stateVal,
  1195. classNames = value.split( rspaces );
  1196. while ( (className = classNames[ i++ ]) ) {
  1197. // check each className given, space seperated list
  1198. state = isBool ? state : !self.hasClass( className );
  1199. self[ state ? "addClass" : "removeClass" ]( className );
  1200. }
  1201. } else if ( type === "undefined" || type === "boolean" ) {
  1202. if ( this.className ) {
  1203. // store className if set
  1204. jQuery.data( this, "__className__", this.className );
  1205. }
  1206. // toggle whole className
  1207. this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
  1208. }
  1209. });
  1210. },
  1211. hasClass: function( selector ) {
  1212. var className = " " + selector + " ";
  1213. for ( var i = 0, l = this.length; i < l; i++ ) {
  1214. if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  1215. return true;
  1216. }
  1217. }
  1218. return false;
  1219. },
  1220. val: function( value ) {
  1221. if ( !arguments.length ) {
  1222. var elem = this[0];
  1223. if ( elem ) {
  1224. if ( jQuery.nodeName( elem, "option" ) ) {
  1225. // attributes.value is undefined in Blackberry 4.7 but
  1226. // uses .value. See #6932
  1227. var val = elem.attributes.value;
  1228. return !val || val.specified ? elem.value : elem.text;
  1229. }
  1230. // We need to handle select boxes special
  1231. if ( jQuery.nodeName( elem, "select" ) ) {
  1232. var index = elem.selectedIndex,
  1233. values = [],
  1234. options = elem.options,
  1235. one = elem.type === "select-one";
  1236. // Nothing was selected
  1237. if ( index < 0 ) {
  1238. return null;
  1239. }
  1240. // Loop through all the selected options
  1241. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  1242. var option = options[ i ];
  1243. // Don't return options that are disabled or in a disabled optgroup
  1244. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  1245. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  1246. // Get the specific value for the option
  1247. value = jQuery(option).val();
  1248. // We don't need an array for one selects
  1249. if ( one ) {
  1250. return value;
  1251. }
  1252. // Multi-Selects return an array
  1253. values.push( value );
  1254. }
  1255. }
  1256. return values;
  1257. }
  1258. // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
  1259. if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
  1260. return elem.getAttribute("value") === null ? "on" : elem.value;
  1261. }
  1262. // Everything else, we just grab the value
  1263. return (elem.value || "").replace(rreturn, "");
  1264. }
  1265. return undefined;
  1266. }
  1267. var isFunction = jQuery.isFunction(value);
  1268. return this.each(function(i) {
  1269. var self = jQuery(this), val = value;
  1270. if ( this.nodeType !== 1 ) {
  1271. return;
  1272. }
  1273. if ( isFunction ) {
  1274. val = value.call(this, i, self.val());
  1275. }
  1276. // Treat null/undefined as ""; convert numbers to string
  1277. if ( val == null ) {
  1278. val = "";
  1279. } else if ( typeof val === "number" ) {
  1280. val += "";
  1281. } else if ( jQuery.isArray(val) ) {
  1282. val = jQuery.map(val, function (value) {
  1283. return value == null ? "" : value + "";
  1284. });
  1285. }
  1286. if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
  1287. this.checked = jQuery.inArray( self.val(), val ) >= 0;
  1288. } else if ( jQuery.nodeName( this, "select" ) ) {
  1289. var values = jQuery.makeArray(val);
  1290. jQuery( "option", this ).each(function() {
  1291. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  1292. });
  1293. if ( !values.length ) {
  1294. this.selectedIndex = -1;
  1295. }
  1296. } else {
  1297. this.value = val;
  1298. }
  1299. });
  1300. }
  1301. });
  1302. jQuery.extend({
  1303. attrFn: {
  1304. val: true,
  1305. css: true,
  1306. html: true,
  1307. text: true,
  1308. data: true,
  1309. width: true,
  1310. height: true,
  1311. offset: true
  1312. },
  1313. attr: function( elem, name, value, pass ) {
  1314. // don't set attributes on text and comment nodes
  1315. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
  1316. return undefined;
  1317. }
  1318. if ( pass && name in jQuery.attrFn ) {
  1319. return jQuery(elem)[name](value);
  1320. }
  1321. var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
  1322. // Whether we are setting (or getting)
  1323. set = value !== undefined;
  1324. // Try to normalize/fix the name
  1325. name = notxml && jQuery.props[ name ] || name;
  1326. // Only do all the following if this is a node (faster for style)
  1327. if ( elem.nodeType === 1 ) {
  1328. // These attributes require special treatment
  1329. var special = rspecialurl.test( name );
  1330. // Safari mis-reports the default selected property of an option
  1331. // Accessing the parent's selectedIndex property fixes it
  1332. if ( name === "selected" && !jQuery.support.optSelected ) {
  1333. var parent = elem.parentNode;
  1334. if ( parent ) {
  1335. parent.selectedIndex;
  1336. // Make sure that it also works with optgroups, see #5701
  1337. if ( parent.parentNode ) {
  1338. parent.parentNode.selectedIndex;
  1339. }
  1340. }
  1341. }
  1342. // If applicable, access the attribute via the DOM 0 way
  1343. // 'in' checks fail in Blackberry 4.7 #6931
  1344. if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
  1345. if ( set ) {
  1346. // We can't allow the type property to be changed (since it causes problems in IE)
  1347. if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
  1348. jQuery.error( "type property can't be changed" );
  1349. }
  1350. if ( value === null ) {
  1351. if ( elem.nodeType === 1 ) {
  1352. elem.removeAttribute( name );
  1353. }
  1354. } else {
  1355. elem[ name ] = value;
  1356. }
  1357. }
  1358. // browsers index elements by id/name on forms, give priority to attributes.
  1359. if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
  1360. return elem.getAttributeNode( name ).nodeValue;
  1361. }
  1362. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  1363. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  1364. if ( name === "tabIndex" ) {
  1365. var attributeNode = elem.getAttributeNode( "tabIndex" );
  1366. return attributeNode && attributeNode.specified ?
  1367. attributeNode.value :
  1368. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  1369. 0 :
  1370. undefined;
  1371. }
  1372. return elem[ name ];
  1373. }
  1374. if ( !jQuery.support.style && notxml && name === "style" ) {
  1375. if ( set ) {
  1376. elem.style.cssText = "" + value;
  1377. }
  1378. return elem.style.cssText;
  1379. }
  1380. if ( set ) {
  1381. // convert the value to a string (all browsers do this but IE) see #1070
  1382. elem.setAttribute( name, "" + value );
  1383. }
  1384. // Ensure that missing attributes return undefined
  1385. // Blackberry 4.7 returns "" from getAttribute #6938
  1386. if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
  1387. return undefined;
  1388. }
  1389. var attr = !jQuery.support.hrefNormalized && notxml && special ?
  1390. // Some attributes require a special call on IE
  1391. elem.getAttribute( name, 2 ) :
  1392. elem.getAttribute( name );
  1393. // Non-existent attributes return null, we normalize to undefined
  1394. return attr === null ? undefined : attr;
  1395. }
  1396. }
  1397. });
  1398. var rnamespaces = /\.(.*)$/,
  1399. rformElems = /^(?:textarea|input|select)$/i,
  1400. rperiod = /\./g,
  1401. rspace = / /g,
  1402. rescape = /[^\w\s.|`]/g,
  1403. fcleanup = function( nm ) {
  1404. return nm.replace(rescape, "\\$&");
  1405. };
  1406. /*
  1407. * A number of helper functions used for managing events.
  1408. * Many of the ideas behind this code originated from
  1409. * Dean Edwards' addEvent library.
  1410. */
  1411. jQuery.event = {
  1412. // Bind an event to an element
  1413. // Original by Dean Edwards
  1414. add: function( elem, types, handler, data ) {
  1415. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1416. return;
  1417. }
  1418. // For whatever reason, IE has trouble passing the window object
  1419. // around, causing it to be cloned in the process
  1420. if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
  1421. elem = window;
  1422. }
  1423. if ( handler === false ) {
  1424. handler = returnFalse;
  1425. }
  1426. var handleObjIn, handleObj;
  1427. if ( handler.handler ) {
  1428. handleObjIn = handler;
  1429. handler = handleObjIn.handler;
  1430. }
  1431. // Make sure that the function being executed has a unique ID
  1432. if ( !handler.guid ) {
  1433. handler.guid = jQuery.guid++;
  1434. }
  1435. // Init the element's event structure
  1436. var elemData = jQuery.data( elem );
  1437. // If no elemData is found then we must be trying to bind to one of the
  1438. // banned noData elements
  1439. if ( !elemData ) {
  1440. return;
  1441. }
  1442. var events = elemData.events,
  1443. eventHandle = elemData.handle;
  1444. if ( typeof events === "function" ) {
  1445. // On plain objects events is a fn that holds the the data
  1446. // which prevents this data from being JSON serialized
  1447. // the function does not need to be called, it just contains the data
  1448. eventHandle = events.handle;
  1449. events = events.events;
  1450. } else if ( !events ) {
  1451. if ( !elem.nodeType ) {
  1452. // On plain objects, create a fn that acts as the holder
  1453. // of the values to avoid JSON serialization of event data
  1454. elemData.events = elemData = function(){};
  1455. }
  1456. elemData.events = events = {};
  1457. }
  1458. if ( !eventHandle ) {
  1459. elemData.handle = eventHandle = function() {
  1460. // Handle the second event of a trigger and when
  1461. // an event is called after a page has unloaded
  1462. return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
  1463. jQuery.event.handle.apply( eventHandle.elem, arguments ) :
  1464. undefined;
  1465. };
  1466. }
  1467. // Add elem as a property of the handle function
  1468. // This is to prevent a memory leak with non-native events in IE.
  1469. eventHandle.elem = elem;
  1470. // Handle multiple events separated by a space
  1471. // jQuery(...).bind("mouseover mouseout", fn);
  1472. types = types.split(" ");
  1473. var type, i = 0, namespaces;
  1474. while ( (type = types[ i++ ]) ) {
  1475. handleObj = handleObjIn ?
  1476. jQuery.extend({}, handleObjIn) :
  1477. { handler: handler, data: data };
  1478. // Namespaced event handlers
  1479. if ( type.indexOf(".") > -1 ) {
  1480. namespaces = type.split(".");
  1481. type = namespaces.shift();
  1482. handleObj.namespace = namespaces.slice(0).sort().join(".");
  1483. } else {
  1484. namespaces = [];
  1485. handleObj.namespace = "";
  1486. }
  1487. handleObj.type = type;
  1488. if ( !handleObj.guid ) {
  1489. handleObj.guid = handler.guid;
  1490. }
  1491. // Get the current list of functions bound to this event
  1492. var handlers = events[ type ],
  1493. special = jQuery.event.special[ type ] || {};
  1494. // Init the event handler queue
  1495. if ( !handlers ) {
  1496. handlers = events[ type ] = [];
  1497. // Check for a special event handler
  1498. // Only use addEventListener/attachEvent if the special
  1499. // events handler returns false
  1500. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  1501. // Bind the global event handler to the element
  1502. if ( elem.addEventListener ) {
  1503. elem.addEventListener( type, eventHandle, false );
  1504. } else if ( elem.attachEvent ) {
  1505. elem.attachEvent( "on" + type, eventHandle );
  1506. }
  1507. }
  1508. }
  1509. if ( special.add ) {
  1510. special.add.call( elem, handleObj );
  1511. if ( !handleObj.handler.guid ) {
  1512. handleObj.handler.guid = handler.guid;
  1513. }
  1514. }
  1515. // Add the function to the element's handler list
  1516. handlers.push( handleObj );
  1517. // Keep track of which events have been used, for global triggering
  1518. jQuery.event.global[ type ] = true;
  1519. }
  1520. // Nullify elem to prevent memory leaks in IE
  1521. elem = null;
  1522. },
  1523. global: {},
  1524. // Detach an event or set of events from an element
  1525. remove: function( elem, types, handler, pos ) {
  1526. // don't do events on text and comment nodes
  1527. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  1528. return;
  1529. }
  1530. if…