PageRenderTime 161ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 4ms

/public/assets/admin/application-2ec33b0347e5b490fc9aa8f9a1bc1984.js

https://gitlab.com/balajigalave/Ruby-CMS
JavaScript | 14667 lines | 9834 code | 2610 blank | 2223 comment | 2827 complexity | b172b37411e7fc1590fd19da57d992b5 MD5 | raw file
  1. /*!
  2. * jQuery JavaScript Library v1.11.3
  3. * http://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * http://sizzlejs.com/
  7. *
  8. * Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors
  9. * Released under the MIT license
  10. * http://jquery.org/license
  11. *
  12. * Date: 2015-04-28T16:19Z
  13. */
  14. (function( global, factory ) {
  15. if ( typeof module === "object" && typeof module.exports === "object" ) {
  16. // For CommonJS and CommonJS-like environments where a proper window is present,
  17. // execute the factory and get jQuery
  18. // For environments that do not inherently posses a window with a document
  19. // (such as Node.js), expose a jQuery-making factory as module.exports
  20. // This accentuates the need for the creation of a real window
  21. // e.g. var jQuery = require("jquery")(window);
  22. // See ticket #14549 for more info
  23. module.exports = global.document ?
  24. factory( global, true ) :
  25. function( w ) {
  26. if ( !w.document ) {
  27. throw new Error( "jQuery requires a window with a document" );
  28. }
  29. return factory( w );
  30. };
  31. } else {
  32. factory( global );
  33. }
  34. // Pass this if window is not defined yet
  35. }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  36. // Can't do this because several apps including ASP.NET trace
  37. // the stack via arguments.caller.callee and Firefox dies if
  38. // you try to trace through "use strict" call chains. (#13335)
  39. // Support: Firefox 18+
  40. //
  41. var deletedIds = [];
  42. var slice = deletedIds.slice;
  43. var concat = deletedIds.concat;
  44. var push = deletedIds.push;
  45. var indexOf = deletedIds.indexOf;
  46. var class2type = {};
  47. var toString = class2type.toString;
  48. var hasOwn = class2type.hasOwnProperty;
  49. var support = {};
  50. var
  51. version = "1.11.3",
  52. // Define a local copy of jQuery
  53. jQuery = function( selector, context ) {
  54. // The jQuery object is actually just the init constructor 'enhanced'
  55. // Need init if jQuery is called (just allow error to be thrown if not included)
  56. return new jQuery.fn.init( selector, context );
  57. },
  58. // Support: Android<4.1, IE<9
  59. // Make sure we trim BOM and NBSP
  60. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
  61. // Matches dashed string for camelizing
  62. rmsPrefix = /^-ms-/,
  63. rdashAlpha = /-([\da-z])/gi,
  64. // Used by jQuery.camelCase as callback to replace()
  65. fcamelCase = function( all, letter ) {
  66. return letter.toUpperCase();
  67. };
  68. jQuery.fn = jQuery.prototype = {
  69. // The current version of jQuery being used
  70. jquery: version,
  71. constructor: jQuery,
  72. // Start with an empty selector
  73. selector: "",
  74. // The default length of a jQuery object is 0
  75. length: 0,
  76. toArray: function() {
  77. return slice.call( this );
  78. },
  79. // Get the Nth element in the matched element set OR
  80. // Get the whole matched element set as a clean array
  81. get: function( num ) {
  82. return num != null ?
  83. // Return just the one element from the set
  84. ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
  85. // Return all the elements in a clean array
  86. slice.call( this );
  87. },
  88. // Take an array of elements and push it onto the stack
  89. // (returning the new matched element set)
  90. pushStack: function( elems ) {
  91. // Build a new jQuery matched element set
  92. var ret = jQuery.merge( this.constructor(), elems );
  93. // Add the old object onto the stack (as a reference)
  94. ret.prevObject = this;
  95. ret.context = this.context;
  96. // Return the newly-formed element set
  97. return ret;
  98. },
  99. // Execute a callback for every element in the matched set.
  100. // (You can seed the arguments with an array of args, but this is
  101. // only used internally.)
  102. each: function( callback, args ) {
  103. return jQuery.each( this, callback, args );
  104. },
  105. map: function( callback ) {
  106. return this.pushStack( jQuery.map(this, function( elem, i ) {
  107. return callback.call( elem, i, elem );
  108. }));
  109. },
  110. slice: function() {
  111. return this.pushStack( slice.apply( this, arguments ) );
  112. },
  113. first: function() {
  114. return this.eq( 0 );
  115. },
  116. last: function() {
  117. return this.eq( -1 );
  118. },
  119. eq: function( i ) {
  120. var len = this.length,
  121. j = +i + ( i < 0 ? len : 0 );
  122. return this.pushStack( j >= 0 && j < len ? [ this[j] ] : [] );
  123. },
  124. end: function() {
  125. return this.prevObject || this.constructor(null);
  126. },
  127. // For internal use only.
  128. // Behaves like an Array's method, not like a jQuery method.
  129. push: push,
  130. sort: deletedIds.sort,
  131. splice: deletedIds.splice
  132. };
  133. jQuery.extend = jQuery.fn.extend = function() {
  134. var src, copyIsArray, copy, name, options, clone,
  135. target = arguments[0] || {},
  136. i = 1,
  137. length = arguments.length,
  138. deep = false;
  139. // Handle a deep copy situation
  140. if ( typeof target === "boolean" ) {
  141. deep = target;
  142. // skip the boolean and the target
  143. target = arguments[ i ] || {};
  144. i++;
  145. }
  146. // Handle case when target is a string or something (possible in deep copy)
  147. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  148. target = {};
  149. }
  150. // extend jQuery itself if only one argument is passed
  151. if ( i === length ) {
  152. target = this;
  153. i--;
  154. }
  155. for ( ; i < length; i++ ) {
  156. // Only deal with non-null/undefined values
  157. if ( (options = arguments[ i ]) != null ) {
  158. // Extend the base object
  159. for ( name in options ) {
  160. src = target[ name ];
  161. copy = options[ name ];
  162. // Prevent never-ending loop
  163. if ( target === copy ) {
  164. continue;
  165. }
  166. // Recurse if we're merging plain objects or arrays
  167. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  168. if ( copyIsArray ) {
  169. copyIsArray = false;
  170. clone = src && jQuery.isArray(src) ? src : [];
  171. } else {
  172. clone = src && jQuery.isPlainObject(src) ? src : {};
  173. }
  174. // Never move original objects, clone them
  175. target[ name ] = jQuery.extend( deep, clone, copy );
  176. // Don't bring in undefined values
  177. } else if ( copy !== undefined ) {
  178. target[ name ] = copy;
  179. }
  180. }
  181. }
  182. }
  183. // Return the modified object
  184. return target;
  185. };
  186. jQuery.extend({
  187. // Unique for each copy of jQuery on the page
  188. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  189. // Assume jQuery is ready without the ready module
  190. isReady: true,
  191. error: function( msg ) {
  192. throw new Error( msg );
  193. },
  194. noop: function() {},
  195. // See test/unit/core.js for details concerning isFunction.
  196. // Since version 1.3, DOM methods and functions like alert
  197. // aren't supported. They return false on IE (#2968).
  198. isFunction: function( obj ) {
  199. return jQuery.type(obj) === "function";
  200. },
  201. isArray: Array.isArray || function( obj ) {
  202. return jQuery.type(obj) === "array";
  203. },
  204. isWindow: function( obj ) {
  205. /* jshint eqeqeq: false */
  206. return obj != null && obj == obj.window;
  207. },
  208. isNumeric: function( obj ) {
  209. // parseFloat NaNs numeric-cast false positives (null|true|false|"")
  210. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  211. // subtraction forces infinities to NaN
  212. // adding 1 corrects loss of precision from parseFloat (#15100)
  213. return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
  214. },
  215. isEmptyObject: function( obj ) {
  216. var name;
  217. for ( name in obj ) {
  218. return false;
  219. }
  220. return true;
  221. },
  222. isPlainObject: function( obj ) {
  223. var key;
  224. // Must be an Object.
  225. // Because of IE, we also have to check the presence of the constructor property.
  226. // Make sure that DOM nodes and window objects don't pass through, as well
  227. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  228. return false;
  229. }
  230. try {
  231. // Not own constructor property must be Object
  232. if ( obj.constructor &&
  233. !hasOwn.call(obj, "constructor") &&
  234. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  235. return false;
  236. }
  237. } catch ( e ) {
  238. // IE8,9 Will throw exceptions on certain host objects #9897
  239. return false;
  240. }
  241. // Support: IE<9
  242. // Handle iteration over inherited properties before own properties.
  243. if ( support.ownLast ) {
  244. for ( key in obj ) {
  245. return hasOwn.call( obj, key );
  246. }
  247. }
  248. // Own properties are enumerated firstly, so to speed up,
  249. // if last one is own, then all properties are own.
  250. for ( key in obj ) {}
  251. return key === undefined || hasOwn.call( obj, key );
  252. },
  253. type: function( obj ) {
  254. if ( obj == null ) {
  255. return obj + "";
  256. }
  257. return typeof obj === "object" || typeof obj === "function" ?
  258. class2type[ toString.call(obj) ] || "object" :
  259. typeof obj;
  260. },
  261. // Evaluates a script in a global context
  262. // Workarounds based on findings by Jim Driscoll
  263. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  264. globalEval: function( data ) {
  265. if ( data && jQuery.trim( data ) ) {
  266. // We use execScript on Internet Explorer
  267. // We use an anonymous function so that context is window
  268. // rather than jQuery in Firefox
  269. ( window.execScript || function( data ) {
  270. window[ "eval" ].call( window, data );
  271. } )( data );
  272. }
  273. },
  274. // Convert dashed to camelCase; used by the css and data modules
  275. // Microsoft forgot to hump their vendor prefix (#9572)
  276. camelCase: function( string ) {
  277. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  278. },
  279. nodeName: function( elem, name ) {
  280. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  281. },
  282. // args is for internal usage only
  283. each: function( obj, callback, args ) {
  284. var value,
  285. i = 0,
  286. length = obj.length,
  287. isArray = isArraylike( obj );
  288. if ( args ) {
  289. if ( isArray ) {
  290. for ( ; i < length; i++ ) {
  291. value = callback.apply( obj[ i ], args );
  292. if ( value === false ) {
  293. break;
  294. }
  295. }
  296. } else {
  297. for ( i in obj ) {
  298. value = callback.apply( obj[ i ], args );
  299. if ( value === false ) {
  300. break;
  301. }
  302. }
  303. }
  304. // A special, fast, case for the most common use of each
  305. } else {
  306. if ( isArray ) {
  307. for ( ; i < length; i++ ) {
  308. value = callback.call( obj[ i ], i, obj[ i ] );
  309. if ( value === false ) {
  310. break;
  311. }
  312. }
  313. } else {
  314. for ( i in obj ) {
  315. value = callback.call( obj[ i ], i, obj[ i ] );
  316. if ( value === false ) {
  317. break;
  318. }
  319. }
  320. }
  321. }
  322. return obj;
  323. },
  324. // Support: Android<4.1, IE<9
  325. trim: function( text ) {
  326. return text == null ?
  327. "" :
  328. ( text + "" ).replace( rtrim, "" );
  329. },
  330. // results is for internal usage only
  331. makeArray: function( arr, results ) {
  332. var ret = results || [];
  333. if ( arr != null ) {
  334. if ( isArraylike( Object(arr) ) ) {
  335. jQuery.merge( ret,
  336. typeof arr === "string" ?
  337. [ arr ] : arr
  338. );
  339. } else {
  340. push.call( ret, arr );
  341. }
  342. }
  343. return ret;
  344. },
  345. inArray: function( elem, arr, i ) {
  346. var len;
  347. if ( arr ) {
  348. if ( indexOf ) {
  349. return indexOf.call( arr, elem, i );
  350. }
  351. len = arr.length;
  352. i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
  353. for ( ; i < len; i++ ) {
  354. // Skip accessing in sparse arrays
  355. if ( i in arr && arr[ i ] === elem ) {
  356. return i;
  357. }
  358. }
  359. }
  360. return -1;
  361. },
  362. merge: function( first, second ) {
  363. var len = +second.length,
  364. j = 0,
  365. i = first.length;
  366. while ( j < len ) {
  367. first[ i++ ] = second[ j++ ];
  368. }
  369. // Support: IE<9
  370. // Workaround casting of .length to NaN on otherwise arraylike objects (e.g., NodeLists)
  371. if ( len !== len ) {
  372. while ( second[j] !== undefined ) {
  373. first[ i++ ] = second[ j++ ];
  374. }
  375. }
  376. first.length = i;
  377. return first;
  378. },
  379. grep: function( elems, callback, invert ) {
  380. var callbackInverse,
  381. matches = [],
  382. i = 0,
  383. length = elems.length,
  384. callbackExpect = !invert;
  385. // Go through the array, only saving the items
  386. // that pass the validator function
  387. for ( ; i < length; i++ ) {
  388. callbackInverse = !callback( elems[ i ], i );
  389. if ( callbackInverse !== callbackExpect ) {
  390. matches.push( elems[ i ] );
  391. }
  392. }
  393. return matches;
  394. },
  395. // arg is for internal usage only
  396. map: function( elems, callback, arg ) {
  397. var value,
  398. i = 0,
  399. length = elems.length,
  400. isArray = isArraylike( elems ),
  401. ret = [];
  402. // Go through the array, translating each of the items to their new values
  403. if ( isArray ) {
  404. for ( ; i < length; i++ ) {
  405. value = callback( elems[ i ], i, arg );
  406. if ( value != null ) {
  407. ret.push( value );
  408. }
  409. }
  410. // Go through every key on the object,
  411. } else {
  412. for ( i in elems ) {
  413. value = callback( elems[ i ], i, arg );
  414. if ( value != null ) {
  415. ret.push( value );
  416. }
  417. }
  418. }
  419. // Flatten any nested arrays
  420. return concat.apply( [], ret );
  421. },
  422. // A global GUID counter for objects
  423. guid: 1,
  424. // Bind a function to a context, optionally partially applying any
  425. // arguments.
  426. proxy: function( fn, context ) {
  427. var args, proxy, tmp;
  428. if ( typeof context === "string" ) {
  429. tmp = fn[ context ];
  430. context = fn;
  431. fn = tmp;
  432. }
  433. // Quick check to determine if target is callable, in the spec
  434. // this throws a TypeError, but we will just return undefined.
  435. if ( !jQuery.isFunction( fn ) ) {
  436. return undefined;
  437. }
  438. // Simulated bind
  439. args = slice.call( arguments, 2 );
  440. proxy = function() {
  441. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  442. };
  443. // Set the guid of unique handler to the same of original handler, so it can be removed
  444. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  445. return proxy;
  446. },
  447. now: function() {
  448. return +( new Date() );
  449. },
  450. // jQuery.support is not used in Core but other projects attach their
  451. // properties to it so it needs to exist.
  452. support: support
  453. });
  454. // Populate the class2type map
  455. jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
  456. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  457. });
  458. function isArraylike( obj ) {
  459. // Support: iOS 8.2 (not reproducible in simulator)
  460. // `in` check used to prevent JIT error (gh-2145)
  461. // hasOwn isn't used here due to false negatives
  462. // regarding Nodelist length in IE
  463. var length = "length" in obj && obj.length,
  464. type = jQuery.type( obj );
  465. if ( type === "function" || jQuery.isWindow( obj ) ) {
  466. return false;
  467. }
  468. if ( obj.nodeType === 1 && length ) {
  469. return true;
  470. }
  471. return type === "array" || length === 0 ||
  472. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  473. }
  474. var Sizzle =
  475. /*!
  476. * Sizzle CSS Selector Engine v2.2.0-pre
  477. * http://sizzlejs.com/
  478. *
  479. * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
  480. * Released under the MIT license
  481. * http://jquery.org/license
  482. *
  483. * Date: 2014-12-16
  484. */
  485. (function( window ) {
  486. var i,
  487. support,
  488. Expr,
  489. getText,
  490. isXML,
  491. tokenize,
  492. compile,
  493. select,
  494. outermostContext,
  495. sortInput,
  496. hasDuplicate,
  497. // Local document vars
  498. setDocument,
  499. document,
  500. docElem,
  501. documentIsHTML,
  502. rbuggyQSA,
  503. rbuggyMatches,
  504. matches,
  505. contains,
  506. // Instance-specific data
  507. expando = "sizzle" + 1 * new Date(),
  508. preferredDoc = window.document,
  509. dirruns = 0,
  510. done = 0,
  511. classCache = createCache(),
  512. tokenCache = createCache(),
  513. compilerCache = createCache(),
  514. sortOrder = function( a, b ) {
  515. if ( a === b ) {
  516. hasDuplicate = true;
  517. }
  518. return 0;
  519. },
  520. // General-purpose constants
  521. MAX_NEGATIVE = 1 << 31,
  522. // Instance methods
  523. hasOwn = ({}).hasOwnProperty,
  524. arr = [],
  525. pop = arr.pop,
  526. push_native = arr.push,
  527. push = arr.push,
  528. slice = arr.slice,
  529. // Use a stripped-down indexOf as it's faster than native
  530. // http://jsperf.com/thor-indexof-vs-for/5
  531. indexOf = function( list, elem ) {
  532. var i = 0,
  533. len = list.length;
  534. for ( ; i < len; i++ ) {
  535. if ( list[i] === elem ) {
  536. return i;
  537. }
  538. }
  539. return -1;
  540. },
  541. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  542. // Regular expressions
  543. // Whitespace characters http://www.w3.org/TR/css3-selectors/#whitespace
  544. whitespace = "[\\x20\\t\\r\\n\\f]",
  545. // http://www.w3.org/TR/css3-syntax/#characters
  546. characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",
  547. // Loosely modeled on CSS identifier characters
  548. // An unquoted value should be a CSS identifier http://www.w3.org/TR/css3-selectors/#attribute-selectors
  549. // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  550. identifier = characterEncoding.replace( "w", "w#" ),
  551. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  552. attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
  553. // Operator (capture 2)
  554. "*([*^$|!~]?=)" + whitespace +
  555. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  556. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  557. "*\\]",
  558. pseudos = ":(" + characterEncoding + ")(?:\\((" +
  559. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  560. // 1. quoted (capture 3; capture 4 or capture 5)
  561. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  562. // 2. simple (capture 6)
  563. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  564. // 3. anything else (capture 2)
  565. ".*" +
  566. ")\\)|)",
  567. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  568. rwhitespace = new RegExp( whitespace + "+", "g" ),
  569. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  570. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  571. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  572. rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ),
  573. rpseudo = new RegExp( pseudos ),
  574. ridentifier = new RegExp( "^" + identifier + "$" ),
  575. matchExpr = {
  576. "ID": new RegExp( "^#(" + characterEncoding + ")" ),
  577. "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
  578. "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
  579. "ATTR": new RegExp( "^" + attributes ),
  580. "PSEUDO": new RegExp( "^" + pseudos ),
  581. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  582. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  583. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  584. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  585. // For use in libraries implementing .is()
  586. // We use this for POS matching in `select`
  587. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  588. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  589. },
  590. rinputs = /^(?:input|select|textarea|button)$/i,
  591. rheader = /^h\d$/i,
  592. rnative = /^[^{]+\{\s*\[native \w/,
  593. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  594. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  595. rsibling = /[+~]/,
  596. rescape = /'|\\/g,
  597. // CSS escapes http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  598. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  599. funescape = function( _, escaped, escapedWhitespace ) {
  600. var high = "0x" + escaped - 0x10000;
  601. // NaN means non-codepoint
  602. // Support: Firefox<24
  603. // Workaround erroneous numeric interpretation of +"0x"
  604. return high !== high || escapedWhitespace ?
  605. escaped :
  606. high < 0 ?
  607. // BMP codepoint
  608. String.fromCharCode( high + 0x10000 ) :
  609. // Supplemental Plane codepoint (surrogate pair)
  610. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  611. },
  612. // Used for iframes
  613. // See setDocument()
  614. // Removing the function wrapper causes a "Permission Denied"
  615. // error in IE
  616. unloadHandler = function() {
  617. setDocument();
  618. };
  619. // Optimize for push.apply( _, NodeList )
  620. try {
  621. push.apply(
  622. (arr = slice.call( preferredDoc.childNodes )),
  623. preferredDoc.childNodes
  624. );
  625. // Support: Android<4.0
  626. // Detect silently failing push.apply
  627. arr[ preferredDoc.childNodes.length ].nodeType;
  628. } catch ( e ) {
  629. push = { apply: arr.length ?
  630. // Leverage slice if possible
  631. function( target, els ) {
  632. push_native.apply( target, slice.call(els) );
  633. } :
  634. // Support: IE<9
  635. // Otherwise append directly
  636. function( target, els ) {
  637. var j = target.length,
  638. i = 0;
  639. // Can't trust NodeList.length
  640. while ( (target[j++] = els[i++]) ) {}
  641. target.length = j - 1;
  642. }
  643. };
  644. }
  645. function Sizzle( selector, context, results, seed ) {
  646. var match, elem, m, nodeType,
  647. // QSA vars
  648. i, groups, old, nid, newContext, newSelector;
  649. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  650. setDocument( context );
  651. }
  652. context = context || document;
  653. results = results || [];
  654. nodeType = context.nodeType;
  655. if ( typeof selector !== "string" || !selector ||
  656. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  657. return results;
  658. }
  659. if ( !seed && documentIsHTML ) {
  660. // Try to shortcut find operations when possible (e.g., not under DocumentFragment)
  661. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  662. // Speed-up: Sizzle("#ID")
  663. if ( (m = match[1]) ) {
  664. if ( nodeType === 9 ) {
  665. elem = context.getElementById( m );
  666. // Check parentNode to catch when Blackberry 4.6 returns
  667. // nodes that are no longer in the document (jQuery #6963)
  668. if ( elem && elem.parentNode ) {
  669. // Handle the case where IE, Opera, and Webkit return items
  670. // by name instead of ID
  671. if ( elem.id === m ) {
  672. results.push( elem );
  673. return results;
  674. }
  675. } else {
  676. return results;
  677. }
  678. } else {
  679. // Context is not a document
  680. if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) &&
  681. contains( context, elem ) && elem.id === m ) {
  682. results.push( elem );
  683. return results;
  684. }
  685. }
  686. // Speed-up: Sizzle("TAG")
  687. } else if ( match[2] ) {
  688. push.apply( results, context.getElementsByTagName( selector ) );
  689. return results;
  690. // Speed-up: Sizzle(".CLASS")
  691. } else if ( (m = match[3]) && support.getElementsByClassName ) {
  692. push.apply( results, context.getElementsByClassName( m ) );
  693. return results;
  694. }
  695. }
  696. // QSA path
  697. if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
  698. nid = old = expando;
  699. newContext = context;
  700. newSelector = nodeType !== 1 && selector;
  701. // qSA works strangely on Element-rooted queries
  702. // We can work around this by specifying an extra ID on the root
  703. // and working up from there (Thanks to Andrew Dupont for the technique)
  704. // IE 8 doesn't work on object elements
  705. if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  706. groups = tokenize( selector );
  707. if ( (old = context.getAttribute("id")) ) {
  708. nid = old.replace( rescape, "\\$&" );
  709. } else {
  710. context.setAttribute( "id", nid );
  711. }
  712. nid = "[id='" + nid + "'] ";
  713. i = groups.length;
  714. while ( i-- ) {
  715. groups[i] = nid + toSelector( groups[i] );
  716. }
  717. newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context;
  718. newSelector = groups.join(",");
  719. }
  720. if ( newSelector ) {
  721. try {
  722. push.apply( results,
  723. newContext.querySelectorAll( newSelector )
  724. );
  725. return results;
  726. } catch(qsaError) {
  727. } finally {
  728. if ( !old ) {
  729. context.removeAttribute("id");
  730. }
  731. }
  732. }
  733. }
  734. }
  735. // All others
  736. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  737. }
  738. /**
  739. * Create key-value caches of limited size
  740. * @returns {Function(string, Object)} Returns the Object data after storing it on itself with
  741. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  742. * deleting the oldest entry
  743. */
  744. function createCache() {
  745. var keys = [];
  746. function cache( key, value ) {
  747. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  748. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  749. // Only keep the most recent entries
  750. delete cache[ keys.shift() ];
  751. }
  752. return (cache[ key + " " ] = value);
  753. }
  754. return cache;
  755. }
  756. /**
  757. * Mark a function for special use by Sizzle
  758. * @param {Function} fn The function to mark
  759. */
  760. function markFunction( fn ) {
  761. fn[ expando ] = true;
  762. return fn;
  763. }
  764. /**
  765. * Support testing using an element
  766. * @param {Function} fn Passed the created div and expects a boolean result
  767. */
  768. function assert( fn ) {
  769. var div = document.createElement("div");
  770. try {
  771. return !!fn( div );
  772. } catch (e) {
  773. return false;
  774. } finally {
  775. // Remove from its parent by default
  776. if ( div.parentNode ) {
  777. div.parentNode.removeChild( div );
  778. }
  779. // release memory in IE
  780. div = null;
  781. }
  782. }
  783. /**
  784. * Adds the same handler for all of the specified attrs
  785. * @param {String} attrs Pipe-separated list of attributes
  786. * @param {Function} handler The method that will be applied
  787. */
  788. function addHandle( attrs, handler ) {
  789. var arr = attrs.split("|"),
  790. i = attrs.length;
  791. while ( i-- ) {
  792. Expr.attrHandle[ arr[i] ] = handler;
  793. }
  794. }
  795. /**
  796. * Checks document order of two siblings
  797. * @param {Element} a
  798. * @param {Element} b
  799. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  800. */
  801. function siblingCheck( a, b ) {
  802. var cur = b && a,
  803. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  804. ( ~b.sourceIndex || MAX_NEGATIVE ) -
  805. ( ~a.sourceIndex || MAX_NEGATIVE );
  806. // Use IE sourceIndex if available on both nodes
  807. if ( diff ) {
  808. return diff;
  809. }
  810. // Check if b follows a
  811. if ( cur ) {
  812. while ( (cur = cur.nextSibling) ) {
  813. if ( cur === b ) {
  814. return -1;
  815. }
  816. }
  817. }
  818. return a ? 1 : -1;
  819. }
  820. /**
  821. * Returns a function to use in pseudos for input types
  822. * @param {String} type
  823. */
  824. function createInputPseudo( type ) {
  825. return function( elem ) {
  826. var name = elem.nodeName.toLowerCase();
  827. return name === "input" && elem.type === type;
  828. };
  829. }
  830. /**
  831. * Returns a function to use in pseudos for buttons
  832. * @param {String} type
  833. */
  834. function createButtonPseudo( type ) {
  835. return function( elem ) {
  836. var name = elem.nodeName.toLowerCase();
  837. return (name === "input" || name === "button") && elem.type === type;
  838. };
  839. }
  840. /**
  841. * Returns a function to use in pseudos for positionals
  842. * @param {Function} fn
  843. */
  844. function createPositionalPseudo( fn ) {
  845. return markFunction(function( argument ) {
  846. argument = +argument;
  847. return markFunction(function( seed, matches ) {
  848. var j,
  849. matchIndexes = fn( [], seed.length, argument ),
  850. i = matchIndexes.length;
  851. // Match elements found at the specified indexes
  852. while ( i-- ) {
  853. if ( seed[ (j = matchIndexes[i]) ] ) {
  854. seed[j] = !(matches[j] = seed[j]);
  855. }
  856. }
  857. });
  858. });
  859. }
  860. /**
  861. * Checks a node for validity as a Sizzle context
  862. * @param {Element|Object=} context
  863. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  864. */
  865. function testContext( context ) {
  866. return context && typeof context.getElementsByTagName !== "undefined" && context;
  867. }
  868. // Expose support vars for convenience
  869. support = Sizzle.support = {};
  870. /**
  871. * Detects XML nodes
  872. * @param {Element|Object} elem An element or a document
  873. * @returns {Boolean} True iff elem is a non-HTML XML node
  874. */
  875. isXML = Sizzle.isXML = function( elem ) {
  876. // documentElement is verified for cases where it doesn't yet exist
  877. // (such as loading iframes in IE - #4833)
  878. var documentElement = elem && (elem.ownerDocument || elem).documentElement;
  879. return documentElement ? documentElement.nodeName !== "HTML" : false;
  880. };
  881. /**
  882. * Sets document-related variables once based on the current document
  883. * @param {Element|Object} [doc] An element or document object to use to set the document
  884. * @returns {Object} Returns the current document
  885. */
  886. setDocument = Sizzle.setDocument = function( node ) {
  887. var hasCompare, parent,
  888. doc = node ? node.ownerDocument || node : preferredDoc;
  889. // If no document and documentElement is available, return
  890. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  891. return document;
  892. }
  893. // Set our document
  894. document = doc;
  895. docElem = doc.documentElement;
  896. parent = doc.defaultView;
  897. // Support: IE>8
  898. // If iframe document is assigned to "document" variable and if iframe has been reloaded,
  899. // IE will throw "permission denied" error when accessing "document" variable, see jQuery #13936
  900. // IE6-8 do not support the defaultView property so parent will be undefined
  901. if ( parent && parent !== parent.top ) {
  902. // IE11 does not have attachEvent, so all must suffer
  903. if ( parent.addEventListener ) {
  904. parent.addEventListener( "unload", unloadHandler, false );
  905. } else if ( parent.attachEvent ) {
  906. parent.attachEvent( "onunload", unloadHandler );
  907. }
  908. }
  909. /* Support tests
  910. ---------------------------------------------------------------------- */
  911. documentIsHTML = !isXML( doc );
  912. /* Attributes
  913. ---------------------------------------------------------------------- */
  914. // Support: IE<8
  915. // Verify that getAttribute really returns attributes and not properties
  916. // (excepting IE8 booleans)
  917. support.attributes = assert(function( div ) {
  918. div.className = "i";
  919. return !div.getAttribute("className");
  920. });
  921. /* getElement(s)By*
  922. ---------------------------------------------------------------------- */
  923. // Check if getElementsByTagName("*") returns only elements
  924. support.getElementsByTagName = assert(function( div ) {
  925. div.appendChild( doc.createComment("") );
  926. return !div.getElementsByTagName("*").length;
  927. });
  928. // Support: IE<9
  929. support.getElementsByClassName = rnative.test( doc.getElementsByClassName );
  930. // Support: IE<10
  931. // Check if getElementById returns elements by name
  932. // The broken getElementById methods don't pick up programatically-set names,
  933. // so use a roundabout getElementsByName test
  934. support.getById = assert(function( div ) {
  935. docElem.appendChild( div ).id = expando;
  936. return !doc.getElementsByName || !doc.getElementsByName( expando ).length;
  937. });
  938. // ID find and filter
  939. if ( support.getById ) {
  940. Expr.find["ID"] = function( id, context ) {
  941. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  942. var m = context.getElementById( id );
  943. // Check parentNode to catch when Blackberry 4.6 returns
  944. // nodes that are no longer in the document #6963
  945. return m && m.parentNode ? [ m ] : [];
  946. }
  947. };
  948. Expr.filter["ID"] = function( id ) {
  949. var attrId = id.replace( runescape, funescape );
  950. return function( elem ) {
  951. return elem.getAttribute("id") === attrId;
  952. };
  953. };
  954. } else {
  955. // Support: IE6/7
  956. // getElementById is not reliable as a find shortcut
  957. delete Expr.find["ID"];
  958. Expr.filter["ID"] = function( id ) {
  959. var attrId = id.replace( runescape, funescape );
  960. return function( elem ) {
  961. var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
  962. return node && node.value === attrId;
  963. };
  964. };
  965. }
  966. // Tag
  967. Expr.find["TAG"] = support.getElementsByTagName ?
  968. function( tag, context ) {
  969. if ( typeof context.getElementsByTagName !== "undefined" ) {
  970. return context.getElementsByTagName( tag );
  971. // DocumentFragment nodes don't have gEBTN
  972. } else if ( support.qsa ) {
  973. return context.querySelectorAll( tag );
  974. }
  975. } :
  976. function( tag, context ) {
  977. var elem,
  978. tmp = [],
  979. i = 0,
  980. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  981. results = context.getElementsByTagName( tag );
  982. // Filter out possible comments
  983. if ( tag === "*" ) {
  984. while ( (elem = results[i++]) ) {
  985. if ( elem.nodeType === 1 ) {
  986. tmp.push( elem );
  987. }
  988. }
  989. return tmp;
  990. }
  991. return results;
  992. };
  993. // Class
  994. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  995. if ( documentIsHTML ) {
  996. return context.getElementsByClassName( className );
  997. }
  998. };
  999. /* QSA/matchesSelector
  1000. ---------------------------------------------------------------------- */
  1001. // QSA and matchesSelector support
  1002. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  1003. rbuggyMatches = [];
  1004. // qSa(:focus) reports false when true (Chrome 21)
  1005. // We allow this because of a bug in IE8/9 that throws an error
  1006. // whenever `document.activeElement` is accessed on an iframe
  1007. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1008. // See http://bugs.jquery.com/ticket/13378
  1009. rbuggyQSA = [];
  1010. if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) {
  1011. // Build QSA regex
  1012. // Regex strategy adopted from Diego Perini
  1013. assert(function( div ) {
  1014. // Select is set to empty string on purpose
  1015. // This is to test IE's treatment of not explicitly
  1016. // setting a boolean content attribute,
  1017. // since its presence should be enough
  1018. // http://bugs.jquery.com/ticket/12359
  1019. docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
  1020. "<select id='" + expando + "-\f]' msallowcapture=''>" +
  1021. "<option selected=''></option></select>";
  1022. // Support: IE8, Opera 11-12.16
  1023. // Nothing should be selected when empty strings follow ^= or $= or *=
  1024. // The test attribute must be unknown in Opera but "safe" for WinRT
  1025. // http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1026. if ( div.querySelectorAll("[msallowcapture^='']").length ) {
  1027. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1028. }
  1029. // Support: IE8
  1030. // Boolean attributes and "value" are not treated correctly
  1031. if ( !div.querySelectorAll("[selected]").length ) {
  1032. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1033. }
  1034. // Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
  1035. if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  1036. rbuggyQSA.push("~=");
  1037. }
  1038. // Webkit/Opera - :checked should return selected option elements
  1039. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1040. // IE8 throws error here and will not see later tests
  1041. if ( !div.querySelectorAll(":checked").length ) {
  1042. rbuggyQSA.push(":checked");
  1043. }
  1044. // Support: Safari 8+, iOS 8+
  1045. // https://bugs.webkit.org/show_bug.cgi?id=136851
  1046. // In-page `selector#id sibing-combinator selector` fails
  1047. if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
  1048. rbuggyQSA.push(".#.+[+~]");
  1049. }
  1050. });
  1051. assert(function( div ) {
  1052. // Support: Windows 8 Native Apps
  1053. // The type and name attributes are restricted during .innerHTML assignment
  1054. var input = doc.createElement("input");
  1055. input.setAttribute( "type", "hidden" );
  1056. div.appendChild( input ).setAttribute( "name", "D" );
  1057. // Support: IE8
  1058. // Enforce case-sensitivity of name attribute
  1059. if ( div.querySelectorAll("[name=d]").length ) {
  1060. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1061. }
  1062. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1063. // IE8 throws error here and will not see later tests
  1064. if ( !div.querySelectorAll(":enabled").length ) {
  1065. rbuggyQSA.push( ":enabled", ":disabled" );
  1066. }
  1067. // Opera 10-11 does not throw on post-comma invalid pseudos
  1068. div.querySelectorAll("*,:x");
  1069. rbuggyQSA.push(",.*:");
  1070. });
  1071. }
  1072. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  1073. docElem.webkitMatchesSelector ||
  1074. docElem.mozMatchesSelector ||
  1075. docElem.oMatchesSelector ||
  1076. docElem.msMatchesSelector) )) ) {
  1077. assert(function( div ) {
  1078. // Check to see if it's possible to do matchesSelector
  1079. // on a disconnected node (IE 9)
  1080. support.disconnectedMatch = matches.call( div, "div" );
  1081. // This should fail with an exception
  1082. // Gecko does not error, returns false instead
  1083. matches.call( div, "[s!='']:x" );
  1084. rbuggyMatches.push( "!=", pseudos );
  1085. });
  1086. }
  1087. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1088. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1089. /* Contains
  1090. ---------------------------------------------------------------------- */
  1091. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1092. // Element contains another
  1093. // Purposefully does not implement inclusive descendent
  1094. // As in, an element does not contain itself
  1095. contains = hasCompare || rnative.test( docElem.contains ) ?
  1096. function( a, b ) {
  1097. var adown = a.nodeType === 9 ? a.documentElement : a,
  1098. bup = b && b.parentNode;
  1099. return a === bup || !!( bup && bup.nodeType === 1 && (
  1100. adown.contains ?
  1101. adown.contains( bup ) :
  1102. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1103. ));
  1104. } :
  1105. function( a, b ) {
  1106. if ( b ) {
  1107. while ( (b = b.parentNode) ) {
  1108. if ( b === a ) {
  1109. return true;
  1110. }
  1111. }
  1112. }
  1113. return false;
  1114. };
  1115. /* Sorting
  1116. ---------------------------------------------------------------------- */
  1117. // Document order sorting
  1118. sortOrder = hasCompare ?
  1119. function( a, b ) {
  1120. // Flag for duplicate removal
  1121. if ( a === b ) {
  1122. hasDuplicate = true;
  1123. return 0;
  1124. }
  1125. // Sort on method existence if only one input has compareDocumentPosition
  1126. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1127. if ( compare ) {
  1128. return compare;
  1129. }
  1130. // Calculate position if both inputs belong to the same document
  1131. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1132. a.compareDocumentPosition( b ) :
  1133. // Otherwise we know they are disconnected
  1134. 1;
  1135. // Disconnected nodes
  1136. if ( compare & 1 ||
  1137. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1138. // Choose the first element that is related to our preferred document
  1139. if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1140. return -1;
  1141. }
  1142. if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1143. return 1;
  1144. }
  1145. // Maintain original order
  1146. return sortInput ?
  1147. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1148. 0;
  1149. }
  1150. return compare & 4 ? -1 : 1;
  1151. } :
  1152. function( a, b ) {
  1153. // Exit early if the nodes are identical
  1154. if ( a === b ) {
  1155. hasDuplicate = true;
  1156. return 0;
  1157. }
  1158. var cur,
  1159. i = 0,
  1160. aup = a.parentNode,
  1161. bup = b.parentNode,
  1162. ap = [ a ],
  1163. bp = [ b ];
  1164. // Parentless nodes are either documents or disconnected
  1165. if ( !aup || !bup ) {
  1166. return a === doc ? -1 :
  1167. b === doc ? 1 :
  1168. aup ? -1 :
  1169. bup ? 1 :
  1170. sortInput ?
  1171. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1172. 0;
  1173. // If the nodes are siblings, we can do a quick check
  1174. } else if ( aup === bup ) {
  1175. return siblingCheck( a, b );
  1176. }
  1177. // Otherwise we need full lists of their ancestors for comparison
  1178. cur = a;
  1179. while ( (cur = cur.parentNode) ) {
  1180. ap.unshift( cur );
  1181. }
  1182. cur = b;
  1183. while ( (cur = cur.parentNode) ) {
  1184. bp.unshift( cur );
  1185. }
  1186. // Walk down the tree looking for a discrepancy
  1187. while ( ap[i] === bp[i] ) {
  1188. i++;
  1189. }
  1190. return i ?
  1191. // Do a sibling check if the nodes have a common ancestor
  1192. siblingCheck( ap[i], bp[i] ) :
  1193. // Otherwise nodes in our document sort first
  1194. ap[i] === preferredDoc ? -1 :
  1195. bp[i] === preferredDoc ? 1 :
  1196. 0;
  1197. };
  1198. return doc;
  1199. };
  1200. Sizzle.matches = function( expr, elements ) {
  1201. return Sizzle( expr, null, null, elements );
  1202. };
  1203. Sizzle.matchesSelector = function( elem, expr ) {
  1204. // Set document vars if needed
  1205. if ( ( elem.ownerDocument || elem ) !== document ) {
  1206. setDocument( elem );
  1207. }
  1208. // Make sure that attribute selectors are quoted
  1209. expr = expr.replace( rattributeQuotes, "='$1']" );
  1210. if ( support.matchesSelector && documentIsHTML &&
  1211. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1212. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1213. try {
  1214. var ret = matches.call( elem, expr );
  1215. // IE 9's matchesSelector returns false on disconnected nodes
  1216. if ( ret || support.disconnectedMatch ||
  1217. // As well, disconnected nodes are said to be in a document
  1218. // fragment in IE 9
  1219. elem.document && elem.document.nodeType !== 11 ) {
  1220. return ret;
  1221. }
  1222. } catch (e) {}
  1223. }
  1224. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  1225. };
  1226. Sizzle.contains = function( context, elem ) {
  1227. // Set document vars if needed
  1228. if ( ( context.ownerDocument || context ) !== document ) {
  1229. setDocument( context );
  1230. }
  1231. return contains( context, elem );
  1232. };
  1233. Sizzle.attr = function( elem, name ) {
  1234. // Set document vars if needed
  1235. if ( ( elem.ownerDocument || elem ) !== document ) {
  1236. setDocument( elem );
  1237. }
  1238. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1239. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1240. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1241. fn( elem, name, !documentIsHTML ) :
  1242. undefined;
  1243. return val !== undefined ?
  1244. val :
  1245. support.attributes || !documentIsHTML ?
  1246. elem.getAttribute( name ) :
  1247. (val = elem.getAttributeNode(name)) && val.specified ?
  1248. val.value :
  1249. null;
  1250. };
  1251. Sizzle.error = function( msg ) {
  1252. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1253. };
  1254. /**
  1255. * Document sorting and removing duplicates
  1256. * @param {ArrayLike} results
  1257. */
  1258. Sizzle.uniqueSort = function( results ) {
  1259. var elem,
  1260. duplicates = [],
  1261. j = 0,
  1262. i = 0;
  1263. // Unless we *know* we can detect duplicates, assume their presence
  1264. hasDuplicate = !support.detectDuplicates;
  1265. sortInput = !support.sortStable && results.slice( 0 );
  1266. results.sort( sortOrder );
  1267. if ( hasDuplicate ) {
  1268. while ( (elem = results[i++]) ) {
  1269. if ( elem === results[ i ] ) {
  1270. j = duplicates.push( i );
  1271. }
  1272. }
  1273. while ( j-- ) {
  1274. results.splice( duplicates[ j ], 1 );
  1275. }
  1276. }
  1277. // Clear input after sorting to release objects
  1278. // See https://github.com/jquery/sizzle/pull/225
  1279. sortInput = null;
  1280. return results;
  1281. };
  1282. /**
  1283. * Utility function for retrieving the text value of an array of DOM nodes
  1284. * @param {Array|Element} elem
  1285. */
  1286. getText = Sizzle.getText = function( elem ) {
  1287. var node,
  1288. ret = "",
  1289. i = 0,
  1290. nodeType = elem.nodeType;
  1291. if ( !nodeType ) {
  1292. // If no nodeType, this is expected to be an array
  1293. while ( (node = elem[i++]) ) {
  1294. // Do not traverse comment nodes
  1295. ret += getText( node );
  1296. }
  1297. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1298. // Use textContent for elements
  1299. // innerText usage removed for consistency of new lines (jQuery #11153)
  1300. if ( typeof elem.textContent === "string" ) {
  1301. return elem.textContent;
  1302. } else {
  1303. // Traverse its children
  1304. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1305. ret += getText( elem );
  1306. }
  1307. }
  1308. } else if ( nodeType === 3 || nodeType === 4 ) {
  1309. return elem.nodeValue;
  1310. }
  1311. // Do not include comment or processing instruction nodes
  1312. return ret;
  1313. };
  1314. Expr = Sizzle.selectors = {
  1315. // Can be adjusted by the user
  1316. cacheLength: 50,
  1317. createPseudo: markFunction,
  1318. match: matchExpr,
  1319. attrHandle: {},
  1320. find: {},
  1321. relative: {
  1322. ">": { dir: "parentNode", first: true },
  1323. " ": { dir: "parentNode" },
  1324. "+": { dir: "previousSibling", first: true },
  1325. "~": { dir: "previousSibling" }
  1326. },
  1327. preFilter: {
  1328. "ATTR": function( match ) {
  1329. match[1] = match[1].replace( runescape, funescape );
  1330. // Move the given value to match[3] whether quoted or unquoted
  1331. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  1332. if ( match[2] === "~=" ) {
  1333. match[3] = " " + match[3] + " ";
  1334. }
  1335. return match.slice( 0, 4 );
  1336. },
  1337. "CHILD": function( match ) {
  1338. /* matches from matchExpr["CHILD"]
  1339. 1 type (only|nth|...)
  1340. 2 what (child|of-type)
  1341. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1342. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1343. 5 sign of xn-component
  1344. 6 x of xn-component
  1345. 7 sign of y-component
  1346. 8 y of y-component
  1347. */
  1348. match[1] = match[1].toLowerCase();
  1349. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1350. // nth-* requires argument
  1351. if ( !match[3] ) {
  1352. Sizzle.error( match[0] );
  1353. }
  1354. // numeric x and y parameters for Expr.filter.CHILD
  1355. // remember that false/true cast respectively to 0/1
  1356. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1357. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1358. // other types prohibit arguments
  1359. } else if ( match[3] ) {
  1360. Sizzle.error( match[0] );
  1361. }
  1362. return match;
  1363. },
  1364. "PSEUDO": function( match ) {
  1365. var excess,
  1366. unquoted = !match[6] && match[2];
  1367. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1368. return null;
  1369. }
  1370. // Accept quoted arguments as-is
  1371. if ( match[3] ) {
  1372. match[2] = match[4] || match[5] || "";
  1373. // Strip excess characters from unquoted arguments
  1374. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1375. // Get excess from tokenize (recursively)
  1376. (excess = tokenize( unquoted, true )) &&
  1377. // advance to the next closing parenthesis
  1378. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1379. // excess is a negative index
  1380. match[0] = match[0].slice( 0, excess );
  1381. match[2] = unquoted.slice( 0, excess );
  1382. }
  1383. // Return only captures needed by the pseudo filter method (type and argument)
  1384. return match.slice( 0, 3 );
  1385. }
  1386. },
  1387. filter: {
  1388. "TAG": function( nodeNameSelector ) {
  1389. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1390. return nodeNameSelector === "*" ?
  1391. function() { return true; } :
  1392. function( elem ) {
  1393. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1394. };
  1395. },
  1396. "CLASS": function( className ) {
  1397. var pattern = classCache[ className + " " ];
  1398. return pattern ||
  1399. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1400. classCache( className, function( elem ) {
  1401. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  1402. });
  1403. },
  1404. "ATTR": function( name, operator, check ) {
  1405. return function( elem ) {
  1406. var result = Sizzle.attr( elem, name );
  1407. if ( result == null ) {
  1408. return operator === "!=";
  1409. }
  1410. if ( !operator ) {
  1411. return true;
  1412. }
  1413. result += "";
  1414. return operator === "=" ? result === check :
  1415. operator === "!=" ? result !== check :
  1416. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1417. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1418. operator === "$=" ? check && result.slice( -check.length ) === check :
  1419. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  1420. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1421. false;
  1422. };
  1423. },
  1424. "CHILD": function( type, what, argument, first, last ) {
  1425. var simple = type.slice( 0, 3 ) !== "nth",
  1426. forward = type.slice( -4 ) !== "last",
  1427. ofType = what === "of-type";
  1428. return first === 1 && last === 0 ?
  1429. // Shortcut for :nth-*(n)
  1430. function( elem ) {
  1431. return !!elem.parentNode;
  1432. } :
  1433. function( elem, context, xml ) {
  1434. var cache, outerCache, node, diff, nodeIndex, start,
  1435. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1436. parent = elem.parentNode,
  1437. name = ofType && elem.nodeName.toLowerCase(),
  1438. useCache = !xml && !ofType;
  1439. if ( parent ) {
  1440. // :(first|last|only)-(child|of-type)
  1441. if ( simple ) {
  1442. while ( dir ) {
  1443. node = elem;
  1444. while ( (node = node[ dir ]) ) {
  1445. if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) {
  1446. return false;
  1447. }
  1448. }
  1449. // Reverse direction for :only-* (if we haven't yet done so)
  1450. start = dir = type === "only" && !start && "nextSibling";
  1451. }
  1452. return true;
  1453. }
  1454. start = [ forward ? parent.firstChild : parent.lastChild ];
  1455. // non-xml :nth-child(...) stores cache data on `parent`
  1456. if ( forward && useCache ) {
  1457. // Seek `elem` from a previously-cached index
  1458. outerCache = parent[ expando ] || (parent[ expando ] = {});
  1459. cache = outerCache[ type ] || [];
  1460. nodeIndex = cache[0] === dirruns && cache[1];
  1461. diff = cache[0] === dirruns && cache[2];
  1462. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1463. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1464. // Fallback to seeking `elem` from the start
  1465. (diff = nodeIndex = 0) || start.pop()) ) {
  1466. // When found, cache indexes on `parent` and break
  1467. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1468. outerCache[ type ] = [ dirruns, nodeIndex, diff ];
  1469. break;
  1470. }
  1471. }
  1472. // Use previously-cached element index if available
  1473. } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) {
  1474. diff = cache[1];
  1475. // xml :nth-child(...) or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1476. } else {
  1477. // Use the same loop as above to seek `elem` from the start
  1478. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1479. (diff = nodeIndex = 0) || start.pop()) ) {
  1480. if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) {
  1481. // Cache the index of each encountered element
  1482. if ( useCache ) {
  1483. (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ];
  1484. }
  1485. if ( node === elem ) {
  1486. break;
  1487. }
  1488. }
  1489. }
  1490. }
  1491. // Incorporate the offset, then check against cycle size
  1492. diff -= last;
  1493. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1494. }
  1495. };
  1496. },
  1497. "PSEUDO": function( pseudo, argument ) {
  1498. // pseudo-class names are case-insensitive
  1499. // http://www.w3.org/TR/selectors/#pseudo-classes
  1500. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1501. // Remember that setFilters inherits from pseudos
  1502. var args,
  1503. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1504. Sizzle.error( "unsupported pseudo: " + pseudo );
  1505. // The user may use createPseudo to indicate that
  1506. // arguments are needed to create the filter function
  1507. // just as Sizzle does
  1508. if ( fn[ expando ] ) {
  1509. return fn( argument );
  1510. }
  1511. // But maintain support for old signatures
  1512. if ( fn.length > 1 ) {
  1513. args = [ pseudo, pseudo, "", argument ];
  1514. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1515. markFunction(function( seed, matches ) {
  1516. var idx,
  1517. matched = fn( seed, argument ),
  1518. i = matched.length;
  1519. while ( i-- ) {
  1520. idx = indexOf( seed, matched[i] );
  1521. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1522. }
  1523. }) :
  1524. function( elem ) {
  1525. return fn( elem, 0, args );
  1526. };
  1527. }
  1528. return fn;
  1529. }
  1530. },
  1531. pseudos: {
  1532. // Potentially complex pseudos
  1533. "not": markFunction(function( selector ) {
  1534. // Trim the selector passed to compile
  1535. // to avoid treating leading and trailing
  1536. // spaces as combinators
  1537. var input = [],
  1538. results = [],
  1539. matcher = compile( selector.replace( rtrim, "$1" ) );
  1540. return matcher[ expando ] ?
  1541. markFunction(function( seed, matches, context, xml ) {
  1542. var elem,
  1543. unmatched = matcher( seed, null, xml, [] ),
  1544. i = seed.length;
  1545. // Match elements unmatched by `matcher`
  1546. while ( i-- ) {
  1547. if ( (elem = unmatched[i]) ) {
  1548. seed[i] = !(matches[i] = elem);
  1549. }
  1550. }
  1551. }) :
  1552. function( elem, context, xml ) {
  1553. input[0] = elem;
  1554. matcher( input, null, xml, results );
  1555. // Don't keep the element (issue #299)
  1556. input[0] = null;
  1557. return !results.pop();
  1558. };
  1559. }),
  1560. "has": markFunction(function( selector ) {
  1561. return function( elem ) {
  1562. return Sizzle( selector, elem ).length > 0;
  1563. };
  1564. }),
  1565. "contains": markFunction(function( text ) {
  1566. text = text.replace( runescape, funescape );
  1567. return function( elem ) {
  1568. return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
  1569. };
  1570. }),
  1571. // "Whether an element is represented by a :lang() selector
  1572. // is based solely on the element's language value
  1573. // being equal to the identifier C,
  1574. // or beginning with the identifier C immediately followed by "-".
  1575. // The matching of C against the element's language value is performed case-insensitively.
  1576. // The identifier C does not have to be a valid language name."
  1577. // http://www.w3.org/TR/selectors/#lang-pseudo
  1578. "lang": markFunction( function( lang ) {
  1579. // lang value must be a valid identifier
  1580. if ( !ridentifier.test(lang || "") ) {
  1581. Sizzle.error( "unsupported lang: " + lang );
  1582. }
  1583. lang = lang.replace( runescape, funescape ).toLowerCase();
  1584. return function( elem ) {
  1585. var elemLang;
  1586. do {
  1587. if ( (elemLang = documentIsHTML ?
  1588. elem.lang :
  1589. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1590. elemLang = elemLang.toLowerCase();
  1591. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1592. }
  1593. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1594. return false;
  1595. };
  1596. }),
  1597. // Miscellaneous
  1598. "target": function( elem ) {
  1599. var hash = window.location && window.location.hash;
  1600. return hash && hash.slice( 1 ) === elem.id;
  1601. },
  1602. "root": function( elem ) {
  1603. return elem === docElem;
  1604. },
  1605. "focus": function( elem ) {
  1606. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1607. },
  1608. // Boolean properties
  1609. "enabled": function( elem ) {
  1610. return elem.disabled === false;
  1611. },
  1612. "disabled": function( elem ) {
  1613. return elem.disabled === true;
  1614. },
  1615. "checked": function( elem ) {
  1616. // In CSS3, :checked should return both checked and selected elements
  1617. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1618. var nodeName = elem.nodeName.toLowerCase();
  1619. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1620. },
  1621. "selected": function( elem ) {
  1622. // Accessing this property makes selected-by-default
  1623. // options in Safari work properly
  1624. if ( elem.parentNode ) {
  1625. elem.parentNode.selectedIndex;
  1626. }
  1627. return elem.selected === true;
  1628. },
  1629. // Contents
  1630. "empty": function( elem ) {
  1631. // http://www.w3.org/TR/selectors/#empty-pseudo
  1632. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1633. // but not by others (comment: 8; processing instruction: 7; etc.)
  1634. // nodeType < 6 works because attributes (2) do not appear as children
  1635. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1636. if ( elem.nodeType < 6 ) {
  1637. return false;
  1638. }
  1639. }
  1640. return true;
  1641. },
  1642. "parent": function( elem ) {
  1643. return !Expr.pseudos["empty"]( elem );
  1644. },
  1645. // Element/input types
  1646. "header": function( elem ) {
  1647. return rheader.test( elem.nodeName );
  1648. },
  1649. "input": function( elem ) {
  1650. return rinputs.test( elem.nodeName );
  1651. },
  1652. "button": function( elem ) {
  1653. var name = elem.nodeName.toLowerCase();
  1654. return name === "input" && elem.type === "button" || name === "button";
  1655. },
  1656. "text": function( elem ) {
  1657. var attr;
  1658. return elem.nodeName.toLowerCase() === "input" &&
  1659. elem.type === "text" &&
  1660. // Support: IE<8
  1661. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1662. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1663. },
  1664. // Position-in-collection
  1665. "first": createPositionalPseudo(function() {
  1666. return [ 0 ];
  1667. }),
  1668. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1669. return [ length - 1 ];
  1670. }),
  1671. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1672. return [ argument < 0 ? argument + length : argument ];
  1673. }),
  1674. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1675. var i = 0;
  1676. for ( ; i < length; i += 2 ) {
  1677. matchIndexes.push( i );
  1678. }
  1679. return matchIndexes;
  1680. }),
  1681. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1682. var i = 1;
  1683. for ( ; i < length; i += 2 ) {
  1684. matchIndexes.push( i );
  1685. }
  1686. return matchIndexes;
  1687. }),
  1688. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1689. var i = argument < 0 ? argument + length : argument;
  1690. for ( ; --i >= 0; ) {
  1691. matchIndexes.push( i );
  1692. }
  1693. return matchIndexes;
  1694. }),
  1695. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1696. var i = argument < 0 ? argument + length : argument;
  1697. for ( ; ++i < length; ) {
  1698. matchIndexes.push( i );
  1699. }
  1700. return matchIndexes;
  1701. })
  1702. }
  1703. };
  1704. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1705. // Add button/input type pseudos
  1706. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1707. Expr.pseudos[ i ] = createInputPseudo( i );
  1708. }
  1709. for ( i in { submit: true, reset: true } ) {
  1710. Expr.pseudos[ i ] = createButtonPseudo( i );
  1711. }
  1712. // Easy API for creating new setFilters
  1713. function setFilters() {}
  1714. setFilters.prototype = Expr.filters = Expr.pseudos;
  1715. Expr.setFilters = new setFilters();
  1716. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1717. var matched, match, tokens, type,
  1718. soFar, groups, preFilters,
  1719. cached = tokenCache[ selector + " " ];
  1720. if ( cached ) {
  1721. return parseOnly ? 0 : cached.slice( 0 );
  1722. }
  1723. soFar = selector;
  1724. groups = [];
  1725. preFilters = Expr.preFilter;
  1726. while ( soFar ) {
  1727. // Comma and first run
  1728. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1729. if ( match ) {
  1730. // Don't consume trailing commas as valid
  1731. soFar = soFar.slice( match[0].length ) || soFar;
  1732. }
  1733. groups.push( (tokens = []) );
  1734. }
  1735. matched = false;
  1736. // Combinators
  1737. if ( (match = rcombinators.exec( soFar )) ) {
  1738. matched = match.shift();
  1739. tokens.push({
  1740. value: matched,
  1741. // Cast descendant combinators to space
  1742. type: match[0].replace( rtrim, " " )
  1743. });
  1744. soFar = soFar.slice( matched.length );
  1745. }
  1746. // Filters
  1747. for ( type in Expr.filter ) {
  1748. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1749. (match = preFilters[ type ]( match ))) ) {
  1750. matched = match.shift();
  1751. tokens.push({
  1752. value: matched,
  1753. type: type,
  1754. matches: match
  1755. });
  1756. soFar = soFar.slice( matched.length );
  1757. }
  1758. }
  1759. if ( !matched ) {
  1760. break;
  1761. }
  1762. }
  1763. // Return the length of the invalid excess
  1764. // if we're just parsing
  1765. // Otherwise, throw an error or return tokens
  1766. return parseOnly ?
  1767. soFar.length :
  1768. soFar ?
  1769. Sizzle.error( selector ) :
  1770. // Cache the tokens
  1771. tokenCache( selector, groups ).slice( 0 );
  1772. };
  1773. function toSelector( tokens ) {
  1774. var i = 0,
  1775. len = tokens.length,
  1776. selector = "";
  1777. for ( ; i < len; i++ ) {
  1778. selector += tokens[i].value;
  1779. }
  1780. return selector;
  1781. }
  1782. function addCombinator( matcher, combinator, base ) {
  1783. var dir = combinator.dir,
  1784. checkNonElements = base && dir === "parentNode",
  1785. doneName = done++;
  1786. return combinator.first ?
  1787. // Check against closest ancestor/preceding element
  1788. function( elem, context, xml ) {
  1789. while ( (elem = elem[ dir ]) ) {
  1790. if ( elem.nodeType === 1 || checkNonElements ) {
  1791. return matcher( elem, context, xml );
  1792. }
  1793. }
  1794. } :
  1795. // Check against all ancestor/preceding elements
  1796. function( elem, context, xml ) {
  1797. var oldCache, outerCache,
  1798. newCache = [ dirruns, doneName ];
  1799. // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
  1800. if ( xml ) {
  1801. while ( (elem = elem[ dir ]) ) {
  1802. if ( elem.nodeType === 1 || checkNonElements ) {
  1803. if ( matcher( elem, context, xml ) ) {
  1804. return true;
  1805. }
  1806. }
  1807. }
  1808. } else {
  1809. while ( (elem = elem[ dir ]) ) {
  1810. if ( elem.nodeType === 1 || checkNonElements ) {
  1811. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1812. if ( (oldCache = outerCache[ dir ]) &&
  1813. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1814. // Assign to newCache so results back-propagate to previous elements
  1815. return (newCache[ 2 ] = oldCache[ 2 ]);
  1816. } else {
  1817. // Reuse newcache so results back-propagate to previous elements
  1818. outerCache[ dir ] = newCache;
  1819. // A match means we're done; a fail means we have to keep checking
  1820. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1821. return true;
  1822. }
  1823. }
  1824. }
  1825. }
  1826. }
  1827. };
  1828. }
  1829. function elementMatcher( matchers ) {
  1830. return matchers.length > 1 ?
  1831. function( elem, context, xml ) {
  1832. var i = matchers.length;
  1833. while ( i-- ) {
  1834. if ( !matchers[i]( elem, context, xml ) ) {
  1835. return false;
  1836. }
  1837. }
  1838. return true;
  1839. } :
  1840. matchers[0];
  1841. }
  1842. function multipleContexts( selector, contexts, results ) {
  1843. var i = 0,
  1844. len = contexts.length;
  1845. for ( ; i < len; i++ ) {
  1846. Sizzle( selector, contexts[i], results );
  1847. }
  1848. return results;
  1849. }
  1850. function condense( unmatched, map, filter, context, xml ) {
  1851. var elem,
  1852. newUnmatched = [],
  1853. i = 0,
  1854. len = unmatched.length,
  1855. mapped = map != null;
  1856. for ( ; i < len; i++ ) {
  1857. if ( (elem = unmatched[i]) ) {
  1858. if ( !filter || filter( elem, context, xml ) ) {
  1859. newUnmatched.push( elem );
  1860. if ( mapped ) {
  1861. map.push( i );
  1862. }
  1863. }
  1864. }
  1865. }
  1866. return newUnmatched;
  1867. }
  1868. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1869. if ( postFilter && !postFilter[ expando ] ) {
  1870. postFilter = setMatcher( postFilter );
  1871. }
  1872. if ( postFinder && !postFinder[ expando ] ) {
  1873. postFinder = setMatcher( postFinder, postSelector );
  1874. }
  1875. return markFunction(function( seed, results, context, xml ) {
  1876. var temp, i, elem,
  1877. preMap = [],
  1878. postMap = [],
  1879. preexisting = results.length,
  1880. // Get initial elements from seed or context
  1881. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1882. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1883. matcherIn = preFilter && ( seed || !selector ) ?
  1884. condense( elems, preMap, preFilter, context, xml ) :
  1885. elems,
  1886. matcherOut = matcher ?
  1887. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1888. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1889. // ...intermediate processing is necessary
  1890. [] :
  1891. // ...otherwise use results directly
  1892. results :
  1893. matcherIn;
  1894. // Find primary matches
  1895. if ( matcher ) {
  1896. matcher( matcherIn, matcherOut, context, xml );
  1897. }
  1898. // Apply postFilter
  1899. if ( postFilter ) {
  1900. temp = condense( matcherOut, postMap );
  1901. postFilter( temp, [], context, xml );
  1902. // Un-match failing elements by moving them back to matcherIn
  1903. i = temp.length;
  1904. while ( i-- ) {
  1905. if ( (elem = temp[i]) ) {
  1906. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1907. }
  1908. }
  1909. }
  1910. if ( seed ) {
  1911. if ( postFinder || preFilter ) {
  1912. if ( postFinder ) {
  1913. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1914. temp = [];
  1915. i = matcherOut.length;
  1916. while ( i-- ) {
  1917. if ( (elem = matcherOut[i]) ) {
  1918. // Restore matcherIn since elem is not yet a final match
  1919. temp.push( (matcherIn[i] = elem) );
  1920. }
  1921. }
  1922. postFinder( null, (matcherOut = []), temp, xml );
  1923. }
  1924. // Move matched elements from seed to results to keep them synchronized
  1925. i = matcherOut.length;
  1926. while ( i-- ) {
  1927. if ( (elem = matcherOut[i]) &&
  1928. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  1929. seed[temp] = !(results[temp] = elem);
  1930. }
  1931. }
  1932. }
  1933. // Add elements to results, through postFinder if defined
  1934. } else {
  1935. matcherOut = condense(
  1936. matcherOut === results ?
  1937. matcherOut.splice( preexisting, matcherOut.length ) :
  1938. matcherOut
  1939. );
  1940. if ( postFinder ) {
  1941. postFinder( null, results, matcherOut, xml );
  1942. } else {
  1943. push.apply( results, matcherOut );
  1944. }
  1945. }
  1946. });
  1947. }
  1948. function matcherFromTokens( tokens ) {
  1949. var checkContext, matcher, j,
  1950. len = tokens.length,
  1951. leadingRelative = Expr.relative[ tokens[0].type ],
  1952. implicitRelative = leadingRelative || Expr.relative[" "],
  1953. i = leadingRelative ? 1 : 0,
  1954. // The foundational matcher ensures that elements are reachable from top-level context(s)
  1955. matchContext = addCombinator( function( elem ) {
  1956. return elem === checkContext;
  1957. }, implicitRelative, true ),
  1958. matchAnyContext = addCombinator( function( elem ) {
  1959. return indexOf( checkContext, elem ) > -1;
  1960. }, implicitRelative, true ),
  1961. matchers = [ function( elem, context, xml ) {
  1962. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  1963. (checkContext = context).nodeType ?
  1964. matchContext( elem, context, xml ) :
  1965. matchAnyContext( elem, context, xml ) );
  1966. // Avoid hanging onto element (issue #299)
  1967. checkContext = null;
  1968. return ret;
  1969. } ];
  1970. for ( ; i < len; i++ ) {
  1971. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  1972. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  1973. } else {
  1974. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  1975. // Return special upon seeing a positional matcher
  1976. if ( matcher[ expando ] ) {
  1977. // Find the next relative operator (if any) for proper handling
  1978. j = ++i;
  1979. for ( ; j < len; j++ ) {
  1980. if ( Expr.relative[ tokens[j].type ] ) {
  1981. break;
  1982. }
  1983. }
  1984. return setMatcher(
  1985. i > 1 && elementMatcher( matchers ),
  1986. i > 1 && toSelector(
  1987. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  1988. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  1989. ).replace( rtrim, "$1" ),
  1990. matcher,
  1991. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  1992. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  1993. j < len && toSelector( tokens )
  1994. );
  1995. }
  1996. matchers.push( matcher );
  1997. }
  1998. }
  1999. return elementMatcher( matchers );
  2000. }
  2001. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  2002. var bySet = setMatchers.length > 0,
  2003. byElement = elementMatchers.length > 0,
  2004. superMatcher = function( seed, context, xml, results, outermost ) {
  2005. var elem, j, matcher,
  2006. matchedCount = 0,
  2007. i = "0",
  2008. unmatched = seed && [],
  2009. setMatched = [],
  2010. contextBackup = outermostContext,
  2011. // We must always have either seed elements or outermost context
  2012. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  2013. // Use integer dirruns iff this is the outermost matcher
  2014. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2015. len = elems.length;
  2016. if ( outermost ) {
  2017. outermostContext = context !== document && context;
  2018. }
  2019. // Add elements passing elementMatchers directly to results
  2020. // Keep `i` a string if there are no elements so `matchedCount` will be "00" below
  2021. // Support: IE<9, Safari
  2022. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2023. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2024. if ( byElement && elem ) {
  2025. j = 0;
  2026. while ( (matcher = elementMatchers[j++]) ) {
  2027. if ( matcher( elem, context, xml ) ) {
  2028. results.push( elem );
  2029. break;
  2030. }
  2031. }
  2032. if ( outermost ) {
  2033. dirruns = dirrunsUnique;
  2034. }
  2035. }
  2036. // Track unmatched elements for set filters
  2037. if ( bySet ) {
  2038. // They will have gone through all possible matchers
  2039. if ( (elem = !matcher && elem) ) {
  2040. matchedCount--;
  2041. }
  2042. // Lengthen the array for every element, matched or not
  2043. if ( seed ) {
  2044. unmatched.push( elem );
  2045. }
  2046. }
  2047. }
  2048. // Apply set filters to unmatched elements
  2049. matchedCount += i;
  2050. if ( bySet && i !== matchedCount ) {
  2051. j = 0;
  2052. while ( (matcher = setMatchers[j++]) ) {
  2053. matcher( unmatched, setMatched, context, xml );
  2054. }
  2055. if ( seed ) {
  2056. // Reintegrate element matches to eliminate the need for sorting
  2057. if ( matchedCount > 0 ) {
  2058. while ( i-- ) {
  2059. if ( !(unmatched[i] || setMatched[i]) ) {
  2060. setMatched[i] = pop.call( results );
  2061. }
  2062. }
  2063. }
  2064. // Discard index placeholder values to get only actual matches
  2065. setMatched = condense( setMatched );
  2066. }
  2067. // Add matches to results
  2068. push.apply( results, setMatched );
  2069. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2070. if ( outermost && !seed && setMatched.length > 0 &&
  2071. ( matchedCount + setMatchers.length ) > 1 ) {
  2072. Sizzle.uniqueSort( results );
  2073. }
  2074. }
  2075. // Override manipulation of globals by nested matchers
  2076. if ( outermost ) {
  2077. dirruns = dirrunsUnique;
  2078. outermostContext = contextBackup;
  2079. }
  2080. return unmatched;
  2081. };
  2082. return bySet ?
  2083. markFunction( superMatcher ) :
  2084. superMatcher;
  2085. }
  2086. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  2087. var i,
  2088. setMatchers = [],
  2089. elementMatchers = [],
  2090. cached = compilerCache[ selector + " " ];
  2091. if ( !cached ) {
  2092. // Generate a function of recursive functions that can be used to check each element
  2093. if ( !match ) {
  2094. match = tokenize( selector );
  2095. }
  2096. i = match.length;
  2097. while ( i-- ) {
  2098. cached = matcherFromTokens( match[i] );
  2099. if ( cached[ expando ] ) {
  2100. setMatchers.push( cached );
  2101. } else {
  2102. elementMatchers.push( cached );
  2103. }
  2104. }
  2105. // Cache the compiled function
  2106. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2107. // Save selector and tokenization
  2108. cached.selector = selector;
  2109. }
  2110. return cached;
  2111. };
  2112. /**
  2113. * A low-level selection function that works with Sizzle's compiled
  2114. * selector functions
  2115. * @param {String|Function} selector A selector or a pre-compiled
  2116. * selector function built with Sizzle.compile
  2117. * @param {Element} context
  2118. * @param {Array} [results]
  2119. * @param {Array} [seed] A set of elements to match against
  2120. */
  2121. select = Sizzle.select = function( selector, context, results, seed ) {
  2122. var i, tokens, token, type, find,
  2123. compiled = typeof selector === "function" && selector,
  2124. match = !seed && tokenize( (selector = compiled.selector || selector) );
  2125. results = results || [];
  2126. // Try to minimize operations if there is no seed and only one group
  2127. if ( match.length === 1 ) {
  2128. // Take a shortcut and set the context if the root selector is an ID
  2129. tokens = match[0] = match[0].slice( 0 );
  2130. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2131. support.getById && context.nodeType === 9 && documentIsHTML &&
  2132. Expr.relative[ tokens[1].type ] ) {
  2133. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2134. if ( !context ) {
  2135. return results;
  2136. // Precompiled matchers will still verify ancestry, so step up a level
  2137. } else if ( compiled ) {
  2138. context = context.parentNode;
  2139. }
  2140. selector = selector.slice( tokens.shift().value.length );
  2141. }
  2142. // Fetch a seed set for right-to-left matching
  2143. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2144. while ( i-- ) {
  2145. token = tokens[i];
  2146. // Abort if we hit a combinator
  2147. if ( Expr.relative[ (type = token.type) ] ) {
  2148. break;
  2149. }
  2150. if ( (find = Expr.find[ type ]) ) {
  2151. // Search, expanding context for leading sibling combinators
  2152. if ( (seed = find(
  2153. token.matches[0].replace( runescape, funescape ),
  2154. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2155. )) ) {
  2156. // If seed is empty or no tokens remain, we can return early
  2157. tokens.splice( i, 1 );
  2158. selector = seed.length && toSelector( tokens );
  2159. if ( !selector ) {
  2160. push.apply( results, seed );
  2161. return results;
  2162. }
  2163. break;
  2164. }
  2165. }
  2166. }
  2167. }
  2168. // Compile and execute a filtering function if one is not provided
  2169. // Provide `match` to avoid retokenization if we modified the selector above
  2170. ( compiled || compile( selector, match ) )(
  2171. seed,
  2172. context,
  2173. !documentIsHTML,
  2174. results,
  2175. rsibling.test( selector ) && testContext( context.parentNode ) || context
  2176. );
  2177. return results;
  2178. };
  2179. // One-time assignments
  2180. // Sort stability
  2181. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2182. // Support: Chrome 14-35+
  2183. // Always assume duplicates if they aren't passed to the comparison function
  2184. support.detectDuplicates = !!hasDuplicate;
  2185. // Initialize against the default document
  2186. setDocument();
  2187. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2188. // Detached nodes confoundingly follow *each other*
  2189. support.sortDetached = assert(function( div1 ) {
  2190. // Should return 1, but returns 4 (following)
  2191. return div1.compareDocumentPosition( document.createElement("div") ) & 1;
  2192. });
  2193. // Support: IE<8
  2194. // Prevent attribute/property "interpolation"
  2195. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2196. if ( !assert(function( div ) {
  2197. div.innerHTML = "<a href='#'></a>";
  2198. return div.firstChild.getAttribute("href") === "#" ;
  2199. }) ) {
  2200. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2201. if ( !isXML ) {
  2202. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2203. }
  2204. });
  2205. }
  2206. // Support: IE<9
  2207. // Use defaultValue in place of getAttribute("value")
  2208. if ( !support.attributes || !assert(function( div ) {
  2209. div.innerHTML = "<input/>";
  2210. div.firstChild.setAttribute( "value", "" );
  2211. return div.firstChild.getAttribute( "value" ) === "";
  2212. }) ) {
  2213. addHandle( "value", function( elem, name, isXML ) {
  2214. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2215. return elem.defaultValue;
  2216. }
  2217. });
  2218. }
  2219. // Support: IE<9
  2220. // Use getAttributeNode to fetch booleans when getAttribute lies
  2221. if ( !assert(function( div ) {
  2222. return div.getAttribute("disabled") == null;
  2223. }) ) {
  2224. addHandle( booleans, function( elem, name, isXML ) {
  2225. var val;
  2226. if ( !isXML ) {
  2227. return elem[ name ] === true ? name.toLowerCase() :
  2228. (val = elem.getAttributeNode( name )) && val.specified ?
  2229. val.value :
  2230. null;
  2231. }
  2232. });
  2233. }
  2234. return Sizzle;
  2235. })( window );
  2236. jQuery.find = Sizzle;
  2237. jQuery.expr = Sizzle.selectors;
  2238. jQuery.expr[":"] = jQuery.expr.pseudos;
  2239. jQuery.unique = Sizzle.uniqueSort;
  2240. jQuery.text = Sizzle.getText;
  2241. jQuery.isXMLDoc = Sizzle.isXML;
  2242. jQuery.contains = Sizzle.contains;
  2243. var rneedsContext = jQuery.expr.match.needsContext;
  2244. var rsingleTag = (/^<(\w+)\s*\/?>(?:<\/\1>|)$/);
  2245. var risSimple = /^.[^:#\[\.,]*$/;
  2246. // Implement the identical functionality for filter and not
  2247. function winnow( elements, qualifier, not ) {
  2248. if ( jQuery.isFunction( qualifier ) ) {
  2249. return jQuery.grep( elements, function( elem, i ) {
  2250. /* jshint -W018 */
  2251. return !!qualifier.call( elem, i, elem ) !== not;
  2252. });
  2253. }
  2254. if ( qualifier.nodeType ) {
  2255. return jQuery.grep( elements, function( elem ) {
  2256. return ( elem === qualifier ) !== not;
  2257. });
  2258. }
  2259. if ( typeof qualifier === "string" ) {
  2260. if ( risSimple.test( qualifier ) ) {
  2261. return jQuery.filter( qualifier, elements, not );
  2262. }
  2263. qualifier = jQuery.filter( qualifier, elements );
  2264. }
  2265. return jQuery.grep( elements, function( elem ) {
  2266. return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
  2267. });
  2268. }
  2269. jQuery.filter = function( expr, elems, not ) {
  2270. var elem = elems[ 0 ];
  2271. if ( not ) {
  2272. expr = ":not(" + expr + ")";
  2273. }
  2274. return elems.length === 1 && elem.nodeType === 1 ?
  2275. jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
  2276. jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2277. return elem.nodeType === 1;
  2278. }));
  2279. };
  2280. jQuery.fn.extend({
  2281. find: function( selector ) {
  2282. var i,
  2283. ret = [],
  2284. self = this,
  2285. len = self.length;
  2286. if ( typeof selector !== "string" ) {
  2287. return this.pushStack( jQuery( selector ).filter(function() {
  2288. for ( i = 0; i < len; i++ ) {
  2289. if ( jQuery.contains( self[ i ], this ) ) {
  2290. return true;
  2291. }
  2292. }
  2293. }) );
  2294. }
  2295. for ( i = 0; i < len; i++ ) {
  2296. jQuery.find( selector, self[ i ], ret );
  2297. }
  2298. // Needed because $( selector, context ) becomes $( context ).find( selector )
  2299. ret = this.pushStack( len > 1 ? jQuery.unique( ret ) : ret );
  2300. ret.selector = this.selector ? this.selector + " " + selector : selector;
  2301. return ret;
  2302. },
  2303. filter: function( selector ) {
  2304. return this.pushStack( winnow(this, selector || [], false) );
  2305. },
  2306. not: function( selector ) {
  2307. return this.pushStack( winnow(this, selector || [], true) );
  2308. },
  2309. is: function( selector ) {
  2310. return !!winnow(
  2311. this,
  2312. // If this is a positional/relative selector, check membership in the returned set
  2313. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2314. typeof selector === "string" && rneedsContext.test( selector ) ?
  2315. jQuery( selector ) :
  2316. selector || [],
  2317. false
  2318. ).length;
  2319. }
  2320. });
  2321. // Initialize a jQuery object
  2322. // A central reference to the root jQuery(document)
  2323. var rootjQuery,
  2324. // Use the correct document accordingly with window argument (sandbox)
  2325. document = window.document,
  2326. // A simple way to check for HTML strings
  2327. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2328. // Strict HTML recognition (#11290: must start with <)
  2329. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
  2330. init = jQuery.fn.init = function( selector, context ) {
  2331. var match, elem;
  2332. // HANDLE: $(""), $(null), $(undefined), $(false)
  2333. if ( !selector ) {
  2334. return this;
  2335. }
  2336. // Handle HTML strings
  2337. if ( typeof selector === "string" ) {
  2338. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  2339. // Assume that strings that start and end with <> are HTML and skip the regex check
  2340. match = [ null, selector, null ];
  2341. } else {
  2342. match = rquickExpr.exec( selector );
  2343. }
  2344. // Match html or make sure no context is specified for #id
  2345. if ( match && (match[1] || !context) ) {
  2346. // HANDLE: $(html) -> $(array)
  2347. if ( match[1] ) {
  2348. context = context instanceof jQuery ? context[0] : context;
  2349. // scripts is true for back-compat
  2350. // Intentionally let the error be thrown if parseHTML is not present
  2351. jQuery.merge( this, jQuery.parseHTML(
  2352. match[1],
  2353. context && context.nodeType ? context.ownerDocument || context : document,
  2354. true
  2355. ) );
  2356. // HANDLE: $(html, props)
  2357. if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
  2358. for ( match in context ) {
  2359. // Properties of context are called as methods if possible
  2360. if ( jQuery.isFunction( this[ match ] ) ) {
  2361. this[ match ]( context[ match ] );
  2362. // ...and otherwise set as attributes
  2363. } else {
  2364. this.attr( match, context[ match ] );
  2365. }
  2366. }
  2367. }
  2368. return this;
  2369. // HANDLE: $(#id)
  2370. } else {
  2371. elem = document.getElementById( match[2] );
  2372. // Check parentNode to catch when Blackberry 4.6 returns
  2373. // nodes that are no longer in the document #6963
  2374. if ( elem && elem.parentNode ) {
  2375. // Handle the case where IE and Opera return items
  2376. // by name instead of ID
  2377. if ( elem.id !== match[2] ) {
  2378. return rootjQuery.find( selector );
  2379. }
  2380. // Otherwise, we inject the element directly into the jQuery object
  2381. this.length = 1;
  2382. this[0] = elem;
  2383. }
  2384. this.context = document;
  2385. this.selector = selector;
  2386. return this;
  2387. }
  2388. // HANDLE: $(expr, $(...))
  2389. } else if ( !context || context.jquery ) {
  2390. return ( context || rootjQuery ).find( selector );
  2391. // HANDLE: $(expr, context)
  2392. // (which is just equivalent to: $(context).find(expr)
  2393. } else {
  2394. return this.constructor( context ).find( selector );
  2395. }
  2396. // HANDLE: $(DOMElement)
  2397. } else if ( selector.nodeType ) {
  2398. this.context = this[0] = selector;
  2399. this.length = 1;
  2400. return this;
  2401. // HANDLE: $(function)
  2402. // Shortcut for document ready
  2403. } else if ( jQuery.isFunction( selector ) ) {
  2404. return typeof rootjQuery.ready !== "undefined" ?
  2405. rootjQuery.ready( selector ) :
  2406. // Execute immediately if ready is not present
  2407. selector( jQuery );
  2408. }
  2409. if ( selector.selector !== undefined ) {
  2410. this.selector = selector.selector;
  2411. this.context = selector.context;
  2412. }
  2413. return jQuery.makeArray( selector, this );
  2414. };
  2415. // Give the init function the jQuery prototype for later instantiation
  2416. init.prototype = jQuery.fn;
  2417. // Initialize central reference
  2418. rootjQuery = jQuery( document );
  2419. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2420. // methods guaranteed to produce a unique set when starting from a unique set
  2421. guaranteedUnique = {
  2422. children: true,
  2423. contents: true,
  2424. next: true,
  2425. prev: true
  2426. };
  2427. jQuery.extend({
  2428. dir: function( elem, dir, until ) {
  2429. var matched = [],
  2430. cur = elem[ dir ];
  2431. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  2432. if ( cur.nodeType === 1 ) {
  2433. matched.push( cur );
  2434. }
  2435. cur = cur[dir];
  2436. }
  2437. return matched;
  2438. },
  2439. sibling: function( n, elem ) {
  2440. var r = [];
  2441. for ( ; n; n = n.nextSibling ) {
  2442. if ( n.nodeType === 1 && n !== elem ) {
  2443. r.push( n );
  2444. }
  2445. }
  2446. return r;
  2447. }
  2448. });
  2449. jQuery.fn.extend({
  2450. has: function( target ) {
  2451. var i,
  2452. targets = jQuery( target, this ),
  2453. len = targets.length;
  2454. return this.filter(function() {
  2455. for ( i = 0; i < len; i++ ) {
  2456. if ( jQuery.contains( this, targets[i] ) ) {
  2457. return true;
  2458. }
  2459. }
  2460. });
  2461. },
  2462. closest: function( selectors, context ) {
  2463. var cur,
  2464. i = 0,
  2465. l = this.length,
  2466. matched = [],
  2467. pos = rneedsContext.test( selectors ) || typeof selectors !== "string" ?
  2468. jQuery( selectors, context || this.context ) :
  2469. 0;
  2470. for ( ; i < l; i++ ) {
  2471. for ( cur = this[i]; cur && cur !== context; cur = cur.parentNode ) {
  2472. // Always skip document fragments
  2473. if ( cur.nodeType < 11 && (pos ?
  2474. pos.index(cur) > -1 :
  2475. // Don't pass non-elements to Sizzle
  2476. cur.nodeType === 1 &&
  2477. jQuery.find.matchesSelector(cur, selectors)) ) {
  2478. matched.push( cur );
  2479. break;
  2480. }
  2481. }
  2482. }
  2483. return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
  2484. },
  2485. // Determine the position of an element within
  2486. // the matched set of elements
  2487. index: function( elem ) {
  2488. // No argument, return index in parent
  2489. if ( !elem ) {
  2490. return ( this[0] && this[0].parentNode ) ? this.first().prevAll().length : -1;
  2491. }
  2492. // index in selector
  2493. if ( typeof elem === "string" ) {
  2494. return jQuery.inArray( this[0], jQuery( elem ) );
  2495. }
  2496. // Locate the position of the desired element
  2497. return jQuery.inArray(
  2498. // If it receives a jQuery object, the first element is used
  2499. elem.jquery ? elem[0] : elem, this );
  2500. },
  2501. add: function( selector, context ) {
  2502. return this.pushStack(
  2503. jQuery.unique(
  2504. jQuery.merge( this.get(), jQuery( selector, context ) )
  2505. )
  2506. );
  2507. },
  2508. addBack: function( selector ) {
  2509. return this.add( selector == null ?
  2510. this.prevObject : this.prevObject.filter(selector)
  2511. );
  2512. }
  2513. });
  2514. function sibling( cur, dir ) {
  2515. do {
  2516. cur = cur[ dir ];
  2517. } while ( cur && cur.nodeType !== 1 );
  2518. return cur;
  2519. }
  2520. jQuery.each({
  2521. parent: function( elem ) {
  2522. var parent = elem.parentNode;
  2523. return parent && parent.nodeType !== 11 ? parent : null;
  2524. },
  2525. parents: function( elem ) {
  2526. return jQuery.dir( elem, "parentNode" );
  2527. },
  2528. parentsUntil: function( elem, i, until ) {
  2529. return jQuery.dir( elem, "parentNode", until );
  2530. },
  2531. next: function( elem ) {
  2532. return sibling( elem, "nextSibling" );
  2533. },
  2534. prev: function( elem ) {
  2535. return sibling( elem, "previousSibling" );
  2536. },
  2537. nextAll: function( elem ) {
  2538. return jQuery.dir( elem, "nextSibling" );
  2539. },
  2540. prevAll: function( elem ) {
  2541. return jQuery.dir( elem, "previousSibling" );
  2542. },
  2543. nextUntil: function( elem, i, until ) {
  2544. return jQuery.dir( elem, "nextSibling", until );
  2545. },
  2546. prevUntil: function( elem, i, until ) {
  2547. return jQuery.dir( elem, "previousSibling", until );
  2548. },
  2549. siblings: function( elem ) {
  2550. return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem );
  2551. },
  2552. children: function( elem ) {
  2553. return jQuery.sibling( elem.firstChild );
  2554. },
  2555. contents: function( elem ) {
  2556. return jQuery.nodeName( elem, "iframe" ) ?
  2557. elem.contentDocument || elem.contentWindow.document :
  2558. jQuery.merge( [], elem.childNodes );
  2559. }
  2560. }, function( name, fn ) {
  2561. jQuery.fn[ name ] = function( until, selector ) {
  2562. var ret = jQuery.map( this, fn, until );
  2563. if ( name.slice( -5 ) !== "Until" ) {
  2564. selector = until;
  2565. }
  2566. if ( selector && typeof selector === "string" ) {
  2567. ret = jQuery.filter( selector, ret );
  2568. }
  2569. if ( this.length > 1 ) {
  2570. // Remove duplicates
  2571. if ( !guaranteedUnique[ name ] ) {
  2572. ret = jQuery.unique( ret );
  2573. }
  2574. // Reverse order for parents* and prev-derivatives
  2575. if ( rparentsprev.test( name ) ) {
  2576. ret = ret.reverse();
  2577. }
  2578. }
  2579. return this.pushStack( ret );
  2580. };
  2581. });
  2582. var rnotwhite = (/\S+/g);
  2583. // String to Object options format cache
  2584. var optionsCache = {};
  2585. // Convert String-formatted options into Object-formatted ones and store in cache
  2586. function createOptions( options ) {
  2587. var object = optionsCache[ options ] = {};
  2588. jQuery.each( options.match( rnotwhite ) || [], function( _, flag ) {
  2589. object[ flag ] = true;
  2590. });
  2591. return object;
  2592. }
  2593. /*
  2594. * Create a callback list using the following parameters:
  2595. *
  2596. * options: an optional list of space-separated options that will change how
  2597. * the callback list behaves or a more traditional option object
  2598. *
  2599. * By default a callback list will act like an event callback list and can be
  2600. * "fired" multiple times.
  2601. *
  2602. * Possible options:
  2603. *
  2604. * once: will ensure the callback list can only be fired once (like a Deferred)
  2605. *
  2606. * memory: will keep track of previous values and will call any callback added
  2607. * after the list has been fired right away with the latest "memorized"
  2608. * values (like a Deferred)
  2609. *
  2610. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2611. *
  2612. * stopOnFalse: interrupt callings when a callback returns false
  2613. *
  2614. */
  2615. jQuery.Callbacks = function( options ) {
  2616. // Convert options from String-formatted to Object-formatted if needed
  2617. // (we check in cache first)
  2618. options = typeof options === "string" ?
  2619. ( optionsCache[ options ] || createOptions( options ) ) :
  2620. jQuery.extend( {}, options );
  2621. var // Flag to know if list is currently firing
  2622. firing,
  2623. // Last fire value (for non-forgettable lists)
  2624. memory,
  2625. // Flag to know if list was already fired
  2626. fired,
  2627. // End of the loop when firing
  2628. firingLength,
  2629. // Index of currently firing callback (modified by remove if needed)
  2630. firingIndex,
  2631. // First callback to fire (used internally by add and fireWith)
  2632. firingStart,
  2633. // Actual callback list
  2634. list = [],
  2635. // Stack of fire calls for repeatable lists
  2636. stack = !options.once && [],
  2637. // Fire callbacks
  2638. fire = function( data ) {
  2639. memory = options.memory && data;
  2640. fired = true;
  2641. firingIndex = firingStart || 0;
  2642. firingStart = 0;
  2643. firingLength = list.length;
  2644. firing = true;
  2645. for ( ; list && firingIndex < firingLength; firingIndex++ ) {
  2646. if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
  2647. memory = false; // To prevent further calls using add
  2648. break;
  2649. }
  2650. }
  2651. firing = false;
  2652. if ( list ) {
  2653. if ( stack ) {
  2654. if ( stack.length ) {
  2655. fire( stack.shift() );
  2656. }
  2657. } else if ( memory ) {
  2658. list = [];
  2659. } else {
  2660. self.disable();
  2661. }
  2662. }
  2663. },
  2664. // Actual Callbacks object
  2665. self = {
  2666. // Add a callback or a collection of callbacks to the list
  2667. add: function() {
  2668. if ( list ) {
  2669. // First, we save the current length
  2670. var start = list.length;
  2671. (function add( args ) {
  2672. jQuery.each( args, function( _, arg ) {
  2673. var type = jQuery.type( arg );
  2674. if ( type === "function" ) {
  2675. if ( !options.unique || !self.has( arg ) ) {
  2676. list.push( arg );
  2677. }
  2678. } else if ( arg && arg.length && type !== "string" ) {
  2679. // Inspect recursively
  2680. add( arg );
  2681. }
  2682. });
  2683. })( arguments );
  2684. // Do we need to add the callbacks to the
  2685. // current firing batch?
  2686. if ( firing ) {
  2687. firingLength = list.length;
  2688. // With memory, if we're not firing then
  2689. // we should call right away
  2690. } else if ( memory ) {
  2691. firingStart = start;
  2692. fire( memory );
  2693. }
  2694. }
  2695. return this;
  2696. },
  2697. // Remove a callback from the list
  2698. remove: function() {
  2699. if ( list ) {
  2700. jQuery.each( arguments, function( _, arg ) {
  2701. var index;
  2702. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2703. list.splice( index, 1 );
  2704. // Handle firing indexes
  2705. if ( firing ) {
  2706. if ( index <= firingLength ) {
  2707. firingLength--;
  2708. }
  2709. if ( index <= firingIndex ) {
  2710. firingIndex--;
  2711. }
  2712. }
  2713. }
  2714. });
  2715. }
  2716. return this;
  2717. },
  2718. // Check if a given callback is in the list.
  2719. // If no argument is given, return whether or not list has callbacks attached.
  2720. has: function( fn ) {
  2721. return fn ? jQuery.inArray( fn, list ) > -1 : !!( list && list.length );
  2722. },
  2723. // Remove all callbacks from the list
  2724. empty: function() {
  2725. list = [];
  2726. firingLength = 0;
  2727. return this;
  2728. },
  2729. // Have the list do nothing anymore
  2730. disable: function() {
  2731. list = stack = memory = undefined;
  2732. return this;
  2733. },
  2734. // Is it disabled?
  2735. disabled: function() {
  2736. return !list;
  2737. },
  2738. // Lock the list in its current state
  2739. lock: function() {
  2740. stack = undefined;
  2741. if ( !memory ) {
  2742. self.disable();
  2743. }
  2744. return this;
  2745. },
  2746. // Is it locked?
  2747. locked: function() {
  2748. return !stack;
  2749. },
  2750. // Call all callbacks with the given context and arguments
  2751. fireWith: function( context, args ) {
  2752. if ( list && ( !fired || stack ) ) {
  2753. args = args || [];
  2754. args = [ context, args.slice ? args.slice() : args ];
  2755. if ( firing ) {
  2756. stack.push( args );
  2757. } else {
  2758. fire( args );
  2759. }
  2760. }
  2761. return this;
  2762. },
  2763. // Call all the callbacks with the given arguments
  2764. fire: function() {
  2765. self.fireWith( this, arguments );
  2766. return this;
  2767. },
  2768. // To know if the callbacks have already been called at least once
  2769. fired: function() {
  2770. return !!fired;
  2771. }
  2772. };
  2773. return self;
  2774. };
  2775. jQuery.extend({
  2776. Deferred: function( func ) {
  2777. var tuples = [
  2778. // action, add listener, listener list, final state
  2779. [ "resolve", "done", jQuery.Callbacks("once memory"), "resolved" ],
  2780. [ "reject", "fail", jQuery.Callbacks("once memory"), "rejected" ],
  2781. [ "notify", "progress", jQuery.Callbacks("memory") ]
  2782. ],
  2783. state = "pending",
  2784. promise = {
  2785. state: function() {
  2786. return state;
  2787. },
  2788. always: function() {
  2789. deferred.done( arguments ).fail( arguments );
  2790. return this;
  2791. },
  2792. then: function( /* fnDone, fnFail, fnProgress */ ) {
  2793. var fns = arguments;
  2794. return jQuery.Deferred(function( newDefer ) {
  2795. jQuery.each( tuples, function( i, tuple ) {
  2796. var fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];
  2797. // deferred[ done | fail | progress ] for forwarding actions to newDefer
  2798. deferred[ tuple[1] ](function() {
  2799. var returned = fn && fn.apply( this, arguments );
  2800. if ( returned && jQuery.isFunction( returned.promise ) ) {
  2801. returned.promise()
  2802. .done( newDefer.resolve )
  2803. .fail( newDefer.reject )
  2804. .progress( newDefer.notify );
  2805. } else {
  2806. newDefer[ tuple[ 0 ] + "With" ]( this === promise ? newDefer.promise() : this, fn ? [ returned ] : arguments );
  2807. }
  2808. });
  2809. });
  2810. fns = null;
  2811. }).promise();
  2812. },
  2813. // Get a promise for this deferred
  2814. // If obj is provided, the promise aspect is added to the object
  2815. promise: function( obj ) {
  2816. return obj != null ? jQuery.extend( obj, promise ) : promise;
  2817. }
  2818. },
  2819. deferred = {};
  2820. // Keep pipe for back-compat
  2821. promise.pipe = promise.then;
  2822. // Add list-specific methods
  2823. jQuery.each( tuples, function( i, tuple ) {
  2824. var list = tuple[ 2 ],
  2825. stateString = tuple[ 3 ];
  2826. // promise[ done | fail | progress ] = list.add
  2827. promise[ tuple[1] ] = list.add;
  2828. // Handle state
  2829. if ( stateString ) {
  2830. list.add(function() {
  2831. // state = [ resolved | rejected ]
  2832. state = stateString;
  2833. // [ reject_list | resolve_list ].disable; progress_list.lock
  2834. }, tuples[ i ^ 1 ][ 2 ].disable, tuples[ 2 ][ 2 ].lock );
  2835. }
  2836. // deferred[ resolve | reject | notify ]
  2837. deferred[ tuple[0] ] = function() {
  2838. deferred[ tuple[0] + "With" ]( this === deferred ? promise : this, arguments );
  2839. return this;
  2840. };
  2841. deferred[ tuple[0] + "With" ] = list.fireWith;
  2842. });
  2843. // Make the deferred a promise
  2844. promise.promise( deferred );
  2845. // Call given func if any
  2846. if ( func ) {
  2847. func.call( deferred, deferred );
  2848. }
  2849. // All done!
  2850. return deferred;
  2851. },
  2852. // Deferred helper
  2853. when: function( subordinate /* , ..., subordinateN */ ) {
  2854. var i = 0,
  2855. resolveValues = slice.call( arguments ),
  2856. length = resolveValues.length,
  2857. // the count of uncompleted subordinates
  2858. remaining = length !== 1 || ( subordinate && jQuery.isFunction( subordinate.promise ) ) ? length : 0,
  2859. // the master Deferred. If resolveValues consist of only a single Deferred, just use that.
  2860. deferred = remaining === 1 ? subordinate : jQuery.Deferred(),
  2861. // Update function for both resolve and progress values
  2862. updateFunc = function( i, contexts, values ) {
  2863. return function( value ) {
  2864. contexts[ i ] = this;
  2865. values[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  2866. if ( values === progressValues ) {
  2867. deferred.notifyWith( contexts, values );
  2868. } else if ( !(--remaining) ) {
  2869. deferred.resolveWith( contexts, values );
  2870. }
  2871. };
  2872. },
  2873. progressValues, progressContexts, resolveContexts;
  2874. // add listeners to Deferred subordinates; treat others as resolved
  2875. if ( length > 1 ) {
  2876. progressValues = new Array( length );
  2877. progressContexts = new Array( length );
  2878. resolveContexts = new Array( length );
  2879. for ( ; i < length; i++ ) {
  2880. if ( resolveValues[ i ] && jQuery.isFunction( resolveValues[ i ].promise ) ) {
  2881. resolveValues[ i ].promise()
  2882. .done( updateFunc( i, resolveContexts, resolveValues ) )
  2883. .fail( deferred.reject )
  2884. .progress( updateFunc( i, progressContexts, progressValues ) );
  2885. } else {
  2886. --remaining;
  2887. }
  2888. }
  2889. }
  2890. // if we're not waiting on anything, resolve the master
  2891. if ( !remaining ) {
  2892. deferred.resolveWith( resolveContexts, resolveValues );
  2893. }
  2894. return deferred.promise();
  2895. }
  2896. });
  2897. // The deferred used on DOM ready
  2898. var readyList;
  2899. jQuery.fn.ready = function( fn ) {
  2900. // Add the callback
  2901. jQuery.ready.promise().done( fn );
  2902. return this;
  2903. };
  2904. jQuery.extend({
  2905. // Is the DOM ready to be used? Set to true once it occurs.
  2906. isReady: false,
  2907. // A counter to track how many items to wait for before
  2908. // the ready event fires. See #6781
  2909. readyWait: 1,
  2910. // Hold (or release) the ready event
  2911. holdReady: function( hold ) {
  2912. if ( hold ) {
  2913. jQuery.readyWait++;
  2914. } else {
  2915. jQuery.ready( true );
  2916. }
  2917. },
  2918. // Handle when the DOM is ready
  2919. ready: function( wait ) {
  2920. // Abort if there are pending holds or we're already ready
  2921. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  2922. return;
  2923. }
  2924. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  2925. if ( !document.body ) {
  2926. return setTimeout( jQuery.ready );
  2927. }
  2928. // Remember that the DOM is ready
  2929. jQuery.isReady = true;
  2930. // If a normal DOM Ready event fired, decrement, and wait if need be
  2931. if ( wait !== true && --jQuery.readyWait > 0 ) {
  2932. return;
  2933. }
  2934. // If there are functions bound, to execute
  2935. readyList.resolveWith( document, [ jQuery ] );
  2936. // Trigger any bound ready events
  2937. if ( jQuery.fn.triggerHandler ) {
  2938. jQuery( document ).triggerHandler( "ready" );
  2939. jQuery( document ).off( "ready" );
  2940. }
  2941. }
  2942. });
  2943. /**
  2944. * Clean-up method for dom ready events
  2945. */
  2946. function detach() {
  2947. if ( document.addEventListener ) {
  2948. document.removeEventListener( "DOMContentLoaded", completed, false );
  2949. window.removeEventListener( "load", completed, false );
  2950. } else {
  2951. document.detachEvent( "onreadystatechange", completed );
  2952. window.detachEvent( "onload", completed );
  2953. }
  2954. }
  2955. /**
  2956. * The ready event handler and self cleanup method
  2957. */
  2958. function completed() {
  2959. // readyState === "complete" is good enough for us to call the dom ready in oldIE
  2960. if ( document.addEventListener || event.type === "load" || document.readyState === "complete" ) {
  2961. detach();
  2962. jQuery.ready();
  2963. }
  2964. }
  2965. jQuery.ready.promise = function( obj ) {
  2966. if ( !readyList ) {
  2967. readyList = jQuery.Deferred();
  2968. // Catch cases where $(document).ready() is called after the browser event has already occurred.
  2969. // we once tried to use readyState "interactive" here, but it caused issues like the one
  2970. // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
  2971. if ( document.readyState === "complete" ) {
  2972. // Handle it asynchronously to allow scripts the opportunity to delay ready
  2973. setTimeout( jQuery.ready );
  2974. // Standards-based browsers support DOMContentLoaded
  2975. } else if ( document.addEventListener ) {
  2976. // Use the handy event callback
  2977. document.addEventListener( "DOMContentLoaded", completed, false );
  2978. // A fallback to window.onload, that will always work
  2979. window.addEventListener( "load", completed, false );
  2980. // If IE event model is used
  2981. } else {
  2982. // Ensure firing before onload, maybe late but safe also for iframes
  2983. document.attachEvent( "onreadystatechange", completed );
  2984. // A fallback to window.onload, that will always work
  2985. window.attachEvent( "onload", completed );
  2986. // If IE and not a frame
  2987. // continually check to see if the document is ready
  2988. var top = false;
  2989. try {
  2990. top = window.frameElement == null && document.documentElement;
  2991. } catch(e) {}
  2992. if ( top && top.doScroll ) {
  2993. (function doScrollCheck() {
  2994. if ( !jQuery.isReady ) {
  2995. try {
  2996. // Use the trick by Diego Perini
  2997. // http://javascript.nwbox.com/IEContentLoaded/
  2998. top.doScroll("left");
  2999. } catch(e) {
  3000. return setTimeout( doScrollCheck, 50 );
  3001. }
  3002. // detach all dom ready events
  3003. detach();
  3004. // and execute any waiting functions
  3005. jQuery.ready();
  3006. }
  3007. })();
  3008. }
  3009. }
  3010. }
  3011. return readyList.promise( obj );
  3012. };
  3013. var strundefined = typeof undefined;
  3014. // Support: IE<9
  3015. // Iteration over object's inherited properties before its own
  3016. var i;
  3017. for ( i in jQuery( support ) ) {
  3018. break;
  3019. }
  3020. support.ownLast = i !== "0";
  3021. // Note: most support tests are defined in their respective modules.
  3022. // false until the test is run
  3023. support.inlineBlockNeedsLayout = false;
  3024. // Execute ASAP in case we need to set body.style.zoom
  3025. jQuery(function() {
  3026. // Minified: var a,b,c,d
  3027. var val, div, body, container;
  3028. body = document.getElementsByTagName( "body" )[ 0 ];
  3029. if ( !body || !body.style ) {
  3030. // Return for frameset docs that don't have a body
  3031. return;
  3032. }
  3033. // Setup
  3034. div = document.createElement( "div" );
  3035. container = document.createElement( "div" );
  3036. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  3037. body.appendChild( container ).appendChild( div );
  3038. if ( typeof div.style.zoom !== strundefined ) {
  3039. // Support: IE<8
  3040. // Check if natively block-level elements act like inline-block
  3041. // elements when setting their display to 'inline' and giving
  3042. // them layout
  3043. div.style.cssText = "display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1";
  3044. support.inlineBlockNeedsLayout = val = div.offsetWidth === 3;
  3045. if ( val ) {
  3046. // Prevent IE 6 from affecting layout for positioned elements #11048
  3047. // Prevent IE from shrinking the body in IE 7 mode #12869
  3048. // Support: IE<8
  3049. body.style.zoom = 1;
  3050. }
  3051. }
  3052. body.removeChild( container );
  3053. });
  3054. (function() {
  3055. var div = document.createElement( "div" );
  3056. // Execute the test only if not already executed in another module.
  3057. if (support.deleteExpando == null) {
  3058. // Support: IE<9
  3059. support.deleteExpando = true;
  3060. try {
  3061. delete div.test;
  3062. } catch( e ) {
  3063. support.deleteExpando = false;
  3064. }
  3065. }
  3066. // Null elements to avoid leaks in IE.
  3067. div = null;
  3068. })();
  3069. /**
  3070. * Determines whether an object can have data
  3071. */
  3072. jQuery.acceptData = function( elem ) {
  3073. var noData = jQuery.noData[ (elem.nodeName + " ").toLowerCase() ],
  3074. nodeType = +elem.nodeType || 1;
  3075. // Do not set data on non-element DOM nodes because it will not be cleared (#8335).
  3076. return nodeType !== 1 && nodeType !== 9 ?
  3077. false :
  3078. // Nodes accept data unless otherwise specified; rejection can be conditional
  3079. !noData || noData !== true && elem.getAttribute("classid") === noData;
  3080. };
  3081. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3082. rmultiDash = /([A-Z])/g;
  3083. function dataAttr( elem, key, data ) {
  3084. // If nothing was found internally, try to fetch any
  3085. // data from the HTML5 data-* attribute
  3086. if ( data === undefined && elem.nodeType === 1 ) {
  3087. var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase();
  3088. data = elem.getAttribute( name );
  3089. if ( typeof data === "string" ) {
  3090. try {
  3091. data = data === "true" ? true :
  3092. data === "false" ? false :
  3093. data === "null" ? null :
  3094. // Only convert to a number if it doesn't change the string
  3095. +data + "" === data ? +data :
  3096. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  3097. data;
  3098. } catch( e ) {}
  3099. // Make sure we set the data so it isn't changed later
  3100. jQuery.data( elem, key, data );
  3101. } else {
  3102. data = undefined;
  3103. }
  3104. }
  3105. return data;
  3106. }
  3107. // checks a cache object for emptiness
  3108. function isEmptyDataObject( obj ) {
  3109. var name;
  3110. for ( name in obj ) {
  3111. // if the public data object is empty, the private is still empty
  3112. if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) {
  3113. continue;
  3114. }
  3115. if ( name !== "toJSON" ) {
  3116. return false;
  3117. }
  3118. }
  3119. return true;
  3120. }
  3121. function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
  3122. if ( !jQuery.acceptData( elem ) ) {
  3123. return;
  3124. }
  3125. var ret, thisCache,
  3126. internalKey = jQuery.expando,
  3127. // We have to handle DOM nodes and JS objects differently because IE6-7
  3128. // can't GC object references properly across the DOM-JS boundary
  3129. isNode = elem.nodeType,
  3130. // Only DOM nodes need the global jQuery cache; JS object data is
  3131. // attached directly to the object so GC can occur automatically
  3132. cache = isNode ? jQuery.cache : elem,
  3133. // Only defining an ID for JS objects if its cache already exists allows
  3134. // the code to shortcut on the same path as a DOM node with no cache
  3135. id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey;
  3136. // Avoid doing any more work than we need to when trying to get data on an
  3137. // object that has no data at all
  3138. if ( (!id || !cache[id] || (!pvt && !cache[id].data)) && data === undefined && typeof name === "string" ) {
  3139. return;
  3140. }
  3141. if ( !id ) {
  3142. // Only DOM nodes need a new unique ID for each element since their data
  3143. // ends up in the global cache
  3144. if ( isNode ) {
  3145. id = elem[ internalKey ] = deletedIds.pop() || jQuery.guid++;
  3146. } else {
  3147. id = internalKey;
  3148. }
  3149. }
  3150. if ( !cache[ id ] ) {
  3151. // Avoid exposing jQuery metadata on plain JS objects when the object
  3152. // is serialized using JSON.stringify
  3153. cache[ id ] = isNode ? {} : { toJSON: jQuery.noop };
  3154. }
  3155. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  3156. // shallow copied over onto the existing cache
  3157. if ( typeof name === "object" || typeof name === "function" ) {
  3158. if ( pvt ) {
  3159. cache[ id ] = jQuery.extend( cache[ id ], name );
  3160. } else {
  3161. cache[ id ].data = jQuery.extend( cache[ id ].data, name );
  3162. }
  3163. }
  3164. thisCache = cache[ id ];
  3165. // jQuery data() is stored in a separate object inside the object's internal data
  3166. // cache in order to avoid key collisions between internal data and user-defined
  3167. // data.
  3168. if ( !pvt ) {
  3169. if ( !thisCache.data ) {
  3170. thisCache.data = {};
  3171. }
  3172. thisCache = thisCache.data;
  3173. }
  3174. if ( data !== undefined ) {
  3175. thisCache[ jQuery.camelCase( name ) ] = data;
  3176. }
  3177. // Check for both converted-to-camel and non-converted data property names
  3178. // If a data property was specified
  3179. if ( typeof name === "string" ) {
  3180. // First Try to find as-is property data
  3181. ret = thisCache[ name ];
  3182. // Test for null|undefined property data
  3183. if ( ret == null ) {
  3184. // Try to find the camelCased property
  3185. ret = thisCache[ jQuery.camelCase( name ) ];
  3186. }
  3187. } else {
  3188. ret = thisCache;
  3189. }
  3190. return ret;
  3191. }
  3192. function internalRemoveData( elem, name, pvt ) {
  3193. if ( !jQuery.acceptData( elem ) ) {
  3194. return;
  3195. }
  3196. var thisCache, i,
  3197. isNode = elem.nodeType,
  3198. // See jQuery.data for more information
  3199. cache = isNode ? jQuery.cache : elem,
  3200. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  3201. // If there is already no cache entry for this object, there is no
  3202. // purpose in continuing
  3203. if ( !cache[ id ] ) {
  3204. return;
  3205. }
  3206. if ( name ) {
  3207. thisCache = pvt ? cache[ id ] : cache[ id ].data;
  3208. if ( thisCache ) {
  3209. // Support array or space separated string names for data keys
  3210. if ( !jQuery.isArray( name ) ) {
  3211. // try the string as a key before any manipulation
  3212. if ( name in thisCache ) {
  3213. name = [ name ];
  3214. } else {
  3215. // split the camel cased version by spaces unless a key with the spaces exists
  3216. name = jQuery.camelCase( name );
  3217. if ( name in thisCache ) {
  3218. name = [ name ];
  3219. } else {
  3220. name = name.split(" ");
  3221. }
  3222. }
  3223. } else {
  3224. // If "name" is an array of keys...
  3225. // When data is initially created, via ("key", "val") signature,
  3226. // keys will be converted to camelCase.
  3227. // Since there is no way to tell _how_ a key was added, remove
  3228. // both plain key and camelCase key. #12786
  3229. // This will only penalize the array argument path.
  3230. name = name.concat( jQuery.map( name, jQuery.camelCase ) );
  3231. }
  3232. i = name.length;
  3233. while ( i-- ) {
  3234. delete thisCache[ name[i] ];
  3235. }
  3236. // If there is no data left in the cache, we want to continue
  3237. // and let the cache object itself get destroyed
  3238. if ( pvt ? !isEmptyDataObject(thisCache) : !jQuery.isEmptyObject(thisCache) ) {
  3239. return;
  3240. }
  3241. }
  3242. }
  3243. // See jQuery.data for more information
  3244. if ( !pvt ) {
  3245. delete cache[ id ].data;
  3246. // Don't destroy the parent cache unless the internal data object
  3247. // had been the only thing left in it
  3248. if ( !isEmptyDataObject( cache[ id ] ) ) {
  3249. return;
  3250. }
  3251. }
  3252. // Destroy the cache
  3253. if ( isNode ) {
  3254. jQuery.cleanData( [ elem ], true );
  3255. // Use delete when supported for expandos or `cache` is not a window per isWindow (#10080)
  3256. /* jshint eqeqeq: false */
  3257. } else if ( support.deleteExpando || cache != cache.window ) {
  3258. /* jshint eqeqeq: true */
  3259. delete cache[ id ];
  3260. // When all else fails, null
  3261. } else {
  3262. cache[ id ] = null;
  3263. }
  3264. }
  3265. jQuery.extend({
  3266. cache: {},
  3267. // The following elements (space-suffixed to avoid Object.prototype collisions)
  3268. // throw uncatchable exceptions if you attempt to set expando properties
  3269. noData: {
  3270. "applet ": true,
  3271. "embed ": true,
  3272. // ...but Flash objects (which have this classid) *can* handle expandos
  3273. "object ": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
  3274. },
  3275. hasData: function( elem ) {
  3276. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  3277. return !!elem && !isEmptyDataObject( elem );
  3278. },
  3279. data: function( elem, name, data ) {
  3280. return internalData( elem, name, data );
  3281. },
  3282. removeData: function( elem, name ) {
  3283. return internalRemoveData( elem, name );
  3284. },
  3285. // For internal use only.
  3286. _data: function( elem, name, data ) {
  3287. return internalData( elem, name, data, true );
  3288. },
  3289. _removeData: function( elem, name ) {
  3290. return internalRemoveData( elem, name, true );
  3291. }
  3292. });
  3293. jQuery.fn.extend({
  3294. data: function( key, value ) {
  3295. var i, name, data,
  3296. elem = this[0],
  3297. attrs = elem && elem.attributes;
  3298. // Special expections of .data basically thwart jQuery.access,
  3299. // so implement the relevant behavior ourselves
  3300. // Gets all values
  3301. if ( key === undefined ) {
  3302. if ( this.length ) {
  3303. data = jQuery.data( elem );
  3304. if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
  3305. i = attrs.length;
  3306. while ( i-- ) {
  3307. // Support: IE11+
  3308. // The attrs elements can be null (#14894)
  3309. if ( attrs[ i ] ) {
  3310. name = attrs[ i ].name;
  3311. if ( name.indexOf( "data-" ) === 0 ) {
  3312. name = jQuery.camelCase( name.slice(5) );
  3313. dataAttr( elem, name, data[ name ] );
  3314. }
  3315. }
  3316. }
  3317. jQuery._data( elem, "parsedAttrs", true );
  3318. }
  3319. }
  3320. return data;
  3321. }
  3322. // Sets multiple values
  3323. if ( typeof key === "object" ) {
  3324. return this.each(function() {
  3325. jQuery.data( this, key );
  3326. });
  3327. }
  3328. return arguments.length > 1 ?
  3329. // Sets one value
  3330. this.each(function() {
  3331. jQuery.data( this, key, value );
  3332. }) :
  3333. // Gets one value
  3334. // Try to fetch any internally stored data first
  3335. elem ? dataAttr( elem, key, jQuery.data( elem, key ) ) : undefined;
  3336. },
  3337. removeData: function( key ) {
  3338. return this.each(function() {
  3339. jQuery.removeData( this, key );
  3340. });
  3341. }
  3342. });
  3343. jQuery.extend({
  3344. queue: function( elem, type, data ) {
  3345. var queue;
  3346. if ( elem ) {
  3347. type = ( type || "fx" ) + "queue";
  3348. queue = jQuery._data( elem, type );
  3349. // Speed up dequeue by getting out quickly if this is just a lookup
  3350. if ( data ) {
  3351. if ( !queue || jQuery.isArray(data) ) {
  3352. queue = jQuery._data( elem, type, jQuery.makeArray(data) );
  3353. } else {
  3354. queue.push( data );
  3355. }
  3356. }
  3357. return queue || [];
  3358. }
  3359. },
  3360. dequeue: function( elem, type ) {
  3361. type = type || "fx";
  3362. var queue = jQuery.queue( elem, type ),
  3363. startLength = queue.length,
  3364. fn = queue.shift(),
  3365. hooks = jQuery._queueHooks( elem, type ),
  3366. next = function() {
  3367. jQuery.dequeue( elem, type );
  3368. };
  3369. // If the fx queue is dequeued, always remove the progress sentinel
  3370. if ( fn === "inprogress" ) {
  3371. fn = queue.shift();
  3372. startLength--;
  3373. }
  3374. if ( fn ) {
  3375. // Add a progress sentinel to prevent the fx queue from being
  3376. // automatically dequeued
  3377. if ( type === "fx" ) {
  3378. queue.unshift( "inprogress" );
  3379. }
  3380. // clear up the last queue stop function
  3381. delete hooks.stop;
  3382. fn.call( elem, next, hooks );
  3383. }
  3384. if ( !startLength && hooks ) {
  3385. hooks.empty.fire();
  3386. }
  3387. },
  3388. // not intended for public consumption - generates a queueHooks object, or returns the current one
  3389. _queueHooks: function( elem, type ) {
  3390. var key = type + "queueHooks";
  3391. return jQuery._data( elem, key ) || jQuery._data( elem, key, {
  3392. empty: jQuery.Callbacks("once memory").add(function() {
  3393. jQuery._removeData( elem, type + "queue" );
  3394. jQuery._removeData( elem, key );
  3395. })
  3396. });
  3397. }
  3398. });
  3399. jQuery.fn.extend({
  3400. queue: function( type, data ) {
  3401. var setter = 2;
  3402. if ( typeof type !== "string" ) {
  3403. data = type;
  3404. type = "fx";
  3405. setter--;
  3406. }
  3407. if ( arguments.length < setter ) {
  3408. return jQuery.queue( this[0], type );
  3409. }
  3410. return data === undefined ?
  3411. this :
  3412. this.each(function() {
  3413. var queue = jQuery.queue( this, type, data );
  3414. // ensure a hooks for this queue
  3415. jQuery._queueHooks( this, type );
  3416. if ( type === "fx" && queue[0] !== "inprogress" ) {
  3417. jQuery.dequeue( this, type );
  3418. }
  3419. });
  3420. },
  3421. dequeue: function( type ) {
  3422. return this.each(function() {
  3423. jQuery.dequeue( this, type );
  3424. });
  3425. },
  3426. clearQueue: function( type ) {
  3427. return this.queue( type || "fx", [] );
  3428. },
  3429. // Get a promise resolved when queues of a certain type
  3430. // are emptied (fx is the type by default)
  3431. promise: function( type, obj ) {
  3432. var tmp,
  3433. count = 1,
  3434. defer = jQuery.Deferred(),
  3435. elements = this,
  3436. i = this.length,
  3437. resolve = function() {
  3438. if ( !( --count ) ) {
  3439. defer.resolveWith( elements, [ elements ] );
  3440. }
  3441. };
  3442. if ( typeof type !== "string" ) {
  3443. obj = type;
  3444. type = undefined;
  3445. }
  3446. type = type || "fx";
  3447. while ( i-- ) {
  3448. tmp = jQuery._data( elements[ i ], type + "queueHooks" );
  3449. if ( tmp && tmp.empty ) {
  3450. count++;
  3451. tmp.empty.add( resolve );
  3452. }
  3453. }
  3454. resolve();
  3455. return defer.promise( obj );
  3456. }
  3457. });
  3458. var pnum = (/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/).source;
  3459. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3460. var isHidden = function( elem, el ) {
  3461. // isHidden might be called from jQuery#filter function;
  3462. // in that case, element will be second argument
  3463. elem = el || elem;
  3464. return jQuery.css( elem, "display" ) === "none" || !jQuery.contains( elem.ownerDocument, elem );
  3465. };
  3466. // Multifunctional method to get and set values of a collection
  3467. // The value/s can optionally be executed if it's a function
  3468. var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3469. var i = 0,
  3470. length = elems.length,
  3471. bulk = key == null;
  3472. // Sets many values
  3473. if ( jQuery.type( key ) === "object" ) {
  3474. chainable = true;
  3475. for ( i in key ) {
  3476. jQuery.access( elems, fn, i, key[i], true, emptyGet, raw );
  3477. }
  3478. // Sets one value
  3479. } else if ( value !== undefined ) {
  3480. chainable = true;
  3481. if ( !jQuery.isFunction( value ) ) {
  3482. raw = true;
  3483. }
  3484. if ( bulk ) {
  3485. // Bulk operations run against the entire set
  3486. if ( raw ) {
  3487. fn.call( elems, value );
  3488. fn = null;
  3489. // ...except when executing function values
  3490. } else {
  3491. bulk = fn;
  3492. fn = function( elem, key, value ) {
  3493. return bulk.call( jQuery( elem ), value );
  3494. };
  3495. }
  3496. }
  3497. if ( fn ) {
  3498. for ( ; i < length; i++ ) {
  3499. fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) );
  3500. }
  3501. }
  3502. }
  3503. return chainable ?
  3504. elems :
  3505. // Gets
  3506. bulk ?
  3507. fn.call( elems ) :
  3508. length ? fn( elems[0], key ) : emptyGet;
  3509. };
  3510. var rcheckableType = (/^(?:checkbox|radio)$/i);
  3511. (function() {
  3512. // Minified: var a,b,c
  3513. var input = document.createElement( "input" ),
  3514. div = document.createElement( "div" ),
  3515. fragment = document.createDocumentFragment();
  3516. // Setup
  3517. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  3518. // IE strips leading whitespace when .innerHTML is used
  3519. support.leadingWhitespace = div.firstChild.nodeType === 3;
  3520. // Make sure that tbody elements aren't automatically inserted
  3521. // IE will insert them into empty tables
  3522. support.tbody = !div.getElementsByTagName( "tbody" ).length;
  3523. // Make sure that link elements get serialized correctly by innerHTML
  3524. // This requires a wrapper element in IE
  3525. support.htmlSerialize = !!div.getElementsByTagName( "link" ).length;
  3526. // Makes sure cloning an html5 element does not cause problems
  3527. // Where outerHTML is undefined, this still works
  3528. support.html5Clone =
  3529. document.createElement( "nav" ).cloneNode( true ).outerHTML !== "<:nav></:nav>";
  3530. // Check if a disconnected checkbox will retain its checked
  3531. // value of true after appended to the DOM (IE6/7)
  3532. input.type = "checkbox";
  3533. input.checked = true;
  3534. fragment.appendChild( input );
  3535. support.appendChecked = input.checked;
  3536. // Make sure textarea (and checkbox) defaultValue is properly cloned
  3537. // Support: IE6-IE11+
  3538. div.innerHTML = "<textarea>x</textarea>";
  3539. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  3540. // #11217 - WebKit loses check when the name is after the checked attribute
  3541. fragment.appendChild( div );
  3542. div.innerHTML = "<input type='radio' checked='checked' name='t'/>";
  3543. // Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3
  3544. // old WebKit doesn't clone checked state correctly in fragments
  3545. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  3546. // Support: IE<9
  3547. // Opera does not clone events (and typeof div.attachEvent === undefined).
  3548. // IE9-10 clones events bound via attachEvent, but they don't trigger with .click()
  3549. support.noCloneEvent = true;
  3550. if ( div.attachEvent ) {
  3551. div.attachEvent( "onclick", function() {
  3552. support.noCloneEvent = false;
  3553. });
  3554. div.cloneNode( true ).click();
  3555. }
  3556. // Execute the test only if not already executed in another module.
  3557. if (support.deleteExpando == null) {
  3558. // Support: IE<9
  3559. support.deleteExpando = true;
  3560. try {
  3561. delete div.test;
  3562. } catch( e ) {
  3563. support.deleteExpando = false;
  3564. }
  3565. }
  3566. })();
  3567. (function() {
  3568. var i, eventName,
  3569. div = document.createElement( "div" );
  3570. // Support: IE<9 (lack submit/change bubble), Firefox 23+ (lack focusin event)
  3571. for ( i in { submit: true, change: true, focusin: true }) {
  3572. eventName = "on" + i;
  3573. if ( !(support[ i + "Bubbles" ] = eventName in window) ) {
  3574. // Beware of CSP restrictions (https://developer.mozilla.org/en/Security/CSP)
  3575. div.setAttribute( eventName, "t" );
  3576. support[ i + "Bubbles" ] = div.attributes[ eventName ].expando === false;
  3577. }
  3578. }
  3579. // Null elements to avoid leaks in IE.
  3580. div = null;
  3581. })();
  3582. var rformElems = /^(?:input|select|textarea)$/i,
  3583. rkeyEvent = /^key/,
  3584. rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
  3585. rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  3586. rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
  3587. function returnTrue() {
  3588. return true;
  3589. }
  3590. function returnFalse() {
  3591. return false;
  3592. }
  3593. function safeActiveElement() {
  3594. try {
  3595. return document.activeElement;
  3596. } catch ( err ) { }
  3597. }
  3598. /*
  3599. * Helper functions for managing events -- not part of the public interface.
  3600. * Props to Dean Edwards' addEvent library for many of the ideas.
  3601. */
  3602. jQuery.event = {
  3603. global: {},
  3604. add: function( elem, types, handler, data, selector ) {
  3605. var tmp, events, t, handleObjIn,
  3606. special, eventHandle, handleObj,
  3607. handlers, type, namespaces, origType,
  3608. elemData = jQuery._data( elem );
  3609. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  3610. if ( !elemData ) {
  3611. return;
  3612. }
  3613. // Caller can pass in an object of custom data in lieu of the handler
  3614. if ( handler.handler ) {
  3615. handleObjIn = handler;
  3616. handler = handleObjIn.handler;
  3617. selector = handleObjIn.selector;
  3618. }
  3619. // Make sure that the handler has a unique ID, used to find/remove it later
  3620. if ( !handler.guid ) {
  3621. handler.guid = jQuery.guid++;
  3622. }
  3623. // Init the element's event structure and main handler, if this is the first
  3624. if ( !(events = elemData.events) ) {
  3625. events = elemData.events = {};
  3626. }
  3627. if ( !(eventHandle = elemData.handle) ) {
  3628. eventHandle = elemData.handle = function( e ) {
  3629. // Discard the second event of a jQuery.event.trigger() and
  3630. // when an event is called after a page has unloaded
  3631. return typeof jQuery !== strundefined && (!e || jQuery.event.triggered !== e.type) ?
  3632. jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
  3633. undefined;
  3634. };
  3635. // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
  3636. eventHandle.elem = elem;
  3637. }
  3638. // Handle multiple events separated by a space
  3639. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3640. t = types.length;
  3641. while ( t-- ) {
  3642. tmp = rtypenamespace.exec( types[t] ) || [];
  3643. type = origType = tmp[1];
  3644. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3645. // There *must* be a type, no attaching namespace-only handlers
  3646. if ( !type ) {
  3647. continue;
  3648. }
  3649. // If event changes its type, use the special event handlers for the changed type
  3650. special = jQuery.event.special[ type ] || {};
  3651. // If selector defined, determine special event api type, otherwise given type
  3652. type = ( selector ? special.delegateType : special.bindType ) || type;
  3653. // Update special based on newly reset type
  3654. special = jQuery.event.special[ type ] || {};
  3655. // handleObj is passed to all event handlers
  3656. handleObj = jQuery.extend({
  3657. type: type,
  3658. origType: origType,
  3659. data: data,
  3660. handler: handler,
  3661. guid: handler.guid,
  3662. selector: selector,
  3663. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  3664. namespace: namespaces.join(".")
  3665. }, handleObjIn );
  3666. // Init the event handler queue if we're the first
  3667. if ( !(handlers = events[ type ]) ) {
  3668. handlers = events[ type ] = [];
  3669. handlers.delegateCount = 0;
  3670. // Only use addEventListener/attachEvent if the special events handler returns false
  3671. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  3672. // Bind the global event handler to the element
  3673. if ( elem.addEventListener ) {
  3674. elem.addEventListener( type, eventHandle, false );
  3675. } else if ( elem.attachEvent ) {
  3676. elem.attachEvent( "on" + type, eventHandle );
  3677. }
  3678. }
  3679. }
  3680. if ( special.add ) {
  3681. special.add.call( elem, handleObj );
  3682. if ( !handleObj.handler.guid ) {
  3683. handleObj.handler.guid = handler.guid;
  3684. }
  3685. }
  3686. // Add to the element's handler list, delegates in front
  3687. if ( selector ) {
  3688. handlers.splice( handlers.delegateCount++, 0, handleObj );
  3689. } else {
  3690. handlers.push( handleObj );
  3691. }
  3692. // Keep track of which events have ever been used, for event optimization
  3693. jQuery.event.global[ type ] = true;
  3694. }
  3695. // Nullify elem to prevent memory leaks in IE
  3696. elem = null;
  3697. },
  3698. // Detach an event or set of events from an element
  3699. remove: function( elem, types, handler, selector, mappedTypes ) {
  3700. var j, handleObj, tmp,
  3701. origCount, t, events,
  3702. special, handlers, type,
  3703. namespaces, origType,
  3704. elemData = jQuery.hasData( elem ) && jQuery._data( elem );
  3705. if ( !elemData || !(events = elemData.events) ) {
  3706. return;
  3707. }
  3708. // Once for each type.namespace in types; type may be omitted
  3709. types = ( types || "" ).match( rnotwhite ) || [ "" ];
  3710. t = types.length;
  3711. while ( t-- ) {
  3712. tmp = rtypenamespace.exec( types[t] ) || [];
  3713. type = origType = tmp[1];
  3714. namespaces = ( tmp[2] || "" ).split( "." ).sort();
  3715. // Unbind all events (on this namespace, if provided) for the element
  3716. if ( !type ) {
  3717. for ( type in events ) {
  3718. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  3719. }
  3720. continue;
  3721. }
  3722. special = jQuery.event.special[ type ] || {};
  3723. type = ( selector ? special.delegateType : special.bindType ) || type;
  3724. handlers = events[ type ] || [];
  3725. tmp = tmp[2] && new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" );
  3726. // Remove matching events
  3727. origCount = j = handlers.length;
  3728. while ( j-- ) {
  3729. handleObj = handlers[ j ];
  3730. if ( ( mappedTypes || origType === handleObj.origType ) &&
  3731. ( !handler || handler.guid === handleObj.guid ) &&
  3732. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  3733. ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
  3734. handlers.splice( j, 1 );
  3735. if ( handleObj.selector ) {
  3736. handlers.delegateCount--;
  3737. }
  3738. if ( special.remove ) {
  3739. special.remove.call( elem, handleObj );
  3740. }
  3741. }
  3742. }
  3743. // Remove generic event handler if we removed something and no more handlers exist
  3744. // (avoids potential for endless recursion during removal of special event handlers)
  3745. if ( origCount && !handlers.length ) {
  3746. if ( !special.teardown || special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  3747. jQuery.removeEvent( elem, type, elemData.handle );
  3748. }
  3749. delete events[ type ];
  3750. }
  3751. }
  3752. // Remove the expando if it's no longer used
  3753. if ( jQuery.isEmptyObject( events ) ) {
  3754. delete elemData.handle;
  3755. // removeData also checks for emptiness and clears the expando if empty
  3756. // so use it instead of delete
  3757. jQuery._removeData( elem, "events" );
  3758. }
  3759. },
  3760. trigger: function( event, data, elem, onlyHandlers ) {
  3761. var handle, ontype, cur,
  3762. bubbleType, special, tmp, i,
  3763. eventPath = [ elem || document ],
  3764. type = hasOwn.call( event, "type" ) ? event.type : event,
  3765. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split(".") : [];
  3766. cur = tmp = elem = elem || document;
  3767. // Don't do events on text and comment nodes
  3768. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  3769. return;
  3770. }
  3771. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  3772. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  3773. return;
  3774. }
  3775. if ( type.indexOf(".") >= 0 ) {
  3776. // Namespaced trigger; create a regexp to match event type in handle()
  3777. namespaces = type.split(".");
  3778. type = namespaces.shift();
  3779. namespaces.sort();
  3780. }
  3781. ontype = type.indexOf(":") < 0 && "on" + type;
  3782. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  3783. event = event[ jQuery.expando ] ?
  3784. event :
  3785. new jQuery.Event( type, typeof event === "object" && event );
  3786. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  3787. event.isTrigger = onlyHandlers ? 2 : 3;
  3788. event.namespace = namespaces.join(".");
  3789. event.namespace_re = event.namespace ?
  3790. new RegExp( "(^|\\.)" + namespaces.join("\\.(?:.*\\.|)") + "(\\.|$)" ) :
  3791. null;
  3792. // Clean up the event in case it is being reused
  3793. event.result = undefined;
  3794. if ( !event.target ) {
  3795. event.target = elem;
  3796. }
  3797. // Clone any incoming data and prepend the event, creating the handler arg list
  3798. data = data == null ?
  3799. [ event ] :
  3800. jQuery.makeArray( data, [ event ] );
  3801. // Allow special events to draw outside the lines
  3802. special = jQuery.event.special[ type ] || {};
  3803. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  3804. return;
  3805. }
  3806. // Determine event propagation path in advance, per W3C events spec (#9951)
  3807. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  3808. if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) {
  3809. bubbleType = special.delegateType || type;
  3810. if ( !rfocusMorph.test( bubbleType + type ) ) {
  3811. cur = cur.parentNode;
  3812. }
  3813. for ( ; cur; cur = cur.parentNode ) {
  3814. eventPath.push( cur );
  3815. tmp = cur;
  3816. }
  3817. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  3818. if ( tmp === (elem.ownerDocument || document) ) {
  3819. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  3820. }
  3821. }
  3822. // Fire handlers on the event path
  3823. i = 0;
  3824. while ( (cur = eventPath[i++]) && !event.isPropagationStopped() ) {
  3825. event.type = i > 1 ?
  3826. bubbleType :
  3827. special.bindType || type;
  3828. // jQuery handler
  3829. handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" );
  3830. if ( handle ) {
  3831. handle.apply( cur, data );
  3832. }
  3833. // Native handler
  3834. handle = ontype && cur[ ontype ];
  3835. if ( handle && handle.apply && jQuery.acceptData( cur ) ) {
  3836. event.result = handle.apply( cur, data );
  3837. if ( event.result === false ) {
  3838. event.preventDefault();
  3839. }
  3840. }
  3841. }
  3842. event.type = type;
  3843. // If nobody prevented the default action, do it now
  3844. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  3845. if ( (!special._default || special._default.apply( eventPath.pop(), data ) === false) &&
  3846. jQuery.acceptData( elem ) ) {
  3847. // Call a native DOM method on the target with the same name name as the event.
  3848. // Can't use an .isFunction() check here because IE6/7 fails that test.
  3849. // Don't do default actions on window, that's where global variables be (#6170)
  3850. if ( ontype && elem[ type ] && !jQuery.isWindow( elem ) ) {
  3851. // Don't re-trigger an onFOO event when we call its FOO() method
  3852. tmp = elem[ ontype ];
  3853. if ( tmp ) {
  3854. elem[ ontype ] = null;
  3855. }
  3856. // Prevent re-triggering of the same event, since we already bubbled it above
  3857. jQuery.event.triggered = type;
  3858. try {
  3859. elem[ type ]();
  3860. } catch ( e ) {
  3861. // IE<9 dies on focus/blur to hidden element (#1486,#12518)
  3862. // only reproducible on winXP IE8 native, not IE9 in IE8 mode
  3863. }
  3864. jQuery.event.triggered = undefined;
  3865. if ( tmp ) {
  3866. elem[ ontype ] = tmp;
  3867. }
  3868. }
  3869. }
  3870. }
  3871. return event.result;
  3872. },
  3873. dispatch: function( event ) {
  3874. // Make a writable jQuery.Event from the native event object
  3875. event = jQuery.event.fix( event );
  3876. var i, ret, handleObj, matched, j,
  3877. handlerQueue = [],
  3878. args = slice.call( arguments ),
  3879. handlers = ( jQuery._data( this, "events" ) || {} )[ event.type ] || [],
  3880. special = jQuery.event.special[ event.type ] || {};
  3881. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  3882. args[0] = event;
  3883. event.delegateTarget = this;
  3884. // Call the preDispatch hook for the mapped type, and let it bail if desired
  3885. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  3886. return;
  3887. }
  3888. // Determine handlers
  3889. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  3890. // Run delegates first; they may want to stop propagation beneath us
  3891. i = 0;
  3892. while ( (matched = handlerQueue[ i++ ]) && !event.isPropagationStopped() ) {
  3893. event.currentTarget = matched.elem;
  3894. j = 0;
  3895. while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
  3896. // Triggered event must either 1) have no namespace, or
  3897. // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace).
  3898. if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
  3899. event.handleObj = handleObj;
  3900. event.data = handleObj.data;
  3901. ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler )
  3902. .apply( matched.elem, args );
  3903. if ( ret !== undefined ) {
  3904. if ( (event.result = ret) === false ) {
  3905. event.preventDefault();
  3906. event.stopPropagation();
  3907. }
  3908. }
  3909. }
  3910. }
  3911. }
  3912. // Call the postDispatch hook for the mapped type
  3913. if ( special.postDispatch ) {
  3914. special.postDispatch.call( this, event );
  3915. }
  3916. return event.result;
  3917. },
  3918. handlers: function( event, handlers ) {
  3919. var sel, handleObj, matches, i,
  3920. handlerQueue = [],
  3921. delegateCount = handlers.delegateCount,
  3922. cur = event.target;
  3923. // Find delegate handlers
  3924. // Black-hole SVG <use> instance trees (#13180)
  3925. // Avoid non-left-click bubbling in Firefox (#3861)
  3926. if ( delegateCount && cur.nodeType && (!event.button || event.type !== "click") ) {
  3927. /* jshint eqeqeq: false */
  3928. for ( ; cur != this; cur = cur.parentNode || this ) {
  3929. /* jshint eqeqeq: true */
  3930. // Don't check non-elements (#13208)
  3931. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  3932. if ( cur.nodeType === 1 && (cur.disabled !== true || event.type !== "click") ) {
  3933. matches = [];
  3934. for ( i = 0; i < delegateCount; i++ ) {
  3935. handleObj = handlers[ i ];
  3936. // Don't conflict with Object.prototype properties (#13203)
  3937. sel = handleObj.selector + " ";
  3938. if ( matches[ sel ] === undefined ) {
  3939. matches[ sel ] = handleObj.needsContext ?
  3940. jQuery( sel, this ).index( cur ) >= 0 :
  3941. jQuery.find( sel, this, null, [ cur ] ).length;
  3942. }
  3943. if ( matches[ sel ] ) {
  3944. matches.push( handleObj );
  3945. }
  3946. }
  3947. if ( matches.length ) {
  3948. handlerQueue.push({ elem: cur, handlers: matches });
  3949. }
  3950. }
  3951. }
  3952. }
  3953. // Add the remaining (directly-bound) handlers
  3954. if ( delegateCount < handlers.length ) {
  3955. handlerQueue.push({ elem: this, handlers: handlers.slice( delegateCount ) });
  3956. }
  3957. return handlerQueue;
  3958. },
  3959. fix: function( event ) {
  3960. if ( event[ jQuery.expando ] ) {
  3961. return event;
  3962. }
  3963. // Create a writable copy of the event object and normalize some properties
  3964. var i, prop, copy,
  3965. type = event.type,
  3966. originalEvent = event,
  3967. fixHook = this.fixHooks[ type ];
  3968. if ( !fixHook ) {
  3969. this.fixHooks[ type ] = fixHook =
  3970. rmouseEvent.test( type ) ? this.mouseHooks :
  3971. rkeyEvent.test( type ) ? this.keyHooks :
  3972. {};
  3973. }
  3974. copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props;
  3975. event = new jQuery.Event( originalEvent );
  3976. i = copy.length;
  3977. while ( i-- ) {
  3978. prop = copy[ i ];
  3979. event[ prop ] = originalEvent[ prop ];
  3980. }
  3981. // Support: IE<9
  3982. // Fix target property (#1925)
  3983. if ( !event.target ) {
  3984. event.target = originalEvent.srcElement || document;
  3985. }
  3986. // Support: Chrome 23+, Safari?
  3987. // Target should not be a text node (#504, #13143)
  3988. if ( event.target.nodeType === 3 ) {
  3989. event.target = event.target.parentNode;
  3990. }
  3991. // Support: IE<9
  3992. // For mouse/key events, metaKey==false if it's undefined (#3368, #11328)
  3993. event.metaKey = !!event.metaKey;
  3994. return fixHook.filter ? fixHook.filter( event, originalEvent ) : event;
  3995. },
  3996. // Includes some event props shared by KeyEvent and MouseEvent
  3997. props: "altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),
  3998. fixHooks: {},
  3999. keyHooks: {
  4000. props: "char charCode key keyCode".split(" "),
  4001. filter: function( event, original ) {
  4002. // Add which for key events
  4003. if ( event.which == null ) {
  4004. event.which = original.charCode != null ? original.charCode : original.keyCode;
  4005. }
  4006. return event;
  4007. }
  4008. },
  4009. mouseHooks: {
  4010. props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),
  4011. filter: function( event, original ) {
  4012. var body, eventDoc, doc,
  4013. button = original.button,
  4014. fromElement = original.fromElement;
  4015. // Calculate pageX/Y if missing and clientX/Y available
  4016. if ( event.pageX == null && original.clientX != null ) {
  4017. eventDoc = event.target.ownerDocument || document;
  4018. doc = eventDoc.documentElement;
  4019. body = eventDoc.body;
  4020. event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 );
  4021. event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 );
  4022. }
  4023. // Add relatedTarget, if necessary
  4024. if ( !event.relatedTarget && fromElement ) {
  4025. event.relatedTarget = fromElement === event.target ? original.toElement : fromElement;
  4026. }
  4027. // Add which for click: 1 === left; 2 === middle; 3 === right
  4028. // Note: button is not normalized, so don't use it
  4029. if ( !event.which && button !== undefined ) {
  4030. event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) );
  4031. }
  4032. return event;
  4033. }
  4034. },
  4035. special: {
  4036. load: {
  4037. // Prevent triggered image.load events from bubbling to window.load
  4038. noBubble: true
  4039. },
  4040. focus: {
  4041. // Fire native event if possible so blur/focus sequence is correct
  4042. trigger: function() {
  4043. if ( this !== safeActiveElement() && this.focus ) {
  4044. try {
  4045. this.focus();
  4046. return false;
  4047. } catch ( e ) {
  4048. // Support: IE<9
  4049. // If we error on focus to hidden element (#1486, #12518),
  4050. // let .trigger() run the handlers
  4051. }
  4052. }
  4053. },
  4054. delegateType: "focusin"
  4055. },
  4056. blur: {
  4057. trigger: function() {
  4058. if ( this === safeActiveElement() && this.blur ) {
  4059. this.blur();
  4060. return false;
  4061. }
  4062. },
  4063. delegateType: "focusout"
  4064. },
  4065. click: {
  4066. // For checkbox, fire native event so checked state will be right
  4067. trigger: function() {
  4068. if ( jQuery.nodeName( this, "input" ) && this.type === "checkbox" && this.click ) {
  4069. this.click();
  4070. return false;
  4071. }
  4072. },
  4073. // For cross-browser consistency, don't fire native .click() on links
  4074. _default: function( event ) {
  4075. return jQuery.nodeName( event.target, "a" );
  4076. }
  4077. },
  4078. beforeunload: {
  4079. postDispatch: function( event ) {
  4080. // Support: Firefox 20+
  4081. // Firefox doesn't alert if the returnValue field is not set.
  4082. if ( event.result !== undefined && event.originalEvent ) {
  4083. event.originalEvent.returnValue = event.result;
  4084. }
  4085. }
  4086. }
  4087. },
  4088. simulate: function( type, elem, event, bubble ) {
  4089. // Piggyback on a donor event to simulate a different one.
  4090. // Fake originalEvent to avoid donor's stopPropagation, but if the
  4091. // simulated event prevents default then we do the same on the donor.
  4092. var e = jQuery.extend(
  4093. new jQuery.Event(),
  4094. event,
  4095. {
  4096. type: type,
  4097. isSimulated: true,
  4098. originalEvent: {}
  4099. }
  4100. );
  4101. if ( bubble ) {
  4102. jQuery.event.trigger( e, null, elem );
  4103. } else {
  4104. jQuery.event.dispatch.call( elem, e );
  4105. }
  4106. if ( e.isDefaultPrevented() ) {
  4107. event.preventDefault();
  4108. }
  4109. }
  4110. };
  4111. jQuery.removeEvent = document.removeEventListener ?
  4112. function( elem, type, handle ) {
  4113. if ( elem.removeEventListener ) {
  4114. elem.removeEventListener( type, handle, false );
  4115. }
  4116. } :
  4117. function( elem, type, handle ) {
  4118. var name = "on" + type;
  4119. if ( elem.detachEvent ) {
  4120. // #8545, #7054, preventing memory leaks for custom events in IE6-8
  4121. // detachEvent needed property on element, by name of that event, to properly expose it to GC
  4122. if ( typeof elem[ name ] === strundefined ) {
  4123. elem[ name ] = null;
  4124. }
  4125. elem.detachEvent( name, handle );
  4126. }
  4127. };
  4128. jQuery.Event = function( src, props ) {
  4129. // Allow instantiation without the 'new' keyword
  4130. if ( !(this instanceof jQuery.Event) ) {
  4131. return new jQuery.Event( src, props );
  4132. }
  4133. // Event object
  4134. if ( src && src.type ) {
  4135. this.originalEvent = src;
  4136. this.type = src.type;
  4137. // Events bubbling up the document may have been marked as prevented
  4138. // by a handler lower down the tree; reflect the correct value.
  4139. this.isDefaultPrevented = src.defaultPrevented ||
  4140. src.defaultPrevented === undefined &&
  4141. // Support: IE < 9, Android < 4.0
  4142. src.returnValue === false ?
  4143. returnTrue :
  4144. returnFalse;
  4145. // Event type
  4146. } else {
  4147. this.type = src;
  4148. }
  4149. // Put explicitly provided properties onto the event object
  4150. if ( props ) {
  4151. jQuery.extend( this, props );
  4152. }
  4153. // Create a timestamp if incoming event doesn't have one
  4154. this.timeStamp = src && src.timeStamp || jQuery.now();
  4155. // Mark it as fixed
  4156. this[ jQuery.expando ] = true;
  4157. };
  4158. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4159. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4160. jQuery.Event.prototype = {
  4161. isDefaultPrevented: returnFalse,
  4162. isPropagationStopped: returnFalse,
  4163. isImmediatePropagationStopped: returnFalse,
  4164. preventDefault: function() {
  4165. var e = this.originalEvent;
  4166. this.isDefaultPrevented = returnTrue;
  4167. if ( !e ) {
  4168. return;
  4169. }
  4170. // If preventDefault exists, run it on the original event
  4171. if ( e.preventDefault ) {
  4172. e.preventDefault();
  4173. // Support: IE
  4174. // Otherwise set the returnValue property of the original event to false
  4175. } else {
  4176. e.returnValue = false;
  4177. }
  4178. },
  4179. stopPropagation: function() {
  4180. var e = this.originalEvent;
  4181. this.isPropagationStopped = returnTrue;
  4182. if ( !e ) {
  4183. return;
  4184. }
  4185. // If stopPropagation exists, run it on the original event
  4186. if ( e.stopPropagation ) {
  4187. e.stopPropagation();
  4188. }
  4189. // Support: IE
  4190. // Set the cancelBubble property of the original event to true
  4191. e.cancelBubble = true;
  4192. },
  4193. stopImmediatePropagation: function() {
  4194. var e = this.originalEvent;
  4195. this.isImmediatePropagationStopped = returnTrue;
  4196. if ( e && e.stopImmediatePropagation ) {
  4197. e.stopImmediatePropagation();
  4198. }
  4199. this.stopPropagation();
  4200. }
  4201. };
  4202. // Create mouseenter/leave events using mouseover/out and event-time checks
  4203. jQuery.each({
  4204. mouseenter: "mouseover",
  4205. mouseleave: "mouseout",
  4206. pointerenter: "pointerover",
  4207. pointerleave: "pointerout"
  4208. }, function( orig, fix ) {
  4209. jQuery.event.special[ orig ] = {
  4210. delegateType: fix,
  4211. bindType: fix,
  4212. handle: function( event ) {
  4213. var ret,
  4214. target = this,
  4215. related = event.relatedTarget,
  4216. handleObj = event.handleObj;
  4217. // For mousenter/leave call the handler if related is outside the target.
  4218. // NB: No relatedTarget if the mouse left/entered the browser window
  4219. if ( !related || (related !== target && !jQuery.contains( target, related )) ) {
  4220. event.type = handleObj.origType;
  4221. ret = handleObj.handler.apply( this, arguments );
  4222. event.type = fix;
  4223. }
  4224. return ret;
  4225. }
  4226. };
  4227. });
  4228. // IE submit delegation
  4229. if ( !support.submitBubbles ) {
  4230. jQuery.event.special.submit = {
  4231. setup: function() {
  4232. // Only need this for delegated form submit events
  4233. if ( jQuery.nodeName( this, "form" ) ) {
  4234. return false;
  4235. }
  4236. // Lazy-add a submit handler when a descendant form may potentially be submitted
  4237. jQuery.event.add( this, "click._submit keypress._submit", function( e ) {
  4238. // Node name check avoids a VML-related crash in IE (#9807)
  4239. var elem = e.target,
  4240. form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined;
  4241. if ( form && !jQuery._data( form, "submitBubbles" ) ) {
  4242. jQuery.event.add( form, "submit._submit", function( event ) {
  4243. event._submit_bubble = true;
  4244. });
  4245. jQuery._data( form, "submitBubbles", true );
  4246. }
  4247. });
  4248. // return undefined since we don't need an event listener
  4249. },
  4250. postDispatch: function( event ) {
  4251. // If form was submitted by the user, bubble the event up the tree
  4252. if ( event._submit_bubble ) {
  4253. delete event._submit_bubble;
  4254. if ( this.parentNode && !event.isTrigger ) {
  4255. jQuery.event.simulate( "submit", this.parentNode, event, true );
  4256. }
  4257. }
  4258. },
  4259. teardown: function() {
  4260. // Only need this for delegated form submit events
  4261. if ( jQuery.nodeName( this, "form" ) ) {
  4262. return false;
  4263. }
  4264. // Remove delegated handlers; cleanData eventually reaps submit handlers attached above
  4265. jQuery.event.remove( this, "._submit" );
  4266. }
  4267. };
  4268. }
  4269. // IE change delegation and checkbox/radio fix
  4270. if ( !support.changeBubbles ) {
  4271. jQuery.event.special.change = {
  4272. setup: function() {
  4273. if ( rformElems.test( this.nodeName ) ) {
  4274. // IE doesn't fire change on a check/radio until blur; trigger it on click
  4275. // after a propertychange. Eat the blur-change in special.change.handle.
  4276. // This still fires onchange a second time for check/radio after blur.
  4277. if ( this.type === "checkbox" || this.type === "radio" ) {
  4278. jQuery.event.add( this, "propertychange._change", function( event ) {
  4279. if ( event.originalEvent.propertyName === "checked" ) {
  4280. this._just_changed = true;
  4281. }
  4282. });
  4283. jQuery.event.add( this, "click._change", function( event ) {
  4284. if ( this._just_changed && !event.isTrigger ) {
  4285. this._just_changed = false;
  4286. }
  4287. // Allow triggered, simulated change events (#11500)
  4288. jQuery.event.simulate( "change", this, event, true );
  4289. });
  4290. }
  4291. return false;
  4292. }
  4293. // Delegated event; lazy-add a change handler on descendant inputs
  4294. jQuery.event.add( this, "beforeactivate._change", function( e ) {
  4295. var elem = e.target;
  4296. if ( rformElems.test( elem.nodeName ) && !jQuery._data( elem, "changeBubbles" ) ) {
  4297. jQuery.event.add( elem, "change._change", function( event ) {
  4298. if ( this.parentNode && !event.isSimulated && !event.isTrigger ) {
  4299. jQuery.event.simulate( "change", this.parentNode, event, true );
  4300. }
  4301. });
  4302. jQuery._data( elem, "changeBubbles", true );
  4303. }
  4304. });
  4305. },
  4306. handle: function( event ) {
  4307. var elem = event.target;
  4308. // Swallow native change events from checkbox/radio, we already triggered them above
  4309. if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) {
  4310. return event.handleObj.handler.apply( this, arguments );
  4311. }
  4312. },
  4313. teardown: function() {
  4314. jQuery.event.remove( this, "._change" );
  4315. return !rformElems.test( this.nodeName );
  4316. }
  4317. };
  4318. }
  4319. // Create "bubbling" focus and blur events
  4320. if ( !support.focusinBubbles ) {
  4321. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  4322. // Attach a single capturing handler on the document while someone wants focusin/focusout
  4323. var handler = function( event ) {
  4324. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true );
  4325. };
  4326. jQuery.event.special[ fix ] = {
  4327. setup: function() {
  4328. var doc = this.ownerDocument || this,
  4329. attaches = jQuery._data( doc, fix );
  4330. if ( !attaches ) {
  4331. doc.addEventListener( orig, handler, true );
  4332. }
  4333. jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
  4334. },
  4335. teardown: function() {
  4336. var doc = this.ownerDocument || this,
  4337. attaches = jQuery._data( doc, fix ) - 1;
  4338. if ( !attaches ) {
  4339. doc.removeEventListener( orig, handler, true );
  4340. jQuery._removeData( doc, fix );
  4341. } else {
  4342. jQuery._data( doc, fix, attaches );
  4343. }
  4344. }
  4345. };
  4346. });
  4347. }
  4348. jQuery.fn.extend({
  4349. on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
  4350. var type, origFn;
  4351. // Types can be a map of types/handlers
  4352. if ( typeof types === "object" ) {
  4353. // ( types-Object, selector, data )
  4354. if ( typeof selector !== "string" ) {
  4355. // ( types-Object, data )
  4356. data = data || selector;
  4357. selector = undefined;
  4358. }
  4359. for ( type in types ) {
  4360. this.on( type, selector, data, types[ type ], one );
  4361. }
  4362. return this;
  4363. }
  4364. if ( data == null && fn == null ) {
  4365. // ( types, fn )
  4366. fn = selector;
  4367. data = selector = undefined;
  4368. } else if ( fn == null ) {
  4369. if ( typeof selector === "string" ) {
  4370. // ( types, selector, fn )
  4371. fn = data;
  4372. data = undefined;
  4373. } else {
  4374. // ( types, data, fn )
  4375. fn = data;
  4376. data = selector;
  4377. selector = undefined;
  4378. }
  4379. }
  4380. if ( fn === false ) {
  4381. fn = returnFalse;
  4382. } else if ( !fn ) {
  4383. return this;
  4384. }
  4385. if ( one === 1 ) {
  4386. origFn = fn;
  4387. fn = function( event ) {
  4388. // Can use an empty set, since event contains the info
  4389. jQuery().off( event );
  4390. return origFn.apply( this, arguments );
  4391. };
  4392. // Use same guid so caller can remove using origFn
  4393. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4394. }
  4395. return this.each( function() {
  4396. jQuery.event.add( this, types, fn, data, selector );
  4397. });
  4398. },
  4399. one: function( types, selector, data, fn ) {
  4400. return this.on( types, selector, data, fn, 1 );
  4401. },
  4402. off: function( types, selector, fn ) {
  4403. var handleObj, type;
  4404. if ( types && types.preventDefault && types.handleObj ) {
  4405. // ( event ) dispatched jQuery.Event
  4406. handleObj = types.handleObj;
  4407. jQuery( types.delegateTarget ).off(
  4408. handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType,
  4409. handleObj.selector,
  4410. handleObj.handler
  4411. );
  4412. return this;
  4413. }
  4414. if ( typeof types === "object" ) {
  4415. // ( types-object [, selector] )
  4416. for ( type in types ) {
  4417. this.off( type, selector, types[ type ] );
  4418. }
  4419. return this;
  4420. }
  4421. if ( selector === false || typeof selector === "function" ) {
  4422. // ( types [, fn] )
  4423. fn = selector;
  4424. selector = undefined;
  4425. }
  4426. if ( fn === false ) {
  4427. fn = returnFalse;
  4428. }
  4429. return this.each(function() {
  4430. jQuery.event.remove( this, types, fn, selector );
  4431. });
  4432. },
  4433. trigger: function( type, data ) {
  4434. return this.each(function() {
  4435. jQuery.event.trigger( type, data, this );
  4436. });
  4437. },
  4438. triggerHandler: function( type, data ) {
  4439. var elem = this[0];
  4440. if ( elem ) {
  4441. return jQuery.event.trigger( type, data, elem, true );
  4442. }
  4443. }
  4444. });
  4445. function createSafeFragment( document ) {
  4446. var list = nodeNames.split( "|" ),
  4447. safeFrag = document.createDocumentFragment();
  4448. if ( safeFrag.createElement ) {
  4449. while ( list.length ) {
  4450. safeFrag.createElement(
  4451. list.pop()
  4452. );
  4453. }
  4454. }
  4455. return safeFrag;
  4456. }
  4457. var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" +
  4458. "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",
  4459. rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
  4460. rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"),
  4461. rleadingWhitespace = /^\s+/,
  4462. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
  4463. rtagName = /<([\w:]+)/,
  4464. rtbody = /<tbody/i,
  4465. rhtml = /<|&#?\w+;/,
  4466. rnoInnerhtml = /<(?:script|style|link)/i,
  4467. // checked="checked" or checked
  4468. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4469. rscriptType = /^$|\/(?:java|ecma)script/i,
  4470. rscriptTypeMasked = /^true\/(.*)/,
  4471. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
  4472. // We have to close these tags to support XHTML (#13200)
  4473. wrapMap = {
  4474. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4475. legend: [ 1, "<fieldset>", "</fieldset>" ],
  4476. area: [ 1, "<map>", "</map>" ],
  4477. param: [ 1, "<object>", "</object>" ],
  4478. thead: [ 1, "<table>", "</table>" ],
  4479. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4480. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  4481. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4482. // IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
  4483. // unless wrapped in a div with non-breaking characters in front of it.
  4484. _default: support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "</div>" ]
  4485. },
  4486. safeFragment = createSafeFragment( document ),
  4487. fragmentDiv = safeFragment.appendChild( document.createElement("div") );
  4488. wrapMap.optgroup = wrapMap.option;
  4489. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4490. wrapMap.th = wrapMap.td;
  4491. function getAll( context, tag ) {
  4492. var elems, elem,
  4493. i = 0,
  4494. found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
  4495. typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
  4496. undefined;
  4497. if ( !found ) {
  4498. for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
  4499. if ( !tag || jQuery.nodeName( elem, tag ) ) {
  4500. found.push( elem );
  4501. } else {
  4502. jQuery.merge( found, getAll( elem, tag ) );
  4503. }
  4504. }
  4505. }
  4506. return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
  4507. jQuery.merge( [ context ], found ) :
  4508. found;
  4509. }
  4510. // Used in buildFragment, fixes the defaultChecked property
  4511. function fixDefaultChecked( elem ) {
  4512. if ( rcheckableType.test( elem.type ) ) {
  4513. elem.defaultChecked = elem.checked;
  4514. }
  4515. }
  4516. // Support: IE<8
  4517. // Manipulating tables requires a tbody
  4518. function manipulationTarget( elem, content ) {
  4519. return jQuery.nodeName( elem, "table" ) &&
  4520. jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
  4521. elem.getElementsByTagName("tbody")[0] ||
  4522. elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
  4523. elem;
  4524. }
  4525. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4526. function disableScript( elem ) {
  4527. elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
  4528. return elem;
  4529. }
  4530. function restoreScript( elem ) {
  4531. var match = rscriptTypeMasked.exec( elem.type );
  4532. if ( match ) {
  4533. elem.type = match[1];
  4534. } else {
  4535. elem.removeAttribute("type");
  4536. }
  4537. return elem;
  4538. }
  4539. // Mark scripts as having already been evaluated
  4540. function setGlobalEval( elems, refElements ) {
  4541. var elem,
  4542. i = 0;
  4543. for ( ; (elem = elems[i]) != null; i++ ) {
  4544. jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
  4545. }
  4546. }
  4547. function cloneCopyEvent( src, dest ) {
  4548. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4549. return;
  4550. }
  4551. var type, i, l,
  4552. oldData = jQuery._data( src ),
  4553. curData = jQuery._data( dest, oldData ),
  4554. events = oldData.events;
  4555. if ( events ) {
  4556. delete curData.handle;
  4557. curData.events = {};
  4558. for ( type in events ) {
  4559. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4560. jQuery.event.add( dest, type, events[ type ][ i ] );
  4561. }
  4562. }
  4563. }
  4564. // make the cloned public data object a copy from the original
  4565. if ( curData.data ) {
  4566. curData.data = jQuery.extend( {}, curData.data );
  4567. }
  4568. }
  4569. function fixCloneNodeIssues( src, dest ) {
  4570. var nodeName, e, data;
  4571. // We do not need to do anything for non-Elements
  4572. if ( dest.nodeType !== 1 ) {
  4573. return;
  4574. }
  4575. nodeName = dest.nodeName.toLowerCase();
  4576. // IE6-8 copies events bound via attachEvent when using cloneNode.
  4577. if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
  4578. data = jQuery._data( dest );
  4579. for ( e in data.events ) {
  4580. jQuery.removeEvent( dest, e, data.handle );
  4581. }
  4582. // Event data gets referenced instead of copied if the expando gets copied too
  4583. dest.removeAttribute( jQuery.expando );
  4584. }
  4585. // IE blanks contents when cloning scripts, and tries to evaluate newly-set text
  4586. if ( nodeName === "script" && dest.text !== src.text ) {
  4587. disableScript( dest ).text = src.text;
  4588. restoreScript( dest );
  4589. // IE6-10 improperly clones children of object elements using classid.
  4590. // IE10 throws NoModificationAllowedError if parent is null, #12132.
  4591. } else if ( nodeName === "object" ) {
  4592. if ( dest.parentNode ) {
  4593. dest.outerHTML = src.outerHTML;
  4594. }
  4595. // This path appears unavoidable for IE9. When cloning an object
  4596. // element in IE9, the outerHTML strategy above is not sufficient.
  4597. // If the src has innerHTML and the destination does not,
  4598. // copy the src.innerHTML into the dest.innerHTML. #10324
  4599. if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
  4600. dest.innerHTML = src.innerHTML;
  4601. }
  4602. } else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4603. // IE6-8 fails to persist the checked state of a cloned checkbox
  4604. // or radio button. Worse, IE6-7 fail to give the cloned element
  4605. // a checked appearance if the defaultChecked value isn't also set
  4606. dest.defaultChecked = dest.checked = src.checked;
  4607. // IE6-7 get confused and end up setting the value of a cloned
  4608. // checkbox/radio button to an empty string instead of "on"
  4609. if ( dest.value !== src.value ) {
  4610. dest.value = src.value;
  4611. }
  4612. // IE6-8 fails to return the selected option to the default selected
  4613. // state when cloning options
  4614. } else if ( nodeName === "option" ) {
  4615. dest.defaultSelected = dest.selected = src.defaultSelected;
  4616. // IE6-8 fails to set the defaultValue to the correct value when
  4617. // cloning other types of input fields
  4618. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4619. dest.defaultValue = src.defaultValue;
  4620. }
  4621. }
  4622. jQuery.extend({
  4623. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4624. var destElements, node, clone, i, srcElements,
  4625. inPage = jQuery.contains( elem.ownerDocument, elem );
  4626. if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
  4627. clone = elem.cloneNode( true );
  4628. // IE<=8 does not properly clone detached, unknown element nodes
  4629. } else {
  4630. fragmentDiv.innerHTML = elem.outerHTML;
  4631. fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
  4632. }
  4633. if ( (!support.noCloneEvent || !support.noCloneChecked) &&
  4634. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  4635. // We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
  4636. destElements = getAll( clone );
  4637. srcElements = getAll( elem );
  4638. // Fix all IE cloning issues
  4639. for ( i = 0; (node = srcElements[i]) != null; ++i ) {
  4640. // Ensure that the destination node is not null; Fixes #9587
  4641. if ( destElements[i] ) {
  4642. fixCloneNodeIssues( node, destElements[i] );
  4643. }
  4644. }
  4645. }
  4646. // Copy the events from the original to the clone
  4647. if ( dataAndEvents ) {
  4648. if ( deepDataAndEvents ) {
  4649. srcElements = srcElements || getAll( elem );
  4650. destElements = destElements || getAll( clone );
  4651. for ( i = 0; (node = srcElements[i]) != null; i++ ) {
  4652. cloneCopyEvent( node, destElements[i] );
  4653. }
  4654. } else {
  4655. cloneCopyEvent( elem, clone );
  4656. }
  4657. }
  4658. // Preserve script evaluation history
  4659. destElements = getAll( clone, "script" );
  4660. if ( destElements.length > 0 ) {
  4661. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4662. }
  4663. destElements = srcElements = node = null;
  4664. // Return the cloned set
  4665. return clone;
  4666. },
  4667. buildFragment: function( elems, context, scripts, selection ) {
  4668. var j, elem, contains,
  4669. tmp, tag, tbody, wrap,
  4670. l = elems.length,
  4671. // Ensure a safe fragment
  4672. safe = createSafeFragment( context ),
  4673. nodes = [],
  4674. i = 0;
  4675. for ( ; i < l; i++ ) {
  4676. elem = elems[ i ];
  4677. if ( elem || elem === 0 ) {
  4678. // Add nodes directly
  4679. if ( jQuery.type( elem ) === "object" ) {
  4680. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  4681. // Convert non-html into a text node
  4682. } else if ( !rhtml.test( elem ) ) {
  4683. nodes.push( context.createTextNode( elem ) );
  4684. // Convert html into DOM nodes
  4685. } else {
  4686. tmp = tmp || safe.appendChild( context.createElement("div") );
  4687. // Deserialize a standard representation
  4688. tag = (rtagName.exec( elem ) || [ "", "" ])[ 1 ].toLowerCase();
  4689. wrap = wrapMap[ tag ] || wrapMap._default;
  4690. tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
  4691. // Descend through wrappers to the right content
  4692. j = wrap[0];
  4693. while ( j-- ) {
  4694. tmp = tmp.lastChild;
  4695. }
  4696. // Manually add leading whitespace removed by IE
  4697. if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  4698. nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
  4699. }
  4700. // Remove IE's autoinserted <tbody> from table fragments
  4701. if ( !support.tbody ) {
  4702. // String was a <table>, *may* have spurious <tbody>
  4703. elem = tag === "table" && !rtbody.test( elem ) ?
  4704. tmp.firstChild :
  4705. // String was a bare <thead> or <tfoot>
  4706. wrap[1] === "<table>" && !rtbody.test( elem ) ?
  4707. tmp :
  4708. 0;
  4709. j = elem && elem.childNodes.length;
  4710. while ( j-- ) {
  4711. if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
  4712. elem.removeChild( tbody );
  4713. }
  4714. }
  4715. }
  4716. jQuery.merge( nodes, tmp.childNodes );
  4717. // Fix #12392 for WebKit and IE > 9
  4718. tmp.textContent = "";
  4719. // Fix #12392 for oldIE
  4720. while ( tmp.firstChild ) {
  4721. tmp.removeChild( tmp.firstChild );
  4722. }
  4723. // Remember the top-level container for proper cleanup
  4724. tmp = safe.lastChild;
  4725. }
  4726. }
  4727. }
  4728. // Fix #11356: Clear elements from fragment
  4729. if ( tmp ) {
  4730. safe.removeChild( tmp );
  4731. }
  4732. // Reset defaultChecked for any radios and checkboxes
  4733. // about to be appended to the DOM in IE 6/7 (#8060)
  4734. if ( !support.appendChecked ) {
  4735. jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
  4736. }
  4737. i = 0;
  4738. while ( (elem = nodes[ i++ ]) ) {
  4739. // #4087 - If origin and destination elements are the same, and this is
  4740. // that element, do not do anything
  4741. if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
  4742. continue;
  4743. }
  4744. contains = jQuery.contains( elem.ownerDocument, elem );
  4745. // Append to fragment
  4746. tmp = getAll( safe.appendChild( elem ), "script" );
  4747. // Preserve script evaluation history
  4748. if ( contains ) {
  4749. setGlobalEval( tmp );
  4750. }
  4751. // Capture executables
  4752. if ( scripts ) {
  4753. j = 0;
  4754. while ( (elem = tmp[ j++ ]) ) {
  4755. if ( rscriptType.test( elem.type || "" ) ) {
  4756. scripts.push( elem );
  4757. }
  4758. }
  4759. }
  4760. }
  4761. tmp = null;
  4762. return safe;
  4763. },
  4764. cleanData: function( elems, /* internal */ acceptData ) {
  4765. var elem, type, id, data,
  4766. i = 0,
  4767. internalKey = jQuery.expando,
  4768. cache = jQuery.cache,
  4769. deleteExpando = support.deleteExpando,
  4770. special = jQuery.event.special;
  4771. for ( ; (elem = elems[i]) != null; i++ ) {
  4772. if ( acceptData || jQuery.acceptData( elem ) ) {
  4773. id = elem[ internalKey ];
  4774. data = id && cache[ id ];
  4775. if ( data ) {
  4776. if ( data.events ) {
  4777. for ( type in data.events ) {
  4778. if ( special[ type ] ) {
  4779. jQuery.event.remove( elem, type );
  4780. // This is a shortcut to avoid jQuery.event.remove's overhead
  4781. } else {
  4782. jQuery.removeEvent( elem, type, data.handle );
  4783. }
  4784. }
  4785. }
  4786. // Remove cache only if it was not already removed by jQuery.event.remove
  4787. if ( cache[ id ] ) {
  4788. delete cache[ id ];
  4789. // IE does not allow us to delete expando properties from nodes,
  4790. // nor does it have a removeAttribute function on Document nodes;
  4791. // we must handle all of these cases
  4792. if ( deleteExpando ) {
  4793. delete elem[ internalKey ];
  4794. } else if ( typeof elem.removeAttribute !== strundefined ) {
  4795. elem.removeAttribute( internalKey );
  4796. } else {
  4797. elem[ internalKey ] = null;
  4798. }
  4799. deletedIds.push( id );
  4800. }
  4801. }
  4802. }
  4803. }
  4804. }
  4805. });
  4806. jQuery.fn.extend({
  4807. text: function( value ) {
  4808. return access( this, function( value ) {
  4809. return value === undefined ?
  4810. jQuery.text( this ) :
  4811. this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
  4812. }, null, value, arguments.length );
  4813. },
  4814. append: function() {
  4815. return this.domManip( arguments, function( elem ) {
  4816. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4817. var target = manipulationTarget( this, elem );
  4818. target.appendChild( elem );
  4819. }
  4820. });
  4821. },
  4822. prepend: function() {
  4823. return this.domManip( arguments, function( elem ) {
  4824. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4825. var target = manipulationTarget( this, elem );
  4826. target.insertBefore( elem, target.firstChild );
  4827. }
  4828. });
  4829. },
  4830. before: function() {
  4831. return this.domManip( arguments, function( elem ) {
  4832. if ( this.parentNode ) {
  4833. this.parentNode.insertBefore( elem, this );
  4834. }
  4835. });
  4836. },
  4837. after: function() {
  4838. return this.domManip( arguments, function( elem ) {
  4839. if ( this.parentNode ) {
  4840. this.parentNode.insertBefore( elem, this.nextSibling );
  4841. }
  4842. });
  4843. },
  4844. remove: function( selector, keepData /* Internal Use Only */ ) {
  4845. var elem,
  4846. elems = selector ? jQuery.filter( selector, this ) : this,
  4847. i = 0;
  4848. for ( ; (elem = elems[i]) != null; i++ ) {
  4849. if ( !keepData && elem.nodeType === 1 ) {
  4850. jQuery.cleanData( getAll( elem ) );
  4851. }
  4852. if ( elem.parentNode ) {
  4853. if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
  4854. setGlobalEval( getAll( elem, "script" ) );
  4855. }
  4856. elem.parentNode.removeChild( elem );
  4857. }
  4858. }
  4859. return this;
  4860. },
  4861. empty: function() {
  4862. var elem,
  4863. i = 0;
  4864. for ( ; (elem = this[i]) != null; i++ ) {
  4865. // Remove element nodes and prevent memory leaks
  4866. if ( elem.nodeType === 1 ) {
  4867. jQuery.cleanData( getAll( elem, false ) );
  4868. }
  4869. // Remove any remaining nodes
  4870. while ( elem.firstChild ) {
  4871. elem.removeChild( elem.firstChild );
  4872. }
  4873. // If this is a select, ensure that it displays empty (#12336)
  4874. // Support: IE<9
  4875. if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
  4876. elem.options.length = 0;
  4877. }
  4878. }
  4879. return this;
  4880. },
  4881. clone: function( dataAndEvents, deepDataAndEvents ) {
  4882. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4883. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4884. return this.map(function() {
  4885. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4886. });
  4887. },
  4888. html: function( value ) {
  4889. return access( this, function( value ) {
  4890. var elem = this[ 0 ] || {},
  4891. i = 0,
  4892. l = this.length;
  4893. if ( value === undefined ) {
  4894. return elem.nodeType === 1 ?
  4895. elem.innerHTML.replace( rinlinejQuery, "" ) :
  4896. undefined;
  4897. }
  4898. // See if we can take a shortcut and just use innerHTML
  4899. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  4900. ( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
  4901. ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
  4902. !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
  4903. value = value.replace( rxhtmlTag, "<$1></$2>" );
  4904. try {
  4905. for (; i < l; i++ ) {
  4906. // Remove element nodes and prevent memory leaks
  4907. elem = this[i] || {};
  4908. if ( elem.nodeType === 1 ) {
  4909. jQuery.cleanData( getAll( elem, false ) );
  4910. elem.innerHTML = value;
  4911. }
  4912. }
  4913. elem = 0;
  4914. // If using innerHTML throws an exception, use the fallback method
  4915. } catch(e) {}
  4916. }
  4917. if ( elem ) {
  4918. this.empty().append( value );
  4919. }
  4920. }, null, value, arguments.length );
  4921. },
  4922. replaceWith: function() {
  4923. var arg = arguments[ 0 ];
  4924. // Make the changes, replacing each context element with the new content
  4925. this.domManip( arguments, function( elem ) {
  4926. arg = this.parentNode;
  4927. jQuery.cleanData( getAll( this ) );
  4928. if ( arg ) {
  4929. arg.replaceChild( elem, this );
  4930. }
  4931. });
  4932. // Force removal if there was no new content (e.g., from empty arguments)
  4933. return arg && (arg.length || arg.nodeType) ? this : this.remove();
  4934. },
  4935. detach: function( selector ) {
  4936. return this.remove( selector, true );
  4937. },
  4938. domManip: function( args, callback ) {
  4939. // Flatten any nested arrays
  4940. args = concat.apply( [], args );
  4941. var first, node, hasScripts,
  4942. scripts, doc, fragment,
  4943. i = 0,
  4944. l = this.length,
  4945. set = this,
  4946. iNoClone = l - 1,
  4947. value = args[0],
  4948. isFunction = jQuery.isFunction( value );
  4949. // We can't cloneNode fragments that contain checked, in WebKit
  4950. if ( isFunction ||
  4951. ( l > 1 && typeof value === "string" &&
  4952. !support.checkClone && rchecked.test( value ) ) ) {
  4953. return this.each(function( index ) {
  4954. var self = set.eq( index );
  4955. if ( isFunction ) {
  4956. args[0] = value.call( this, index, self.html() );
  4957. }
  4958. self.domManip( args, callback );
  4959. });
  4960. }
  4961. if ( l ) {
  4962. fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this );
  4963. first = fragment.firstChild;
  4964. if ( fragment.childNodes.length === 1 ) {
  4965. fragment = first;
  4966. }
  4967. if ( first ) {
  4968. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4969. hasScripts = scripts.length;
  4970. // Use the original fragment for the last item instead of the first because it can end up
  4971. // being emptied incorrectly in certain situations (#8070).
  4972. for ( ; i < l; i++ ) {
  4973. node = fragment;
  4974. if ( i !== iNoClone ) {
  4975. node = jQuery.clone( node, true, true );
  4976. // Keep references to cloned scripts for later restoration
  4977. if ( hasScripts ) {
  4978. jQuery.merge( scripts, getAll( node, "script" ) );
  4979. }
  4980. }
  4981. callback.call( this[i], node, i );
  4982. }
  4983. if ( hasScripts ) {
  4984. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4985. // Reenable scripts
  4986. jQuery.map( scripts, restoreScript );
  4987. // Evaluate executable scripts on first document insertion
  4988. for ( i = 0; i < hasScripts; i++ ) {
  4989. node = scripts[ i ];
  4990. if ( rscriptType.test( node.type || "" ) &&
  4991. !jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
  4992. if ( node.src ) {
  4993. // Optional AJAX dependency, but won't run scripts if not present
  4994. if ( jQuery._evalUrl ) {
  4995. jQuery._evalUrl( node.src );
  4996. }
  4997. } else {
  4998. jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
  4999. }
  5000. }
  5001. }
  5002. }
  5003. // Fix #11809: Avoid leaking memory
  5004. fragment = first = null;
  5005. }
  5006. }
  5007. return this;
  5008. }
  5009. });
  5010. jQuery.each({
  5011. appendTo: "append",
  5012. prependTo: "prepend",
  5013. insertBefore: "before",
  5014. insertAfter: "after",
  5015. replaceAll: "replaceWith"
  5016. }, function( name, original ) {
  5017. jQuery.fn[ name ] = function( selector ) {
  5018. var elems,
  5019. i = 0,
  5020. ret = [],
  5021. insert = jQuery( selector ),
  5022. last = insert.length - 1;
  5023. for ( ; i <= last; i++ ) {
  5024. elems = i === last ? this : this.clone(true);
  5025. jQuery( insert[i] )[ original ]( elems );
  5026. // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
  5027. push.apply( ret, elems.get() );
  5028. }
  5029. return this.pushStack( ret );
  5030. };
  5031. });
  5032. var iframe,
  5033. elemdisplay = {};
  5034. /**
  5035. * Retrieve the actual display of a element
  5036. * @param {String} name nodeName of the element
  5037. * @param {Object} doc Document object
  5038. */
  5039. // Called only from within defaultDisplay
  5040. function actualDisplay( name, doc ) {
  5041. var style,
  5042. elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
  5043. // getDefaultComputedStyle might be reliably used only on attached element
  5044. display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
  5045. // Use of this method is a temporary fix (more like optmization) until something better comes along,
  5046. // since it was removed from specification and supported only in FF
  5047. style.display : jQuery.css( elem[ 0 ], "display" );
  5048. // We don't have any data stored on the element,
  5049. // so use "detach" method as fast way to get rid of the element
  5050. elem.detach();
  5051. return display;
  5052. }
  5053. /**
  5054. * Try to determine the default display value of an element
  5055. * @param {String} nodeName
  5056. */
  5057. function defaultDisplay( nodeName ) {
  5058. var doc = document,
  5059. display = elemdisplay[ nodeName ];
  5060. if ( !display ) {
  5061. display = actualDisplay( nodeName, doc );
  5062. // If the simple way fails, read from inside an iframe
  5063. if ( display === "none" || !display ) {
  5064. // Use the already-created iframe if possible
  5065. iframe = (iframe || jQuery( "<iframe frameborder='0' width='0' height='0'/>" )).appendTo( doc.documentElement );
  5066. // Always write a new HTML skeleton so Webkit and Firefox don't choke on reuse
  5067. doc = ( iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument ).document;
  5068. // Support: IE
  5069. doc.write();
  5070. doc.close();
  5071. display = actualDisplay( nodeName, doc );
  5072. iframe.detach();
  5073. }
  5074. // Store the correct default display
  5075. elemdisplay[ nodeName ] = display;
  5076. }
  5077. return display;
  5078. }
  5079. (function() {
  5080. var shrinkWrapBlocksVal;
  5081. support.shrinkWrapBlocks = function() {
  5082. if ( shrinkWrapBlocksVal != null ) {
  5083. return shrinkWrapBlocksVal;
  5084. }
  5085. // Will be changed later if needed.
  5086. shrinkWrapBlocksVal = false;
  5087. // Minified: var b,c,d
  5088. var div, body, container;
  5089. body = document.getElementsByTagName( "body" )[ 0 ];
  5090. if ( !body || !body.style ) {
  5091. // Test fired too early or in an unsupported environment, exit.
  5092. return;
  5093. }
  5094. // Setup
  5095. div = document.createElement( "div" );
  5096. container = document.createElement( "div" );
  5097. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  5098. body.appendChild( container ).appendChild( div );
  5099. // Support: IE6
  5100. // Check if elements with layout shrink-wrap their children
  5101. if ( typeof div.style.zoom !== strundefined ) {
  5102. // Reset CSS: box-sizing; display; margin; border
  5103. div.style.cssText =
  5104. // Support: Firefox<29, Android 2.3
  5105. // Vendor-prefix box-sizing
  5106. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5107. "box-sizing:content-box;display:block;margin:0;border:0;" +
  5108. "padding:1px;width:1px;zoom:1";
  5109. div.appendChild( document.createElement( "div" ) ).style.width = "5px";
  5110. shrinkWrapBlocksVal = div.offsetWidth !== 3;
  5111. }
  5112. body.removeChild( container );
  5113. return shrinkWrapBlocksVal;
  5114. };
  5115. })();
  5116. var rmargin = (/^margin/);
  5117. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  5118. var getStyles, curCSS,
  5119. rposition = /^(top|right|bottom|left)$/;
  5120. if ( window.getComputedStyle ) {
  5121. getStyles = function( elem ) {
  5122. // Support: IE<=11+, Firefox<=30+ (#15098, #14150)
  5123. // IE throws on elements created in popups
  5124. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  5125. if ( elem.ownerDocument.defaultView.opener ) {
  5126. return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
  5127. }
  5128. return window.getComputedStyle( elem, null );
  5129. };
  5130. curCSS = function( elem, name, computed ) {
  5131. var width, minWidth, maxWidth, ret,
  5132. style = elem.style;
  5133. computed = computed || getStyles( elem );
  5134. // getPropertyValue is only needed for .css('filter') in IE9, see #12537
  5135. ret = computed ? computed.getPropertyValue( name ) || computed[ name ] : undefined;
  5136. if ( computed ) {
  5137. if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
  5138. ret = jQuery.style( elem, name );
  5139. }
  5140. // A tribute to the "awesome hack by Dean Edwards"
  5141. // Chrome < 17 and Safari 5.0 uses "computed value" instead of "used value" for margin-right
  5142. // Safari 5.1.7 (at least) returns percentage for a larger set of values, but width seems to be reliably pixels
  5143. // this is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
  5144. if ( rnumnonpx.test( ret ) && rmargin.test( name ) ) {
  5145. // Remember the original values
  5146. width = style.width;
  5147. minWidth = style.minWidth;
  5148. maxWidth = style.maxWidth;
  5149. // Put in the new values to get a computed value out
  5150. style.minWidth = style.maxWidth = style.width = ret;
  5151. ret = computed.width;
  5152. // Revert the changed values
  5153. style.width = width;
  5154. style.minWidth = minWidth;
  5155. style.maxWidth = maxWidth;
  5156. }
  5157. }
  5158. // Support: IE
  5159. // IE returns zIndex value as an integer.
  5160. return ret === undefined ?
  5161. ret :
  5162. ret + "";
  5163. };
  5164. } else if ( document.documentElement.currentStyle ) {
  5165. getStyles = function( elem ) {
  5166. return elem.currentStyle;
  5167. };
  5168. curCSS = function( elem, name, computed ) {
  5169. var left, rs, rsLeft, ret,
  5170. style = elem.style;
  5171. computed = computed || getStyles( elem );
  5172. ret = computed ? computed[ name ] : undefined;
  5173. // Avoid setting ret to empty string here
  5174. // so we don't default to auto
  5175. if ( ret == null && style && style[ name ] ) {
  5176. ret = style[ name ];
  5177. }
  5178. // From the awesome hack by Dean Edwards
  5179. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  5180. // If we're not dealing with a regular pixel number
  5181. // but a number that has a weird ending, we need to convert it to pixels
  5182. // but not position css attributes, as those are proportional to the parent element instead
  5183. // and we can't measure the parent instead because it might trigger a "stacking dolls" problem
  5184. if ( rnumnonpx.test( ret ) && !rposition.test( name ) ) {
  5185. // Remember the original values
  5186. left = style.left;
  5187. rs = elem.runtimeStyle;
  5188. rsLeft = rs && rs.left;
  5189. // Put in the new values to get a computed value out
  5190. if ( rsLeft ) {
  5191. rs.left = elem.currentStyle.left;
  5192. }
  5193. style.left = name === "fontSize" ? "1em" : ret;
  5194. ret = style.pixelLeft + "px";
  5195. // Revert the changed values
  5196. style.left = left;
  5197. if ( rsLeft ) {
  5198. rs.left = rsLeft;
  5199. }
  5200. }
  5201. // Support: IE
  5202. // IE returns zIndex value as an integer.
  5203. return ret === undefined ?
  5204. ret :
  5205. ret + "" || "auto";
  5206. };
  5207. }
  5208. function addGetHookIf( conditionFn, hookFn ) {
  5209. // Define the hook, we'll check on the first run if it's really needed.
  5210. return {
  5211. get: function() {
  5212. var condition = conditionFn();
  5213. if ( condition == null ) {
  5214. // The test was not ready at this point; screw the hook this time
  5215. // but check again when needed next time.
  5216. return;
  5217. }
  5218. if ( condition ) {
  5219. // Hook not needed (or it's not possible to use it due to missing dependency),
  5220. // remove it.
  5221. // Since there are no other hooks for marginRight, remove the whole object.
  5222. delete this.get;
  5223. return;
  5224. }
  5225. // Hook needed; redefine it so that the support test is not executed again.
  5226. return (this.get = hookFn).apply( this, arguments );
  5227. }
  5228. };
  5229. }
  5230. (function() {
  5231. // Minified: var b,c,d,e,f,g, h,i
  5232. var div, style, a, pixelPositionVal, boxSizingReliableVal,
  5233. reliableHiddenOffsetsVal, reliableMarginRightVal;
  5234. // Setup
  5235. div = document.createElement( "div" );
  5236. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  5237. a = div.getElementsByTagName( "a" )[ 0 ];
  5238. style = a && a.style;
  5239. // Finish early in limited (non-browser) environments
  5240. if ( !style ) {
  5241. return;
  5242. }
  5243. style.cssText = "float:left;opacity:.5";
  5244. // Support: IE<9
  5245. // Make sure that element opacity exists (as opposed to filter)
  5246. support.opacity = style.opacity === "0.5";
  5247. // Verify style float existence
  5248. // (IE uses styleFloat instead of cssFloat)
  5249. support.cssFloat = !!style.cssFloat;
  5250. div.style.backgroundClip = "content-box";
  5251. div.cloneNode( true ).style.backgroundClip = "";
  5252. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5253. // Support: Firefox<29, Android 2.3
  5254. // Vendor-prefix box-sizing
  5255. support.boxSizing = style.boxSizing === "" || style.MozBoxSizing === "" ||
  5256. style.WebkitBoxSizing === "";
  5257. jQuery.extend(support, {
  5258. reliableHiddenOffsets: function() {
  5259. if ( reliableHiddenOffsetsVal == null ) {
  5260. computeStyleTests();
  5261. }
  5262. return reliableHiddenOffsetsVal;
  5263. },
  5264. boxSizingReliable: function() {
  5265. if ( boxSizingReliableVal == null ) {
  5266. computeStyleTests();
  5267. }
  5268. return boxSizingReliableVal;
  5269. },
  5270. pixelPosition: function() {
  5271. if ( pixelPositionVal == null ) {
  5272. computeStyleTests();
  5273. }
  5274. return pixelPositionVal;
  5275. },
  5276. // Support: Android 2.3
  5277. reliableMarginRight: function() {
  5278. if ( reliableMarginRightVal == null ) {
  5279. computeStyleTests();
  5280. }
  5281. return reliableMarginRightVal;
  5282. }
  5283. });
  5284. function computeStyleTests() {
  5285. // Minified: var b,c,d,j
  5286. var div, body, container, contents;
  5287. body = document.getElementsByTagName( "body" )[ 0 ];
  5288. if ( !body || !body.style ) {
  5289. // Test fired too early or in an unsupported environment, exit.
  5290. return;
  5291. }
  5292. // Setup
  5293. div = document.createElement( "div" );
  5294. container = document.createElement( "div" );
  5295. container.style.cssText = "position:absolute;border:0;width:0;height:0;top:0;left:-9999px";
  5296. body.appendChild( container ).appendChild( div );
  5297. div.style.cssText =
  5298. // Support: Firefox<29, Android 2.3
  5299. // Vendor-prefix box-sizing
  5300. "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
  5301. "box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
  5302. "border:1px;padding:1px;width:4px;position:absolute";
  5303. // Support: IE<9
  5304. // Assume reasonable values in the absence of getComputedStyle
  5305. pixelPositionVal = boxSizingReliableVal = false;
  5306. reliableMarginRightVal = true;
  5307. // Check for getComputedStyle so that this code is not run in IE<9.
  5308. if ( window.getComputedStyle ) {
  5309. pixelPositionVal = ( window.getComputedStyle( div, null ) || {} ).top !== "1%";
  5310. boxSizingReliableVal =
  5311. ( window.getComputedStyle( div, null ) || { width: "4px" } ).width === "4px";
  5312. // Support: Android 2.3
  5313. // Div with explicit width and no margin-right incorrectly
  5314. // gets computed margin-right based on width of container (#3333)
  5315. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5316. contents = div.appendChild( document.createElement( "div" ) );
  5317. // Reset CSS: box-sizing; display; margin; border; padding
  5318. contents.style.cssText = div.style.cssText =
  5319. // Support: Firefox<29, Android 2.3
  5320. // Vendor-prefix box-sizing
  5321. "-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
  5322. "box-sizing:content-box;display:block;margin:0;border:0;padding:0";
  5323. contents.style.marginRight = contents.style.width = "0";
  5324. div.style.width = "1px";
  5325. reliableMarginRightVal =
  5326. !parseFloat( ( window.getComputedStyle( contents, null ) || {} ).marginRight );
  5327. div.removeChild( contents );
  5328. }
  5329. // Support: IE8
  5330. // Check if table cells still have offsetWidth/Height when they are set
  5331. // to display:none and there are still other visible table cells in a
  5332. // table row; if so, offsetWidth/Height are not reliable for use when
  5333. // determining if an element has been hidden directly using
  5334. // display:none (it is still safe to use offsets if a parent element is
  5335. // hidden; don safety goggles and see bug #4512 for more information).
  5336. div.innerHTML = "<table><tr><td></td><td>t</td></tr></table>";
  5337. contents = div.getElementsByTagName( "td" );
  5338. contents[ 0 ].style.cssText = "margin:0;border:0;padding:0;display:none";
  5339. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5340. if ( reliableHiddenOffsetsVal ) {
  5341. contents[ 0 ].style.display = "";
  5342. contents[ 1 ].style.display = "none";
  5343. reliableHiddenOffsetsVal = contents[ 0 ].offsetHeight === 0;
  5344. }
  5345. body.removeChild( container );
  5346. }
  5347. })();
  5348. // A method for quickly swapping in/out CSS properties to get correct calculations.
  5349. jQuery.swap = function( elem, options, callback, args ) {
  5350. var ret, name,
  5351. old = {};
  5352. // Remember the old values, and insert the new ones
  5353. for ( name in options ) {
  5354. old[ name ] = elem.style[ name ];
  5355. elem.style[ name ] = options[ name ];
  5356. }
  5357. ret = callback.apply( elem, args || [] );
  5358. // Revert the old values
  5359. for ( name in options ) {
  5360. elem.style[ name ] = old[ name ];
  5361. }
  5362. return ret;
  5363. };
  5364. var
  5365. ralpha = /alpha\([^)]*\)/i,
  5366. ropacity = /opacity\s*=\s*([^)]*)/,
  5367. // swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
  5368. // see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5369. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5370. rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
  5371. rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
  5372. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5373. cssNormalTransform = {
  5374. letterSpacing: "0",
  5375. fontWeight: "400"
  5376. },
  5377. cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
  5378. // return a css property mapped to a potentially vendor prefixed property
  5379. function vendorPropName( style, name ) {
  5380. // shortcut for names that are not vendor prefixed
  5381. if ( name in style ) {
  5382. return name;
  5383. }
  5384. // check for vendor prefixed names
  5385. var capName = name.charAt(0).toUpperCase() + name.slice(1),
  5386. origName = name,
  5387. i = cssPrefixes.length;
  5388. while ( i-- ) {
  5389. name = cssPrefixes[ i ] + capName;
  5390. if ( name in style ) {
  5391. return name;
  5392. }
  5393. }
  5394. return origName;
  5395. }
  5396. function showHide( elements, show ) {
  5397. var display, elem, hidden,
  5398. values = [],
  5399. index = 0,
  5400. length = elements.length;
  5401. for ( ; index < length; index++ ) {
  5402. elem = elements[ index ];
  5403. if ( !elem.style ) {
  5404. continue;
  5405. }
  5406. values[ index ] = jQuery._data( elem, "olddisplay" );
  5407. display = elem.style.display;
  5408. if ( show ) {
  5409. // Reset the inline display of this element to learn if it is
  5410. // being hidden by cascaded rules or not
  5411. if ( !values[ index ] && display === "none" ) {
  5412. elem.style.display = "";
  5413. }
  5414. // Set elements which have been overridden with display: none
  5415. // in a stylesheet to whatever the default browser style is
  5416. // for such an element
  5417. if ( elem.style.display === "" && isHidden( elem ) ) {
  5418. values[ index ] = jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) );
  5419. }
  5420. } else {
  5421. hidden = isHidden( elem );
  5422. if ( display && display !== "none" || !hidden ) {
  5423. jQuery._data( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
  5424. }
  5425. }
  5426. }
  5427. // Set the display of most of the elements in a second loop
  5428. // to avoid the constant reflow
  5429. for ( index = 0; index < length; index++ ) {
  5430. elem = elements[ index ];
  5431. if ( !elem.style ) {
  5432. continue;
  5433. }
  5434. if ( !show || elem.style.display === "none" || elem.style.display === "" ) {
  5435. elem.style.display = show ? values[ index ] || "" : "none";
  5436. }
  5437. }
  5438. return elements;
  5439. }
  5440. function setPositiveNumber( elem, value, subtract ) {
  5441. var matches = rnumsplit.exec( value );
  5442. return matches ?
  5443. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5444. Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
  5445. value;
  5446. }
  5447. function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
  5448. var i = extra === ( isBorderBox ? "border" : "content" ) ?
  5449. // If we already have the right measurement, avoid augmentation
  5450. 4 :
  5451. // Otherwise initialize for horizontal or vertical properties
  5452. name === "width" ? 1 : 0,
  5453. val = 0;
  5454. for ( ; i < 4; i += 2 ) {
  5455. // both box models exclude margin, so add it if we want it
  5456. if ( extra === "margin" ) {
  5457. val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
  5458. }
  5459. if ( isBorderBox ) {
  5460. // border-box includes padding, so remove it if we want content
  5461. if ( extra === "content" ) {
  5462. val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5463. }
  5464. // at this point, extra isn't border nor margin, so remove border
  5465. if ( extra !== "margin" ) {
  5466. val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5467. }
  5468. } else {
  5469. // at this point, extra isn't content, so add padding
  5470. val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5471. // at this point, extra isn't content nor padding, so add border
  5472. if ( extra !== "padding" ) {
  5473. val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5474. }
  5475. }
  5476. }
  5477. return val;
  5478. }
  5479. function getWidthOrHeight( elem, name, extra ) {
  5480. // Start with offset property, which is equivalent to the border-box value
  5481. var valueIsBorderBox = true,
  5482. val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5483. styles = getStyles( elem ),
  5484. isBorderBox = support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5485. // some non-html elements return undefined for offsetWidth, so check for null/undefined
  5486. // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
  5487. // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
  5488. if ( val <= 0 || val == null ) {
  5489. // Fall back to computed then uncomputed css if necessary
  5490. val = curCSS( elem, name, styles );
  5491. if ( val < 0 || val == null ) {
  5492. val = elem.style[ name ];
  5493. }
  5494. // Computed unit is not pixels. Stop here and return.
  5495. if ( rnumnonpx.test(val) ) {
  5496. return val;
  5497. }
  5498. // we need the check for style in case a browser which returns unreliable values
  5499. // for getComputedStyle silently falls back to the reliable elem.style
  5500. valueIsBorderBox = isBorderBox && ( support.boxSizingReliable() || val === elem.style[ name ] );
  5501. // Normalize "", auto, and prepare for extra
  5502. val = parseFloat( val ) || 0;
  5503. }
  5504. // use the active box-sizing model to add/subtract irrelevant styles
  5505. return ( val +
  5506. augmentWidthOrHeight(
  5507. elem,
  5508. name,
  5509. extra || ( isBorderBox ? "border" : "content" ),
  5510. valueIsBorderBox,
  5511. styles
  5512. )
  5513. ) + "px";
  5514. }
  5515. jQuery.extend({
  5516. // Add in style property hooks for overriding the default
  5517. // behavior of getting and setting a style property
  5518. cssHooks: {
  5519. opacity: {
  5520. get: function( elem, computed ) {
  5521. if ( computed ) {
  5522. // We should always get a number back from opacity
  5523. var ret = curCSS( elem, "opacity" );
  5524. return ret === "" ? "1" : ret;
  5525. }
  5526. }
  5527. }
  5528. },
  5529. // Don't automatically add "px" to these possibly-unitless properties
  5530. cssNumber: {
  5531. "columnCount": true,
  5532. "fillOpacity": true,
  5533. "flexGrow": true,
  5534. "flexShrink": true,
  5535. "fontWeight": true,
  5536. "lineHeight": true,
  5537. "opacity": true,
  5538. "order": true,
  5539. "orphans": true,
  5540. "widows": true,
  5541. "zIndex": true,
  5542. "zoom": true
  5543. },
  5544. // Add in properties whose names you wish to fix before
  5545. // setting or getting the value
  5546. cssProps: {
  5547. // normalize float css property
  5548. "float": support.cssFloat ? "cssFloat" : "styleFloat"
  5549. },
  5550. // Get and set the style property on a DOM Node
  5551. style: function( elem, name, value, extra ) {
  5552. // Don't set styles on text and comment nodes
  5553. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5554. return;
  5555. }
  5556. // Make sure that we're working with the right name
  5557. var ret, type, hooks,
  5558. origName = jQuery.camelCase( name ),
  5559. style = elem.style;
  5560. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
  5561. // gets hook for the prefixed version
  5562. // followed by the unprefixed version
  5563. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5564. // Check if we're setting a value
  5565. if ( value !== undefined ) {
  5566. type = typeof value;
  5567. // convert relative number strings (+= or -=) to relative numbers. #7345
  5568. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  5569. value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
  5570. // Fixes bug #9237
  5571. type = "number";
  5572. }
  5573. // Make sure that null and NaN values aren't set. See: #7116
  5574. if ( value == null || value !== value ) {
  5575. return;
  5576. }
  5577. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  5578. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  5579. value += "px";
  5580. }
  5581. // Fixes #8908, it can be done more correctly by specifing setters in cssHooks,
  5582. // but it would mean to define eight (for every problematic property) identical functions
  5583. if ( !support.clearCloneStyle && value === "" && name.indexOf("background") === 0 ) {
  5584. style[ name ] = "inherit";
  5585. }
  5586. // If a hook was provided, use that value, otherwise just set the specified value
  5587. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
  5588. // Support: IE
  5589. // Swallow errors from 'invalid' CSS values (#5509)
  5590. try {
  5591. style[ name ] = value;
  5592. } catch(e) {}
  5593. }
  5594. } else {
  5595. // If a hook was provided get the non-computed value from there
  5596. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  5597. return ret;
  5598. }
  5599. // Otherwise just get the value from the style object
  5600. return style[ name ];
  5601. }
  5602. },
  5603. css: function( elem, name, extra, styles ) {
  5604. var num, val, hooks,
  5605. origName = jQuery.camelCase( name );
  5606. // Make sure that we're working with the right name
  5607. name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
  5608. // gets hook for the prefixed version
  5609. // followed by the unprefixed version
  5610. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5611. // If a hook was provided get the computed value from there
  5612. if ( hooks && "get" in hooks ) {
  5613. val = hooks.get( elem, true, extra );
  5614. }
  5615. // Otherwise, if a way to get the computed value exists, use that
  5616. if ( val === undefined ) {
  5617. val = curCSS( elem, name, styles );
  5618. }
  5619. //convert "normal" to computed value
  5620. if ( val === "normal" && name in cssNormalTransform ) {
  5621. val = cssNormalTransform[ name ];
  5622. }
  5623. // Return, converting to number if forced or a qualifier was provided and val looks numeric
  5624. if ( extra === "" || extra ) {
  5625. num = parseFloat( val );
  5626. return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
  5627. }
  5628. return val;
  5629. }
  5630. });
  5631. jQuery.each([ "height", "width" ], function( i, name ) {
  5632. jQuery.cssHooks[ name ] = {
  5633. get: function( elem, computed, extra ) {
  5634. if ( computed ) {
  5635. // certain elements can have dimension info if we invisibly show them
  5636. // however, it must have a current display style that would benefit from this
  5637. return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
  5638. jQuery.swap( elem, cssShow, function() {
  5639. return getWidthOrHeight( elem, name, extra );
  5640. }) :
  5641. getWidthOrHeight( elem, name, extra );
  5642. }
  5643. },
  5644. set: function( elem, value, extra ) {
  5645. var styles = extra && getStyles( elem );
  5646. return setPositiveNumber( elem, value, extra ?
  5647. augmentWidthOrHeight(
  5648. elem,
  5649. name,
  5650. extra,
  5651. support.boxSizing && jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5652. styles
  5653. ) : 0
  5654. );
  5655. }
  5656. };
  5657. });
  5658. if ( !support.opacity ) {
  5659. jQuery.cssHooks.opacity = {
  5660. get: function( elem, computed ) {
  5661. // IE uses filters for opacity
  5662. return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
  5663. ( 0.01 * parseFloat( RegExp.$1 ) ) + "" :
  5664. computed ? "1" : "";
  5665. },
  5666. set: function( elem, value ) {
  5667. var style = elem.style,
  5668. currentStyle = elem.currentStyle,
  5669. opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "",
  5670. filter = currentStyle && currentStyle.filter || style.filter || "";
  5671. // IE has trouble with opacity if it does not have layout
  5672. // Force it by setting the zoom level
  5673. style.zoom = 1;
  5674. // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
  5675. // if value === "", then remove inline opacity #12685
  5676. if ( ( value >= 1 || value === "" ) &&
  5677. jQuery.trim( filter.replace( ralpha, "" ) ) === "" &&
  5678. style.removeAttribute ) {
  5679. // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
  5680. // if "filter:" is present at all, clearType is disabled, we want to avoid this
  5681. // style.removeAttribute is IE Only, but so apparently is this code path...
  5682. style.removeAttribute( "filter" );
  5683. // if there is no filter style applied in a css rule or unset inline opacity, we are done
  5684. if ( value === "" || currentStyle && !currentStyle.filter ) {
  5685. return;
  5686. }
  5687. }
  5688. // otherwise, set new filter values
  5689. style.filter = ralpha.test( filter ) ?
  5690. filter.replace( ralpha, opacity ) :
  5691. filter + " " + opacity;
  5692. }
  5693. };
  5694. }
  5695. jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
  5696. function( elem, computed ) {
  5697. if ( computed ) {
  5698. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5699. // Work around by temporarily setting element display to inline-block
  5700. return jQuery.swap( elem, { "display": "inline-block" },
  5701. curCSS, [ elem, "marginRight" ] );
  5702. }
  5703. }
  5704. );
  5705. // These hooks are used by animate to expand properties
  5706. jQuery.each({
  5707. margin: "",
  5708. padding: "",
  5709. border: "Width"
  5710. }, function( prefix, suffix ) {
  5711. jQuery.cssHooks[ prefix + suffix ] = {
  5712. expand: function( value ) {
  5713. var i = 0,
  5714. expanded = {},
  5715. // assumes a single number if not a string
  5716. parts = typeof value === "string" ? value.split(" ") : [ value ];
  5717. for ( ; i < 4; i++ ) {
  5718. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5719. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5720. }
  5721. return expanded;
  5722. }
  5723. };
  5724. if ( !rmargin.test( prefix ) ) {
  5725. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5726. }
  5727. });
  5728. jQuery.fn.extend({
  5729. css: function( name, value ) {
  5730. return access( this, function( elem, name, value ) {
  5731. var styles, len,
  5732. map = {},
  5733. i = 0;
  5734. if ( jQuery.isArray( name ) ) {
  5735. styles = getStyles( elem );
  5736. len = name.length;
  5737. for ( ; i < len; i++ ) {
  5738. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5739. }
  5740. return map;
  5741. }
  5742. return value !== undefined ?
  5743. jQuery.style( elem, name, value ) :
  5744. jQuery.css( elem, name );
  5745. }, name, value, arguments.length > 1 );
  5746. },
  5747. show: function() {
  5748. return showHide( this, true );
  5749. },
  5750. hide: function() {
  5751. return showHide( this );
  5752. },
  5753. toggle: function( state ) {
  5754. if ( typeof state === "boolean" ) {
  5755. return state ? this.show() : this.hide();
  5756. }
  5757. return this.each(function() {
  5758. if ( isHidden( this ) ) {
  5759. jQuery( this ).show();
  5760. } else {
  5761. jQuery( this ).hide();
  5762. }
  5763. });
  5764. }
  5765. });
  5766. function Tween( elem, options, prop, end, easing ) {
  5767. return new Tween.prototype.init( elem, options, prop, end, easing );
  5768. }
  5769. jQuery.Tween = Tween;
  5770. Tween.prototype = {
  5771. constructor: Tween,
  5772. init: function( elem, options, prop, end, easing, unit ) {
  5773. this.elem = elem;
  5774. this.prop = prop;
  5775. this.easing = easing || "swing";
  5776. this.options = options;
  5777. this.start = this.now = this.cur();
  5778. this.end = end;
  5779. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5780. },
  5781. cur: function() {
  5782. var hooks = Tween.propHooks[ this.prop ];
  5783. return hooks && hooks.get ?
  5784. hooks.get( this ) :
  5785. Tween.propHooks._default.get( this );
  5786. },
  5787. run: function( percent ) {
  5788. var eased,
  5789. hooks = Tween.propHooks[ this.prop ];
  5790. if ( this.options.duration ) {
  5791. this.pos = eased = jQuery.easing[ this.easing ](
  5792. percent, this.options.duration * percent, 0, 1, this.options.duration
  5793. );
  5794. } else {
  5795. this.pos = eased = percent;
  5796. }
  5797. this.now = ( this.end - this.start ) * eased + this.start;
  5798. if ( this.options.step ) {
  5799. this.options.step.call( this.elem, this.now, this );
  5800. }
  5801. if ( hooks && hooks.set ) {
  5802. hooks.set( this );
  5803. } else {
  5804. Tween.propHooks._default.set( this );
  5805. }
  5806. return this;
  5807. }
  5808. };
  5809. Tween.prototype.init.prototype = Tween.prototype;
  5810. Tween.propHooks = {
  5811. _default: {
  5812. get: function( tween ) {
  5813. var result;
  5814. if ( tween.elem[ tween.prop ] != null &&
  5815. (!tween.elem.style || tween.elem.style[ tween.prop ] == null) ) {
  5816. return tween.elem[ tween.prop ];
  5817. }
  5818. // passing an empty string as a 3rd parameter to .css will automatically
  5819. // attempt a parseFloat and fallback to a string if the parse fails
  5820. // so, simple values such as "10px" are parsed to Float.
  5821. // complex values such as "rotate(1rad)" are returned as is.
  5822. result = jQuery.css( tween.elem, tween.prop, "" );
  5823. // Empty strings, null, undefined and "auto" are converted to 0.
  5824. return !result || result === "auto" ? 0 : result;
  5825. },
  5826. set: function( tween ) {
  5827. // use step hook for back compat - use cssHook if its there - use .style if its
  5828. // available and use plain properties where available
  5829. if ( jQuery.fx.step[ tween.prop ] ) {
  5830. jQuery.fx.step[ tween.prop ]( tween );
  5831. } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
  5832. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5833. } else {
  5834. tween.elem[ tween.prop ] = tween.now;
  5835. }
  5836. }
  5837. }
  5838. };
  5839. // Support: IE <=9
  5840. // Panic based approach to setting things on disconnected nodes
  5841. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5842. set: function( tween ) {
  5843. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5844. tween.elem[ tween.prop ] = tween.now;
  5845. }
  5846. }
  5847. };
  5848. jQuery.easing = {
  5849. linear: function( p ) {
  5850. return p;
  5851. },
  5852. swing: function( p ) {
  5853. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5854. }
  5855. };
  5856. jQuery.fx = Tween.prototype.init;
  5857. // Back Compat <1.8 extension point
  5858. jQuery.fx.step = {};
  5859. var
  5860. fxNow, timerId,
  5861. rfxtypes = /^(?:toggle|show|hide)$/,
  5862. rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
  5863. rrun = /queueHooks$/,
  5864. animationPrefilters = [ defaultPrefilter ],
  5865. tweeners = {
  5866. "*": [ function( prop, value ) {
  5867. var tween = this.createTween( prop, value ),
  5868. target = tween.cur(),
  5869. parts = rfxnum.exec( value ),
  5870. unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  5871. // Starting value computation is required for potential unit mismatches
  5872. start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
  5873. rfxnum.exec( jQuery.css( tween.elem, prop ) ),
  5874. scale = 1,
  5875. maxIterations = 20;
  5876. if ( start && start[ 3 ] !== unit ) {
  5877. // Trust units reported by jQuery.css
  5878. unit = unit || start[ 3 ];
  5879. // Make sure we update the tween properties later on
  5880. parts = parts || [];
  5881. // Iteratively approximate from a nonzero starting point
  5882. start = +target || 1;
  5883. do {
  5884. // If previous iteration zeroed out, double until we get *something*
  5885. // Use a string for doubling factor so we don't accidentally see scale as unchanged below
  5886. scale = scale || ".5";
  5887. // Adjust and apply
  5888. start = start / scale;
  5889. jQuery.style( tween.elem, prop, start + unit );
  5890. // Update scale, tolerating zero or NaN from tween.cur()
  5891. // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
  5892. } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  5893. }
  5894. // Update tween properties
  5895. if ( parts ) {
  5896. start = tween.start = +start || +target || 0;
  5897. tween.unit = unit;
  5898. // If a +=/-= token was provided, we're doing a relative animation
  5899. tween.end = parts[ 1 ] ?
  5900. start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
  5901. +parts[ 2 ];
  5902. }
  5903. return tween;
  5904. } ]
  5905. };
  5906. // Animations created synchronously will run synchronously
  5907. function createFxNow() {
  5908. setTimeout(function() {
  5909. fxNow = undefined;
  5910. });
  5911. return ( fxNow = jQuery.now() );
  5912. }
  5913. // Generate parameters to create a standard animation
  5914. function genFx( type, includeWidth ) {
  5915. var which,
  5916. attrs = { height: type },
  5917. i = 0;
  5918. // if we include width, step value is 1 to do all cssExpand values,
  5919. // if we don't include width, step value is 2 to skip over Left and Right
  5920. includeWidth = includeWidth ? 1 : 0;
  5921. for ( ; i < 4 ; i += 2 - includeWidth ) {
  5922. which = cssExpand[ i ];
  5923. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5924. }
  5925. if ( includeWidth ) {
  5926. attrs.opacity = attrs.width = type;
  5927. }
  5928. return attrs;
  5929. }
  5930. function createTween( value, prop, animation ) {
  5931. var tween,
  5932. collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
  5933. index = 0,
  5934. length = collection.length;
  5935. for ( ; index < length; index++ ) {
  5936. if ( (tween = collection[ index ].call( animation, prop, value )) ) {
  5937. // we're done with this property
  5938. return tween;
  5939. }
  5940. }
  5941. }
  5942. function defaultPrefilter( elem, props, opts ) {
  5943. /* jshint validthis: true */
  5944. var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
  5945. anim = this,
  5946. orig = {},
  5947. style = elem.style,
  5948. hidden = elem.nodeType && isHidden( elem ),
  5949. dataShow = jQuery._data( elem, "fxshow" );
  5950. // handle queue: false promises
  5951. if ( !opts.queue ) {
  5952. hooks = jQuery._queueHooks( elem, "fx" );
  5953. if ( hooks.unqueued == null ) {
  5954. hooks.unqueued = 0;
  5955. oldfire = hooks.empty.fire;
  5956. hooks.empty.fire = function() {
  5957. if ( !hooks.unqueued ) {
  5958. oldfire();
  5959. }
  5960. };
  5961. }
  5962. hooks.unqueued++;
  5963. anim.always(function() {
  5964. // doing this makes sure that the complete handler will be called
  5965. // before this completes
  5966. anim.always(function() {
  5967. hooks.unqueued--;
  5968. if ( !jQuery.queue( elem, "fx" ).length ) {
  5969. hooks.empty.fire();
  5970. }
  5971. });
  5972. });
  5973. }
  5974. // height/width overflow pass
  5975. if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
  5976. // Make sure that nothing sneaks out
  5977. // Record all 3 overflow attributes because IE does not
  5978. // change the overflow attribute when overflowX and
  5979. // overflowY are set to the same value
  5980. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5981. // Set display property to inline-block for height/width
  5982. // animations on inline elements that are having width/height animated
  5983. display = jQuery.css( elem, "display" );
  5984. // Test default display if display is currently "none"
  5985. checkDisplay = display === "none" ?
  5986. jQuery._data( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
  5987. if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
  5988. // inline-level elements accept inline-block;
  5989. // block-level elements need to be inline with layout
  5990. if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
  5991. style.display = "inline-block";
  5992. } else {
  5993. style.zoom = 1;
  5994. }
  5995. }
  5996. }
  5997. if ( opts.overflow ) {
  5998. style.overflow = "hidden";
  5999. if ( !support.shrinkWrapBlocks() ) {
  6000. anim.always(function() {
  6001. style.overflow = opts.overflow[ 0 ];
  6002. style.overflowX = opts.overflow[ 1 ];
  6003. style.overflowY = opts.overflow[ 2 ];
  6004. });
  6005. }
  6006. }
  6007. // show/hide pass
  6008. for ( prop in props ) {
  6009. value = props[ prop ];
  6010. if ( rfxtypes.exec( value ) ) {
  6011. delete props[ prop ];
  6012. toggle = toggle || value === "toggle";
  6013. if ( value === ( hidden ? "hide" : "show" ) ) {
  6014. // If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
  6015. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  6016. hidden = true;
  6017. } else {
  6018. continue;
  6019. }
  6020. }
  6021. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  6022. // Any non-fx value stops us from restoring the original display value
  6023. } else {
  6024. display = undefined;
  6025. }
  6026. }
  6027. if ( !jQuery.isEmptyObject( orig ) ) {
  6028. if ( dataShow ) {
  6029. if ( "hidden" in dataShow ) {
  6030. hidden = dataShow.hidden;
  6031. }
  6032. } else {
  6033. dataShow = jQuery._data( elem, "fxshow", {} );
  6034. }
  6035. // store state if its toggle - enables .stop().toggle() to "reverse"
  6036. if ( toggle ) {
  6037. dataShow.hidden = !hidden;
  6038. }
  6039. if ( hidden ) {
  6040. jQuery( elem ).show();
  6041. } else {
  6042. anim.done(function() {
  6043. jQuery( elem ).hide();
  6044. });
  6045. }
  6046. anim.done(function() {
  6047. var prop;
  6048. jQuery._removeData( elem, "fxshow" );
  6049. for ( prop in orig ) {
  6050. jQuery.style( elem, prop, orig[ prop ] );
  6051. }
  6052. });
  6053. for ( prop in orig ) {
  6054. tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  6055. if ( !( prop in dataShow ) ) {
  6056. dataShow[ prop ] = tween.start;
  6057. if ( hidden ) {
  6058. tween.end = tween.start;
  6059. tween.start = prop === "width" || prop === "height" ? 1 : 0;
  6060. }
  6061. }
  6062. }
  6063. // If this is a noop like .hide().hide(), restore an overwritten display value
  6064. } else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
  6065. style.display = display;
  6066. }
  6067. }
  6068. function propFilter( props, specialEasing ) {
  6069. var index, name, easing, value, hooks;
  6070. // camelCase, specialEasing and expand cssHook pass
  6071. for ( index in props ) {
  6072. name = jQuery.camelCase( index );
  6073. easing = specialEasing[ name ];
  6074. value = props[ index ];
  6075. if ( jQuery.isArray( value ) ) {
  6076. easing = value[ 1 ];
  6077. value = props[ index ] = value[ 0 ];
  6078. }
  6079. if ( index !== name ) {
  6080. props[ name ] = value;
  6081. delete props[ index ];
  6082. }
  6083. hooks = jQuery.cssHooks[ name ];
  6084. if ( hooks && "expand" in hooks ) {
  6085. value = hooks.expand( value );
  6086. delete props[ name ];
  6087. // not quite $.extend, this wont overwrite keys already present.
  6088. // also - reusing 'index' from above because we have the correct "name"
  6089. for ( index in value ) {
  6090. if ( !( index in props ) ) {
  6091. props[ index ] = value[ index ];
  6092. specialEasing[ index ] = easing;
  6093. }
  6094. }
  6095. } else {
  6096. specialEasing[ name ] = easing;
  6097. }
  6098. }
  6099. }
  6100. function Animation( elem, properties, options ) {
  6101. var result,
  6102. stopped,
  6103. index = 0,
  6104. length = animationPrefilters.length,
  6105. deferred = jQuery.Deferred().always( function() {
  6106. // don't match elem in the :animated selector
  6107. delete tick.elem;
  6108. }),
  6109. tick = function() {
  6110. if ( stopped ) {
  6111. return false;
  6112. }
  6113. var currentTime = fxNow || createFxNow(),
  6114. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  6115. // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
  6116. temp = remaining / animation.duration || 0,
  6117. percent = 1 - temp,
  6118. index = 0,
  6119. length = animation.tweens.length;
  6120. for ( ; index < length ; index++ ) {
  6121. animation.tweens[ index ].run( percent );
  6122. }
  6123. deferred.notifyWith( elem, [ animation, percent, remaining ]);
  6124. if ( percent < 1 && length ) {
  6125. return remaining;
  6126. } else {
  6127. deferred.resolveWith( elem, [ animation ] );
  6128. return false;
  6129. }
  6130. },
  6131. animation = deferred.promise({
  6132. elem: elem,
  6133. props: jQuery.extend( {}, properties ),
  6134. opts: jQuery.extend( true, { specialEasing: {} }, options ),
  6135. originalProperties: properties,
  6136. originalOptions: options,
  6137. startTime: fxNow || createFxNow(),
  6138. duration: options.duration,
  6139. tweens: [],
  6140. createTween: function( prop, end ) {
  6141. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  6142. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  6143. animation.tweens.push( tween );
  6144. return tween;
  6145. },
  6146. stop: function( gotoEnd ) {
  6147. var index = 0,
  6148. // if we are going to the end, we want to run all the tweens
  6149. // otherwise we skip this part
  6150. length = gotoEnd ? animation.tweens.length : 0;
  6151. if ( stopped ) {
  6152. return this;
  6153. }
  6154. stopped = true;
  6155. for ( ; index < length ; index++ ) {
  6156. animation.tweens[ index ].run( 1 );
  6157. }
  6158. // resolve when we played the last frame
  6159. // otherwise, reject
  6160. if ( gotoEnd ) {
  6161. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  6162. } else {
  6163. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  6164. }
  6165. return this;
  6166. }
  6167. }),
  6168. props = animation.props;
  6169. propFilter( props, animation.opts.specialEasing );
  6170. for ( ; index < length ; index++ ) {
  6171. result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
  6172. if ( result ) {
  6173. return result;
  6174. }
  6175. }
  6176. jQuery.map( props, createTween, animation );
  6177. if ( jQuery.isFunction( animation.opts.start ) ) {
  6178. animation.opts.start.call( elem, animation );
  6179. }
  6180. jQuery.fx.timer(
  6181. jQuery.extend( tick, {
  6182. elem: elem,
  6183. anim: animation,
  6184. queue: animation.opts.queue
  6185. })
  6186. );
  6187. // attach callbacks from options
  6188. return animation.progress( animation.opts.progress )
  6189. .done( animation.opts.done, animation.opts.complete )
  6190. .fail( animation.opts.fail )
  6191. .always( animation.opts.always );
  6192. }
  6193. jQuery.Animation = jQuery.extend( Animation, {
  6194. tweener: function( props, callback ) {
  6195. if ( jQuery.isFunction( props ) ) {
  6196. callback = props;
  6197. props = [ "*" ];
  6198. } else {
  6199. props = props.split(" ");
  6200. }
  6201. var prop,
  6202. index = 0,
  6203. length = props.length;
  6204. for ( ; index < length ; index++ ) {
  6205. prop = props[ index ];
  6206. tweeners[ prop ] = tweeners[ prop ] || [];
  6207. tweeners[ prop ].unshift( callback );
  6208. }
  6209. },
  6210. prefilter: function( callback, prepend ) {
  6211. if ( prepend ) {
  6212. animationPrefilters.unshift( callback );
  6213. } else {
  6214. animationPrefilters.push( callback );
  6215. }
  6216. }
  6217. });
  6218. jQuery.speed = function( speed, easing, fn ) {
  6219. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  6220. complete: fn || !fn && easing ||
  6221. jQuery.isFunction( speed ) && speed,
  6222. duration: speed,
  6223. easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  6224. };
  6225. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  6226. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
  6227. // normalize opt.queue - true/undefined/null -> "fx"
  6228. if ( opt.queue == null || opt.queue === true ) {
  6229. opt.queue = "fx";
  6230. }
  6231. // Queueing
  6232. opt.old = opt.complete;
  6233. opt.complete = function() {
  6234. if ( jQuery.isFunction( opt.old ) ) {
  6235. opt.old.call( this );
  6236. }
  6237. if ( opt.queue ) {
  6238. jQuery.dequeue( this, opt.queue );
  6239. }
  6240. };
  6241. return opt;
  6242. };
  6243. jQuery.fn.extend({
  6244. fadeTo: function( speed, to, easing, callback ) {
  6245. // show any hidden elements after setting opacity to 0
  6246. return this.filter( isHidden ).css( "opacity", 0 ).show()
  6247. // animate to the value specified
  6248. .end().animate({ opacity: to }, speed, easing, callback );
  6249. },
  6250. animate: function( prop, speed, easing, callback ) {
  6251. var empty = jQuery.isEmptyObject( prop ),
  6252. optall = jQuery.speed( speed, easing, callback ),
  6253. doAnimation = function() {
  6254. // Operate on a copy of prop so per-property easing won't be lost
  6255. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  6256. // Empty animations, or finishing resolves immediately
  6257. if ( empty || jQuery._data( this, "finish" ) ) {
  6258. anim.stop( true );
  6259. }
  6260. };
  6261. doAnimation.finish = doAnimation;
  6262. return empty || optall.queue === false ?
  6263. this.each( doAnimation ) :
  6264. this.queue( optall.queue, doAnimation );
  6265. },
  6266. stop: function( type, clearQueue, gotoEnd ) {
  6267. var stopQueue = function( hooks ) {
  6268. var stop = hooks.stop;
  6269. delete hooks.stop;
  6270. stop( gotoEnd );
  6271. };
  6272. if ( typeof type !== "string" ) {
  6273. gotoEnd = clearQueue;
  6274. clearQueue = type;
  6275. type = undefined;
  6276. }
  6277. if ( clearQueue && type !== false ) {
  6278. this.queue( type || "fx", [] );
  6279. }
  6280. return this.each(function() {
  6281. var dequeue = true,
  6282. index = type != null && type + "queueHooks",
  6283. timers = jQuery.timers,
  6284. data = jQuery._data( this );
  6285. if ( index ) {
  6286. if ( data[ index ] && data[ index ].stop ) {
  6287. stopQueue( data[ index ] );
  6288. }
  6289. } else {
  6290. for ( index in data ) {
  6291. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  6292. stopQueue( data[ index ] );
  6293. }
  6294. }
  6295. }
  6296. for ( index = timers.length; index--; ) {
  6297. if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
  6298. timers[ index ].anim.stop( gotoEnd );
  6299. dequeue = false;
  6300. timers.splice( index, 1 );
  6301. }
  6302. }
  6303. // start the next in the queue if the last step wasn't forced
  6304. // timers currently will call their complete callbacks, which will dequeue
  6305. // but only if they were gotoEnd
  6306. if ( dequeue || !gotoEnd ) {
  6307. jQuery.dequeue( this, type );
  6308. }
  6309. });
  6310. },
  6311. finish: function( type ) {
  6312. if ( type !== false ) {
  6313. type = type || "fx";
  6314. }
  6315. return this.each(function() {
  6316. var index,
  6317. data = jQuery._data( this ),
  6318. queue = data[ type + "queue" ],
  6319. hooks = data[ type + "queueHooks" ],
  6320. timers = jQuery.timers,
  6321. length = queue ? queue.length : 0;
  6322. // enable finishing flag on private data
  6323. data.finish = true;
  6324. // empty the queue first
  6325. jQuery.queue( this, type, [] );
  6326. if ( hooks && hooks.stop ) {
  6327. hooks.stop.call( this, true );
  6328. }
  6329. // look for any active animations, and finish them
  6330. for ( index = timers.length; index--; ) {
  6331. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6332. timers[ index ].anim.stop( true );
  6333. timers.splice( index, 1 );
  6334. }
  6335. }
  6336. // look for any animations in the old queue and finish them
  6337. for ( index = 0; index < length; index++ ) {
  6338. if ( queue[ index ] && queue[ index ].finish ) {
  6339. queue[ index ].finish.call( this );
  6340. }
  6341. }
  6342. // turn off finishing flag
  6343. delete data.finish;
  6344. });
  6345. }
  6346. });
  6347. jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
  6348. var cssFn = jQuery.fn[ name ];
  6349. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6350. return speed == null || typeof speed === "boolean" ?
  6351. cssFn.apply( this, arguments ) :
  6352. this.animate( genFx( name, true ), speed, easing, callback );
  6353. };
  6354. });
  6355. // Generate shortcuts for custom animations
  6356. jQuery.each({
  6357. slideDown: genFx("show"),
  6358. slideUp: genFx("hide"),
  6359. slideToggle: genFx("toggle"),
  6360. fadeIn: { opacity: "show" },
  6361. fadeOut: { opacity: "hide" },
  6362. fadeToggle: { opacity: "toggle" }
  6363. }, function( name, props ) {
  6364. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6365. return this.animate( props, speed, easing, callback );
  6366. };
  6367. });
  6368. jQuery.timers = [];
  6369. jQuery.fx.tick = function() {
  6370. var timer,
  6371. timers = jQuery.timers,
  6372. i = 0;
  6373. fxNow = jQuery.now();
  6374. for ( ; i < timers.length; i++ ) {
  6375. timer = timers[ i ];
  6376. // Checks the timer has not already been removed
  6377. if ( !timer() && timers[ i ] === timer ) {
  6378. timers.splice( i--, 1 );
  6379. }
  6380. }
  6381. if ( !timers.length ) {
  6382. jQuery.fx.stop();
  6383. }
  6384. fxNow = undefined;
  6385. };
  6386. jQuery.fx.timer = function( timer ) {
  6387. jQuery.timers.push( timer );
  6388. if ( timer() ) {
  6389. jQuery.fx.start();
  6390. } else {
  6391. jQuery.timers.pop();
  6392. }
  6393. };
  6394. jQuery.fx.interval = 13;
  6395. jQuery.fx.start = function() {
  6396. if ( !timerId ) {
  6397. timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
  6398. }
  6399. };
  6400. jQuery.fx.stop = function() {
  6401. clearInterval( timerId );
  6402. timerId = null;
  6403. };
  6404. jQuery.fx.speeds = {
  6405. slow: 600,
  6406. fast: 200,
  6407. // Default speed
  6408. _default: 400
  6409. };
  6410. // Based off of the plugin by Clint Helfers, with permission.
  6411. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  6412. jQuery.fn.delay = function( time, type ) {
  6413. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6414. type = type || "fx";
  6415. return this.queue( type, function( next, hooks ) {
  6416. var timeout = setTimeout( next, time );
  6417. hooks.stop = function() {
  6418. clearTimeout( timeout );
  6419. };
  6420. });
  6421. };
  6422. (function() {
  6423. // Minified: var a,b,c,d,e
  6424. var input, div, select, a, opt;
  6425. // Setup
  6426. div = document.createElement( "div" );
  6427. div.setAttribute( "className", "t" );
  6428. div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
  6429. a = div.getElementsByTagName("a")[ 0 ];
  6430. // First batch of tests.
  6431. select = document.createElement("select");
  6432. opt = select.appendChild( document.createElement("option") );
  6433. input = div.getElementsByTagName("input")[ 0 ];
  6434. a.style.cssText = "top:1px";
  6435. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  6436. support.getSetAttribute = div.className !== "t";
  6437. // Get the style information from getAttribute
  6438. // (IE uses .cssText instead)
  6439. support.style = /top/.test( a.getAttribute("style") );
  6440. // Make sure that URLs aren't manipulated
  6441. // (IE normalizes it by default)
  6442. support.hrefNormalized = a.getAttribute("href") === "/a";
  6443. // Check the default checkbox/radio value ("" on WebKit; "on" elsewhere)
  6444. support.checkOn = !!input.value;
  6445. // Make sure that a selected-by-default option has a working selected property.
  6446. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  6447. support.optSelected = opt.selected;
  6448. // Tests for enctype support on a form (#6743)
  6449. support.enctype = !!document.createElement("form").enctype;
  6450. // Make sure that the options inside disabled selects aren't marked as disabled
  6451. // (WebKit marks them as disabled)
  6452. select.disabled = true;
  6453. support.optDisabled = !opt.disabled;
  6454. // Support: IE8 only
  6455. // Check if we can trust getAttribute("value")
  6456. input = document.createElement( "input" );
  6457. input.setAttribute( "value", "" );
  6458. support.input = input.getAttribute( "value" ) === "";
  6459. // Check if an input maintains its value after becoming a radio
  6460. input.value = "t";
  6461. input.setAttribute( "type", "radio" );
  6462. support.radioValue = input.value === "t";
  6463. })();
  6464. var rreturn = /\r/g;
  6465. jQuery.fn.extend({
  6466. val: function( value ) {
  6467. var hooks, ret, isFunction,
  6468. elem = this[0];
  6469. if ( !arguments.length ) {
  6470. if ( elem ) {
  6471. hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6472. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  6473. return ret;
  6474. }
  6475. ret = elem.value;
  6476. return typeof ret === "string" ?
  6477. // handle most common string cases
  6478. ret.replace(rreturn, "") :
  6479. // handle cases where value is null/undef or number
  6480. ret == null ? "" : ret;
  6481. }
  6482. return;
  6483. }
  6484. isFunction = jQuery.isFunction( value );
  6485. return this.each(function( i ) {
  6486. var val;
  6487. if ( this.nodeType !== 1 ) {
  6488. return;
  6489. }
  6490. if ( isFunction ) {
  6491. val = value.call( this, i, jQuery( this ).val() );
  6492. } else {
  6493. val = value;
  6494. }
  6495. // Treat null/undefined as ""; convert numbers to string
  6496. if ( val == null ) {
  6497. val = "";
  6498. } else if ( typeof val === "number" ) {
  6499. val += "";
  6500. } else if ( jQuery.isArray( val ) ) {
  6501. val = jQuery.map( val, function( value ) {
  6502. return value == null ? "" : value + "";
  6503. });
  6504. }
  6505. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6506. // If set returns undefined, fall back to normal setting
  6507. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  6508. this.value = val;
  6509. }
  6510. });
  6511. }
  6512. });
  6513. jQuery.extend({
  6514. valHooks: {
  6515. option: {
  6516. get: function( elem ) {
  6517. var val = jQuery.find.attr( elem, "value" );
  6518. return val != null ?
  6519. val :
  6520. // Support: IE10-11+
  6521. // option.text throws exceptions (#14686, #14858)
  6522. jQuery.trim( jQuery.text( elem ) );
  6523. }
  6524. },
  6525. select: {
  6526. get: function( elem ) {
  6527. var value, option,
  6528. options = elem.options,
  6529. index = elem.selectedIndex,
  6530. one = elem.type === "select-one" || index < 0,
  6531. values = one ? null : [],
  6532. max = one ? index + 1 : options.length,
  6533. i = index < 0 ?
  6534. max :
  6535. one ? index : 0;
  6536. // Loop through all the selected options
  6537. for ( ; i < max; i++ ) {
  6538. option = options[ i ];
  6539. // oldIE doesn't update selected after form reset (#2551)
  6540. if ( ( option.selected || i === index ) &&
  6541. // Don't return options that are disabled or in a disabled optgroup
  6542. ( support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
  6543. ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
  6544. // Get the specific value for the option
  6545. value = jQuery( option ).val();
  6546. // We don't need an array for one selects
  6547. if ( one ) {
  6548. return value;
  6549. }
  6550. // Multi-Selects return an array
  6551. values.push( value );
  6552. }
  6553. }
  6554. return values;
  6555. },
  6556. set: function( elem, value ) {
  6557. var optionSet, option,
  6558. options = elem.options,
  6559. values = jQuery.makeArray( value ),
  6560. i = options.length;
  6561. while ( i-- ) {
  6562. option = options[ i ];
  6563. if ( jQuery.inArray( jQuery.valHooks.option.get( option ), values ) >= 0 ) {
  6564. // Support: IE6
  6565. // When new option element is added to select box we need to
  6566. // force reflow of newly added node in order to workaround delay
  6567. // of initialization properties
  6568. try {
  6569. option.selected = optionSet = true;
  6570. } catch ( _ ) {
  6571. // Will be executed only in IE6
  6572. option.scrollHeight;
  6573. }
  6574. } else {
  6575. option.selected = false;
  6576. }
  6577. }
  6578. // Force browsers to behave consistently when non-matching value is set
  6579. if ( !optionSet ) {
  6580. elem.selectedIndex = -1;
  6581. }
  6582. return options;
  6583. }
  6584. }
  6585. }
  6586. });
  6587. // Radios and checkboxes getter/setter
  6588. jQuery.each([ "radio", "checkbox" ], function() {
  6589. jQuery.valHooks[ this ] = {
  6590. set: function( elem, value ) {
  6591. if ( jQuery.isArray( value ) ) {
  6592. return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
  6593. }
  6594. }
  6595. };
  6596. if ( !support.checkOn ) {
  6597. jQuery.valHooks[ this ].get = function( elem ) {
  6598. // Support: Webkit
  6599. // "" is returned instead of "on" if a value isn't specified
  6600. return elem.getAttribute("value") === null ? "on" : elem.value;
  6601. };
  6602. }
  6603. });
  6604. var nodeHook, boolHook,
  6605. attrHandle = jQuery.expr.attrHandle,
  6606. ruseDefault = /^(?:checked|selected)$/i,
  6607. getSetAttribute = support.getSetAttribute,
  6608. getSetInput = support.input;
  6609. jQuery.fn.extend({
  6610. attr: function( name, value ) {
  6611. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6612. },
  6613. removeAttr: function( name ) {
  6614. return this.each(function() {
  6615. jQuery.removeAttr( this, name );
  6616. });
  6617. }
  6618. });
  6619. jQuery.extend({
  6620. attr: function( elem, name, value ) {
  6621. var hooks, ret,
  6622. nType = elem.nodeType;
  6623. // don't get/set attributes on text, comment and attribute nodes
  6624. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6625. return;
  6626. }
  6627. // Fallback to prop when attributes are not supported
  6628. if ( typeof elem.getAttribute === strundefined ) {
  6629. return jQuery.prop( elem, name, value );
  6630. }
  6631. // All attributes are lowercase
  6632. // Grab necessary hook if one is defined
  6633. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6634. name = name.toLowerCase();
  6635. hooks = jQuery.attrHooks[ name ] ||
  6636. ( jQuery.expr.match.bool.test( name ) ? boolHook : nodeHook );
  6637. }
  6638. if ( value !== undefined ) {
  6639. if ( value === null ) {
  6640. jQuery.removeAttr( elem, name );
  6641. } else if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  6642. return ret;
  6643. } else {
  6644. elem.setAttribute( name, value + "" );
  6645. return value;
  6646. }
  6647. } else if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  6648. return ret;
  6649. } else {
  6650. ret = jQuery.find.attr( elem, name );
  6651. // Non-existent attributes return null, we normalize to undefined
  6652. return ret == null ?
  6653. undefined :
  6654. ret;
  6655. }
  6656. },
  6657. removeAttr: function( elem, value ) {
  6658. var name, propName,
  6659. i = 0,
  6660. attrNames = value && value.match( rnotwhite );
  6661. if ( attrNames && elem.nodeType === 1 ) {
  6662. while ( (name = attrNames[i++]) ) {
  6663. propName = jQuery.propFix[ name ] || name;
  6664. // Boolean attributes get special treatment (#10870)
  6665. if ( jQuery.expr.match.bool.test( name ) ) {
  6666. // Set corresponding property to false
  6667. if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6668. elem[ propName ] = false;
  6669. // Support: IE<9
  6670. // Also clear defaultChecked/defaultSelected (if appropriate)
  6671. } else {
  6672. elem[ jQuery.camelCase( "default-" + name ) ] =
  6673. elem[ propName ] = false;
  6674. }
  6675. // See #9699 for explanation of this approach (setting first, then removal)
  6676. } else {
  6677. jQuery.attr( elem, name, "" );
  6678. }
  6679. elem.removeAttribute( getSetAttribute ? name : propName );
  6680. }
  6681. }
  6682. },
  6683. attrHooks: {
  6684. type: {
  6685. set: function( elem, value ) {
  6686. if ( !support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
  6687. // Setting the type on a radio button after the value resets the value in IE6-9
  6688. // Reset value to default in case type is set after value during creation
  6689. var val = elem.value;
  6690. elem.setAttribute( "type", value );
  6691. if ( val ) {
  6692. elem.value = val;
  6693. }
  6694. return value;
  6695. }
  6696. }
  6697. }
  6698. }
  6699. });
  6700. // Hook for boolean attributes
  6701. boolHook = {
  6702. set: function( elem, value, name ) {
  6703. if ( value === false ) {
  6704. // Remove boolean attributes when set to false
  6705. jQuery.removeAttr( elem, name );
  6706. } else if ( getSetInput && getSetAttribute || !ruseDefault.test( name ) ) {
  6707. // IE<8 needs the *property* name
  6708. elem.setAttribute( !getSetAttribute && jQuery.propFix[ name ] || name, name );
  6709. // Use defaultChecked and defaultSelected for oldIE
  6710. } else {
  6711. elem[ jQuery.camelCase( "default-" + name ) ] = elem[ name ] = true;
  6712. }
  6713. return name;
  6714. }
  6715. };
  6716. // Retrieve booleans specially
  6717. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6718. var getter = attrHandle[ name ] || jQuery.find.attr;
  6719. attrHandle[ name ] = getSetInput && getSetAttribute || !ruseDefault.test( name ) ?
  6720. function( elem, name, isXML ) {
  6721. var ret, handle;
  6722. if ( !isXML ) {
  6723. // Avoid an infinite loop by temporarily removing this function from the getter
  6724. handle = attrHandle[ name ];
  6725. attrHandle[ name ] = ret;
  6726. ret = getter( elem, name, isXML ) != null ?
  6727. name.toLowerCase() :
  6728. null;
  6729. attrHandle[ name ] = handle;
  6730. }
  6731. return ret;
  6732. } :
  6733. function( elem, name, isXML ) {
  6734. if ( !isXML ) {
  6735. return elem[ jQuery.camelCase( "default-" + name ) ] ?
  6736. name.toLowerCase() :
  6737. null;
  6738. }
  6739. };
  6740. });
  6741. // fix oldIE attroperties
  6742. if ( !getSetInput || !getSetAttribute ) {
  6743. jQuery.attrHooks.value = {
  6744. set: function( elem, value, name ) {
  6745. if ( jQuery.nodeName( elem, "input" ) ) {
  6746. // Does not return so that setAttribute is also used
  6747. elem.defaultValue = value;
  6748. } else {
  6749. // Use nodeHook if defined (#1954); otherwise setAttribute is fine
  6750. return nodeHook && nodeHook.set( elem, value, name );
  6751. }
  6752. }
  6753. };
  6754. }
  6755. // IE6/7 do not support getting/setting some attributes with get/setAttribute
  6756. if ( !getSetAttribute ) {
  6757. // Use this for any attribute in IE6/7
  6758. // This fixes almost every IE6/7 issue
  6759. nodeHook = {
  6760. set: function( elem, value, name ) {
  6761. // Set the existing or create a new attribute node
  6762. var ret = elem.getAttributeNode( name );
  6763. if ( !ret ) {
  6764. elem.setAttributeNode(
  6765. (ret = elem.ownerDocument.createAttribute( name ))
  6766. );
  6767. }
  6768. ret.value = value += "";
  6769. // Break association with cloned elements by also using setAttribute (#9646)
  6770. if ( name === "value" || value === elem.getAttribute( name ) ) {
  6771. return value;
  6772. }
  6773. }
  6774. };
  6775. // Some attributes are constructed with empty-string values when not defined
  6776. attrHandle.id = attrHandle.name = attrHandle.coords =
  6777. function( elem, name, isXML ) {
  6778. var ret;
  6779. if ( !isXML ) {
  6780. return (ret = elem.getAttributeNode( name )) && ret.value !== "" ?
  6781. ret.value :
  6782. null;
  6783. }
  6784. };
  6785. // Fixing value retrieval on a button requires this module
  6786. jQuery.valHooks.button = {
  6787. get: function( elem, name ) {
  6788. var ret = elem.getAttributeNode( name );
  6789. if ( ret && ret.specified ) {
  6790. return ret.value;
  6791. }
  6792. },
  6793. set: nodeHook.set
  6794. };
  6795. // Set contenteditable to false on removals(#10429)
  6796. // Setting to empty string throws an error as an invalid value
  6797. jQuery.attrHooks.contenteditable = {
  6798. set: function( elem, value, name ) {
  6799. nodeHook.set( elem, value === "" ? false : value, name );
  6800. }
  6801. };
  6802. // Set width and height to auto instead of 0 on empty string( Bug #8150 )
  6803. // This is for removals
  6804. jQuery.each([ "width", "height" ], function( i, name ) {
  6805. jQuery.attrHooks[ name ] = {
  6806. set: function( elem, value ) {
  6807. if ( value === "" ) {
  6808. elem.setAttribute( name, "auto" );
  6809. return value;
  6810. }
  6811. }
  6812. };
  6813. });
  6814. }
  6815. if ( !support.style ) {
  6816. jQuery.attrHooks.style = {
  6817. get: function( elem ) {
  6818. // Return undefined in the case of empty string
  6819. // Note: IE uppercases css property names, but if we were to .toLowerCase()
  6820. // .cssText, that would destroy case senstitivity in URL's, like in "background"
  6821. return elem.style.cssText || undefined;
  6822. },
  6823. set: function( elem, value ) {
  6824. return ( elem.style.cssText = value + "" );
  6825. }
  6826. };
  6827. }
  6828. var rfocusable = /^(?:input|select|textarea|button|object)$/i,
  6829. rclickable = /^(?:a|area)$/i;
  6830. jQuery.fn.extend({
  6831. prop: function( name, value ) {
  6832. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6833. },
  6834. removeProp: function( name ) {
  6835. name = jQuery.propFix[ name ] || name;
  6836. return this.each(function() {
  6837. // try/catch handles cases where IE balks (such as removing a property on window)
  6838. try {
  6839. this[ name ] = undefined;
  6840. delete this[ name ];
  6841. } catch( e ) {}
  6842. });
  6843. }
  6844. });
  6845. jQuery.extend({
  6846. propFix: {
  6847. "for": "htmlFor",
  6848. "class": "className"
  6849. },
  6850. prop: function( elem, name, value ) {
  6851. var ret, hooks, notxml,
  6852. nType = elem.nodeType;
  6853. // don't get/set properties on text, comment and attribute nodes
  6854. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  6855. return;
  6856. }
  6857. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  6858. if ( notxml ) {
  6859. // Fix name and attach hooks
  6860. name = jQuery.propFix[ name ] || name;
  6861. hooks = jQuery.propHooks[ name ];
  6862. }
  6863. if ( value !== undefined ) {
  6864. return hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ?
  6865. ret :
  6866. ( elem[ name ] = value );
  6867. } else {
  6868. return hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ?
  6869. ret :
  6870. elem[ name ];
  6871. }
  6872. },
  6873. propHooks: {
  6874. tabIndex: {
  6875. get: function( elem ) {
  6876. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  6877. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  6878. // Use proper attribute retrieval(#12072)
  6879. var tabindex = jQuery.find.attr( elem, "tabindex" );
  6880. return tabindex ?
  6881. parseInt( tabindex, 10 ) :
  6882. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  6883. 0 :
  6884. -1;
  6885. }
  6886. }
  6887. }
  6888. });
  6889. // Some attributes require a special call on IE
  6890. // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  6891. if ( !support.hrefNormalized ) {
  6892. // href/src property should get the full normalized URL (#10299/#12915)
  6893. jQuery.each([ "href", "src" ], function( i, name ) {
  6894. jQuery.propHooks[ name ] = {
  6895. get: function( elem ) {
  6896. return elem.getAttribute( name, 4 );
  6897. }
  6898. };
  6899. });
  6900. }
  6901. // Support: Safari, IE9+
  6902. // mis-reports the default selected property of an option
  6903. // Accessing the parent's selectedIndex property fixes it
  6904. if ( !support.optSelected ) {
  6905. jQuery.propHooks.selected = {
  6906. get: function( elem ) {
  6907. var parent = elem.parentNode;
  6908. if ( parent ) {
  6909. parent.selectedIndex;
  6910. // Make sure that it also works with optgroups, see #5701
  6911. if ( parent.parentNode ) {
  6912. parent.parentNode.selectedIndex;
  6913. }
  6914. }
  6915. return null;
  6916. }
  6917. };
  6918. }
  6919. jQuery.each([
  6920. "tabIndex",
  6921. "readOnly",
  6922. "maxLength",
  6923. "cellSpacing",
  6924. "cellPadding",
  6925. "rowSpan",
  6926. "colSpan",
  6927. "useMap",
  6928. "frameBorder",
  6929. "contentEditable"
  6930. ], function() {
  6931. jQuery.propFix[ this.toLowerCase() ] = this;
  6932. });
  6933. // IE6/7 call enctype encoding
  6934. if ( !support.enctype ) {
  6935. jQuery.propFix.enctype = "encoding";
  6936. }
  6937. var rclass = /[\t\r\n\f]/g;
  6938. jQuery.fn.extend({
  6939. addClass: function( value ) {
  6940. var classes, elem, cur, clazz, j, finalValue,
  6941. i = 0,
  6942. len = this.length,
  6943. proceed = typeof value === "string" && value;
  6944. if ( jQuery.isFunction( value ) ) {
  6945. return this.each(function( j ) {
  6946. jQuery( this ).addClass( value.call( this, j, this.className ) );
  6947. });
  6948. }
  6949. if ( proceed ) {
  6950. // The disjunction here is for better compressibility (see removeClass)
  6951. classes = ( value || "" ).match( rnotwhite ) || [];
  6952. for ( ; i < len; i++ ) {
  6953. elem = this[ i ];
  6954. cur = elem.nodeType === 1 && ( elem.className ?
  6955. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6956. " "
  6957. );
  6958. if ( cur ) {
  6959. j = 0;
  6960. while ( (clazz = classes[j++]) ) {
  6961. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6962. cur += clazz + " ";
  6963. }
  6964. }
  6965. // only assign if different to avoid unneeded rendering.
  6966. finalValue = jQuery.trim( cur );
  6967. if ( elem.className !== finalValue ) {
  6968. elem.className = finalValue;
  6969. }
  6970. }
  6971. }
  6972. }
  6973. return this;
  6974. },
  6975. removeClass: function( value ) {
  6976. var classes, elem, cur, clazz, j, finalValue,
  6977. i = 0,
  6978. len = this.length,
  6979. proceed = arguments.length === 0 || typeof value === "string" && value;
  6980. if ( jQuery.isFunction( value ) ) {
  6981. return this.each(function( j ) {
  6982. jQuery( this ).removeClass( value.call( this, j, this.className ) );
  6983. });
  6984. }
  6985. if ( proceed ) {
  6986. classes = ( value || "" ).match( rnotwhite ) || [];
  6987. for ( ; i < len; i++ ) {
  6988. elem = this[ i ];
  6989. // This expression is here for better compressibility (see addClass)
  6990. cur = elem.nodeType === 1 && ( elem.className ?
  6991. ( " " + elem.className + " " ).replace( rclass, " " ) :
  6992. ""
  6993. );
  6994. if ( cur ) {
  6995. j = 0;
  6996. while ( (clazz = classes[j++]) ) {
  6997. // Remove *all* instances
  6998. while ( cur.indexOf( " " + clazz + " " ) >= 0 ) {
  6999. cur = cur.replace( " " + clazz + " ", " " );
  7000. }
  7001. }
  7002. // only assign if different to avoid unneeded rendering.
  7003. finalValue = value ? jQuery.trim( cur ) : "";
  7004. if ( elem.className !== finalValue ) {
  7005. elem.className = finalValue;
  7006. }
  7007. }
  7008. }
  7009. }
  7010. return this;
  7011. },
  7012. toggleClass: function( value, stateVal ) {
  7013. var type = typeof value;
  7014. if ( typeof stateVal === "boolean" && type === "string" ) {
  7015. return stateVal ? this.addClass( value ) : this.removeClass( value );
  7016. }
  7017. if ( jQuery.isFunction( value ) ) {
  7018. return this.each(function( i ) {
  7019. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  7020. });
  7021. }
  7022. return this.each(function() {
  7023. if ( type === "string" ) {
  7024. // toggle individual class names
  7025. var className,
  7026. i = 0,
  7027. self = jQuery( this ),
  7028. classNames = value.match( rnotwhite ) || [];
  7029. while ( (className = classNames[ i++ ]) ) {
  7030. // check each className given, space separated list
  7031. if ( self.hasClass( className ) ) {
  7032. self.removeClass( className );
  7033. } else {
  7034. self.addClass( className );
  7035. }
  7036. }
  7037. // Toggle whole class name
  7038. } else if ( type === strundefined || type === "boolean" ) {
  7039. if ( this.className ) {
  7040. // store className if set
  7041. jQuery._data( this, "__className__", this.className );
  7042. }
  7043. // If the element has a class name or if we're passed "false",
  7044. // then remove the whole classname (if there was one, the above saved it).
  7045. // Otherwise bring back whatever was previously saved (if anything),
  7046. // falling back to the empty string if nothing was stored.
  7047. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  7048. }
  7049. });
  7050. },
  7051. hasClass: function( selector ) {
  7052. var className = " " + selector + " ",
  7053. i = 0,
  7054. l = this.length;
  7055. for ( ; i < l; i++ ) {
  7056. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
  7057. return true;
  7058. }
  7059. }
  7060. return false;
  7061. }
  7062. });
  7063. // Return jQuery for attributes-only inclusion
  7064. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  7065. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  7066. "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) {
  7067. // Handle event binding
  7068. jQuery.fn[ name ] = function( data, fn ) {
  7069. return arguments.length > 0 ?
  7070. this.on( name, null, data, fn ) :
  7071. this.trigger( name );
  7072. };
  7073. });
  7074. jQuery.fn.extend({
  7075. hover: function( fnOver, fnOut ) {
  7076. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  7077. },
  7078. bind: function( types, data, fn ) {
  7079. return this.on( types, null, data, fn );
  7080. },
  7081. unbind: function( types, fn ) {
  7082. return this.off( types, null, fn );
  7083. },
  7084. delegate: function( selector, types, data, fn ) {
  7085. return this.on( types, selector, data, fn );
  7086. },
  7087. undelegate: function( selector, types, fn ) {
  7088. // ( namespace ) or ( selector, types [, fn] )
  7089. return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
  7090. }
  7091. });
  7092. var nonce = jQuery.now();
  7093. var rquery = (/\?/);
  7094. var rvalidtokens = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;
  7095. jQuery.parseJSON = function( data ) {
  7096. // Attempt to parse using the native JSON parser first
  7097. if ( window.JSON && window.JSON.parse ) {
  7098. // Support: Android 2.3
  7099. // Workaround failure to string-cast null input
  7100. return window.JSON.parse( data + "" );
  7101. }
  7102. var requireNonComma,
  7103. depth = null,
  7104. str = jQuery.trim( data + "" );
  7105. // Guard against invalid (and possibly dangerous) input by ensuring that nothing remains
  7106. // after removing valid tokens
  7107. return str && !jQuery.trim( str.replace( rvalidtokens, function( token, comma, open, close ) {
  7108. // Force termination if we see a misplaced comma
  7109. if ( requireNonComma && comma ) {
  7110. depth = 0;
  7111. }
  7112. // Perform no more replacements after returning to outermost depth
  7113. if ( depth === 0 ) {
  7114. return token;
  7115. }
  7116. // Commas must not follow "[", "{", or ","
  7117. requireNonComma = open || comma;
  7118. // Determine new depth
  7119. // array/object open ("[" or "{"): depth += true - false (increment)
  7120. // array/object close ("]" or "}"): depth += false - true (decrement)
  7121. // other cases ("," or primitive): depth += true - true (numeric cast)
  7122. depth += !close - !open;
  7123. // Remove this token
  7124. return "";
  7125. }) ) ?
  7126. ( Function( "return " + str ) )() :
  7127. jQuery.error( "Invalid JSON: " + data );
  7128. };
  7129. // Cross-browser xml parsing
  7130. jQuery.parseXML = function( data ) {
  7131. var xml, tmp;
  7132. if ( !data || typeof data !== "string" ) {
  7133. return null;
  7134. }
  7135. try {
  7136. if ( window.DOMParser ) { // Standard
  7137. tmp = new DOMParser();
  7138. xml = tmp.parseFromString( data, "text/xml" );
  7139. } else { // IE
  7140. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  7141. xml.async = "false";
  7142. xml.loadXML( data );
  7143. }
  7144. } catch( e ) {
  7145. xml = undefined;
  7146. }
  7147. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  7148. jQuery.error( "Invalid XML: " + data );
  7149. }
  7150. return xml;
  7151. };
  7152. var
  7153. // Document location
  7154. ajaxLocParts,
  7155. ajaxLocation,
  7156. rhash = /#.*$/,
  7157. rts = /([?&])_=[^&]*/,
  7158. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  7159. // #7653, #8125, #8152: local protocol detection
  7160. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  7161. rnoContent = /^(?:GET|HEAD)$/,
  7162. rprotocol = /^\/\//,
  7163. rurl = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,
  7164. /* Prefilters
  7165. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7166. * 2) These are called:
  7167. * - BEFORE asking for a transport
  7168. * - AFTER param serialization (s.data is a string if s.processData is true)
  7169. * 3) key is the dataType
  7170. * 4) the catchall symbol "*" can be used
  7171. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7172. */
  7173. prefilters = {},
  7174. /* Transports bindings
  7175. * 1) key is the dataType
  7176. * 2) the catchall symbol "*" can be used
  7177. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7178. */
  7179. transports = {},
  7180. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7181. allTypes = "*/".concat("*");
  7182. // #8138, IE may throw an exception when accessing
  7183. // a field from window.location if document.domain has been set
  7184. try {
  7185. ajaxLocation = location.href;
  7186. } catch( e ) {
  7187. // Use the href attribute of an A element
  7188. // since IE will modify it given document.location
  7189. ajaxLocation = document.createElement( "a" );
  7190. ajaxLocation.href = "";
  7191. ajaxLocation = ajaxLocation.href;
  7192. }
  7193. // Segment location into parts
  7194. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  7195. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7196. function addToPrefiltersOrTransports( structure ) {
  7197. // dataTypeExpression is optional and defaults to "*"
  7198. return function( dataTypeExpression, func ) {
  7199. if ( typeof dataTypeExpression !== "string" ) {
  7200. func = dataTypeExpression;
  7201. dataTypeExpression = "*";
  7202. }
  7203. var dataType,
  7204. i = 0,
  7205. dataTypes = dataTypeExpression.toLowerCase().match( rnotwhite ) || [];
  7206. if ( jQuery.isFunction( func ) ) {
  7207. // For each dataType in the dataTypeExpression
  7208. while ( (dataType = dataTypes[i++]) ) {
  7209. // Prepend if requested
  7210. if ( dataType.charAt( 0 ) === "+" ) {
  7211. dataType = dataType.slice( 1 ) || "*";
  7212. (structure[ dataType ] = structure[ dataType ] || []).unshift( func );
  7213. // Otherwise append
  7214. } else {
  7215. (structure[ dataType ] = structure[ dataType ] || []).push( func );
  7216. }
  7217. }
  7218. }
  7219. };
  7220. }
  7221. // Base inspection function for prefilters and transports
  7222. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  7223. var inspected = {},
  7224. seekingTransport = ( structure === transports );
  7225. function inspect( dataType ) {
  7226. var selected;
  7227. inspected[ dataType ] = true;
  7228. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  7229. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  7230. if ( typeof dataTypeOrTransport === "string" && !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  7231. options.dataTypes.unshift( dataTypeOrTransport );
  7232. inspect( dataTypeOrTransport );
  7233. return false;
  7234. } else if ( seekingTransport ) {
  7235. return !( selected = dataTypeOrTransport );
  7236. }
  7237. });
  7238. return selected;
  7239. }
  7240. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  7241. }
  7242. // A special extend for ajax options
  7243. // that takes "flat" options (not to be deep extended)
  7244. // Fixes #9887
  7245. function ajaxExtend( target, src ) {
  7246. var deep, key,
  7247. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7248. for ( key in src ) {
  7249. if ( src[ key ] !== undefined ) {
  7250. ( flatOptions[ key ] ? target : ( deep || (deep = {}) ) )[ key ] = src[ key ];
  7251. }
  7252. }
  7253. if ( deep ) {
  7254. jQuery.extend( true, target, deep );
  7255. }
  7256. return target;
  7257. }
  7258. /* Handles responses to an ajax request:
  7259. * - finds the right dataType (mediates between content-type and expected dataType)
  7260. * - returns the corresponding response
  7261. */
  7262. function ajaxHandleResponses( s, jqXHR, responses ) {
  7263. var firstDataType, ct, finalDataType, type,
  7264. contents = s.contents,
  7265. dataTypes = s.dataTypes;
  7266. // Remove auto dataType and get content-type in the process
  7267. while ( dataTypes[ 0 ] === "*" ) {
  7268. dataTypes.shift();
  7269. if ( ct === undefined ) {
  7270. ct = s.mimeType || jqXHR.getResponseHeader("Content-Type");
  7271. }
  7272. }
  7273. // Check if we're dealing with a known content-type
  7274. if ( ct ) {
  7275. for ( type in contents ) {
  7276. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  7277. dataTypes.unshift( type );
  7278. break;
  7279. }
  7280. }
  7281. }
  7282. // Check to see if we have a response for the expected dataType
  7283. if ( dataTypes[ 0 ] in responses ) {
  7284. finalDataType = dataTypes[ 0 ];
  7285. } else {
  7286. // Try convertible dataTypes
  7287. for ( type in responses ) {
  7288. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  7289. finalDataType = type;
  7290. break;
  7291. }
  7292. if ( !firstDataType ) {
  7293. firstDataType = type;
  7294. }
  7295. }
  7296. // Or just use first one
  7297. finalDataType = finalDataType || firstDataType;
  7298. }
  7299. // If we found a dataType
  7300. // We add the dataType to the list if needed
  7301. // and return the corresponding response
  7302. if ( finalDataType ) {
  7303. if ( finalDataType !== dataTypes[ 0 ] ) {
  7304. dataTypes.unshift( finalDataType );
  7305. }
  7306. return responses[ finalDataType ];
  7307. }
  7308. }
  7309. /* Chain conversions given the request and the original response
  7310. * Also sets the responseXXX fields on the jqXHR instance
  7311. */
  7312. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  7313. var conv2, current, conv, tmp, prev,
  7314. converters = {},
  7315. // Work with a copy of dataTypes in case we need to modify it for conversion
  7316. dataTypes = s.dataTypes.slice();
  7317. // Create converters map with lowercased keys
  7318. if ( dataTypes[ 1 ] ) {
  7319. for ( conv in s.converters ) {
  7320. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  7321. }
  7322. }
  7323. current = dataTypes.shift();
  7324. // Convert to each sequential dataType
  7325. while ( current ) {
  7326. if ( s.responseFields[ current ] ) {
  7327. jqXHR[ s.responseFields[ current ] ] = response;
  7328. }
  7329. // Apply the dataFilter if provided
  7330. if ( !prev && isSuccess && s.dataFilter ) {
  7331. response = s.dataFilter( response, s.dataType );
  7332. }
  7333. prev = current;
  7334. current = dataTypes.shift();
  7335. if ( current ) {
  7336. // There's only work to do if current dataType is non-auto
  7337. if ( current === "*" ) {
  7338. current = prev;
  7339. // Convert response if prev dataType is non-auto and differs from current
  7340. } else if ( prev !== "*" && prev !== current ) {
  7341. // Seek a direct converter
  7342. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  7343. // If none found, seek a pair
  7344. if ( !conv ) {
  7345. for ( conv2 in converters ) {
  7346. // If conv2 outputs current
  7347. tmp = conv2.split( " " );
  7348. if ( tmp[ 1 ] === current ) {
  7349. // If prev can be converted to accepted input
  7350. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  7351. converters[ "* " + tmp[ 0 ] ];
  7352. if ( conv ) {
  7353. // Condense equivalence converters
  7354. if ( conv === true ) {
  7355. conv = converters[ conv2 ];
  7356. // Otherwise, insert the intermediate dataType
  7357. } else if ( converters[ conv2 ] !== true ) {
  7358. current = tmp[ 0 ];
  7359. dataTypes.unshift( tmp[ 1 ] );
  7360. }
  7361. break;
  7362. }
  7363. }
  7364. }
  7365. }
  7366. // Apply converter (if not an equivalence)
  7367. if ( conv !== true ) {
  7368. // Unless errors are allowed to bubble, catch and return them
  7369. if ( conv && s[ "throws" ] ) {
  7370. response = conv( response );
  7371. } else {
  7372. try {
  7373. response = conv( response );
  7374. } catch ( e ) {
  7375. return { state: "parsererror", error: conv ? e : "No conversion from " + prev + " to " + current };
  7376. }
  7377. }
  7378. }
  7379. }
  7380. }
  7381. }
  7382. return { state: "success", data: response };
  7383. }
  7384. jQuery.extend({
  7385. // Counter for holding the number of active queries
  7386. active: 0,
  7387. // Last-Modified header cache for next request
  7388. lastModified: {},
  7389. etag: {},
  7390. ajaxSettings: {
  7391. url: ajaxLocation,
  7392. type: "GET",
  7393. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  7394. global: true,
  7395. processData: true,
  7396. async: true,
  7397. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  7398. /*
  7399. timeout: 0,
  7400. data: null,
  7401. dataType: null,
  7402. username: null,
  7403. password: null,
  7404. cache: null,
  7405. throws: false,
  7406. traditional: false,
  7407. headers: {},
  7408. */
  7409. accepts: {
  7410. "*": allTypes,
  7411. text: "text/plain",
  7412. html: "text/html",
  7413. xml: "application/xml, text/xml",
  7414. json: "application/json, text/javascript"
  7415. },
  7416. contents: {
  7417. xml: /xml/,
  7418. html: /html/,
  7419. json: /json/
  7420. },
  7421. responseFields: {
  7422. xml: "responseXML",
  7423. text: "responseText",
  7424. json: "responseJSON"
  7425. },
  7426. // Data converters
  7427. // Keys separate source (or catchall "*") and destination types with a single space
  7428. converters: {
  7429. // Convert anything to text
  7430. "* text": String,
  7431. // Text to html (true = no transformation)
  7432. "text html": true,
  7433. // Evaluate text as a json expression
  7434. "text json": jQuery.parseJSON,
  7435. // Parse text as xml
  7436. "text xml": jQuery.parseXML
  7437. },
  7438. // For options that shouldn't be deep extended:
  7439. // you can add your own custom options here if
  7440. // and when you create one that shouldn't be
  7441. // deep extended (see ajaxExtend)
  7442. flatOptions: {
  7443. url: true,
  7444. context: true
  7445. }
  7446. },
  7447. // Creates a full fledged settings object into target
  7448. // with both ajaxSettings and settings fields.
  7449. // If target is omitted, writes into ajaxSettings.
  7450. ajaxSetup: function( target, settings ) {
  7451. return settings ?
  7452. // Building a settings object
  7453. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  7454. // Extending ajaxSettings
  7455. ajaxExtend( jQuery.ajaxSettings, target );
  7456. },
  7457. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  7458. ajaxTransport: addToPrefiltersOrTransports( transports ),
  7459. // Main method
  7460. ajax: function( url, options ) {
  7461. // If url is an object, simulate pre-1.5 signature
  7462. if ( typeof url === "object" ) {
  7463. options = url;
  7464. url = undefined;
  7465. }
  7466. // Force options to be an object
  7467. options = options || {};
  7468. var // Cross-domain detection vars
  7469. parts,
  7470. // Loop variable
  7471. i,
  7472. // URL without anti-cache param
  7473. cacheURL,
  7474. // Response headers as string
  7475. responseHeadersString,
  7476. // timeout handle
  7477. timeoutTimer,
  7478. // To know if global events are to be dispatched
  7479. fireGlobals,
  7480. transport,
  7481. // Response headers
  7482. responseHeaders,
  7483. // Create the final options object
  7484. s = jQuery.ajaxSetup( {}, options ),
  7485. // Callbacks context
  7486. callbackContext = s.context || s,
  7487. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  7488. globalEventContext = s.context && ( callbackContext.nodeType || callbackContext.jquery ) ?
  7489. jQuery( callbackContext ) :
  7490. jQuery.event,
  7491. // Deferreds
  7492. deferred = jQuery.Deferred(),
  7493. completeDeferred = jQuery.Callbacks("once memory"),
  7494. // Status-dependent callbacks
  7495. statusCode = s.statusCode || {},
  7496. // Headers (they are sent all at once)
  7497. requestHeaders = {},
  7498. requestHeadersNames = {},
  7499. // The jqXHR state
  7500. state = 0,
  7501. // Default abort message
  7502. strAbort = "canceled",
  7503. // Fake xhr
  7504. jqXHR = {
  7505. readyState: 0,
  7506. // Builds headers hashtable if needed
  7507. getResponseHeader: function( key ) {
  7508. var match;
  7509. if ( state === 2 ) {
  7510. if ( !responseHeaders ) {
  7511. responseHeaders = {};
  7512. while ( (match = rheaders.exec( responseHeadersString )) ) {
  7513. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  7514. }
  7515. }
  7516. match = responseHeaders[ key.toLowerCase() ];
  7517. }
  7518. return match == null ? null : match;
  7519. },
  7520. // Raw string
  7521. getAllResponseHeaders: function() {
  7522. return state === 2 ? responseHeadersString : null;
  7523. },
  7524. // Caches the header
  7525. setRequestHeader: function( name, value ) {
  7526. var lname = name.toLowerCase();
  7527. if ( !state ) {
  7528. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  7529. requestHeaders[ name ] = value;
  7530. }
  7531. return this;
  7532. },
  7533. // Overrides response content-type header
  7534. overrideMimeType: function( type ) {
  7535. if ( !state ) {
  7536. s.mimeType = type;
  7537. }
  7538. return this;
  7539. },
  7540. // Status-dependent callbacks
  7541. statusCode: function( map ) {
  7542. var code;
  7543. if ( map ) {
  7544. if ( state < 2 ) {
  7545. for ( code in map ) {
  7546. // Lazy-add the new callback in a way that preserves old ones
  7547. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7548. }
  7549. } else {
  7550. // Execute the appropriate callbacks
  7551. jqXHR.always( map[ jqXHR.status ] );
  7552. }
  7553. }
  7554. return this;
  7555. },
  7556. // Cancel the request
  7557. abort: function( statusText ) {
  7558. var finalText = statusText || strAbort;
  7559. if ( transport ) {
  7560. transport.abort( finalText );
  7561. }
  7562. done( 0, finalText );
  7563. return this;
  7564. }
  7565. };
  7566. // Attach deferreds
  7567. deferred.promise( jqXHR ).complete = completeDeferred.add;
  7568. jqXHR.success = jqXHR.done;
  7569. jqXHR.error = jqXHR.fail;
  7570. // Remove hash character (#7531: and string promotion)
  7571. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  7572. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7573. // We also use the url parameter if available
  7574. s.url = ( ( url || s.url || ajaxLocation ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  7575. // Alias method option to type as per ticket #12004
  7576. s.type = options.method || options.type || s.method || s.type;
  7577. // Extract dataTypes list
  7578. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().match( rnotwhite ) || [ "" ];
  7579. // A cross-domain request is in order when we have a protocol:host:port mismatch
  7580. if ( s.crossDomain == null ) {
  7581. parts = rurl.exec( s.url.toLowerCase() );
  7582. s.crossDomain = !!( parts &&
  7583. ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
  7584. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? "80" : "443" ) ) !==
  7585. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? "80" : "443" ) ) )
  7586. );
  7587. }
  7588. // Convert data if not already a string
  7589. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7590. s.data = jQuery.param( s.data, s.traditional );
  7591. }
  7592. // Apply prefilters
  7593. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7594. // If request was aborted inside a prefilter, stop there
  7595. if ( state === 2 ) {
  7596. return jqXHR;
  7597. }
  7598. // We can fire global events as of now if asked to
  7599. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  7600. fireGlobals = jQuery.event && s.global;
  7601. // Watch for a new set of requests
  7602. if ( fireGlobals && jQuery.active++ === 0 ) {
  7603. jQuery.event.trigger("ajaxStart");
  7604. }
  7605. // Uppercase the type
  7606. s.type = s.type.toUpperCase();
  7607. // Determine if request has content
  7608. s.hasContent = !rnoContent.test( s.type );
  7609. // Save the URL in case we're toying with the If-Modified-Since
  7610. // and/or If-None-Match header later on
  7611. cacheURL = s.url;
  7612. // More options handling for requests with no content
  7613. if ( !s.hasContent ) {
  7614. // If data is available, append data to url
  7615. if ( s.data ) {
  7616. cacheURL = ( s.url += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data );
  7617. // #9682: remove data so that it's not used in an eventual retry
  7618. delete s.data;
  7619. }
  7620. // Add anti-cache in url if needed
  7621. if ( s.cache === false ) {
  7622. s.url = rts.test( cacheURL ) ?
  7623. // If there is already a '_' parameter, set its value
  7624. cacheURL.replace( rts, "$1_=" + nonce++ ) :
  7625. // Otherwise add one to the end
  7626. cacheURL + ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + nonce++;
  7627. }
  7628. }
  7629. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7630. if ( s.ifModified ) {
  7631. if ( jQuery.lastModified[ cacheURL ] ) {
  7632. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7633. }
  7634. if ( jQuery.etag[ cacheURL ] ) {
  7635. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7636. }
  7637. }
  7638. // Set the correct header, if data is being sent
  7639. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7640. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7641. }
  7642. // Set the Accepts header for the server, depending on the dataType
  7643. jqXHR.setRequestHeader(
  7644. "Accept",
  7645. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  7646. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7647. s.accepts[ "*" ]
  7648. );
  7649. // Check for headers option
  7650. for ( i in s.headers ) {
  7651. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7652. }
  7653. // Allow custom headers/mimetypes and early abort
  7654. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  7655. // Abort if not done already and return
  7656. return jqXHR.abort();
  7657. }
  7658. // aborting is no longer a cancellation
  7659. strAbort = "abort";
  7660. // Install callbacks on deferreds
  7661. for ( i in { success: 1, error: 1, complete: 1 } ) {
  7662. jqXHR[ i ]( s[ i ] );
  7663. }
  7664. // Get transport
  7665. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7666. // If no transport, we auto-abort
  7667. if ( !transport ) {
  7668. done( -1, "No Transport" );
  7669. } else {
  7670. jqXHR.readyState = 1;
  7671. // Send global event
  7672. if ( fireGlobals ) {
  7673. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7674. }
  7675. // Timeout
  7676. if ( s.async && s.timeout > 0 ) {
  7677. timeoutTimer = setTimeout(function() {
  7678. jqXHR.abort("timeout");
  7679. }, s.timeout );
  7680. }
  7681. try {
  7682. state = 1;
  7683. transport.send( requestHeaders, done );
  7684. } catch ( e ) {
  7685. // Propagate exception as error if not done
  7686. if ( state < 2 ) {
  7687. done( -1, e );
  7688. // Simply rethrow otherwise
  7689. } else {
  7690. throw e;
  7691. }
  7692. }
  7693. }
  7694. // Callback for when everything is done
  7695. function done( status, nativeStatusText, responses, headers ) {
  7696. var isSuccess, success, error, response, modified,
  7697. statusText = nativeStatusText;
  7698. // Called once
  7699. if ( state === 2 ) {
  7700. return;
  7701. }
  7702. // State is "done" now
  7703. state = 2;
  7704. // Clear timeout if it exists
  7705. if ( timeoutTimer ) {
  7706. clearTimeout( timeoutTimer );
  7707. }
  7708. // Dereference transport for early garbage collection
  7709. // (no matter how long the jqXHR object will be used)
  7710. transport = undefined;
  7711. // Cache response headers
  7712. responseHeadersString = headers || "";
  7713. // Set readyState
  7714. jqXHR.readyState = status > 0 ? 4 : 0;
  7715. // Determine if successful
  7716. isSuccess = status >= 200 && status < 300 || status === 304;
  7717. // Get response data
  7718. if ( responses ) {
  7719. response = ajaxHandleResponses( s, jqXHR, responses );
  7720. }
  7721. // Convert no matter what (that way responseXXX fields are always set)
  7722. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7723. // If successful, handle type chaining
  7724. if ( isSuccess ) {
  7725. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7726. if ( s.ifModified ) {
  7727. modified = jqXHR.getResponseHeader("Last-Modified");
  7728. if ( modified ) {
  7729. jQuery.lastModified[ cacheURL ] = modified;
  7730. }
  7731. modified = jqXHR.getResponseHeader("etag");
  7732. if ( modified ) {
  7733. jQuery.etag[ cacheURL ] = modified;
  7734. }
  7735. }
  7736. // if no content
  7737. if ( status === 204 || s.type === "HEAD" ) {
  7738. statusText = "nocontent";
  7739. // if not modified
  7740. } else if ( status === 304 ) {
  7741. statusText = "notmodified";
  7742. // If we have data, let's convert it
  7743. } else {
  7744. statusText = response.state;
  7745. success = response.data;
  7746. error = response.error;
  7747. isSuccess = !error;
  7748. }
  7749. } else {
  7750. // We extract error from statusText
  7751. // then normalize statusText and status for non-aborts
  7752. error = statusText;
  7753. if ( status || !statusText ) {
  7754. statusText = "error";
  7755. if ( status < 0 ) {
  7756. status = 0;
  7757. }
  7758. }
  7759. }
  7760. // Set data for the fake xhr object
  7761. jqXHR.status = status;
  7762. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7763. // Success/Error
  7764. if ( isSuccess ) {
  7765. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7766. } else {
  7767. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7768. }
  7769. // Status-dependent callbacks
  7770. jqXHR.statusCode( statusCode );
  7771. statusCode = undefined;
  7772. if ( fireGlobals ) {
  7773. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7774. [ jqXHR, s, isSuccess ? success : error ] );
  7775. }
  7776. // Complete
  7777. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7778. if ( fireGlobals ) {
  7779. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7780. // Handle the global AJAX counter
  7781. if ( !( --jQuery.active ) ) {
  7782. jQuery.event.trigger("ajaxStop");
  7783. }
  7784. }
  7785. }
  7786. return jqXHR;
  7787. },
  7788. getJSON: function( url, data, callback ) {
  7789. return jQuery.get( url, data, callback, "json" );
  7790. },
  7791. getScript: function( url, callback ) {
  7792. return jQuery.get( url, undefined, callback, "script" );
  7793. }
  7794. });
  7795. jQuery.each( [ "get", "post" ], function( i, method ) {
  7796. jQuery[ method ] = function( url, data, callback, type ) {
  7797. // shift arguments if data argument was omitted
  7798. if ( jQuery.isFunction( data ) ) {
  7799. type = type || callback;
  7800. callback = data;
  7801. data = undefined;
  7802. }
  7803. return jQuery.ajax({
  7804. url: url,
  7805. type: method,
  7806. dataType: type,
  7807. data: data,
  7808. success: callback
  7809. });
  7810. };
  7811. });
  7812. jQuery._evalUrl = function( url ) {
  7813. return jQuery.ajax({
  7814. url: url,
  7815. type: "GET",
  7816. dataType: "script",
  7817. async: false,
  7818. global: false,
  7819. "throws": true
  7820. });
  7821. };
  7822. jQuery.fn.extend({
  7823. wrapAll: function( html ) {
  7824. if ( jQuery.isFunction( html ) ) {
  7825. return this.each(function(i) {
  7826. jQuery(this).wrapAll( html.call(this, i) );
  7827. });
  7828. }
  7829. if ( this[0] ) {
  7830. // The elements to wrap the target around
  7831. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  7832. if ( this[0].parentNode ) {
  7833. wrap.insertBefore( this[0] );
  7834. }
  7835. wrap.map(function() {
  7836. var elem = this;
  7837. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  7838. elem = elem.firstChild;
  7839. }
  7840. return elem;
  7841. }).append( this );
  7842. }
  7843. return this;
  7844. },
  7845. wrapInner: function( html ) {
  7846. if ( jQuery.isFunction( html ) ) {
  7847. return this.each(function(i) {
  7848. jQuery(this).wrapInner( html.call(this, i) );
  7849. });
  7850. }
  7851. return this.each(function() {
  7852. var self = jQuery( this ),
  7853. contents = self.contents();
  7854. if ( contents.length ) {
  7855. contents.wrapAll( html );
  7856. } else {
  7857. self.append( html );
  7858. }
  7859. });
  7860. },
  7861. wrap: function( html ) {
  7862. var isFunction = jQuery.isFunction( html );
  7863. return this.each(function(i) {
  7864. jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html );
  7865. });
  7866. },
  7867. unwrap: function() {
  7868. return this.parent().each(function() {
  7869. if ( !jQuery.nodeName( this, "body" ) ) {
  7870. jQuery( this ).replaceWith( this.childNodes );
  7871. }
  7872. }).end();
  7873. }
  7874. });
  7875. jQuery.expr.filters.hidden = function( elem ) {
  7876. // Support: Opera <= 12.12
  7877. // Opera reports offsetWidths and offsetHeights less than zero on some elements
  7878. return elem.offsetWidth <= 0 && elem.offsetHeight <= 0 ||
  7879. (!support.reliableHiddenOffsets() &&
  7880. ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none");
  7881. };
  7882. jQuery.expr.filters.visible = function( elem ) {
  7883. return !jQuery.expr.filters.hidden( elem );
  7884. };
  7885. var r20 = /%20/g,
  7886. rbracket = /\[\]$/,
  7887. rCRLF = /\r?\n/g,
  7888. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7889. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7890. function buildParams( prefix, obj, traditional, add ) {
  7891. var name;
  7892. if ( jQuery.isArray( obj ) ) {
  7893. // Serialize array item.
  7894. jQuery.each( obj, function( i, v ) {
  7895. if ( traditional || rbracket.test( prefix ) ) {
  7896. // Treat each array item as a scalar.
  7897. add( prefix, v );
  7898. } else {
  7899. // Item is non-scalar (array or object), encode its numeric index.
  7900. buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
  7901. }
  7902. });
  7903. } else if ( !traditional && jQuery.type( obj ) === "object" ) {
  7904. // Serialize object item.
  7905. for ( name in obj ) {
  7906. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7907. }
  7908. } else {
  7909. // Serialize scalar item.
  7910. add( prefix, obj );
  7911. }
  7912. }
  7913. // Serialize an array of form elements or a set of
  7914. // key/values into a query string
  7915. jQuery.param = function( a, traditional ) {
  7916. var prefix,
  7917. s = [],
  7918. add = function( key, value ) {
  7919. // If value is a function, invoke it and return its value
  7920. value = jQuery.isFunction( value ) ? value() : ( value == null ? "" : value );
  7921. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  7922. };
  7923. // Set traditional to true for jQuery <= 1.3.2 behavior.
  7924. if ( traditional === undefined ) {
  7925. traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
  7926. }
  7927. // If an array was passed in, assume that it is an array of form elements.
  7928. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7929. // Serialize the form elements
  7930. jQuery.each( a, function() {
  7931. add( this.name, this.value );
  7932. });
  7933. } else {
  7934. // If traditional, encode the "old" way (the way 1.3.2 or older
  7935. // did it), otherwise encode params recursively.
  7936. for ( prefix in a ) {
  7937. buildParams( prefix, a[ prefix ], traditional, add );
  7938. }
  7939. }
  7940. // Return the resulting serialization
  7941. return s.join( "&" ).replace( r20, "+" );
  7942. };
  7943. jQuery.fn.extend({
  7944. serialize: function() {
  7945. return jQuery.param( this.serializeArray() );
  7946. },
  7947. serializeArray: function() {
  7948. return this.map(function() {
  7949. // Can add propHook for "elements" to filter or add form elements
  7950. var elements = jQuery.prop( this, "elements" );
  7951. return elements ? jQuery.makeArray( elements ) : this;
  7952. })
  7953. .filter(function() {
  7954. var type = this.type;
  7955. // Use .is(":disabled") so that fieldset[disabled] works
  7956. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7957. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7958. ( this.checked || !rcheckableType.test( type ) );
  7959. })
  7960. .map(function( i, elem ) {
  7961. var val = jQuery( this ).val();
  7962. return val == null ?
  7963. null :
  7964. jQuery.isArray( val ) ?
  7965. jQuery.map( val, function( val ) {
  7966. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7967. }) :
  7968. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7969. }).get();
  7970. }
  7971. });
  7972. // Create the request object
  7973. // (This is still attached to ajaxSettings for backward compatibility)
  7974. jQuery.ajaxSettings.xhr = window.ActiveXObject !== undefined ?
  7975. // Support: IE6+
  7976. function() {
  7977. // XHR cannot access local files, always use ActiveX for that case
  7978. return !this.isLocal &&
  7979. // Support: IE7-8
  7980. // oldIE XHR does not support non-RFC2616 methods (#13240)
  7981. // See http://msdn.microsoft.com/en-us/library/ie/ms536648(v=vs.85).aspx
  7982. // and http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9
  7983. // Although this check for six methods instead of eight
  7984. // since IE also does not support "trace" and "connect"
  7985. /^(get|post|head|put|delete|options)$/i.test( this.type ) &&
  7986. createStandardXHR() || createActiveXHR();
  7987. } :
  7988. // For all other browsers, use the standard XMLHttpRequest object
  7989. createStandardXHR;
  7990. var xhrId = 0,
  7991. xhrCallbacks = {},
  7992. xhrSupported = jQuery.ajaxSettings.xhr();
  7993. // Support: IE<10
  7994. // Open requests must be manually aborted on unload (#5280)
  7995. // See https://support.microsoft.com/kb/2856746 for more info
  7996. if ( window.attachEvent ) {
  7997. window.attachEvent( "onunload", function() {
  7998. for ( var key in xhrCallbacks ) {
  7999. xhrCallbacks[ key ]( undefined, true );
  8000. }
  8001. });
  8002. }
  8003. // Determine support properties
  8004. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  8005. xhrSupported = support.ajax = !!xhrSupported;
  8006. // Create transport if the browser can provide an xhr
  8007. if ( xhrSupported ) {
  8008. jQuery.ajaxTransport(function( options ) {
  8009. // Cross domain only allowed if supported through XMLHttpRequest
  8010. if ( !options.crossDomain || support.cors ) {
  8011. var callback;
  8012. return {
  8013. send: function( headers, complete ) {
  8014. var i,
  8015. xhr = options.xhr(),
  8016. id = ++xhrId;
  8017. // Open the socket
  8018. xhr.open( options.type, options.url, options.async, options.username, options.password );
  8019. // Apply custom fields if provided
  8020. if ( options.xhrFields ) {
  8021. for ( i in options.xhrFields ) {
  8022. xhr[ i ] = options.xhrFields[ i ];
  8023. }
  8024. }
  8025. // Override mime type if needed
  8026. if ( options.mimeType && xhr.overrideMimeType ) {
  8027. xhr.overrideMimeType( options.mimeType );
  8028. }
  8029. // X-Requested-With header
  8030. // For cross-domain requests, seeing as conditions for a preflight are
  8031. // akin to a jigsaw puzzle, we simply never set it to be sure.
  8032. // (it can always be set on a per-request basis or even using ajaxSetup)
  8033. // For same-domain requests, won't change header if already provided.
  8034. if ( !options.crossDomain && !headers["X-Requested-With"] ) {
  8035. headers["X-Requested-With"] = "XMLHttpRequest";
  8036. }
  8037. // Set headers
  8038. for ( i in headers ) {
  8039. // Support: IE<9
  8040. // IE's ActiveXObject throws a 'Type Mismatch' exception when setting
  8041. // request header to a null-value.
  8042. //
  8043. // To keep consistent with other XHR implementations, cast the value
  8044. // to string and ignore `undefined`.
  8045. if ( headers[ i ] !== undefined ) {
  8046. xhr.setRequestHeader( i, headers[ i ] + "" );
  8047. }
  8048. }
  8049. // Do send the request
  8050. // This may raise an exception which is actually
  8051. // handled in jQuery.ajax (so no try/catch here)
  8052. xhr.send( ( options.hasContent && options.data ) || null );
  8053. // Listener
  8054. callback = function( _, isAbort ) {
  8055. var status, statusText, responses;
  8056. // Was never called and is aborted or complete
  8057. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  8058. // Clean up
  8059. delete xhrCallbacks[ id ];
  8060. callback = undefined;
  8061. xhr.onreadystatechange = jQuery.noop;
  8062. // Abort manually if needed
  8063. if ( isAbort ) {
  8064. if ( xhr.readyState !== 4 ) {
  8065. xhr.abort();
  8066. }
  8067. } else {
  8068. responses = {};
  8069. status = xhr.status;
  8070. // Support: IE<10
  8071. // Accessing binary-data responseText throws an exception
  8072. // (#11426)
  8073. if ( typeof xhr.responseText === "string" ) {
  8074. responses.text = xhr.responseText;
  8075. }
  8076. // Firefox throws an exception when accessing
  8077. // statusText for faulty cross-domain requests
  8078. try {
  8079. statusText = xhr.statusText;
  8080. } catch( e ) {
  8081. // We normalize with Webkit giving an empty statusText
  8082. statusText = "";
  8083. }
  8084. // Filter status for non standard behaviors
  8085. // If the request is local and we have data: assume a success
  8086. // (success with no data won't get notified, that's the best we
  8087. // can do given current implementations)
  8088. if ( !status && options.isLocal && !options.crossDomain ) {
  8089. status = responses.text ? 200 : 404;
  8090. // IE - #1450: sometimes returns 1223 when it should be 204
  8091. } else if ( status === 1223 ) {
  8092. status = 204;
  8093. }
  8094. }
  8095. }
  8096. // Call complete if needed
  8097. if ( responses ) {
  8098. complete( status, statusText, responses, xhr.getAllResponseHeaders() );
  8099. }
  8100. };
  8101. if ( !options.async ) {
  8102. // if we're in sync mode we fire the callback
  8103. callback();
  8104. } else if ( xhr.readyState === 4 ) {
  8105. // (IE6 & IE7) if it's in cache and has been
  8106. // retrieved directly we need to fire the callback
  8107. setTimeout( callback );
  8108. } else {
  8109. // Add to the list of active xhr callbacks
  8110. xhr.onreadystatechange = xhrCallbacks[ id ] = callback;
  8111. }
  8112. },
  8113. abort: function() {
  8114. if ( callback ) {
  8115. callback( undefined, true );
  8116. }
  8117. }
  8118. };
  8119. }
  8120. });
  8121. }
  8122. // Functions to create xhrs
  8123. function createStandardXHR() {
  8124. try {
  8125. return new window.XMLHttpRequest();
  8126. } catch( e ) {}
  8127. }
  8128. function createActiveXHR() {
  8129. try {
  8130. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  8131. } catch( e ) {}
  8132. }
  8133. // Install script dataType
  8134. jQuery.ajaxSetup({
  8135. accepts: {
  8136. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  8137. },
  8138. contents: {
  8139. script: /(?:java|ecma)script/
  8140. },
  8141. converters: {
  8142. "text script": function( text ) {
  8143. jQuery.globalEval( text );
  8144. return text;
  8145. }
  8146. }
  8147. });
  8148. // Handle cache's special case and global
  8149. jQuery.ajaxPrefilter( "script", function( s ) {
  8150. if ( s.cache === undefined ) {
  8151. s.cache = false;
  8152. }
  8153. if ( s.crossDomain ) {
  8154. s.type = "GET";
  8155. s.global = false;
  8156. }
  8157. });
  8158. // Bind script tag hack transport
  8159. jQuery.ajaxTransport( "script", function(s) {
  8160. // This transport only deals with cross domain requests
  8161. if ( s.crossDomain ) {
  8162. var script,
  8163. head = document.head || jQuery("head")[0] || document.documentElement;
  8164. return {
  8165. send: function( _, callback ) {
  8166. script = document.createElement("script");
  8167. script.async = true;
  8168. if ( s.scriptCharset ) {
  8169. script.charset = s.scriptCharset;
  8170. }
  8171. script.src = s.url;
  8172. // Attach handlers for all browsers
  8173. script.onload = script.onreadystatechange = function( _, isAbort ) {
  8174. if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  8175. // Handle memory leak in IE
  8176. script.onload = script.onreadystatechange = null;
  8177. // Remove the script
  8178. if ( script.parentNode ) {
  8179. script.parentNode.removeChild( script );
  8180. }
  8181. // Dereference the script
  8182. script = null;
  8183. // Callback if not abort
  8184. if ( !isAbort ) {
  8185. callback( 200, "success" );
  8186. }
  8187. }
  8188. };
  8189. // Circumvent IE6 bugs with base elements (#2709 and #4378) by prepending
  8190. // Use native DOM manipulation to avoid our domManip AJAX trickery
  8191. head.insertBefore( script, head.firstChild );
  8192. },
  8193. abort: function() {
  8194. if ( script ) {
  8195. script.onload( undefined, true );
  8196. }
  8197. }
  8198. };
  8199. }
  8200. });
  8201. var oldCallbacks = [],
  8202. rjsonp = /(=)\?(?=&|$)|\?\?/;
  8203. // Default jsonp settings
  8204. jQuery.ajaxSetup({
  8205. jsonp: "callback",
  8206. jsonpCallback: function() {
  8207. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8208. this[ callback ] = true;
  8209. return callback;
  8210. }
  8211. });
  8212. // Detect, normalize options and install callbacks for jsonp requests
  8213. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8214. var callbackName, overwritten, responseContainer,
  8215. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  8216. "url" :
  8217. typeof s.data === "string" && !( s.contentType || "" ).indexOf("application/x-www-form-urlencoded") && rjsonp.test( s.data ) && "data"
  8218. );
  8219. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8220. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  8221. // Get callback name, remembering preexisting value associated with it
  8222. callbackName = s.jsonpCallback = jQuery.isFunction( s.jsonpCallback ) ?
  8223. s.jsonpCallback() :
  8224. s.jsonpCallback;
  8225. // Insert callback into url or form data
  8226. if ( jsonProp ) {
  8227. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  8228. } else if ( s.jsonp !== false ) {
  8229. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8230. }
  8231. // Use data converter to retrieve json after script execution
  8232. s.converters["script json"] = function() {
  8233. if ( !responseContainer ) {
  8234. jQuery.error( callbackName + " was not called" );
  8235. }
  8236. return responseContainer[ 0 ];
  8237. };
  8238. // force json dataType
  8239. s.dataTypes[ 0 ] = "json";
  8240. // Install callback
  8241. overwritten = window[ callbackName ];
  8242. window[ callbackName ] = function() {
  8243. responseContainer = arguments;
  8244. };
  8245. // Clean-up function (fires after converters)
  8246. jqXHR.always(function() {
  8247. // Restore preexisting value
  8248. window[ callbackName ] = overwritten;
  8249. // Save back as free
  8250. if ( s[ callbackName ] ) {
  8251. // make sure that re-using the options doesn't screw things around
  8252. s.jsonpCallback = originalSettings.jsonpCallback;
  8253. // save the callback name for future use
  8254. oldCallbacks.push( callbackName );
  8255. }
  8256. // Call if it was a function and we have a response
  8257. if ( responseContainer && jQuery.isFunction( overwritten ) ) {
  8258. overwritten( responseContainer[ 0 ] );
  8259. }
  8260. responseContainer = overwritten = undefined;
  8261. });
  8262. // Delegate to script
  8263. return "script";
  8264. }
  8265. });
  8266. // data: string of html
  8267. // context (optional): If specified, the fragment will be created in this context, defaults to document
  8268. // keepScripts (optional): If true, will include scripts passed in the html string
  8269. jQuery.parseHTML = function( data, context, keepScripts ) {
  8270. if ( !data || typeof data !== "string" ) {
  8271. return null;
  8272. }
  8273. if ( typeof context === "boolean" ) {
  8274. keepScripts = context;
  8275. context = false;
  8276. }
  8277. context = context || document;
  8278. var parsed = rsingleTag.exec( data ),
  8279. scripts = !keepScripts && [];
  8280. // Single tag
  8281. if ( parsed ) {
  8282. return [ context.createElement( parsed[1] ) ];
  8283. }
  8284. parsed = jQuery.buildFragment( [ data ], context, scripts );
  8285. if ( scripts && scripts.length ) {
  8286. jQuery( scripts ).remove();
  8287. }
  8288. return jQuery.merge( [], parsed.childNodes );
  8289. };
  8290. // Keep a copy of the old load method
  8291. var _load = jQuery.fn.load;
  8292. /**
  8293. * Load a url into a page
  8294. */
  8295. jQuery.fn.load = function( url, params, callback ) {
  8296. if ( typeof url !== "string" && _load ) {
  8297. return _load.apply( this, arguments );
  8298. }
  8299. var selector, response, type,
  8300. self = this,
  8301. off = url.indexOf(" ");
  8302. if ( off >= 0 ) {
  8303. selector = jQuery.trim( url.slice( off, url.length ) );
  8304. url = url.slice( 0, off );
  8305. }
  8306. // If it's a function
  8307. if ( jQuery.isFunction( params ) ) {
  8308. // We assume that it's the callback
  8309. callback = params;
  8310. params = undefined;
  8311. // Otherwise, build a param string
  8312. } else if ( params && typeof params === "object" ) {
  8313. type = "POST";
  8314. }
  8315. // If we have elements to modify, make the request
  8316. if ( self.length > 0 ) {
  8317. jQuery.ajax({
  8318. url: url,
  8319. // if "type" variable is undefined, then "GET" method will be used
  8320. type: type,
  8321. dataType: "html",
  8322. data: params
  8323. }).done(function( responseText ) {
  8324. // Save response for use in complete callback
  8325. response = arguments;
  8326. self.html( selector ?
  8327. // If a selector was specified, locate the right elements in a dummy div
  8328. // Exclude scripts to avoid IE 'Permission Denied' errors
  8329. jQuery("<div>").append( jQuery.parseHTML( responseText ) ).find( selector ) :
  8330. // Otherwise use the full result
  8331. responseText );
  8332. }).complete( callback && function( jqXHR, status ) {
  8333. self.each( callback, response || [ jqXHR.responseText, status, jqXHR ] );
  8334. });
  8335. }
  8336. return this;
  8337. };
  8338. // Attach a bunch of functions for handling common AJAX events
  8339. jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
  8340. jQuery.fn[ type ] = function( fn ) {
  8341. return this.on( type, fn );
  8342. };
  8343. });
  8344. jQuery.expr.filters.animated = function( elem ) {
  8345. return jQuery.grep(jQuery.timers, function( fn ) {
  8346. return elem === fn.elem;
  8347. }).length;
  8348. };
  8349. var docElem = window.document.documentElement;
  8350. /**
  8351. * Gets a window from an element
  8352. */
  8353. function getWindow( elem ) {
  8354. return jQuery.isWindow( elem ) ?
  8355. elem :
  8356. elem.nodeType === 9 ?
  8357. elem.defaultView || elem.parentWindow :
  8358. false;
  8359. }
  8360. jQuery.offset = {
  8361. setOffset: function( elem, options, i ) {
  8362. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  8363. position = jQuery.css( elem, "position" ),
  8364. curElem = jQuery( elem ),
  8365. props = {};
  8366. // set position first, in-case top/left are set even on static elem
  8367. if ( position === "static" ) {
  8368. elem.style.position = "relative";
  8369. }
  8370. curOffset = curElem.offset();
  8371. curCSSTop = jQuery.css( elem, "top" );
  8372. curCSSLeft = jQuery.css( elem, "left" );
  8373. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  8374. jQuery.inArray("auto", [ curCSSTop, curCSSLeft ] ) > -1;
  8375. // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  8376. if ( calculatePosition ) {
  8377. curPosition = curElem.position();
  8378. curTop = curPosition.top;
  8379. curLeft = curPosition.left;
  8380. } else {
  8381. curTop = parseFloat( curCSSTop ) || 0;
  8382. curLeft = parseFloat( curCSSLeft ) || 0;
  8383. }
  8384. if ( jQuery.isFunction( options ) ) {
  8385. options = options.call( elem, i, curOffset );
  8386. }
  8387. if ( options.top != null ) {
  8388. props.top = ( options.top - curOffset.top ) + curTop;
  8389. }
  8390. if ( options.left != null ) {
  8391. props.left = ( options.left - curOffset.left ) + curLeft;
  8392. }
  8393. if ( "using" in options ) {
  8394. options.using.call( elem, props );
  8395. } else {
  8396. curElem.css( props );
  8397. }
  8398. }
  8399. };
  8400. jQuery.fn.extend({
  8401. offset: function( options ) {
  8402. if ( arguments.length ) {
  8403. return options === undefined ?
  8404. this :
  8405. this.each(function( i ) {
  8406. jQuery.offset.setOffset( this, options, i );
  8407. });
  8408. }
  8409. var docElem, win,
  8410. box = { top: 0, left: 0 },
  8411. elem = this[ 0 ],
  8412. doc = elem && elem.ownerDocument;
  8413. if ( !doc ) {
  8414. return;
  8415. }
  8416. docElem = doc.documentElement;
  8417. // Make sure it's not a disconnected DOM node
  8418. if ( !jQuery.contains( docElem, elem ) ) {
  8419. return box;
  8420. }
  8421. // If we don't have gBCR, just use 0,0 rather than error
  8422. // BlackBerry 5, iOS 3 (original iPhone)
  8423. if ( typeof elem.getBoundingClientRect !== strundefined ) {
  8424. box = elem.getBoundingClientRect();
  8425. }
  8426. win = getWindow( doc );
  8427. return {
  8428. top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
  8429. left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
  8430. };
  8431. },
  8432. position: function() {
  8433. if ( !this[ 0 ] ) {
  8434. return;
  8435. }
  8436. var offsetParent, offset,
  8437. parentOffset = { top: 0, left: 0 },
  8438. elem = this[ 0 ];
  8439. // fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
  8440. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  8441. // we assume that getBoundingClientRect is available when computed position is fixed
  8442. offset = elem.getBoundingClientRect();
  8443. } else {
  8444. // Get *real* offsetParent
  8445. offsetParent = this.offsetParent();
  8446. // Get correct offsets
  8447. offset = this.offset();
  8448. if ( !jQuery.nodeName( offsetParent[ 0 ], "html" ) ) {
  8449. parentOffset = offsetParent.offset();
  8450. }
  8451. // Add offsetParent borders
  8452. parentOffset.top += jQuery.css( offsetParent[ 0 ], "borderTopWidth", true );
  8453. parentOffset.left += jQuery.css( offsetParent[ 0 ], "borderLeftWidth", true );
  8454. }
  8455. // Subtract parent offsets and element margins
  8456. // note: when an element has margin: auto the offsetLeft and marginLeft
  8457. // are the same in Safari causing offset.left to incorrectly be 0
  8458. return {
  8459. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  8460. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true)
  8461. };
  8462. },
  8463. offsetParent: function() {
  8464. return this.map(function() {
  8465. var offsetParent = this.offsetParent || docElem;
  8466. while ( offsetParent && ( !jQuery.nodeName( offsetParent, "html" ) && jQuery.css( offsetParent, "position" ) === "static" ) ) {
  8467. offsetParent = offsetParent.offsetParent;
  8468. }
  8469. return offsetParent || docElem;
  8470. });
  8471. }
  8472. });
  8473. // Create scrollLeft and scrollTop methods
  8474. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  8475. var top = /Y/.test( prop );
  8476. jQuery.fn[ method ] = function( val ) {
  8477. return access( this, function( elem, method, val ) {
  8478. var win = getWindow( elem );
  8479. if ( val === undefined ) {
  8480. return win ? (prop in win) ? win[ prop ] :
  8481. win.document.documentElement[ method ] :
  8482. elem[ method ];
  8483. }
  8484. if ( win ) {
  8485. win.scrollTo(
  8486. !top ? val : jQuery( win ).scrollLeft(),
  8487. top ? val : jQuery( win ).scrollTop()
  8488. );
  8489. } else {
  8490. elem[ method ] = val;
  8491. }
  8492. }, method, val, arguments.length, null );
  8493. };
  8494. });
  8495. // Add the top/left cssHooks using jQuery.fn.position
  8496. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  8497. // getComputedStyle returns percent when specified for top/left/bottom/right
  8498. // rather than make the css module depend on the offset module, we just check for it here
  8499. jQuery.each( [ "top", "left" ], function( i, prop ) {
  8500. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  8501. function( elem, computed ) {
  8502. if ( computed ) {
  8503. computed = curCSS( elem, prop );
  8504. // if curCSS returns percentage, fallback to offset
  8505. return rnumnonpx.test( computed ) ?
  8506. jQuery( elem ).position()[ prop ] + "px" :
  8507. computed;
  8508. }
  8509. }
  8510. );
  8511. });
  8512. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  8513. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8514. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
  8515. // margin is only for outerHeight, outerWidth
  8516. jQuery.fn[ funcName ] = function( margin, value ) {
  8517. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  8518. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  8519. return access( this, function( elem, type, value ) {
  8520. var doc;
  8521. if ( jQuery.isWindow( elem ) ) {
  8522. // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
  8523. // isn't a whole lot we can do. See pull request at this URL for discussion:
  8524. // https://github.com/jquery/jquery/pull/764
  8525. return elem.document.documentElement[ "client" + name ];
  8526. }
  8527. // Get document width or height
  8528. if ( elem.nodeType === 9 ) {
  8529. doc = elem.documentElement;
  8530. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height], whichever is greatest
  8531. // unfortunately, this causes bug #3838 in IE6/8 only, but there is currently no good, small way to fix it.
  8532. return Math.max(
  8533. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  8534. elem.body[ "offset" + name ], doc[ "offset" + name ],
  8535. doc[ "client" + name ]
  8536. );
  8537. }
  8538. return value === undefined ?
  8539. // Get width or height on the element, requesting but not forcing parseFloat
  8540. jQuery.css( elem, type, extra ) :
  8541. // Set width or height on the element
  8542. jQuery.style( elem, type, value, extra );
  8543. }, type, chainable ? margin : undefined, chainable, null );
  8544. };
  8545. });
  8546. });
  8547. // The number of elements contained in the matched element set
  8548. jQuery.fn.size = function() {
  8549. return this.length;
  8550. };
  8551. jQuery.fn.andSelf = jQuery.fn.addBack;
  8552. // Register as a named AMD module, since jQuery can be concatenated with other
  8553. // files that may use define, but not via a proper concatenation script that
  8554. // understands anonymous AMD modules. A named AMD is safest and most robust
  8555. // way to register. Lowercase jquery is used because AMD module names are
  8556. // derived from file names, and jQuery is normally delivered in a lowercase
  8557. // file name. Do this after creating the global so that if an AMD module wants
  8558. // to call noConflict to hide this version of jQuery, it will work.
  8559. // Note that for maximum portability, libraries that are not jQuery should
  8560. // declare themselves as anonymous modules, and avoid setting a global if an
  8561. // AMD loader is present. jQuery is a special case. For more information, see
  8562. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  8563. if ( typeof define === "function" && define.amd ) {
  8564. define( "jquery", [], function() {
  8565. return jQuery;
  8566. });
  8567. }
  8568. var
  8569. // Map over jQuery in case of overwrite
  8570. _jQuery = window.jQuery,
  8571. // Map over the $ in case of overwrite
  8572. _$ = window.$;
  8573. jQuery.noConflict = function( deep ) {
  8574. if ( window.$ === jQuery ) {
  8575. window.$ = _$;
  8576. }
  8577. if ( deep && window.jQuery === jQuery ) {
  8578. window.jQuery = _jQuery;
  8579. }
  8580. return jQuery;
  8581. };
  8582. // Expose jQuery and $ identifiers, even in
  8583. // AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  8584. // and CommonJS for browser emulators (#13566)
  8585. if ( typeof noGlobal === strundefined ) {
  8586. window.jQuery = window.$ = jQuery;
  8587. }
  8588. return jQuery;
  8589. }));
  8590. // Generated by CoffeeScript 1.7.1
  8591. /*
  8592. jQuery.Turbolinks ~ https://github.com/kossnocorp/jquery.turbolinks
  8593. jQuery plugin for drop-in fix binded events problem caused by Turbolinks
  8594. The MIT License
  8595. Copyright (c) 2012-2013 Sasha Koss & Rico Sta. Cruz
  8596. */
  8597. (function() {
  8598. var $, $document;
  8599. $ = window.jQuery || (typeof require === "function" ? require('jquery') : void 0);
  8600. $document = $(document);
  8601. $.turbo = {
  8602. version: '2.1.0',
  8603. isReady: false,
  8604. use: function(load, fetch) {
  8605. return $document.off('.turbo').on("" + load + ".turbo", this.onLoad).on("" + fetch + ".turbo", this.onFetch);
  8606. },
  8607. addCallback: function(callback) {
  8608. if ($.turbo.isReady) {
  8609. callback($);
  8610. }
  8611. return $document.on('turbo:ready', function() {
  8612. return callback($);
  8613. });
  8614. },
  8615. onLoad: function() {
  8616. $.turbo.isReady = true;
  8617. return $document.trigger('turbo:ready');
  8618. },
  8619. onFetch: function() {
  8620. return $.turbo.isReady = false;
  8621. },
  8622. register: function() {
  8623. $(this.onLoad);
  8624. return $.fn.ready = this.addCallback;
  8625. }
  8626. };
  8627. $.turbo.register();
  8628. $.turbo.use('page:load', 'page:fetch');
  8629. }).call(this);
  8630. (function($, undefined) {
  8631. /**
  8632. * Unobtrusive scripting adapter for jQuery
  8633. * https://github.com/rails/jquery-ujs
  8634. *
  8635. * Requires jQuery 1.8.0 or later.
  8636. *
  8637. * Released under the MIT license
  8638. *
  8639. */
  8640. // Cut down on the number of issues from people inadvertently including jquery_ujs twice
  8641. // by detecting and raising an error when it happens.
  8642. 'use strict';
  8643. if ( $.rails !== undefined ) {
  8644. $.error('jquery-ujs has already been loaded!');
  8645. }
  8646. // Shorthand to make it a little easier to call public rails functions from within rails.js
  8647. var rails;
  8648. var $document = $(document);
  8649. $.rails = rails = {
  8650. // Link elements bound by jquery-ujs
  8651. linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
  8652. // Button elements bound by jquery-ujs
  8653. buttonClickSelector: 'button[data-remote]:not(form button), button[data-confirm]:not(form button)',
  8654. // Select elements bound by jquery-ujs
  8655. inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
  8656. // Form elements bound by jquery-ujs
  8657. formSubmitSelector: 'form',
  8658. // Form input elements bound by jquery-ujs
  8659. formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
  8660. // Form input elements disabled during form submission
  8661. disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
  8662. // Form input elements re-enabled after form submission
  8663. enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
  8664. // Form required input elements
  8665. requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
  8666. // Form file input elements
  8667. fileInputSelector: 'input[type=file]:not([disabled])',
  8668. // Link onClick disable selector with possible reenable after remote submission
  8669. linkDisableSelector: 'a[data-disable-with], a[data-disable]',
  8670. // Button onClick disable selector with possible reenable after remote submission
  8671. buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
  8672. // Up-to-date Cross-Site Request Forgery token
  8673. csrfToken: function() {
  8674. return $('meta[name=csrf-token]').attr('content');
  8675. },
  8676. // URL param that must contain the CSRF token
  8677. csrfParam: function() {
  8678. return $('meta[name=csrf-param]').attr('content');
  8679. },
  8680. // Make sure that every Ajax request sends the CSRF token
  8681. CSRFProtection: function(xhr) {
  8682. var token = rails.csrfToken();
  8683. if (token) xhr.setRequestHeader('X-CSRF-Token', token);
  8684. },
  8685. // making sure that all forms have actual up-to-date token(cached forms contain old one)
  8686. refreshCSRFTokens: function(){
  8687. $('form input[name="' + rails.csrfParam() + '"]').val(rails.csrfToken());
  8688. },
  8689. // Triggers an event on an element and returns false if the event result is false
  8690. fire: function(obj, name, data) {
  8691. var event = $.Event(name);
  8692. obj.trigger(event, data);
  8693. return event.result !== false;
  8694. },
  8695. // Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
  8696. confirm: function(message) {
  8697. return confirm(message);
  8698. },
  8699. // Default ajax function, may be overridden with custom function in $.rails.ajax
  8700. ajax: function(options) {
  8701. return $.ajax(options);
  8702. },
  8703. // Default way to get an element's href. May be overridden at $.rails.href.
  8704. href: function(element) {
  8705. return element[0].href;
  8706. },
  8707. // Checks "data-remote" if true to handle the request through a XHR request.
  8708. isRemote: function(element) {
  8709. return element.data('remote') !== undefined && element.data('remote') !== false;
  8710. },
  8711. // Submits "remote" forms and links with ajax
  8712. handleRemote: function(element) {
  8713. var method, url, data, withCredentials, dataType, options;
  8714. if (rails.fire(element, 'ajax:before')) {
  8715. withCredentials = element.data('with-credentials') || null;
  8716. dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
  8717. if (element.is('form')) {
  8718. method = element.attr('method');
  8719. url = element.attr('action');
  8720. data = element.serializeArray();
  8721. // memoized value from clicked submit button
  8722. var button = element.data('ujs:submit-button');
  8723. if (button) {
  8724. data.push(button);
  8725. element.data('ujs:submit-button', null);
  8726. }
  8727. } else if (element.is(rails.inputChangeSelector)) {
  8728. method = element.data('method');
  8729. url = element.data('url');
  8730. data = element.serialize();
  8731. if (element.data('params')) data = data + '&' + element.data('params');
  8732. } else if (element.is(rails.buttonClickSelector)) {
  8733. method = element.data('method') || 'get';
  8734. url = element.data('url');
  8735. data = element.serialize();
  8736. if (element.data('params')) data = data + '&' + element.data('params');
  8737. } else {
  8738. method = element.data('method');
  8739. url = rails.href(element);
  8740. data = element.data('params') || null;
  8741. }
  8742. options = {
  8743. type: method || 'GET', data: data, dataType: dataType,
  8744. // stopping the "ajax:beforeSend" event will cancel the ajax request
  8745. beforeSend: function(xhr, settings) {
  8746. if (settings.dataType === undefined) {
  8747. xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
  8748. }
  8749. if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) {
  8750. element.trigger('ajax:send', xhr);
  8751. } else {
  8752. return false;
  8753. }
  8754. },
  8755. success: function(data, status, xhr) {
  8756. element.trigger('ajax:success', [data, status, xhr]);
  8757. },
  8758. complete: function(xhr, status) {
  8759. element.trigger('ajax:complete', [xhr, status]);
  8760. },
  8761. error: function(xhr, status, error) {
  8762. element.trigger('ajax:error', [xhr, status, error]);
  8763. },
  8764. crossDomain: rails.isCrossDomain(url)
  8765. };
  8766. // There is no withCredentials for IE6-8 when
  8767. // "Enable native XMLHTTP support" is disabled
  8768. if (withCredentials) {
  8769. options.xhrFields = {
  8770. withCredentials: withCredentials
  8771. };
  8772. }
  8773. // Only pass url to `ajax` options if not blank
  8774. if (url) { options.url = url; }
  8775. return rails.ajax(options);
  8776. } else {
  8777. return false;
  8778. }
  8779. },
  8780. // Determines if the request is a cross domain request.
  8781. isCrossDomain: function(url) {
  8782. var originAnchor = document.createElement('a');
  8783. originAnchor.href = location.href;
  8784. var urlAnchor = document.createElement('a');
  8785. try {
  8786. urlAnchor.href = url;
  8787. // This is a workaround to a IE bug.
  8788. urlAnchor.href = urlAnchor.href;
  8789. // If URL protocol is false or is a string containing a single colon
  8790. // *and* host are false, assume it is not a cross-domain request
  8791. // (should only be the case for IE7 and IE compatibility mode).
  8792. // Otherwise, evaluate protocol and host of the URL against the origin
  8793. // protocol and host.
  8794. return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) ||
  8795. (originAnchor.protocol + '//' + originAnchor.host ===
  8796. urlAnchor.protocol + '//' + urlAnchor.host));
  8797. } catch (e) {
  8798. // If there is an error parsing the URL, assume it is crossDomain.
  8799. return true;
  8800. }
  8801. },
  8802. // Handles "data-method" on links such as:
  8803. // <a href="/users/5" data-method="delete" rel="nofollow" data-confirm="Are you sure?">Delete</a>
  8804. handleMethod: function(link) {
  8805. var href = rails.href(link),
  8806. method = link.data('method'),
  8807. target = link.attr('target'),
  8808. csrfToken = rails.csrfToken(),
  8809. csrfParam = rails.csrfParam(),
  8810. form = $('<form method="post" action="' + href + '"></form>'),
  8811. metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
  8812. if (csrfParam !== undefined && csrfToken !== undefined && !rails.isCrossDomain(href)) {
  8813. metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
  8814. }
  8815. if (target) { form.attr('target', target); }
  8816. form.hide().append(metadataInput).appendTo('body');
  8817. form.submit();
  8818. },
  8819. // Helper function that returns form elements that match the specified CSS selector
  8820. // If form is actually a "form" element this will return associated elements outside the from that have
  8821. // the html form attribute set
  8822. formElements: function(form, selector) {
  8823. return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector);
  8824. },
  8825. /* Disables form elements:
  8826. - Caches element value in 'ujs:enable-with' data store
  8827. - Replaces element text with value of 'data-disable-with' attribute
  8828. - Sets disabled property to true
  8829. */
  8830. disableFormElements: function(form) {
  8831. rails.formElements(form, rails.disableSelector).each(function() {
  8832. rails.disableFormElement($(this));
  8833. });
  8834. },
  8835. disableFormElement: function(element) {
  8836. var method, replacement;
  8837. method = element.is('button') ? 'html' : 'val';
  8838. replacement = element.data('disable-with');
  8839. element.data('ujs:enable-with', element[method]());
  8840. if (replacement !== undefined) {
  8841. element[method](replacement);
  8842. }
  8843. element.prop('disabled', true);
  8844. },
  8845. /* Re-enables disabled form elements:
  8846. - Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
  8847. - Sets disabled property to false
  8848. */
  8849. enableFormElements: function(form) {
  8850. rails.formElements(form, rails.enableSelector).each(function() {
  8851. rails.enableFormElement($(this));
  8852. });
  8853. },
  8854. enableFormElement: function(element) {
  8855. var method = element.is('button') ? 'html' : 'val';
  8856. if (typeof element.data('ujs:enable-with') !== 'undefined') element[method](element.data('ujs:enable-with'));
  8857. element.prop('disabled', false);
  8858. },
  8859. /* For 'data-confirm' attribute:
  8860. - Fires `confirm` event
  8861. - Shows the confirmation dialog
  8862. - Fires the `confirm:complete` event
  8863. Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
  8864. Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
  8865. Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
  8866. return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
  8867. */
  8868. allowAction: function(element) {
  8869. var message = element.data('confirm'),
  8870. answer = false, callback;
  8871. if (!message) { return true; }
  8872. if (rails.fire(element, 'confirm')) {
  8873. try {
  8874. answer = rails.confirm(message);
  8875. } catch (e) {
  8876. (console.error || console.log).call(console, e.stack || e);
  8877. }
  8878. callback = rails.fire(element, 'confirm:complete', [answer]);
  8879. }
  8880. return answer && callback;
  8881. },
  8882. // Helper function which checks for blank inputs in a form that match the specified CSS selector
  8883. blankInputs: function(form, specifiedSelector, nonBlank) {
  8884. var inputs = $(), input, valueToCheck,
  8885. selector = specifiedSelector || 'input,textarea',
  8886. allInputs = form.find(selector);
  8887. allInputs.each(function() {
  8888. input = $(this);
  8889. valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : !!input.val();
  8890. if (valueToCheck === nonBlank) {
  8891. // Don't count unchecked required radio if other radio with same name is checked
  8892. if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
  8893. return true; // Skip to next input
  8894. }
  8895. inputs = inputs.add(input);
  8896. }
  8897. });
  8898. return inputs.length ? inputs : false;
  8899. },
  8900. // Helper function which checks for non-blank inputs in a form that match the specified CSS selector
  8901. nonBlankInputs: function(form, specifiedSelector) {
  8902. return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
  8903. },
  8904. // Helper function, needed to provide consistent behavior in IE
  8905. stopEverything: function(e) {
  8906. $(e.target).trigger('ujs:everythingStopped');
  8907. e.stopImmediatePropagation();
  8908. return false;
  8909. },
  8910. // replace element's html with the 'data-disable-with' after storing original html
  8911. // and prevent clicking on it
  8912. disableElement: function(element) {
  8913. var replacement = element.data('disable-with');
  8914. element.data('ujs:enable-with', element.html()); // store enabled state
  8915. if (replacement !== undefined) {
  8916. element.html(replacement);
  8917. }
  8918. element.bind('click.railsDisable', function(e) { // prevent further clicking
  8919. return rails.stopEverything(e);
  8920. });
  8921. },
  8922. // restore element to its original state which was disabled by 'disableElement' above
  8923. enableElement: function(element) {
  8924. if (element.data('ujs:enable-with') !== undefined) {
  8925. element.html(element.data('ujs:enable-with')); // set to old enabled state
  8926. element.removeData('ujs:enable-with'); // clean up cache
  8927. }
  8928. element.unbind('click.railsDisable'); // enable element
  8929. }
  8930. };
  8931. if (rails.fire($document, 'rails:attachBindings')) {
  8932. $.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
  8933. // This event works the same as the load event, except that it fires every
  8934. // time the page is loaded.
  8935. //
  8936. // See https://github.com/rails/jquery-ujs/issues/357
  8937. // See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
  8938. $(window).on('pageshow.rails', function () {
  8939. $($.rails.enableSelector).each(function () {
  8940. var element = $(this);
  8941. if (element.data('ujs:enable-with')) {
  8942. $.rails.enableFormElement(element);
  8943. }
  8944. });
  8945. $($.rails.linkDisableSelector).each(function () {
  8946. var element = $(this);
  8947. if (element.data('ujs:enable-with')) {
  8948. $.rails.enableElement(element);
  8949. }
  8950. });
  8951. });
  8952. $document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
  8953. rails.enableElement($(this));
  8954. });
  8955. $document.delegate(rails.buttonDisableSelector, 'ajax:complete', function() {
  8956. rails.enableFormElement($(this));
  8957. });
  8958. $document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
  8959. var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
  8960. if (!rails.allowAction(link)) return rails.stopEverything(e);
  8961. if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
  8962. if (rails.isRemote(link)) {
  8963. if (metaClick && (!method || method === 'GET') && !data) { return true; }
  8964. var handleRemote = rails.handleRemote(link);
  8965. // response from rails.handleRemote() will either be false or a deferred object promise.
  8966. if (handleRemote === false) {
  8967. rails.enableElement(link);
  8968. } else {
  8969. handleRemote.fail( function() { rails.enableElement(link); } );
  8970. }
  8971. return false;
  8972. } else if (method) {
  8973. rails.handleMethod(link);
  8974. return false;
  8975. }
  8976. });
  8977. $document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
  8978. var button = $(this);
  8979. if (!rails.allowAction(button) || !rails.isRemote(button)) return rails.stopEverything(e);
  8980. if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
  8981. var handleRemote = rails.handleRemote(button);
  8982. // response from rails.handleRemote() will either be false or a deferred object promise.
  8983. if (handleRemote === false) {
  8984. rails.enableFormElement(button);
  8985. } else {
  8986. handleRemote.fail( function() { rails.enableFormElement(button); } );
  8987. }
  8988. return false;
  8989. });
  8990. $document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
  8991. var link = $(this);
  8992. if (!rails.allowAction(link) || !rails.isRemote(link)) return rails.stopEverything(e);
  8993. rails.handleRemote(link);
  8994. return false;
  8995. });
  8996. $document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
  8997. var form = $(this),
  8998. remote = rails.isRemote(form),
  8999. blankRequiredInputs,
  9000. nonBlankFileInputs;
  9001. if (!rails.allowAction(form)) return rails.stopEverything(e);
  9002. // skip other logic when required values are missing or file upload is present
  9003. if (form.attr('novalidate') === undefined) {
  9004. blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector, false);
  9005. if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
  9006. return rails.stopEverything(e);
  9007. }
  9008. }
  9009. if (remote) {
  9010. nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
  9011. if (nonBlankFileInputs) {
  9012. // slight timeout so that the submit button gets properly serialized
  9013. // (make it easy for event handler to serialize form without disabled values)
  9014. setTimeout(function(){ rails.disableFormElements(form); }, 13);
  9015. var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
  9016. // re-enable form elements if event bindings return false (canceling normal form submission)
  9017. if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
  9018. return aborted;
  9019. }
  9020. rails.handleRemote(form);
  9021. return false;
  9022. } else {
  9023. // slight timeout so that the submit button gets properly serialized
  9024. setTimeout(function(){ rails.disableFormElements(form); }, 13);
  9025. }
  9026. });
  9027. $document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
  9028. var button = $(this);
  9029. if (!rails.allowAction(button)) return rails.stopEverything(event);
  9030. // register the pressed submit button
  9031. var name = button.attr('name'),
  9032. data = name ? {name:name, value:button.val()} : null;
  9033. button.closest('form').data('ujs:submit-button', data);
  9034. });
  9035. $document.delegate(rails.formSubmitSelector, 'ajax:send.rails', function(event) {
  9036. if (this === event.target) rails.disableFormElements($(this));
  9037. });
  9038. $document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
  9039. if (this === event.target) rails.enableFormElements($(this));
  9040. });
  9041. $(function(){
  9042. rails.refreshCSRFTokens();
  9043. });
  9044. }
  9045. })( jQuery );
  9046. (function() {
  9047. var CSRFToken, Click, ComponentUrl, EVENTS, Link, ProgressBar, browserIsntBuggy, browserSupportsCustomEvents, browserSupportsPushState, browserSupportsTurbolinks, bypassOnLoadPopstate, cacheCurrentPage, cacheSize, changePage, clone, constrainPageCacheTo, createDocument, crossOriginRedirect, currentState, enableProgressBar, enableTransitionCache, executeScriptTags, extractTitleAndBody, fetch, fetchHistory, fetchReplacement, historyStateIsDefined, initializeTurbolinks, installDocumentReadyPageEventTriggers, installHistoryChangeHandler, installJqueryAjaxSuccessPageUpdateTrigger, loadedAssets, manuallyTriggerHashChangeForFirefox, pageCache, pageChangePrevented, pagesCached, popCookie, processResponse, progressBar, recallScrollPosition, ref, referer, reflectNewUrl, reflectRedirectedUrl, rememberCurrentState, rememberCurrentUrl, rememberReferer, removeNoscriptTags, requestMethodIsSafe, resetScrollPosition, setAutofocusElement, transitionCacheEnabled, transitionCacheFor, triggerEvent, visit, xhr,
  9048. indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
  9049. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  9050. hasProp = {}.hasOwnProperty,
  9051. slice = [].slice,
  9052. bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
  9053. pageCache = {};
  9054. cacheSize = 10;
  9055. transitionCacheEnabled = false;
  9056. progressBar = null;
  9057. currentState = null;
  9058. loadedAssets = null;
  9059. referer = null;
  9060. xhr = null;
  9061. EVENTS = {
  9062. BEFORE_CHANGE: 'page:before-change',
  9063. FETCH: 'page:fetch',
  9064. RECEIVE: 'page:receive',
  9065. CHANGE: 'page:change',
  9066. UPDATE: 'page:update',
  9067. LOAD: 'page:load',
  9068. RESTORE: 'page:restore',
  9069. BEFORE_UNLOAD: 'page:before-unload',
  9070. EXPIRE: 'page:expire'
  9071. };
  9072. fetch = function(url) {
  9073. var cachedPage;
  9074. url = new ComponentUrl(url);
  9075. rememberReferer();
  9076. cacheCurrentPage();
  9077. if (progressBar != null) {
  9078. progressBar.start();
  9079. }
  9080. if (transitionCacheEnabled && (cachedPage = transitionCacheFor(url.absolute))) {
  9081. fetchHistory(cachedPage);
  9082. return fetchReplacement(url, null, false);
  9083. } else {
  9084. return fetchReplacement(url, resetScrollPosition);
  9085. }
  9086. };
  9087. transitionCacheFor = function(url) {
  9088. var cachedPage;
  9089. cachedPage = pageCache[url];
  9090. if (cachedPage && !cachedPage.transitionCacheDisabled) {
  9091. return cachedPage;
  9092. }
  9093. };
  9094. enableTransitionCache = function(enable) {
  9095. if (enable == null) {
  9096. enable = true;
  9097. }
  9098. return transitionCacheEnabled = enable;
  9099. };
  9100. enableProgressBar = function(enable) {
  9101. if (enable == null) {
  9102. enable = true;
  9103. }
  9104. if (!browserSupportsTurbolinks) {
  9105. return;
  9106. }
  9107. if (enable) {
  9108. return progressBar != null ? progressBar : progressBar = new ProgressBar('html');
  9109. } else {
  9110. if (progressBar != null) {
  9111. progressBar.uninstall();
  9112. }
  9113. return progressBar = null;
  9114. }
  9115. };
  9116. fetchReplacement = function(url, onLoadFunction, showProgressBar) {
  9117. if (showProgressBar == null) {
  9118. showProgressBar = true;
  9119. }
  9120. triggerEvent(EVENTS.FETCH, {
  9121. url: url.absolute
  9122. });
  9123. if (xhr != null) {
  9124. xhr.abort();
  9125. }
  9126. xhr = new XMLHttpRequest;
  9127. xhr.open('GET', url.withoutHashForIE10compatibility(), true);
  9128. xhr.setRequestHeader('Accept', 'text/html, application/xhtml+xml, application/xml');
  9129. xhr.setRequestHeader('X-XHR-Referer', referer);
  9130. xhr.onload = function() {
  9131. var doc;
  9132. triggerEvent(EVENTS.RECEIVE, {
  9133. url: url.absolute
  9134. });
  9135. if (doc = processResponse()) {
  9136. reflectNewUrl(url);
  9137. reflectRedirectedUrl();
  9138. changePage.apply(null, extractTitleAndBody(doc));
  9139. manuallyTriggerHashChangeForFirefox();
  9140. if (typeof onLoadFunction === "function") {
  9141. onLoadFunction();
  9142. }
  9143. return triggerEvent(EVENTS.LOAD);
  9144. } else {
  9145. return document.location.href = crossOriginRedirect() || url.absolute;
  9146. }
  9147. };
  9148. if (progressBar && showProgressBar) {
  9149. xhr.onprogress = (function(_this) {
  9150. return function(event) {
  9151. var percent;
  9152. percent = event.lengthComputable ? event.loaded / event.total * 100 : progressBar.value + (100 - progressBar.value) / 10;
  9153. return progressBar.advanceTo(percent);
  9154. };
  9155. })(this);
  9156. }
  9157. xhr.onloadend = function() {
  9158. return xhr = null;
  9159. };
  9160. xhr.onerror = function() {
  9161. return document.location.href = url.absolute;
  9162. };
  9163. return xhr.send();
  9164. };
  9165. fetchHistory = function(cachedPage) {
  9166. if (xhr != null) {
  9167. xhr.abort();
  9168. }
  9169. changePage(cachedPage.title, cachedPage.body);
  9170. recallScrollPosition(cachedPage);
  9171. return triggerEvent(EVENTS.RESTORE);
  9172. };
  9173. cacheCurrentPage = function() {
  9174. var currentStateUrl;
  9175. currentStateUrl = new ComponentUrl(currentState.url);
  9176. pageCache[currentStateUrl.absolute] = {
  9177. url: currentStateUrl.relative,
  9178. body: document.body,
  9179. title: document.title,
  9180. positionY: window.pageYOffset,
  9181. positionX: window.pageXOffset,
  9182. cachedAt: new Date().getTime(),
  9183. transitionCacheDisabled: document.querySelector('[data-no-transition-cache]') != null
  9184. };
  9185. return constrainPageCacheTo(cacheSize);
  9186. };
  9187. pagesCached = function(size) {
  9188. if (size == null) {
  9189. size = cacheSize;
  9190. }
  9191. if (/^[\d]+$/.test(size)) {
  9192. return cacheSize = parseInt(size);
  9193. }
  9194. };
  9195. constrainPageCacheTo = function(limit) {
  9196. var cacheTimesRecentFirst, i, key, len, pageCacheKeys, results;
  9197. pageCacheKeys = Object.keys(pageCache);
  9198. cacheTimesRecentFirst = pageCacheKeys.map(function(url) {
  9199. return pageCache[url].cachedAt;
  9200. }).sort(function(a, b) {
  9201. return b - a;
  9202. });
  9203. results = [];
  9204. for (i = 0, len = pageCacheKeys.length; i < len; i++) {
  9205. key = pageCacheKeys[i];
  9206. if (!(pageCache[key].cachedAt <= cacheTimesRecentFirst[limit])) {
  9207. continue;
  9208. }
  9209. triggerEvent(EVENTS.EXPIRE, pageCache[key]);
  9210. results.push(delete pageCache[key]);
  9211. }
  9212. return results;
  9213. };
  9214. changePage = function(title, body, csrfToken, runScripts) {
  9215. triggerEvent(EVENTS.BEFORE_UNLOAD);
  9216. document.title = title;
  9217. document.documentElement.replaceChild(body, document.body);
  9218. if (csrfToken != null) {
  9219. CSRFToken.update(csrfToken);
  9220. }
  9221. setAutofocusElement();
  9222. if (runScripts) {
  9223. executeScriptTags();
  9224. }
  9225. currentState = window.history.state;
  9226. if (progressBar != null) {
  9227. progressBar.done();
  9228. }
  9229. triggerEvent(EVENTS.CHANGE);
  9230. return triggerEvent(EVENTS.UPDATE);
  9231. };
  9232. executeScriptTags = function() {
  9233. var attr, copy, i, j, len, len1, nextSibling, parentNode, ref, ref1, script, scripts;
  9234. scripts = Array.prototype.slice.call(document.body.querySelectorAll('script:not([data-turbolinks-eval="false"])'));
  9235. for (i = 0, len = scripts.length; i < len; i++) {
  9236. script = scripts[i];
  9237. if (!((ref = script.type) === '' || ref === 'text/javascript')) {
  9238. continue;
  9239. }
  9240. copy = document.createElement('script');
  9241. ref1 = script.attributes;
  9242. for (j = 0, len1 = ref1.length; j < len1; j++) {
  9243. attr = ref1[j];
  9244. copy.setAttribute(attr.name, attr.value);
  9245. }
  9246. if (!script.hasAttribute('async')) {
  9247. copy.async = false;
  9248. }
  9249. copy.appendChild(document.createTextNode(script.innerHTML));
  9250. parentNode = script.parentNode, nextSibling = script.nextSibling;
  9251. parentNode.removeChild(script);
  9252. parentNode.insertBefore(copy, nextSibling);
  9253. }
  9254. };
  9255. removeNoscriptTags = function(node) {
  9256. node.innerHTML = node.innerHTML.replace(/<noscript[\S\s]*?<\/noscript>/ig, '');
  9257. return node;
  9258. };
  9259. setAutofocusElement = function() {
  9260. var autofocusElement, list;
  9261. autofocusElement = (list = document.querySelectorAll('input[autofocus], textarea[autofocus]'))[list.length - 1];
  9262. if (autofocusElement && document.activeElement !== autofocusElement) {
  9263. return autofocusElement.focus();
  9264. }
  9265. };
  9266. reflectNewUrl = function(url) {
  9267. if ((url = new ComponentUrl(url)).absolute !== referer) {
  9268. return window.history.pushState({
  9269. turbolinks: true,
  9270. url: url.absolute
  9271. }, '', url.absolute);
  9272. }
  9273. };
  9274. reflectRedirectedUrl = function() {
  9275. var location, preservedHash;
  9276. if (location = xhr.getResponseHeader('X-XHR-Redirected-To')) {
  9277. location = new ComponentUrl(location);
  9278. preservedHash = location.hasNoHash() ? document.location.hash : '';
  9279. return window.history.replaceState(window.history.state, '', location.href + preservedHash);
  9280. }
  9281. };
  9282. crossOriginRedirect = function() {
  9283. var redirect;
  9284. if (((redirect = xhr.getResponseHeader('Location')) != null) && (new ComponentUrl(redirect)).crossOrigin()) {
  9285. return redirect;
  9286. }
  9287. };
  9288. rememberReferer = function() {
  9289. return referer = document.location.href;
  9290. };
  9291. rememberCurrentUrl = function() {
  9292. return window.history.replaceState({
  9293. turbolinks: true,
  9294. url: document.location.href
  9295. }, '', document.location.href);
  9296. };
  9297. rememberCurrentState = function() {
  9298. return currentState = window.history.state;
  9299. };
  9300. manuallyTriggerHashChangeForFirefox = function() {
  9301. var url;
  9302. if (navigator.userAgent.match(/Firefox/) && !(url = new ComponentUrl).hasNoHash()) {
  9303. window.history.replaceState(currentState, '', url.withoutHash());
  9304. return document.location.hash = url.hash;
  9305. }
  9306. };
  9307. recallScrollPosition = function(page) {
  9308. return window.scrollTo(page.positionX, page.positionY);
  9309. };
  9310. resetScrollPosition = function() {
  9311. if (document.location.hash) {
  9312. return document.location.href = document.location.href;
  9313. } else {
  9314. return window.scrollTo(0, 0);
  9315. }
  9316. };
  9317. clone = function(original) {
  9318. var copy, key, value;
  9319. if ((original == null) || typeof original !== 'object') {
  9320. return original;
  9321. }
  9322. copy = new original.constructor();
  9323. for (key in original) {
  9324. value = original[key];
  9325. copy[key] = clone(value);
  9326. }
  9327. return copy;
  9328. };
  9329. popCookie = function(name) {
  9330. var ref, value;
  9331. value = ((ref = document.cookie.match(new RegExp(name + "=(\\w+)"))) != null ? ref[1].toUpperCase() : void 0) || '';
  9332. document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/';
  9333. return value;
  9334. };
  9335. triggerEvent = function(name, data) {
  9336. var event;
  9337. if (typeof Prototype !== 'undefined') {
  9338. Event.fire(document, name, data, true);
  9339. }
  9340. event = document.createEvent('Events');
  9341. if (data) {
  9342. event.data = data;
  9343. }
  9344. event.initEvent(name, true, true);
  9345. return document.dispatchEvent(event);
  9346. };
  9347. pageChangePrevented = function(url) {
  9348. return !triggerEvent(EVENTS.BEFORE_CHANGE, {
  9349. url: url
  9350. });
  9351. };
  9352. processResponse = function() {
  9353. var assetsChanged, clientOrServerError, doc, extractTrackAssets, intersection, validContent;
  9354. clientOrServerError = function() {
  9355. var ref;
  9356. return (400 <= (ref = xhr.status) && ref < 600);
  9357. };
  9358. validContent = function() {
  9359. var contentType;
  9360. return ((contentType = xhr.getResponseHeader('Content-Type')) != null) && contentType.match(/^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/);
  9361. };
  9362. extractTrackAssets = function(doc) {
  9363. var i, len, node, ref, results;
  9364. ref = doc.querySelector('head').childNodes;
  9365. results = [];
  9366. for (i = 0, len = ref.length; i < len; i++) {
  9367. node = ref[i];
  9368. if ((typeof node.getAttribute === "function" ? node.getAttribute('data-turbolinks-track') : void 0) != null) {
  9369. results.push(node.getAttribute('src') || node.getAttribute('href'));
  9370. }
  9371. }
  9372. return results;
  9373. };
  9374. assetsChanged = function(doc) {
  9375. var fetchedAssets;
  9376. loadedAssets || (loadedAssets = extractTrackAssets(document));
  9377. fetchedAssets = extractTrackAssets(doc);
  9378. return fetchedAssets.length !== loadedAssets.length || intersection(fetchedAssets, loadedAssets).length !== loadedAssets.length;
  9379. };
  9380. intersection = function(a, b) {
  9381. var i, len, ref, results, value;
  9382. if (a.length > b.length) {
  9383. ref = [b, a], a = ref[0], b = ref[1];
  9384. }
  9385. results = [];
  9386. for (i = 0, len = a.length; i < len; i++) {
  9387. value = a[i];
  9388. if (indexOf.call(b, value) >= 0) {
  9389. results.push(value);
  9390. }
  9391. }
  9392. return results;
  9393. };
  9394. if (!clientOrServerError() && validContent()) {
  9395. doc = createDocument(xhr.responseText);
  9396. if (doc && !assetsChanged(doc)) {
  9397. return doc;
  9398. }
  9399. }
  9400. };
  9401. extractTitleAndBody = function(doc) {
  9402. var title;
  9403. title = doc.querySelector('title');
  9404. return [title != null ? title.textContent : void 0, removeNoscriptTags(doc.querySelector('body')), CSRFToken.get(doc).token, 'runScripts'];
  9405. };
  9406. CSRFToken = {
  9407. get: function(doc) {
  9408. var tag;
  9409. if (doc == null) {
  9410. doc = document;
  9411. }
  9412. return {
  9413. node: tag = doc.querySelector('meta[name="csrf-token"]'),
  9414. token: tag != null ? typeof tag.getAttribute === "function" ? tag.getAttribute('content') : void 0 : void 0
  9415. };
  9416. },
  9417. update: function(latest) {
  9418. var current;
  9419. current = this.get();
  9420. if ((current.token != null) && (latest != null) && current.token !== latest) {
  9421. return current.node.setAttribute('content', latest);
  9422. }
  9423. }
  9424. };
  9425. createDocument = function(html) {
  9426. var doc;
  9427. doc = document.documentElement.cloneNode();
  9428. doc.innerHTML = html;
  9429. doc.head = doc.querySelector('head');
  9430. doc.body = doc.querySelector('body');
  9431. return doc;
  9432. };
  9433. ComponentUrl = (function() {
  9434. function ComponentUrl(original1) {
  9435. this.original = original1 != null ? original1 : document.location.href;
  9436. if (this.original.constructor === ComponentUrl) {
  9437. return this.original;
  9438. }
  9439. this._parse();
  9440. }
  9441. ComponentUrl.prototype.withoutHash = function() {
  9442. return this.href.replace(this.hash, '').replace('#', '');
  9443. };
  9444. ComponentUrl.prototype.withoutHashForIE10compatibility = function() {
  9445. return this.withoutHash();
  9446. };
  9447. ComponentUrl.prototype.hasNoHash = function() {
  9448. return this.hash.length === 0;
  9449. };
  9450. ComponentUrl.prototype.crossOrigin = function() {
  9451. return this.origin !== (new ComponentUrl).origin;
  9452. };
  9453. ComponentUrl.prototype._parse = function() {
  9454. var ref;
  9455. (this.link != null ? this.link : this.link = document.createElement('a')).href = this.original;
  9456. ref = this.link, this.href = ref.href, this.protocol = ref.protocol, this.host = ref.host, this.hostname = ref.hostname, this.port = ref.port, this.pathname = ref.pathname, this.search = ref.search, this.hash = ref.hash;
  9457. this.origin = [this.protocol, '//', this.hostname].join('');
  9458. if (this.port.length !== 0) {
  9459. this.origin += ":" + this.port;
  9460. }
  9461. this.relative = [this.pathname, this.search, this.hash].join('');
  9462. return this.absolute = this.href;
  9463. };
  9464. return ComponentUrl;
  9465. })();
  9466. Link = (function(superClass) {
  9467. extend(Link, superClass);
  9468. Link.HTML_EXTENSIONS = ['html'];
  9469. Link.allowExtensions = function() {
  9470. var extension, extensions, i, len;
  9471. extensions = 1 <= arguments.length ? slice.call(arguments, 0) : [];
  9472. for (i = 0, len = extensions.length; i < len; i++) {
  9473. extension = extensions[i];
  9474. Link.HTML_EXTENSIONS.push(extension);
  9475. }
  9476. return Link.HTML_EXTENSIONS;
  9477. };
  9478. function Link(link1) {
  9479. this.link = link1;
  9480. if (this.link.constructor === Link) {
  9481. return this.link;
  9482. }
  9483. this.original = this.link.href;
  9484. this.originalElement = this.link;
  9485. this.link = this.link.cloneNode(false);
  9486. Link.__super__.constructor.apply(this, arguments);
  9487. }
  9488. Link.prototype.shouldIgnore = function() {
  9489. return this.crossOrigin() || this._anchored() || this._nonHtml() || this._optOut() || this._target();
  9490. };
  9491. Link.prototype._anchored = function() {
  9492. return (this.hash.length > 0 || this.href.charAt(this.href.length - 1) === '#') && (this.withoutHash() === (new ComponentUrl).withoutHash());
  9493. };
  9494. Link.prototype._nonHtml = function() {
  9495. return this.pathname.match(/\.[a-z]+$/g) && !this.pathname.match(new RegExp("\\.(?:" + (Link.HTML_EXTENSIONS.join('|')) + ")?$", 'g'));
  9496. };
  9497. Link.prototype._optOut = function() {
  9498. var ignore, link;
  9499. link = this.originalElement;
  9500. while (!(ignore || link === document)) {
  9501. ignore = link.getAttribute('data-no-turbolink') != null;
  9502. link = link.parentNode;
  9503. }
  9504. return ignore;
  9505. };
  9506. Link.prototype._target = function() {
  9507. return this.link.target.length !== 0;
  9508. };
  9509. return Link;
  9510. })(ComponentUrl);
  9511. Click = (function() {
  9512. Click.installHandlerLast = function(event) {
  9513. if (!event.defaultPrevented) {
  9514. document.removeEventListener('click', Click.handle, false);
  9515. return document.addEventListener('click', Click.handle, false);
  9516. }
  9517. };
  9518. Click.handle = function(event) {
  9519. return new Click(event);
  9520. };
  9521. function Click(event1) {
  9522. this.event = event1;
  9523. if (this.event.defaultPrevented) {
  9524. return;
  9525. }
  9526. this._extractLink();
  9527. if (this._validForTurbolinks()) {
  9528. if (!pageChangePrevented(this.link.absolute)) {
  9529. visit(this.link.href);
  9530. }
  9531. this.event.preventDefault();
  9532. }
  9533. }
  9534. Click.prototype._extractLink = function() {
  9535. var link;
  9536. link = this.event.target;
  9537. while (!(!link.parentNode || link.nodeName === 'A')) {
  9538. link = link.parentNode;
  9539. }
  9540. if (link.nodeName === 'A' && link.href.length !== 0) {
  9541. return this.link = new Link(link);
  9542. }
  9543. };
  9544. Click.prototype._validForTurbolinks = function() {
  9545. return (this.link != null) && !(this.link.shouldIgnore() || this._nonStandardClick());
  9546. };
  9547. Click.prototype._nonStandardClick = function() {
  9548. return this.event.which > 1 || this.event.metaKey || this.event.ctrlKey || this.event.shiftKey || this.event.altKey;
  9549. };
  9550. return Click;
  9551. })();
  9552. ProgressBar = (function() {
  9553. var className;
  9554. className = 'turbolinks-progress-bar';
  9555. function ProgressBar(elementSelector) {
  9556. this.elementSelector = elementSelector;
  9557. this._trickle = bind(this._trickle, this);
  9558. this.value = 0;
  9559. this.content = '';
  9560. this.speed = 300;
  9561. this.opacity = 0.99;
  9562. this.install();
  9563. }
  9564. ProgressBar.prototype.install = function() {
  9565. this.element = document.querySelector(this.elementSelector);
  9566. this.element.classList.add(className);
  9567. this.styleElement = document.createElement('style');
  9568. document.head.appendChild(this.styleElement);
  9569. return this._updateStyle();
  9570. };
  9571. ProgressBar.prototype.uninstall = function() {
  9572. this.element.classList.remove(className);
  9573. return document.head.removeChild(this.styleElement);
  9574. };
  9575. ProgressBar.prototype.start = function() {
  9576. return this.advanceTo(5);
  9577. };
  9578. ProgressBar.prototype.advanceTo = function(value) {
  9579. var ref;
  9580. if ((value > (ref = this.value) && ref <= 100)) {
  9581. this.value = value;
  9582. this._updateStyle();
  9583. if (this.value === 100) {
  9584. return this._stopTrickle();
  9585. } else if (this.value > 0) {
  9586. return this._startTrickle();
  9587. }
  9588. }
  9589. };
  9590. ProgressBar.prototype.done = function() {
  9591. if (this.value > 0) {
  9592. this.advanceTo(100);
  9593. return this._reset();
  9594. }
  9595. };
  9596. ProgressBar.prototype._reset = function() {
  9597. var originalOpacity;
  9598. originalOpacity = this.opacity;
  9599. setTimeout((function(_this) {
  9600. return function() {
  9601. _this.opacity = 0;
  9602. return _this._updateStyle();
  9603. };
  9604. })(this), this.speed / 2);
  9605. return setTimeout((function(_this) {
  9606. return function() {
  9607. _this.value = 0;
  9608. _this.opacity = originalOpacity;
  9609. return _this._withSpeed(0, function() {
  9610. return _this._updateStyle(true);
  9611. });
  9612. };
  9613. })(this), this.speed);
  9614. };
  9615. ProgressBar.prototype._startTrickle = function() {
  9616. if (this.trickling) {
  9617. return;
  9618. }
  9619. this.trickling = true;
  9620. return setTimeout(this._trickle, this.speed);
  9621. };
  9622. ProgressBar.prototype._stopTrickle = function() {
  9623. return delete this.trickling;
  9624. };
  9625. ProgressBar.prototype._trickle = function() {
  9626. if (!this.trickling) {
  9627. return;
  9628. }
  9629. this.advanceTo(this.value + Math.random() / 2);
  9630. return setTimeout(this._trickle, this.speed);
  9631. };
  9632. ProgressBar.prototype._withSpeed = function(speed, fn) {
  9633. var originalSpeed, result;
  9634. originalSpeed = this.speed;
  9635. this.speed = speed;
  9636. result = fn();
  9637. this.speed = originalSpeed;
  9638. return result;
  9639. };
  9640. ProgressBar.prototype._updateStyle = function(forceRepaint) {
  9641. if (forceRepaint == null) {
  9642. forceRepaint = false;
  9643. }
  9644. if (forceRepaint) {
  9645. this._changeContentToForceRepaint();
  9646. }
  9647. return this.styleElement.textContent = this._createCSSRule();
  9648. };
  9649. ProgressBar.prototype._changeContentToForceRepaint = function() {
  9650. return this.content = this.content === '' ? ' ' : '';
  9651. };
  9652. ProgressBar.prototype._createCSSRule = function() {
  9653. return this.elementSelector + "." + className + "::before {\n content: '" + this.content + "';\n position: fixed;\n top: 0;\n left: 0;\n z-index: 2000;\n background-color: #0076ff;\n height: 3px;\n opacity: " + this.opacity + ";\n width: " + this.value + "%;\n transition: width " + this.speed + "ms ease-out, opacity " + (this.speed / 2) + "ms ease-in;\n transform: translate3d(0,0,0);\n}";
  9654. };
  9655. return ProgressBar;
  9656. })();
  9657. bypassOnLoadPopstate = function(fn) {
  9658. return setTimeout(fn, 500);
  9659. };
  9660. installDocumentReadyPageEventTriggers = function() {
  9661. return document.addEventListener('DOMContentLoaded', (function() {
  9662. triggerEvent(EVENTS.CHANGE);
  9663. return triggerEvent(EVENTS.UPDATE);
  9664. }), true);
  9665. };
  9666. installJqueryAjaxSuccessPageUpdateTrigger = function() {
  9667. if (typeof jQuery !== 'undefined') {
  9668. return jQuery(document).on('ajaxSuccess', function(event, xhr, settings) {
  9669. if (!jQuery.trim(xhr.responseText)) {
  9670. return;
  9671. }
  9672. return triggerEvent(EVENTS.UPDATE);
  9673. });
  9674. }
  9675. };
  9676. installHistoryChangeHandler = function(event) {
  9677. var cachedPage, ref;
  9678. if ((ref = event.state) != null ? ref.turbolinks : void 0) {
  9679. if (cachedPage = pageCache[(new ComponentUrl(event.state.url)).absolute]) {
  9680. cacheCurrentPage();
  9681. return fetchHistory(cachedPage);
  9682. } else {
  9683. return visit(event.target.location.href);
  9684. }
  9685. }
  9686. };
  9687. initializeTurbolinks = function() {
  9688. rememberCurrentUrl();
  9689. rememberCurrentState();
  9690. document.addEventListener('click', Click.installHandlerLast, true);
  9691. window.addEventListener('hashchange', function(event) {
  9692. rememberCurrentUrl();
  9693. return rememberCurrentState();
  9694. }, false);
  9695. return bypassOnLoadPopstate(function() {
  9696. return window.addEventListener('popstate', installHistoryChangeHandler, false);
  9697. });
  9698. };
  9699. historyStateIsDefined = window.history.state !== void 0 || navigator.userAgent.match(/Firefox\/2[6|7]/);
  9700. browserSupportsPushState = window.history && window.history.pushState && window.history.replaceState && historyStateIsDefined;
  9701. browserIsntBuggy = !navigator.userAgent.match(/CriOS\//);
  9702. requestMethodIsSafe = (ref = popCookie('request_method')) === 'GET' || ref === '';
  9703. browserSupportsTurbolinks = browserSupportsPushState && browserIsntBuggy && requestMethodIsSafe;
  9704. browserSupportsCustomEvents = document.addEventListener && document.createEvent;
  9705. if (browserSupportsCustomEvents) {
  9706. installDocumentReadyPageEventTriggers();
  9707. installJqueryAjaxSuccessPageUpdateTrigger();
  9708. }
  9709. if (browserSupportsTurbolinks) {
  9710. visit = fetch;
  9711. initializeTurbolinks();
  9712. } else {
  9713. visit = function(url) {
  9714. return document.location.href = url;
  9715. };
  9716. }
  9717. this.Turbolinks = {
  9718. visit: visit,
  9719. pagesCached: pagesCached,
  9720. enableTransitionCache: enableTransitionCache,
  9721. enableProgressBar: enableProgressBar,
  9722. allowLinkExtensions: Link.allowExtensions,
  9723. supported: browserSupportsTurbolinks,
  9724. EVENTS: clone(EVENTS)
  9725. };
  9726. }).call(this);
  9727. /* Modernizr 2.6.2 (Custom Build) | MIT & BSD
  9728. * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
  9729. */
  9730. ;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d<e;d++)u[c[d]]=c[d]in k;return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){for(var d=0,e,f,h,i=a.length;d<i;d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;visibility:hidden;",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;return t}("search tel url email datetime date month week time datetime-local number range color".split(" "))}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={}.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={svg:"http://www.w3.org/2000/svg"},s={},t={},u={},v=[],w=v.slice,x,y=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["&#173;",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.borderradius=function(){return J("borderRadius")},s.boxshadow=function(){return J("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML="<svg/>",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&&!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e<g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&&!f&&!c.hasCSS&&(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f<d;f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));for(f=0;f<b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&b++;return b}(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&&a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&&l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&&c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i<a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);else Object(a)===a&&h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))};
  9731. /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
  9732. /*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
  9733. window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.style.background="none";d.appendChild(g);return function(h){g.innerHTML='&shy;<style media="'+h+'"> #mq-test-1 { width: 42px; }</style>';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document);
  9734. /*! Respond.js v1.1.0: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs */
  9735. (function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var w=e.document,s=w.documentElement,i=[],k=[],q=[],o={},h=30,f=w.getElementsByTagName("head")[0]||s,g=w.getElementsByTagName("base")[0],b=f.getElementsByTagName("link"),d=[],a=function(){var D=b,y=D.length,B=0,A,z,C,x;for(;B<y;B++){A=D[B],z=A.href,C=A.media,x=A.rel&&A.rel.toLowerCase()==="stylesheet";if(!!z&&x&&!o[z]){if(A.styleSheet&&A.styleSheet.rawCssText){m(A.styleSheet.rawCssText,z,C);o[z]=true}else{if((!/^([a-zA-Z:]*\/\/)/.test(z)&&!g)||z.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:z,media:C})}}}}u()},u=function(){if(d.length){var x=d.shift();n(x.href,function(y){m(y,x.href,x.media);o[x.href]=true;u()})}},m=function(I,x,z){var G=I.match(/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi),J=G&&G.length||0,x=x.substring(0,x.lastIndexOf("/")),y=function(K){return K.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+x+"$2$3")},A=!J&&z,D=0,C,E,F,B,H;if(x.length){x+="/"}if(A){J=1}for(;D<J;D++){C=0;if(A){E=z;k.push(y(I))}else{E=G[D].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;k.push(RegExp.$2&&y(RegExp.$2))}B=E.split(",");H=B.length;for(;C<H;C++){F=B[C];i.push({media:F.split("(")[0].match(/(only\s+)?([a-zA-Z]+)\s?/)&&RegExp.$2||"all",rules:k.length-1,hasquery:F.indexOf("(")>-1,minw:F.match(/\(min\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:F.match(/\(max\-width:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}}j()},l,r,v=function(){var z,A=w.createElement("div"),x=w.body,y=false;A.style.cssText="position:absolute;font-size:1em;width:1em";if(!x){x=y=w.createElement("body");x.style.background="none"}x.appendChild(A);s.insertBefore(x,s.firstChild);z=A.offsetWidth;if(y){s.removeChild(x)}else{x.removeChild(A)}z=p=parseFloat(z);return z},p,j=function(I){var x="clientWidth",B=s[x],H=w.compatMode==="CSS1Compat"&&B||w.body[x]||B,D={},G=b[b.length-1],z=(new Date()).getTime();if(I&&l&&z-l<h){clearTimeout(r);r=setTimeout(j,h);return}else{l=z}for(var E in i){var K=i[E],C=K.minw,J=K.maxw,A=C===null,L=J===null,y="em";if(!!C){C=parseFloat(C)*(C.indexOf(y)>-1?(p||v()):1)}if(!!J){J=parseFloat(J)*(J.indexOf(y)>-1?(p||v()):1)}if(!K.hasquery||(!A||!L)&&(A||H>=C)&&(L||H<=J)){if(!D[K.media]){D[K.media]=[]}D[K.media].push(k[K.rules])}}for(var E in q){if(q[E]&&q[E].parentNode===f){f.removeChild(q[E])}}for(var E in D){var M=w.createElement("style"),F=D[E].join("\n");M.type="text/css";M.media=E;f.insertBefore(M,G.nextSibling);if(M.styleSheet){M.styleSheet.cssText=F}else{M.appendChild(w.createTextNode(F))}q.push(M)}},n=function(x,z){var y=c();if(!y){return}y.open("GET",x,true);y.onreadystatechange=function(){if(y.readyState!=4||y.status!=200&&y.status!=304){return}z(y.responseText)};if(y.readyState==4){return}y.send(null)},c=(function(){var x=false;try{x=new XMLHttpRequest()}catch(y){x=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return x}})();a();respond.update=a;function t(){j(true)}if(e.addEventListener){e.addEventListener("resize",t,false)}else{if(e.attachEvent){e.attachEvent("onresize",t)}}})(this);
  9736. (function($) {
  9737. var cocoon_element_counter = 0;
  9738. var create_new_id = function() {
  9739. return (new Date().getTime() + cocoon_element_counter++);
  9740. }
  9741. var newcontent_braced = function(id) {
  9742. return '[' + id + ']$1';
  9743. }
  9744. var newcontent_underscord = function(id) {
  9745. return '_' + id + '_$1';
  9746. }
  9747. $(document).on('click', '.add_fields', function(e) {
  9748. e.preventDefault();
  9749. var $this = $(this),
  9750. assoc = $this.data('association'),
  9751. assocs = $this.data('associations'),
  9752. content = $this.data('association-insertion-template'),
  9753. insertionMethod = $this.data('association-insertion-method') || $this.data('association-insertion-position') || 'before',
  9754. insertionNode = $this.data('association-insertion-node'),
  9755. insertionTraversal = $this.data('association-insertion-traversal'),
  9756. count = parseInt($this.data('count'), 10),
  9757. regexp_braced = new RegExp('\\[new_' + assoc + '\\](.*?\\s)', 'g'),
  9758. regexp_underscord = new RegExp('_new_' + assoc + '_(\\w*)', 'g'),
  9759. new_id = create_new_id(),
  9760. new_content = content.replace(regexp_braced, newcontent_braced(new_id)),
  9761. new_contents = [];
  9762. if (new_content == content) {
  9763. regexp_braced = new RegExp('\\[new_' + assocs + '\\](.*?\\s)', 'g');
  9764. regexp_underscord = new RegExp('_new_' + assocs + '_(\\w*)', 'g');
  9765. new_content = content.replace(regexp_braced, newcontent_braced(new_id));
  9766. }
  9767. new_content = new_content.replace(regexp_underscord, newcontent_underscord(new_id));
  9768. new_contents = [new_content];
  9769. count = (isNaN(count) ? 1 : Math.max(count, 1));
  9770. count -= 1;
  9771. while (count) {
  9772. new_id = create_new_id();
  9773. new_content = content.replace(regexp_braced, newcontent_braced(new_id));
  9774. new_content = new_content.replace(regexp_underscord, newcontent_underscord(new_id));
  9775. new_contents.push(new_content);
  9776. count -= 1;
  9777. }
  9778. if (insertionNode){
  9779. if (insertionTraversal){
  9780. insertionNode = $this[insertionTraversal](insertionNode);
  9781. } else {
  9782. insertionNode = insertionNode == "this" ? $this : $(insertionNode);
  9783. }
  9784. } else {
  9785. insertionNode = $this.parent();
  9786. }
  9787. $.each(new_contents, function(i, node) {
  9788. var contentNode = $(node);
  9789. insertionNode.trigger('cocoon:before-insert', [contentNode]);
  9790. // allow any of the jquery dom manipulation methods (after, before, append, prepend, etc)
  9791. // to be called on the node. allows the insertion node to be the parent of the inserted
  9792. // code and doesn't force it to be a sibling like after/before does. default: 'before'
  9793. var addedContent = insertionNode[insertionMethod](contentNode);
  9794. insertionNode.trigger('cocoon:after-insert', [contentNode]);
  9795. });
  9796. });
  9797. $(document).on('click', '.remove_fields.dynamic, .remove_fields.existing', function(e) {
  9798. var $this = $(this),
  9799. wrapper_class = $this.data('wrapper-class') || 'nested-fields',
  9800. node_to_delete = $this.closest('.' + wrapper_class),
  9801. trigger_node = node_to_delete.parent();
  9802. e.preventDefault();
  9803. trigger_node.trigger('cocoon:before-remove', [node_to_delete]);
  9804. var timeout = trigger_node.data('remove-timeout') || 0;
  9805. setTimeout(function() {
  9806. if ($this.hasClass('dynamic')) {
  9807. node_to_delete.remove();
  9808. } else {
  9809. $this.prev("input[type=hidden]").val("1");
  9810. node_to_delete.hide();
  9811. }
  9812. trigger_node.trigger('cocoon:after-remove', [node_to_delete]);
  9813. }, timeout);
  9814. });
  9815. $('.remove_fields.existing.destroyed').each(function(i, obj) {
  9816. var $this = $(this),
  9817. wrapper_class = $this.data('wrapper-class') || 'nested-fields';
  9818. $this.closest('.' + wrapper_class).hide();
  9819. });
  9820. })(jQuery);
  9821. /*
  9822. Textile Editor v0.2
  9823. created by: dave olsen, wvu web services
  9824. created on: march 17, 2007
  9825. project page: slateinfo.blogs.wvu.edu
  9826. inspired by:
  9827. - Patrick Woods, http://www.hakjoon.com/code/38/textile-quicktags-redirect &
  9828. - Alex King, http://alexking.org/projects/js-quicktags
  9829. features:
  9830. - supports: IE7, FF2, Safari2
  9831. - ability to use "simple" vs. "extended" editor
  9832. - supports all block elements in textile except footnote
  9833. - supports all block modifier elements in textile
  9834. - supports simple ordered and unordered lists
  9835. - supports most of the phrase modifiers, very easy to add the missing ones
  9836. - supports multiple-paragraph modification
  9837. - can have multiple "editors" on one page, access key use in this environment is flaky
  9838. - access key support
  9839. - select text to add and remove tags, selection stays highlighted
  9840. - seamlessly change between tags and modifiers
  9841. - doesn't need to be in the body onload tag
  9842. - can supply your own, custom IDs for the editor to be drawn around
  9843. todo:
  9844. - a clean way of providing image and link inserts
  9845. - get the selection to properly show in IE
  9846. more on textile:
  9847. - Textism, http://www.textism.com/tools/textile/index.php
  9848. - Textile Reference, http://hobix.com/textile/
  9849. */
  9850. // Define Button Object
  9851. function TextileEditorButton(id, display, tagStart, tagEnd, access, title, sve, open) {
  9852. this.id = id; // used to name the toolbar button
  9853. this.display = display; // label on button
  9854. this.tagStart = tagStart; // open tag
  9855. this.tagEnd = tagEnd; // close tag
  9856. this.access = access; // set to -1 if tag does not need to be closed
  9857. this.title = title; // sets the title attribute of the button to give 'tool tips'
  9858. this.sve = sve; // sve = simple vs. extended. add an 's' to make it show up in the simple toolbar
  9859. this.open = open; // set to -1 if tag does not need to be closed
  9860. this.standard = true; // this is a standard button
  9861. // this.framework = 'prototype'; // the JS framework used
  9862. }
  9863. function TextileEditorButtonSeparator(sve) {
  9864. this.separator = true;
  9865. this.sve = sve;
  9866. }
  9867. var TextileEditor = function() {};
  9868. TextileEditor.buttons = new Array();
  9869. TextileEditor.Methods = {
  9870. // class methods
  9871. // create the toolbar (edToolbar)
  9872. initialize: function(canvas, view) {
  9873. var toolbar = document.createElement("div");
  9874. toolbar.id = "textile-toolbar-" + canvas;
  9875. toolbar.className = 'textile-toolbar';
  9876. this.canvas = document.getElementById(canvas);
  9877. this.canvas.parentNode.insertBefore(toolbar, this.canvas);
  9878. this.openTags = new Array();
  9879. // Create the local Button array by assigning theButtons array to edButtons
  9880. var edButtons = new Array();
  9881. edButtons = this.buttons;
  9882. var standardButtons = new Array();
  9883. for(var i = 0; i < edButtons.length; i++) {
  9884. var thisButton = this.prepareButton(edButtons[i]);
  9885. if (view == 's') {
  9886. if (edButtons[i].sve == 's') {
  9887. toolbar.appendChild(thisButton);
  9888. standardButtons.push(thisButton);
  9889. }
  9890. } else {
  9891. if (typeof thisButton == 'string') {
  9892. toolbar.innerHTML += thisButton;
  9893. } else {
  9894. toolbar.appendChild(thisButton);
  9895. standardButtons.push(thisButton);
  9896. }
  9897. }
  9898. } // end for
  9899. var te = this;
  9900. var buttons = toolbar.getElementsByTagName('button');
  9901. for(var i = 0; i < buttons.length; i++) {
  9902. //$A(toolbar.getElementsByTagName('button')).each(function(button) {
  9903. if (!buttons[i].onclick) {
  9904. buttons[i].onclick = function() { te.insertTag(this); return false; }
  9905. } // end if
  9906. buttons[i].tagStart = buttons[i].getAttribute('tagStart');
  9907. buttons[i].tagEnd = buttons[i].getAttribute('tagEnd');
  9908. buttons[i].open = buttons[i].getAttribute('open');
  9909. buttons[i].textile_editor = te;
  9910. buttons[i].canvas = te.canvas;
  9911. // console.log(buttons[i].canvas);
  9912. //});
  9913. }
  9914. }, // end initialize
  9915. // draw individual buttons (edShowButton)
  9916. prepareButton: function(button) {
  9917. if (button.separator) {
  9918. var theButton = document.createElement('span');
  9919. theButton.className = 'ed_sep';
  9920. return theButton;
  9921. }
  9922. if (button.standard) {
  9923. var theButton = document.createElement("button");
  9924. theButton.id = button.id;
  9925. theButton.setAttribute('class', 'standard');
  9926. theButton.setAttribute('tagStart', button.tagStart);
  9927. theButton.setAttribute('tagEnd', button.tagEnd);
  9928. theButton.setAttribute('open', button.open);
  9929. var img = document.createElement('img');
  9930. img.src = '/textile-editor/' + button.display;
  9931. theButton.appendChild(img);
  9932. } else {
  9933. return button;
  9934. } // end if !custom
  9935. theButton.accessKey = button.access;
  9936. theButton.title = button.title;
  9937. return theButton;
  9938. }, // end prepareButton
  9939. // if clicked, no selected text, tag not open highlight button
  9940. // (edAddTag)
  9941. addTag: function(button) {
  9942. if (button.tagEnd != '') {
  9943. this.openTags[this.openTags.length] = button;
  9944. //var el = document.getElementById(button.id);
  9945. //el.className = 'selected';
  9946. button.className = 'selected';
  9947. }
  9948. }, // end addTag
  9949. // if clicked, no selected text, tag open lowlight button
  9950. // (edRemoveTag)
  9951. removeTag: function(button) {
  9952. for (i = 0; i < this.openTags.length; i++) {
  9953. if (this.openTags[i] == button) {
  9954. this.openTags.splice(button, 1);
  9955. //var el = document.getElementById(button.id);
  9956. //el.className = 'unselected';
  9957. button.className = 'unselected';
  9958. }
  9959. }
  9960. }, // end removeTag
  9961. // see if there are open tags. for the remove tag bit...
  9962. // (edCheckOpenTags)
  9963. checkOpenTags: function(button) {
  9964. var tag = 0;
  9965. for (i = 0; i < this.openTags.length; i++) {
  9966. if (this.openTags[i] == button) {
  9967. tag++;
  9968. }
  9969. }
  9970. if (tag > 0) {
  9971. return true; // tag found
  9972. }
  9973. else {
  9974. return false; // tag not found
  9975. }
  9976. }, // end checkOpenTags
  9977. // insert the tag. this is the bulk of the code.
  9978. // (edInsertTag)
  9979. insertTag: function(button, tagStart, tagEnd) {
  9980. // console.log(button);
  9981. var myField = button.canvas;
  9982. myField.focus();
  9983. if (tagStart) {
  9984. button.tagStart = tagStart;
  9985. button.tagEnd = tagEnd ? tagEnd : '\n';
  9986. }
  9987. var textSelected = false;
  9988. var finalText = '';
  9989. var FF = false;
  9990. // grab the text that's going to be manipulated, by browser
  9991. if (document.selection) { // IE support
  9992. sel = document.selection.createRange();
  9993. // set-up the text vars
  9994. var beginningText = '';
  9995. var followupText = '';
  9996. var selectedText = sel.text;
  9997. // check if text has been selected
  9998. if (sel.text.length > 0) {
  9999. textSelected = true;
  10000. }
  10001. // set-up newline regex's so we can swap tags across multiple paragraphs
  10002. var newlineReplaceRegexClean = /\r\n\s\n/g;
  10003. var newlineReplaceRegexDirty = '\\r\\n\\s\\n';
  10004. var newlineReplaceClean = '\r\n\n';
  10005. }
  10006. else if (myField.selectionStart || myField.selectionStart == '0') { // MOZ/FF/NS/S support
  10007. // figure out cursor and selection positions
  10008. var startPos = myField.selectionStart;
  10009. var endPos = myField.selectionEnd;
  10010. var cursorPos = endPos;
  10011. var scrollTop = myField.scrollTop;
  10012. FF = true; // note that is is a FF/MOZ/NS/S browser
  10013. // set-up the text vars
  10014. var beginningText = myField.value.substring(0, startPos);
  10015. var followupText = myField.value.substring(endPos, myField.value.length);
  10016. // check if text has been selected
  10017. if (startPos != endPos) {
  10018. textSelected = true;
  10019. var selectedText = myField.value.substring(startPos, endPos);
  10020. }
  10021. // set-up newline regex's so we can swap tags across multiple paragraphs
  10022. var newlineReplaceRegexClean = /\n\n/g;
  10023. var newlineReplaceRegexDirty = '\\n\\n';
  10024. var newlineReplaceClean = '\n\n';
  10025. }
  10026. // if there is text that has been highlighted...
  10027. if (textSelected) {
  10028. // set-up some defaults for how to handle bad new line characters
  10029. var newlineStart = '';
  10030. var newlineStartPos = 0;
  10031. var newlineEnd = '';
  10032. var newlineEndPos = 0;
  10033. var newlineFollowup = '';
  10034. // set-up some defaults for how to handle placing the beginning and end of selection
  10035. var posDiffPos = 0;
  10036. var posDiffNeg = 0;
  10037. var mplier = 1;
  10038. // remove newline from the beginning of the selectedText.
  10039. if (selectedText.match(/^\n/)) {
  10040. selectedText = selectedText.replace(/^\n/,'');
  10041. newlineStart = '\n';
  10042. newlineStartpos = 1;
  10043. }
  10044. // remove newline from the end of the selectedText.
  10045. if (selectedText.match(/\n$/g)) {
  10046. selectedText = selectedText.replace(/\n$/g,'');
  10047. newlineEnd = '\n';
  10048. newlineEndPos = 1;
  10049. }
  10050. // remove space from the end of the selectedText.
  10051. // Fixes a bug that causes any browser running under Microsoft Internet Explorer
  10052. // to append an additional space before the closing element.
  10053. // *Bold text *here => *Bold text*
  10054. if (selectedText.match(/\s$/g)) {
  10055. selectedText = selectedText.replace(/\s$/g,'');
  10056. followupText = ' ' + followupText;
  10057. }
  10058. // no clue, i'm sure it made sense at the time i wrote it
  10059. if (followupText.match(/^\n/)) {
  10060. newlineFollowup = '';
  10061. }
  10062. else {
  10063. newlineFollowup = '\n\n';
  10064. }
  10065. // first off let's check if the user is trying to mess with lists
  10066. if ((button.tagStart == ' * ') || (button.tagStart == ' # ')) {
  10067. listItems = 0; // sets up a default to be able to properly manipulate final selection
  10068. // set-up all of the regex's
  10069. re_start = new RegExp('^ (\\*|\\#) ','g');
  10070. if (button.tagStart == ' # ') {
  10071. re_tag = new RegExp(' \\# ','g'); // because of JS regex stupidity i need an if/else to properly set it up, could have done it with a regex replace though
  10072. }
  10073. else {
  10074. re_tag = new RegExp(' \\* ','g');
  10075. }
  10076. re_replace = new RegExp(' (\\*|\\#) ','g');
  10077. // try to remove bullets in text copied from ms word **Mac Only!**
  10078. re_word_bullet_m_s = new RegExp('• ','g'); // mac/safari
  10079. re_word_bullet_m_f = new RegExp('∑ ','g'); // mac/firefox
  10080. selectedText = selectedText.replace(re_word_bullet_m_s,'').replace(re_word_bullet_m_f,'');
  10081. // if the selected text starts with one of the tags we're working with...
  10082. if (selectedText.match(re_start)) {
  10083. // if tag that begins the selection matches the one clicked, remove them all
  10084. if (selectedText.match(re_tag)) {
  10085. finalText = beginningText
  10086. + newlineStart
  10087. + selectedText.replace(re_replace,'')
  10088. + newlineEnd
  10089. + followupText;
  10090. if (matches = selectedText.match(/ (\*|\#) /g)) {
  10091. listItems = matches.length;
  10092. }
  10093. posDiffNeg = listItems*3; // how many list items were there because that's 3 spaces to remove from final selection
  10094. }
  10095. // else replace the current tag type with the selected tag type
  10096. else {
  10097. finalText = beginningText
  10098. + newlineStart
  10099. + selectedText.replace(re_replace,button.tagStart)
  10100. + newlineEnd
  10101. + followupText;
  10102. }
  10103. }
  10104. // else try to create the list type
  10105. // NOTE: the items in a list will only be replaced if a newline starts with some character, not a space
  10106. else {
  10107. finalText = beginningText
  10108. + newlineStart
  10109. + button.tagStart
  10110. + selectedText.replace(newlineReplaceRegexClean,newlineReplaceClean + button.tagStart).replace(/\n(\S)/g,'\n' + button.tagStart + '$1')
  10111. + newlineEnd
  10112. + followupText;
  10113. if (matches = selectedText.match(/\n(\S)/g)) {
  10114. listItems = matches.length;
  10115. }
  10116. posDiffPos = 3 + listItems*3;
  10117. }
  10118. }
  10119. // now lets look and see if the user is trying to muck with a block or block modifier
  10120. else if (button.tagStart.match(/^(h1|h2|h3|h4|h5|h6|bq|p|\>|\<\>|\<|\=|\(|\))/g)) {
  10121. var insertTag = '';
  10122. var insertModifier = '';
  10123. var tagPartBlock = '';
  10124. var tagPartModifier = '';
  10125. var tagPartModifierOrig = ''; // ugly hack but it's late
  10126. var drawSwitch = '';
  10127. var captureIndentStart = false;
  10128. var captureListStart = false;
  10129. var periodAddition = '\\. ';
  10130. var periodAdditionClean = '. ';
  10131. var listItemsAddition = 0;
  10132. var re_list_items = new RegExp('(\\*+|\\#+)','g'); // need this regex later on when checking indentation of lists
  10133. var re_block_modifier = new RegExp('^(h1|h2|h3|h4|h5|h6|bq|p| [\\*]{1,} | [\\#]{1,} |)(\\>|\\<\\>|\\<|\\=|[\\(]{1,}|[\\)]{1,6}|)','g');
  10134. if (tagPartMatches = re_block_modifier.exec(selectedText)) {
  10135. tagPartBlock = tagPartMatches[1];
  10136. tagPartModifier = tagPartMatches[2];
  10137. tagPartModifierOrig = tagPartMatches[2];
  10138. tagPartModifierOrig = tagPartModifierOrig.replace(/\(/g,"\\(");
  10139. }
  10140. // if tag already up is the same as the tag provided replace the whole tag
  10141. if (tagPartBlock == button.tagStart) {
  10142. insertTag = tagPartBlock + tagPartModifierOrig; // use Orig because it's escaped for regex
  10143. drawSwitch = 0;
  10144. }
  10145. // else if let's check to add/remove block modifier
  10146. else if ((tagPartModifier == button.tagStart) || (newm = tagPartModifier.match(/[\(]{2,}/g))) {
  10147. if ((button.tagStart == '(') || (button.tagStart == ')')) {
  10148. var indentLength = tagPartModifier.length;
  10149. if (button.tagStart == '(') {
  10150. indentLength = indentLength + 1;
  10151. }
  10152. else {
  10153. indentLength = indentLength - 1;
  10154. }
  10155. for (var i = 0; i < indentLength; i++) {
  10156. insertModifier = insertModifier + '(';
  10157. }
  10158. insertTag = tagPartBlock + insertModifier;
  10159. }
  10160. else {
  10161. if (button.tagStart == tagPartModifier) {
  10162. insertTag = tagPartBlock;
  10163. } // going to rely on the default empty insertModifier
  10164. else {
  10165. if (button.tagStart.match(/(\>|\<\>|\<|\=)/g)) {
  10166. insertTag = tagPartBlock + button.tagStart;
  10167. }
  10168. else {
  10169. insertTag = button.tagStart + tagPartModifier;
  10170. }
  10171. }
  10172. }
  10173. drawSwitch = 1;
  10174. }
  10175. // indentation of list items
  10176. else if (listPartMatches = re_list_items.exec(tagPartBlock)) {
  10177. var listTypeMatch = listPartMatches[1];
  10178. var indentLength = tagPartBlock.length - 2;
  10179. var listInsert = '';
  10180. if (button.tagStart == '(') {
  10181. indentLength = indentLength + 1;
  10182. }
  10183. else {
  10184. indentLength = indentLength - 1;
  10185. }
  10186. if (listTypeMatch.match(/[\*]{1,}/g)) {
  10187. var listType = '*';
  10188. var listReplace = '\\*';
  10189. }
  10190. else {
  10191. var listType = '#';
  10192. var listReplace = '\\#';
  10193. }
  10194. for (var i = 0; i < indentLength; i++) {
  10195. listInsert = listInsert + listType;
  10196. }
  10197. if (listInsert != '') {
  10198. insertTag = ' ' + listInsert + ' ';
  10199. }
  10200. else {
  10201. insertTag = '';
  10202. }
  10203. tagPartBlock = tagPartBlock.replace(/(\*|\#)/g,listReplace);
  10204. drawSwitch = 1;
  10205. captureListStart = true;
  10206. periodAddition = '';
  10207. periodAdditionClean = '';
  10208. if (matches = selectedText.match(/\n\s/g)) {
  10209. listItemsAddition = matches.length;
  10210. }
  10211. }
  10212. // must be a block modification e.g. p>. to p<.
  10213. else {
  10214. // if this is a block modification/addition
  10215. if (button.tagStart.match(/(h1|h2|h3|h4|h5|h6|bq|p)/g)) {
  10216. if (tagPartBlock == '') {
  10217. drawSwitch = 2;
  10218. }
  10219. else {
  10220. drawSwitch = 1;
  10221. }
  10222. insertTag = button.tagStart + tagPartModifier;
  10223. }
  10224. // else this is a modifier modification/addition
  10225. else {
  10226. if ((tagPartModifier == '') && (tagPartBlock != '')) {
  10227. drawSwitch = 1;
  10228. }
  10229. else if (tagPartModifier == '') {
  10230. drawSwitch = 2;
  10231. }
  10232. else {
  10233. drawSwitch = 1;
  10234. }
  10235. // if no tag part block but a modifier we need at least the p tag
  10236. if (tagPartBlock == '') {
  10237. tagPartBlock = 'p';
  10238. }
  10239. //make sure to swap out outdent
  10240. if (button.tagStart == ')') {
  10241. tagPartModifier = '';
  10242. }
  10243. else {
  10244. tagPartModifier = button.tagStart;
  10245. captureIndentStart = true; // ugly hack to fix issue with proper selection handling
  10246. }
  10247. insertTag = tagPartBlock + tagPartModifier;
  10248. }
  10249. }
  10250. mplier = 0;
  10251. if (captureListStart || (tagPartModifier.match(/[\(\)]{1,}/g))) {
  10252. re_start = new RegExp(insertTag.escape + periodAddition,'g'); // for tags that mimic regex properties, parens + list tags
  10253. }
  10254. else {
  10255. re_start = new RegExp(insertTag + periodAddition,'g'); // for tags that don't, why i can't just escape everything i have no clue
  10256. }
  10257. re_old = new RegExp(tagPartBlock + tagPartModifierOrig + periodAddition,'g');
  10258. re_middle = new RegExp(newlineReplaceRegexDirty + insertTag.escape + periodAddition.escape,'g');
  10259. re_tag = new RegExp(insertTag.escape + periodAddition.escape,'g');
  10260. // *************************************************************************************************************************
  10261. // this is where everything gets swapped around or inserted, bullets and single options have their own if/else statements
  10262. // *************************************************************************************************************************
  10263. if ((drawSwitch == 0) || (drawSwitch == 1)) {
  10264. if (drawSwitch == 0) { // completely removing a tag
  10265. finalText = beginningText
  10266. + newlineStart
  10267. + selectedText.replace(re_start,'').replace(re_middle,newlineReplaceClean)
  10268. + newlineEnd
  10269. + followupText;
  10270. if (matches = selectedText.match(newlineReplaceRegexClean)) {
  10271. mplier = mplier + matches.length;
  10272. }
  10273. posDiffNeg = insertTag.length + 2 + (mplier*4);
  10274. }
  10275. else { // modifying a tag, though we do delete bullets here
  10276. finalText = beginningText
  10277. + newlineStart
  10278. + selectedText.replace(re_old,insertTag + periodAdditionClean)
  10279. + newlineEnd
  10280. + followupText;
  10281. if (matches = selectedText.match(newlineReplaceRegexClean)) {
  10282. mplier = mplier + matches.length;
  10283. }
  10284. // figure out the length of various elements to modify the selection position
  10285. if (captureIndentStart) { // need to double-check that this wasn't the first indent
  10286. tagPreviousLength = tagPartBlock.length;
  10287. tagCurrentLength = insertTag.length;
  10288. }
  10289. else if (captureListStart) { // if this is a list we're manipulating
  10290. if (button.tagStart == '(') { // if indenting
  10291. tagPreviousLength = listTypeMatch.length + 2;
  10292. tagCurrentLength = insertTag.length + listItemsAddition;
  10293. }
  10294. else if (insertTag.match(/(\*|\#)/g)) { // if removing but still has bullets
  10295. tagPreviousLength = insertTag.length + listItemsAddition;
  10296. tagCurrentLength = listTypeMatch.length;
  10297. }
  10298. else { // if removing last bullet
  10299. tagPreviousLength = insertTag.length + listItemsAddition;
  10300. tagCurrentLength = listTypeMatch.length - (3*listItemsAddition) - 1;
  10301. }
  10302. }
  10303. else { // everything else
  10304. tagPreviousLength = tagPartBlock.length + tagPartModifier.length;
  10305. tagCurrentLength = insertTag.length;
  10306. }
  10307. if (tagCurrentLength > tagPreviousLength) {
  10308. posDiffPos = (tagCurrentLength - tagPreviousLength) + (mplier*(tagCurrentLength - tagPreviousLength));
  10309. }
  10310. else {
  10311. posDiffNeg = (tagPreviousLength - tagCurrentLength) + (mplier*(tagPreviousLength - tagCurrentLength));
  10312. }
  10313. }
  10314. }
  10315. else { // for adding tags other then bullets (have their own statement)
  10316. finalText = beginningText
  10317. + newlineStart
  10318. + insertTag + '. '
  10319. + selectedText.replace(newlineReplaceRegexClean,button.tagEnd + '\n' + insertTag + '. ')
  10320. + newlineFollowup
  10321. + newlineEnd
  10322. + followupText;
  10323. if (matches = selectedText.match(newlineReplaceRegexClean)) {
  10324. mplier = mplier + matches.length;
  10325. }
  10326. posDiffPos = insertTag.length + 2 + (mplier*4);
  10327. }
  10328. }
  10329. // swap in and out the simple tags around a selection like bold
  10330. else {
  10331. mplier = 1; // the multiplier for the tag length
  10332. re_start = new RegExp('^\\' + button.tagStart,'g');
  10333. re_end = new RegExp('\\' + button.tagEnd + '$','g');
  10334. re_middle = new RegExp('\\' + button.tagEnd + newlineReplaceRegexDirty + '\\' + button.tagStart,'g');
  10335. if (selectedText.match(re_start) && selectedText.match(re_end)) {
  10336. finalText = beginningText
  10337. + newlineStart
  10338. + selectedText.replace(re_start,'').replace(re_end,'').replace(re_middle,newlineReplaceClean)
  10339. + newlineEnd
  10340. + followupText;
  10341. if (matches = selectedText.match(newlineReplaceRegexClean)) {
  10342. mplier = mplier + matches.length;
  10343. }
  10344. posDiffNeg = button.tagStart.length*mplier + button.tagEnd.length*mplier;
  10345. }
  10346. else {
  10347. finalText = beginningText
  10348. + newlineStart
  10349. + button.tagStart
  10350. + selectedText.replace(newlineReplaceRegexClean,button.tagEnd + newlineReplaceClean + button.tagStart)
  10351. + button.tagEnd
  10352. + newlineEnd
  10353. + followupText;
  10354. if (matches = selectedText.match(newlineReplaceRegexClean)) {
  10355. mplier = mplier + matches.length;
  10356. }
  10357. posDiffPos = (button.tagStart.length*mplier) + (button.tagEnd.length*mplier);
  10358. }
  10359. }
  10360. cursorPos += button.tagStart.length + button.tagEnd.length;
  10361. }
  10362. // just swap in and out single values, e.g. someone clicks b they'll get a *
  10363. else {
  10364. var buttonStart = '';
  10365. var buttonEnd = '';
  10366. var re_p = new RegExp('(\\<|\\>|\\=|\\<\\>|\\(|\\))','g');
  10367. var re_h = new RegExp('^(h1|h2|h3|h4|h5|h6|p|bq)','g');
  10368. if (!this.checkOpenTags(button) || button.tagEnd == '') { // opening tag
  10369. if (button.tagStart.match(re_h)) {
  10370. buttonStart = button.tagStart + '. ';
  10371. }
  10372. else {
  10373. buttonStart = button.tagStart;
  10374. }
  10375. if (button.tagStart.match(re_p)) { // make sure that invoking block modifiers don't do anything
  10376. finalText = beginningText
  10377. + followupText;
  10378. cursorPos = startPos;
  10379. }
  10380. else {
  10381. finalText = beginningText
  10382. + buttonStart
  10383. + followupText;
  10384. this.addTag(button);
  10385. cursorPos = startPos + buttonStart.length;
  10386. }
  10387. }
  10388. else { // closing tag
  10389. if (button.tagStart.match(re_p)) {
  10390. buttonEnd = '\n\n';
  10391. }
  10392. else if (button.tagStart.match(re_h)) {
  10393. buttonEnd = '\n\n';
  10394. }
  10395. else {
  10396. buttonEnd = button.tagEnd
  10397. }
  10398. finalText = beginningText
  10399. + button.tagEnd
  10400. + followupText;
  10401. this.removeTag(button);
  10402. cursorPos = startPos + button.tagEnd.length;
  10403. }
  10404. }
  10405. // set the appropriate DOM value with the final text
  10406. if (FF == true) {
  10407. myField.value = finalText;
  10408. myField.scrollTop = scrollTop;
  10409. }
  10410. else {
  10411. sel.text = finalText;
  10412. }
  10413. // build up the selection capture, doesn't work in IE
  10414. if (textSelected) {
  10415. myField.selectionStart = startPos + newlineStartPos;
  10416. myField.selectionEnd = endPos + posDiffPos - posDiffNeg - newlineEndPos;
  10417. //alert('s: ' + myField.selectionStart + ' e: ' + myField.selectionEnd + ' sp: ' + startPos + ' ep: ' + endPos + ' pdp: ' + posDiffPos + ' pdn: ' + posDiffNeg)
  10418. }
  10419. else {
  10420. myField.selectionStart = cursorPos;
  10421. myField.selectionEnd = cursorPos;
  10422. }
  10423. } // end insertTag
  10424. }; // end class
  10425. // add class methods
  10426. // Object.extend(TextileEditor, TextileEditor.Methods);
  10427. destination = TextileEditor
  10428. source = TextileEditor.Methods
  10429. for(var property in source) destination[property] = source[property];
  10430. var teButtons = TextileEditor.buttons;
  10431. // teButtons.push(new TextileEditorButton('ed_strong', 'bold.png', '*', '*', 'b', 'Bold','s'));
  10432. // teButtons.push(new TextileEditorButton('ed_emphasis', 'italic.png', '_', '_', 'i', 'Italicize','s'));
  10433. // teButtons.push(new TextileEditorButton('ed_underline', 'underline.png', '+', '+', 'u', 'Underline','s'));
  10434. // teButtons.push(new TextileEditorButton('ed_strike', 'strikethrough.png', '-', '-', 's', 'Strikethrough','s'));
  10435. teButtons.push(new TextileEditorButton('ed_ol', 'list_numbers.png', ' # ', '\n', ',', 'Numbered List'));
  10436. teButtons.push(new TextileEditorButton('ed_ul', 'list_bullets.png', ' * ', '\n', '.', 'Bulleted List'));
  10437. teButtons.push(new TextileEditorButton('ed_p', 'paragraph.png', 'p', '\n', 'p', 'Paragraph'));
  10438. teButtons.push(new TextileEditorButton('ed_h1', 'h1.png', 'h1', '\n', '1', 'Header 1'));
  10439. teButtons.push(new TextileEditorButton('ed_h2', 'h2.png', 'h2', '\n', '2', 'Header 2'));
  10440. teButtons.push(new TextileEditorButton('ed_h3', 'h3.png', 'h3', '\n', '3', 'Header 3'));
  10441. teButtons.push(new TextileEditorButton('ed_h4', 'h4.png', 'h4', '\n', '4', 'Header 4'));
  10442. teButtons.push(new TextileEditorButton('ed_block', 'blockquote.png', 'bq', '\n', 'q', 'Blockquote'));
  10443. teButtons.push(new TextileEditorButton('ed_outdent', 'outdent.png', ')', '\n', ']', 'Outdent'));
  10444. teButtons.push(new TextileEditorButton('ed_indent', 'indent.png', '(', '\n', '[', 'Indent'));
  10445. teButtons.push(new TextileEditorButton('ed_justifyl', 'left.png', '<', '\n', 'l', 'Left Justify'));
  10446. teButtons.push(new TextileEditorButton('ed_justifyc', 'center.png', '=', '\n', 'e', 'Center Text'));
  10447. teButtons.push(new TextileEditorButton('ed_justifyr', 'right.png', '>', '\n', 'r', 'Right Justify'));
  10448. teButtons.push(new TextileEditorButton('ed_justify', 'justify.png', '<>', '\n', 'j', 'Justify'));
  10449. // teButtons.push(new TextileEditorButton('ed_code','code','@','@','c','Code'));
  10450. /* ========================================================================
  10451. * Bootstrap: affix.js v3.2.0
  10452. * http://getbootstrap.com/javascript/#affix
  10453. * ========================================================================
  10454. * Copyright 2011-2014 Twitter, Inc.
  10455. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  10456. * ======================================================================== */
  10457. +function ($) {
  10458. 'use strict';
  10459. // AFFIX CLASS DEFINITION
  10460. // ======================
  10461. var Affix = function (element, options) {
  10462. this.options = $.extend({}, Affix.DEFAULTS, options)
  10463. this.$target = $(this.options.target)
  10464. .on('scroll.bs.affix.data-api', $.proxy(this.checkPosition, this))
  10465. .on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
  10466. this.$element = $(element)
  10467. this.affixed =
  10468. this.unpin =
  10469. this.pinnedOffset = null
  10470. this.checkPosition()
  10471. }
  10472. Affix.VERSION = '3.2.0'
  10473. Affix.RESET = 'affix affix-top affix-bottom'
  10474. Affix.DEFAULTS = {
  10475. offset: 0,
  10476. target: window
  10477. }
  10478. Affix.prototype.getPinnedOffset = function () {
  10479. if (this.pinnedOffset) return this.pinnedOffset
  10480. this.$element.removeClass(Affix.RESET).addClass('affix')
  10481. var scrollTop = this.$target.scrollTop()
  10482. var position = this.$element.offset()
  10483. return (this.pinnedOffset = position.top - scrollTop)
  10484. }
  10485. Affix.prototype.checkPositionWithEventLoop = function () {
  10486. setTimeout($.proxy(this.checkPosition, this), 1)
  10487. }
  10488. Affix.prototype.checkPosition = function () {
  10489. if (!this.$element.is(':visible')) return
  10490. var scrollHeight = $(document).height()
  10491. var scrollTop = this.$target.scrollTop()
  10492. var position = this.$element.offset()
  10493. var offset = this.options.offset
  10494. var offsetTop = offset.top
  10495. var offsetBottom = offset.bottom
  10496. if (typeof offset != 'object') offsetBottom = offsetTop = offset
  10497. if (typeof offsetTop == 'function') offsetTop = offset.top(this.$element)
  10498. if (typeof offsetBottom == 'function') offsetBottom = offset.bottom(this.$element)
  10499. var affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ? false :
  10500. offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ? 'bottom' :
  10501. offsetTop != null && (scrollTop <= offsetTop) ? 'top' : false
  10502. if (this.affixed === affix) return
  10503. if (this.unpin != null) this.$element.css('top', '')
  10504. var affixType = 'affix' + (affix ? '-' + affix : '')
  10505. var e = $.Event(affixType + '.bs.affix')
  10506. this.$element.trigger(e)
  10507. if (e.isDefaultPrevented()) return
  10508. this.affixed = affix
  10509. this.unpin = affix == 'bottom' ? this.getPinnedOffset() : null
  10510. this.$element
  10511. .removeClass(Affix.RESET)
  10512. .addClass(affixType)
  10513. .trigger($.Event(affixType.replace('affix', 'affixed')))
  10514. if (affix == 'bottom') {
  10515. this.$element.offset({
  10516. top: scrollHeight - this.$element.height() - offsetBottom
  10517. })
  10518. }
  10519. }
  10520. // AFFIX PLUGIN DEFINITION
  10521. // =======================
  10522. function Plugin(option) {
  10523. return this.each(function () {
  10524. var $this = $(this)
  10525. var data = $this.data('bs.affix')
  10526. var options = typeof option == 'object' && option
  10527. if (!data) $this.data('bs.affix', (data = new Affix(this, options)))
  10528. if (typeof option == 'string') data[option]()
  10529. })
  10530. }
  10531. var old = $.fn.affix
  10532. $.fn.affix = Plugin
  10533. $.fn.affix.Constructor = Affix
  10534. // AFFIX NO CONFLICT
  10535. // =================
  10536. $.fn.affix.noConflict = function () {
  10537. $.fn.affix = old
  10538. return this
  10539. }
  10540. // AFFIX DATA-API
  10541. // ==============
  10542. $(window).on('load', function () {
  10543. $('[data-spy="affix"]').each(function () {
  10544. var $spy = $(this)
  10545. var data = $spy.data()
  10546. data.offset = data.offset || {}
  10547. if (data.offsetBottom) data.offset.bottom = data.offsetBottom
  10548. if (data.offsetTop) data.offset.top = data.offsetTop
  10549. Plugin.call($spy, data)
  10550. })
  10551. })
  10552. }(jQuery);
  10553. /* ========================================================================
  10554. * Bootstrap: alert.js v3.2.0
  10555. * http://getbootstrap.com/javascript/#alerts
  10556. * ========================================================================
  10557. * Copyright 2011-2014 Twitter, Inc.
  10558. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  10559. * ======================================================================== */
  10560. +function ($) {
  10561. 'use strict';
  10562. // ALERT CLASS DEFINITION
  10563. // ======================
  10564. var dismiss = '[data-dismiss="alert"]'
  10565. var Alert = function (el) {
  10566. $(el).on('click', dismiss, this.close)
  10567. }
  10568. Alert.VERSION = '3.2.0'
  10569. Alert.prototype.close = function (e) {
  10570. var $this = $(this)
  10571. var selector = $this.attr('data-target')
  10572. if (!selector) {
  10573. selector = $this.attr('href')
  10574. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  10575. }
  10576. var $parent = $(selector)
  10577. if (e) e.preventDefault()
  10578. if (!$parent.length) {
  10579. $parent = $this.hasClass('alert') ? $this : $this.parent()
  10580. }
  10581. $parent.trigger(e = $.Event('close.bs.alert'))
  10582. if (e.isDefaultPrevented()) return
  10583. $parent.removeClass('in')
  10584. function removeElement() {
  10585. // detach from parent, fire event then clean up data
  10586. $parent.detach().trigger('closed.bs.alert').remove()
  10587. }
  10588. $.support.transition && $parent.hasClass('fade') ?
  10589. $parent
  10590. .one('bsTransitionEnd', removeElement)
  10591. .emulateTransitionEnd(150) :
  10592. removeElement()
  10593. }
  10594. // ALERT PLUGIN DEFINITION
  10595. // =======================
  10596. function Plugin(option) {
  10597. return this.each(function () {
  10598. var $this = $(this)
  10599. var data = $this.data('bs.alert')
  10600. if (!data) $this.data('bs.alert', (data = new Alert(this)))
  10601. if (typeof option == 'string') data[option].call($this)
  10602. })
  10603. }
  10604. var old = $.fn.alert
  10605. $.fn.alert = Plugin
  10606. $.fn.alert.Constructor = Alert
  10607. // ALERT NO CONFLICT
  10608. // =================
  10609. $.fn.alert.noConflict = function () {
  10610. $.fn.alert = old
  10611. return this
  10612. }
  10613. // ALERT DATA-API
  10614. // ==============
  10615. $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
  10616. }(jQuery);
  10617. /* ========================================================================
  10618. * Bootstrap: button.js v3.2.0
  10619. * http://getbootstrap.com/javascript/#buttons
  10620. * ========================================================================
  10621. * Copyright 2011-2014 Twitter, Inc.
  10622. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  10623. * ======================================================================== */
  10624. +function ($) {
  10625. 'use strict';
  10626. // BUTTON PUBLIC CLASS DEFINITION
  10627. // ==============================
  10628. var Button = function (element, options) {
  10629. this.$element = $(element)
  10630. this.options = $.extend({}, Button.DEFAULTS, options)
  10631. this.isLoading = false
  10632. }
  10633. Button.VERSION = '3.2.0'
  10634. Button.DEFAULTS = {
  10635. loadingText: 'loading...'
  10636. }
  10637. Button.prototype.setState = function (state) {
  10638. var d = 'disabled'
  10639. var $el = this.$element
  10640. var val = $el.is('input') ? 'val' : 'html'
  10641. var data = $el.data()
  10642. state = state + 'Text'
  10643. if (data.resetText == null) $el.data('resetText', $el[val]())
  10644. $el[val](data[state] == null ? this.options[state] : data[state])
  10645. // push to event loop to allow forms to submit
  10646. setTimeout($.proxy(function () {
  10647. if (state == 'loadingText') {
  10648. this.isLoading = true
  10649. $el.addClass(d).attr(d, d)
  10650. } else if (this.isLoading) {
  10651. this.isLoading = false
  10652. $el.removeClass(d).removeAttr(d)
  10653. }
  10654. }, this), 0)
  10655. }
  10656. Button.prototype.toggle = function () {
  10657. var changed = true
  10658. var $parent = this.$element.closest('[data-toggle="buttons"]')
  10659. if ($parent.length) {
  10660. var $input = this.$element.find('input')
  10661. if ($input.prop('type') == 'radio') {
  10662. if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
  10663. else $parent.find('.active').removeClass('active')
  10664. }
  10665. if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
  10666. }
  10667. if (changed) this.$element.toggleClass('active')
  10668. }
  10669. // BUTTON PLUGIN DEFINITION
  10670. // ========================
  10671. function Plugin(option) {
  10672. return this.each(function () {
  10673. var $this = $(this)
  10674. var data = $this.data('bs.button')
  10675. var options = typeof option == 'object' && option
  10676. if (!data) $this.data('bs.button', (data = new Button(this, options)))
  10677. if (option == 'toggle') data.toggle()
  10678. else if (option) data.setState(option)
  10679. })
  10680. }
  10681. var old = $.fn.button
  10682. $.fn.button = Plugin
  10683. $.fn.button.Constructor = Button
  10684. // BUTTON NO CONFLICT
  10685. // ==================
  10686. $.fn.button.noConflict = function () {
  10687. $.fn.button = old
  10688. return this
  10689. }
  10690. // BUTTON DATA-API
  10691. // ===============
  10692. $(document).on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
  10693. var $btn = $(e.target)
  10694. if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
  10695. Plugin.call($btn, 'toggle')
  10696. e.preventDefault()
  10697. })
  10698. }(jQuery);
  10699. /* ========================================================================
  10700. * Bootstrap: carousel.js v3.2.0
  10701. * http://getbootstrap.com/javascript/#carousel
  10702. * ========================================================================
  10703. * Copyright 2011-2014 Twitter, Inc.
  10704. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  10705. * ======================================================================== */
  10706. +function ($) {
  10707. 'use strict';
  10708. // CAROUSEL CLASS DEFINITION
  10709. // =========================
  10710. var Carousel = function (element, options) {
  10711. this.$element = $(element).on('keydown.bs.carousel', $.proxy(this.keydown, this))
  10712. this.$indicators = this.$element.find('.carousel-indicators')
  10713. this.options = options
  10714. this.paused =
  10715. this.sliding =
  10716. this.interval =
  10717. this.$active =
  10718. this.$items = null
  10719. this.options.pause == 'hover' && this.$element
  10720. .on('mouseenter.bs.carousel', $.proxy(this.pause, this))
  10721. .on('mouseleave.bs.carousel', $.proxy(this.cycle, this))
  10722. }
  10723. Carousel.VERSION = '3.2.0'
  10724. Carousel.DEFAULTS = {
  10725. interval: 5000,
  10726. pause: 'hover',
  10727. wrap: true
  10728. }
  10729. Carousel.prototype.keydown = function (e) {
  10730. switch (e.which) {
  10731. case 37: this.prev(); break
  10732. case 39: this.next(); break
  10733. default: return
  10734. }
  10735. e.preventDefault()
  10736. }
  10737. Carousel.prototype.cycle = function (e) {
  10738. e || (this.paused = false)
  10739. this.interval && clearInterval(this.interval)
  10740. this.options.interval
  10741. && !this.paused
  10742. && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
  10743. return this
  10744. }
  10745. Carousel.prototype.getItemIndex = function (item) {
  10746. this.$items = item.parent().children('.item')
  10747. return this.$items.index(item || this.$active)
  10748. }
  10749. Carousel.prototype.to = function (pos) {
  10750. var that = this
  10751. var activeIndex = this.getItemIndex(this.$active = this.$element.find('.item.active'))
  10752. if (pos > (this.$items.length - 1) || pos < 0) return
  10753. if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid"
  10754. if (activeIndex == pos) return this.pause().cycle()
  10755. return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
  10756. }
  10757. Carousel.prototype.pause = function (e) {
  10758. e || (this.paused = true)
  10759. if (this.$element.find('.next, .prev').length && $.support.transition) {
  10760. this.$element.trigger($.support.transition.end)
  10761. this.cycle(true)
  10762. }
  10763. this.interval = clearInterval(this.interval)
  10764. return this
  10765. }
  10766. Carousel.prototype.next = function () {
  10767. if (this.sliding) return
  10768. return this.slide('next')
  10769. }
  10770. Carousel.prototype.prev = function () {
  10771. if (this.sliding) return
  10772. return this.slide('prev')
  10773. }
  10774. Carousel.prototype.slide = function (type, next) {
  10775. var $active = this.$element.find('.item.active')
  10776. var $next = next || $active[type]()
  10777. var isCycling = this.interval
  10778. var direction = type == 'next' ? 'left' : 'right'
  10779. var fallback = type == 'next' ? 'first' : 'last'
  10780. var that = this
  10781. if (!$next.length) {
  10782. if (!this.options.wrap) return
  10783. $next = this.$element.find('.item')[fallback]()
  10784. }
  10785. if ($next.hasClass('active')) return (this.sliding = false)
  10786. var relatedTarget = $next[0]
  10787. var slideEvent = $.Event('slide.bs.carousel', {
  10788. relatedTarget: relatedTarget,
  10789. direction: direction
  10790. })
  10791. this.$element.trigger(slideEvent)
  10792. if (slideEvent.isDefaultPrevented()) return
  10793. this.sliding = true
  10794. isCycling && this.pause()
  10795. if (this.$indicators.length) {
  10796. this.$indicators.find('.active').removeClass('active')
  10797. var $nextIndicator = $(this.$indicators.children()[this.getItemIndex($next)])
  10798. $nextIndicator && $nextIndicator.addClass('active')
  10799. }
  10800. var slidEvent = $.Event('slid.bs.carousel', { relatedTarget: relatedTarget, direction: direction }) // yes, "slid"
  10801. if ($.support.transition && this.$element.hasClass('slide')) {
  10802. $next.addClass(type)
  10803. $next[0].offsetWidth // force reflow
  10804. $active.addClass(direction)
  10805. $next.addClass(direction)
  10806. $active
  10807. .one('bsTransitionEnd', function () {
  10808. $next.removeClass([type, direction].join(' ')).addClass('active')
  10809. $active.removeClass(['active', direction].join(' '))
  10810. that.sliding = false
  10811. setTimeout(function () {
  10812. that.$element.trigger(slidEvent)
  10813. }, 0)
  10814. })
  10815. .emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
  10816. } else {
  10817. $active.removeClass('active')
  10818. $next.addClass('active')
  10819. this.sliding = false
  10820. this.$element.trigger(slidEvent)
  10821. }
  10822. isCycling && this.cycle()
  10823. return this
  10824. }
  10825. // CAROUSEL PLUGIN DEFINITION
  10826. // ==========================
  10827. function Plugin(option) {
  10828. return this.each(function () {
  10829. var $this = $(this)
  10830. var data = $this.data('bs.carousel')
  10831. var options = $.extend({}, Carousel.DEFAULTS, $this.data(), typeof option == 'object' && option)
  10832. var action = typeof option == 'string' ? option : options.slide
  10833. if (!data) $this.data('bs.carousel', (data = new Carousel(this, options)))
  10834. if (typeof option == 'number') data.to(option)
  10835. else if (action) data[action]()
  10836. else if (options.interval) data.pause().cycle()
  10837. })
  10838. }
  10839. var old = $.fn.carousel
  10840. $.fn.carousel = Plugin
  10841. $.fn.carousel.Constructor = Carousel
  10842. // CAROUSEL NO CONFLICT
  10843. // ====================
  10844. $.fn.carousel.noConflict = function () {
  10845. $.fn.carousel = old
  10846. return this
  10847. }
  10848. // CAROUSEL DATA-API
  10849. // =================
  10850. $(document).on('click.bs.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
  10851. var href
  10852. var $this = $(this)
  10853. var $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) // strip for ie7
  10854. if (!$target.hasClass('carousel')) return
  10855. var options = $.extend({}, $target.data(), $this.data())
  10856. var slideIndex = $this.attr('data-slide-to')
  10857. if (slideIndex) options.interval = false
  10858. Plugin.call($target, options)
  10859. if (slideIndex) {
  10860. $target.data('bs.carousel').to(slideIndex)
  10861. }
  10862. e.preventDefault()
  10863. })
  10864. $(window).on('load', function () {
  10865. $('[data-ride="carousel"]').each(function () {
  10866. var $carousel = $(this)
  10867. Plugin.call($carousel, $carousel.data())
  10868. })
  10869. })
  10870. }(jQuery);
  10871. /* ========================================================================
  10872. * Bootstrap: collapse.js v3.2.0
  10873. * http://getbootstrap.com/javascript/#collapse
  10874. * ========================================================================
  10875. * Copyright 2011-2014 Twitter, Inc.
  10876. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  10877. * ======================================================================== */
  10878. +function ($) {
  10879. 'use strict';
  10880. // COLLAPSE PUBLIC CLASS DEFINITION
  10881. // ================================
  10882. var Collapse = function (element, options) {
  10883. this.$element = $(element)
  10884. this.options = $.extend({}, Collapse.DEFAULTS, options)
  10885. this.transitioning = null
  10886. if (this.options.parent) this.$parent = $(this.options.parent)
  10887. if (this.options.toggle) this.toggle()
  10888. }
  10889. Collapse.VERSION = '3.2.0'
  10890. Collapse.DEFAULTS = {
  10891. toggle: true
  10892. }
  10893. Collapse.prototype.dimension = function () {
  10894. var hasWidth = this.$element.hasClass('width')
  10895. return hasWidth ? 'width' : 'height'
  10896. }
  10897. Collapse.prototype.show = function () {
  10898. if (this.transitioning || this.$element.hasClass('in')) return
  10899. var startEvent = $.Event('show.bs.collapse')
  10900. this.$element.trigger(startEvent)
  10901. if (startEvent.isDefaultPrevented()) return
  10902. var actives = this.$parent && this.$parent.find('> .panel > .in')
  10903. if (actives && actives.length) {
  10904. var hasData = actives.data('bs.collapse')
  10905. if (hasData && hasData.transitioning) return
  10906. Plugin.call(actives, 'hide')
  10907. hasData || actives.data('bs.collapse', null)
  10908. }
  10909. var dimension = this.dimension()
  10910. this.$element
  10911. .removeClass('collapse')
  10912. .addClass('collapsing')[dimension](0)
  10913. this.transitioning = 1
  10914. var complete = function () {
  10915. this.$element
  10916. .removeClass('collapsing')
  10917. .addClass('collapse in')[dimension]('')
  10918. this.transitioning = 0
  10919. this.$element
  10920. .trigger('shown.bs.collapse')
  10921. }
  10922. if (!$.support.transition) return complete.call(this)
  10923. var scrollSize = $.camelCase(['scroll', dimension].join('-'))
  10924. this.$element
  10925. .one('bsTransitionEnd', $.proxy(complete, this))
  10926. .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
  10927. }
  10928. Collapse.prototype.hide = function () {
  10929. if (this.transitioning || !this.$element.hasClass('in')) return
  10930. var startEvent = $.Event('hide.bs.collapse')
  10931. this.$element.trigger(startEvent)
  10932. if (startEvent.isDefaultPrevented()) return
  10933. var dimension = this.dimension()
  10934. this.$element[dimension](this.$element[dimension]())[0].offsetHeight
  10935. this.$element
  10936. .addClass('collapsing')
  10937. .removeClass('collapse')
  10938. .removeClass('in')
  10939. this.transitioning = 1
  10940. var complete = function () {
  10941. this.transitioning = 0
  10942. this.$element
  10943. .trigger('hidden.bs.collapse')
  10944. .removeClass('collapsing')
  10945. .addClass('collapse')
  10946. }
  10947. if (!$.support.transition) return complete.call(this)
  10948. this.$element
  10949. [dimension](0)
  10950. .one('bsTransitionEnd', $.proxy(complete, this))
  10951. .emulateTransitionEnd(350)
  10952. }
  10953. Collapse.prototype.toggle = function () {
  10954. this[this.$element.hasClass('in') ? 'hide' : 'show']()
  10955. }
  10956. // COLLAPSE PLUGIN DEFINITION
  10957. // ==========================
  10958. function Plugin(option) {
  10959. return this.each(function () {
  10960. var $this = $(this)
  10961. var data = $this.data('bs.collapse')
  10962. var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
  10963. if (!data && options.toggle && option == 'show') option = !option
  10964. if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
  10965. if (typeof option == 'string') data[option]()
  10966. })
  10967. }
  10968. var old = $.fn.collapse
  10969. $.fn.collapse = Plugin
  10970. $.fn.collapse.Constructor = Collapse
  10971. // COLLAPSE NO CONFLICT
  10972. // ====================
  10973. $.fn.collapse.noConflict = function () {
  10974. $.fn.collapse = old
  10975. return this
  10976. }
  10977. // COLLAPSE DATA-API
  10978. // =================
  10979. $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
  10980. var href
  10981. var $this = $(this)
  10982. var target = $this.attr('data-target')
  10983. || e.preventDefault()
  10984. || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
  10985. var $target = $(target)
  10986. var data = $target.data('bs.collapse')
  10987. var option = data ? 'toggle' : $this.data()
  10988. var parent = $this.attr('data-parent')
  10989. var $parent = parent && $(parent)
  10990. if (!data || !data.transitioning) {
  10991. if ($parent) $parent.find('[data-toggle="collapse"][data-parent="' + parent + '"]').not($this).addClass('collapsed')
  10992. $this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
  10993. }
  10994. Plugin.call($target, option)
  10995. })
  10996. }(jQuery);
  10997. /* ========================================================================
  10998. * Bootstrap: dropdown.js v3.2.0
  10999. * http://getbootstrap.com/javascript/#dropdowns
  11000. * ========================================================================
  11001. * Copyright 2011-2014 Twitter, Inc.
  11002. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11003. * ======================================================================== */
  11004. +function ($) {
  11005. 'use strict';
  11006. // DROPDOWN CLASS DEFINITION
  11007. // =========================
  11008. var backdrop = '.dropdown-backdrop'
  11009. var toggle = '[data-toggle="dropdown"]'
  11010. var Dropdown = function (element) {
  11011. $(element).on('click.bs.dropdown', this.toggle)
  11012. }
  11013. Dropdown.VERSION = '3.2.0'
  11014. Dropdown.prototype.toggle = function (e) {
  11015. var $this = $(this)
  11016. if ($this.is('.disabled, :disabled')) return
  11017. var $parent = getParent($this)
  11018. var isActive = $parent.hasClass('open')
  11019. clearMenus()
  11020. if (!isActive) {
  11021. if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
  11022. // if mobile we use a backdrop because click events don't delegate
  11023. $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
  11024. }
  11025. var relatedTarget = { relatedTarget: this }
  11026. $parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
  11027. if (e.isDefaultPrevented()) return
  11028. $this.trigger('focus')
  11029. $parent
  11030. .toggleClass('open')
  11031. .trigger('shown.bs.dropdown', relatedTarget)
  11032. }
  11033. return false
  11034. }
  11035. Dropdown.prototype.keydown = function (e) {
  11036. if (!/(38|40|27)/.test(e.keyCode)) return
  11037. var $this = $(this)
  11038. e.preventDefault()
  11039. e.stopPropagation()
  11040. if ($this.is('.disabled, :disabled')) return
  11041. var $parent = getParent($this)
  11042. var isActive = $parent.hasClass('open')
  11043. if (!isActive || (isActive && e.keyCode == 27)) {
  11044. if (e.which == 27) $parent.find(toggle).trigger('focus')
  11045. return $this.trigger('click')
  11046. }
  11047. var desc = ' li:not(.divider):visible a'
  11048. var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
  11049. if (!$items.length) return
  11050. var index = $items.index($items.filter(':focus'))
  11051. if (e.keyCode == 38 && index > 0) index-- // up
  11052. if (e.keyCode == 40 && index < $items.length - 1) index++ // down
  11053. if (!~index) index = 0
  11054. $items.eq(index).trigger('focus')
  11055. }
  11056. function clearMenus(e) {
  11057. if (e && e.which === 3) return
  11058. $(backdrop).remove()
  11059. $(toggle).each(function () {
  11060. var $parent = getParent($(this))
  11061. var relatedTarget = { relatedTarget: this }
  11062. if (!$parent.hasClass('open')) return
  11063. $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
  11064. if (e.isDefaultPrevented()) return
  11065. $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
  11066. })
  11067. }
  11068. function getParent($this) {
  11069. var selector = $this.attr('data-target')
  11070. if (!selector) {
  11071. selector = $this.attr('href')
  11072. selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  11073. }
  11074. var $parent = selector && $(selector)
  11075. return $parent && $parent.length ? $parent : $this.parent()
  11076. }
  11077. // DROPDOWN PLUGIN DEFINITION
  11078. // ==========================
  11079. function Plugin(option) {
  11080. return this.each(function () {
  11081. var $this = $(this)
  11082. var data = $this.data('bs.dropdown')
  11083. if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
  11084. if (typeof option == 'string') data[option].call($this)
  11085. })
  11086. }
  11087. var old = $.fn.dropdown
  11088. $.fn.dropdown = Plugin
  11089. $.fn.dropdown.Constructor = Dropdown
  11090. // DROPDOWN NO CONFLICT
  11091. // ====================
  11092. $.fn.dropdown.noConflict = function () {
  11093. $.fn.dropdown = old
  11094. return this
  11095. }
  11096. // APPLY TO STANDARD DROPDOWN ELEMENTS
  11097. // ===================================
  11098. $(document)
  11099. .on('click.bs.dropdown.data-api', clearMenus)
  11100. .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
  11101. .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
  11102. .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
  11103. }(jQuery);
  11104. /* ========================================================================
  11105. * Bootstrap: tab.js v3.2.0
  11106. * http://getbootstrap.com/javascript/#tabs
  11107. * ========================================================================
  11108. * Copyright 2011-2014 Twitter, Inc.
  11109. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11110. * ======================================================================== */
  11111. +function ($) {
  11112. 'use strict';
  11113. // TAB CLASS DEFINITION
  11114. // ====================
  11115. var Tab = function (element) {
  11116. this.element = $(element)
  11117. }
  11118. Tab.VERSION = '3.2.0'
  11119. Tab.prototype.show = function () {
  11120. var $this = this.element
  11121. var $ul = $this.closest('ul:not(.dropdown-menu)')
  11122. var selector = $this.data('target')
  11123. if (!selector) {
  11124. selector = $this.attr('href')
  11125. selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
  11126. }
  11127. if ($this.parent('li').hasClass('active')) return
  11128. var previous = $ul.find('.active:last a')[0]
  11129. var e = $.Event('show.bs.tab', {
  11130. relatedTarget: previous
  11131. })
  11132. $this.trigger(e)
  11133. if (e.isDefaultPrevented()) return
  11134. var $target = $(selector)
  11135. this.activate($this.closest('li'), $ul)
  11136. this.activate($target, $target.parent(), function () {
  11137. $this.trigger({
  11138. type: 'shown.bs.tab',
  11139. relatedTarget: previous
  11140. })
  11141. })
  11142. }
  11143. Tab.prototype.activate = function (element, container, callback) {
  11144. var $active = container.find('> .active')
  11145. var transition = callback
  11146. && $.support.transition
  11147. && $active.hasClass('fade')
  11148. function next() {
  11149. $active
  11150. .removeClass('active')
  11151. .find('> .dropdown-menu > .active')
  11152. .removeClass('active')
  11153. element.addClass('active')
  11154. if (transition) {
  11155. element[0].offsetWidth // reflow for transition
  11156. element.addClass('in')
  11157. } else {
  11158. element.removeClass('fade')
  11159. }
  11160. if (element.parent('.dropdown-menu')) {
  11161. element.closest('li.dropdown').addClass('active')
  11162. }
  11163. callback && callback()
  11164. }
  11165. transition ?
  11166. $active
  11167. .one('bsTransitionEnd', next)
  11168. .emulateTransitionEnd(150) :
  11169. next()
  11170. $active.removeClass('in')
  11171. }
  11172. // TAB PLUGIN DEFINITION
  11173. // =====================
  11174. function Plugin(option) {
  11175. return this.each(function () {
  11176. var $this = $(this)
  11177. var data = $this.data('bs.tab')
  11178. if (!data) $this.data('bs.tab', (data = new Tab(this)))
  11179. if (typeof option == 'string') data[option]()
  11180. })
  11181. }
  11182. var old = $.fn.tab
  11183. $.fn.tab = Plugin
  11184. $.fn.tab.Constructor = Tab
  11185. // TAB NO CONFLICT
  11186. // ===============
  11187. $.fn.tab.noConflict = function () {
  11188. $.fn.tab = old
  11189. return this
  11190. }
  11191. // TAB DATA-API
  11192. // ============
  11193. $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
  11194. e.preventDefault()
  11195. Plugin.call($(this), 'show')
  11196. })
  11197. }(jQuery);
  11198. /* ========================================================================
  11199. * Bootstrap: transition.js v3.2.0
  11200. * http://getbootstrap.com/javascript/#transitions
  11201. * ========================================================================
  11202. * Copyright 2011-2014 Twitter, Inc.
  11203. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11204. * ======================================================================== */
  11205. +function ($) {
  11206. 'use strict';
  11207. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  11208. // ============================================================
  11209. function transitionEnd() {
  11210. var el = document.createElement('bootstrap')
  11211. var transEndEventNames = {
  11212. WebkitTransition : 'webkitTransitionEnd',
  11213. MozTransition : 'transitionend',
  11214. OTransition : 'oTransitionEnd otransitionend',
  11215. transition : 'transitionend'
  11216. }
  11217. for (var name in transEndEventNames) {
  11218. if (el.style[name] !== undefined) {
  11219. return { end: transEndEventNames[name] }
  11220. }
  11221. }
  11222. return false // explicit for ie8 ( ._.)
  11223. }
  11224. // http://blog.alexmaccaw.com/css-transitions
  11225. $.fn.emulateTransitionEnd = function (duration) {
  11226. var called = false
  11227. var $el = this
  11228. $(this).one('bsTransitionEnd', function () { called = true })
  11229. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  11230. setTimeout(callback, duration)
  11231. return this
  11232. }
  11233. $(function () {
  11234. $.support.transition = transitionEnd()
  11235. if (!$.support.transition) return
  11236. $.event.special.bsTransitionEnd = {
  11237. bindType: $.support.transition.end,
  11238. delegateType: $.support.transition.end,
  11239. handle: function (e) {
  11240. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
  11241. }
  11242. }
  11243. })
  11244. }(jQuery);
  11245. /* ========================================================================
  11246. * Bootstrap: scrollspy.js v3.2.0
  11247. * http://getbootstrap.com/javascript/#scrollspy
  11248. * ========================================================================
  11249. * Copyright 2011-2014 Twitter, Inc.
  11250. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11251. * ======================================================================== */
  11252. +function ($) {
  11253. 'use strict';
  11254. // SCROLLSPY CLASS DEFINITION
  11255. // ==========================
  11256. function ScrollSpy(element, options) {
  11257. var process = $.proxy(this.process, this)
  11258. this.$body = $('body')
  11259. this.$scrollElement = $(element).is('body') ? $(window) : $(element)
  11260. this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
  11261. this.selector = (this.options.target || '') + ' .nav li > a'
  11262. this.offsets = []
  11263. this.targets = []
  11264. this.activeTarget = null
  11265. this.scrollHeight = 0
  11266. this.$scrollElement.on('scroll.bs.scrollspy', process)
  11267. this.refresh()
  11268. this.process()
  11269. }
  11270. ScrollSpy.VERSION = '3.2.0'
  11271. ScrollSpy.DEFAULTS = {
  11272. offset: 10
  11273. }
  11274. ScrollSpy.prototype.getScrollHeight = function () {
  11275. return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
  11276. }
  11277. ScrollSpy.prototype.refresh = function () {
  11278. var offsetMethod = 'offset'
  11279. var offsetBase = 0
  11280. if (!$.isWindow(this.$scrollElement[0])) {
  11281. offsetMethod = 'position'
  11282. offsetBase = this.$scrollElement.scrollTop()
  11283. }
  11284. this.offsets = []
  11285. this.targets = []
  11286. this.scrollHeight = this.getScrollHeight()
  11287. var self = this
  11288. this.$body
  11289. .find(this.selector)
  11290. .map(function () {
  11291. var $el = $(this)
  11292. var href = $el.data('target') || $el.attr('href')
  11293. var $href = /^#./.test(href) && $(href)
  11294. return ($href
  11295. && $href.length
  11296. && $href.is(':visible')
  11297. && [[$href[offsetMethod]().top + offsetBase, href]]) || null
  11298. })
  11299. .sort(function (a, b) { return a[0] - b[0] })
  11300. .each(function () {
  11301. self.offsets.push(this[0])
  11302. self.targets.push(this[1])
  11303. })
  11304. }
  11305. ScrollSpy.prototype.process = function () {
  11306. var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
  11307. var scrollHeight = this.getScrollHeight()
  11308. var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
  11309. var offsets = this.offsets
  11310. var targets = this.targets
  11311. var activeTarget = this.activeTarget
  11312. var i
  11313. if (this.scrollHeight != scrollHeight) {
  11314. this.refresh()
  11315. }
  11316. if (scrollTop >= maxScroll) {
  11317. return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
  11318. }
  11319. if (activeTarget && scrollTop <= offsets[0]) {
  11320. return activeTarget != (i = targets[0]) && this.activate(i)
  11321. }
  11322. for (i = offsets.length; i--;) {
  11323. activeTarget != targets[i]
  11324. && scrollTop >= offsets[i]
  11325. && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
  11326. && this.activate(targets[i])
  11327. }
  11328. }
  11329. ScrollSpy.prototype.activate = function (target) {
  11330. this.activeTarget = target
  11331. $(this.selector)
  11332. .parentsUntil(this.options.target, '.active')
  11333. .removeClass('active')
  11334. var selector = this.selector +
  11335. '[data-target="' + target + '"],' +
  11336. this.selector + '[href="' + target + '"]'
  11337. var active = $(selector)
  11338. .parents('li')
  11339. .addClass('active')
  11340. if (active.parent('.dropdown-menu').length) {
  11341. active = active
  11342. .closest('li.dropdown')
  11343. .addClass('active')
  11344. }
  11345. active.trigger('activate.bs.scrollspy')
  11346. }
  11347. // SCROLLSPY PLUGIN DEFINITION
  11348. // ===========================
  11349. function Plugin(option) {
  11350. return this.each(function () {
  11351. var $this = $(this)
  11352. var data = $this.data('bs.scrollspy')
  11353. var options = typeof option == 'object' && option
  11354. if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
  11355. if (typeof option == 'string') data[option]()
  11356. })
  11357. }
  11358. var old = $.fn.scrollspy
  11359. $.fn.scrollspy = Plugin
  11360. $.fn.scrollspy.Constructor = ScrollSpy
  11361. // SCROLLSPY NO CONFLICT
  11362. // =====================
  11363. $.fn.scrollspy.noConflict = function () {
  11364. $.fn.scrollspy = old
  11365. return this
  11366. }
  11367. // SCROLLSPY DATA-API
  11368. // ==================
  11369. $(window).on('load.bs.scrollspy.data-api', function () {
  11370. $('[data-spy="scroll"]').each(function () {
  11371. var $spy = $(this)
  11372. Plugin.call($spy, $spy.data())
  11373. })
  11374. })
  11375. }(jQuery);
  11376. /* ========================================================================
  11377. * Bootstrap: modal.js v3.2.0
  11378. * http://getbootstrap.com/javascript/#modals
  11379. * ========================================================================
  11380. * Copyright 2011-2014 Twitter, Inc.
  11381. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11382. * ======================================================================== */
  11383. +function ($) {
  11384. 'use strict';
  11385. // MODAL CLASS DEFINITION
  11386. // ======================
  11387. var Modal = function (element, options) {
  11388. this.options = options
  11389. this.$body = $(document.body)
  11390. this.$element = $(element)
  11391. this.$backdrop =
  11392. this.isShown = null
  11393. this.scrollbarWidth = 0
  11394. if (this.options.remote) {
  11395. this.$element
  11396. .find('.modal-content')
  11397. .load(this.options.remote, $.proxy(function () {
  11398. this.$element.trigger('loaded.bs.modal')
  11399. }, this))
  11400. }
  11401. }
  11402. Modal.VERSION = '3.2.0'
  11403. Modal.DEFAULTS = {
  11404. backdrop: true,
  11405. keyboard: true,
  11406. show: true
  11407. }
  11408. Modal.prototype.toggle = function (_relatedTarget) {
  11409. return this.isShown ? this.hide() : this.show(_relatedTarget)
  11410. }
  11411. Modal.prototype.show = function (_relatedTarget) {
  11412. var that = this
  11413. var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
  11414. this.$element.trigger(e)
  11415. if (this.isShown || e.isDefaultPrevented()) return
  11416. this.isShown = true
  11417. this.checkScrollbar()
  11418. this.$body.addClass('modal-open')
  11419. this.setScrollbar()
  11420. this.escape()
  11421. this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
  11422. this.backdrop(function () {
  11423. var transition = $.support.transition && that.$element.hasClass('fade')
  11424. if (!that.$element.parent().length) {
  11425. that.$element.appendTo(that.$body) // don't move modals dom position
  11426. }
  11427. that.$element
  11428. .show()
  11429. .scrollTop(0)
  11430. if (transition) {
  11431. that.$element[0].offsetWidth // force reflow
  11432. }
  11433. that.$element
  11434. .addClass('in')
  11435. .attr('aria-hidden', false)
  11436. that.enforceFocus()
  11437. var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
  11438. transition ?
  11439. that.$element.find('.modal-dialog') // wait for modal to slide in
  11440. .one('bsTransitionEnd', function () {
  11441. that.$element.trigger('focus').trigger(e)
  11442. })
  11443. .emulateTransitionEnd(300) :
  11444. that.$element.trigger('focus').trigger(e)
  11445. })
  11446. }
  11447. Modal.prototype.hide = function (e) {
  11448. if (e) e.preventDefault()
  11449. e = $.Event('hide.bs.modal')
  11450. this.$element.trigger(e)
  11451. if (!this.isShown || e.isDefaultPrevented()) return
  11452. this.isShown = false
  11453. this.$body.removeClass('modal-open')
  11454. this.resetScrollbar()
  11455. this.escape()
  11456. $(document).off('focusin.bs.modal')
  11457. this.$element
  11458. .removeClass('in')
  11459. .attr('aria-hidden', true)
  11460. .off('click.dismiss.bs.modal')
  11461. $.support.transition && this.$element.hasClass('fade') ?
  11462. this.$element
  11463. .one('bsTransitionEnd', $.proxy(this.hideModal, this))
  11464. .emulateTransitionEnd(300) :
  11465. this.hideModal()
  11466. }
  11467. Modal.prototype.enforceFocus = function () {
  11468. $(document)
  11469. .off('focusin.bs.modal') // guard against infinite focus loop
  11470. .on('focusin.bs.modal', $.proxy(function (e) {
  11471. if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
  11472. this.$element.trigger('focus')
  11473. }
  11474. }, this))
  11475. }
  11476. Modal.prototype.escape = function () {
  11477. if (this.isShown && this.options.keyboard) {
  11478. this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
  11479. e.which == 27 && this.hide()
  11480. }, this))
  11481. } else if (!this.isShown) {
  11482. this.$element.off('keyup.dismiss.bs.modal')
  11483. }
  11484. }
  11485. Modal.prototype.hideModal = function () {
  11486. var that = this
  11487. this.$element.hide()
  11488. this.backdrop(function () {
  11489. that.$element.trigger('hidden.bs.modal')
  11490. })
  11491. }
  11492. Modal.prototype.removeBackdrop = function () {
  11493. this.$backdrop && this.$backdrop.remove()
  11494. this.$backdrop = null
  11495. }
  11496. Modal.prototype.backdrop = function (callback) {
  11497. var that = this
  11498. var animate = this.$element.hasClass('fade') ? 'fade' : ''
  11499. if (this.isShown && this.options.backdrop) {
  11500. var doAnimate = $.support.transition && animate
  11501. this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
  11502. .appendTo(this.$body)
  11503. this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
  11504. if (e.target !== e.currentTarget) return
  11505. this.options.backdrop == 'static'
  11506. ? this.$element[0].focus.call(this.$element[0])
  11507. : this.hide.call(this)
  11508. }, this))
  11509. if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
  11510. this.$backdrop.addClass('in')
  11511. if (!callback) return
  11512. doAnimate ?
  11513. this.$backdrop
  11514. .one('bsTransitionEnd', callback)
  11515. .emulateTransitionEnd(150) :
  11516. callback()
  11517. } else if (!this.isShown && this.$backdrop) {
  11518. this.$backdrop.removeClass('in')
  11519. var callbackRemove = function () {
  11520. that.removeBackdrop()
  11521. callback && callback()
  11522. }
  11523. $.support.transition && this.$element.hasClass('fade') ?
  11524. this.$backdrop
  11525. .one('bsTransitionEnd', callbackRemove)
  11526. .emulateTransitionEnd(150) :
  11527. callbackRemove()
  11528. } else if (callback) {
  11529. callback()
  11530. }
  11531. }
  11532. Modal.prototype.checkScrollbar = function () {
  11533. if (document.body.clientWidth >= window.innerWidth) return
  11534. this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
  11535. }
  11536. Modal.prototype.setScrollbar = function () {
  11537. var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
  11538. if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
  11539. }
  11540. Modal.prototype.resetScrollbar = function () {
  11541. this.$body.css('padding-right', '')
  11542. }
  11543. Modal.prototype.measureScrollbar = function () { // thx walsh
  11544. var scrollDiv = document.createElement('div')
  11545. scrollDiv.className = 'modal-scrollbar-measure'
  11546. this.$body.append(scrollDiv)
  11547. var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
  11548. this.$body[0].removeChild(scrollDiv)
  11549. return scrollbarWidth
  11550. }
  11551. // MODAL PLUGIN DEFINITION
  11552. // =======================
  11553. function Plugin(option, _relatedTarget) {
  11554. return this.each(function () {
  11555. var $this = $(this)
  11556. var data = $this.data('bs.modal')
  11557. var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
  11558. if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
  11559. if (typeof option == 'string') data[option](_relatedTarget)
  11560. else if (options.show) data.show(_relatedTarget)
  11561. })
  11562. }
  11563. var old = $.fn.modal
  11564. $.fn.modal = Plugin
  11565. $.fn.modal.Constructor = Modal
  11566. // MODAL NO CONFLICT
  11567. // =================
  11568. $.fn.modal.noConflict = function () {
  11569. $.fn.modal = old
  11570. return this
  11571. }
  11572. // MODAL DATA-API
  11573. // ==============
  11574. $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
  11575. var $this = $(this)
  11576. var href = $this.attr('href')
  11577. var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7
  11578. var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
  11579. if ($this.is('a')) e.preventDefault()
  11580. $target.one('show.bs.modal', function (showEvent) {
  11581. if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
  11582. $target.one('hidden.bs.modal', function () {
  11583. $this.is(':visible') && $this.trigger('focus')
  11584. })
  11585. })
  11586. Plugin.call($target, option, this)
  11587. })
  11588. }(jQuery);
  11589. /* ========================================================================
  11590. * Bootstrap: tooltip.js v3.2.0
  11591. * http://getbootstrap.com/javascript/#tooltip
  11592. * Inspired by the original jQuery.tipsy by Jason Frame
  11593. * ========================================================================
  11594. * Copyright 2011-2014 Twitter, Inc.
  11595. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11596. * ======================================================================== */
  11597. +function ($) {
  11598. 'use strict';
  11599. // TOOLTIP PUBLIC CLASS DEFINITION
  11600. // ===============================
  11601. var Tooltip = function (element, options) {
  11602. this.type =
  11603. this.options =
  11604. this.enabled =
  11605. this.timeout =
  11606. this.hoverState =
  11607. this.$element = null
  11608. this.init('tooltip', element, options)
  11609. }
  11610. Tooltip.VERSION = '3.2.0'
  11611. Tooltip.DEFAULTS = {
  11612. animation: true,
  11613. placement: 'top',
  11614. selector: false,
  11615. template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  11616. trigger: 'hover focus',
  11617. title: '',
  11618. delay: 0,
  11619. html: false,
  11620. container: false,
  11621. viewport: {
  11622. selector: 'body',
  11623. padding: 0
  11624. }
  11625. }
  11626. Tooltip.prototype.init = function (type, element, options) {
  11627. this.enabled = true
  11628. this.type = type
  11629. this.$element = $(element)
  11630. this.options = this.getOptions(options)
  11631. this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
  11632. var triggers = this.options.trigger.split(' ')
  11633. for (var i = triggers.length; i--;) {
  11634. var trigger = triggers[i]
  11635. if (trigger == 'click') {
  11636. this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
  11637. } else if (trigger != 'manual') {
  11638. var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
  11639. var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
  11640. this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
  11641. this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
  11642. }
  11643. }
  11644. this.options.selector ?
  11645. (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
  11646. this.fixTitle()
  11647. }
  11648. Tooltip.prototype.getDefaults = function () {
  11649. return Tooltip.DEFAULTS
  11650. }
  11651. Tooltip.prototype.getOptions = function (options) {
  11652. options = $.extend({}, this.getDefaults(), this.$element.data(), options)
  11653. if (options.delay && typeof options.delay == 'number') {
  11654. options.delay = {
  11655. show: options.delay,
  11656. hide: options.delay
  11657. }
  11658. }
  11659. return options
  11660. }
  11661. Tooltip.prototype.getDelegateOptions = function () {
  11662. var options = {}
  11663. var defaults = this.getDefaults()
  11664. this._options && $.each(this._options, function (key, value) {
  11665. if (defaults[key] != value) options[key] = value
  11666. })
  11667. return options
  11668. }
  11669. Tooltip.prototype.enter = function (obj) {
  11670. var self = obj instanceof this.constructor ?
  11671. obj : $(obj.currentTarget).data('bs.' + this.type)
  11672. if (!self) {
  11673. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  11674. $(obj.currentTarget).data('bs.' + this.type, self)
  11675. }
  11676. clearTimeout(self.timeout)
  11677. self.hoverState = 'in'
  11678. if (!self.options.delay || !self.options.delay.show) return self.show()
  11679. self.timeout = setTimeout(function () {
  11680. if (self.hoverState == 'in') self.show()
  11681. }, self.options.delay.show)
  11682. }
  11683. Tooltip.prototype.leave = function (obj) {
  11684. var self = obj instanceof this.constructor ?
  11685. obj : $(obj.currentTarget).data('bs.' + this.type)
  11686. if (!self) {
  11687. self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
  11688. $(obj.currentTarget).data('bs.' + this.type, self)
  11689. }
  11690. clearTimeout(self.timeout)
  11691. self.hoverState = 'out'
  11692. if (!self.options.delay || !self.options.delay.hide) return self.hide()
  11693. self.timeout = setTimeout(function () {
  11694. if (self.hoverState == 'out') self.hide()
  11695. }, self.options.delay.hide)
  11696. }
  11697. Tooltip.prototype.show = function () {
  11698. var e = $.Event('show.bs.' + this.type)
  11699. if (this.hasContent() && this.enabled) {
  11700. this.$element.trigger(e)
  11701. var inDom = $.contains(document.documentElement, this.$element[0])
  11702. if (e.isDefaultPrevented() || !inDom) return
  11703. var that = this
  11704. var $tip = this.tip()
  11705. var tipId = this.getUID(this.type)
  11706. this.setContent()
  11707. $tip.attr('id', tipId)
  11708. this.$element.attr('aria-describedby', tipId)
  11709. if (this.options.animation) $tip.addClass('fade')
  11710. var placement = typeof this.options.placement == 'function' ?
  11711. this.options.placement.call(this, $tip[0], this.$element[0]) :
  11712. this.options.placement
  11713. var autoToken = /\s?auto?\s?/i
  11714. var autoPlace = autoToken.test(placement)
  11715. if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
  11716. $tip
  11717. .detach()
  11718. .css({ top: 0, left: 0, display: 'block' })
  11719. .addClass(placement)
  11720. .data('bs.' + this.type, this)
  11721. this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
  11722. var pos = this.getPosition()
  11723. var actualWidth = $tip[0].offsetWidth
  11724. var actualHeight = $tip[0].offsetHeight
  11725. if (autoPlace) {
  11726. var orgPlacement = placement
  11727. var $parent = this.$element.parent()
  11728. var parentDim = this.getPosition($parent)
  11729. placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
  11730. placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
  11731. placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
  11732. placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
  11733. placement
  11734. $tip
  11735. .removeClass(orgPlacement)
  11736. .addClass(placement)
  11737. }
  11738. var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
  11739. this.applyPlacement(calculatedOffset, placement)
  11740. var complete = function () {
  11741. that.$element.trigger('shown.bs.' + that.type)
  11742. that.hoverState = null
  11743. }
  11744. $.support.transition && this.$tip.hasClass('fade') ?
  11745. $tip
  11746. .one('bsTransitionEnd', complete)
  11747. .emulateTransitionEnd(150) :
  11748. complete()
  11749. }
  11750. }
  11751. Tooltip.prototype.applyPlacement = function (offset, placement) {
  11752. var $tip = this.tip()
  11753. var width = $tip[0].offsetWidth
  11754. var height = $tip[0].offsetHeight
  11755. // manually read margins because getBoundingClientRect includes difference
  11756. var marginTop = parseInt($tip.css('margin-top'), 10)
  11757. var marginLeft = parseInt($tip.css('margin-left'), 10)
  11758. // we must check for NaN for ie 8/9
  11759. if (isNaN(marginTop)) marginTop = 0
  11760. if (isNaN(marginLeft)) marginLeft = 0
  11761. offset.top = offset.top + marginTop
  11762. offset.left = offset.left + marginLeft
  11763. // $.fn.offset doesn't round pixel values
  11764. // so we use setOffset directly with our own function B-0
  11765. $.offset.setOffset($tip[0], $.extend({
  11766. using: function (props) {
  11767. $tip.css({
  11768. top: Math.round(props.top),
  11769. left: Math.round(props.left)
  11770. })
  11771. }
  11772. }, offset), 0)
  11773. $tip.addClass('in')
  11774. // check to see if placing tip in new offset caused the tip to resize itself
  11775. var actualWidth = $tip[0].offsetWidth
  11776. var actualHeight = $tip[0].offsetHeight
  11777. if (placement == 'top' && actualHeight != height) {
  11778. offset.top = offset.top + height - actualHeight
  11779. }
  11780. var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
  11781. if (delta.left) offset.left += delta.left
  11782. else offset.top += delta.top
  11783. var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
  11784. var arrowPosition = delta.left ? 'left' : 'top'
  11785. var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
  11786. $tip.offset(offset)
  11787. this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
  11788. }
  11789. Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
  11790. this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
  11791. }
  11792. Tooltip.prototype.setContent = function () {
  11793. var $tip = this.tip()
  11794. var title = this.getTitle()
  11795. $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
  11796. $tip.removeClass('fade in top bottom left right')
  11797. }
  11798. Tooltip.prototype.hide = function () {
  11799. var that = this
  11800. var $tip = this.tip()
  11801. var e = $.Event('hide.bs.' + this.type)
  11802. this.$element.removeAttr('aria-describedby')
  11803. function complete() {
  11804. if (that.hoverState != 'in') $tip.detach()
  11805. that.$element.trigger('hidden.bs.' + that.type)
  11806. }
  11807. this.$element.trigger(e)
  11808. if (e.isDefaultPrevented()) return
  11809. $tip.removeClass('in')
  11810. $.support.transition && this.$tip.hasClass('fade') ?
  11811. $tip
  11812. .one('bsTransitionEnd', complete)
  11813. .emulateTransitionEnd(150) :
  11814. complete()
  11815. this.hoverState = null
  11816. return this
  11817. }
  11818. Tooltip.prototype.fixTitle = function () {
  11819. var $e = this.$element
  11820. if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
  11821. $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
  11822. }
  11823. }
  11824. Tooltip.prototype.hasContent = function () {
  11825. return this.getTitle()
  11826. }
  11827. Tooltip.prototype.getPosition = function ($element) {
  11828. $element = $element || this.$element
  11829. var el = $element[0]
  11830. var isBody = el.tagName == 'BODY'
  11831. return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : null, {
  11832. scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop(),
  11833. width: isBody ? $(window).width() : $element.outerWidth(),
  11834. height: isBody ? $(window).height() : $element.outerHeight()
  11835. }, isBody ? { top: 0, left: 0 } : $element.offset())
  11836. }
  11837. Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
  11838. return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  11839. placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
  11840. placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
  11841. /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
  11842. }
  11843. Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
  11844. var delta = { top: 0, left: 0 }
  11845. if (!this.$viewport) return delta
  11846. var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
  11847. var viewportDimensions = this.getPosition(this.$viewport)
  11848. if (/right|left/.test(placement)) {
  11849. var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
  11850. var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
  11851. if (topEdgeOffset < viewportDimensions.top) { // top overflow
  11852. delta.top = viewportDimensions.top - topEdgeOffset
  11853. } else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
  11854. delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
  11855. }
  11856. } else {
  11857. var leftEdgeOffset = pos.left - viewportPadding
  11858. var rightEdgeOffset = pos.left + viewportPadding + actualWidth
  11859. if (leftEdgeOffset < viewportDimensions.left) { // left overflow
  11860. delta.left = viewportDimensions.left - leftEdgeOffset
  11861. } else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
  11862. delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
  11863. }
  11864. }
  11865. return delta
  11866. }
  11867. Tooltip.prototype.getTitle = function () {
  11868. var title
  11869. var $e = this.$element
  11870. var o = this.options
  11871. title = $e.attr('data-original-title')
  11872. || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
  11873. return title
  11874. }
  11875. Tooltip.prototype.getUID = function (prefix) {
  11876. do prefix += ~~(Math.random() * 1000000)
  11877. while (document.getElementById(prefix))
  11878. return prefix
  11879. }
  11880. Tooltip.prototype.tip = function () {
  11881. return (this.$tip = this.$tip || $(this.options.template))
  11882. }
  11883. Tooltip.prototype.arrow = function () {
  11884. return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
  11885. }
  11886. Tooltip.prototype.validate = function () {
  11887. if (!this.$element[0].parentNode) {
  11888. this.hide()
  11889. this.$element = null
  11890. this.options = null
  11891. }
  11892. }
  11893. Tooltip.prototype.enable = function () {
  11894. this.enabled = true
  11895. }
  11896. Tooltip.prototype.disable = function () {
  11897. this.enabled = false
  11898. }
  11899. Tooltip.prototype.toggleEnabled = function () {
  11900. this.enabled = !this.enabled
  11901. }
  11902. Tooltip.prototype.toggle = function (e) {
  11903. var self = this
  11904. if (e) {
  11905. self = $(e.currentTarget).data('bs.' + this.type)
  11906. if (!self) {
  11907. self = new this.constructor(e.currentTarget, this.getDelegateOptions())
  11908. $(e.currentTarget).data('bs.' + this.type, self)
  11909. }
  11910. }
  11911. self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
  11912. }
  11913. Tooltip.prototype.destroy = function () {
  11914. clearTimeout(this.timeout)
  11915. this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
  11916. }
  11917. // TOOLTIP PLUGIN DEFINITION
  11918. // =========================
  11919. function Plugin(option) {
  11920. return this.each(function () {
  11921. var $this = $(this)
  11922. var data = $this.data('bs.tooltip')
  11923. var options = typeof option == 'object' && option
  11924. if (!data && option == 'destroy') return
  11925. if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
  11926. if (typeof option == 'string') data[option]()
  11927. })
  11928. }
  11929. var old = $.fn.tooltip
  11930. $.fn.tooltip = Plugin
  11931. $.fn.tooltip.Constructor = Tooltip
  11932. // TOOLTIP NO CONFLICT
  11933. // ===================
  11934. $.fn.tooltip.noConflict = function () {
  11935. $.fn.tooltip = old
  11936. return this
  11937. }
  11938. }(jQuery);
  11939. /* ========================================================================
  11940. * Bootstrap: popover.js v3.2.0
  11941. * http://getbootstrap.com/javascript/#popovers
  11942. * ========================================================================
  11943. * Copyright 2011-2014 Twitter, Inc.
  11944. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  11945. * ======================================================================== */
  11946. +function ($) {
  11947. 'use strict';
  11948. // POPOVER PUBLIC CLASS DEFINITION
  11949. // ===============================
  11950. var Popover = function (element, options) {
  11951. this.init('popover', element, options)
  11952. }
  11953. if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
  11954. Popover.VERSION = '3.2.0'
  11955. Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
  11956. placement: 'right',
  11957. trigger: 'click',
  11958. content: '',
  11959. template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
  11960. })
  11961. // NOTE: POPOVER EXTENDS tooltip.js
  11962. // ================================
  11963. Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
  11964. Popover.prototype.constructor = Popover
  11965. Popover.prototype.getDefaults = function () {
  11966. return Popover.DEFAULTS
  11967. }
  11968. Popover.prototype.setContent = function () {
  11969. var $tip = this.tip()
  11970. var title = this.getTitle()
  11971. var content = this.getContent()
  11972. $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
  11973. $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
  11974. this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
  11975. ](content)
  11976. $tip.removeClass('fade top bottom left right in')
  11977. // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
  11978. // this manually by checking the contents.
  11979. if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
  11980. }
  11981. Popover.prototype.hasContent = function () {
  11982. return this.getTitle() || this.getContent()
  11983. }
  11984. Popover.prototype.getContent = function () {
  11985. var $e = this.$element
  11986. var o = this.options
  11987. return $e.attr('data-content')
  11988. || (typeof o.content == 'function' ?
  11989. o.content.call($e[0]) :
  11990. o.content)
  11991. }
  11992. Popover.prototype.arrow = function () {
  11993. return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
  11994. }
  11995. Popover.prototype.tip = function () {
  11996. if (!this.$tip) this.$tip = $(this.options.template)
  11997. return this.$tip
  11998. }
  11999. // POPOVER PLUGIN DEFINITION
  12000. // =========================
  12001. function Plugin(option) {
  12002. return this.each(function () {
  12003. var $this = $(this)
  12004. var data = $this.data('bs.popover')
  12005. var options = typeof option == 'object' && option
  12006. if (!data && option == 'destroy') return
  12007. if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
  12008. if (typeof option == 'string') data[option]()
  12009. })
  12010. }
  12011. var old = $.fn.popover
  12012. $.fn.popover = Plugin
  12013. $.fn.popover.Constructor = Popover
  12014. // POPOVER NO CONFLICT
  12015. // ===================
  12016. $.fn.popover.noConflict = function () {
  12017. $.fn.popover = old
  12018. return this
  12019. }
  12020. }(jQuery);
  12021. $(document).ready(function(){
  12022. Turbolinks.enableProgressBar();
  12023. $('[data-toggle="tooltip"]').tooltip();
  12024. });
  12025. // This is a manifest file that'll be compiled into application.js, which will include all the files
  12026. // listed below.
  12027. //
  12028. // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
  12029. // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
  12030. //
  12031. // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
  12032. // compiled file.
  12033. //
  12034. // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
  12035. // about supported directives.
  12036. //
  12037. ;