PageRenderTime 169ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 3ms

/node_modules/socket.io/node_modules/socket.io-client/node_modules/uglify-js/tmp/app.js

https://bitbucket.org/mpuckett/iostudio-whiteboard
JavaScript | 14291 lines | 10479 code | 1963 blank | 1849 comment | 2373 complexity | dc89ca0c0ee287847dfb7aac75688c5f MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, MIT
  1. /* Modernizr 2.0.6 (Custom Build) | MIT & BSD
  2. * Build: http://www.modernizr.com/download/#-iepp
  3. */
  4. ;window.Modernizr=function(a,b,c){function w(a,b){return!!~(""+a).indexOf(b)}function v(a,b){return typeof a===b}function u(a,b){return t(prefixes.join(a+";")+(b||""))}function t(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k,l=Object.prototype.toString,m={},n={},o={},p=[],q,r={}.hasOwnProperty,s;!v(r,c)&&!v(r.call,c)?s=function(a,b){return r.call(a,b)}:s=function(a,b){return b in a&&v(a.constructor.prototype[b],c)};for(var x in m)s(m,x)&&(q=x.toLowerCase(),e[q]=m[x](),p.push((e[q]?"":"no-")+q));t(""),i=k=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b<g)a.createElement(f[b])}a.iepp=a.iepp||{};var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{\}]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;d.getCSS=function(a,b){if(a+""===c)return"";var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},d.parseCSS=function(a){var b=[],c;while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);return b.join("\n")},d.writeHTML=function(){var a=-1;r=r||b.body;while(++a<g){var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")},d._beforePrint=function(){p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()},d.restoreHTML=function(){o.innerHTML="",m.removeChild(o),m.appendChild(r)},d._afterPrint=function(){d.restoreHTML(),p.styleSheet.cssText=""},s(b),s(l);d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}(a,b),e._version=d;return e}(this,this.document);
  5. (function (con) {
  6. // the dummy function
  7. function dummy() {};
  8. // console methods that may exist
  9. for(var methods = "assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(','), func; func = methods.pop();) {
  10. con[func] = con[func] || dummy;
  11. }
  12. }(window.console = window.console || {}));
  13. // we do this crazy little dance so that the `console` object
  14. // inside the function is a name that can be shortened to a single
  15. // letter by the compressor to make the compressed script as tiny
  16. // as possible.
  17. /*!
  18. * jQuery JavaScript Library v1.6.3
  19. * http://jquery.com/
  20. *
  21. * Copyright 2011, John Resig
  22. * Dual licensed under the MIT or GPL Version 2 licenses.
  23. * http://jquery.org/license
  24. *
  25. * Includes Sizzle.js
  26. * http://sizzlejs.com/
  27. * Copyright 2011, The Dojo Foundation
  28. * Released under the MIT, BSD, and GPL Licenses.
  29. *
  30. * Date: Wed Aug 31 10:35:15 2011 -0400
  31. */
  32. (function( window, undefined ) {
  33. // Use the correct document accordingly with window argument (sandbox)
  34. var document = window.document,
  35. navigator = window.navigator,
  36. location = window.location;
  37. var jQuery = (function() {
  38. // Define a local copy of jQuery
  39. var jQuery = function( selector, context ) {
  40. // The jQuery object is actually just the init constructor 'enhanced'
  41. return new jQuery.fn.init( selector, context, rootjQuery );
  42. },
  43. // Map over jQuery in case of overwrite
  44. _jQuery = window.jQuery,
  45. // Map over the $ in case of overwrite
  46. _$ = window.$,
  47. // A central reference to the root jQuery(document)
  48. rootjQuery,
  49. // A simple way to check for HTML strings or ID strings
  50. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  51. quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
  52. // Check if a string has a non-whitespace character in it
  53. rnotwhite = /\S/,
  54. // Used for trimming whitespace
  55. trimLeft = /^\s+/,
  56. trimRight = /\s+$/,
  57. // Check for digits
  58. rdigit = /\d/,
  59. // Match a standalone tag
  60. rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
  61. // JSON RegExp
  62. rvalidchars = /^[\],:{}\s]*$/,
  63. rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
  64. rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
  65. rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
  66. // Useragent RegExp
  67. rwebkit = /(webkit)[ \/]([\w.]+)/,
  68. ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
  69. rmsie = /(msie) ([\w.]+)/,
  70. rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
  71. // Matches dashed string for camelizing
  72. rdashAlpha = /-([a-z]|[0-9])/ig,
  73. rmsPrefix = /^-ms-/,
  74. // Used by jQuery.camelCase as callback to replace()
  75. fcamelCase = function( all, letter ) {
  76. return ( letter + "" ).toUpperCase();
  77. },
  78. // Keep a UserAgent string for use with jQuery.browser
  79. userAgent = navigator.userAgent,
  80. // For matching the engine and version of the browser
  81. browserMatch,
  82. // The deferred used on DOM ready
  83. readyList,
  84. // The ready event handler
  85. DOMContentLoaded,
  86. // Save a reference to some core methods
  87. toString = Object.prototype.toString,
  88. hasOwn = Object.prototype.hasOwnProperty,
  89. push = Array.prototype.push,
  90. slice = Array.prototype.slice,
  91. trim = String.prototype.trim,
  92. indexOf = Array.prototype.indexOf,
  93. // [[Class]] -> type pairs
  94. class2type = {};
  95. jQuery.fn = jQuery.prototype = {
  96. constructor: jQuery,
  97. init: function( selector, context, rootjQuery ) {
  98. var match, elem, ret, doc;
  99. // Handle $(""), $(null), or $(undefined)
  100. if ( !selector ) {
  101. return this;
  102. }
  103. // Handle $(DOMElement)
  104. if ( selector.nodeType ) {
  105. this.context = this[0] = selector;
  106. this.length = 1;
  107. return this;
  108. }
  109. // The body element only exists once, optimize finding it
  110. if ( selector === "body" && !context && document.body ) {
  111. this.context = document;
  112. this[0] = document.body;
  113. this.selector = selector;
  114. this.length = 1;
  115. return this;
  116. }
  117. // Handle HTML strings
  118. if ( typeof selector === "string" ) {
  119. // Are we dealing with HTML string or an ID?
  120. if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
  121. // Assume that strings that start and end with <> are HTML and skip the regex check
  122. match = [ null, selector, null ];
  123. } else {
  124. match = quickExpr.exec( selector );
  125. }
  126. // Verify a match, and that no context was specified for #id
  127. if ( match && (match[1] || !context) ) {
  128. // HANDLE: $(html) -> $(array)
  129. if ( match[1] ) {
  130. context = context instanceof jQuery ? context[0] : context;
  131. doc = (context ? context.ownerDocument || context : document);
  132. // If a single string is passed in and it's a single tag
  133. // just do a createElement and skip the rest
  134. ret = rsingleTag.exec( selector );
  135. if ( ret ) {
  136. if ( jQuery.isPlainObject( context ) ) {
  137. selector = [ document.createElement( ret[1] ) ];
  138. jQuery.fn.attr.call( selector, context, true );
  139. } else {
  140. selector = [ doc.createElement( ret[1] ) ];
  141. }
  142. } else {
  143. ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
  144. selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
  145. }
  146. return jQuery.merge( this, selector );
  147. // HANDLE: $("#id")
  148. } else {
  149. elem = document.getElementById( match[2] );
  150. // Check parentNode to catch when Blackberry 4.6 returns
  151. // nodes that are no longer in the document #6963
  152. if ( elem && elem.parentNode ) {
  153. // Handle the case where IE and Opera return items
  154. // by name instead of ID
  155. if ( elem.id !== match[2] ) {
  156. return rootjQuery.find( selector );
  157. }
  158. // Otherwise, we inject the element directly into the jQuery object
  159. this.length = 1;
  160. this[0] = elem;
  161. }
  162. this.context = document;
  163. this.selector = selector;
  164. return this;
  165. }
  166. // HANDLE: $(expr, $(...))
  167. } else if ( !context || context.jquery ) {
  168. return (context || rootjQuery).find( selector );
  169. // HANDLE: $(expr, context)
  170. // (which is just equivalent to: $(context).find(expr)
  171. } else {
  172. return this.constructor( context ).find( selector );
  173. }
  174. // HANDLE: $(function)
  175. // Shortcut for document ready
  176. } else if ( jQuery.isFunction( selector ) ) {
  177. return rootjQuery.ready( selector );
  178. }
  179. if (selector.selector !== undefined) {
  180. this.selector = selector.selector;
  181. this.context = selector.context;
  182. }
  183. return jQuery.makeArray( selector, this );
  184. },
  185. // Start with an empty selector
  186. selector: "",
  187. // The current version of jQuery being used
  188. jquery: "1.6.3",
  189. // The default length of a jQuery object is 0
  190. length: 0,
  191. // The number of elements contained in the matched element set
  192. size: function() {
  193. return this.length;
  194. },
  195. toArray: function() {
  196. return slice.call( this, 0 );
  197. },
  198. // Get the Nth element in the matched element set OR
  199. // Get the whole matched element set as a clean array
  200. get: function( num ) {
  201. return num == null ?
  202. // Return a 'clean' array
  203. this.toArray() :
  204. // Return just the object
  205. ( num < 0 ? this[ this.length + num ] : this[ num ] );
  206. },
  207. // Take an array of elements and push it onto the stack
  208. // (returning the new matched element set)
  209. pushStack: function( elems, name, selector ) {
  210. // Build a new jQuery matched element set
  211. var ret = this.constructor();
  212. if ( jQuery.isArray( elems ) ) {
  213. push.apply( ret, elems );
  214. } else {
  215. jQuery.merge( ret, elems );
  216. }
  217. // Add the old object onto the stack (as a reference)
  218. ret.prevObject = this;
  219. ret.context = this.context;
  220. if ( name === "find" ) {
  221. ret.selector = this.selector + (this.selector ? " " : "") + selector;
  222. } else if ( name ) {
  223. ret.selector = this.selector + "." + name + "(" + selector + ")";
  224. }
  225. // Return the newly-formed element set
  226. return ret;
  227. },
  228. // Execute a callback for every element in the matched set.
  229. // (You can seed the arguments with an array of args, but this is
  230. // only used internally.)
  231. each: function( callback, args ) {
  232. return jQuery.each( this, callback, args );
  233. },
  234. ready: function( fn ) {
  235. // Attach the listeners
  236. jQuery.bindReady();
  237. // Add the callback
  238. readyList.done( fn );
  239. return this;
  240. },
  241. eq: function( i ) {
  242. return i === -1 ?
  243. this.slice( i ) :
  244. this.slice( i, +i + 1 );
  245. },
  246. first: function() {
  247. return this.eq( 0 );
  248. },
  249. last: function() {
  250. return this.eq( -1 );
  251. },
  252. slice: function() {
  253. return this.pushStack( slice.apply( this, arguments ),
  254. "slice", slice.call(arguments).join(",") );
  255. },
  256. map: function( callback ) {
  257. return this.pushStack( jQuery.map(this, function( elem, i ) {
  258. return callback.call( elem, i, elem );
  259. }));
  260. },
  261. end: function() {
  262. return this.prevObject || this.constructor(null);
  263. },
  264. // For internal use only.
  265. // Behaves like an Array's method, not like a jQuery method.
  266. push: push,
  267. sort: [].sort,
  268. splice: [].splice
  269. };
  270. // Give the init function the jQuery prototype for later instantiation
  271. jQuery.fn.init.prototype = jQuery.fn;
  272. jQuery.extend = jQuery.fn.extend = function() {
  273. var options, name, src, copy, copyIsArray, clone,
  274. target = arguments[0] || {},
  275. i = 1,
  276. length = arguments.length,
  277. deep = false;
  278. // Handle a deep copy situation
  279. if ( typeof target === "boolean" ) {
  280. deep = target;
  281. target = arguments[1] || {};
  282. // skip the boolean and the target
  283. i = 2;
  284. }
  285. // Handle case when target is a string or something (possible in deep copy)
  286. if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
  287. target = {};
  288. }
  289. // extend jQuery itself if only one argument is passed
  290. if ( length === i ) {
  291. target = this;
  292. --i;
  293. }
  294. for ( ; i < length; i++ ) {
  295. // Only deal with non-null/undefined values
  296. if ( (options = arguments[ i ]) != null ) {
  297. // Extend the base object
  298. for ( name in options ) {
  299. src = target[ name ];
  300. copy = options[ name ];
  301. // Prevent never-ending loop
  302. if ( target === copy ) {
  303. continue;
  304. }
  305. // Recurse if we're merging plain objects or arrays
  306. if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
  307. if ( copyIsArray ) {
  308. copyIsArray = false;
  309. clone = src && jQuery.isArray(src) ? src : [];
  310. } else {
  311. clone = src && jQuery.isPlainObject(src) ? src : {};
  312. }
  313. // Never move original objects, clone them
  314. target[ name ] = jQuery.extend( deep, clone, copy );
  315. // Don't bring in undefined values
  316. } else if ( copy !== undefined ) {
  317. target[ name ] = copy;
  318. }
  319. }
  320. }
  321. }
  322. // Return the modified object
  323. return target;
  324. };
  325. jQuery.extend({
  326. noConflict: function( deep ) {
  327. if ( window.$ === jQuery ) {
  328. window.$ = _$;
  329. }
  330. if ( deep && window.jQuery === jQuery ) {
  331. window.jQuery = _jQuery;
  332. }
  333. return jQuery;
  334. },
  335. // Is the DOM ready to be used? Set to true once it occurs.
  336. isReady: false,
  337. // A counter to track how many items to wait for before
  338. // the ready event fires. See #6781
  339. readyWait: 1,
  340. // Hold (or release) the ready event
  341. holdReady: function( hold ) {
  342. if ( hold ) {
  343. jQuery.readyWait++;
  344. } else {
  345. jQuery.ready( true );
  346. }
  347. },
  348. // Handle when the DOM is ready
  349. ready: function( wait ) {
  350. // Either a released hold or an DOMready/load event and not yet ready
  351. if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
  352. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  353. if ( !document.body ) {
  354. return setTimeout( jQuery.ready, 1 );
  355. }
  356. // Remember that the DOM is ready
  357. jQuery.isReady = true;
  358. // If a normal DOM Ready event fired, decrement, and wait if need be
  359. if ( wait !== true && --jQuery.readyWait > 0 ) {
  360. return;
  361. }
  362. // If there are functions bound, to execute
  363. readyList.resolveWith( document, [ jQuery ] );
  364. // Trigger any bound ready events
  365. if ( jQuery.fn.trigger ) {
  366. jQuery( document ).trigger( "ready" ).unbind( "ready" );
  367. }
  368. }
  369. },
  370. bindReady: function() {
  371. if ( readyList ) {
  372. return;
  373. }
  374. readyList = jQuery._Deferred();
  375. // Catch cases where $(document).ready() is called after the
  376. // browser event has already occurred.
  377. if ( document.readyState === "complete" ) {
  378. // Handle it asynchronously to allow scripts the opportunity to delay ready
  379. return setTimeout( jQuery.ready, 1 );
  380. }
  381. // Mozilla, Opera and webkit nightlies currently support this event
  382. if ( document.addEventListener ) {
  383. // Use the handy event callback
  384. document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  385. // A fallback to window.onload, that will always work
  386. window.addEventListener( "load", jQuery.ready, false );
  387. // If IE event model is used
  388. } else if ( document.attachEvent ) {
  389. // ensure firing before onload,
  390. // maybe late but safe also for iframes
  391. document.attachEvent( "onreadystatechange", DOMContentLoaded );
  392. // A fallback to window.onload, that will always work
  393. window.attachEvent( "onload", jQuery.ready );
  394. // If IE and not a frame
  395. // continually check to see if the document is ready
  396. var toplevel = false;
  397. try {
  398. toplevel = window.frameElement == null;
  399. } catch(e) {}
  400. if ( document.documentElement.doScroll && toplevel ) {
  401. doScrollCheck();
  402. }
  403. }
  404. },
  405. // See test/unit/core.js for details concerning isFunction.
  406. // Since version 1.3, DOM methods and functions like alert
  407. // aren't supported. They return false on IE (#2968).
  408. isFunction: function( obj ) {
  409. return jQuery.type(obj) === "function";
  410. },
  411. isArray: Array.isArray || function( obj ) {
  412. return jQuery.type(obj) === "array";
  413. },
  414. // A crude way of determining if an object is a window
  415. isWindow: function( obj ) {
  416. return obj && typeof obj === "object" && "setInterval" in obj;
  417. },
  418. isNaN: function( obj ) {
  419. return obj == null || !rdigit.test( obj ) || isNaN( obj );
  420. },
  421. type: function( obj ) {
  422. return obj == null ?
  423. String( obj ) :
  424. class2type[ toString.call(obj) ] || "object";
  425. },
  426. isPlainObject: function( obj ) {
  427. // Must be an Object.
  428. // Because of IE, we also have to check the presence of the constructor property.
  429. // Make sure that DOM nodes and window objects don't pass through, as well
  430. if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
  431. return false;
  432. }
  433. try {
  434. // Not own constructor property must be Object
  435. if ( obj.constructor &&
  436. !hasOwn.call(obj, "constructor") &&
  437. !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
  438. return false;
  439. }
  440. } catch ( e ) {
  441. // IE8,9 Will throw exceptions on certain host objects #9897
  442. return false;
  443. }
  444. // Own properties are enumerated firstly, so to speed up,
  445. // if last one is own, then all properties are own.
  446. var key;
  447. for ( key in obj ) {}
  448. return key === undefined || hasOwn.call( obj, key );
  449. },
  450. isEmptyObject: function( obj ) {
  451. for ( var name in obj ) {
  452. return false;
  453. }
  454. return true;
  455. },
  456. error: function( msg ) {
  457. throw msg;
  458. },
  459. parseJSON: function( data ) {
  460. if ( typeof data !== "string" || !data ) {
  461. return null;
  462. }
  463. // Make sure leading/trailing whitespace is removed (IE can't handle it)
  464. data = jQuery.trim( data );
  465. // Attempt to parse using the native JSON parser first
  466. if ( window.JSON && window.JSON.parse ) {
  467. return window.JSON.parse( data );
  468. }
  469. // Make sure the incoming data is actual JSON
  470. // Logic borrowed from http://json.org/json2.js
  471. if ( rvalidchars.test( data.replace( rvalidescape, "@" )
  472. .replace( rvalidtokens, "]" )
  473. .replace( rvalidbraces, "")) ) {
  474. return (new Function( "return " + data ))();
  475. }
  476. jQuery.error( "Invalid JSON: " + data );
  477. },
  478. // Cross-browser xml parsing
  479. parseXML: function( data ) {
  480. var xml, tmp;
  481. try {
  482. if ( window.DOMParser ) { // Standard
  483. tmp = new DOMParser();
  484. xml = tmp.parseFromString( data , "text/xml" );
  485. } else { // IE
  486. xml = new ActiveXObject( "Microsoft.XMLDOM" );
  487. xml.async = "false";
  488. xml.loadXML( data );
  489. }
  490. } catch( e ) {
  491. xml = undefined;
  492. }
  493. if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
  494. jQuery.error( "Invalid XML: " + data );
  495. }
  496. return xml;
  497. },
  498. noop: function() {},
  499. // Evaluates a script in a global context
  500. // Workarounds based on findings by Jim Driscoll
  501. // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
  502. globalEval: function( data ) {
  503. if ( data && rnotwhite.test( data ) ) {
  504. // We use execScript on Internet Explorer
  505. // We use an anonymous function so that context is window
  506. // rather than jQuery in Firefox
  507. ( window.execScript || function( data ) {
  508. window[ "eval" ].call( window, data );
  509. } )( data );
  510. }
  511. },
  512. // Convert dashed to camelCase; used by the css and data modules
  513. // Microsoft forgot to hump their vendor prefix (#9572)
  514. camelCase: function( string ) {
  515. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  516. },
  517. nodeName: function( elem, name ) {
  518. return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
  519. },
  520. // args is for internal usage only
  521. each: function( object, callback, args ) {
  522. var name, i = 0,
  523. length = object.length,
  524. isObj = length === undefined || jQuery.isFunction( object );
  525. if ( args ) {
  526. if ( isObj ) {
  527. for ( name in object ) {
  528. if ( callback.apply( object[ name ], args ) === false ) {
  529. break;
  530. }
  531. }
  532. } else {
  533. for ( ; i < length; ) {
  534. if ( callback.apply( object[ i++ ], args ) === false ) {
  535. break;
  536. }
  537. }
  538. }
  539. // A special, fast, case for the most common use of each
  540. } else {
  541. if ( isObj ) {
  542. for ( name in object ) {
  543. if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
  544. break;
  545. }
  546. }
  547. } else {
  548. for ( ; i < length; ) {
  549. if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
  550. break;
  551. }
  552. }
  553. }
  554. }
  555. return object;
  556. },
  557. // Use native String.trim function wherever possible
  558. trim: trim ?
  559. function( text ) {
  560. return text == null ?
  561. "" :
  562. trim.call( text );
  563. } :
  564. // Otherwise use our own trimming functionality
  565. function( text ) {
  566. return text == null ?
  567. "" :
  568. text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
  569. },
  570. // results is for internal usage only
  571. makeArray: function( array, results ) {
  572. var ret = results || [];
  573. if ( array != null ) {
  574. // The window, strings (and functions) also have 'length'
  575. // The extra typeof function check is to prevent crashes
  576. // in Safari 2 (See: #3039)
  577. // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
  578. var type = jQuery.type( array );
  579. if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
  580. push.call( ret, array );
  581. } else {
  582. jQuery.merge( ret, array );
  583. }
  584. }
  585. return ret;
  586. },
  587. inArray: function( elem, array ) {
  588. if ( !array ) {
  589. return -1;
  590. }
  591. if ( indexOf ) {
  592. return indexOf.call( array, elem );
  593. }
  594. for ( var i = 0, length = array.length; i < length; i++ ) {
  595. if ( array[ i ] === elem ) {
  596. return i;
  597. }
  598. }
  599. return -1;
  600. },
  601. merge: function( first, second ) {
  602. var i = first.length,
  603. j = 0;
  604. if ( typeof second.length === "number" ) {
  605. for ( var l = second.length; j < l; j++ ) {
  606. first[ i++ ] = second[ j ];
  607. }
  608. } else {
  609. while ( second[j] !== undefined ) {
  610. first[ i++ ] = second[ j++ ];
  611. }
  612. }
  613. first.length = i;
  614. return first;
  615. },
  616. grep: function( elems, callback, inv ) {
  617. var ret = [], retVal;
  618. inv = !!inv;
  619. // Go through the array, only saving the items
  620. // that pass the validator function
  621. for ( var i = 0, length = elems.length; i < length; i++ ) {
  622. retVal = !!callback( elems[ i ], i );
  623. if ( inv !== retVal ) {
  624. ret.push( elems[ i ] );
  625. }
  626. }
  627. return ret;
  628. },
  629. // arg is for internal usage only
  630. map: function( elems, callback, arg ) {
  631. var value, key, ret = [],
  632. i = 0,
  633. length = elems.length,
  634. // jquery objects are treated as arrays
  635. isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
  636. // Go through the array, translating each of the items to their
  637. if ( isArray ) {
  638. for ( ; i < length; i++ ) {
  639. value = callback( elems[ i ], i, arg );
  640. if ( value != null ) {
  641. ret[ ret.length ] = value;
  642. }
  643. }
  644. // Go through every key on the object,
  645. } else {
  646. for ( key in elems ) {
  647. value = callback( elems[ key ], key, arg );
  648. if ( value != null ) {
  649. ret[ ret.length ] = value;
  650. }
  651. }
  652. }
  653. // Flatten any nested arrays
  654. return ret.concat.apply( [], ret );
  655. },
  656. // A global GUID counter for objects
  657. guid: 1,
  658. // Bind a function to a context, optionally partially applying any
  659. // arguments.
  660. proxy: function( fn, context ) {
  661. if ( typeof context === "string" ) {
  662. var tmp = fn[ context ];
  663. context = fn;
  664. fn = tmp;
  665. }
  666. // Quick check to determine if target is callable, in the spec
  667. // this throws a TypeError, but we will just return undefined.
  668. if ( !jQuery.isFunction( fn ) ) {
  669. return undefined;
  670. }
  671. // Simulated bind
  672. var args = slice.call( arguments, 2 ),
  673. proxy = function() {
  674. return fn.apply( context, args.concat( slice.call( arguments ) ) );
  675. };
  676. // Set the guid of unique handler to the same of original handler, so it can be removed
  677. proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
  678. return proxy;
  679. },
  680. // Mutifunctional method to get and set values to a collection
  681. // The value/s can optionally be executed if it's a function
  682. access: function( elems, key, value, exec, fn, pass ) {
  683. var length = elems.length;
  684. // Setting many attributes
  685. if ( typeof key === "object" ) {
  686. for ( var k in key ) {
  687. jQuery.access( elems, k, key[k], exec, fn, value );
  688. }
  689. return elems;
  690. }
  691. // Setting one attribute
  692. if ( value !== undefined ) {
  693. // Optionally, function values get executed if exec is true
  694. exec = !pass && exec && jQuery.isFunction(value);
  695. for ( var i = 0; i < length; i++ ) {
  696. fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
  697. }
  698. return elems;
  699. }
  700. // Getting an attribute
  701. return length ? fn( elems[0], key ) : undefined;
  702. },
  703. now: function() {
  704. return (new Date()).getTime();
  705. },
  706. // Use of jQuery.browser is frowned upon.
  707. // More details: http://docs.jquery.com/Utilities/jQuery.browser
  708. uaMatch: function( ua ) {
  709. ua = ua.toLowerCase();
  710. var match = rwebkit.exec( ua ) ||
  711. ropera.exec( ua ) ||
  712. rmsie.exec( ua ) ||
  713. ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
  714. [];
  715. return { browser: match[1] || "", version: match[2] || "0" };
  716. },
  717. sub: function() {
  718. function jQuerySub( selector, context ) {
  719. return new jQuerySub.fn.init( selector, context );
  720. }
  721. jQuery.extend( true, jQuerySub, this );
  722. jQuerySub.superclass = this;
  723. jQuerySub.fn = jQuerySub.prototype = this();
  724. jQuerySub.fn.constructor = jQuerySub;
  725. jQuerySub.sub = this.sub;
  726. jQuerySub.fn.init = function init( selector, context ) {
  727. if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) {
  728. context = jQuerySub( context );
  729. }
  730. return jQuery.fn.init.call( this, selector, context, rootjQuerySub );
  731. };
  732. jQuerySub.fn.init.prototype = jQuerySub.fn;
  733. var rootjQuerySub = jQuerySub(document);
  734. return jQuerySub;
  735. },
  736. browser: {}
  737. });
  738. // Populate the class2type map
  739. jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
  740. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  741. });
  742. browserMatch = jQuery.uaMatch( userAgent );
  743. if ( browserMatch.browser ) {
  744. jQuery.browser[ browserMatch.browser ] = true;
  745. jQuery.browser.version = browserMatch.version;
  746. }
  747. // Deprecated, use jQuery.browser.webkit instead
  748. if ( jQuery.browser.webkit ) {
  749. jQuery.browser.safari = true;
  750. }
  751. // IE doesn't match non-breaking spaces with \s
  752. if ( rnotwhite.test( "\xA0" ) ) {
  753. trimLeft = /^[\s\xA0]+/;
  754. trimRight = /[\s\xA0]+$/;
  755. }
  756. // All jQuery objects should point back to these
  757. rootjQuery = jQuery(document);
  758. // Cleanup functions for the document ready method
  759. if ( document.addEventListener ) {
  760. DOMContentLoaded = function() {
  761. document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
  762. jQuery.ready();
  763. };
  764. } else if ( document.attachEvent ) {
  765. DOMContentLoaded = function() {
  766. // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
  767. if ( document.readyState === "complete" ) {
  768. document.detachEvent( "onreadystatechange", DOMContentLoaded );
  769. jQuery.ready();
  770. }
  771. };
  772. }
  773. // The DOM ready check for Internet Explorer
  774. function doScrollCheck() {
  775. if ( jQuery.isReady ) {
  776. return;
  777. }
  778. try {
  779. // If IE is used, use the trick by Diego Perini
  780. // http://javascript.nwbox.com/IEContentLoaded/
  781. document.documentElement.doScroll("left");
  782. } catch(e) {
  783. setTimeout( doScrollCheck, 1 );
  784. return;
  785. }
  786. // and execute any waiting functions
  787. jQuery.ready();
  788. }
  789. return jQuery;
  790. })();
  791. var // Promise methods
  792. promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ),
  793. // Static reference to slice
  794. sliceDeferred = [].slice;
  795. jQuery.extend({
  796. // Create a simple deferred (one callbacks list)
  797. _Deferred: function() {
  798. var // callbacks list
  799. callbacks = [],
  800. // stored [ context , args ]
  801. fired,
  802. // to avoid firing when already doing so
  803. firing,
  804. // flag to know if the deferred has been cancelled
  805. cancelled,
  806. // the deferred itself
  807. deferred = {
  808. // done( f1, f2, ...)
  809. done: function() {
  810. if ( !cancelled ) {
  811. var args = arguments,
  812. i,
  813. length,
  814. elem,
  815. type,
  816. _fired;
  817. if ( fired ) {
  818. _fired = fired;
  819. fired = 0;
  820. }
  821. for ( i = 0, length = args.length; i < length; i++ ) {
  822. elem = args[ i ];
  823. type = jQuery.type( elem );
  824. if ( type === "array" ) {
  825. deferred.done.apply( deferred, elem );
  826. } else if ( type === "function" ) {
  827. callbacks.push( elem );
  828. }
  829. }
  830. if ( _fired ) {
  831. deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
  832. }
  833. }
  834. return this;
  835. },
  836. // resolve with given context and args
  837. resolveWith: function( context, args ) {
  838. if ( !cancelled && !fired && !firing ) {
  839. // make sure args are available (#8421)
  840. args = args || [];
  841. firing = 1;
  842. try {
  843. while( callbacks[ 0 ] ) {
  844. callbacks.shift().apply( context, args );
  845. }
  846. }
  847. finally {
  848. fired = [ context, args ];
  849. firing = 0;
  850. }
  851. }
  852. return this;
  853. },
  854. // resolve with this as context and given arguments
  855. resolve: function() {
  856. deferred.resolveWith( this, arguments );
  857. return this;
  858. },
  859. // Has this deferred been resolved?
  860. isResolved: function() {
  861. return !!( firing || fired );
  862. },
  863. // Cancel
  864. cancel: function() {
  865. cancelled = 1;
  866. callbacks = [];
  867. return this;
  868. }
  869. };
  870. return deferred;
  871. },
  872. // Full fledged deferred (two callbacks list)
  873. Deferred: function( func ) {
  874. var deferred = jQuery._Deferred(),
  875. failDeferred = jQuery._Deferred(),
  876. promise;
  877. // Add errorDeferred methods, then and promise
  878. jQuery.extend( deferred, {
  879. then: function( doneCallbacks, failCallbacks ) {
  880. deferred.done( doneCallbacks ).fail( failCallbacks );
  881. return this;
  882. },
  883. always: function() {
  884. return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments );
  885. },
  886. fail: failDeferred.done,
  887. rejectWith: failDeferred.resolveWith,
  888. reject: failDeferred.resolve,
  889. isRejected: failDeferred.isResolved,
  890. pipe: function( fnDone, fnFail ) {
  891. return jQuery.Deferred(function( newDefer ) {
  892. jQuery.each( {
  893. done: [ fnDone, "resolve" ],
  894. fail: [ fnFail, "reject" ]
  895. }, function( handler, data ) {
  896. var fn = data[ 0 ],
  897. action = data[ 1 ],
  898. returned;
  899. if ( jQuery.isFunction( fn ) ) {
  900. deferred[ handler ](function() {
  901. returned = fn.apply( this, arguments );
  902. if ( returned && jQuery.isFunction( returned.promise ) ) {
  903. returned.promise().then( newDefer.resolve, newDefer.reject );
  904. } else {
  905. newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] );
  906. }
  907. });
  908. } else {
  909. deferred[ handler ]( newDefer[ action ] );
  910. }
  911. });
  912. }).promise();
  913. },
  914. // Get a promise for this deferred
  915. // If obj is provided, the promise aspect is added to the object
  916. promise: function( obj ) {
  917. if ( obj == null ) {
  918. if ( promise ) {
  919. return promise;
  920. }
  921. promise = obj = {};
  922. }
  923. var i = promiseMethods.length;
  924. while( i-- ) {
  925. obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
  926. }
  927. return obj;
  928. }
  929. });
  930. // Make sure only one callback list will be used
  931. deferred.done( failDeferred.cancel ).fail( deferred.cancel );
  932. // Unexpose cancel
  933. delete deferred.cancel;
  934. // Call given func if any
  935. if ( func ) {
  936. func.call( deferred, deferred );
  937. }
  938. return deferred;
  939. },
  940. // Deferred helper
  941. when: function( firstParam ) {
  942. var args = arguments,
  943. i = 0,
  944. length = args.length,
  945. count = length,
  946. deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ?
  947. firstParam :
  948. jQuery.Deferred();
  949. function resolveFunc( i ) {
  950. return function( value ) {
  951. args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value;
  952. if ( !( --count ) ) {
  953. // Strange bug in FF4:
  954. // Values changed onto the arguments object sometimes end up as undefined values
  955. // outside the $.when method. Cloning the object into a fresh array solves the issue
  956. deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) );
  957. }
  958. };
  959. }
  960. if ( length > 1 ) {
  961. for( ; i < length; i++ ) {
  962. if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) {
  963. args[ i ].promise().then( resolveFunc(i), deferred.reject );
  964. } else {
  965. --count;
  966. }
  967. }
  968. if ( !count ) {
  969. deferred.resolveWith( deferred, args );
  970. }
  971. } else if ( deferred !== firstParam ) {
  972. deferred.resolveWith( deferred, length ? [ firstParam ] : [] );
  973. }
  974. return deferred.promise();
  975. }
  976. });
  977. jQuery.support = (function() {
  978. var div = document.createElement( "div" ),
  979. documentElement = document.documentElement,
  980. all,
  981. a,
  982. select,
  983. opt,
  984. input,
  985. marginDiv,
  986. support,
  987. fragment,
  988. body,
  989. testElementParent,
  990. testElement,
  991. testElementStyle,
  992. tds,
  993. events,
  994. eventName,
  995. i,
  996. isSupported;
  997. // Preliminary tests
  998. div.setAttribute("className", "t");
  999. div.innerHTML = " <link><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type=checkbox>";
  1000. all = div.getElementsByTagName( "*" );
  1001. a = div.getElementsByTagName( "a" )[ 0 ];
  1002. // Can't get basic test support
  1003. if ( !all || !all.length || !a ) {
  1004. return {};
  1005. }
  1006. // First batch of supports tests
  1007. select = document.createElement( "select" );
  1008. opt = select.appendChild( document.createElement("option") );
  1009. input = div.getElementsByTagName( "input" )[ 0 ];
  1010. support = {
  1011. // IE strips leading whitespace when .innerHTML is used
  1012. leadingWhitespace: ( div.firstChild.nodeType === 3 ),
  1013. // Make sure that tbody elements aren't automatically inserted
  1014. // IE will insert them into empty tables
  1015. tbody: !div.getElementsByTagName( "tbody" ).length,
  1016. // Make sure that link elements get serialized correctly by innerHTML
  1017. // This requires a wrapper element in IE
  1018. htmlSerialize: !!div.getElementsByTagName( "link" ).length,
  1019. // Get the style information from getAttribute
  1020. // (IE uses .cssText instead)
  1021. style: /top/.test( a.getAttribute("style") ),
  1022. // Make sure that URLs aren't manipulated
  1023. // (IE normalizes it by default)
  1024. hrefNormalized: ( a.getAttribute( "href" ) === "/a" ),
  1025. // Make sure that element opacity exists
  1026. // (IE uses filter instead)
  1027. // Use a regex to work around a WebKit issue. See #5145
  1028. opacity: /^0.55$/.test( a.style.opacity ),
  1029. // Verify style float existence
  1030. // (IE uses styleFloat instead of cssFloat)
  1031. cssFloat: !!a.style.cssFloat,
  1032. // Make sure that if no value is specified for a checkbox
  1033. // that it defaults to "on".
  1034. // (WebKit defaults to "" instead)
  1035. checkOn: ( input.value === "on" ),
  1036. // Make sure that a selected-by-default option has a working selected property.
  1037. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
  1038. optSelected: opt.selected,
  1039. // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
  1040. getSetAttribute: div.className !== "t",
  1041. // Will be defined later
  1042. submitBubbles: true,
  1043. changeBubbles: true,
  1044. focusinBubbles: false,
  1045. deleteExpando: true,
  1046. noCloneEvent: true,
  1047. inlineBlockNeedsLayout: false,
  1048. shrinkWrapBlocks: false,
  1049. reliableMarginRight: true
  1050. };
  1051. // Make sure checked status is properly cloned
  1052. input.checked = true;
  1053. support.noCloneChecked = input.cloneNode( true ).checked;
  1054. // Make sure that the options inside disabled selects aren't marked as disabled
  1055. // (WebKit marks them as disabled)
  1056. select.disabled = true;
  1057. support.optDisabled = !opt.disabled;
  1058. // Test to see if it's possible to delete an expando from an element
  1059. // Fails in Internet Explorer
  1060. try {
  1061. delete div.test;
  1062. } catch( e ) {
  1063. support.deleteExpando = false;
  1064. }
  1065. if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
  1066. div.attachEvent( "onclick", function() {
  1067. // Cloning a node shouldn't copy over any
  1068. // bound event handlers (IE does this)
  1069. support.noCloneEvent = false;
  1070. });
  1071. div.cloneNode( true ).fireEvent( "onclick" );
  1072. }
  1073. // Check if a radio maintains it's value
  1074. // after being appended to the DOM
  1075. input = document.createElement("input");
  1076. input.value = "t";
  1077. input.setAttribute("type", "radio");
  1078. support.radioValue = input.value === "t";
  1079. input.setAttribute("checked", "checked");
  1080. div.appendChild( input );
  1081. fragment = document.createDocumentFragment();
  1082. fragment.appendChild( div.firstChild );
  1083. // WebKit doesn't clone checked state correctly in fragments
  1084. support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked;
  1085. div.innerHTML = "";
  1086. // Figure out if the W3C box model works as expected
  1087. div.style.width = div.style.paddingLeft = "1px";
  1088. body = document.getElementsByTagName( "body" )[ 0 ];
  1089. // We use our own, invisible, body unless the body is already present
  1090. // in which case we use a div (#9239)
  1091. testElement = document.createElement( body ? "div" : "body" );
  1092. testElementStyle = {
  1093. visibility: "hidden",
  1094. width: 0,
  1095. height: 0,
  1096. border: 0,
  1097. margin: 0,
  1098. background: "none"
  1099. };
  1100. if ( body ) {
  1101. jQuery.extend( testElementStyle, {
  1102. position: "absolute",
  1103. left: "-1000px",
  1104. top: "-1000px"
  1105. });
  1106. }
  1107. for ( i in testElementStyle ) {
  1108. testElement.style[ i ] = testElementStyle[ i ];
  1109. }
  1110. testElement.appendChild( div );
  1111. testElementParent = body || documentElement;
  1112. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1113. // Check if a disconnected checkbox will retain its checked
  1114. // value of true after appended to the DOM (IE6/7)
  1115. support.appendChecked = input.checked;
  1116. support.boxModel = div.offsetWidth === 2;
  1117. if ( "zoom" in div.style ) {
  1118. // Check if natively block-level elements act like inline-block
  1119. // elements when setting their display to 'inline' and giving
  1120. // them layout
  1121. // (IE < 8 does this)
  1122. div.style.display = "inline";
  1123. div.style.zoom = 1;
  1124. support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 );
  1125. // Check if elements with layout shrink-wrap their children
  1126. // (IE 6 does this)
  1127. div.style.display = "";
  1128. div.innerHTML = "<div style='width:4px;'></div>";
  1129. support.shrinkWrapBlocks = ( div.offsetWidth !== 2 );
  1130. }
  1131. div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
  1132. tds = div.getElementsByTagName( "td" );
  1133. // Check if table cells still have offsetWidth/Height when they are set
  1134. // to display:none and there are still other visible table cells in a
  1135. // table row; if so, offsetWidth/Height are not reliable for use when
  1136. // determining if an element has been hidden directly using
  1137. // display:none (it is still safe to use offsets if a parent element is
  1138. // hidden; don safety goggles and see bug #4512 for more information).
  1139. // (only IE 8 fails this test)
  1140. isSupported = ( tds[ 0 ].offsetHeight === 0 );
  1141. tds[ 0 ].style.display = "";
  1142. tds[ 1 ].style.display = "none";
  1143. // Check if empty table cells still have offsetWidth/Height
  1144. // (IE < 8 fail this test)
  1145. support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 );
  1146. div.innerHTML = "";
  1147. // Check if div with explicit width and no margin-right incorrectly
  1148. // gets computed margin-right based on width of container. For more
  1149. // info see bug #3333
  1150. // Fails in WebKit before Feb 2011 nightlies
  1151. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  1152. if ( document.defaultView && document.defaultView.getComputedStyle ) {
  1153. marginDiv = document.createElement( "div" );
  1154. marginDiv.style.width = "0";
  1155. marginDiv.style.marginRight = "0";
  1156. div.appendChild( marginDiv );
  1157. support.reliableMarginRight =
  1158. ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0;
  1159. }
  1160. // Remove the body element we added
  1161. testElement.innerHTML = "";
  1162. testElementParent.removeChild( testElement );
  1163. // Technique from Juriy Zaytsev
  1164. // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
  1165. // We only care about the case where non-standard event systems
  1166. // are used, namely in IE. Short-circuiting here helps us to
  1167. // avoid an eval call (in setAttribute) which can cause CSP
  1168. // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
  1169. if ( div.attachEvent ) {
  1170. for( i in {
  1171. submit: 1,
  1172. change: 1,
  1173. focusin: 1
  1174. } ) {
  1175. eventName = "on" + i;
  1176. isSupported = ( eventName in div );
  1177. if ( !isSupported ) {
  1178. div.setAttribute( eventName, "return;" );
  1179. isSupported = ( typeof div[ eventName ] === "function" );
  1180. }
  1181. support[ i + "Bubbles" ] = isSupported;
  1182. }
  1183. }
  1184. // Null connected elements to avoid leaks in IE
  1185. testElement = fragment = select = opt = body = marginDiv = div = input = null;
  1186. return support;
  1187. })();
  1188. // Keep track of boxModel
  1189. jQuery.boxModel = jQuery.support.boxModel;
  1190. var rbrace = /^(?:\{.*\}|\[.*\])$/,
  1191. rmultiDash = /([a-z])([A-Z])/g;
  1192. jQuery.extend({
  1193. cache: {},
  1194. // Please use with caution
  1195. uuid: 0,
  1196. // Unique for each copy of jQuery on the page
  1197. // Non-digits removed to match rinlinejQuery
  1198. expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
  1199. // The following elements throw uncatchable exceptions if you
  1200. // attempt to add expando properties to them.
  1201. noData: {
  1202. "embed": true,
  1203. // Ban all objects except for Flash (which handle expandos)
  1204. "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
  1205. "applet": true
  1206. },
  1207. hasData: function( elem ) {
  1208. elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
  1209. return !!elem && !isEmptyDataObject( elem );
  1210. },
  1211. data: function( elem, name, data, pvt /* Internal Use Only */ ) {
  1212. if ( !jQuery.acceptData( elem ) ) {
  1213. return;
  1214. }
  1215. var thisCache, ret,
  1216. internalKey = jQuery.expando,
  1217. getByName = typeof name === "string",
  1218. // We have to handle DOM nodes and JS objects differently because IE6-7
  1219. // can't GC object references properly across the DOM-JS boundary
  1220. isNode = elem.nodeType,
  1221. // Only DOM nodes need the global jQuery cache; JS object data is
  1222. // attached directly to the object so GC can occur automatically
  1223. cache = isNode ? jQuery.cache : elem,
  1224. // Only defining an ID for JS objects if its cache already exists allows
  1225. // the code to shortcut on the same path as a DOM node with no cache
  1226. id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
  1227. // Avoid doing any more work than we need to when trying to get data on an
  1228. // object that has no data at all
  1229. if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) {
  1230. return;
  1231. }
  1232. if ( !id ) {
  1233. // Only DOM nodes need a new unique ID for each element since their data
  1234. // ends up in the global cache
  1235. if ( isNode ) {
  1236. elem[ jQuery.expando ] = id = ++jQuery.uuid;
  1237. } else {
  1238. id = jQuery.expando;
  1239. }
  1240. }
  1241. if ( !cache[ id ] ) {
  1242. cache[ id ] = {};
  1243. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1244. // metadata on plain JS objects when the object is serialized using
  1245. // JSON.stringify
  1246. if ( !isNode ) {
  1247. cache[ id ].toJSON = jQuery.noop;
  1248. }
  1249. }
  1250. // An object can be passed to jQuery.data instead of a key/value pair; this gets
  1251. // shallow copied over onto the existing cache
  1252. if ( typeof name === "object" || typeof name === "function" ) {
  1253. if ( pvt ) {
  1254. cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
  1255. } else {
  1256. cache[ id ] = jQuery.extend(cache[ id ], name);
  1257. }
  1258. }
  1259. thisCache = cache[ id ];
  1260. // Internal jQuery data is stored in a separate object inside the object's data
  1261. // cache in order to avoid key collisions between internal data and user-defined
  1262. // data
  1263. if ( pvt ) {
  1264. if ( !thisCache[ internalKey ] ) {
  1265. thisCache[ internalKey ] = {};
  1266. }
  1267. thisCache = thisCache[ internalKey ];
  1268. }
  1269. if ( data !== undefined ) {
  1270. thisCache[ jQuery.camelCase( name ) ] = data;
  1271. }
  1272. // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
  1273. // not attempt to inspect the internal events object using jQuery.data, as this
  1274. // internal data object is undocumented and subject to change.
  1275. if ( name === "events" && !thisCache[name] ) {
  1276. return thisCache[ internalKey ] && thisCache[ internalKey ].events;
  1277. }
  1278. // Check for both converted-to-camel and non-converted data property names
  1279. // If a data property was specified
  1280. if ( getByName ) {
  1281. // First Try to find as-is property data
  1282. ret = thisCache[ name ];
  1283. // Test for null|undefined property data
  1284. if ( ret == null ) {
  1285. // Try to find the camelCased property
  1286. ret = thisCache[ jQuery.camelCase( name ) ];
  1287. }
  1288. } else {
  1289. ret = thisCache;
  1290. }
  1291. return ret;
  1292. },
  1293. removeData: function( elem, name, pvt /* Internal Use Only */ ) {
  1294. if ( !jQuery.acceptData( elem ) ) {
  1295. return;
  1296. }
  1297. var thisCache,
  1298. // Reference to internal data cache key
  1299. internalKey = jQuery.expando,
  1300. isNode = elem.nodeType,
  1301. // See jQuery.data for more information
  1302. cache = isNode ? jQuery.cache : elem,
  1303. // See jQuery.data for more information
  1304. id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
  1305. // If there is already no cache entry for this object, there is no
  1306. // purpose in continuing
  1307. if ( !cache[ id ] ) {
  1308. return;
  1309. }
  1310. if ( name ) {
  1311. thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
  1312. if ( thisCache ) {
  1313. // Support interoperable removal of hyphenated or camelcased keys
  1314. if ( !thisCache[ name ] ) {
  1315. name = jQuery.camelCase( name );
  1316. }
  1317. delete thisCache[ name ];
  1318. // If there is no data left in the cache, we want to continue
  1319. // and let the cache object itself get destroyed
  1320. if ( !isEmptyDataObject(thisCache) ) {
  1321. return;
  1322. }
  1323. }
  1324. }
  1325. // See jQuery.data for more information
  1326. if ( pvt ) {
  1327. delete cache[ id ][ internalKey ];
  1328. // Don't destroy the parent cache unless the internal data object
  1329. // had been the only thing left in it
  1330. if ( !isEmptyDataObject(cache[ id ]) ) {
  1331. return;
  1332. }
  1333. }
  1334. var internalCache = cache[ id ][ internalKey ];
  1335. // Browsers that fail expando deletion also refuse to delete expandos on
  1336. // the window, but it will allow it on all other JS objects; other browsers
  1337. // don't care
  1338. // Ensure that `cache` is not a window object #10080
  1339. if ( jQuery.support.deleteExpando || !cache.setInterval ) {
  1340. delete cache[ id ];
  1341. } else {
  1342. cache[ id ] = null;
  1343. }
  1344. // We destroyed the entire user cache at once because it's faster than
  1345. // iterating through each key, but we need to continue to persist internal
  1346. // data if it existed
  1347. if ( internalCache ) {
  1348. cache[ id ] = {};
  1349. // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
  1350. // metadata on plain JS objects when the object is serialized using
  1351. // JSON.stringify
  1352. if ( !isNode ) {
  1353. cache[ id ].toJSON = jQuery.noop;
  1354. }
  1355. cache[ id ][ internalKey ] = internalCache;
  1356. // Otherwise, we need to eliminate the expando on the node to avoid
  1357. // false lookups in the cache for entries that no longer exist
  1358. } else if ( isNode ) {
  1359. // IE does not allow us to delete expando properties from nodes,
  1360. // nor does it have a removeAttribute function on Document nodes;
  1361. // we must handle all of these cases
  1362. if ( jQuery.support.deleteExpando ) {
  1363. delete elem[ jQuery.expando ];
  1364. } else if ( elem.removeAttribute ) {
  1365. elem.removeAttribute( jQuery.expando );
  1366. } else {
  1367. elem[ jQuery.expando ] = null;
  1368. }
  1369. }
  1370. },
  1371. // For internal use only.
  1372. _data: function( elem, name, data ) {
  1373. return jQuery.data( elem, name, data, true );
  1374. },
  1375. // A method for determining if a DOM node can handle the data expando
  1376. acceptData: function( elem ) {
  1377. if ( elem.nodeName ) {
  1378. var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
  1379. if ( match ) {
  1380. return !(match === true || elem.getAttribute("classid") !== match);
  1381. }
  1382. }
  1383. return true;
  1384. }
  1385. });
  1386. jQuery.fn.extend({
  1387. data: function( key, value ) {
  1388. var data = null;
  1389. if ( typeof key === "undefined" ) {
  1390. if ( this.length ) {
  1391. data = jQuery.data( this[0] );
  1392. if ( this[0].nodeType === 1 ) {
  1393. var attr = this[0].attributes, name;
  1394. for ( var i = 0, l = attr.length; i < l; i++ ) {
  1395. name = attr[i].name;
  1396. if ( name.indexOf( "data-" ) === 0 ) {
  1397. name = jQuery.camelCase( name.substring(5) );
  1398. dataAttr( this[0], name, data[ name ] );
  1399. }
  1400. }
  1401. }
  1402. }
  1403. return data;
  1404. } else if ( typeof key === "object" ) {
  1405. return this.each(function() {
  1406. jQuery.data( this, key );
  1407. });
  1408. }
  1409. var parts = key.split(".");
  1410. parts[1] = parts[1] ? "." + parts[1] : "";
  1411. if ( value === undefined ) {
  1412. data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
  1413. // Try to fetch any internally stored data first
  1414. if ( data === undefined && this.length ) {
  1415. data = jQuery.data( this[0], key );
  1416. data = dataAttr( this[0], key, data );
  1417. }
  1418. return data === undefined && parts[1] ?
  1419. this.data( parts[0] ) :
  1420. data;
  1421. } else {
  1422. return this.each(function() {
  1423. var $this = jQuery( this ),
  1424. args = [ parts[0], value ];
  1425. $this.triggerHandler( "setData" + parts[1] + "!", args );
  1426. jQuery.data( this, key, value );
  1427. $this.triggerHandler( "changeData" + parts[1] + "!", args );
  1428. });
  1429. }
  1430. },
  1431. removeData: function( key ) {
  1432. return this.each(function() {
  1433. jQuery.removeData( this, key );
  1434. });
  1435. }
  1436. });
  1437. function dataAttr( elem, key, data ) {
  1438. // If nothing was found internally, try to fetch any
  1439. // data from the HTML5 data-* attribute
  1440. if ( data === undefined && elem.nodeType === 1 ) {
  1441. var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase();
  1442. data = elem.getAttribute( name );
  1443. if ( typeof data === "string" ) {
  1444. try {
  1445. data = data === "true" ? true :
  1446. data === "false" ? false :
  1447. data === "null" ? null :
  1448. !jQuery.isNaN( data ) ? parseFloat( data ) :
  1449. rbrace.test( data ) ? jQuery.parseJSON( data ) :
  1450. data;
  1451. } catch( e ) {}
  1452. // Make sure we set the data so it isn't changed later
  1453. jQuery.data( elem, key, data );
  1454. } else {
  1455. data = undefined;
  1456. }
  1457. }
  1458. return data;
  1459. }
  1460. // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
  1461. // property to be considered empty objects; this property always exists in
  1462. // order to make sure JSON.stringify does not expose internal metadata
  1463. function isEmptyDataObject( obj ) {
  1464. for ( var name in obj ) {
  1465. if ( name !== "toJSON" ) {
  1466. return false;
  1467. }
  1468. }
  1469. return true;
  1470. }
  1471. function handleQueueMarkDefer( elem, type, src ) {
  1472. var deferDataKey = type + "defer",
  1473. queueDataKey = type + "queue",
  1474. markDataKey = type + "mark",
  1475. defer = jQuery.data( elem, deferDataKey, undefined, true );
  1476. if ( defer &&
  1477. ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) &&
  1478. ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) {
  1479. // Give room for hard-coded callbacks to fire first
  1480. // and eventually mark/queue something else on the element
  1481. setTimeout( function() {
  1482. if ( !jQuery.data( elem, queueDataKey, undefined, true ) &&
  1483. !jQuery.data( elem, markDataKey, undefined, true ) ) {
  1484. jQuery.removeData( elem, deferDataKey, true );
  1485. defer.resolve();
  1486. }
  1487. }, 0 );
  1488. }
  1489. }
  1490. jQuery.extend({
  1491. _mark: function( elem, type ) {
  1492. if ( elem ) {
  1493. type = (type || "fx") + "mark";
  1494. jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true );
  1495. }
  1496. },
  1497. _unmark: function( force, elem, type ) {
  1498. if ( force !== true ) {
  1499. type = elem;
  1500. elem = force;
  1501. force = false;
  1502. }
  1503. if ( elem ) {
  1504. type = type || "fx";
  1505. var key = type + "mark",
  1506. count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 );
  1507. if ( count ) {
  1508. jQuery.data( elem, key, count, true );
  1509. } else {
  1510. jQuery.removeData( elem, key, true );
  1511. handleQueueMarkDefer( elem, type, "mark" );
  1512. }
  1513. }
  1514. },
  1515. queue: function( elem, type, data ) {
  1516. if ( elem ) {
  1517. type = (type || "fx") + "queue";
  1518. var q = jQuery.data( elem, type, undefined, true );
  1519. // Speed up dequeue by getting out quickly if this is just a lookup
  1520. if ( data ) {
  1521. if ( !q || jQuery.isArray(data) ) {
  1522. q = jQuery.data( elem, type, jQuery.makeArray(data), true );
  1523. } else {
  1524. q.push( data );
  1525. }
  1526. }
  1527. return q || [];
  1528. }
  1529. },
  1530. dequeue: function( elem, type ) {
  1531. type = type || "fx";
  1532. var queue = jQuery.queue( elem, type ),
  1533. fn = queue.shift(),
  1534. defer;
  1535. // If the fx queue is dequeued, always remove the progress sentinel
  1536. if ( fn === "inprogress" ) {
  1537. fn = queue.shift();
  1538. }
  1539. if ( fn ) {
  1540. // Add a progress sentinel to prevent the fx queue from being
  1541. // automatically dequeued
  1542. if ( type === "fx" ) {
  1543. queue.unshift("inprogress");
  1544. }
  1545. fn.call(elem, function() {
  1546. jQuery.dequeue(elem, type);
  1547. });
  1548. }
  1549. if ( !queue.length ) {
  1550. jQuery.removeData( elem, type + "queue", true );
  1551. handleQueueMarkDefer( elem, type, "queue" );
  1552. }
  1553. }
  1554. });
  1555. jQuery.fn.extend({
  1556. queue: function( type, data ) {
  1557. if ( typeof type !== "string" ) {
  1558. data = type;
  1559. type = "fx";
  1560. }
  1561. if ( data === undefined ) {
  1562. return jQuery.queue( this[0], type );
  1563. }
  1564. return this.each(function() {
  1565. var queue = jQuery.queue( this, type, data );
  1566. if ( type === "fx" && queue[0] !== "inprogress" ) {
  1567. jQuery.dequeue( this, type );
  1568. }
  1569. });
  1570. },
  1571. dequeue: function( type ) {
  1572. return this.each(function() {
  1573. jQuery.dequeue( this, type );
  1574. });
  1575. },
  1576. // Based off of the plugin by Clint Helfers, with permission.
  1577. // http://blindsignals.com/index.php/2009/07/jquery-delay/
  1578. delay: function( time, type ) {
  1579. time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
  1580. type = type || "fx";
  1581. return this.queue( type, function() {
  1582. var elem = this;
  1583. setTimeout(function() {
  1584. jQuery.dequeue( elem, type );
  1585. }, time );
  1586. });
  1587. },
  1588. clearQueue: function( type ) {
  1589. return this.queue( type || "fx", [] );
  1590. },
  1591. // Get a promise resolved when queues of a certain type
  1592. // are emptied (fx is the type by default)
  1593. promise: function( type, object ) {
  1594. if ( typeof type !== "string" ) {
  1595. object = type;
  1596. type = undefined;
  1597. }
  1598. type = type || "fx";
  1599. var defer = jQuery.Deferred(),
  1600. elements = this,
  1601. i = elements.length,
  1602. count = 1,
  1603. deferDataKey = type + "defer",
  1604. queueDataKey = type + "queue",
  1605. markDataKey = type + "mark",
  1606. tmp;
  1607. function resolve() {
  1608. if ( !( --count ) ) {
  1609. defer.resolveWith( elements, [ elements ] );
  1610. }
  1611. }
  1612. while( i-- ) {
  1613. if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
  1614. ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
  1615. jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
  1616. jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) {
  1617. count++;
  1618. tmp.done( resolve );
  1619. }
  1620. }
  1621. resolve();
  1622. return defer.promise();
  1623. }
  1624. });
  1625. var rclass = /[\n\t\r]/g,
  1626. rspace = /\s+/,
  1627. rreturn = /\r/g,
  1628. rtype = /^(?:button|input)$/i,
  1629. rfocusable = /^(?:button|input|object|select|textarea)$/i,
  1630. rclickable = /^a(?:rea)?$/i,
  1631. rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
  1632. nodeHook, boolHook;
  1633. jQuery.fn.extend({
  1634. attr: function( name, value ) {
  1635. return jQuery.access( this, name, value, true, jQuery.attr );
  1636. },
  1637. removeAttr: function( name ) {
  1638. return this.each(function() {
  1639. jQuery.removeAttr( this, name );
  1640. });
  1641. },
  1642. prop: function( name, value ) {
  1643. return jQuery.access( this, name, value, true, jQuery.prop );
  1644. },
  1645. removeProp: function( name ) {
  1646. name = jQuery.propFix[ name ] || name;
  1647. return this.each(function() {
  1648. // try/catch handles cases where IE balks (such as removing a property on window)
  1649. try {
  1650. this[ name ] = undefined;
  1651. delete this[ name ];
  1652. } catch( e ) {}
  1653. });
  1654. },
  1655. addClass: function( value ) {
  1656. var classNames, i, l, elem,
  1657. setClass, c, cl;
  1658. if ( jQuery.isFunction( value ) ) {
  1659. return this.each(function( j ) {
  1660. jQuery( this ).addClass( value.call(this, j, this.className) );
  1661. });
  1662. }
  1663. if ( value && typeof value === "string" ) {
  1664. classNames = value.split( rspace );
  1665. for ( i = 0, l = this.length; i < l; i++ ) {
  1666. elem = this[ i ];
  1667. if ( elem.nodeType === 1 ) {
  1668. if ( !elem.className && classNames.length === 1 ) {
  1669. elem.className = value;
  1670. } else {
  1671. setClass = " " + elem.className + " ";
  1672. for ( c = 0, cl = classNames.length; c < cl; c++ ) {
  1673. if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
  1674. setClass += classNames[ c ] + " ";
  1675. }
  1676. }
  1677. elem.className = jQuery.trim( setClass );
  1678. }
  1679. }
  1680. }
  1681. }
  1682. return this;
  1683. },
  1684. removeClass: function( value ) {
  1685. var classNames, i, l, elem, className, c, cl;
  1686. if ( jQuery.isFunction( value ) ) {
  1687. return this.each(function( j ) {
  1688. jQuery( this ).removeClass( value.call(this, j, this.className) );
  1689. });
  1690. }
  1691. if ( (value && typeof value === "string") || value === undefined ) {
  1692. classNames = (value || "").split( rspace );
  1693. for ( i = 0, l = this.length; i < l; i++ ) {
  1694. elem = this[ i ];
  1695. if ( elem.nodeType === 1 && elem.className ) {
  1696. if ( value ) {
  1697. className = (" " + elem.className + " ").replace( rclass, " " );
  1698. for ( c = 0, cl = classNames.length; c < cl; c++ ) {
  1699. className = className.replace(" " + classNames[ c ] + " ", " ");
  1700. }
  1701. elem.className = jQuery.trim( className );
  1702. } else {
  1703. elem.className = "";
  1704. }
  1705. }
  1706. }
  1707. }
  1708. return this;
  1709. },
  1710. toggleClass: function( value, stateVal ) {
  1711. var type = typeof value,
  1712. isBool = typeof stateVal === "boolean";
  1713. if ( jQuery.isFunction( value ) ) {
  1714. return this.each(function( i ) {
  1715. jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
  1716. });
  1717. }
  1718. return this.each(function() {
  1719. if ( type === "string" ) {
  1720. // toggle individual class names
  1721. var className,
  1722. i = 0,
  1723. self = jQuery( this ),
  1724. state = stateVal,
  1725. classNames = value.split( rspace );
  1726. while ( (className = classNames[ i++ ]) ) {
  1727. // check each className given, space seperated list
  1728. state = isBool ? state : !self.hasClass( className );
  1729. self[ state ? "addClass" : "removeClass" ]( className );
  1730. }
  1731. } else if ( type === "undefined" || type === "boolean" ) {
  1732. if ( this.className ) {
  1733. // store className if set
  1734. jQuery._data( this, "__className__", this.className );
  1735. }
  1736. // toggle whole className
  1737. this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
  1738. }
  1739. });
  1740. },
  1741. hasClass: function( selector ) {
  1742. var className = " " + selector + " ";
  1743. for ( var i = 0, l = this.length; i < l; i++ ) {
  1744. if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
  1745. return true;
  1746. }
  1747. }
  1748. return false;
  1749. },
  1750. val: function( value ) {
  1751. var hooks, ret,
  1752. elem = this[0];
  1753. if ( !arguments.length ) {
  1754. if ( elem ) {
  1755. hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
  1756. if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
  1757. return ret;
  1758. }
  1759. ret = elem.value;
  1760. return typeof ret === "string" ?
  1761. // handle most common string cases
  1762. ret.replace(rreturn, "") :
  1763. // handle cases where value is null/undef or number
  1764. ret == null ? "" : ret;
  1765. }
  1766. return undefined;
  1767. }
  1768. var isFunction = jQuery.isFunction( value );
  1769. return this.each(function( i ) {
  1770. var self = jQuery(this), val;
  1771. if ( this.nodeType !== 1 ) {
  1772. return;
  1773. }
  1774. if ( isFunction ) {
  1775. val = value.call( this, i, self.val() );
  1776. } else {
  1777. val = value;
  1778. }
  1779. // Treat null/undefined as ""; convert numbers to string
  1780. if ( val == null ) {
  1781. val = "";
  1782. } else if ( typeof val === "number" ) {
  1783. val += "";
  1784. } else if ( jQuery.isArray( val ) ) {
  1785. val = jQuery.map(val, function ( value ) {
  1786. return value == null ? "" : value + "";
  1787. });
  1788. }
  1789. hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
  1790. // If set returns undefined, fall back to normal setting
  1791. if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
  1792. this.value = val;
  1793. }
  1794. });
  1795. }
  1796. });
  1797. jQuery.extend({
  1798. valHooks: {
  1799. option: {
  1800. get: function( elem ) {
  1801. // attributes.value is undefined in Blackberry 4.7 but
  1802. // uses .value. See #6932
  1803. var val = elem.attributes.value;
  1804. return !val || val.specified ? elem.value : elem.text;
  1805. }
  1806. },
  1807. select: {
  1808. get: function( elem ) {
  1809. var value,
  1810. index = elem.selectedIndex,
  1811. values = [],
  1812. options = elem.options,
  1813. one = elem.type === "select-one";
  1814. // Nothing was selected
  1815. if ( index < 0 ) {
  1816. return null;
  1817. }
  1818. // Loop through all the selected options
  1819. for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
  1820. var option = options[ i ];
  1821. // Don't return options that are disabled or in a disabled optgroup
  1822. if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
  1823. (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
  1824. // Get the specific value for the option
  1825. value = jQuery( option ).val();
  1826. // We don't need an array for one selects
  1827. if ( one ) {
  1828. return value;
  1829. }
  1830. // Multi-Selects return an array
  1831. values.push( value );
  1832. }
  1833. }
  1834. // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
  1835. if ( one && !values.length && options.length ) {
  1836. return jQuery( options[ index ] ).val();
  1837. }
  1838. return values;
  1839. },
  1840. set: function( elem, value ) {
  1841. var values = jQuery.makeArray( value );
  1842. jQuery(elem).find("option").each(function() {
  1843. this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
  1844. });
  1845. if ( !values.length ) {
  1846. elem.selectedIndex = -1;
  1847. }
  1848. return values;
  1849. }
  1850. }
  1851. },
  1852. attrFn: {
  1853. val: true,
  1854. css: true,
  1855. html: true,
  1856. text: true,
  1857. data: true,
  1858. width: true,
  1859. height: true,
  1860. offset: true
  1861. },
  1862. attrFix: {
  1863. // Always normalize to ensure hook usage
  1864. tabindex: "tabIndex"
  1865. },
  1866. attr: function( elem, name, value, pass ) {
  1867. var nType = elem.nodeType;
  1868. // don't get/set attributes on text, comment and attribute nodes
  1869. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  1870. return undefined;
  1871. }
  1872. if ( pass && name in jQuery.attrFn ) {
  1873. return jQuery( elem )[ name ]( value );
  1874. }
  1875. // Fallback to prop when attributes are not supported
  1876. if ( !("getAttribute" in elem) ) {
  1877. return jQuery.prop( elem, name, value );
  1878. }
  1879. var ret, hooks,
  1880. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  1881. // Normalize the name if needed
  1882. if ( notxml ) {
  1883. name = jQuery.attrFix[ name ] || name;
  1884. hooks = jQuery.attrHooks[ name ];
  1885. if ( !hooks ) {
  1886. // Use boolHook for boolean attributes
  1887. if ( rboolean.test( name ) ) {
  1888. hooks = boolHook;
  1889. // Use nodeHook if available( IE6/7 )
  1890. } else if ( nodeHook ) {
  1891. hooks = nodeHook;
  1892. }
  1893. }
  1894. }
  1895. if ( value !== undefined ) {
  1896. if ( value === null ) {
  1897. jQuery.removeAttr( elem, name );
  1898. return undefined;
  1899. } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
  1900. return ret;
  1901. } else {
  1902. elem.setAttribute( name, "" + value );
  1903. return value;
  1904. }
  1905. } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
  1906. return ret;
  1907. } else {
  1908. ret = elem.getAttribute( name );
  1909. // Non-existent attributes return null, we normalize to undefined
  1910. return ret === null ?
  1911. undefined :
  1912. ret;
  1913. }
  1914. },
  1915. removeAttr: function( elem, name ) {
  1916. var propName;
  1917. if ( elem.nodeType === 1 ) {
  1918. name = jQuery.attrFix[ name ] || name;
  1919. jQuery.attr( elem, name, "" );
  1920. elem.removeAttribute( name );
  1921. // Set corresponding property to false for boolean attributes
  1922. if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) {
  1923. elem[ propName ] = false;
  1924. }
  1925. }
  1926. },
  1927. attrHooks: {
  1928. type: {
  1929. set: function( elem, value ) {
  1930. // We can't allow the type property to be changed (since it causes problems in IE)
  1931. if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
  1932. jQuery.error( "type property can't be changed" );
  1933. } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
  1934. // Setting the type on a radio button after the value resets the value in IE6-9
  1935. // Reset value to it's default in case type is set after value
  1936. // This is for element creation
  1937. var val = elem.value;
  1938. elem.setAttribute( "type", value );
  1939. if ( val ) {
  1940. elem.value = val;
  1941. }
  1942. return value;
  1943. }
  1944. }
  1945. },
  1946. // Use the value property for back compat
  1947. // Use the nodeHook for button elements in IE6/7 (#1954)
  1948. value: {
  1949. get: function( elem, name ) {
  1950. if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
  1951. return nodeHook.get( elem, name );
  1952. }
  1953. return name in elem ?
  1954. elem.value :
  1955. null;
  1956. },
  1957. set: function( elem, value, name ) {
  1958. if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
  1959. return nodeHook.set( elem, value, name );
  1960. }
  1961. // Does not return so that setAttribute is also used
  1962. elem.value = value;
  1963. }
  1964. }
  1965. },
  1966. propFix: {
  1967. tabindex: "tabIndex",
  1968. readonly: "readOnly",
  1969. "for": "htmlFor",
  1970. "class": "className",
  1971. maxlength: "maxLength",
  1972. cellspacing: "cellSpacing",
  1973. cellpadding: "cellPadding",
  1974. rowspan: "rowSpan",
  1975. colspan: "colSpan",
  1976. usemap: "useMap",
  1977. frameborder: "frameBorder",
  1978. contenteditable: "contentEditable"
  1979. },
  1980. prop: function( elem, name, value ) {
  1981. var nType = elem.nodeType;
  1982. // don't get/set properties on text, comment and attribute nodes
  1983. if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
  1984. return undefined;
  1985. }
  1986. var ret, hooks,
  1987. notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
  1988. if ( notxml ) {
  1989. // Fix name and attach hooks
  1990. name = jQuery.propFix[ name ] || name;
  1991. hooks = jQuery.propHooks[ name ];
  1992. }
  1993. if ( value !== undefined ) {
  1994. if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
  1995. return ret;
  1996. } else {
  1997. return (elem[ name ] = value);
  1998. }
  1999. } else {
  2000. if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
  2001. return ret;
  2002. } else {
  2003. return elem[ name ];
  2004. }
  2005. }
  2006. },
  2007. propHooks: {
  2008. tabIndex: {
  2009. get: function( elem ) {
  2010. // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
  2011. // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  2012. var attributeNode = elem.getAttributeNode("tabindex");
  2013. return attributeNode && attributeNode.specified ?
  2014. parseInt( attributeNode.value, 10 ) :
  2015. rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
  2016. 0 :
  2017. undefined;
  2018. }
  2019. }
  2020. }
  2021. });
  2022. // Add the tabindex propHook to attrHooks for back-compat
  2023. jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex;
  2024. // Hook for boolean attributes
  2025. boolHook = {
  2026. get: function( elem, name ) {
  2027. // Align boolean attributes with corresponding properties
  2028. // Fall back to attribute presence where some booleans are not supported
  2029. var attrNode;
  2030. return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ?
  2031. name.toLowerCase() :
  2032. undefined;
  2033. },
  2034. set: function( elem, value, name ) {
  2035. var propName;
  2036. if ( value === false ) {
  2037. // Remove boolean attributes when set to false
  2038. jQuery.removeAttr( elem, name );
  2039. } else {
  2040. // value is true since we know at this point it's type boolean and not false
  2041. // Set boolean attributes to the same name and set the DOM property
  2042. propName = jQuery.propFix[ name ] || name;
  2043. if ( propName in elem ) {
  2044. // Only set the IDL specifically if it already exists on the element
  2045. elem[ propName ] = true;
  2046. }
  2047. elem.setAttribute( name, name.toLowerCase() );
  2048. }
  2049. return name;
  2050. }
  2051. };
  2052. // IE6/7 do not support getting/setting some attributes with get/setAttribute
  2053. if ( !jQuery.support.getSetAttribute ) {
  2054. // Use this for any attribute in IE6/7
  2055. // This fixes almost every IE6/7 issue
  2056. nodeHook = jQuery.valHooks.button = {
  2057. get: function( elem, name ) {
  2058. var ret;
  2059. ret = elem.getAttributeNode( name );
  2060. // Return undefined if nodeValue is empty string
  2061. return ret && ret.nodeValue !== "" ?
  2062. ret.nodeValue :
  2063. undefined;
  2064. },
  2065. set: function( elem, value, name ) {
  2066. // Set the existing or create a new attribute node
  2067. var ret = elem.getAttributeNode( name );
  2068. if ( !ret ) {
  2069. ret = document.createAttribute( name );
  2070. elem.setAttributeNode( ret );
  2071. }
  2072. return (ret.nodeValue = value + "");
  2073. }
  2074. };
  2075. // Set width and height to auto instead of 0 on empty string( Bug #8150 )
  2076. // This is for removals
  2077. jQuery.each([ "width", "height" ], function( i, name ) {
  2078. jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
  2079. set: function( elem, value ) {
  2080. if ( value === "" ) {
  2081. elem.setAttribute( name, "auto" );
  2082. return value;
  2083. }
  2084. }
  2085. });
  2086. });
  2087. }
  2088. // Some attributes require a special call on IE
  2089. if ( !jQuery.support.hrefNormalized ) {
  2090. jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
  2091. jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
  2092. get: function( elem ) {
  2093. var ret = elem.getAttribute( name, 2 );
  2094. return ret === null ? undefined : ret;
  2095. }
  2096. });
  2097. });
  2098. }
  2099. if ( !jQuery.support.style ) {
  2100. jQuery.attrHooks.style = {
  2101. get: function( elem ) {
  2102. // Return undefined in the case of empty string
  2103. // Normalize to lowercase since IE uppercases css property names
  2104. return elem.style.cssText.toLowerCase() || undefined;
  2105. },
  2106. set: function( elem, value ) {
  2107. return (elem.style.cssText = "" + value);
  2108. }
  2109. };
  2110. }
  2111. // Safari mis-reports the default selected property of an option
  2112. // Accessing the parent's selectedIndex property fixes it
  2113. if ( !jQuery.support.optSelected ) {
  2114. jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
  2115. get: function( elem ) {
  2116. var parent = elem.parentNode;
  2117. if ( parent ) {
  2118. parent.selectedIndex;
  2119. // Make sure that it also works with optgroups, see #5701
  2120. if ( parent.parentNode ) {
  2121. parent.parentNode.selectedIndex;
  2122. }
  2123. }
  2124. return null;
  2125. }
  2126. });
  2127. }
  2128. // Radios and checkboxes getter/setter
  2129. if ( !jQuery.support.checkOn ) {
  2130. jQuery.each([ "radio", "checkbox" ], function() {
  2131. jQuery.valHooks[ this ] = {
  2132. get: function( elem ) {
  2133. // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
  2134. return elem.getAttribute("value") === null ? "on" : elem.value;
  2135. }
  2136. };
  2137. });
  2138. }
  2139. jQuery.each([ "radio", "checkbox" ], function() {
  2140. jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
  2141. set: function( elem, value ) {
  2142. if ( jQuery.isArray( value ) ) {
  2143. return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0);
  2144. }
  2145. }
  2146. });
  2147. });
  2148. var rnamespaces = /\.(.*)$/,
  2149. rformElems = /^(?:textarea|input|select)$/i,
  2150. rperiod = /\./g,
  2151. rspaces = / /g,
  2152. rescape = /[^\w\s.|`]/g,
  2153. fcleanup = function( nm ) {
  2154. return nm.replace(rescape, "\\$&");
  2155. };
  2156. /*
  2157. * A number of helper functions used for managing events.
  2158. * Many of the ideas behind this code originated from
  2159. * Dean Edwards' addEvent library.
  2160. */
  2161. jQuery.event = {
  2162. // Bind an event to an element
  2163. // Original by Dean Edwards
  2164. add: function( elem, types, handler, data ) {
  2165. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  2166. return;
  2167. }
  2168. if ( handler === false ) {
  2169. handler = returnFalse;
  2170. } else if ( !handler ) {
  2171. // Fixes bug #7229. Fix recommended by jdalton
  2172. return;
  2173. }
  2174. var handleObjIn, handleObj;
  2175. if ( handler.handler ) {
  2176. handleObjIn = handler;
  2177. handler = handleObjIn.handler;
  2178. }
  2179. // Make sure that the function being executed has a unique ID
  2180. if ( !handler.guid ) {
  2181. handler.guid = jQuery.guid++;
  2182. }
  2183. // Init the element's event structure
  2184. var elemData = jQuery._data( elem );
  2185. // If no elemData is found then we must be trying to bind to one of the
  2186. // banned noData elements
  2187. if ( !elemData ) {
  2188. return;
  2189. }
  2190. var events = elemData.events,
  2191. eventHandle = elemData.handle;
  2192. if ( !events ) {
  2193. elemData.events = events = {};
  2194. }
  2195. if ( !eventHandle ) {
  2196. elemData.handle = eventHandle = function( e ) {
  2197. // Discard the second event of a jQuery.event.trigger() and
  2198. // when an event is called after a page has unloaded
  2199. return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
  2200. jQuery.event.handle.apply( eventHandle.elem, arguments ) :
  2201. undefined;
  2202. };
  2203. }
  2204. // Add elem as a property of the handle function
  2205. // This is to prevent a memory leak with non-native events in IE.
  2206. eventHandle.elem = elem;
  2207. // Handle multiple events separated by a space
  2208. // jQuery(...).bind("mouseover mouseout", fn);
  2209. types = types.split(" ");
  2210. var type, i = 0, namespaces;
  2211. while ( (type = types[ i++ ]) ) {
  2212. handleObj = handleObjIn ?
  2213. jQuery.extend({}, handleObjIn) :
  2214. { handler: handler, data: data };
  2215. // Namespaced event handlers
  2216. if ( type.indexOf(".") > -1 ) {
  2217. namespaces = type.split(".");
  2218. type = namespaces.shift();
  2219. handleObj.namespace = namespaces.slice(0).sort().join(".");
  2220. } else {
  2221. namespaces = [];
  2222. handleObj.namespace = "";
  2223. }
  2224. handleObj.type = type;
  2225. if ( !handleObj.guid ) {
  2226. handleObj.guid = handler.guid;
  2227. }
  2228. // Get the current list of functions bound to this event
  2229. var handlers = events[ type ],
  2230. special = jQuery.event.special[ type ] || {};
  2231. // Init the event handler queue
  2232. if ( !handlers ) {
  2233. handlers = events[ type ] = [];
  2234. // Check for a special event handler
  2235. // Only use addEventListener/attachEvent if the special
  2236. // events handler returns false
  2237. if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  2238. // Bind the global event handler to the element
  2239. if ( elem.addEventListener ) {
  2240. elem.addEventListener( type, eventHandle, false );
  2241. } else if ( elem.attachEvent ) {
  2242. elem.attachEvent( "on" + type, eventHandle );
  2243. }
  2244. }
  2245. }
  2246. if ( special.add ) {
  2247. special.add.call( elem, handleObj );
  2248. if ( !handleObj.handler.guid ) {
  2249. handleObj.handler.guid = handler.guid;
  2250. }
  2251. }
  2252. // Add the function to the element's handler list
  2253. handlers.push( handleObj );
  2254. // Keep track of which events have been used, for event optimization
  2255. jQuery.event.global[ type ] = true;
  2256. }
  2257. // Nullify elem to prevent memory leaks in IE
  2258. elem = null;
  2259. },
  2260. global: {},
  2261. // Detach an event or set of events from an element
  2262. remove: function( elem, types, handler, pos ) {
  2263. // don't do events on text and comment nodes
  2264. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  2265. return;
  2266. }
  2267. if ( handler === false ) {
  2268. handler = returnFalse;
  2269. }
  2270. var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
  2271. elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
  2272. events = elemData && elemData.events;
  2273. if ( !elemData || !events ) {
  2274. return;
  2275. }
  2276. // types is actually an event object here
  2277. if ( types && types.type ) {
  2278. handler = types.handler;
  2279. types = types.type;
  2280. }
  2281. // Unbind all events for the element
  2282. if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
  2283. types = types || "";
  2284. for ( type in events ) {
  2285. jQuery.event.remove( elem, type + types );
  2286. }
  2287. return;
  2288. }
  2289. // Handle multiple events separated by a space
  2290. // jQuery(...).unbind("mouseover mouseout", fn);
  2291. types = types.split(" ");
  2292. while ( (type = types[ i++ ]) ) {
  2293. origType = type;
  2294. handleObj = null;
  2295. all = type.indexOf(".") < 0;
  2296. namespaces = [];
  2297. if ( !all ) {
  2298. // Namespaced event handlers
  2299. namespaces = type.split(".");
  2300. type = namespaces.shift();
  2301. namespace = new RegExp("(^|\\.)" +
  2302. jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
  2303. }
  2304. eventType = events[ type ];
  2305. if ( !eventType ) {
  2306. continue;
  2307. }
  2308. if ( !handler ) {
  2309. for ( j = 0; j < eventType.length; j++ ) {
  2310. handleObj = eventType[ j ];
  2311. if ( all || namespace.test( handleObj.namespace ) ) {
  2312. jQuery.event.remove( elem, origType, handleObj.handler, j );
  2313. eventType.splice( j--, 1 );
  2314. }
  2315. }
  2316. continue;
  2317. }
  2318. special = jQuery.event.special[ type ] || {};
  2319. for ( j = pos || 0; j < eventType.length; j++ ) {
  2320. handleObj = eventType[ j ];
  2321. if ( handler.guid === handleObj.guid ) {
  2322. // remove the given handler for the given type
  2323. if ( all || namespace.test( handleObj.namespace ) ) {
  2324. if ( pos == null ) {
  2325. eventType.splice( j--, 1 );
  2326. }
  2327. if ( special.remove ) {
  2328. special.remove.call( elem, handleObj );
  2329. }
  2330. }
  2331. if ( pos != null ) {
  2332. break;
  2333. }
  2334. }
  2335. }
  2336. // remove generic event handler if no more handlers exist
  2337. if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
  2338. if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
  2339. jQuery.removeEvent( elem, type, elemData.handle );
  2340. }
  2341. ret = null;
  2342. delete events[ type ];
  2343. }
  2344. }
  2345. // Remove the expando if it's no longer used
  2346. if ( jQuery.isEmptyObject( events ) ) {
  2347. var handle = elemData.handle;
  2348. if ( handle ) {
  2349. handle.elem = null;
  2350. }
  2351. delete elemData.events;
  2352. delete elemData.handle;
  2353. if ( jQuery.isEmptyObject( elemData ) ) {
  2354. jQuery.removeData( elem, undefined, true );
  2355. }
  2356. }
  2357. },
  2358. // Events that are safe to short-circuit if no handlers are attached.
  2359. // Native DOM events should not be added, they may have inline handlers.
  2360. customEvent: {
  2361. "getData": true,
  2362. "setData": true,
  2363. "changeData": true
  2364. },
  2365. trigger: function( event, data, elem, onlyHandlers ) {
  2366. // Event object or event type
  2367. var type = event.type || event,
  2368. namespaces = [],
  2369. exclusive;
  2370. if ( type.indexOf("!") >= 0 ) {
  2371. // Exclusive events trigger only for the exact event (no namespaces)
  2372. type = type.slice(0, -1);
  2373. exclusive = true;
  2374. }
  2375. if ( type.indexOf(".") >= 0 ) {
  2376. // Namespaced trigger; create a regexp to match event type in handle()
  2377. namespaces = type.split(".");
  2378. type = namespaces.shift();
  2379. namespaces.sort();
  2380. }
  2381. if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) {
  2382. // No jQuery handlers for this event type, and it can't have inline handlers
  2383. return;
  2384. }
  2385. // Caller can pass in an Event, Object, or just an event type string
  2386. event = typeof event === "object" ?
  2387. // jQuery.Event object
  2388. event[ jQuery.expando ] ? event :
  2389. // Object literal
  2390. new jQuery.Event( type, event ) :
  2391. // Just the event type (string)
  2392. new jQuery.Event( type );
  2393. event.type = type;
  2394. event.exclusive = exclusive;
  2395. event.namespace = namespaces.join(".");
  2396. event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)");
  2397. // triggerHandler() and global events don't bubble or run the default action
  2398. if ( onlyHandlers || !elem ) {
  2399. event.preventDefault();
  2400. event.stopPropagation();
  2401. }
  2402. // Handle a global trigger
  2403. if ( !elem ) {
  2404. // TODO: Stop taunting the data cache; remove global events and always attach to document
  2405. jQuery.each( jQuery.cache, function() {
  2406. // internalKey variable is just used to make it easier to find
  2407. // and potentially change this stuff later; currently it just
  2408. // points to jQuery.expando
  2409. var internalKey = jQuery.expando,
  2410. internalCache = this[ internalKey ];
  2411. if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
  2412. jQuery.event.trigger( event, data, internalCache.handle.elem );
  2413. }
  2414. });
  2415. return;
  2416. }
  2417. // Don't do events on text and comment nodes
  2418. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  2419. return;
  2420. }
  2421. // Clean up the event in case it is being reused
  2422. event.result = undefined;
  2423. event.target = elem;
  2424. // Clone any incoming data and prepend the event, creating the handler arg list
  2425. data = data != null ? jQuery.makeArray( data ) : [];
  2426. data.unshift( event );
  2427. var cur = elem,
  2428. // IE doesn't like method names with a colon (#3533, #8272)
  2429. ontype = type.indexOf(":") < 0 ? "on" + type : "";
  2430. // Fire event on the current element, then bubble up the DOM tree
  2431. do {
  2432. var handle = jQuery._data( cur, "handle" );
  2433. event.currentTarget = cur;
  2434. if ( handle ) {
  2435. handle.apply( cur, data );
  2436. }
  2437. // Trigger an inline bound script
  2438. if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) {
  2439. event.result = false;
  2440. event.preventDefault();
  2441. }
  2442. // Bubble up to document, then to window
  2443. cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window;
  2444. } while ( cur && !event.isPropagationStopped() );
  2445. // If nobody prevented the default action, do it now
  2446. if ( !event.isDefaultPrevented() ) {
  2447. var old,
  2448. special = jQuery.event.special[ type ] || {};
  2449. if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) &&
  2450. !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) {
  2451. // Call a native DOM method on the target with the same name name as the event.
  2452. // Can't use an .isFunction)() check here because IE6/7 fails that test.
  2453. // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch.
  2454. try {
  2455. if ( ontype && elem[ type ] ) {
  2456. // Don't re-trigger an onFOO event when we call its FOO() method
  2457. old = elem[ ontype ];
  2458. if ( old ) {
  2459. elem[ ontype ] = null;
  2460. }
  2461. jQuery.event.triggered = type;
  2462. elem[ type ]();
  2463. }
  2464. } catch ( ieError ) {}
  2465. if ( old ) {
  2466. elem[ ontype ] = old;
  2467. }
  2468. jQuery.event.triggered = undefined;
  2469. }
  2470. }
  2471. return event.result;
  2472. },
  2473. handle: function( event ) {
  2474. event = jQuery.event.fix( event || window.event );
  2475. // Snapshot the handlers list since a called handler may add/remove events.
  2476. var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0),
  2477. run_all = !event.exclusive && !event.namespace,
  2478. args = Array.prototype.slice.call( arguments, 0 );
  2479. // Use the fix-ed Event rather than the (read-only) native event
  2480. args[0] = event;
  2481. event.currentTarget = this;
  2482. for ( var j = 0, l = handlers.length; j < l; j++ ) {
  2483. var handleObj = handlers[ j ];
  2484. // Triggered event must 1) be non-exclusive and have no namespace, or
  2485. // 2) have namespace(s) a subset or equal to those in the bound event.
  2486. if ( run_all || event.namespace_re.test( handleObj.namespace ) ) {
  2487. // Pass in a reference to the handler function itself
  2488. // So that we can later remove it
  2489. event.handler = handleObj.handler;
  2490. event.data = handleObj.data;
  2491. event.handleObj = handleObj;
  2492. var ret = handleObj.handler.apply( this, args );
  2493. if ( ret !== undefined ) {
  2494. event.result = ret;
  2495. if ( ret === false ) {
  2496. event.preventDefault();
  2497. event.stopPropagation();
  2498. }
  2499. }
  2500. if ( event.isImmediatePropagationStopped() ) {
  2501. break;
  2502. }
  2503. }
  2504. }
  2505. return event.result;
  2506. },
  2507. props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
  2508. fix: function( event ) {
  2509. if ( event[ jQuery.expando ] ) {
  2510. return event;
  2511. }
  2512. // store a copy of the original event object
  2513. // and "clone" to set read-only properties
  2514. var originalEvent = event;
  2515. event = jQuery.Event( originalEvent );
  2516. for ( var i = this.props.length, prop; i; ) {
  2517. prop = this.props[ --i ];
  2518. event[ prop ] = originalEvent[ prop ];
  2519. }
  2520. // Fix target property, if necessary
  2521. if ( !event.target ) {
  2522. // Fixes #1925 where srcElement might not be defined either
  2523. event.target = event.srcElement || document;
  2524. }
  2525. // check if target is a textnode (safari)
  2526. if ( event.target.nodeType === 3 ) {
  2527. event.target = event.target.parentNode;
  2528. }
  2529. // Add relatedTarget, if necessary
  2530. if ( !event.relatedTarget && event.fromElement ) {
  2531. event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
  2532. }
  2533. // Calculate pageX/Y if missing and clientX/Y available
  2534. if ( event.pageX == null && event.clientX != null ) {
  2535. var eventDocument = event.target.ownerDocument || document,
  2536. doc = eventDocument.documentElement,
  2537. body = eventDocument.body;
  2538. event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  2539. event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  2540. }
  2541. // Add which for key events
  2542. if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
  2543. event.which = event.charCode != null ? event.charCode : event.keyCode;
  2544. }
  2545. // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
  2546. if ( !event.metaKey && event.ctrlKey ) {
  2547. event.metaKey = event.ctrlKey;
  2548. }
  2549. // Add which for click: 1 === left; 2 === middle; 3 === right
  2550. // Note: button is not normalized, so don't use it
  2551. if ( !event.which && event.button !== undefined ) {
  2552. event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
  2553. }
  2554. return event;
  2555. },
  2556. // Deprecated, use jQuery.guid instead
  2557. guid: 1E8,
  2558. // Deprecated, use jQuery.proxy instead
  2559. proxy: jQuery.proxy,
  2560. special: {
  2561. ready: {
  2562. // Make sure the ready event is setup
  2563. setup: jQuery.bindReady,
  2564. teardown: jQuery.noop
  2565. },
  2566. live: {
  2567. add: function( handleObj ) {
  2568. jQuery.event.add( this,
  2569. liveConvert( handleObj.origType, handleObj.selector ),
  2570. jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
  2571. },
  2572. remove: function( handleObj ) {
  2573. jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
  2574. }
  2575. },
  2576. beforeunload: {
  2577. setup: function( data, namespaces, eventHandle ) {
  2578. // We only want to do this special case on windows
  2579. if ( jQuery.isWindow( this ) ) {
  2580. this.onbeforeunload = eventHandle;
  2581. }
  2582. },
  2583. teardown: function( namespaces, eventHandle ) {
  2584. if ( this.onbeforeunload === eventHandle ) {
  2585. this.onbeforeunload = null;
  2586. }
  2587. }
  2588. }
  2589. }
  2590. };
  2591. jQuery.removeEvent = document.removeEventListener ?
  2592. function( elem, type, handle ) {
  2593. if ( elem.removeEventListener ) {
  2594. elem.removeEventListener( type, handle, false );
  2595. }
  2596. } :
  2597. function( elem, type, handle ) {
  2598. if ( elem.detachEvent ) {
  2599. elem.detachEvent( "on" + type, handle );
  2600. }
  2601. };
  2602. jQuery.Event = function( src, props ) {
  2603. // Allow instantiation without the 'new' keyword
  2604. if ( !this.preventDefault ) {
  2605. return new jQuery.Event( src, props );
  2606. }
  2607. // Event object
  2608. if ( src && src.type ) {
  2609. this.originalEvent = src;
  2610. this.type = src.type;
  2611. // Events bubbling up the document may have been marked as prevented
  2612. // by a handler lower down the tree; reflect the correct value.
  2613. this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
  2614. src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
  2615. // Event type
  2616. } else {
  2617. this.type = src;
  2618. }
  2619. // Put explicitly provided properties onto the event object
  2620. if ( props ) {
  2621. jQuery.extend( this, props );
  2622. }
  2623. // timeStamp is buggy for some events on Firefox(#3843)
  2624. // So we won't rely on the native value
  2625. this.timeStamp = jQuery.now();
  2626. // Mark it as fixed
  2627. this[ jQuery.expando ] = true;
  2628. };
  2629. function returnFalse() {
  2630. return false;
  2631. }
  2632. function returnTrue() {
  2633. return true;
  2634. }
  2635. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  2636. // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  2637. jQuery.Event.prototype = {
  2638. preventDefault: function() {
  2639. this.isDefaultPrevented = returnTrue;
  2640. var e = this.originalEvent;
  2641. if ( !e ) {
  2642. return;
  2643. }
  2644. // if preventDefault exists run it on the original event
  2645. if ( e.preventDefault ) {
  2646. e.preventDefault();
  2647. // otherwise set the returnValue property of the original event to false (IE)
  2648. } else {
  2649. e.returnValue = false;
  2650. }
  2651. },
  2652. stopPropagation: function() {
  2653. this.isPropagationStopped = returnTrue;
  2654. var e = this.originalEvent;
  2655. if ( !e ) {
  2656. return;
  2657. }
  2658. // if stopPropagation exists run it on the original event
  2659. if ( e.stopPropagation ) {
  2660. e.stopPropagation();
  2661. }
  2662. // otherwise set the cancelBubble property of the original event to true (IE)
  2663. e.cancelBubble = true;
  2664. },
  2665. stopImmediatePropagation: function() {
  2666. this.isImmediatePropagationStopped = returnTrue;
  2667. this.stopPropagation();
  2668. },
  2669. isDefaultPrevented: returnFalse,
  2670. isPropagationStopped: returnFalse,
  2671. isImmediatePropagationStopped: returnFalse
  2672. };
  2673. // Checks if an event happened on an element within another element
  2674. // Used in jQuery.event.special.mouseenter and mouseleave handlers
  2675. var withinElement = function( event ) {
  2676. // Check if mouse(over|out) are still within the same parent element
  2677. var related = event.relatedTarget,
  2678. inside = false,
  2679. eventType = event.type;
  2680. event.type = event.data;
  2681. if ( related !== this ) {
  2682. if ( related ) {
  2683. inside = jQuery.contains( this, related );
  2684. }
  2685. if ( !inside ) {
  2686. jQuery.event.handle.apply( this, arguments );
  2687. event.type = eventType;
  2688. }
  2689. }
  2690. },
  2691. // In case of event delegation, we only need to rename the event.type,
  2692. // liveHandler will take care of the rest.
  2693. delegate = function( event ) {
  2694. event.type = event.data;
  2695. jQuery.event.handle.apply( this, arguments );
  2696. };
  2697. // Create mouseenter and mouseleave events
  2698. jQuery.each({
  2699. mouseenter: "mouseover",
  2700. mouseleave: "mouseout"
  2701. }, function( orig, fix ) {
  2702. jQuery.event.special[ orig ] = {
  2703. setup: function( data ) {
  2704. jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
  2705. },
  2706. teardown: function( data ) {
  2707. jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
  2708. }
  2709. };
  2710. });
  2711. // submit delegation
  2712. if ( !jQuery.support.submitBubbles ) {
  2713. jQuery.event.special.submit = {
  2714. setup: function( data, namespaces ) {
  2715. if ( !jQuery.nodeName( this, "form" ) ) {
  2716. jQuery.event.add(this, "click.specialSubmit", function( e ) {
  2717. var elem = e.target,
  2718. type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
  2719. if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
  2720. trigger( "submit", this, arguments );
  2721. }
  2722. });
  2723. jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
  2724. var elem = e.target,
  2725. type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
  2726. if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
  2727. trigger( "submit", this, arguments );
  2728. }
  2729. });
  2730. } else {
  2731. return false;
  2732. }
  2733. },
  2734. teardown: function( namespaces ) {
  2735. jQuery.event.remove( this, ".specialSubmit" );
  2736. }
  2737. };
  2738. }
  2739. // change delegation, happens here so we have bind.
  2740. if ( !jQuery.support.changeBubbles ) {
  2741. var changeFilters,
  2742. getVal = function( elem ) {
  2743. var type = jQuery.nodeName( elem, "input" ) ? elem.type : "",
  2744. val = elem.value;
  2745. if ( type === "radio" || type === "checkbox" ) {
  2746. val = elem.checked;
  2747. } else if ( type === "select-multiple" ) {
  2748. val = elem.selectedIndex > -1 ?
  2749. jQuery.map( elem.options, function( elem ) {
  2750. return elem.selected;
  2751. }).join("-") :
  2752. "";
  2753. } else if ( jQuery.nodeName( elem, "select" ) ) {
  2754. val = elem.selectedIndex;
  2755. }
  2756. return val;
  2757. },
  2758. testChange = function testChange( e ) {
  2759. var elem = e.target, data, val;
  2760. if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
  2761. return;
  2762. }
  2763. data = jQuery._data( elem, "_change_data" );
  2764. val = getVal(elem);
  2765. // the current data will be also retrieved by beforeactivate
  2766. if ( e.type !== "focusout" || elem.type !== "radio" ) {
  2767. jQuery._data( elem, "_change_data", val );
  2768. }
  2769. if ( data === undefined || val === data ) {
  2770. return;
  2771. }
  2772. if ( data != null || val ) {
  2773. e.type = "change";
  2774. e.liveFired = undefined;
  2775. jQuery.event.trigger( e, arguments[1], elem );
  2776. }
  2777. };
  2778. jQuery.event.special.change = {
  2779. filters: {
  2780. focusout: testChange,
  2781. beforedeactivate: testChange,
  2782. click: function( e ) {
  2783. var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
  2784. if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) {
  2785. testChange.call( this, e );
  2786. }
  2787. },
  2788. // Change has to be called before submit
  2789. // Keydown will be called before keypress, which is used in submit-event delegation
  2790. keydown: function( e ) {
  2791. var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : "";
  2792. if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) ||
  2793. (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
  2794. type === "select-multiple" ) {
  2795. testChange.call( this, e );
  2796. }
  2797. },
  2798. // Beforeactivate happens also before the previous element is blurred
  2799. // with this event you can't trigger a change event, but you can store
  2800. // information
  2801. beforeactivate: function( e ) {
  2802. var elem = e.target;
  2803. jQuery._data( elem, "_change_data", getVal(elem) );
  2804. }
  2805. },
  2806. setup: function( data, namespaces ) {
  2807. if ( this.type === "file" ) {
  2808. return false;
  2809. }
  2810. for ( var type in changeFilters ) {
  2811. jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
  2812. }
  2813. return rformElems.test( this.nodeName );
  2814. },
  2815. teardown: function( namespaces ) {
  2816. jQuery.event.remove( this, ".specialChange" );
  2817. return rformElems.test( this.nodeName );
  2818. }
  2819. };
  2820. changeFilters = jQuery.event.special.change.filters;
  2821. // Handle when the input is .focus()'d
  2822. changeFilters.focus = changeFilters.beforeactivate;
  2823. }
  2824. function trigger( type, elem, args ) {
  2825. // Piggyback on a donor event to simulate a different one.
  2826. // Fake originalEvent to avoid donor's stopPropagation, but if the
  2827. // simulated event prevents default then we do the same on the donor.
  2828. // Don't pass args or remember liveFired; they apply to the donor event.
  2829. var event = jQuery.extend( {}, args[ 0 ] );
  2830. event.type = type;
  2831. event.originalEvent = {};
  2832. event.liveFired = undefined;
  2833. jQuery.event.handle.call( elem, event );
  2834. if ( event.isDefaultPrevented() ) {
  2835. args[ 0 ].preventDefault();
  2836. }
  2837. }
  2838. // Create "bubbling" focus and blur events
  2839. if ( !jQuery.support.focusinBubbles ) {
  2840. jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  2841. // Attach a single capturing handler while someone wants focusin/focusout
  2842. var attaches = 0;
  2843. jQuery.event.special[ fix ] = {
  2844. setup: function() {
  2845. if ( attaches++ === 0 ) {
  2846. document.addEventListener( orig, handler, true );
  2847. }
  2848. },
  2849. teardown: function() {
  2850. if ( --attaches === 0 ) {
  2851. document.removeEventListener( orig, handler, true );
  2852. }
  2853. }
  2854. };
  2855. function handler( donor ) {
  2856. // Donor event is always a native one; fix it and switch its type.
  2857. // Let focusin/out handler cancel the donor focus/blur event.
  2858. var e = jQuery.event.fix( donor );
  2859. e.type = fix;
  2860. e.originalEvent = {};
  2861. jQuery.event.trigger( e, null, e.target );
  2862. if ( e.isDefaultPrevented() ) {
  2863. donor.preventDefault();
  2864. }
  2865. }
  2866. });
  2867. }
  2868. jQuery.each(["bind", "one"], function( i, name ) {
  2869. jQuery.fn[ name ] = function( type, data, fn ) {
  2870. var handler;
  2871. // Handle object literals
  2872. if ( typeof type === "object" ) {
  2873. for ( var key in type ) {
  2874. this[ name ](key, data, type[key], fn);
  2875. }
  2876. return this;
  2877. }
  2878. if ( arguments.length === 2 || data === false ) {
  2879. fn = data;
  2880. data = undefined;
  2881. }
  2882. if ( name === "one" ) {
  2883. handler = function( event ) {
  2884. jQuery( this ).unbind( event, handler );
  2885. return fn.apply( this, arguments );
  2886. };
  2887. handler.guid = fn.guid || jQuery.guid++;
  2888. } else {
  2889. handler = fn;
  2890. }
  2891. if ( type === "unload" && name !== "one" ) {
  2892. this.one( type, data, fn );
  2893. } else {
  2894. for ( var i = 0, l = this.length; i < l; i++ ) {
  2895. jQuery.event.add( this[i], type, handler, data );
  2896. }
  2897. }
  2898. return this;
  2899. };
  2900. });
  2901. jQuery.fn.extend({
  2902. unbind: function( type, fn ) {
  2903. // Handle object literals
  2904. if ( typeof type === "object" && !type.preventDefault ) {
  2905. for ( var key in type ) {
  2906. this.unbind(key, type[key]);
  2907. }
  2908. } else {
  2909. for ( var i = 0, l = this.length; i < l; i++ ) {
  2910. jQuery.event.remove( this[i], type, fn );
  2911. }
  2912. }
  2913. return this;
  2914. },
  2915. delegate: function( selector, types, data, fn ) {
  2916. return this.live( types, data, fn, selector );
  2917. },
  2918. undelegate: function( selector, types, fn ) {
  2919. if ( arguments.length === 0 ) {
  2920. return this.unbind( "live" );
  2921. } else {
  2922. return this.die( types, null, fn, selector );
  2923. }
  2924. },
  2925. trigger: function( type, data ) {
  2926. return this.each(function() {
  2927. jQuery.event.trigger( type, data, this );
  2928. });
  2929. },
  2930. triggerHandler: function( type, data ) {
  2931. if ( this[0] ) {
  2932. return jQuery.event.trigger( type, data, this[0], true );
  2933. }
  2934. },
  2935. toggle: function( fn ) {
  2936. // Save reference to arguments for access in closure
  2937. var args = arguments,
  2938. guid = fn.guid || jQuery.guid++,
  2939. i = 0,
  2940. toggler = function( event ) {
  2941. // Figure out which function to execute
  2942. var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
  2943. jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
  2944. // Make sure that clicks stop
  2945. event.preventDefault();
  2946. // and execute the function
  2947. return args[ lastToggle ].apply( this, arguments ) || false;
  2948. };
  2949. // link all the functions, so any of them can unbind this click handler
  2950. toggler.guid = guid;
  2951. while ( i < args.length ) {
  2952. args[ i++ ].guid = guid;
  2953. }
  2954. return this.click( toggler );
  2955. },
  2956. hover: function( fnOver, fnOut ) {
  2957. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  2958. }
  2959. });
  2960. var liveMap = {
  2961. focus: "focusin",
  2962. blur: "focusout",
  2963. mouseenter: "mouseover",
  2964. mouseleave: "mouseout"
  2965. };
  2966. jQuery.each(["live", "die"], function( i, name ) {
  2967. jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
  2968. var type, i = 0, match, namespaces, preType,
  2969. selector = origSelector || this.selector,
  2970. context = origSelector ? this : jQuery( this.context );
  2971. if ( typeof types === "object" && !types.preventDefault ) {
  2972. for ( var key in types ) {
  2973. context[ name ]( key, data, types[key], selector );
  2974. }
  2975. return this;
  2976. }
  2977. if ( name === "die" && !types &&
  2978. origSelector && origSelector.charAt(0) === "." ) {
  2979. context.unbind( origSelector );
  2980. return this;
  2981. }
  2982. if ( data === false || jQuery.isFunction( data ) ) {
  2983. fn = data || returnFalse;
  2984. data = undefined;
  2985. }
  2986. types = (types || "").split(" ");
  2987. while ( (type = types[ i++ ]) != null ) {
  2988. match = rnamespaces.exec( type );
  2989. namespaces = "";
  2990. if ( match ) {
  2991. namespaces = match[0];
  2992. type = type.replace( rnamespaces, "" );
  2993. }
  2994. if ( type === "hover" ) {
  2995. types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
  2996. continue;
  2997. }
  2998. preType = type;
  2999. if ( liveMap[ type ] ) {
  3000. types.push( liveMap[ type ] + namespaces );
  3001. type = type + namespaces;
  3002. } else {
  3003. type = (liveMap[ type ] || type) + namespaces;
  3004. }
  3005. if ( name === "live" ) {
  3006. // bind live handler
  3007. for ( var j = 0, l = context.length; j < l; j++ ) {
  3008. jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
  3009. { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
  3010. }
  3011. } else {
  3012. // unbind live handler
  3013. context.unbind( "live." + liveConvert( type, selector ), fn );
  3014. }
  3015. }
  3016. return this;
  3017. };
  3018. });
  3019. function liveHandler( event ) {
  3020. var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
  3021. elems = [],
  3022. selectors = [],
  3023. events = jQuery._data( this, "events" );
  3024. // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
  3025. if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
  3026. return;
  3027. }
  3028. if ( event.namespace ) {
  3029. namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
  3030. }
  3031. event.liveFired = this;
  3032. var live = events.live.slice(0);
  3033. for ( j = 0; j < live.length; j++ ) {
  3034. handleObj = live[j];
  3035. if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
  3036. selectors.push( handleObj.selector );
  3037. } else {
  3038. live.splice( j--, 1 );
  3039. }
  3040. }
  3041. match = jQuery( event.target ).closest( selectors, event.currentTarget );
  3042. for ( i = 0, l = match.length; i < l; i++ ) {
  3043. close = match[i];
  3044. for ( j = 0; j < live.length; j++ ) {
  3045. handleObj = live[j];
  3046. if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
  3047. elem = close.elem;
  3048. related = null;
  3049. // Those two events require additional checking
  3050. if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
  3051. event.type = handleObj.preType;
  3052. related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
  3053. // Make sure not to accidentally match a child element with the same selector
  3054. if ( related && jQuery.contains( elem, related ) ) {
  3055. related = elem;
  3056. }
  3057. }
  3058. if ( !related || related !== elem ) {
  3059. elems.push({ elem: elem, handleObj: handleObj, level: close.level });
  3060. }
  3061. }
  3062. }
  3063. }
  3064. for ( i = 0, l = elems.length; i < l; i++ ) {
  3065. match = elems[i];
  3066. if ( maxLevel && match.level > maxLevel ) {
  3067. break;
  3068. }
  3069. event.currentTarget = match.elem;
  3070. event.data = match.handleObj.data;
  3071. event.handleObj = match.handleObj;
  3072. ret = match.handleObj.origHandler.apply( match.elem, arguments );
  3073. if ( ret === false || event.isPropagationStopped() ) {
  3074. maxLevel = match.level;
  3075. if ( ret === false ) {
  3076. stop = false;
  3077. }
  3078. if ( event.isImmediatePropagationStopped() ) {
  3079. break;
  3080. }
  3081. }
  3082. }
  3083. return stop;
  3084. }
  3085. function liveConvert( type, selector ) {
  3086. return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&");
  3087. }
  3088. jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
  3089. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  3090. "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
  3091. // Handle event binding
  3092. jQuery.fn[ name ] = function( data, fn ) {
  3093. if ( fn == null ) {
  3094. fn = data;
  3095. data = null;
  3096. }
  3097. return arguments.length > 0 ?
  3098. this.bind( name, data, fn ) :
  3099. this.trigger( name );
  3100. };
  3101. if ( jQuery.attrFn ) {
  3102. jQuery.attrFn[ name ] = true;
  3103. }
  3104. });
  3105. /*!
  3106. * Sizzle CSS Selector Engine
  3107. * Copyright 2011, The Dojo Foundation
  3108. * Released under the MIT, BSD, and GPL Licenses.
  3109. * More information: http://sizzlejs.com/
  3110. */
  3111. (function(){
  3112. var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
  3113. done = 0,
  3114. toString = Object.prototype.toString,
  3115. hasDuplicate = false,
  3116. baseHasDuplicate = true,
  3117. rBackslash = /\\/g,
  3118. rNonWord = /\W/;
  3119. // Here we check if the JavaScript engine is using some sort of
  3120. // optimization where it does not always call our comparision
  3121. // function. If that is the case, discard the hasDuplicate value.
  3122. // Thus far that includes Google Chrome.
  3123. [0, 0].sort(function() {
  3124. baseHasDuplicate = false;
  3125. return 0;
  3126. });
  3127. var Sizzle = function( selector, context, results, seed ) {
  3128. results = results || [];
  3129. context = context || document;
  3130. var origContext = context;
  3131. if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
  3132. return [];
  3133. }
  3134. if ( !selector || typeof selector !== "string" ) {
  3135. return results;
  3136. }
  3137. var m, set, checkSet, extra, ret, cur, pop, i,
  3138. prune = true,
  3139. contextXML = Sizzle.isXML( context ),
  3140. parts = [],
  3141. soFar = selector;
  3142. // Reset the position of the chunker regexp (start from head)
  3143. do {
  3144. chunker.exec( "" );
  3145. m = chunker.exec( soFar );
  3146. if ( m ) {
  3147. soFar = m[3];
  3148. parts.push( m[1] );
  3149. if ( m[2] ) {
  3150. extra = m[3];
  3151. break;
  3152. }
  3153. }
  3154. } while ( m );
  3155. if ( parts.length > 1 && origPOS.exec( selector ) ) {
  3156. if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
  3157. set = posProcess( parts[0] + parts[1], context );
  3158. } else {
  3159. set = Expr.relative[ parts[0] ] ?
  3160. [ context ] :
  3161. Sizzle( parts.shift(), context );
  3162. while ( parts.length ) {
  3163. selector = parts.shift();
  3164. if ( Expr.relative[ selector ] ) {
  3165. selector += parts.shift();
  3166. }
  3167. set = posProcess( selector, set );
  3168. }
  3169. }
  3170. } else {
  3171. // Take a shortcut and set the context if the root selector is an ID
  3172. // (but not if it'll be faster if the inner selector is an ID)
  3173. if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
  3174. Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
  3175. ret = Sizzle.find( parts.shift(), context, contextXML );
  3176. context = ret.expr ?
  3177. Sizzle.filter( ret.expr, ret.set )[0] :
  3178. ret.set[0];
  3179. }
  3180. if ( context ) {
  3181. ret = seed ?
  3182. { expr: parts.pop(), set: makeArray(seed) } :
  3183. Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
  3184. set = ret.expr ?
  3185. Sizzle.filter( ret.expr, ret.set ) :
  3186. ret.set;
  3187. if ( parts.length > 0 ) {
  3188. checkSet = makeArray( set );
  3189. } else {
  3190. prune = false;
  3191. }
  3192. while ( parts.length ) {
  3193. cur = parts.pop();
  3194. pop = cur;
  3195. if ( !Expr.relative[ cur ] ) {
  3196. cur = "";
  3197. } else {
  3198. pop = parts.pop();
  3199. }
  3200. if ( pop == null ) {
  3201. pop = context;
  3202. }
  3203. Expr.relative[ cur ]( checkSet, pop, contextXML );
  3204. }
  3205. } else {
  3206. checkSet = parts = [];
  3207. }
  3208. }
  3209. if ( !checkSet ) {
  3210. checkSet = set;
  3211. }
  3212. if ( !checkSet ) {
  3213. Sizzle.error( cur || selector );
  3214. }
  3215. if ( toString.call(checkSet) === "[object Array]" ) {
  3216. if ( !prune ) {
  3217. results.push.apply( results, checkSet );
  3218. } else if ( context && context.nodeType === 1 ) {
  3219. for ( i = 0; checkSet[i] != null; i++ ) {
  3220. if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
  3221. results.push( set[i] );
  3222. }
  3223. }
  3224. } else {
  3225. for ( i = 0; checkSet[i] != null; i++ ) {
  3226. if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
  3227. results.push( set[i] );
  3228. }
  3229. }
  3230. }
  3231. } else {
  3232. makeArray( checkSet, results );
  3233. }
  3234. if ( extra ) {
  3235. Sizzle( extra, origContext, results, seed );
  3236. Sizzle.uniqueSort( results );
  3237. }
  3238. return results;
  3239. };
  3240. Sizzle.uniqueSort = function( results ) {
  3241. if ( sortOrder ) {
  3242. hasDuplicate = baseHasDuplicate;
  3243. results.sort( sortOrder );
  3244. if ( hasDuplicate ) {
  3245. for ( var i = 1; i < results.length; i++ ) {
  3246. if ( results[i] === results[ i - 1 ] ) {
  3247. results.splice( i--, 1 );
  3248. }
  3249. }
  3250. }
  3251. }
  3252. return results;
  3253. };
  3254. Sizzle.matches = function( expr, set ) {
  3255. return Sizzle( expr, null, null, set );
  3256. };
  3257. Sizzle.matchesSelector = function( node, expr ) {
  3258. return Sizzle( expr, null, null, [node] ).length > 0;
  3259. };
  3260. Sizzle.find = function( expr, context, isXML ) {
  3261. var set;
  3262. if ( !expr ) {
  3263. return [];
  3264. }
  3265. for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
  3266. var match,
  3267. type = Expr.order[i];
  3268. if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
  3269. var left = match[1];
  3270. match.splice( 1, 1 );
  3271. if ( left.substr( left.length - 1 ) !== "\\" ) {
  3272. match[1] = (match[1] || "").replace( rBackslash, "" );
  3273. set = Expr.find[ type ]( match, context, isXML );
  3274. if ( set != null ) {
  3275. expr = expr.replace( Expr.match[ type ], "" );
  3276. break;
  3277. }
  3278. }
  3279. }
  3280. }
  3281. if ( !set ) {
  3282. set = typeof context.getElementsByTagName !== "undefined" ?
  3283. context.getElementsByTagName( "*" ) :
  3284. [];
  3285. }
  3286. return { set: set, expr: expr };
  3287. };
  3288. Sizzle.filter = function( expr, set, inplace, not ) {
  3289. var match, anyFound,
  3290. old = expr,
  3291. result = [],
  3292. curLoop = set,
  3293. isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
  3294. while ( expr && set.length ) {
  3295. for ( var type in Expr.filter ) {
  3296. if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
  3297. var found, item,
  3298. filter = Expr.filter[ type ],
  3299. left = match[1];
  3300. anyFound = false;
  3301. match.splice(1,1);
  3302. if ( left.substr( left.length - 1 ) === "\\" ) {
  3303. continue;
  3304. }
  3305. if ( curLoop === result ) {
  3306. result = [];
  3307. }
  3308. if ( Expr.preFilter[ type ] ) {
  3309. match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
  3310. if ( !match ) {
  3311. anyFound = found = true;
  3312. } else if ( match === true ) {
  3313. continue;
  3314. }
  3315. }
  3316. if ( match ) {
  3317. for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
  3318. if ( item ) {
  3319. found = filter( item, match, i, curLoop );
  3320. var pass = not ^ !!found;
  3321. if ( inplace && found != null ) {
  3322. if ( pass ) {
  3323. anyFound = true;
  3324. } else {
  3325. curLoop[i] = false;
  3326. }
  3327. } else if ( pass ) {
  3328. result.push( item );
  3329. anyFound = true;
  3330. }
  3331. }
  3332. }
  3333. }
  3334. if ( found !== undefined ) {
  3335. if ( !inplace ) {
  3336. curLoop = result;
  3337. }
  3338. expr = expr.replace( Expr.match[ type ], "" );
  3339. if ( !anyFound ) {
  3340. return [];
  3341. }
  3342. break;
  3343. }
  3344. }
  3345. }
  3346. // Improper expression
  3347. if ( expr === old ) {
  3348. if ( anyFound == null ) {
  3349. Sizzle.error( expr );
  3350. } else {
  3351. break;
  3352. }
  3353. }
  3354. old = expr;
  3355. }
  3356. return curLoop;
  3357. };
  3358. Sizzle.error = function( msg ) {
  3359. throw "Syntax error, unrecognized expression: " + msg;
  3360. };
  3361. var Expr = Sizzle.selectors = {
  3362. order: [ "ID", "NAME", "TAG" ],
  3363. match: {
  3364. ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  3365. CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
  3366. NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
  3367. ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
  3368. TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
  3369. CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
  3370. POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
  3371. PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
  3372. },
  3373. leftMatch: {},
  3374. attrMap: {
  3375. "class": "className",
  3376. "for": "htmlFor"
  3377. },
  3378. attrHandle: {
  3379. href: function( elem ) {
  3380. return elem.getAttribute( "href" );
  3381. },
  3382. type: function( elem ) {
  3383. return elem.getAttribute( "type" );
  3384. }
  3385. },
  3386. relative: {
  3387. "+": function(checkSet, part){
  3388. var isPartStr = typeof part === "string",
  3389. isTag = isPartStr && !rNonWord.test( part ),
  3390. isPartStrNotTag = isPartStr && !isTag;
  3391. if ( isTag ) {
  3392. part = part.toLowerCase();
  3393. }
  3394. for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
  3395. if ( (elem = checkSet[i]) ) {
  3396. while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
  3397. checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
  3398. elem || false :
  3399. elem === part;
  3400. }
  3401. }
  3402. if ( isPartStrNotTag ) {
  3403. Sizzle.filter( part, checkSet, true );
  3404. }
  3405. },
  3406. ">": function( checkSet, part ) {
  3407. var elem,
  3408. isPartStr = typeof part === "string",
  3409. i = 0,
  3410. l = checkSet.length;
  3411. if ( isPartStr && !rNonWord.test( part ) ) {
  3412. part = part.toLowerCase();
  3413. for ( ; i < l; i++ ) {
  3414. elem = checkSet[i];
  3415. if ( elem ) {
  3416. var parent = elem.parentNode;
  3417. checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
  3418. }
  3419. }
  3420. } else {
  3421. for ( ; i < l; i++ ) {
  3422. elem = checkSet[i];
  3423. if ( elem ) {
  3424. checkSet[i] = isPartStr ?
  3425. elem.parentNode :
  3426. elem.parentNode === part;
  3427. }
  3428. }
  3429. if ( isPartStr ) {
  3430. Sizzle.filter( part, checkSet, true );
  3431. }
  3432. }
  3433. },
  3434. "": function(checkSet, part, isXML){
  3435. var nodeCheck,
  3436. doneName = done++,
  3437. checkFn = dirCheck;
  3438. if ( typeof part === "string" && !rNonWord.test( part ) ) {
  3439. part = part.toLowerCase();
  3440. nodeCheck = part;
  3441. checkFn = dirNodeCheck;
  3442. }
  3443. checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
  3444. },
  3445. "~": function( checkSet, part, isXML ) {
  3446. var nodeCheck,
  3447. doneName = done++,
  3448. checkFn = dirCheck;
  3449. if ( typeof part === "string" && !rNonWord.test( part ) ) {
  3450. part = part.toLowerCase();
  3451. nodeCheck = part;
  3452. checkFn = dirNodeCheck;
  3453. }
  3454. checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
  3455. }
  3456. },
  3457. find: {
  3458. ID: function( match, context, isXML ) {
  3459. if ( typeof context.getElementById !== "undefined" && !isXML ) {
  3460. var m = context.getElementById(match[1]);
  3461. // Check parentNode to catch when Blackberry 4.6 returns
  3462. // nodes that are no longer in the document #6963
  3463. return m && m.parentNode ? [m] : [];
  3464. }
  3465. },
  3466. NAME: function( match, context ) {
  3467. if ( typeof context.getElementsByName !== "undefined" ) {
  3468. var ret = [],
  3469. results = context.getElementsByName( match[1] );
  3470. for ( var i = 0, l = results.length; i < l; i++ ) {
  3471. if ( results[i].getAttribute("name") === match[1] ) {
  3472. ret.push( results[i] );
  3473. }
  3474. }
  3475. return ret.length === 0 ? null : ret;
  3476. }
  3477. },
  3478. TAG: function( match, context ) {
  3479. if ( typeof context.getElementsByTagName !== "undefined" ) {
  3480. return context.getElementsByTagName( match[1] );
  3481. }
  3482. }
  3483. },
  3484. preFilter: {
  3485. CLASS: function( match, curLoop, inplace, result, not, isXML ) {
  3486. match = " " + match[1].replace( rBackslash, "" ) + " ";
  3487. if ( isXML ) {
  3488. return match;
  3489. }
  3490. for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
  3491. if ( elem ) {
  3492. if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
  3493. if ( !inplace ) {
  3494. result.push( elem );
  3495. }
  3496. } else if ( inplace ) {
  3497. curLoop[i] = false;
  3498. }
  3499. }
  3500. }
  3501. return false;
  3502. },
  3503. ID: function( match ) {
  3504. return match[1].replace( rBackslash, "" );
  3505. },
  3506. TAG: function( match, curLoop ) {
  3507. return match[1].replace( rBackslash, "" ).toLowerCase();
  3508. },
  3509. CHILD: function( match ) {
  3510. if ( match[1] === "nth" ) {
  3511. if ( !match[2] ) {
  3512. Sizzle.error( match[0] );
  3513. }
  3514. match[2] = match[2].replace(/^\+|\s*/g, '');
  3515. // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
  3516. var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
  3517. match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
  3518. !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
  3519. // calculate the numbers (first)n+(last) including if they are negative
  3520. match[2] = (test[1] + (test[2] || 1)) - 0;
  3521. match[3] = test[3] - 0;
  3522. }
  3523. else if ( match[2] ) {
  3524. Sizzle.error( match[0] );
  3525. }
  3526. // TODO: Move to normal caching system
  3527. match[0] = done++;
  3528. return match;
  3529. },
  3530. ATTR: function( match, curLoop, inplace, result, not, isXML ) {
  3531. var name = match[1] = match[1].replace( rBackslash, "" );
  3532. if ( !isXML && Expr.attrMap[name] ) {
  3533. match[1] = Expr.attrMap[name];
  3534. }
  3535. // Handle if an un-quoted value was used
  3536. match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
  3537. if ( match[2] === "~=" ) {
  3538. match[4] = " " + match[4] + " ";
  3539. }
  3540. return match;
  3541. },
  3542. PSEUDO: function( match, curLoop, inplace, result, not ) {
  3543. if ( match[1] === "not" ) {
  3544. // If we're dealing with a complex expression, or a simple one
  3545. if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
  3546. match[3] = Sizzle(match[3], null, null, curLoop);
  3547. } else {
  3548. var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
  3549. if ( !inplace ) {
  3550. result.push.apply( result, ret );
  3551. }
  3552. return false;
  3553. }
  3554. } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
  3555. return true;
  3556. }
  3557. return match;
  3558. },
  3559. POS: function( match ) {
  3560. match.unshift( true );
  3561. return match;
  3562. }
  3563. },
  3564. filters: {
  3565. enabled: function( elem ) {
  3566. return elem.disabled === false && elem.type !== "hidden";
  3567. },
  3568. disabled: function( elem ) {
  3569. return elem.disabled === true;
  3570. },
  3571. checked: function( elem ) {
  3572. return elem.checked === true;
  3573. },
  3574. selected: function( elem ) {
  3575. // Accessing this property makes selected-by-default
  3576. // options in Safari work properly
  3577. if ( elem.parentNode ) {
  3578. elem.parentNode.selectedIndex;
  3579. }
  3580. return elem.selected === true;
  3581. },
  3582. parent: function( elem ) {
  3583. return !!elem.firstChild;
  3584. },
  3585. empty: function( elem ) {
  3586. return !elem.firstChild;
  3587. },
  3588. has: function( elem, i, match ) {
  3589. return !!Sizzle( match[3], elem ).length;
  3590. },
  3591. header: function( elem ) {
  3592. return (/h\d/i).test( elem.nodeName );
  3593. },
  3594. text: function( elem ) {
  3595. var attr = elem.getAttribute( "type" ), type = elem.type;
  3596. // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
  3597. // use getAttribute instead to test this case
  3598. return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null );
  3599. },
  3600. radio: function( elem ) {
  3601. return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type;
  3602. },
  3603. checkbox: function( elem ) {
  3604. return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type;
  3605. },
  3606. file: function( elem ) {
  3607. return elem.nodeName.toLowerCase() === "input" && "file" === elem.type;
  3608. },
  3609. password: function( elem ) {
  3610. return elem.nodeName.toLowerCase() === "input" && "password" === elem.type;
  3611. },
  3612. submit: function( elem ) {
  3613. var name = elem.nodeName.toLowerCase();
  3614. return (name === "input" || name === "button") && "submit" === elem.type;
  3615. },
  3616. image: function( elem ) {
  3617. return elem.nodeName.toLowerCase() === "input" && "image" === elem.type;
  3618. },
  3619. reset: function( elem ) {
  3620. var name = elem.nodeName.toLowerCase();
  3621. return (name === "input" || name === "button") && "reset" === elem.type;
  3622. },
  3623. button: function( elem ) {
  3624. var name = elem.nodeName.toLowerCase();
  3625. return name === "input" && "button" === elem.type || name === "button";
  3626. },
  3627. input: function( elem ) {
  3628. return (/input|select|textarea|button/i).test( elem.nodeName );
  3629. },
  3630. focus: function( elem ) {
  3631. return elem === elem.ownerDocument.activeElement;
  3632. }
  3633. },
  3634. setFilters: {
  3635. first: function( elem, i ) {
  3636. return i === 0;
  3637. },
  3638. last: function( elem, i, match, array ) {
  3639. return i === array.length - 1;
  3640. },
  3641. even: function( elem, i ) {
  3642. return i % 2 === 0;
  3643. },
  3644. odd: function( elem, i ) {
  3645. return i % 2 === 1;
  3646. },
  3647. lt: function( elem, i, match ) {
  3648. return i < match[3] - 0;
  3649. },
  3650. gt: function( elem, i, match ) {
  3651. return i > match[3] - 0;
  3652. },
  3653. nth: function( elem, i, match ) {
  3654. return match[3] - 0 === i;
  3655. },
  3656. eq: function( elem, i, match ) {
  3657. return match[3] - 0 === i;
  3658. }
  3659. },
  3660. filter: {
  3661. PSEUDO: function( elem, match, i, array ) {
  3662. var name = match[1],
  3663. filter = Expr.filters[ name ];
  3664. if ( filter ) {
  3665. return filter( elem, i, match, array );
  3666. } else if ( name === "contains" ) {
  3667. return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
  3668. } else if ( name === "not" ) {
  3669. var not = match[3];
  3670. for ( var j = 0, l = not.length; j < l; j++ ) {
  3671. if ( not[j] === elem ) {
  3672. return false;
  3673. }
  3674. }
  3675. return true;
  3676. } else {
  3677. Sizzle.error( name );
  3678. }
  3679. },
  3680. CHILD: function( elem, match ) {
  3681. var type = match[1],
  3682. node = elem;
  3683. switch ( type ) {
  3684. case "only":
  3685. case "first":
  3686. while ( (node = node.previousSibling) ) {
  3687. if ( node.nodeType === 1 ) {
  3688. return false;
  3689. }
  3690. }
  3691. if ( type === "first" ) {
  3692. return true;
  3693. }
  3694. node = elem;
  3695. case "last":
  3696. while ( (node = node.nextSibling) ) {
  3697. if ( node.nodeType === 1 ) {
  3698. return false;
  3699. }
  3700. }
  3701. return true;
  3702. case "nth":
  3703. var first = match[2],
  3704. last = match[3];
  3705. if ( first === 1 && last === 0 ) {
  3706. return true;
  3707. }
  3708. var doneName = match[0],
  3709. parent = elem.parentNode;
  3710. if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
  3711. var count = 0;
  3712. for ( node = parent.firstChild; node; node = node.nextSibling ) {
  3713. if ( node.nodeType === 1 ) {
  3714. node.nodeIndex = ++count;
  3715. }
  3716. }
  3717. parent.sizcache = doneName;
  3718. }
  3719. var diff = elem.nodeIndex - last;
  3720. if ( first === 0 ) {
  3721. return diff === 0;
  3722. } else {
  3723. return ( diff % first === 0 && diff / first >= 0 );
  3724. }
  3725. }
  3726. },
  3727. ID: function( elem, match ) {
  3728. return elem.nodeType === 1 && elem.getAttribute("id") === match;
  3729. },
  3730. TAG: function( elem, match ) {
  3731. return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
  3732. },
  3733. CLASS: function( elem, match ) {
  3734. return (" " + (elem.className || elem.getAttribute("class")) + " ")
  3735. .indexOf( match ) > -1;
  3736. },
  3737. ATTR: function( elem, match ) {
  3738. var name = match[1],
  3739. result = Expr.attrHandle[ name ] ?
  3740. Expr.attrHandle[ name ]( elem ) :
  3741. elem[ name ] != null ?
  3742. elem[ name ] :
  3743. elem.getAttribute( name ),
  3744. value = result + "",
  3745. type = match[2],
  3746. check = match[4];
  3747. return result == null ?
  3748. type === "!=" :
  3749. type === "=" ?
  3750. value === check :
  3751. type === "*=" ?
  3752. value.indexOf(check) >= 0 :
  3753. type === "~=" ?
  3754. (" " + value + " ").indexOf(check) >= 0 :
  3755. !check ?
  3756. value && result !== false :
  3757. type === "!=" ?
  3758. value !== check :
  3759. type === "^=" ?
  3760. value.indexOf(check) === 0 :
  3761. type === "$=" ?
  3762. value.substr(value.length - check.length) === check :
  3763. type === "|=" ?
  3764. value === check || value.substr(0, check.length + 1) === check + "-" :
  3765. false;
  3766. },
  3767. POS: function( elem, match, i, array ) {
  3768. var name = match[2],
  3769. filter = Expr.setFilters[ name ];
  3770. if ( filter ) {
  3771. return filter( elem, i, match, array );
  3772. }
  3773. }
  3774. }
  3775. };
  3776. var origPOS = Expr.match.POS,
  3777. fescape = function(all, num){
  3778. return "\\" + (num - 0 + 1);
  3779. };
  3780. for ( var type in Expr.match ) {
  3781. Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
  3782. Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
  3783. }
  3784. var makeArray = function( array, results ) {
  3785. array = Array.prototype.slice.call( array, 0 );
  3786. if ( results ) {
  3787. results.push.apply( results, array );
  3788. return results;
  3789. }
  3790. return array;
  3791. };
  3792. // Perform a simple check to determine if the browser is capable of
  3793. // converting a NodeList to an array using builtin methods.
  3794. // Also verifies that the returned array holds DOM nodes
  3795. // (which is not the case in the Blackberry browser)
  3796. try {
  3797. Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
  3798. // Provide a fallback method if it does not work
  3799. } catch( e ) {
  3800. makeArray = function( array, results ) {
  3801. var i = 0,
  3802. ret = results || [];
  3803. if ( toString.call(array) === "[object Array]" ) {
  3804. Array.prototype.push.apply( ret, array );
  3805. } else {
  3806. if ( typeof array.length === "number" ) {
  3807. for ( var l = array.length; i < l; i++ ) {
  3808. ret.push( array[i] );
  3809. }
  3810. } else {
  3811. for ( ; array[i]; i++ ) {
  3812. ret.push( array[i] );
  3813. }
  3814. }
  3815. }
  3816. return ret;
  3817. };
  3818. }
  3819. var sortOrder, siblingCheck;
  3820. if ( document.documentElement.compareDocumentPosition ) {
  3821. sortOrder = function( a, b ) {
  3822. if ( a === b ) {
  3823. hasDuplicate = true;
  3824. return 0;
  3825. }
  3826. if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
  3827. return a.compareDocumentPosition ? -1 : 1;
  3828. }
  3829. return a.compareDocumentPosition(b) & 4 ? -1 : 1;
  3830. };
  3831. } else {
  3832. sortOrder = function( a, b ) {
  3833. // The nodes are identical, we can exit early
  3834. if ( a === b ) {
  3835. hasDuplicate = true;
  3836. return 0;
  3837. // Fallback to using sourceIndex (in IE) if it's available on both nodes
  3838. } else if ( a.sourceIndex && b.sourceIndex ) {
  3839. return a.sourceIndex - b.sourceIndex;
  3840. }
  3841. var al, bl,
  3842. ap = [],
  3843. bp = [],
  3844. aup = a.parentNode,
  3845. bup = b.parentNode,
  3846. cur = aup;
  3847. // If the nodes are siblings (or identical) we can do a quick check
  3848. if ( aup === bup ) {
  3849. return siblingCheck( a, b );
  3850. // If no parents were found then the nodes are disconnected
  3851. } else if ( !aup ) {
  3852. return -1;
  3853. } else if ( !bup ) {
  3854. return 1;
  3855. }
  3856. // Otherwise they're somewhere else in the tree so we need
  3857. // to build up a full list of the parentNodes for comparison
  3858. while ( cur ) {
  3859. ap.unshift( cur );
  3860. cur = cur.parentNode;
  3861. }
  3862. cur = bup;
  3863. while ( cur ) {
  3864. bp.unshift( cur );
  3865. cur = cur.parentNode;
  3866. }
  3867. al = ap.length;
  3868. bl = bp.length;
  3869. // Start walking down the tree looking for a discrepancy
  3870. for ( var i = 0; i < al && i < bl; i++ ) {
  3871. if ( ap[i] !== bp[i] ) {
  3872. return siblingCheck( ap[i], bp[i] );
  3873. }
  3874. }
  3875. // We ended someplace up the tree so do a sibling check
  3876. return i === al ?
  3877. siblingCheck( a, bp[i], -1 ) :
  3878. siblingCheck( ap[i], b, 1 );
  3879. };
  3880. siblingCheck = function( a, b, ret ) {
  3881. if ( a === b ) {
  3882. return ret;
  3883. }
  3884. var cur = a.nextSibling;
  3885. while ( cur ) {
  3886. if ( cur === b ) {
  3887. return -1;
  3888. }
  3889. cur = cur.nextSibling;
  3890. }
  3891. return 1;
  3892. };
  3893. }
  3894. // Utility function for retreiving the text value of an array of DOM nodes
  3895. Sizzle.getText = function( elems ) {
  3896. var ret = "", elem;
  3897. for ( var i = 0; elems[i]; i++ ) {
  3898. elem = elems[i];
  3899. // Get the text from text nodes and CDATA nodes
  3900. if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
  3901. ret += elem.nodeValue;
  3902. // Traverse everything else, except comment nodes
  3903. } else if ( elem.nodeType !== 8 ) {
  3904. ret += Sizzle.getText( elem.childNodes );
  3905. }
  3906. }
  3907. return ret;
  3908. };
  3909. // Check to see if the browser returns elements by name when
  3910. // querying by getElementById (and provide a workaround)
  3911. (function(){
  3912. // We're going to inject a fake input element with a specified name
  3913. var form = document.createElement("div"),
  3914. id = "script" + (new Date()).getTime(),
  3915. root = document.documentElement;
  3916. form.innerHTML = "<a name='" + id + "'/>";
  3917. // Inject it into the root element, check its status, and remove it quickly
  3918. root.insertBefore( form, root.firstChild );
  3919. // The workaround has to do additional checks after a getElementById
  3920. // Which slows things down for other browsers (hence the branching)
  3921. if ( document.getElementById( id ) ) {
  3922. Expr.find.ID = function( match, context, isXML ) {
  3923. if ( typeof context.getElementById !== "undefined" && !isXML ) {
  3924. var m = context.getElementById(match[1]);
  3925. return m ?
  3926. m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
  3927. [m] :
  3928. undefined :
  3929. [];
  3930. }
  3931. };
  3932. Expr.filter.ID = function( elem, match ) {
  3933. var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
  3934. return elem.nodeType === 1 && node && node.nodeValue === match;
  3935. };
  3936. }
  3937. root.removeChild( form );
  3938. // release memory in IE
  3939. root = form = null;
  3940. })();
  3941. (function(){
  3942. // Check to see if the browser returns only elements
  3943. // when doing getElementsByTagName("*")
  3944. // Create a fake element
  3945. var div = document.createElement("div");
  3946. div.appendChild( document.createComment("") );
  3947. // Make sure no comments are found
  3948. if ( div.getElementsByTagName("*").length > 0 ) {
  3949. Expr.find.TAG = function( match, context ) {
  3950. var results = context.getElementsByTagName( match[1] );
  3951. // Filter out possible comments
  3952. if ( match[1] === "*" ) {
  3953. var tmp = [];
  3954. for ( var i = 0; results[i]; i++ ) {
  3955. if ( results[i].nodeType === 1 ) {
  3956. tmp.push( results[i] );
  3957. }
  3958. }
  3959. results = tmp;
  3960. }
  3961. return results;
  3962. };
  3963. }
  3964. // Check to see if an attribute returns normalized href attributes
  3965. div.innerHTML = "<a href='#'></a>";
  3966. if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
  3967. div.firstChild.getAttribute("href") !== "#" ) {
  3968. Expr.attrHandle.href = function( elem ) {
  3969. return elem.getAttribute( "href", 2 );
  3970. };
  3971. }
  3972. // release memory in IE
  3973. div = null;
  3974. })();
  3975. if ( document.querySelectorAll ) {
  3976. (function(){
  3977. var oldSizzle = Sizzle,
  3978. div = document.createElement("div"),
  3979. id = "__sizzle__";
  3980. div.innerHTML = "<p class='TEST'></p>";
  3981. // Safari can't handle uppercase or unicode characters when
  3982. // in quirks mode.
  3983. if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
  3984. return;
  3985. }
  3986. Sizzle = function( query, context, extra, seed ) {
  3987. context = context || document;
  3988. // Only use querySelectorAll on non-XML documents
  3989. // (ID selectors don't work in non-HTML documents)
  3990. if ( !seed && !Sizzle.isXML(context) ) {
  3991. // See if we find a selector to speed up
  3992. var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
  3993. if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
  3994. // Speed-up: Sizzle("TAG")
  3995. if ( match[1] ) {
  3996. return makeArray( context.getElementsByTagName( query ), extra );
  3997. // Speed-up: Sizzle(".CLASS")
  3998. } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
  3999. return makeArray( context.getElementsByClassName( match[2] ), extra );
  4000. }
  4001. }
  4002. if ( context.nodeType === 9 ) {
  4003. // Speed-up: Sizzle("body")
  4004. // The body element only exists once, optimize finding it
  4005. if ( query === "body" && context.body ) {
  4006. return makeArray( [ context.body ], extra );
  4007. // Speed-up: Sizzle("#ID")
  4008. } else if ( match && match[3] ) {
  4009. var elem = context.getElementById( match[3] );
  4010. // Check parentNode to catch when Blackberry 4.6 returns
  4011. // nodes that are no longer in the document #6963
  4012. if ( elem && elem.parentNode ) {
  4013. // Handle the case where IE and Opera return items
  4014. // by name instead of ID
  4015. if ( elem.id === match[3] ) {
  4016. return makeArray( [ elem ], extra );
  4017. }
  4018. } else {
  4019. return makeArray( [], extra );
  4020. }
  4021. }
  4022. try {
  4023. return makeArray( context.querySelectorAll(query), extra );
  4024. } catch(qsaError) {}
  4025. // qSA works strangely on Element-rooted queries
  4026. // We can work around this by specifying an extra ID on the root
  4027. // and working up from there (Thanks to Andrew Dupont for the technique)
  4028. // IE 8 doesn't work on object elements
  4029. } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
  4030. var oldContext = context,
  4031. old = context.getAttribute( "id" ),
  4032. nid = old || id,
  4033. hasParent = context.parentNode,
  4034. relativeHierarchySelector = /^\s*[+~]/.test( query );
  4035. if ( !old ) {
  4036. context.setAttribute( "id", nid );
  4037. } else {
  4038. nid = nid.replace( /'/g, "\\$&" );
  4039. }
  4040. if ( relativeHierarchySelector && hasParent ) {
  4041. context = context.parentNode;
  4042. }
  4043. try {
  4044. if ( !relativeHierarchySelector || hasParent ) {
  4045. return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
  4046. }
  4047. } catch(pseudoError) {
  4048. } finally {
  4049. if ( !old ) {
  4050. oldContext.removeAttribute( "id" );
  4051. }
  4052. }
  4053. }
  4054. }
  4055. return oldSizzle(query, context, extra, seed);
  4056. };
  4057. for ( var prop in oldSizzle ) {
  4058. Sizzle[ prop ] = oldSizzle[ prop ];
  4059. }
  4060. // release memory in IE
  4061. div = null;
  4062. })();
  4063. }
  4064. (function(){
  4065. var html = document.documentElement,
  4066. matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector;
  4067. if ( matches ) {
  4068. // Check to see if it's possible to do matchesSelector
  4069. // on a disconnected node (IE 9 fails this)
  4070. var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ),
  4071. pseudoWorks = false;
  4072. try {
  4073. // This should fail with an exception
  4074. // Gecko does not error, returns false instead
  4075. matches.call( document.documentElement, "[test!='']:sizzle" );
  4076. } catch( pseudoError ) {
  4077. pseudoWorks = true;
  4078. }
  4079. Sizzle.matchesSelector = function( node, expr ) {
  4080. // Make sure that attribute selectors are quoted
  4081. expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
  4082. if ( !Sizzle.isXML( node ) ) {
  4083. try {
  4084. if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
  4085. var ret = matches.call( node, expr );
  4086. // IE 9's matchesSelector returns false on disconnected nodes
  4087. if ( ret || !disconnectedMatch ||
  4088. // As well, disconnected nodes are said to be in a document
  4089. // fragment in IE 9, so check for that
  4090. node.document && node.document.nodeType !== 11 ) {
  4091. return ret;
  4092. }
  4093. }
  4094. } catch(e) {}
  4095. }
  4096. return Sizzle(expr, null, null, [node]).length > 0;
  4097. };
  4098. }
  4099. })();
  4100. (function(){
  4101. var div = document.createElement("div");
  4102. div.innerHTML = "<div class='test e'></div><div class='test'></div>";
  4103. // Opera can't find a second classname (in 9.6)
  4104. // Also, make sure that getElementsByClassName actually exists
  4105. if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
  4106. return;
  4107. }
  4108. // Safari caches class attributes, doesn't catch changes (in 3.2)
  4109. div.lastChild.className = "e";
  4110. if ( div.getElementsByClassName("e").length === 1 ) {
  4111. return;
  4112. }
  4113. Expr.order.splice(1, 0, "CLASS");
  4114. Expr.find.CLASS = function( match, context, isXML ) {
  4115. if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
  4116. return context.getElementsByClassName(match[1]);
  4117. }
  4118. };
  4119. // release memory in IE
  4120. div = null;
  4121. })();
  4122. function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
  4123. for ( var i = 0, l = checkSet.length; i < l; i++ ) {
  4124. var elem = checkSet[i];
  4125. if ( elem ) {
  4126. var match = false;
  4127. elem = elem[dir];
  4128. while ( elem ) {
  4129. if ( elem.sizcache === doneName ) {
  4130. match = checkSet[elem.sizset];
  4131. break;
  4132. }
  4133. if ( elem.nodeType === 1 && !isXML ){
  4134. elem.sizcache = doneName;
  4135. elem.sizset = i;
  4136. }
  4137. if ( elem.nodeName.toLowerCase() === cur ) {
  4138. match = elem;
  4139. break;
  4140. }
  4141. elem = elem[dir];
  4142. }
  4143. checkSet[i] = match;
  4144. }
  4145. }
  4146. }
  4147. function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
  4148. for ( var i = 0, l = checkSet.length; i < l; i++ ) {
  4149. var elem = checkSet[i];
  4150. if ( elem ) {
  4151. var match = false;
  4152. elem = elem[dir];
  4153. while ( elem ) {
  4154. if ( elem.sizcache === doneName ) {
  4155. match = checkSet[elem.sizset];
  4156. break;
  4157. }
  4158. if ( elem.nodeType === 1 ) {
  4159. if ( !isXML ) {
  4160. elem.sizcache = doneName;
  4161. elem.sizset = i;
  4162. }
  4163. if ( typeof cur !== "string" ) {
  4164. if ( elem === cur ) {
  4165. match = true;
  4166. break;
  4167. }
  4168. } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
  4169. match = elem;
  4170. break;
  4171. }
  4172. }
  4173. elem = elem[dir];
  4174. }
  4175. checkSet[i] = match;
  4176. }
  4177. }
  4178. }
  4179. if ( document.documentElement.contains ) {
  4180. Sizzle.contains = function( a, b ) {
  4181. return a !== b && (a.contains ? a.contains(b) : true);
  4182. };
  4183. } else if ( document.documentElement.compareDocumentPosition ) {
  4184. Sizzle.contains = function( a, b ) {
  4185. return !!(a.compareDocumentPosition(b) & 16);
  4186. };
  4187. } else {
  4188. Sizzle.contains = function() {
  4189. return false;
  4190. };
  4191. }
  4192. Sizzle.isXML = function( elem ) {
  4193. // documentElement is verified for cases where it doesn't yet exist
  4194. // (such as loading iframes in IE - #4833)
  4195. var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
  4196. return documentElement ? documentElement.nodeName !== "HTML" : false;
  4197. };
  4198. var posProcess = function( selector, context ) {
  4199. var match,
  4200. tmpSet = [],
  4201. later = "",
  4202. root = context.nodeType ? [context] : context;
  4203. // Position selectors must be done after the filter
  4204. // And so must :not(positional) so we move all PSEUDOs to the end
  4205. while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
  4206. later += match[0];
  4207. selector = selector.replace( Expr.match.PSEUDO, "" );
  4208. }
  4209. selector = Expr.relative[selector] ? selector + "*" : selector;
  4210. for ( var i = 0, l = root.length; i < l; i++ ) {
  4211. Sizzle( selector, root[i], tmpSet );
  4212. }
  4213. return Sizzle.filter( later, tmpSet );
  4214. };
  4215. // EXPOSE
  4216. jQuery.find = Sizzle;
  4217. jQuery.expr = Sizzle.selectors;
  4218. jQuery.expr[":"] = jQuery.expr.filters;
  4219. jQuery.unique = Sizzle.uniqueSort;
  4220. jQuery.text = Sizzle.getText;
  4221. jQuery.isXMLDoc = Sizzle.isXML;
  4222. jQuery.contains = Sizzle.contains;
  4223. })();
  4224. var runtil = /Until$/,
  4225. rparentsprev = /^(?:parents|prevUntil|prevAll)/,
  4226. // Note: This RegExp should be improved, or likely pulled from Sizzle
  4227. rmultiselector = /,/,
  4228. isSimple = /^.[^:#\[\.,]*$/,
  4229. slice = Array.prototype.slice,
  4230. POS = jQuery.expr.match.POS,
  4231. // methods guaranteed to produce a unique set when starting from a unique set
  4232. guaranteedUnique = {
  4233. children: true,
  4234. contents: true,
  4235. next: true,
  4236. prev: true
  4237. };
  4238. jQuery.fn.extend({
  4239. find: function( selector ) {
  4240. var self = this,
  4241. i, l;
  4242. if ( typeof selector !== "string" ) {
  4243. return jQuery( selector ).filter(function() {
  4244. for ( i = 0, l = self.length; i < l; i++ ) {
  4245. if ( jQuery.contains( self[ i ], this ) ) {
  4246. return true;
  4247. }
  4248. }
  4249. });
  4250. }
  4251. var ret = this.pushStack( "", "find", selector ),
  4252. length, n, r;
  4253. for ( i = 0, l = this.length; i < l; i++ ) {
  4254. length = ret.length;
  4255. jQuery.find( selector, this[i], ret );
  4256. if ( i > 0 ) {
  4257. // Make sure that the results are unique
  4258. for ( n = length; n < ret.length; n++ ) {
  4259. for ( r = 0; r < length; r++ ) {
  4260. if ( ret[r] === ret[n] ) {
  4261. ret.splice(n--, 1);
  4262. break;
  4263. }
  4264. }
  4265. }
  4266. }
  4267. }
  4268. return ret;
  4269. },
  4270. has: function( target ) {
  4271. var targets = jQuery( target );
  4272. return this.filter(function() {
  4273. for ( var i = 0, l = targets.length; i < l; i++ ) {
  4274. if ( jQuery.contains( this, targets[i] ) ) {
  4275. return true;
  4276. }
  4277. }
  4278. });
  4279. },
  4280. not: function( selector ) {
  4281. return this.pushStack( winnow(this, selector, false), "not", selector);
  4282. },
  4283. filter: function( selector ) {
  4284. return this.pushStack( winnow(this, selector, true), "filter", selector );
  4285. },
  4286. is: function( selector ) {
  4287. return !!selector && ( typeof selector === "string" ?
  4288. jQuery.filter( selector, this ).length > 0 :
  4289. this.filter( selector ).length > 0 );
  4290. },
  4291. closest: function( selectors, context ) {
  4292. var ret = [], i, l, cur = this[0];
  4293. // Array
  4294. if ( jQuery.isArray( selectors ) ) {
  4295. var match, selector,
  4296. matches = {},
  4297. level = 1;
  4298. if ( cur && selectors.length ) {
  4299. for ( i = 0, l = selectors.length; i < l; i++ ) {
  4300. selector = selectors[i];
  4301. if ( !matches[ selector ] ) {
  4302. matches[ selector ] = POS.test( selector ) ?
  4303. jQuery( selector, context || this.context ) :
  4304. selector;
  4305. }
  4306. }
  4307. while ( cur && cur.ownerDocument && cur !== context ) {
  4308. for ( selector in matches ) {
  4309. match = matches[ selector ];
  4310. if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) {
  4311. ret.push({ selector: selector, elem: cur, level: level });
  4312. }
  4313. }
  4314. cur = cur.parentNode;
  4315. level++;
  4316. }
  4317. }
  4318. return ret;
  4319. }
  4320. // String
  4321. var pos = POS.test( selectors ) || typeof selectors !== "string" ?
  4322. jQuery( selectors, context || this.context ) :
  4323. 0;
  4324. for ( i = 0, l = this.length; i < l; i++ ) {
  4325. cur = this[i];
  4326. while ( cur ) {
  4327. if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
  4328. ret.push( cur );
  4329. break;
  4330. } else {
  4331. cur = cur.parentNode;
  4332. if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) {
  4333. break;
  4334. }
  4335. }
  4336. }
  4337. }
  4338. ret = ret.length > 1 ? jQuery.unique( ret ) : ret;
  4339. return this.pushStack( ret, "closest", selectors );
  4340. },
  4341. // Determine the position of an element within
  4342. // the matched set of elements
  4343. index: function( elem ) {
  4344. // No argument, return index in parent
  4345. if ( !elem ) {
  4346. return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1;
  4347. }
  4348. // index in selector
  4349. if ( typeof elem === "string" ) {
  4350. return jQuery.inArray( this[0], jQuery( elem ) );
  4351. }
  4352. // Locate the position of the desired element
  4353. return jQuery.inArray(
  4354. // If it receives a jQuery object, the first element is used
  4355. elem.jquery ? elem[0] : elem, this );
  4356. },
  4357. add: function( selector, context ) {
  4358. var set = typeof selector === "string" ?
  4359. jQuery( selector, context ) :
  4360. jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ),
  4361. all = jQuery.merge( this.get(), set );
  4362. return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
  4363. all :
  4364. jQuery.unique( all ) );
  4365. },
  4366. andSelf: function() {
  4367. return this.add( this.prevObject );
  4368. }
  4369. });
  4370. // A painfully simple check to see if an element is disconnected
  4371. // from a document (should be improved, where feasible).
  4372. function isDisconnected( node ) {
  4373. return !node || !node.parentNode || node.parentNode.nodeType === 11;
  4374. }
  4375. jQuery.each({
  4376. parent: function( elem ) {
  4377. var parent = elem.parentNode;
  4378. return parent && parent.nodeType !== 11 ? parent : null;
  4379. },
  4380. parents: function( elem ) {
  4381. return jQuery.dir( elem, "parentNode" );
  4382. },
  4383. parentsUntil: function( elem, i, until ) {
  4384. return jQuery.dir( elem, "parentNode", until );
  4385. },
  4386. next: function( elem ) {
  4387. return jQuery.nth( elem, 2, "nextSibling" );
  4388. },
  4389. prev: function( elem ) {
  4390. return jQuery.nth( elem, 2, "previousSibling" );
  4391. },
  4392. nextAll: function( elem ) {
  4393. return jQuery.dir( elem, "nextSibling" );
  4394. },
  4395. prevAll: function( elem ) {
  4396. return jQuery.dir( elem, "previousSibling" );
  4397. },
  4398. nextUntil: function( elem, i, until ) {
  4399. return jQuery.dir( elem, "nextSibling", until );
  4400. },
  4401. prevUntil: function( elem, i, until ) {
  4402. return jQuery.dir( elem, "previousSibling", until );
  4403. },
  4404. siblings: function( elem ) {
  4405. return jQuery.sibling( elem.parentNode.firstChild, elem );
  4406. },
  4407. children: function( elem ) {
  4408. return jQuery.sibling( elem.firstChild );
  4409. },
  4410. contents: function( elem ) {
  4411. return jQuery.nodeName( elem, "iframe" ) ?
  4412. elem.contentDocument || elem.contentWindow.document :
  4413. jQuery.makeArray( elem.childNodes );
  4414. }
  4415. }, function( name, fn ) {
  4416. jQuery.fn[ name ] = function( until, selector ) {
  4417. var ret = jQuery.map( this, fn, until ),
  4418. // The variable 'args' was introduced in
  4419. // https://github.com/jquery/jquery/commit/52a0238
  4420. // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
  4421. // http://code.google.com/p/v8/issues/detail?id=1050
  4422. args = slice.call(arguments);
  4423. if ( !runtil.test( name ) ) {
  4424. selector = until;
  4425. }
  4426. if ( selector && typeof selector === "string" ) {
  4427. ret = jQuery.filter( selector, ret );
  4428. }
  4429. ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
  4430. if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
  4431. ret = ret.reverse();
  4432. }
  4433. return this.pushStack( ret, name, args.join(",") );
  4434. };
  4435. });
  4436. jQuery.extend({
  4437. filter: function( expr, elems, not ) {
  4438. if ( not ) {
  4439. expr = ":not(" + expr + ")";
  4440. }
  4441. return elems.length === 1 ?
  4442. jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
  4443. jQuery.find.matches(expr, elems);
  4444. },
  4445. dir: function( elem, dir, until ) {
  4446. var matched = [],
  4447. cur = elem[ dir ];
  4448. while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
  4449. if ( cur.nodeType === 1 ) {
  4450. matched.push( cur );
  4451. }
  4452. cur = cur[dir];
  4453. }
  4454. return matched;
  4455. },
  4456. nth: function( cur, result, dir, elem ) {
  4457. result = result || 1;
  4458. var num = 0;
  4459. for ( ; cur; cur = cur[dir] ) {
  4460. if ( cur.nodeType === 1 && ++num === result ) {
  4461. break;
  4462. }
  4463. }
  4464. return cur;
  4465. },
  4466. sibling: function( n, elem ) {
  4467. var r = [];
  4468. for ( ; n; n = n.nextSibling ) {
  4469. if ( n.nodeType === 1 && n !== elem ) {
  4470. r.push( n );
  4471. }
  4472. }
  4473. return r;
  4474. }
  4475. });
  4476. // Implement the identical functionality for filter and not
  4477. function winnow( elements, qualifier, keep ) {
  4478. // Can't pass null or undefined to indexOf in Firefox 4
  4479. // Set to 0 to skip string check
  4480. qualifier = qualifier || 0;
  4481. if ( jQuery.isFunction( qualifier ) ) {
  4482. return jQuery.grep(elements, function( elem, i ) {
  4483. var retVal = !!qualifier.call( elem, i, elem );
  4484. return retVal === keep;
  4485. });
  4486. } else if ( qualifier.nodeType ) {
  4487. return jQuery.grep(elements, function( elem, i ) {
  4488. return (elem === qualifier) === keep;
  4489. });
  4490. } else if ( typeof qualifier === "string" ) {
  4491. var filtered = jQuery.grep(elements, function( elem ) {
  4492. return elem.nodeType === 1;
  4493. });
  4494. if ( isSimple.test( qualifier ) ) {
  4495. return jQuery.filter(qualifier, filtered, !keep);
  4496. } else {
  4497. qualifier = jQuery.filter( qualifier, filtered );
  4498. }
  4499. }
  4500. return jQuery.grep(elements, function( elem, i ) {
  4501. return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
  4502. });
  4503. }
  4504. var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
  4505. rleadingWhitespace = /^\s+/,
  4506. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
  4507. rtagName = /<([\w:]+)/,
  4508. rtbody = /<tbody/i,
  4509. rhtml = /<|&#?\w+;/,
  4510. rnocache = /<(?:script|object|embed|option|style)/i,
  4511. // checked="checked" or checked
  4512. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4513. rscriptType = /\/(java|ecma)script/i,
  4514. rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/,
  4515. wrapMap = {
  4516. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  4517. legend: [ 1, "<fieldset>", "</fieldset>" ],
  4518. thead: [ 1, "<table>", "</table>" ],
  4519. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  4520. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  4521. col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
  4522. area: [ 1, "<map>", "</map>" ],
  4523. _default: [ 0, "", "" ]
  4524. };
  4525. wrapMap.optgroup = wrapMap.option;
  4526. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  4527. wrapMap.th = wrapMap.td;
  4528. // IE can't serialize <link> and <script> tags normally
  4529. if ( !jQuery.support.htmlSerialize ) {
  4530. wrapMap._default = [ 1, "div<div>", "</div>" ];
  4531. }
  4532. jQuery.fn.extend({
  4533. text: function( text ) {
  4534. if ( jQuery.isFunction(text) ) {
  4535. return this.each(function(i) {
  4536. var self = jQuery( this );
  4537. self.text( text.call(this, i, self.text()) );
  4538. });
  4539. }
  4540. if ( typeof text !== "object" && text !== undefined ) {
  4541. return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
  4542. }
  4543. return jQuery.text( this );
  4544. },
  4545. wrapAll: function( html ) {
  4546. if ( jQuery.isFunction( html ) ) {
  4547. return this.each(function(i) {
  4548. jQuery(this).wrapAll( html.call(this, i) );
  4549. });
  4550. }
  4551. if ( this[0] ) {
  4552. // The elements to wrap the target around
  4553. var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
  4554. if ( this[0].parentNode ) {
  4555. wrap.insertBefore( this[0] );
  4556. }
  4557. wrap.map(function() {
  4558. var elem = this;
  4559. while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
  4560. elem = elem.firstChild;
  4561. }
  4562. return elem;
  4563. }).append( this );
  4564. }
  4565. return this;
  4566. },
  4567. wrapInner: function( html ) {
  4568. if ( jQuery.isFunction( html ) ) {
  4569. return this.each(function(i) {
  4570. jQuery(this).wrapInner( html.call(this, i) );
  4571. });
  4572. }
  4573. return this.each(function() {
  4574. var self = jQuery( this ),
  4575. contents = self.contents();
  4576. if ( contents.length ) {
  4577. contents.wrapAll( html );
  4578. } else {
  4579. self.append( html );
  4580. }
  4581. });
  4582. },
  4583. wrap: function( html ) {
  4584. return this.each(function() {
  4585. jQuery( this ).wrapAll( html );
  4586. });
  4587. },
  4588. unwrap: function() {
  4589. return this.parent().each(function() {
  4590. if ( !jQuery.nodeName( this, "body" ) ) {
  4591. jQuery( this ).replaceWith( this.childNodes );
  4592. }
  4593. }).end();
  4594. },
  4595. append: function() {
  4596. return this.domManip(arguments, true, function( elem ) {
  4597. if ( this.nodeType === 1 ) {
  4598. this.appendChild( elem );
  4599. }
  4600. });
  4601. },
  4602. prepend: function() {
  4603. return this.domManip(arguments, true, function( elem ) {
  4604. if ( this.nodeType === 1 ) {
  4605. this.insertBefore( elem, this.firstChild );
  4606. }
  4607. });
  4608. },
  4609. before: function() {
  4610. if ( this[0] && this[0].parentNode ) {
  4611. return this.domManip(arguments, false, function( elem ) {
  4612. this.parentNode.insertBefore( elem, this );
  4613. });
  4614. } else if ( arguments.length ) {
  4615. var set = jQuery(arguments[0]);
  4616. set.push.apply( set, this.toArray() );
  4617. return this.pushStack( set, "before", arguments );
  4618. }
  4619. },
  4620. after: function() {
  4621. if ( this[0] && this[0].parentNode ) {
  4622. return this.domManip(arguments, false, function( elem ) {
  4623. this.parentNode.insertBefore( elem, this.nextSibling );
  4624. });
  4625. } else if ( arguments.length ) {
  4626. var set = this.pushStack( this, "after", arguments );
  4627. set.push.apply( set, jQuery(arguments[0]).toArray() );
  4628. return set;
  4629. }
  4630. },
  4631. // keepData is for internal use only--do not document
  4632. remove: function( selector, keepData ) {
  4633. for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
  4634. if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
  4635. if ( !keepData && elem.nodeType === 1 ) {
  4636. jQuery.cleanData( elem.getElementsByTagName("*") );
  4637. jQuery.cleanData( [ elem ] );
  4638. }
  4639. if ( elem.parentNode ) {
  4640. elem.parentNode.removeChild( elem );
  4641. }
  4642. }
  4643. }
  4644. return this;
  4645. },
  4646. empty: function() {
  4647. for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
  4648. // Remove element nodes and prevent memory leaks
  4649. if ( elem.nodeType === 1 ) {
  4650. jQuery.cleanData( elem.getElementsByTagName("*") );
  4651. }
  4652. // Remove any remaining nodes
  4653. while ( elem.firstChild ) {
  4654. elem.removeChild( elem.firstChild );
  4655. }
  4656. }
  4657. return this;
  4658. },
  4659. clone: function( dataAndEvents, deepDataAndEvents ) {
  4660. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  4661. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  4662. return this.map( function () {
  4663. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  4664. });
  4665. },
  4666. html: function( value ) {
  4667. if ( value === undefined ) {
  4668. return this[0] && this[0].nodeType === 1 ?
  4669. this[0].innerHTML.replace(rinlinejQuery, "") :
  4670. null;
  4671. // See if we can take a shortcut and just use innerHTML
  4672. } else if ( typeof value === "string" && !rnocache.test( value ) &&
  4673. (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
  4674. !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
  4675. value = value.replace(rxhtmlTag, "<$1></$2>");
  4676. try {
  4677. for ( var i = 0, l = this.length; i < l; i++ ) {
  4678. // Remove element nodes and prevent memory leaks
  4679. if ( this[i].nodeType === 1 ) {
  4680. jQuery.cleanData( this[i].getElementsByTagName("*") );
  4681. this[i].innerHTML = value;
  4682. }
  4683. }
  4684. // If using innerHTML throws an exception, use the fallback method
  4685. } catch(e) {
  4686. this.empty().append( value );
  4687. }
  4688. } else if ( jQuery.isFunction( value ) ) {
  4689. this.each(function(i){
  4690. var self = jQuery( this );
  4691. self.html( value.call(this, i, self.html()) );
  4692. });
  4693. } else {
  4694. this.empty().append( value );
  4695. }
  4696. return this;
  4697. },
  4698. replaceWith: function( value ) {
  4699. if ( this[0] && this[0].parentNode ) {
  4700. // Make sure that the elements are removed from the DOM before they are inserted
  4701. // this can help fix replacing a parent with child elements
  4702. if ( jQuery.isFunction( value ) ) {
  4703. return this.each(function(i) {
  4704. var self = jQuery(this), old = self.html();
  4705. self.replaceWith( value.call( this, i, old ) );
  4706. });
  4707. }
  4708. if ( typeof value !== "string" ) {
  4709. value = jQuery( value ).detach();
  4710. }
  4711. return this.each(function() {
  4712. var next = this.nextSibling,
  4713. parent = this.parentNode;
  4714. jQuery( this ).remove();
  4715. if ( next ) {
  4716. jQuery(next).before( value );
  4717. } else {
  4718. jQuery(parent).append( value );
  4719. }
  4720. });
  4721. } else {
  4722. return this.length ?
  4723. this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
  4724. this;
  4725. }
  4726. },
  4727. detach: function( selector ) {
  4728. return this.remove( selector, true );
  4729. },
  4730. domManip: function( args, table, callback ) {
  4731. var results, first, fragment, parent,
  4732. value = args[0],
  4733. scripts = [];
  4734. // We can't cloneNode fragments that contain checked, in WebKit
  4735. if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
  4736. return this.each(function() {
  4737. jQuery(this).domManip( args, table, callback, true );
  4738. });
  4739. }
  4740. if ( jQuery.isFunction(value) ) {
  4741. return this.each(function(i) {
  4742. var self = jQuery(this);
  4743. args[0] = value.call(this, i, table ? self.html() : undefined);
  4744. self.domManip( args, table, callback );
  4745. });
  4746. }
  4747. if ( this[0] ) {
  4748. parent = value && value.parentNode;
  4749. // If we're in a fragment, just use that instead of building a new one
  4750. if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
  4751. results = { fragment: parent };
  4752. } else {
  4753. results = jQuery.buildFragment( args, this, scripts );
  4754. }
  4755. fragment = results.fragment;
  4756. if ( fragment.childNodes.length === 1 ) {
  4757. first = fragment = fragment.firstChild;
  4758. } else {
  4759. first = fragment.firstChild;
  4760. }
  4761. if ( first ) {
  4762. table = table && jQuery.nodeName( first, "tr" );
  4763. for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
  4764. callback.call(
  4765. table ?
  4766. root(this[i], first) :
  4767. this[i],
  4768. // Make sure that we do not leak memory by inadvertently discarding
  4769. // the original fragment (which might have attached data) instead of
  4770. // using it; in addition, use the original fragment object for the last
  4771. // item instead of first because it can end up being emptied incorrectly
  4772. // in certain situations (Bug #8070).
  4773. // Fragments from the fragment cache must always be cloned and never used
  4774. // in place.
  4775. results.cacheable || (l > 1 && i < lastIndex) ?
  4776. jQuery.clone( fragment, true, true ) :
  4777. fragment
  4778. );
  4779. }
  4780. }
  4781. if ( scripts.length ) {
  4782. jQuery.each( scripts, evalScript );
  4783. }
  4784. }
  4785. return this;
  4786. }
  4787. });
  4788. function root( elem, cur ) {
  4789. return jQuery.nodeName(elem, "table") ?
  4790. (elem.getElementsByTagName("tbody")[0] ||
  4791. elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
  4792. elem;
  4793. }
  4794. function cloneCopyEvent( src, dest ) {
  4795. if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
  4796. return;
  4797. }
  4798. var internalKey = jQuery.expando,
  4799. oldData = jQuery.data( src ),
  4800. curData = jQuery.data( dest, oldData );
  4801. // Switch to use the internal data object, if it exists, for the next
  4802. // stage of data copying
  4803. if ( (oldData = oldData[ internalKey ]) ) {
  4804. var events = oldData.events;
  4805. curData = curData[ internalKey ] = jQuery.extend({}, oldData);
  4806. if ( events ) {
  4807. delete curData.handle;
  4808. curData.events = {};
  4809. for ( var type in events ) {
  4810. for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
  4811. jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
  4812. }
  4813. }
  4814. }
  4815. }
  4816. }
  4817. function cloneFixAttributes( src, dest ) {
  4818. var nodeName;
  4819. // We do not need to do anything for non-Elements
  4820. if ( dest.nodeType !== 1 ) {
  4821. return;
  4822. }
  4823. // clearAttributes removes the attributes, which we don't want,
  4824. // but also removes the attachEvent events, which we *do* want
  4825. if ( dest.clearAttributes ) {
  4826. dest.clearAttributes();
  4827. }
  4828. // mergeAttributes, in contrast, only merges back on the
  4829. // original attributes, not the events
  4830. if ( dest.mergeAttributes ) {
  4831. dest.mergeAttributes( src );
  4832. }
  4833. nodeName = dest.nodeName.toLowerCase();
  4834. // IE6-8 fail to clone children inside object elements that use
  4835. // the proprietary classid attribute value (rather than the type
  4836. // attribute) to identify the type of content to display
  4837. if ( nodeName === "object" ) {
  4838. dest.outerHTML = src.outerHTML;
  4839. } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
  4840. // IE6-8 fails to persist the checked state of a cloned checkbox
  4841. // or radio button. Worse, IE6-7 fail to give the cloned element
  4842. // a checked appearance if the defaultChecked value isn't also set
  4843. if ( src.checked ) {
  4844. dest.defaultChecked = dest.checked = src.checked;
  4845. }
  4846. // IE6-7 get confused and end up setting the value of a cloned
  4847. // checkbox/radio button to an empty string instead of "on"
  4848. if ( dest.value !== src.value ) {
  4849. dest.value = src.value;
  4850. }
  4851. // IE6-8 fails to return the selected option to the default selected
  4852. // state when cloning options
  4853. } else if ( nodeName === "option" ) {
  4854. dest.selected = src.defaultSelected;
  4855. // IE6-8 fails to set the defaultValue to the correct value when
  4856. // cloning other types of input fields
  4857. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4858. dest.defaultValue = src.defaultValue;
  4859. }
  4860. // Event data gets referenced instead of copied if the expando
  4861. // gets copied too
  4862. dest.removeAttribute( jQuery.expando );
  4863. }
  4864. jQuery.buildFragment = function( args, nodes, scripts ) {
  4865. var fragment, cacheable, cacheresults, doc;
  4866. // nodes may contain either an explicit document object,
  4867. // a jQuery collection or context object.
  4868. // If nodes[0] contains a valid object to assign to doc
  4869. if ( nodes && nodes[0] ) {
  4870. doc = nodes[0].ownerDocument || nodes[0];
  4871. }
  4872. // Ensure that an attr object doesn't incorrectly stand in as a document object
  4873. // Chrome and Firefox seem to allow this to occur and will throw exception
  4874. // Fixes #8950
  4875. if ( !doc.createDocumentFragment ) {
  4876. doc = document;
  4877. }
  4878. // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
  4879. // Cloning options loses the selected state, so don't cache them
  4880. // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
  4881. // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
  4882. if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
  4883. args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
  4884. cacheable = true;
  4885. cacheresults = jQuery.fragments[ args[0] ];
  4886. if ( cacheresults && cacheresults !== 1 ) {
  4887. fragment = cacheresults;
  4888. }
  4889. }
  4890. if ( !fragment ) {
  4891. fragment = doc.createDocumentFragment();
  4892. jQuery.clean( args, doc, fragment, scripts );
  4893. }
  4894. if ( cacheable ) {
  4895. jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
  4896. }
  4897. return { fragment: fragment, cacheable: cacheable };
  4898. };
  4899. jQuery.fragments = {};
  4900. jQuery.each({
  4901. appendTo: "append",
  4902. prependTo: "prepend",
  4903. insertBefore: "before",
  4904. insertAfter: "after",
  4905. replaceAll: "replaceWith"
  4906. }, function( name, original ) {
  4907. jQuery.fn[ name ] = function( selector ) {
  4908. var ret = [],
  4909. insert = jQuery( selector ),
  4910. parent = this.length === 1 && this[0].parentNode;
  4911. if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
  4912. insert[ original ]( this[0] );
  4913. return this;
  4914. } else {
  4915. for ( var i = 0, l = insert.length; i < l; i++ ) {
  4916. var elems = (i > 0 ? this.clone(true) : this).get();
  4917. jQuery( insert[i] )[ original ]( elems );
  4918. ret = ret.concat( elems );
  4919. }
  4920. return this.pushStack( ret, name, insert.selector );
  4921. }
  4922. };
  4923. });
  4924. function getAll( elem ) {
  4925. if ( "getElementsByTagName" in elem ) {
  4926. return elem.getElementsByTagName( "*" );
  4927. } else if ( "querySelectorAll" in elem ) {
  4928. return elem.querySelectorAll( "*" );
  4929. } else {
  4930. return [];
  4931. }
  4932. }
  4933. // Used in clean, fixes the defaultChecked property
  4934. function fixDefaultChecked( elem ) {
  4935. if ( elem.type === "checkbox" || elem.type === "radio" ) {
  4936. elem.defaultChecked = elem.checked;
  4937. }
  4938. }
  4939. // Finds all inputs and passes them to fixDefaultChecked
  4940. function findInputs( elem ) {
  4941. if ( jQuery.nodeName( elem, "input" ) ) {
  4942. fixDefaultChecked( elem );
  4943. } else if ( "getElementsByTagName" in elem ) {
  4944. jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked );
  4945. }
  4946. }
  4947. jQuery.extend({
  4948. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4949. var clone = elem.cloneNode(true),
  4950. srcElements,
  4951. destElements,
  4952. i;
  4953. if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
  4954. (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
  4955. // IE copies events bound via attachEvent when using cloneNode.
  4956. // Calling detachEvent on the clone will also remove the events
  4957. // from the original. In order to get around this, we use some
  4958. // proprietary methods to clear the events. Thanks to MooTools
  4959. // guys for this hotness.
  4960. cloneFixAttributes( elem, clone );
  4961. // Using Sizzle here is crazy slow, so we use getElementsByTagName
  4962. // instead
  4963. srcElements = getAll( elem );
  4964. destElements = getAll( clone );
  4965. // Weird iteration because IE will replace the length property
  4966. // with an element if you are cloning the body and one of the
  4967. // elements on the page has a name or id of "length"
  4968. for ( i = 0; srcElements[i]; ++i ) {
  4969. // Ensure that the destination node is not null; Fixes #9587
  4970. if ( destElements[i] ) {
  4971. cloneFixAttributes( srcElements[i], destElements[i] );
  4972. }
  4973. }
  4974. }
  4975. // Copy the events from the original to the clone
  4976. if ( dataAndEvents ) {
  4977. cloneCopyEvent( elem, clone );
  4978. if ( deepDataAndEvents ) {
  4979. srcElements = getAll( elem );
  4980. destElements = getAll( clone );
  4981. for ( i = 0; srcElements[i]; ++i ) {
  4982. cloneCopyEvent( srcElements[i], destElements[i] );
  4983. }
  4984. }
  4985. }
  4986. srcElements = destElements = null;
  4987. // Return the cloned set
  4988. return clone;
  4989. },
  4990. clean: function( elems, context, fragment, scripts ) {
  4991. var checkScriptType;
  4992. context = context || document;
  4993. // !context.createElement fails in IE with an error but returns typeof 'object'
  4994. if ( typeof context.createElement === "undefined" ) {
  4995. context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
  4996. }
  4997. var ret = [], j;
  4998. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  4999. if ( typeof elem === "number" ) {
  5000. elem += "";
  5001. }
  5002. if ( !elem ) {
  5003. continue;
  5004. }
  5005. // Convert html string into DOM nodes
  5006. if ( typeof elem === "string" ) {
  5007. if ( !rhtml.test( elem ) ) {
  5008. elem = context.createTextNode( elem );
  5009. } else {
  5010. // Fix "XHTML"-style tags in all browsers
  5011. elem = elem.replace(rxhtmlTag, "<$1></$2>");
  5012. // Trim whitespace, otherwise indexOf won't work as expected
  5013. var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
  5014. wrap = wrapMap[ tag ] || wrapMap._default,
  5015. depth = wrap[0],
  5016. div = context.createElement("div");
  5017. // Go to html and back, then peel off extra wrappers
  5018. div.innerHTML = wrap[1] + elem + wrap[2];
  5019. // Move to the right depth
  5020. while ( depth-- ) {
  5021. div = div.lastChild;
  5022. }
  5023. // Remove IE's autoinserted <tbody> from table fragments
  5024. if ( !jQuery.support.tbody ) {
  5025. // String was a <table>, *may* have spurious <tbody>
  5026. var hasBody = rtbody.test(elem),
  5027. tbody = tag === "table" && !hasBody ?
  5028. div.firstChild && div.firstChild.childNodes :
  5029. // String was a bare <thead> or <tfoot>
  5030. wrap[1] === "<table>" && !hasBody ?
  5031. div.childNodes :
  5032. [];
  5033. for ( j = tbody.length - 1; j >= 0 ; --j ) {
  5034. if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
  5035. tbody[ j ].parentNode.removeChild( tbody[ j ] );
  5036. }
  5037. }
  5038. }
  5039. // IE completely kills leading whitespace when innerHTML is used
  5040. if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
  5041. div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
  5042. }
  5043. elem = div.childNodes;
  5044. }
  5045. }
  5046. // Resets defaultChecked for any radios and checkboxes
  5047. // about to be appended to the DOM in IE 6/7 (#8060)
  5048. var len;
  5049. if ( !jQuery.support.appendChecked ) {
  5050. if ( elem[0] && typeof (len = elem.length) === "number" ) {
  5051. for ( j = 0; j < len; j++ ) {
  5052. findInputs( elem[j] );
  5053. }
  5054. } else {
  5055. findInputs( elem );
  5056. }
  5057. }
  5058. if ( elem.nodeType ) {
  5059. ret.push( elem );
  5060. } else {
  5061. ret = jQuery.merge( ret, elem );
  5062. }
  5063. }
  5064. if ( fragment ) {
  5065. checkScriptType = function( elem ) {
  5066. return !elem.type || rscriptType.test( elem.type );
  5067. };
  5068. for ( i = 0; ret[i]; i++ ) {
  5069. if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
  5070. scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
  5071. } else {
  5072. if ( ret[i].nodeType === 1 ) {
  5073. var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType );
  5074. ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );
  5075. }
  5076. fragment.appendChild( ret[i] );
  5077. }
  5078. }
  5079. }
  5080. return ret;
  5081. },
  5082. cleanData: function( elems ) {
  5083. var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
  5084. deleteExpando = jQuery.support.deleteExpando;
  5085. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  5086. if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
  5087. continue;
  5088. }
  5089. id = elem[ jQuery.expando ];
  5090. if ( id ) {
  5091. data = cache[ id ] && cache[ id ][ internalKey ];
  5092. if ( data && data.events ) {
  5093. for ( var type in data.events ) {
  5094. if ( special[ type ] ) {
  5095. jQuery.event.remove( elem, type );
  5096. // This is a shortcut to avoid jQuery.event.remove's overhead
  5097. } else {
  5098. jQuery.removeEvent( elem, type, data.handle );
  5099. }
  5100. }
  5101. // Null the DOM reference to avoid IE6/7/8 leak (#7054)
  5102. if ( data.handle ) {
  5103. data.handle.elem = null;
  5104. }
  5105. }
  5106. if ( deleteExpando ) {
  5107. delete elem[ jQuery.expando ];
  5108. } else if ( elem.removeAttribute ) {
  5109. elem.removeAttribute( jQuery.expando );
  5110. }
  5111. delete cache[ id ];
  5112. }
  5113. }
  5114. }
  5115. });
  5116. function evalScript( i, elem ) {
  5117. if ( elem.src ) {
  5118. jQuery.ajax({
  5119. url: elem.src,
  5120. async: false,
  5121. dataType: "script"
  5122. });
  5123. } else {
  5124. jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) );
  5125. }
  5126. if ( elem.parentNode ) {
  5127. elem.parentNode.removeChild( elem );
  5128. }
  5129. }
  5130. var ralpha = /alpha\([^)]*\)/i,
  5131. ropacity = /opacity=([^)]*)/,
  5132. // fixed for IE9, see #8346
  5133. rupper = /([A-Z]|^ms)/g,
  5134. rnumpx = /^-?\d+(?:px)?$/i,
  5135. rnum = /^-?\d/,
  5136. rrelNum = /^([\-+])=([\-+.\de]+)/,
  5137. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5138. cssWidth = [ "Left", "Right" ],
  5139. cssHeight = [ "Top", "Bottom" ],
  5140. curCSS,
  5141. getComputedStyle,
  5142. currentStyle;
  5143. jQuery.fn.css = function( name, value ) {
  5144. // Setting 'undefined' is a no-op
  5145. if ( arguments.length === 2 && value === undefined ) {
  5146. return this;
  5147. }
  5148. return jQuery.access( this, name, value, true, function( elem, name, value ) {
  5149. return value !== undefined ?
  5150. jQuery.style( elem, name, value ) :
  5151. jQuery.css( elem, name );
  5152. });
  5153. };
  5154. jQuery.extend({
  5155. // Add in style property hooks for overriding the default
  5156. // behavior of getting and setting a style property
  5157. cssHooks: {
  5158. opacity: {
  5159. get: function( elem, computed ) {
  5160. if ( computed ) {
  5161. // We should always get a number back from opacity
  5162. var ret = curCSS( elem, "opacity", "opacity" );
  5163. return ret === "" ? "1" : ret;
  5164. } else {
  5165. return elem.style.opacity;
  5166. }
  5167. }
  5168. }
  5169. },
  5170. // Exclude the following css properties to add px
  5171. cssNumber: {
  5172. "fillOpacity": true,
  5173. "fontWeight": true,
  5174. "lineHeight": true,
  5175. "opacity": true,
  5176. "orphans": true,
  5177. "widows": true,
  5178. "zIndex": true,
  5179. "zoom": true
  5180. },
  5181. // Add in properties whose names you wish to fix before
  5182. // setting or getting the value
  5183. cssProps: {
  5184. // normalize float css property
  5185. "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
  5186. },
  5187. // Get and set the style property on a DOM Node
  5188. style: function( elem, name, value, extra ) {
  5189. // Don't set styles on text and comment nodes
  5190. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5191. return;
  5192. }
  5193. // Make sure that we're working with the right name
  5194. var ret, type, origName = jQuery.camelCase( name ),
  5195. style = elem.style, hooks = jQuery.cssHooks[ origName ];
  5196. name = jQuery.cssProps[ origName ] || origName;
  5197. // Check if we're setting a value
  5198. if ( value !== undefined ) {
  5199. type = typeof value;
  5200. // convert relative number strings (+= or -=) to relative numbers. #7345
  5201. if ( type === "string" && (ret = rrelNum.exec( value )) ) {
  5202. value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) );
  5203. // Fixes bug #9237
  5204. type = "number";
  5205. }
  5206. // Make sure that NaN and null values aren't set. See: #7116
  5207. if ( value == null || type === "number" && isNaN( value ) ) {
  5208. return;
  5209. }
  5210. // If a number was passed in, add 'px' to the (except for certain CSS properties)
  5211. if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
  5212. value += "px";
  5213. }
  5214. // If a hook was provided, use that value, otherwise just set the specified value
  5215. if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
  5216. // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
  5217. // Fixes bug #5509
  5218. try {
  5219. style[ name ] = value;
  5220. } catch(e) {}
  5221. }
  5222. } else {
  5223. // If a hook was provided get the non-computed value from there
  5224. if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
  5225. return ret;
  5226. }
  5227. // Otherwise just get the value from the style object
  5228. return style[ name ];
  5229. }
  5230. },
  5231. css: function( elem, name, extra ) {
  5232. var ret, hooks;
  5233. // Make sure that we're working with the right name
  5234. name = jQuery.camelCase( name );
  5235. hooks = jQuery.cssHooks[ name ];
  5236. name = jQuery.cssProps[ name ] || name;
  5237. // cssFloat needs a special treatment
  5238. if ( name === "cssFloat" ) {
  5239. name = "float";
  5240. }
  5241. // If a hook was provided get the computed value from there
  5242. if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
  5243. return ret;
  5244. // Otherwise, if a way to get the computed value exists, use that
  5245. } else if ( curCSS ) {
  5246. return curCSS( elem, name );
  5247. }
  5248. },
  5249. // A method for quickly swapping in/out CSS properties to get correct calculations
  5250. swap: function( elem, options, callback ) {
  5251. var old = {};
  5252. // Remember the old values, and insert the new ones
  5253. for ( var name in options ) {
  5254. old[ name ] = elem.style[ name ];
  5255. elem.style[ name ] = options[ name ];
  5256. }
  5257. callback.call( elem );
  5258. // Revert the old values
  5259. for ( name in options ) {
  5260. elem.style[ name ] = old[ name ];
  5261. }
  5262. }
  5263. });
  5264. // DEPRECATED, Use jQuery.css() instead
  5265. jQuery.curCSS = jQuery.css;
  5266. jQuery.each(["height", "width"], function( i, name ) {
  5267. jQuery.cssHooks[ name ] = {
  5268. get: function( elem, computed, extra ) {
  5269. var val;
  5270. if ( computed ) {
  5271. if ( elem.offsetWidth !== 0 ) {
  5272. return getWH( elem, name, extra );
  5273. } else {
  5274. jQuery.swap( elem, cssShow, function() {
  5275. val = getWH( elem, name, extra );
  5276. });
  5277. }
  5278. return val;
  5279. }
  5280. },
  5281. set: function( elem, value ) {
  5282. if ( rnumpx.test( value ) ) {
  5283. // ignore negative width and height values #1599
  5284. value = parseFloat( value );
  5285. if ( value >= 0 ) {
  5286. return value + "px";
  5287. }
  5288. } else {
  5289. return value;
  5290. }
  5291. }
  5292. };
  5293. });
  5294. if ( !jQuery.support.opacity ) {
  5295. jQuery.cssHooks.opacity = {
  5296. get: function( elem, computed ) {
  5297. // IE uses filters for opacity
  5298. return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ?
  5299. ( parseFloat( RegExp.$1 ) / 100 ) + "" :
  5300. computed ? "1" : "";
  5301. },
  5302. set: function( elem, value ) {
  5303. var style = elem.style,
  5304. currentStyle = elem.currentStyle,
  5305. opacity = jQuery.isNaN( value ) ? "" : "alpha(opacity=" + value * 100 + ")",
  5306. filter = currentStyle && currentStyle.filter || style.filter || "";
  5307. // IE has trouble with opacity if it does not have layout
  5308. // Force it by setting the zoom level
  5309. style.zoom = 1;
  5310. // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
  5311. if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) {
  5312. // Setting style.filter to null, "" & " " still leave "filter:" in the cssText
  5313. // if "filter:" is present at all, clearType is disabled, we want to avoid this
  5314. // style.removeAttribute is IE Only, but so apparently is this code path...
  5315. style.removeAttribute( "filter" );
  5316. // if there there is no filter style applied in a css rule, we are done
  5317. if ( currentStyle && !currentStyle.filter ) {
  5318. return;
  5319. }
  5320. }
  5321. // otherwise, set new filter values
  5322. style.filter = ralpha.test( filter ) ?
  5323. filter.replace( ralpha, opacity ) :
  5324. filter + " " + opacity;
  5325. }
  5326. };
  5327. }
  5328. jQuery(function() {
  5329. // This hook cannot be added until DOM ready because the support test
  5330. // for it is not run until after DOM ready
  5331. if ( !jQuery.support.reliableMarginRight ) {
  5332. jQuery.cssHooks.marginRight = {
  5333. get: function( elem, computed ) {
  5334. // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
  5335. // Work around by temporarily setting element display to inline-block
  5336. var ret;
  5337. jQuery.swap( elem, { "display": "inline-block" }, function() {
  5338. if ( computed ) {
  5339. ret = curCSS( elem, "margin-right", "marginRight" );
  5340. } else {
  5341. ret = elem.style.marginRight;
  5342. }
  5343. });
  5344. return ret;
  5345. }
  5346. };
  5347. }
  5348. });
  5349. if ( document.defaultView && document.defaultView.getComputedStyle ) {
  5350. getComputedStyle = function( elem, name ) {
  5351. var ret, defaultView, computedStyle;
  5352. name = name.replace( rupper, "-$1" ).toLowerCase();
  5353. if ( !(defaultView = elem.ownerDocument.defaultView) ) {
  5354. return undefined;
  5355. }
  5356. if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
  5357. ret = computedStyle.getPropertyValue( name );
  5358. if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
  5359. ret = jQuery.style( elem, name );
  5360. }
  5361. }
  5362. return ret;
  5363. };
  5364. }
  5365. if ( document.documentElement.currentStyle ) {
  5366. currentStyle = function( elem, name ) {
  5367. var left,
  5368. ret = elem.currentStyle && elem.currentStyle[ name ],
  5369. rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
  5370. style = elem.style;
  5371. // From the awesome hack by Dean Edwards
  5372. // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
  5373. // If we're not dealing with a regular pixel number
  5374. // but a number that has a weird ending, we need to convert it to pixels
  5375. if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
  5376. // Remember the original values
  5377. left = style.left;
  5378. // Put in the new values to get a computed value out
  5379. if ( rsLeft ) {
  5380. elem.runtimeStyle.left = elem.currentStyle.left;
  5381. }
  5382. style.left = name === "fontSize" ? "1em" : (ret || 0);
  5383. ret = style.pixelLeft + "px";
  5384. // Revert the changed values
  5385. style.left = left;
  5386. if ( rsLeft ) {
  5387. elem.runtimeStyle.left = rsLeft;
  5388. }
  5389. }
  5390. return ret === "" ? "auto" : ret;
  5391. };
  5392. }
  5393. curCSS = getComputedStyle || currentStyle;
  5394. function getWH( elem, name, extra ) {
  5395. // Start with offset property
  5396. var val = name === "width" ? elem.offsetWidth : elem.offsetHeight,
  5397. which = name === "width" ? cssWidth : cssHeight;
  5398. if ( val > 0 ) {
  5399. if ( extra !== "border" ) {
  5400. jQuery.each( which, function() {
  5401. if ( !extra ) {
  5402. val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
  5403. }
  5404. if ( extra === "margin" ) {
  5405. val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
  5406. } else {
  5407. val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
  5408. }
  5409. });
  5410. }
  5411. return val + "px";
  5412. }
  5413. // Fall back to computed then uncomputed css if necessary
  5414. val = curCSS( elem, name, name );
  5415. if ( val < 0 || val == null ) {
  5416. val = elem.style[ name ] || 0;
  5417. }
  5418. // Normalize "", auto, and prepare for extra
  5419. val = parseFloat( val ) || 0;
  5420. // Add padding, border, margin
  5421. if ( extra ) {
  5422. jQuery.each( which, function() {
  5423. val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0;
  5424. if ( extra !== "padding" ) {
  5425. val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0;
  5426. }
  5427. if ( extra === "margin" ) {
  5428. val += parseFloat( jQuery.css( elem, extra + this ) ) || 0;
  5429. }
  5430. });
  5431. }
  5432. return val + "px";
  5433. }
  5434. if ( jQuery.expr && jQuery.expr.filters ) {
  5435. jQuery.expr.filters.hidden = function( elem ) {
  5436. var width = elem.offsetWidth,
  5437. height = elem.offsetHeight;
  5438. return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
  5439. };
  5440. jQuery.expr.filters.visible = function( elem ) {
  5441. return !jQuery.expr.filters.hidden( elem );
  5442. };
  5443. }
  5444. var r20 = /%20/g,
  5445. rbracket = /\[\]$/,
  5446. rCRLF = /\r?\n/g,
  5447. rhash = /#.*$/,
  5448. rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
  5449. rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
  5450. // #7653, #8125, #8152: local protocol detection
  5451. rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
  5452. rnoContent = /^(?:GET|HEAD)$/,
  5453. rprotocol = /^\/\//,
  5454. rquery = /\?/,
  5455. rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
  5456. rselectTextarea = /^(?:select|textarea)/i,
  5457. rspacesAjax = /\s+/,
  5458. rts = /([?&])_=[^&]*/,
  5459. rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,
  5460. // Keep a copy of the old load method
  5461. _load = jQuery.fn.load,
  5462. /* Prefilters
  5463. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  5464. * 2) These are called:
  5465. * - BEFORE asking for a transport
  5466. * - AFTER param serialization (s.data is a string if s.processData is true)
  5467. * 3) key is the dataType
  5468. * 4) the catchall symbol "*" can be used
  5469. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  5470. */
  5471. prefilters = {},
  5472. /* Transports bindings
  5473. * 1) key is the dataType
  5474. * 2) the catchall symbol "*" can be used
  5475. * 3) selection will start with transport dataType and THEN go to "*" if needed
  5476. */
  5477. transports = {},
  5478. // Document location
  5479. ajaxLocation,
  5480. // Document location segments
  5481. ajaxLocParts,
  5482. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  5483. allTypes = ["*/"] + ["*"];
  5484. // #8138, IE may throw an exception when accessing
  5485. // a field from window.location if document.domain has been set
  5486. try {
  5487. ajaxLocation = location.href;
  5488. } catch( e ) {
  5489. // Use the href attribute of an A element
  5490. // since IE will modify it given document.location
  5491. ajaxLocation = document.createElement( "a" );
  5492. ajaxLocation.href = "";
  5493. ajaxLocation = ajaxLocation.href;
  5494. }
  5495. // Segment location into parts
  5496. ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
  5497. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  5498. function addToPrefiltersOrTransports( structure ) {
  5499. // dataTypeExpression is optional and defaults to "*"
  5500. return function( dataTypeExpression, func ) {
  5501. if ( typeof dataTypeExpression !== "string" ) {
  5502. func = dataTypeExpression;
  5503. dataTypeExpression = "*";
  5504. }
  5505. if ( jQuery.isFunction( func ) ) {
  5506. var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
  5507. i = 0,
  5508. length = dataTypes.length,
  5509. dataType,
  5510. list,
  5511. placeBefore;
  5512. // For each dataType in the dataTypeExpression
  5513. for(; i < length; i++ ) {
  5514. dataType = dataTypes[ i ];
  5515. // We control if we're asked to add before
  5516. // any existing element
  5517. placeBefore = /^\+/.test( dataType );
  5518. if ( placeBefore ) {
  5519. dataType = dataType.substr( 1 ) || "*";
  5520. }
  5521. list = structure[ dataType ] = structure[ dataType ] || [];
  5522. // then we add to the structure accordingly
  5523. list[ placeBefore ? "unshift" : "push" ]( func );
  5524. }
  5525. }
  5526. };
  5527. }
  5528. // Base inspection function for prefilters and transports
  5529. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
  5530. dataType /* internal */, inspected /* internal */ ) {
  5531. dataType = dataType || options.dataTypes[ 0 ];
  5532. inspected = inspected || {};
  5533. inspected[ dataType ] = true;
  5534. var list = structure[ dataType ],
  5535. i = 0,
  5536. length = list ? list.length : 0,
  5537. executeOnly = ( structure === prefilters ),
  5538. selection;
  5539. for(; i < length && ( executeOnly || !selection ); i++ ) {
  5540. selection = list[ i ]( options, originalOptions, jqXHR );
  5541. // If we got redirected to another dataType
  5542. // we try there if executing only and not done already
  5543. if ( typeof selection === "string" ) {
  5544. if ( !executeOnly || inspected[ selection ] ) {
  5545. selection = undefined;
  5546. } else {
  5547. options.dataTypes.unshift( selection );
  5548. selection = inspectPrefiltersOrTransports(
  5549. structure, options, originalOptions, jqXHR, selection, inspected );
  5550. }
  5551. }
  5552. }
  5553. // If we're only executing or nothing was selected
  5554. // we try the catchall dataType if not done already
  5555. if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
  5556. selection = inspectPrefiltersOrTransports(
  5557. structure, options, originalOptions, jqXHR, "*", inspected );
  5558. }
  5559. // unnecessary when only executing (prefilters)
  5560. // but it'll be ignored by the caller in that case
  5561. return selection;
  5562. }
  5563. // A special extend for ajax options
  5564. // that takes "flat" options (not to be deep extended)
  5565. // Fixes #9887
  5566. function ajaxExtend( target, src ) {
  5567. var key, deep,
  5568. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  5569. for( key in src ) {
  5570. if ( src[ key ] !== undefined ) {
  5571. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  5572. }
  5573. }
  5574. if ( deep ) {
  5575. jQuery.extend( true, target, deep );
  5576. }
  5577. }
  5578. jQuery.fn.extend({
  5579. load: function( url, params, callback ) {
  5580. if ( typeof url !== "string" && _load ) {
  5581. return _load.apply( this, arguments );
  5582. // Don't do a request if no elements are being requested
  5583. } else if ( !this.length ) {
  5584. return this;
  5585. }
  5586. var off = url.indexOf( " " );
  5587. if ( off >= 0 ) {
  5588. var selector = url.slice( off, url.length );
  5589. url = url.slice( 0, off );
  5590. }
  5591. // Default to a GET request
  5592. var type = "GET";
  5593. // If the second parameter was provided
  5594. if ( params ) {
  5595. // If it's a function
  5596. if ( jQuery.isFunction( params ) ) {
  5597. // We assume that it's the callback
  5598. callback = params;
  5599. params = undefined;
  5600. // Otherwise, build a param string
  5601. } else if ( typeof params === "object" ) {
  5602. params = jQuery.param( params, jQuery.ajaxSettings.traditional );
  5603. type = "POST";
  5604. }
  5605. }
  5606. var self = this;
  5607. // Request the remote document
  5608. jQuery.ajax({
  5609. url: url,
  5610. type: type,
  5611. dataType: "html",
  5612. data: params,
  5613. // Complete callback (responseText is used internally)
  5614. complete: function( jqXHR, status, responseText ) {
  5615. // Store the response as specified by the jqXHR object
  5616. responseText = jqXHR.responseText;
  5617. // If successful, inject the HTML into all the matched elements
  5618. if ( jqXHR.isResolved() ) {
  5619. // #4825: Get the actual response in case
  5620. // a dataFilter is present in ajaxSettings
  5621. jqXHR.done(function( r ) {
  5622. responseText = r;
  5623. });
  5624. // See if a selector was specified
  5625. self.html( selector ?
  5626. // Create a dummy div to hold the results
  5627. jQuery("<div>")
  5628. // inject the contents of the document in, removing the scripts
  5629. // to avoid any 'Permission Denied' errors in IE
  5630. .append(responseText.replace(rscript, ""))
  5631. // Locate the specified elements
  5632. .find(selector) :
  5633. // If not, just inject the full result
  5634. responseText );
  5635. }
  5636. if ( callback ) {
  5637. self.each( callback, [ responseText, status, jqXHR ] );
  5638. }
  5639. }
  5640. });
  5641. return this;
  5642. },
  5643. serialize: function() {
  5644. return jQuery.param( this.serializeArray() );
  5645. },
  5646. serializeArray: function() {
  5647. return this.map(function(){
  5648. return this.elements ? jQuery.makeArray( this.elements ) : this;
  5649. })
  5650. .filter(function(){
  5651. return this.name && !this.disabled &&
  5652. ( this.checked || rselectTextarea.test( this.nodeName ) ||
  5653. rinput.test( this.type ) );
  5654. })
  5655. .map(function( i, elem ){
  5656. var val = jQuery( this ).val();
  5657. return val == null ?
  5658. null :
  5659. jQuery.isArray( val ) ?
  5660. jQuery.map( val, function( val, i ){
  5661. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  5662. }) :
  5663. { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  5664. }).get();
  5665. }
  5666. });
  5667. // Attach a bunch of functions for handling common AJAX events
  5668. jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
  5669. jQuery.fn[ o ] = function( f ){
  5670. return this.bind( o, f );
  5671. };
  5672. });
  5673. jQuery.each( [ "get", "post" ], function( i, method ) {
  5674. jQuery[ method ] = function( url, data, callback, type ) {
  5675. // shift arguments if data argument was omitted
  5676. if ( jQuery.isFunction( data ) ) {
  5677. type = type || callback;
  5678. callback = data;
  5679. data = undefined;
  5680. }
  5681. return jQuery.ajax({
  5682. type: method,
  5683. url: url,
  5684. data: data,
  5685. success: callback,
  5686. dataType: type
  5687. });
  5688. };
  5689. });
  5690. jQuery.extend({
  5691. getScript: function( url, callback ) {
  5692. return jQuery.get( url, undefined, callback, "script" );
  5693. },
  5694. getJSON: function( url, data, callback ) {
  5695. return jQuery.get( url, data, callback, "json" );
  5696. },
  5697. // Creates a full fledged settings object into target
  5698. // with both ajaxSettings and settings fields.
  5699. // If target is omitted, writes into ajaxSettings.
  5700. ajaxSetup: function( target, settings ) {
  5701. if ( settings ) {
  5702. // Building a settings object
  5703. ajaxExtend( target, jQuery.ajaxSettings );
  5704. } else {
  5705. // Extending ajaxSettings
  5706. settings = target;
  5707. target = jQuery.ajaxSettings;
  5708. }
  5709. ajaxExtend( target, settings );
  5710. return target;
  5711. },
  5712. ajaxSettings: {
  5713. url: ajaxLocation,
  5714. isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
  5715. global: true,
  5716. type: "GET",
  5717. contentType: "application/x-www-form-urlencoded",
  5718. processData: true,
  5719. async: true,
  5720. /*
  5721. timeout: 0,
  5722. data: null,
  5723. dataType: null,
  5724. username: null,
  5725. password: null,
  5726. cache: null,
  5727. traditional: false,
  5728. headers: {},
  5729. */
  5730. accepts: {
  5731. xml: "application/xml, text/xml",
  5732. html: "text/html",
  5733. text: "text/plain",
  5734. json: "application/json, text/javascript",
  5735. "*": allTypes
  5736. },
  5737. contents: {
  5738. xml: /xml/,
  5739. html: /html/,
  5740. json: /json/
  5741. },
  5742. responseFields: {
  5743. xml: "responseXML",
  5744. text: "responseText"
  5745. },
  5746. // List of data converters
  5747. // 1) key format is "source_type destination_type" (a single space in-between)
  5748. // 2) the catchall symbol "*" can be used for source_type
  5749. converters: {
  5750. // Convert anything to text
  5751. "* text": window.String,
  5752. // Text to html (true = no transformation)
  5753. "text html": true,
  5754. // Evaluate text as a json expression
  5755. "text json": jQuery.parseJSON,
  5756. // Parse text as xml
  5757. "text xml": jQuery.parseXML
  5758. },
  5759. // For options that shouldn't be deep extended:
  5760. // you can add your own custom options here if
  5761. // and when you create one that shouldn't be
  5762. // deep extended (see ajaxExtend)
  5763. flatOptions: {
  5764. context: true,
  5765. url: true
  5766. }
  5767. },
  5768. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  5769. ajaxTransport: addToPrefiltersOrTransports( transports ),
  5770. // Main method
  5771. ajax: function( url, options ) {
  5772. // If url is an object, simulate pre-1.5 signature
  5773. if ( typeof url === "object" ) {
  5774. options = url;
  5775. url = undefined;
  5776. }
  5777. // Force options to be an object
  5778. options = options || {};
  5779. var // Create the final options object
  5780. s = jQuery.ajaxSetup( {}, options ),
  5781. // Callbacks context
  5782. callbackContext = s.context || s,
  5783. // Context for global events
  5784. // It's the callbackContext if one was provided in the options
  5785. // and if it's a DOM node or a jQuery collection
  5786. globalEventContext = callbackContext !== s &&
  5787. ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
  5788. jQuery( callbackContext ) : jQuery.event,
  5789. // Deferreds
  5790. deferred = jQuery.Deferred(),
  5791. completeDeferred = jQuery._Deferred(),
  5792. // Status-dependent callbacks
  5793. statusCode = s.statusCode || {},
  5794. // ifModified key
  5795. ifModifiedKey,
  5796. // Headers (they are sent all at once)
  5797. requestHeaders = {},
  5798. requestHeadersNames = {},
  5799. // Response headers
  5800. responseHeadersString,
  5801. responseHeaders,
  5802. // transport
  5803. transport,
  5804. // timeout handle
  5805. timeoutTimer,
  5806. // Cross-domain detection vars
  5807. parts,
  5808. // The jqXHR state
  5809. state = 0,
  5810. // To know if global events are to be dispatched
  5811. fireGlobals,
  5812. // Loop variable
  5813. i,
  5814. // Fake xhr
  5815. jqXHR = {
  5816. readyState: 0,
  5817. // Caches the header
  5818. setRequestHeader: function( name, value ) {
  5819. if ( !state ) {
  5820. var lname = name.toLowerCase();
  5821. name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name;
  5822. requestHeaders[ name ] = value;
  5823. }
  5824. return this;
  5825. },
  5826. // Raw string
  5827. getAllResponseHeaders: function() {
  5828. return state === 2 ? responseHeadersString : null;
  5829. },
  5830. // Builds headers hashtable if needed
  5831. getResponseHeader: function( key ) {
  5832. var match;
  5833. if ( state === 2 ) {
  5834. if ( !responseHeaders ) {
  5835. responseHeaders = {};
  5836. while( ( match = rheaders.exec( responseHeadersString ) ) ) {
  5837. responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
  5838. }
  5839. }
  5840. match = responseHeaders[ key.toLowerCase() ];
  5841. }
  5842. return match === undefined ? null : match;
  5843. },
  5844. // Overrides response content-type header
  5845. overrideMimeType: function( type ) {
  5846. if ( !state ) {
  5847. s.mimeType = type;
  5848. }
  5849. return this;
  5850. },
  5851. // Cancel the request
  5852. abort: function( statusText ) {
  5853. statusText = statusText || "abort";
  5854. if ( transport ) {
  5855. transport.abort( statusText );
  5856. }
  5857. done( 0, statusText );
  5858. return this;
  5859. }
  5860. };
  5861. // Callback for when everything is done
  5862. // It is defined here because jslint complains if it is declared
  5863. // at the end of the function (which would be more logical and readable)
  5864. function done( status, nativeStatusText, responses, headers ) {
  5865. // Called once
  5866. if ( state === 2 ) {
  5867. return;
  5868. }
  5869. // State is "done" now
  5870. state = 2;
  5871. // Clear timeout if it exists
  5872. if ( timeoutTimer ) {
  5873. clearTimeout( timeoutTimer );
  5874. }
  5875. // Dereference transport for early garbage collection
  5876. // (no matter how long the jqXHR object will be used)
  5877. transport = undefined;
  5878. // Cache response headers
  5879. responseHeadersString = headers || "";
  5880. // Set readyState
  5881. jqXHR.readyState = status > 0 ? 4 : 0;
  5882. var isSuccess,
  5883. success,
  5884. error,
  5885. statusText = nativeStatusText,
  5886. response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
  5887. lastModified,
  5888. etag;
  5889. // If successful, handle type chaining
  5890. if ( status >= 200 && status < 300 || status === 304 ) {
  5891. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  5892. if ( s.ifModified ) {
  5893. if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
  5894. jQuery.lastModified[ ifModifiedKey ] = lastModified;
  5895. }
  5896. if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
  5897. jQuery.etag[ ifModifiedKey ] = etag;
  5898. }
  5899. }
  5900. // If not modified
  5901. if ( status === 304 ) {
  5902. statusText = "notmodified";
  5903. isSuccess = true;
  5904. // If we have data
  5905. } else {
  5906. try {
  5907. success = ajaxConvert( s, response );
  5908. statusText = "success";
  5909. isSuccess = true;
  5910. } catch(e) {
  5911. // We have a parsererror
  5912. statusText = "parsererror";
  5913. error = e;
  5914. }
  5915. }
  5916. } else {
  5917. // We extract error from statusText
  5918. // then normalize statusText and status for non-aborts
  5919. error = statusText;
  5920. if( !statusText || status ) {
  5921. statusText = "error";
  5922. if ( status < 0 ) {
  5923. status = 0;
  5924. }
  5925. }
  5926. }
  5927. // Set data for the fake xhr object
  5928. jqXHR.status = status;
  5929. jqXHR.statusText = "" + ( nativeStatusText || statusText );
  5930. // Success/Error
  5931. if ( isSuccess ) {
  5932. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  5933. } else {
  5934. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  5935. }
  5936. // Status-dependent callbacks
  5937. jqXHR.statusCode( statusCode );
  5938. statusCode = undefined;
  5939. if ( fireGlobals ) {
  5940. globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
  5941. [ jqXHR, s, isSuccess ? success : error ] );
  5942. }
  5943. // Complete
  5944. completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
  5945. if ( fireGlobals ) {
  5946. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  5947. // Handle the global AJAX counter
  5948. if ( !( --jQuery.active ) ) {
  5949. jQuery.event.trigger( "ajaxStop" );
  5950. }
  5951. }
  5952. }
  5953. // Attach deferreds
  5954. deferred.promise( jqXHR );
  5955. jqXHR.success = jqXHR.done;
  5956. jqXHR.error = jqXHR.fail;
  5957. jqXHR.complete = completeDeferred.done;
  5958. // Status-dependent callbacks
  5959. jqXHR.statusCode = function( map ) {
  5960. if ( map ) {
  5961. var tmp;
  5962. if ( state < 2 ) {
  5963. for( tmp in map ) {
  5964. statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
  5965. }
  5966. } else {
  5967. tmp = map[ jqXHR.status ];
  5968. jqXHR.then( tmp, tmp );
  5969. }
  5970. }
  5971. return this;
  5972. };
  5973. // Remove hash character (#7531: and string promotion)
  5974. // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
  5975. // We also use the url parameter if available
  5976. s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
  5977. // Extract dataTypes list
  5978. s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
  5979. // Determine if a cross-domain request is in order
  5980. if ( s.crossDomain == null ) {
  5981. parts = rurl.exec( s.url.toLowerCase() );
  5982. s.crossDomain = !!( parts &&
  5983. ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
  5984. ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
  5985. ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
  5986. );
  5987. }
  5988. // Convert data if not already a string
  5989. if ( s.data && s.processData && typeof s.data !== "string" ) {
  5990. s.data = jQuery.param( s.data, s.traditional );
  5991. }
  5992. // Apply prefilters
  5993. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  5994. // If request was aborted inside a prefiler, stop there
  5995. if ( state === 2 ) {
  5996. return false;
  5997. }
  5998. // We can fire global events as of now if asked to
  5999. fireGlobals = s.global;
  6000. // Uppercase the type
  6001. s.type = s.type.toUpperCase();
  6002. // Determine if request has content
  6003. s.hasContent = !rnoContent.test( s.type );
  6004. // Watch for a new set of requests
  6005. if ( fireGlobals && jQuery.active++ === 0 ) {
  6006. jQuery.event.trigger( "ajaxStart" );
  6007. }
  6008. // More options handling for requests with no content
  6009. if ( !s.hasContent ) {
  6010. // If data is available, append data to url
  6011. if ( s.data ) {
  6012. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
  6013. // #9682: remove data so that it's not used in an eventual retry
  6014. delete s.data;
  6015. }
  6016. // Get ifModifiedKey before adding the anti-cache parameter
  6017. ifModifiedKey = s.url;
  6018. // Add anti-cache in url if needed
  6019. if ( s.cache === false ) {
  6020. var ts = jQuery.now(),
  6021. // try replacing _= if it is there
  6022. ret = s.url.replace( rts, "$1_=" + ts );
  6023. // if nothing was replaced, add timestamp to the end
  6024. s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
  6025. }
  6026. }
  6027. // Set the correct header, if data is being sent
  6028. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  6029. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  6030. }
  6031. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  6032. if ( s.ifModified ) {
  6033. ifModifiedKey = ifModifiedKey || s.url;
  6034. if ( jQuery.lastModified[ ifModifiedKey ] ) {
  6035. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] );
  6036. }
  6037. if ( jQuery.etag[ ifModifiedKey ] ) {
  6038. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] );
  6039. }
  6040. }
  6041. // Set the Accepts header for the server, depending on the dataType
  6042. jqXHR.setRequestHeader(
  6043. "Accept",
  6044. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
  6045. s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  6046. s.accepts[ "*" ]
  6047. );
  6048. // Check for headers option
  6049. for ( i in s.headers ) {
  6050. jqXHR.setRequestHeader( i, s.headers[ i ] );
  6051. }
  6052. // Allow custom headers/mimetypes and early abort
  6053. if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
  6054. // Abort if not done already
  6055. jqXHR.abort();
  6056. return false;
  6057. }
  6058. // Install callbacks on deferreds
  6059. for ( i in { success: 1, error: 1, complete: 1 } ) {
  6060. jqXHR[ i ]( s[ i ] );
  6061. }
  6062. // Get transport
  6063. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  6064. // If no transport, we auto-abort
  6065. if ( !transport ) {
  6066. done( -1, "No Transport" );
  6067. } else {
  6068. jqXHR.readyState = 1;
  6069. // Send global event
  6070. if ( fireGlobals ) {
  6071. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  6072. }
  6073. // Timeout
  6074. if ( s.async && s.timeout > 0 ) {
  6075. timeoutTimer = setTimeout( function(){
  6076. jqXHR.abort( "timeout" );
  6077. }, s.timeout );
  6078. }
  6079. try {
  6080. state = 1;
  6081. transport.send( requestHeaders, done );
  6082. } catch (e) {
  6083. // Propagate exception as error if not done
  6084. if ( state < 2 ) {
  6085. done( -1, e );
  6086. // Simply rethrow otherwise
  6087. } else {
  6088. jQuery.error( e );
  6089. }
  6090. }
  6091. }
  6092. return jqXHR;
  6093. },
  6094. // Serialize an array of form elements or a set of
  6095. // key/values into a query string
  6096. param: function( a, traditional ) {
  6097. var s = [],
  6098. add = function( key, value ) {
  6099. // If value is a function, invoke it and return its value
  6100. value = jQuery.isFunction( value ) ? value() : value;
  6101. s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
  6102. };
  6103. // Set traditional to true for jQuery <= 1.3.2 behavior.
  6104. if ( traditional === undefined ) {
  6105. traditional = jQuery.ajaxSettings.traditional;
  6106. }
  6107. // If an array was passed in, assume that it is an array of form elements.
  6108. if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  6109. // Serialize the form elements
  6110. jQuery.each( a, function() {
  6111. add( this.name, this.value );
  6112. });
  6113. } else {
  6114. // If traditional, encode the "old" way (the way 1.3.2 or older
  6115. // did it), otherwise encode params recursively.
  6116. for ( var prefix in a ) {
  6117. buildParams( prefix, a[ prefix ], traditional, add );
  6118. }
  6119. }
  6120. // Return the resulting serialization
  6121. return s.join( "&" ).replace( r20, "+" );
  6122. }
  6123. });
  6124. function buildParams( prefix, obj, traditional, add ) {
  6125. if ( jQuery.isArray( obj ) ) {
  6126. // Serialize array item.
  6127. jQuery.each( obj, function( i, v ) {
  6128. if ( traditional || rbracket.test( prefix ) ) {
  6129. // Treat each array item as a scalar.
  6130. add( prefix, v );
  6131. } else {
  6132. // If array item is non-scalar (array or object), encode its
  6133. // numeric index to resolve deserialization ambiguity issues.
  6134. // Note that rack (as of 1.0.0) can't currently deserialize
  6135. // nested arrays properly, and attempting to do so may cause
  6136. // a server error. Possible fixes are to modify rack's
  6137. // deserialization algorithm or to provide an option or flag
  6138. // to force array serialization to be shallow.
  6139. buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
  6140. }
  6141. });
  6142. } else if ( !traditional && obj != null && typeof obj === "object" ) {
  6143. // Serialize object item.
  6144. for ( var name in obj ) {
  6145. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  6146. }
  6147. } else {
  6148. // Serialize scalar item.
  6149. add( prefix, obj );
  6150. }
  6151. }
  6152. // This is still on the jQuery object... for now
  6153. // Want to move this to jQuery.ajax some day
  6154. jQuery.extend({
  6155. // Counter for holding the number of active queries
  6156. active: 0,
  6157. // Last-Modified header cache for next request
  6158. lastModified: {},
  6159. etag: {}
  6160. });
  6161. /* Handles responses to an ajax request:
  6162. * - sets all responseXXX fields accordingly
  6163. * - finds the right dataType (mediates between content-type and expected dataType)
  6164. * - returns the corresponding response
  6165. */
  6166. function ajaxHandleResponses( s, jqXHR, responses ) {
  6167. var contents = s.contents,
  6168. dataTypes = s.dataTypes,
  6169. responseFields = s.responseFields,
  6170. ct,
  6171. type,
  6172. finalDataType,
  6173. firstDataType;
  6174. // Fill responseXXX fields
  6175. for( type in responseFields ) {
  6176. if ( type in responses ) {
  6177. jqXHR[ responseFields[type] ] = responses[ type ];
  6178. }
  6179. }
  6180. // Remove auto dataType and get content-type in the process
  6181. while( dataTypes[ 0 ] === "*" ) {
  6182. dataTypes.shift();
  6183. if ( ct === undefined ) {
  6184. ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
  6185. }
  6186. }
  6187. // Check if we're dealing with a known content-type
  6188. if ( ct ) {
  6189. for ( type in contents ) {
  6190. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  6191. dataTypes.unshift( type );
  6192. break;
  6193. }
  6194. }
  6195. }
  6196. // Check to see if we have a response for the expected dataType
  6197. if ( dataTypes[ 0 ] in responses ) {
  6198. finalDataType = dataTypes[ 0 ];
  6199. } else {
  6200. // Try convertible dataTypes
  6201. for ( type in responses ) {
  6202. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
  6203. finalDataType = type;
  6204. break;
  6205. }
  6206. if ( !firstDataType ) {
  6207. firstDataType = type;
  6208. }
  6209. }
  6210. // Or just use first one
  6211. finalDataType = finalDataType || firstDataType;
  6212. }
  6213. // If we found a dataType
  6214. // We add the dataType to the list if needed
  6215. // and return the corresponding response
  6216. if ( finalDataType ) {
  6217. if ( finalDataType !== dataTypes[ 0 ] ) {
  6218. dataTypes.unshift( finalDataType );
  6219. }
  6220. return responses[ finalDataType ];
  6221. }
  6222. }
  6223. // Chain conversions given the request and the original response
  6224. function ajaxConvert( s, response ) {
  6225. // Apply the dataFilter if provided
  6226. if ( s.dataFilter ) {
  6227. response = s.dataFilter( response, s.dataType );
  6228. }
  6229. var dataTypes = s.dataTypes,
  6230. converters = {},
  6231. i,
  6232. key,
  6233. length = dataTypes.length,
  6234. tmp,
  6235. // Current and previous dataTypes
  6236. current = dataTypes[ 0 ],
  6237. prev,
  6238. // Conversion expression
  6239. conversion,
  6240. // Conversion function
  6241. conv,
  6242. // Conversion functions (transitive conversion)
  6243. conv1,
  6244. conv2;
  6245. // For each dataType in the chain
  6246. for( i = 1; i < length; i++ ) {
  6247. // Create converters map
  6248. // with lowercased keys
  6249. if ( i === 1 ) {
  6250. for( key in s.converters ) {
  6251. if( typeof key === "string" ) {
  6252. converters[ key.toLowerCase() ] = s.converters[ key ];
  6253. }
  6254. }
  6255. }
  6256. // Get the dataTypes
  6257. prev = current;
  6258. current = dataTypes[ i ];
  6259. // If current is auto dataType, update it to prev
  6260. if( current === "*" ) {
  6261. current = prev;
  6262. // If no auto and dataTypes are actually different
  6263. } else if ( prev !== "*" && prev !== current ) {
  6264. // Get the converter
  6265. conversion = prev + " " + current;
  6266. conv = converters[ conversion ] || converters[ "* " + current ];
  6267. // If there is no direct converter, search transitively
  6268. if ( !conv ) {
  6269. conv2 = undefined;
  6270. for( conv1 in converters ) {
  6271. tmp = conv1.split( " " );
  6272. if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
  6273. conv2 = converters[ tmp[1] + " " + current ];
  6274. if ( conv2 ) {
  6275. conv1 = converters[ conv1 ];
  6276. if ( conv1 === true ) {
  6277. conv = conv2;
  6278. } else if ( conv2 === true ) {
  6279. conv = conv1;
  6280. }
  6281. break;
  6282. }
  6283. }
  6284. }
  6285. }
  6286. // If we found no converter, dispatch an error
  6287. if ( !( conv || conv2 ) ) {
  6288. jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
  6289. }
  6290. // If found converter is not an equivalence
  6291. if ( conv !== true ) {
  6292. // Convert with 1 or 2 converters accordingly
  6293. response = conv ? conv( response ) : conv2( conv1(response) );
  6294. }
  6295. }
  6296. }
  6297. return response;
  6298. }
  6299. var jsc = jQuery.now(),
  6300. jsre = /(\=)\?(&|$)|\?\?/i;
  6301. // Default jsonp settings
  6302. jQuery.ajaxSetup({
  6303. jsonp: "callback",
  6304. jsonpCallback: function() {
  6305. return jQuery.expando + "_" + ( jsc++ );
  6306. }
  6307. });
  6308. // Detect, normalize options and install callbacks for jsonp requests
  6309. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  6310. var inspectData = s.contentType === "application/x-www-form-urlencoded" &&
  6311. ( typeof s.data === "string" );
  6312. if ( s.dataTypes[ 0 ] === "jsonp" ||
  6313. s.jsonp !== false && ( jsre.test( s.url ) ||
  6314. inspectData && jsre.test( s.data ) ) ) {
  6315. var responseContainer,
  6316. jsonpCallback = s.jsonpCallback =
  6317. jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
  6318. previous = window[ jsonpCallback ],
  6319. url = s.url,
  6320. data = s.data,
  6321. replace = "$1" + jsonpCallback + "$2";
  6322. if ( s.jsonp !== false ) {
  6323. url = url.replace( jsre, replace );
  6324. if ( s.url === url ) {
  6325. if ( inspectData ) {
  6326. data = data.replace( jsre, replace );
  6327. }
  6328. if ( s.data === data ) {
  6329. // Add callback manually
  6330. url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
  6331. }
  6332. }
  6333. }
  6334. s.url = url;
  6335. s.data = data;
  6336. // Install callback
  6337. window[ jsonpCallback ] = function( response ) {
  6338. responseContainer = [ response ];
  6339. };
  6340. // Clean-up function
  6341. jqXHR.always(function() {
  6342. // Set callback back to previous value
  6343. window[ jsonpCallback ] = previous;
  6344. // Call if it was a function and we have a response
  6345. if ( responseContainer && jQuery.isFunction( previous ) ) {
  6346. window[ jsonpCallback ]( responseContainer[ 0 ] );
  6347. }
  6348. });
  6349. // Use data converter to retrieve json after script execution
  6350. s.converters["script json"] = function() {
  6351. if ( !responseContainer ) {
  6352. jQuery.error( jsonpCallback + " was not called" );
  6353. }
  6354. return responseContainer[ 0 ];
  6355. };
  6356. // force json dataType
  6357. s.dataTypes[ 0 ] = "json";
  6358. // Delegate to script
  6359. return "script";
  6360. }
  6361. });
  6362. // Install script dataType
  6363. jQuery.ajaxSetup({
  6364. accepts: {
  6365. script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
  6366. },
  6367. contents: {
  6368. script: /javascript|ecmascript/
  6369. },
  6370. converters: {
  6371. "text script": function( text ) {
  6372. jQuery.globalEval( text );
  6373. return text;
  6374. }
  6375. }
  6376. });
  6377. // Handle cache's special case and global
  6378. jQuery.ajaxPrefilter( "script", function( s ) {
  6379. if ( s.cache === undefined ) {
  6380. s.cache = false;
  6381. }
  6382. if ( s.crossDomain ) {
  6383. s.type = "GET";
  6384. s.global = false;
  6385. }
  6386. });
  6387. // Bind script tag hack transport
  6388. jQuery.ajaxTransport( "script", function(s) {
  6389. // This transport only deals with cross domain requests
  6390. if ( s.crossDomain ) {
  6391. var script,
  6392. head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
  6393. return {
  6394. send: function( _, callback ) {
  6395. script = document.createElement( "script" );
  6396. script.async = "async";
  6397. if ( s.scriptCharset ) {
  6398. script.charset = s.scriptCharset;
  6399. }
  6400. script.src = s.url;
  6401. // Attach handlers for all browsers
  6402. script.onload = script.onreadystatechange = function( _, isAbort ) {
  6403. if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) {
  6404. // Handle memory leak in IE
  6405. script.onload = script.onreadystatechange = null;
  6406. // Remove the script
  6407. if ( head && script.parentNode ) {
  6408. head.removeChild( script );
  6409. }
  6410. // Dereference the script
  6411. script = undefined;
  6412. // Callback if not abort
  6413. if ( !isAbort ) {
  6414. callback( 200, "success" );
  6415. }
  6416. }
  6417. };
  6418. // Use insertBefore instead of appendChild to circumvent an IE6 bug.
  6419. // This arises when a base node is used (#2709 and #4378).
  6420. head.insertBefore( script, head.firstChild );
  6421. },
  6422. abort: function() {
  6423. if ( script ) {
  6424. script.onload( 0, 1 );
  6425. }
  6426. }
  6427. };
  6428. }
  6429. });
  6430. var // #5280: Internet Explorer will keep connections alive if we don't abort on unload
  6431. xhrOnUnloadAbort = window.ActiveXObject ? function() {
  6432. // Abort all pending requests
  6433. for ( var key in xhrCallbacks ) {
  6434. xhrCallbacks[ key ]( 0, 1 );
  6435. }
  6436. } : false,
  6437. xhrId = 0,
  6438. xhrCallbacks;
  6439. // Functions to create xhrs
  6440. function createStandardXHR() {
  6441. try {
  6442. return new window.XMLHttpRequest();
  6443. } catch( e ) {}
  6444. }
  6445. function createActiveXHR() {
  6446. try {
  6447. return new window.ActiveXObject( "Microsoft.XMLHTTP" );
  6448. } catch( e ) {}
  6449. }
  6450. // Create the request object
  6451. // (This is still attached to ajaxSettings for backward compatibility)
  6452. jQuery.ajaxSettings.xhr = window.ActiveXObject ?
  6453. /* Microsoft failed to properly
  6454. * implement the XMLHttpRequest in IE7 (can't request local files),
  6455. * so we use the ActiveXObject when it is available
  6456. * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
  6457. * we need a fallback.
  6458. */
  6459. function() {
  6460. return !this.isLocal && createStandardXHR() || createActiveXHR();
  6461. } :
  6462. // For all other browsers, use the standard XMLHttpRequest object
  6463. createStandardXHR;
  6464. // Determine support properties
  6465. (function( xhr ) {
  6466. jQuery.extend( jQuery.support, {
  6467. ajax: !!xhr,
  6468. cors: !!xhr && ( "withCredentials" in xhr )
  6469. });
  6470. })( jQuery.ajaxSettings.xhr() );
  6471. // Create transport if the browser can provide an xhr
  6472. if ( jQuery.support.ajax ) {
  6473. jQuery.ajaxTransport(function( s ) {
  6474. // Cross domain only allowed if supported through XMLHttpRequest
  6475. if ( !s.crossDomain || jQuery.support.cors ) {
  6476. var callback;
  6477. return {
  6478. send: function( headers, complete ) {
  6479. // Get a new xhr
  6480. var xhr = s.xhr(),
  6481. handle,
  6482. i;
  6483. // Open the socket
  6484. // Passing null username, generates a login popup on Opera (#2865)
  6485. if ( s.username ) {
  6486. xhr.open( s.type, s.url, s.async, s.username, s.password );
  6487. } else {
  6488. xhr.open( s.type, s.url, s.async );
  6489. }
  6490. // Apply custom fields if provided
  6491. if ( s.xhrFields ) {
  6492. for ( i in s.xhrFields ) {
  6493. xhr[ i ] = s.xhrFields[ i ];
  6494. }
  6495. }
  6496. // Override mime type if needed
  6497. if ( s.mimeType && xhr.overrideMimeType ) {
  6498. xhr.overrideMimeType( s.mimeType );
  6499. }
  6500. // X-Requested-With header
  6501. // For cross-domain requests, seeing as conditions for a preflight are
  6502. // akin to a jigsaw puzzle, we simply never set it to be sure.
  6503. // (it can always be set on a per-request basis or even using ajaxSetup)
  6504. // For same-domain requests, won't change header if already provided.
  6505. if ( !s.crossDomain && !headers["X-Requested-With"] ) {
  6506. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  6507. }
  6508. // Need an extra try/catch for cross domain requests in Firefox 3
  6509. try {
  6510. for ( i in headers ) {
  6511. xhr.setRequestHeader( i, headers[ i ] );
  6512. }
  6513. } catch( _ ) {}
  6514. // Do send the request
  6515. // This may raise an exception which is actually
  6516. // handled in jQuery.ajax (so no try/catch here)
  6517. xhr.send( ( s.hasContent && s.data ) || null );
  6518. // Listener
  6519. callback = function( _, isAbort ) {
  6520. var status,
  6521. statusText,
  6522. responseHeaders,
  6523. responses,
  6524. xml;
  6525. // Firefox throws exceptions when accessing properties
  6526. // of an xhr when a network error occured
  6527. // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
  6528. try {
  6529. // Was never called and is aborted or complete
  6530. if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
  6531. // Only called once
  6532. callback = undefined;
  6533. // Do not keep as active anymore
  6534. if ( handle ) {
  6535. xhr.onreadystatechange = jQuery.noop;
  6536. if ( xhrOnUnloadAbort ) {
  6537. delete xhrCallbacks[ handle ];
  6538. }
  6539. }
  6540. // If it's an abort
  6541. if ( isAbort ) {
  6542. // Abort it manually if needed
  6543. if ( xhr.readyState !== 4 ) {
  6544. xhr.abort();
  6545. }
  6546. } else {
  6547. status = xhr.status;
  6548. responseHeaders = xhr.getAllResponseHeaders();
  6549. responses = {};
  6550. xml = xhr.responseXML;
  6551. // Construct response list
  6552. if ( xml && xml.documentElement /* #4958 */ ) {
  6553. responses.xml = xml;
  6554. }
  6555. responses.text = xhr.responseText;
  6556. // Firefox throws an exception when accessing
  6557. // statusText for faulty cross-domain requests
  6558. try {
  6559. statusText = xhr.statusText;
  6560. } catch( e ) {
  6561. // We normalize with Webkit giving an empty statusText
  6562. statusText = "";
  6563. }
  6564. // Filter status for non standard behaviors
  6565. // If the request is local and we have data: assume a success
  6566. // (success with no data won't get notified, that's the best we
  6567. // can do given current implementations)
  6568. if ( !status && s.isLocal && !s.crossDomain ) {
  6569. status = responses.text ? 200 : 404;
  6570. // IE - #1450: sometimes returns 1223 when it should be 204
  6571. } else if ( status === 1223 ) {
  6572. status = 204;
  6573. }
  6574. }
  6575. }
  6576. } catch( firefoxAccessException ) {
  6577. if ( !isAbort ) {
  6578. complete( -1, firefoxAccessException );
  6579. }
  6580. }
  6581. // Call complete if needed
  6582. if ( responses ) {
  6583. complete( status, statusText, responses, responseHeaders );
  6584. }
  6585. };
  6586. // if we're in sync mode or it's in cache
  6587. // and has been retrieved directly (IE6 & IE7)
  6588. // we need to manually fire the callback
  6589. if ( !s.async || xhr.readyState === 4 ) {
  6590. callback();
  6591. } else {
  6592. handle = ++xhrId;
  6593. if ( xhrOnUnloadAbort ) {
  6594. // Create the active xhrs callbacks list if needed
  6595. // and attach the unload handler
  6596. if ( !xhrCallbacks ) {
  6597. xhrCallbacks = {};
  6598. jQuery( window ).unload( xhrOnUnloadAbort );
  6599. }
  6600. // Add to list of active xhrs callbacks
  6601. xhrCallbacks[ handle ] = callback;
  6602. }
  6603. xhr.onreadystatechange = callback;
  6604. }
  6605. },
  6606. abort: function() {
  6607. if ( callback ) {
  6608. callback(0,1);
  6609. }
  6610. }
  6611. };
  6612. }
  6613. });
  6614. }
  6615. var elemdisplay = {},
  6616. iframe, iframeDoc,
  6617. rfxtypes = /^(?:toggle|show|hide)$/,
  6618. rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
  6619. timerId,
  6620. fxAttrs = [
  6621. // height animations
  6622. [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
  6623. // width animations
  6624. [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
  6625. // opacity animations
  6626. [ "opacity" ]
  6627. ],
  6628. fxNow;
  6629. jQuery.fn.extend({
  6630. show: function( speed, easing, callback ) {
  6631. var elem, display;
  6632. if ( speed || speed === 0 ) {
  6633. return this.animate( genFx("show", 3), speed, easing, callback);
  6634. } else {
  6635. for ( var i = 0, j = this.length; i < j; i++ ) {
  6636. elem = this[i];
  6637. if ( elem.style ) {
  6638. display = elem.style.display;
  6639. // Reset the inline display of this element to learn if it is
  6640. // being hidden by cascaded rules or not
  6641. if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
  6642. display = elem.style.display = "";
  6643. }
  6644. // Set elements which have been overridden with display: none
  6645. // in a stylesheet to whatever the default browser style is
  6646. // for such an element
  6647. if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
  6648. jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
  6649. }
  6650. }
  6651. }
  6652. // Set the display of most of the elements in a second loop
  6653. // to avoid the constant reflow
  6654. for ( i = 0; i < j; i++ ) {
  6655. elem = this[i];
  6656. if ( elem.style ) {
  6657. display = elem.style.display;
  6658. if ( display === "" || display === "none" ) {
  6659. elem.style.display = jQuery._data(elem, "olddisplay") || "";
  6660. }
  6661. }
  6662. }
  6663. return this;
  6664. }
  6665. },
  6666. hide: function( speed, easing, callback ) {
  6667. if ( speed || speed === 0 ) {
  6668. return this.animate( genFx("hide", 3), speed, easing, callback);
  6669. } else {
  6670. for ( var i = 0, j = this.length; i < j; i++ ) {
  6671. if ( this[i].style ) {
  6672. var display = jQuery.css( this[i], "display" );
  6673. if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
  6674. jQuery._data( this[i], "olddisplay", display );
  6675. }
  6676. }
  6677. }
  6678. // Set the display of the elements in a second loop
  6679. // to avoid the constant reflow
  6680. for ( i = 0; i < j; i++ ) {
  6681. if ( this[i].style ) {
  6682. this[i].style.display = "none";
  6683. }
  6684. }
  6685. return this;
  6686. }
  6687. },
  6688. // Save the old toggle function
  6689. _toggle: jQuery.fn.toggle,
  6690. toggle: function( fn, fn2, callback ) {
  6691. var bool = typeof fn === "boolean";
  6692. if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
  6693. this._toggle.apply( this, arguments );
  6694. } else if ( fn == null || bool ) {
  6695. this.each(function() {
  6696. var state = bool ? fn : jQuery(this).is(":hidden");
  6697. jQuery(this)[ state ? "show" : "hide" ]();
  6698. });
  6699. } else {
  6700. this.animate(genFx("toggle", 3), fn, fn2, callback);
  6701. }
  6702. return this;
  6703. },
  6704. fadeTo: function( speed, to, easing, callback ) {
  6705. return this.filter(":hidden").css("opacity", 0).show().end()
  6706. .animate({opacity: to}, speed, easing, callback);
  6707. },
  6708. animate: function( prop, speed, easing, callback ) {
  6709. var optall = jQuery.speed(speed, easing, callback);
  6710. if ( jQuery.isEmptyObject( prop ) ) {
  6711. return this.each( optall.complete, [ false ] );
  6712. }
  6713. // Do not change referenced properties as per-property easing will be lost
  6714. prop = jQuery.extend( {}, prop );
  6715. return this[ optall.queue === false ? "each" : "queue" ](function() {
  6716. // XXX 'this' does not always have a nodeName when running the
  6717. // test suite
  6718. if ( optall.queue === false ) {
  6719. jQuery._mark( this );
  6720. }
  6721. var opt = jQuery.extend( {}, optall ),
  6722. isElement = this.nodeType === 1,
  6723. hidden = isElement && jQuery(this).is(":hidden"),
  6724. name, val, p,
  6725. display, e,
  6726. parts, start, end, unit;
  6727. // will store per property easing and be used to determine when an animation is complete
  6728. opt.animatedProperties = {};
  6729. for ( p in prop ) {
  6730. // property name normalization
  6731. name = jQuery.camelCase( p );
  6732. if ( p !== name ) {
  6733. prop[ name ] = prop[ p ];
  6734. delete prop[ p ];
  6735. }
  6736. val = prop[ name ];
  6737. // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default)
  6738. if ( jQuery.isArray( val ) ) {
  6739. opt.animatedProperties[ name ] = val[ 1 ];
  6740. val = prop[ name ] = val[ 0 ];
  6741. } else {
  6742. opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing';
  6743. }
  6744. if ( val === "hide" && hidden || val === "show" && !hidden ) {
  6745. return opt.complete.call( this );
  6746. }
  6747. if ( isElement && ( name === "height" || name === "width" ) ) {
  6748. // Make sure that nothing sneaks out
  6749. // Record all 3 overflow attributes because IE does not
  6750. // change the overflow attribute when overflowX and
  6751. // overflowY are set to the same value
  6752. opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
  6753. // Set display property to inline-block for height/width
  6754. // animations on inline elements that are having width/height
  6755. // animated
  6756. if ( jQuery.css( this, "display" ) === "inline" &&
  6757. jQuery.css( this, "float" ) === "none" ) {
  6758. if ( !jQuery.support.inlineBlockNeedsLayout ) {
  6759. this.style.display = "inline-block";
  6760. } else {
  6761. display = defaultDisplay( this.nodeName );
  6762. // inline-level elements accept inline-block;
  6763. // block-level elements need to be inline with layout
  6764. if ( display === "inline" ) {
  6765. this.style.display = "inline-block";
  6766. } else {
  6767. this.style.display = "inline";
  6768. this.style.zoom = 1;
  6769. }
  6770. }
  6771. }
  6772. }
  6773. }
  6774. if ( opt.overflow != null ) {
  6775. this.style.overflow = "hidden";
  6776. }
  6777. for ( p in prop ) {
  6778. e = new jQuery.fx( this, opt, p );
  6779. val = prop[ p ];
  6780. if ( rfxtypes.test(val) ) {
  6781. e[ val === "toggle" ? hidden ? "show" : "hide" : val ]();
  6782. } else {
  6783. parts = rfxnum.exec( val );
  6784. start = e.cur();
  6785. if ( parts ) {
  6786. end = parseFloat( parts[2] );
  6787. unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" );
  6788. // We need to compute starting value
  6789. if ( unit !== "px" ) {
  6790. jQuery.style( this, p, (end || 1) + unit);
  6791. start = ((end || 1) / e.cur()) * start;
  6792. jQuery.style( this, p, start + unit);
  6793. }
  6794. // If a +=/-= token was provided, we're doing a relative animation
  6795. if ( parts[1] ) {
  6796. end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start;
  6797. }
  6798. e.custom( start, end, unit );
  6799. } else {
  6800. e.custom( start, val, "" );
  6801. }
  6802. }
  6803. }
  6804. // For JS strict compliance
  6805. return true;
  6806. });
  6807. },
  6808. stop: function( clearQueue, gotoEnd ) {
  6809. if ( clearQueue ) {
  6810. this.queue([]);
  6811. }
  6812. this.each(function() {
  6813. var timers = jQuery.timers,
  6814. i = timers.length;
  6815. // clear marker counters if we know they won't be
  6816. if ( !gotoEnd ) {
  6817. jQuery._unmark( true, this );
  6818. }
  6819. while ( i-- ) {
  6820. if ( timers[i].elem === this ) {
  6821. if (gotoEnd) {
  6822. // force the next step to be the last
  6823. timers[i](true);
  6824. }
  6825. timers.splice(i, 1);
  6826. }
  6827. }
  6828. });
  6829. // start the next in the queue if the last step wasn't forced
  6830. if ( !gotoEnd ) {
  6831. this.dequeue();
  6832. }
  6833. return this;
  6834. }
  6835. });
  6836. // Animations created synchronously will run synchronously
  6837. function createFxNow() {
  6838. setTimeout( clearFxNow, 0 );
  6839. return ( fxNow = jQuery.now() );
  6840. }
  6841. function clearFxNow() {
  6842. fxNow = undefined;
  6843. }
  6844. // Generate parameters to create a standard animation
  6845. function genFx( type, num ) {
  6846. var obj = {};
  6847. jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
  6848. obj[ this ] = type;
  6849. });
  6850. return obj;
  6851. }
  6852. // Generate shortcuts for custom animations
  6853. jQuery.each({
  6854. slideDown: genFx("show", 1),
  6855. slideUp: genFx("hide", 1),
  6856. slideToggle: genFx("toggle", 1),
  6857. fadeIn: { opacity: "show" },
  6858. fadeOut: { opacity: "hide" },
  6859. fadeToggle: { opacity: "toggle" }
  6860. }, function( name, props ) {
  6861. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6862. return this.animate( props, speed, easing, callback );
  6863. };
  6864. });
  6865. jQuery.extend({
  6866. speed: function( speed, easing, fn ) {
  6867. var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
  6868. complete: fn || !fn && easing ||
  6869. jQuery.isFunction( speed ) && speed,
  6870. duration: speed,
  6871. easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
  6872. };
  6873. opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  6874. opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
  6875. // Queueing
  6876. opt.old = opt.complete;
  6877. opt.complete = function( noUnmark ) {
  6878. if ( jQuery.isFunction( opt.old ) ) {
  6879. opt.old.call( this );
  6880. }
  6881. if ( opt.queue !== false ) {
  6882. jQuery.dequeue( this );
  6883. } else if ( noUnmark !== false ) {
  6884. jQuery._unmark( this );
  6885. }
  6886. };
  6887. return opt;
  6888. },
  6889. easing: {
  6890. linear: function( p, n, firstNum, diff ) {
  6891. return firstNum + diff * p;
  6892. },
  6893. swing: function( p, n, firstNum, diff ) {
  6894. return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
  6895. }
  6896. },
  6897. timers: [],
  6898. fx: function( elem, options, prop ) {
  6899. this.options = options;
  6900. this.elem = elem;
  6901. this.prop = prop;
  6902. options.orig = options.orig || {};
  6903. }
  6904. });
  6905. jQuery.fx.prototype = {
  6906. // Simple function for setting a style value
  6907. update: function() {
  6908. if ( this.options.step ) {
  6909. this.options.step.call( this.elem, this.now, this );
  6910. }
  6911. (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
  6912. },
  6913. // Get the current size
  6914. cur: function() {
  6915. if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
  6916. return this.elem[ this.prop ];
  6917. }
  6918. var parsed,
  6919. r = jQuery.css( this.elem, this.prop );
  6920. // Empty strings, null, undefined and "auto" are converted to 0,
  6921. // complex values such as "rotate(1rad)" are returned as is,
  6922. // simple values such as "10px" are parsed to Float.
  6923. return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
  6924. },
  6925. // Start an animation from one number to another
  6926. custom: function( from, to, unit ) {
  6927. var self = this,
  6928. fx = jQuery.fx;
  6929. this.startTime = fxNow || createFxNow();
  6930. this.start = from;
  6931. this.end = to;
  6932. this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
  6933. this.now = this.start;
  6934. this.pos = this.state = 0;
  6935. function t( gotoEnd ) {
  6936. return self.step(gotoEnd);
  6937. }
  6938. t.elem = this.elem;
  6939. if ( t() && jQuery.timers.push(t) && !timerId ) {
  6940. timerId = setInterval( fx.tick, fx.interval );
  6941. }
  6942. },
  6943. // Simple 'show' function
  6944. show: function() {
  6945. // Remember where we started, so that we can go back to it later
  6946. this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
  6947. this.options.show = true;
  6948. // Begin the animation
  6949. // Make sure that we start at a small width/height to avoid any
  6950. // flash of content
  6951. this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
  6952. // Start by showing the element
  6953. jQuery( this.elem ).show();
  6954. },
  6955. // Simple 'hide' function
  6956. hide: function() {
  6957. // Remember where we started, so that we can go back to it later
  6958. this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
  6959. this.options.hide = true;
  6960. // Begin the animation
  6961. this.custom(this.cur(), 0);
  6962. },
  6963. // Each step of an animation
  6964. step: function( gotoEnd ) {
  6965. var t = fxNow || createFxNow(),
  6966. done = true,
  6967. elem = this.elem,
  6968. options = this.options,
  6969. i, n;
  6970. if ( gotoEnd || t >= options.duration + this.startTime ) {
  6971. this.now = this.end;
  6972. this.pos = this.state = 1;
  6973. this.update();
  6974. options.animatedProperties[ this.prop ] = true;
  6975. for ( i in options.animatedProperties ) {
  6976. if ( options.animatedProperties[i] !== true ) {
  6977. done = false;
  6978. }
  6979. }
  6980. if ( done ) {
  6981. // Reset the overflow
  6982. if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
  6983. jQuery.each( [ "", "X", "Y" ], function (index, value) {
  6984. elem.style[ "overflow" + value ] = options.overflow[index];
  6985. });
  6986. }
  6987. // Hide the element if the "hide" operation was done
  6988. if ( options.hide ) {
  6989. jQuery(elem).hide();
  6990. }
  6991. // Reset the properties, if the item has been hidden or shown
  6992. if ( options.hide || options.show ) {
  6993. for ( var p in options.animatedProperties ) {
  6994. jQuery.style( elem, p, options.orig[p] );
  6995. }
  6996. }
  6997. // Execute the complete function
  6998. options.complete.call( elem );
  6999. }
  7000. return false;
  7001. } else {
  7002. // classical easing cannot be used with an Infinity duration
  7003. if ( options.duration == Infinity ) {
  7004. this.now = t;
  7005. } else {
  7006. n = t - this.startTime;
  7007. this.state = n / options.duration;
  7008. // Perform the easing function, defaults to swing
  7009. this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration );
  7010. this.now = this.start + ((this.end - this.start) * this.pos);
  7011. }
  7012. // Perform the next step of the animation
  7013. this.update();
  7014. }
  7015. return true;
  7016. }
  7017. };
  7018. jQuery.extend( jQuery.fx, {
  7019. tick: function() {
  7020. for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) {
  7021. if ( !timers[i]() ) {
  7022. timers.splice(i--, 1);
  7023. }
  7024. }
  7025. if ( !timers.length ) {
  7026. jQuery.fx.stop();
  7027. }
  7028. },
  7029. interval: 13,
  7030. stop: function() {
  7031. clearInterval( timerId );
  7032. timerId = null;
  7033. },
  7034. speeds: {
  7035. slow: 600,
  7036. fast: 200,
  7037. // Default speed
  7038. _default: 400
  7039. },
  7040. step: {
  7041. opacity: function( fx ) {
  7042. jQuery.style( fx.elem, "opacity", fx.now );
  7043. },
  7044. _default: function( fx ) {
  7045. if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
  7046. fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
  7047. } else {
  7048. fx.elem[ fx.prop ] = fx.now;
  7049. }
  7050. }
  7051. }
  7052. });
  7053. if ( jQuery.expr && jQuery.expr.filters ) {
  7054. jQuery.expr.filters.animated = function( elem ) {
  7055. return jQuery.grep(jQuery.timers, function( fn ) {
  7056. return elem === fn.elem;
  7057. }).length;
  7058. };
  7059. }
  7060. // Try to restore the default display value of an element
  7061. function defaultDisplay( nodeName ) {
  7062. if ( !elemdisplay[ nodeName ] ) {
  7063. var body = document.body,
  7064. elem = jQuery( "<" + nodeName + ">" ).appendTo( body ),
  7065. display = elem.css( "display" );
  7066. elem.remove();
  7067. // If the simple way fails,
  7068. // get element's real default display by attaching it to a temp iframe
  7069. if ( display === "none" || display === "" ) {
  7070. // No iframe to use yet, so create it
  7071. if ( !iframe ) {
  7072. iframe = document.createElement( "iframe" );
  7073. iframe.frameBorder = iframe.width = iframe.height = 0;
  7074. }
  7075. body.appendChild( iframe );
  7076. // Create a cacheable copy of the iframe document on first call.
  7077. // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML
  7078. // document to it; WebKit & Firefox won't allow reusing the iframe document.
  7079. if ( !iframeDoc || !iframe.createElement ) {
  7080. iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document;
  7081. iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" );
  7082. iframeDoc.close();
  7083. }
  7084. elem = iframeDoc.createElement( nodeName );
  7085. iframeDoc.body.appendChild( elem );
  7086. display = jQuery.css( elem, "display" );
  7087. body.removeChild( iframe );
  7088. }
  7089. // Store the correct default display
  7090. elemdisplay[ nodeName ] = display;
  7091. }
  7092. return elemdisplay[ nodeName ];
  7093. }
  7094. var rtable = /^t(?:able|d|h)$/i,
  7095. rroot = /^(?:body|html)$/i;
  7096. if ( "getBoundingClientRect" in document.documentElement ) {
  7097. jQuery.fn.offset = function( options ) {
  7098. var elem = this[0], box;
  7099. if ( options ) {
  7100. return this.each(function( i ) {
  7101. jQuery.offset.setOffset( this, options, i );
  7102. });
  7103. }
  7104. if ( !elem || !elem.ownerDocument ) {
  7105. return null;
  7106. }
  7107. if ( elem === elem.ownerDocument.body ) {
  7108. return jQuery.offset.bodyOffset( elem );
  7109. }
  7110. try {
  7111. box = elem.getBoundingClientRect();
  7112. } catch(e) {}
  7113. var doc = elem.ownerDocument,
  7114. docElem = doc.documentElement;
  7115. // Make sure we're not dealing with a disconnected DOM node
  7116. if ( !box || !jQuery.contains( docElem, elem ) ) {
  7117. return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
  7118. }
  7119. var body = doc.body,
  7120. win = getWindow(doc),
  7121. clientTop = docElem.clientTop || body.clientTop || 0,
  7122. clientLeft = docElem.clientLeft || body.clientLeft || 0,
  7123. scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop,
  7124. scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft,
  7125. top = box.top + scrollTop - clientTop,
  7126. left = box.left + scrollLeft - clientLeft;
  7127. return { top: top, left: left };
  7128. };
  7129. } else {
  7130. jQuery.fn.offset = function( options ) {
  7131. var elem = this[0];
  7132. if ( options ) {
  7133. return this.each(function( i ) {
  7134. jQuery.offset.setOffset( this, options, i );
  7135. });
  7136. }
  7137. if ( !elem || !elem.ownerDocument ) {
  7138. return null;
  7139. }
  7140. if ( elem === elem.ownerDocument.body ) {
  7141. return jQuery.offset.bodyOffset( elem );
  7142. }
  7143. jQuery.offset.initialize();
  7144. var computedStyle,
  7145. offsetParent = elem.offsetParent,
  7146. prevOffsetParent = elem,
  7147. doc = elem.ownerDocument,
  7148. docElem = doc.documentElement,
  7149. body = doc.body,
  7150. defaultView = doc.defaultView,
  7151. prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
  7152. top = elem.offsetTop,
  7153. left = elem.offsetLeft;
  7154. while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
  7155. if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
  7156. break;
  7157. }
  7158. computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
  7159. top -= elem.scrollTop;
  7160. left -= elem.scrollLeft;
  7161. if ( elem === offsetParent ) {
  7162. top += elem.offsetTop;
  7163. left += elem.offsetLeft;
  7164. if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
  7165. top += parseFloat( computedStyle.borderTopWidth ) || 0;
  7166. left += parseFloat( computedStyle.borderLeftWidth ) || 0;
  7167. }
  7168. prevOffsetParent = offsetParent;
  7169. offsetParent = elem.offsetParent;
  7170. }
  7171. if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
  7172. top += parseFloat( computedStyle.borderTopWidth ) || 0;
  7173. left += parseFloat( computedStyle.borderLeftWidth ) || 0;
  7174. }
  7175. prevComputedStyle = computedStyle;
  7176. }
  7177. if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
  7178. top += body.offsetTop;
  7179. left += body.offsetLeft;
  7180. }
  7181. if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
  7182. top += Math.max( docElem.scrollTop, body.scrollTop );
  7183. left += Math.max( docElem.scrollLeft, body.scrollLeft );
  7184. }
  7185. return { top: top, left: left };
  7186. };
  7187. }
  7188. jQuery.offset = {
  7189. initialize: function() {
  7190. var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
  7191. html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
  7192. jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
  7193. container.innerHTML = html;
  7194. body.insertBefore( container, body.firstChild );
  7195. innerDiv = container.firstChild;
  7196. checkDiv = innerDiv.firstChild;
  7197. td = innerDiv.nextSibling.firstChild.firstChild;
  7198. this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
  7199. this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
  7200. checkDiv.style.position = "fixed";
  7201. checkDiv.style.top = "20px";
  7202. // safari subtracts parent border width here which is 5px
  7203. this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
  7204. checkDiv.style.position = checkDiv.style.top = "";
  7205. innerDiv.style.overflow = "hidden";
  7206. innerDiv.style.position = "relative";
  7207. this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
  7208. this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
  7209. body.removeChild( container );
  7210. jQuery.offset.initialize = jQuery.noop;
  7211. },
  7212. bodyOffset: function( body ) {
  7213. var top = body.offsetTop,
  7214. left = body.offsetLeft;
  7215. jQuery.offset.initialize();
  7216. if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
  7217. top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
  7218. left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
  7219. }
  7220. return { top: top, left: left };
  7221. },
  7222. setOffset: function( elem, options, i ) {
  7223. var position = jQuery.css( elem, "position" );
  7224. // set position first, in-case top/left are set even on static elem
  7225. if ( position === "static" ) {
  7226. elem.style.position = "relative";
  7227. }
  7228. var curElem = jQuery( elem ),
  7229. curOffset = curElem.offset(),
  7230. curCSSTop = jQuery.css( elem, "top" ),
  7231. curCSSLeft = jQuery.css( elem, "left" ),
  7232. calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1,
  7233. props = {}, curPosition = {}, curTop, curLeft;
  7234. // need to be able to calculate position if either top or left is auto and position is either absolute or fixed
  7235. if ( calculatePosition ) {
  7236. curPosition = curElem.position();
  7237. curTop = curPosition.top;
  7238. curLeft = curPosition.left;
  7239. } else {
  7240. curTop = parseFloat( curCSSTop ) || 0;
  7241. curLeft = parseFloat( curCSSLeft ) || 0;
  7242. }
  7243. if ( jQuery.isFunction( options ) ) {
  7244. options = options.call( elem, i, curOffset );
  7245. }
  7246. if (options.top != null) {
  7247. props.top = (options.top - curOffset.top) + curTop;
  7248. }
  7249. if (options.left != null) {
  7250. props.left = (options.left - curOffset.left) + curLeft;
  7251. }
  7252. if ( "using" in options ) {
  7253. options.using.call( elem, props );
  7254. } else {
  7255. curElem.css( props );
  7256. }
  7257. }
  7258. };
  7259. jQuery.fn.extend({
  7260. position: function() {
  7261. if ( !this[0] ) {
  7262. return null;
  7263. }
  7264. var elem = this[0],
  7265. // Get *real* offsetParent
  7266. offsetParent = this.offsetParent(),
  7267. // Get correct offsets
  7268. offset = this.offset(),
  7269. parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
  7270. // Subtract element margins
  7271. // note: when an element has margin: auto the offsetLeft and marginLeft
  7272. // are the same in Safari causing offset.left to incorrectly be 0
  7273. offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
  7274. offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
  7275. // Add offsetParent borders
  7276. parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
  7277. parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
  7278. // Subtract the two offsets
  7279. return {
  7280. top: offset.top - parentOffset.top,
  7281. left: offset.left - parentOffset.left
  7282. };
  7283. },
  7284. offsetParent: function() {
  7285. return this.map(function() {
  7286. var offsetParent = this.offsetParent || document.body;
  7287. while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
  7288. offsetParent = offsetParent.offsetParent;
  7289. }
  7290. return offsetParent;
  7291. });
  7292. }
  7293. });
  7294. // Create scrollLeft and scrollTop methods
  7295. jQuery.each( ["Left", "Top"], function( i, name ) {
  7296. var method = "scroll" + name;
  7297. jQuery.fn[ method ] = function( val ) {
  7298. var elem, win;
  7299. if ( val === undefined ) {
  7300. elem = this[ 0 ];
  7301. if ( !elem ) {
  7302. return null;
  7303. }
  7304. win = getWindow( elem );
  7305. // Return the scroll offset
  7306. return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
  7307. jQuery.support.boxModel && win.document.documentElement[ method ] ||
  7308. win.document.body[ method ] :
  7309. elem[ method ];
  7310. }
  7311. // Set the scroll offset
  7312. return this.each(function() {
  7313. win = getWindow( this );
  7314. if ( win ) {
  7315. win.scrollTo(
  7316. !i ? val : jQuery( win ).scrollLeft(),
  7317. i ? val : jQuery( win ).scrollTop()
  7318. );
  7319. } else {
  7320. this[ method ] = val;
  7321. }
  7322. });
  7323. };
  7324. });
  7325. function getWindow( elem ) {
  7326. return jQuery.isWindow( elem ) ?
  7327. elem :
  7328. elem.nodeType === 9 ?
  7329. elem.defaultView || elem.parentWindow :
  7330. false;
  7331. }
  7332. // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods
  7333. jQuery.each([ "Height", "Width" ], function( i, name ) {
  7334. var type = name.toLowerCase();
  7335. // innerHeight and innerWidth
  7336. jQuery.fn[ "inner" + name ] = function() {
  7337. var elem = this[0];
  7338. return elem && elem.style ?
  7339. parseFloat( jQuery.css( elem, type, "padding" ) ) :
  7340. null;
  7341. };
  7342. // outerHeight and outerWidth
  7343. jQuery.fn[ "outer" + name ] = function( margin ) {
  7344. var elem = this[0];
  7345. return elem && elem.style ?
  7346. parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) :
  7347. null;
  7348. };
  7349. jQuery.fn[ type ] = function( size ) {
  7350. // Get window width or height
  7351. var elem = this[0];
  7352. if ( !elem ) {
  7353. return size == null ? null : this;
  7354. }
  7355. if ( jQuery.isFunction( size ) ) {
  7356. return this.each(function( i ) {
  7357. var self = jQuery( this );
  7358. self[ type ]( size.call( this, i, self[ type ]() ) );
  7359. });
  7360. }
  7361. if ( jQuery.isWindow( elem ) ) {
  7362. // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
  7363. // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
  7364. var docElemProp = elem.document.documentElement[ "client" + name ],
  7365. body = elem.document.body;
  7366. return elem.document.compatMode === "CSS1Compat" && docElemProp ||
  7367. body && body[ "client" + name ] || docElemProp;
  7368. // Get document width or height
  7369. } else if ( elem.nodeType === 9 ) {
  7370. // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
  7371. return Math.max(
  7372. elem.documentElement["client" + name],
  7373. elem.body["scroll" + name], elem.documentElement["scroll" + name],
  7374. elem.body["offset" + name], elem.documentElement["offset" + name]
  7375. );
  7376. // Get or set width or height on the element
  7377. } else if ( size === undefined ) {
  7378. var orig = jQuery.css( elem, type ),
  7379. ret = parseFloat( orig );
  7380. return jQuery.isNaN( ret ) ? orig : ret;
  7381. // Set the width or height on the element (default to pixels if value is unitless)
  7382. } else {
  7383. return this.css( type, typeof size === "string" ? size : size + "px" );
  7384. }
  7385. };
  7386. });
  7387. // Expose jQuery to the global object
  7388. window.jQuery = window.$ = jQuery;
  7389. })(window);
  7390. // Underscore.js 1.1.7
  7391. // (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
  7392. // Underscore is freely distributable under the MIT license.
  7393. // Portions of Underscore are inspired or borrowed from Prototype,
  7394. // Oliver Steele's Functional, and John Resig's Micro-Templating.
  7395. // For all details and documentation:
  7396. // http://documentcloud.github.com/underscore
  7397. (function() {
  7398. // Baseline setup
  7399. // --------------
  7400. // Establish the root object, `window` in the browser, or `global` on the server.
  7401. var root = this;
  7402. // Save the previous value of the `_` variable.
  7403. var previousUnderscore = root._;
  7404. // Establish the object that gets returned to break out of a loop iteration.
  7405. var breaker = {};
  7406. // Save bytes in the minified (but not gzipped) version:
  7407. var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
  7408. // Create quick reference variables for speed access to core prototypes.
  7409. var slice = ArrayProto.slice,
  7410. unshift = ArrayProto.unshift,
  7411. toString = ObjProto.toString,
  7412. hasOwnProperty = ObjProto.hasOwnProperty;
  7413. // All **ECMAScript 5** native function implementations that we hope to use
  7414. // are declared here.
  7415. var
  7416. nativeForEach = ArrayProto.forEach,
  7417. nativeMap = ArrayProto.map,
  7418. nativeReduce = ArrayProto.reduce,
  7419. nativeReduceRight = ArrayProto.reduceRight,
  7420. nativeFilter = ArrayProto.filter,
  7421. nativeEvery = ArrayProto.every,
  7422. nativeSome = ArrayProto.some,
  7423. nativeIndexOf = ArrayProto.indexOf,
  7424. nativeLastIndexOf = ArrayProto.lastIndexOf,
  7425. nativeIsArray = Array.isArray,
  7426. nativeKeys = Object.keys,
  7427. nativeBind = FuncProto.bind;
  7428. // Create a safe reference to the Underscore object for use below.
  7429. var _ = function(obj) { return new wrapper(obj); };
  7430. // Export the Underscore object for **CommonJS**, with backwards-compatibility
  7431. // for the old `require()` API. If we're not in CommonJS, add `_` to the
  7432. // global object.
  7433. if (typeof module !== 'undefined' && module.exports) {
  7434. module.exports = _;
  7435. _._ = _;
  7436. } else {
  7437. // Exported as a string, for Closure Compiler "advanced" mode.
  7438. root['_'] = _;
  7439. }
  7440. // Current version.
  7441. _.VERSION = '1.1.7';
  7442. // Collection Functions
  7443. // --------------------
  7444. // The cornerstone, an `each` implementation, aka `forEach`.
  7445. // Handles objects with the built-in `forEach`, arrays, and raw objects.
  7446. // Delegates to **ECMAScript 5**'s native `forEach` if available.
  7447. var each = _.each = _.forEach = function(obj, iterator, context) {
  7448. if (obj == null) return;
  7449. if (nativeForEach && obj.forEach === nativeForEach) {
  7450. obj.forEach(iterator, context);
  7451. } else if (obj.length === +obj.length) {
  7452. for (var i = 0, l = obj.length; i < l; i++) {
  7453. if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
  7454. }
  7455. } else {
  7456. for (var key in obj) {
  7457. if (hasOwnProperty.call(obj, key)) {
  7458. if (iterator.call(context, obj[key], key, obj) === breaker) return;
  7459. }
  7460. }
  7461. }
  7462. };
  7463. // Return the results of applying the iterator to each element.
  7464. // Delegates to **ECMAScript 5**'s native `map` if available.
  7465. _.map = function(obj, iterator, context) {
  7466. var results = [];
  7467. if (obj == null) return results;
  7468. if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
  7469. each(obj, function(value, index, list) {
  7470. results[results.length] = iterator.call(context, value, index, list);
  7471. });
  7472. return results;
  7473. };
  7474. // **Reduce** builds up a single result from a list of values, aka `inject`,
  7475. // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
  7476. _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
  7477. var initial = memo !== void 0;
  7478. if (obj == null) obj = [];
  7479. if (nativeReduce && obj.reduce === nativeReduce) {
  7480. if (context) iterator = _.bind(iterator, context);
  7481. return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
  7482. }
  7483. each(obj, function(value, index, list) {
  7484. if (!initial) {
  7485. memo = value;
  7486. initial = true;
  7487. } else {
  7488. memo = iterator.call(context, memo, value, index, list);
  7489. }
  7490. });
  7491. if (!initial) throw new TypeError("Reduce of empty array with no initial value");
  7492. return memo;
  7493. };
  7494. // The right-associative version of reduce, also known as `foldr`.
  7495. // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
  7496. _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
  7497. if (obj == null) obj = [];
  7498. if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
  7499. if (context) iterator = _.bind(iterator, context);
  7500. return memo !== void 0 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
  7501. }
  7502. var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();
  7503. return _.reduce(reversed, iterator, memo, context);
  7504. };
  7505. // Return the first value which passes a truth test. Aliased as `detect`.
  7506. _.find = _.detect = function(obj, iterator, context) {
  7507. var result;
  7508. any(obj, function(value, index, list) {
  7509. if (iterator.call(context, value, index, list)) {
  7510. result = value;
  7511. return true;
  7512. }
  7513. });
  7514. return result;
  7515. };
  7516. // Return all the elements that pass a truth test.
  7517. // Delegates to **ECMAScript 5**'s native `filter` if available.
  7518. // Aliased as `select`.
  7519. _.filter = _.select = function(obj, iterator, context) {
  7520. var results = [];
  7521. if (obj == null) return results;
  7522. if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context);
  7523. each(obj, function(value, index, list) {
  7524. if (iterator.call(context, value, index, list)) results[results.length] = value;
  7525. });
  7526. return results;
  7527. };
  7528. // Return all the elements for which a truth test fails.
  7529. _.reject = function(obj, iterator, context) {
  7530. var results = [];
  7531. if (obj == null) return results;
  7532. each(obj, function(value, index, list) {
  7533. if (!iterator.call(context, value, index, list)) results[results.length] = value;
  7534. });
  7535. return results;
  7536. };
  7537. // Determine whether all of the elements match a truth test.
  7538. // Delegates to **ECMAScript 5**'s native `every` if available.
  7539. // Aliased as `all`.
  7540. _.every = _.all = function(obj, iterator, context) {
  7541. var result = true;
  7542. if (obj == null) return result;
  7543. if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context);
  7544. each(obj, function(value, index, list) {
  7545. if (!(result = result && iterator.call(context, value, index, list))) return breaker;
  7546. });
  7547. return result;
  7548. };
  7549. // Determine if at least one element in the object matches a truth test.
  7550. // Delegates to **ECMAScript 5**'s native `some` if available.
  7551. // Aliased as `any`.
  7552. var any = _.some = _.any = function(obj, iterator, context) {
  7553. iterator = iterator || _.identity;
  7554. var result = false;
  7555. if (obj == null) return result;
  7556. if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
  7557. each(obj, function(value, index, list) {
  7558. if (result |= iterator.call(context, value, index, list)) return breaker;
  7559. });
  7560. return !!result;
  7561. };
  7562. // Determine if a given value is included in the array or object using `===`.
  7563. // Aliased as `contains`.
  7564. _.include = _.contains = function(obj, target) {
  7565. var found = false;
  7566. if (obj == null) return found;
  7567. if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
  7568. any(obj, function(value) {
  7569. if (found = value === target) return true;
  7570. });
  7571. return found;
  7572. };
  7573. // Invoke a method (with arguments) on every item in a collection.
  7574. _.invoke = function(obj, method) {
  7575. var args = slice.call(arguments, 2);
  7576. return _.map(obj, function(value) {
  7577. return (method.call ? method || value : value[method]).apply(value, args);
  7578. });
  7579. };
  7580. // Convenience version of a common use case of `map`: fetching a property.
  7581. _.pluck = function(obj, key) {
  7582. return _.map(obj, function(value){ return value[key]; });
  7583. };
  7584. // Return the maximum element or (element-based computation).
  7585. _.max = function(obj, iterator, context) {
  7586. if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);
  7587. var result = {computed : -Infinity};
  7588. each(obj, function(value, index, list) {
  7589. var computed = iterator ? iterator.call(context, value, index, list) : value;
  7590. computed >= result.computed && (result = {value : value, computed : computed});
  7591. });
  7592. return result.value;
  7593. };
  7594. // Return the minimum element (or element-based computation).
  7595. _.min = function(obj, iterator, context) {
  7596. if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);
  7597. var result = {computed : Infinity};
  7598. each(obj, function(value, index, list) {
  7599. var computed = iterator ? iterator.call(context, value, index, list) : value;
  7600. computed < result.computed && (result = {value : value, computed : computed});
  7601. });
  7602. return result.value;
  7603. };
  7604. // Sort the object's values by a criterion produced by an iterator.
  7605. _.sortBy = function(obj, iterator, context) {
  7606. return _.pluck(_.map(obj, function(value, index, list) {
  7607. return {
  7608. value : value,
  7609. criteria : iterator.call(context, value, index, list)
  7610. };
  7611. }).sort(function(left, right) {
  7612. var a = left.criteria, b = right.criteria;
  7613. return a < b ? -1 : a > b ? 1 : 0;
  7614. }), 'value');
  7615. };
  7616. // Groups the object's values by a criterion produced by an iterator
  7617. _.groupBy = function(obj, iterator) {
  7618. var result = {};
  7619. each(obj, function(value, index) {
  7620. var key = iterator(value, index);
  7621. (result[key] || (result[key] = [])).push(value);
  7622. });
  7623. return result;
  7624. };
  7625. // Use a comparator function to figure out at what index an object should
  7626. // be inserted so as to maintain order. Uses binary search.
  7627. _.sortedIndex = function(array, obj, iterator) {
  7628. iterator || (iterator = _.identity);
  7629. var low = 0, high = array.length;
  7630. while (low < high) {
  7631. var mid = (low + high) >> 1;
  7632. iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid;
  7633. }
  7634. return low;
  7635. };
  7636. // Safely convert anything iterable into a real, live array.
  7637. _.toArray = function(iterable) {
  7638. if (!iterable) return [];
  7639. if (iterable.toArray) return iterable.toArray();
  7640. if (_.isArray(iterable)) return slice.call(iterable);
  7641. if (_.isArguments(iterable)) return slice.call(iterable);
  7642. return _.values(iterable);
  7643. };
  7644. // Return the number of elements in an object.
  7645. _.size = function(obj) {
  7646. return _.toArray(obj).length;
  7647. };
  7648. // Array Functions
  7649. // ---------------
  7650. // Get the first element of an array. Passing **n** will return the first N
  7651. // values in the array. Aliased as `head`. The **guard** check allows it to work
  7652. // with `_.map`.
  7653. _.first = _.head = function(array, n, guard) {
  7654. return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
  7655. };
  7656. // Returns everything but the first entry of the array. Aliased as `tail`.
  7657. // Especially useful on the arguments object. Passing an **index** will return
  7658. // the rest of the values in the array from that index onward. The **guard**
  7659. // check allows it to work with `_.map`.
  7660. _.rest = _.tail = function(array, index, guard) {
  7661. return slice.call(array, (index == null) || guard ? 1 : index);
  7662. };
  7663. // Get the last element of an array.
  7664. _.last = function(array) {
  7665. return array[array.length - 1];
  7666. };
  7667. // Trim out all falsy values from an array.
  7668. _.compact = function(array) {
  7669. return _.filter(array, function(value){ return !!value; });
  7670. };
  7671. // Return a completely flattened version of an array.
  7672. _.flatten = function(array) {
  7673. return _.reduce(array, function(memo, value) {
  7674. if (_.isArray(value)) return memo.concat(_.flatten(value));
  7675. memo[memo.length] = value;
  7676. return memo;
  7677. }, []);
  7678. };
  7679. // Return a version of the array that does not contain the specified value(s).
  7680. _.without = function(array) {
  7681. return _.difference(array, slice.call(arguments, 1));
  7682. };
  7683. // Produce a duplicate-free version of the array. If the array has already
  7684. // been sorted, you have the option of using a faster algorithm.
  7685. // Aliased as `unique`.
  7686. _.uniq = _.unique = function(array, isSorted) {
  7687. return _.reduce(array, function(memo, el, i) {
  7688. if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) memo[memo.length] = el;
  7689. return memo;
  7690. }, []);
  7691. };
  7692. // Produce an array that contains the union: each distinct element from all of
  7693. // the passed-in arrays.
  7694. _.union = function() {
  7695. return _.uniq(_.flatten(arguments));
  7696. };
  7697. // Produce an array that contains every item shared between all the
  7698. // passed-in arrays. (Aliased as "intersect" for back-compat.)
  7699. _.intersection = _.intersect = function(array) {
  7700. var rest = slice.call(arguments, 1);
  7701. return _.filter(_.uniq(array), function(item) {
  7702. return _.every(rest, function(other) {
  7703. return _.indexOf(other, item) >= 0;
  7704. });
  7705. });
  7706. };
  7707. // Take the difference between one array and another.
  7708. // Only the elements present in just the first array will remain.
  7709. _.difference = function(array, other) {
  7710. return _.filter(array, function(value){ return !_.include(other, value); });
  7711. };
  7712. // Zip together multiple lists into a single array -- elements that share
  7713. // an index go together.
  7714. _.zip = function() {
  7715. var args = slice.call(arguments);
  7716. var length = _.max(_.pluck(args, 'length'));
  7717. var results = new Array(length);
  7718. for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i);
  7719. return results;
  7720. };
  7721. // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**),
  7722. // we need this function. Return the position of the first occurrence of an
  7723. // item in an array, or -1 if the item is not included in the array.
  7724. // Delegates to **ECMAScript 5**'s native `indexOf` if available.
  7725. // If the array is large and already in sort order, pass `true`
  7726. // for **isSorted** to use binary search.
  7727. _.indexOf = function(array, item, isSorted) {
  7728. if (array == null) return -1;
  7729. var i, l;
  7730. if (isSorted) {
  7731. i = _.sortedIndex(array, item);
  7732. return array[i] === item ? i : -1;
  7733. }
  7734. if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
  7735. for (i = 0, l = array.length; i < l; i++) if (array[i] === item) return i;
  7736. return -1;
  7737. };
  7738. // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
  7739. _.lastIndexOf = function(array, item) {
  7740. if (array == null) return -1;
  7741. if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
  7742. var i = array.length;
  7743. while (i--) if (array[i] === item) return i;
  7744. return -1;
  7745. };
  7746. // Generate an integer Array containing an arithmetic progression. A port of
  7747. // the native Python `range()` function. See
  7748. // [the Python documentation](http://docs.python.org/library/functions.html#range).
  7749. _.range = function(start, stop, step) {
  7750. if (arguments.length <= 1) {
  7751. stop = start || 0;
  7752. start = 0;
  7753. }
  7754. step = arguments[2] || 1;
  7755. var len = Math.max(Math.ceil((stop - start) / step), 0);
  7756. var idx = 0;
  7757. var range = new Array(len);
  7758. while(idx < len) {
  7759. range[idx++] = start;
  7760. start += step;
  7761. }
  7762. return range;
  7763. };
  7764. // Function (ahem) Functions
  7765. // ------------------
  7766. // Create a function bound to a given object (assigning `this`, and arguments,
  7767. // optionally). Binding with arguments is also known as `curry`.
  7768. // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
  7769. // We check for `func.bind` first, to fail fast when `func` is undefined.
  7770. _.bind = function(func, obj) {
  7771. if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
  7772. var args = slice.call(arguments, 2);
  7773. return function() {
  7774. return func.apply(obj, args.concat(slice.call(arguments)));
  7775. };
  7776. };
  7777. // Bind all of an object's methods to that object. Useful for ensuring that
  7778. // all callbacks defined on an object belong to it.
  7779. _.bindAll = function(obj) {
  7780. var funcs = slice.call(arguments, 1);
  7781. if (funcs.length == 0) funcs = _.functions(obj);
  7782. each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); });
  7783. return obj;
  7784. };
  7785. // Memoize an expensive function by storing its results.
  7786. _.memoize = function(func, hasher) {
  7787. var memo = {};
  7788. hasher || (hasher = _.identity);
  7789. return function() {
  7790. var key = hasher.apply(this, arguments);
  7791. return hasOwnProperty.call(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
  7792. };
  7793. };
  7794. // Delays a function for the given number of milliseconds, and then calls
  7795. // it with the arguments supplied.
  7796. _.delay = function(func, wait) {
  7797. var args = slice.call(arguments, 2);
  7798. return setTimeout(function(){ return func.apply(func, args); }, wait);
  7799. };
  7800. // Defers a function, scheduling it to run after the current call stack has
  7801. // cleared.
  7802. _.defer = function(func) {
  7803. return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
  7804. };
  7805. // Internal function used to implement `_.throttle` and `_.debounce`.
  7806. var limit = function(func, wait, debounce) {
  7807. var timeout;
  7808. return function() {
  7809. var context = this, args = arguments;
  7810. var throttler = function() {
  7811. timeout = null;
  7812. func.apply(context, args);
  7813. };
  7814. if (debounce) clearTimeout(timeout);
  7815. if (debounce || !timeout) timeout = setTimeout(throttler, wait);
  7816. };
  7817. };
  7818. // Returns a function, that, when invoked, will only be triggered at most once
  7819. // during a given window of time.
  7820. _.throttle = function(func, wait) {
  7821. return limit(func, wait, false);
  7822. };
  7823. // Returns a function, that, as long as it continues to be invoked, will not
  7824. // be triggered. The function will be called after it stops being called for
  7825. // N milliseconds.
  7826. _.debounce = function(func, wait) {
  7827. return limit(func, wait, true);
  7828. };
  7829. // Returns a function that will be executed at most one time, no matter how
  7830. // often you call it. Useful for lazy initialization.
  7831. _.once = function(func) {
  7832. var ran = false, memo;
  7833. return function() {
  7834. if (ran) return memo;
  7835. ran = true;
  7836. return memo = func.apply(this, arguments);
  7837. };
  7838. };
  7839. // Returns the first function passed as an argument to the second,
  7840. // allowing you to adjust arguments, run code before and after, and
  7841. // conditionally execute the original function.
  7842. _.wrap = function(func, wrapper) {
  7843. return function() {
  7844. var args = [func].concat(slice.call(arguments));
  7845. return wrapper.apply(this, args);
  7846. };
  7847. };
  7848. // Returns a function that is the composition of a list of functions, each
  7849. // consuming the return value of the function that follows.
  7850. _.compose = function() {
  7851. var funcs = slice.call(arguments);
  7852. return function() {
  7853. var args = slice.call(arguments);
  7854. for (var i = funcs.length - 1; i >= 0; i--) {
  7855. args = [funcs[i].apply(this, args)];
  7856. }
  7857. return args[0];
  7858. };
  7859. };
  7860. // Returns a function that will only be executed after being called N times.
  7861. _.after = function(times, func) {
  7862. return function() {
  7863. if (--times < 1) { return func.apply(this, arguments); }
  7864. };
  7865. };
  7866. // Object Functions
  7867. // ----------------
  7868. // Retrieve the names of an object's properties.
  7869. // Delegates to **ECMAScript 5**'s native `Object.keys`
  7870. _.keys = nativeKeys || function(obj) {
  7871. if (obj !== Object(obj)) throw new TypeError('Invalid object');
  7872. var keys = [];
  7873. for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
  7874. return keys;
  7875. };
  7876. // Retrieve the values of an object's properties.
  7877. _.values = function(obj) {
  7878. return _.map(obj, _.identity);
  7879. };
  7880. // Return a sorted list of the function names available on the object.
  7881. // Aliased as `methods`
  7882. _.functions = _.methods = function(obj) {
  7883. var names = [];
  7884. for (var key in obj) {
  7885. if (_.isFunction(obj[key])) names.push(key);
  7886. }
  7887. return names.sort();
  7888. };
  7889. // Extend a given object with all the properties in passed-in object(s).
  7890. _.extend = function(obj) {
  7891. each(slice.call(arguments, 1), function(source) {
  7892. for (var prop in source) {
  7893. if (source[prop] !== void 0) obj[prop] = source[prop];
  7894. }
  7895. });
  7896. return obj;
  7897. };
  7898. // Fill in a given object with default properties.
  7899. _.defaults = function(obj) {
  7900. each(slice.call(arguments, 1), function(source) {
  7901. for (var prop in source) {
  7902. if (obj[prop] == null) obj[prop] = source[prop];
  7903. }
  7904. });
  7905. return obj;
  7906. };
  7907. // Create a (shallow-cloned) duplicate of an object.
  7908. _.clone = function(obj) {
  7909. return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
  7910. };
  7911. // Invokes interceptor with the obj, and then returns obj.
  7912. // The primary purpose of this method is to "tap into" a method chain, in
  7913. // order to perform operations on intermediate results within the chain.
  7914. _.tap = function(obj, interceptor) {
  7915. interceptor(obj);
  7916. return obj;
  7917. };
  7918. // Perform a deep comparison to check if two objects are equal.
  7919. _.isEqual = function(a, b) {
  7920. // Check object identity.
  7921. if (a === b) return true;
  7922. // Different types?
  7923. var atype = typeof(a), btype = typeof(b);
  7924. if (atype != btype) return false;
  7925. // Basic equality test (watch out for coercions).
  7926. if (a == b) return true;
  7927. // One is falsy and the other truthy.
  7928. if ((!a && b) || (a && !b)) return false;
  7929. // Unwrap any wrapped objects.
  7930. if (a._chain) a = a._wrapped;
  7931. if (b._chain) b = b._wrapped;
  7932. // One of them implements an isEqual()?
  7933. if (a.isEqual) return a.isEqual(b);
  7934. if (b.isEqual) return b.isEqual(a);
  7935. // Check dates' integer values.
  7936. if (_.isDate(a) && _.isDate(b)) return a.getTime() === b.getTime();
  7937. // Both are NaN?
  7938. if (_.isNaN(a) && _.isNaN(b)) return false;
  7939. // Compare regular expressions.
  7940. if (_.isRegExp(a) && _.isRegExp(b))
  7941. return a.source === b.source &&
  7942. a.global === b.global &&
  7943. a.ignoreCase === b.ignoreCase &&
  7944. a.multiline === b.multiline;
  7945. // If a is not an object by this point, we can't handle it.
  7946. if (atype !== 'object') return false;
  7947. // Check for different array lengths before comparing contents.
  7948. if (a.length && (a.length !== b.length)) return false;
  7949. // Nothing else worked, deep compare the contents.
  7950. var aKeys = _.keys(a), bKeys = _.keys(b);
  7951. // Different object sizes?
  7952. if (aKeys.length != bKeys.length) return false;
  7953. // Recursive comparison of contents.
  7954. for (var key in a) if (!(key in b) || !_.isEqual(a[key], b[key])) return false;
  7955. return true;
  7956. };
  7957. // Is a given array or object empty?
  7958. _.isEmpty = function(obj) {
  7959. if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
  7960. for (var key in obj) if (hasOwnProperty.call(obj, key)) return false;
  7961. return true;
  7962. };
  7963. // Is a given value a DOM element?
  7964. _.isElement = function(obj) {
  7965. return !!(obj && obj.nodeType == 1);
  7966. };
  7967. // Is a given value an array?
  7968. // Delegates to ECMA5's native Array.isArray
  7969. _.isArray = nativeIsArray || function(obj) {
  7970. return toString.call(obj) === '[object Array]';
  7971. };
  7972. // Is a given variable an object?
  7973. _.isObject = function(obj) {
  7974. return obj === Object(obj);
  7975. };
  7976. // Is a given variable an arguments object?
  7977. _.isArguments = function(obj) {
  7978. return !!(obj && hasOwnProperty.call(obj, 'callee'));
  7979. };
  7980. // Is a given value a function?
  7981. _.isFunction = function(obj) {
  7982. return !!(obj && obj.constructor && obj.call && obj.apply);
  7983. };
  7984. // Is a given value a string?
  7985. _.isString = function(obj) {
  7986. return !!(obj === '' || (obj && obj.charCodeAt && obj.substr));
  7987. };
  7988. // Is a given value a number?
  7989. _.isNumber = function(obj) {
  7990. return !!(obj === 0 || (obj && obj.toExponential && obj.toFixed));
  7991. };
  7992. // Is the given value `NaN`? `NaN` happens to be the only value in JavaScript
  7993. // that does not equal itself.
  7994. _.isNaN = function(obj) {
  7995. return obj !== obj;
  7996. };
  7997. // Is a given value a boolean?
  7998. _.isBoolean = function(obj) {
  7999. return obj === true || obj === false;
  8000. };
  8001. // Is a given value a date?
  8002. _.isDate = function(obj) {
  8003. return !!(obj && obj.getTimezoneOffset && obj.setUTCFullYear);
  8004. };
  8005. // Is the given value a regular expression?
  8006. _.isRegExp = function(obj) {
  8007. return !!(obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false));
  8008. };
  8009. // Is a given value equal to null?
  8010. _.isNull = function(obj) {
  8011. return obj === null;
  8012. };
  8013. // Is a given variable undefined?
  8014. _.isUndefined = function(obj) {
  8015. return obj === void 0;
  8016. };
  8017. // Utility Functions
  8018. // -----------------
  8019. // Run Underscore.js in *noConflict* mode, returning the `_` variable to its
  8020. // previous owner. Returns a reference to the Underscore object.
  8021. _.noConflict = function() {
  8022. root._ = previousUnderscore;
  8023. return this;
  8024. };
  8025. // Keep the identity function around for default iterators.
  8026. _.identity = function(value) {
  8027. return value;
  8028. };
  8029. // Run a function **n** times.
  8030. _.times = function (n, iterator, context) {
  8031. for (var i = 0; i < n; i++) iterator.call(context, i);
  8032. };
  8033. // Add your own custom functions to the Underscore object, ensuring that
  8034. // they're correctly added to the OOP wrapper as well.
  8035. _.mixin = function(obj) {
  8036. each(_.functions(obj), function(name){
  8037. addToWrapper(name, _[name] = obj[name]);
  8038. });
  8039. };
  8040. // Generate a unique integer id (unique within the entire client session).
  8041. // Useful for temporary DOM ids.
  8042. var idCounter = 0;
  8043. _.uniqueId = function(prefix) {
  8044. var id = idCounter++;
  8045. return prefix ? prefix + id : id;
  8046. };
  8047. // By default, Underscore uses ERB-style template delimiters, change the
  8048. // following template settings to use alternative delimiters.
  8049. _.templateSettings = {
  8050. evaluate : /<%([\s\S]+?)%>/g,
  8051. interpolate : /<%=([\s\S]+?)%>/g
  8052. };
  8053. // JavaScript micro-templating, similar to John Resig's implementation.
  8054. // Underscore templating handles arbitrary delimiters, preserves whitespace,
  8055. // and correctly escapes quotes within interpolated code.
  8056. _.template = function(str, data) {
  8057. var c = _.templateSettings;
  8058. var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
  8059. 'with(obj||{}){__p.push(\'' +
  8060. str.replace(/\\/g, '\\\\')
  8061. .replace(/'/g, "\\'")
  8062. .replace(c.interpolate, function(match, code) {
  8063. return "'," + code.replace(/\\'/g, "'") + ",'";
  8064. })
  8065. .replace(c.evaluate || null, function(match, code) {
  8066. return "');" + code.replace(/\\'/g, "'")
  8067. .replace(/[\r\n\t]/g, ' ') + "__p.push('";
  8068. })
  8069. .replace(/\r/g, '\\r')
  8070. .replace(/\n/g, '\\n')
  8071. .replace(/\t/g, '\\t')
  8072. + "');}return __p.join('');";
  8073. var func = new Function('obj', tmpl);
  8074. return data ? func(data) : func;
  8075. };
  8076. // The OOP Wrapper
  8077. // ---------------
  8078. // If Underscore is called as a function, it returns a wrapped object that
  8079. // can be used OO-style. This wrapper holds altered versions of all the
  8080. // underscore functions. Wrapped objects may be chained.
  8081. var wrapper = function(obj) { this._wrapped = obj; };
  8082. // Expose `wrapper.prototype` as `_.prototype`
  8083. _.prototype = wrapper.prototype;
  8084. // Helper function to continue chaining intermediate results.
  8085. var result = function(obj, chain) {
  8086. return chain ? _(obj).chain() : obj;
  8087. };
  8088. // A method to easily add functions to the OOP wrapper.
  8089. var addToWrapper = function(name, func) {
  8090. wrapper.prototype[name] = function() {
  8091. var args = slice.call(arguments);
  8092. unshift.call(args, this._wrapped);
  8093. return result(func.apply(_, args), this._chain);
  8094. };
  8095. };
  8096. // Add all of the Underscore functions to the wrapper object.
  8097. _.mixin(_);
  8098. // Add all mutator Array functions to the wrapper.
  8099. each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
  8100. var method = ArrayProto[name];
  8101. wrapper.prototype[name] = function() {
  8102. method.apply(this._wrapped, arguments);
  8103. return result(this._wrapped, this._chain);
  8104. };
  8105. });
  8106. // Add all accessor Array functions to the wrapper.
  8107. each(['concat', 'join', 'slice'], function(name) {
  8108. var method = ArrayProto[name];
  8109. wrapper.prototype[name] = function() {
  8110. return result(method.apply(this._wrapped, arguments), this._chain);
  8111. };
  8112. });
  8113. // Start chaining a wrapped Underscore object.
  8114. wrapper.prototype.chain = function() {
  8115. this._chain = true;
  8116. return this;
  8117. };
  8118. // Extracts the result from a wrapped and chained object.
  8119. wrapper.prototype.value = function() {
  8120. return this._wrapped;
  8121. };
  8122. })();
  8123. // Backbone.js 0.5.3
  8124. // (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
  8125. // Backbone may be freely distributed under the MIT license.
  8126. // For all details and documentation:
  8127. // http://documentcloud.github.com/backbone
  8128. (function(){
  8129. // Initial Setup
  8130. // -------------
  8131. // Save a reference to the global object.
  8132. var root = this;
  8133. // Save the previous value of the `Backbone` variable.
  8134. var previousBackbone = root.Backbone;
  8135. // The top-level namespace. All public Backbone classes and modules will
  8136. // be attached to this. Exported for both CommonJS and the browser.
  8137. var Backbone;
  8138. if (typeof exports !== 'undefined') {
  8139. Backbone = exports;
  8140. } else {
  8141. Backbone = root.Backbone = {};
  8142. }
  8143. // Current version of the library. Keep in sync with `package.json`.
  8144. Backbone.VERSION = '0.5.3';
  8145. // Require Underscore, if we're on the server, and it's not already present.
  8146. var _ = root._;
  8147. if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;
  8148. // For Backbone's purposes, jQuery or Zepto owns the `$` variable.
  8149. var $ = root.jQuery || root.Zepto;
  8150. // Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
  8151. // to its previous owner. Returns a reference to this Backbone object.
  8152. Backbone.noConflict = function() {
  8153. root.Backbone = previousBackbone;
  8154. return this;
  8155. };
  8156. // Turn on `emulateHTTP` to support legacy HTTP servers. Setting this option will
  8157. // fake `"PUT"` and `"DELETE"` requests via the `_method` parameter and set a
  8158. // `X-Http-Method-Override` header.
  8159. Backbone.emulateHTTP = false;
  8160. // Turn on `emulateJSON` to support legacy servers that can't deal with direct
  8161. // `application/json` requests ... will encode the body as
  8162. // `application/x-www-form-urlencoded` instead and will send the model in a
  8163. // form param named `model`.
  8164. Backbone.emulateJSON = false;
  8165. // Backbone.Events
  8166. // -----------------
  8167. // A module that can be mixed in to *any object* in order to provide it with
  8168. // custom events. You may `bind` or `unbind` a callback function to an event;
  8169. // `trigger`-ing an event fires all callbacks in succession.
  8170. //
  8171. // var object = {};
  8172. // _.extend(object, Backbone.Events);
  8173. // object.bind('expand', function(){ alert('expanded'); });
  8174. // object.trigger('expand');
  8175. //
  8176. Backbone.Events = {
  8177. // Bind an event, specified by a string name, `ev`, to a `callback` function.
  8178. // Passing `"all"` will bind the callback to all events fired.
  8179. bind : function(ev, callback, context) {
  8180. var calls = this._callbacks || (this._callbacks = {});
  8181. var list = calls[ev] || (calls[ev] = []);
  8182. list.push([callback, context]);
  8183. return this;
  8184. },
  8185. // Remove one or many callbacks. If `callback` is null, removes all
  8186. // callbacks for the event. If `ev` is null, removes all bound callbacks
  8187. // for all events.
  8188. unbind : function(ev, callback) {
  8189. var calls;
  8190. if (!ev) {
  8191. this._callbacks = {};
  8192. } else if (calls = this._callbacks) {
  8193. if (!callback) {
  8194. calls[ev] = [];
  8195. } else {
  8196. var list = calls[ev];
  8197. if (!list) return this;
  8198. for (var i = 0, l = list.length; i < l; i++) {
  8199. if (list[i] && callback === list[i][0]) {
  8200. list[i] = null;
  8201. break;
  8202. }
  8203. }
  8204. }
  8205. }
  8206. return this;
  8207. },
  8208. // Trigger an event, firing all bound callbacks. Callbacks are passed the
  8209. // same arguments as `trigger` is, apart from the event name.
  8210. // Listening for `"all"` passes the true event name as the first argument.
  8211. trigger : function(eventName) {
  8212. var list, calls, ev, callback, args;
  8213. var both = 2;
  8214. if (!(calls = this._callbacks)) return this;
  8215. while (both--) {
  8216. ev = both ? eventName : 'all';
  8217. if (list = calls[ev]) {
  8218. for (var i = 0, l = list.length; i < l; i++) {
  8219. if (!(callback = list[i])) {
  8220. list.splice(i, 1); i--; l--;
  8221. } else {
  8222. args = both ? Array.prototype.slice.call(arguments, 1) : arguments;
  8223. callback[0].apply(callback[1] || this, args);
  8224. }
  8225. }
  8226. }
  8227. }
  8228. return this;
  8229. }
  8230. };
  8231. // Backbone.Model
  8232. // --------------
  8233. // Create a new model, with defined attributes. A client id (`cid`)
  8234. // is automatically generated and assigned for you.
  8235. Backbone.Model = function(attributes, options) {
  8236. var defaults;
  8237. attributes || (attributes = {});
  8238. if (defaults = this.defaults) {
  8239. if (_.isFunction(defaults)) defaults = defaults.call(this);
  8240. attributes = _.extend({}, defaults, attributes);
  8241. }
  8242. this.attributes = {};
  8243. this._escapedAttributes = {};
  8244. this.cid = _.uniqueId('c');
  8245. this.set(attributes, {silent : true});
  8246. this._changed = false;
  8247. this._previousAttributes = _.clone(this.attributes);
  8248. if (options && options.collection) this.collection = options.collection;
  8249. this.initialize(attributes, options);
  8250. };
  8251. // Attach all inheritable methods to the Model prototype.
  8252. _.extend(Backbone.Model.prototype, Backbone.Events, {
  8253. // A snapshot of the model's previous attributes, taken immediately
  8254. // after the last `"change"` event was fired.
  8255. _previousAttributes : null,
  8256. // Has the item been changed since the last `"change"` event?
  8257. _changed : false,
  8258. // The default name for the JSON `id` attribute is `"id"`. MongoDB and
  8259. // CouchDB users may want to set this to `"_id"`.
  8260. idAttribute : 'id',
  8261. // Initialize is an empty function by default. Override it with your own
  8262. // initialization logic.
  8263. initialize : function(){},
  8264. // Return a copy of the model's `attributes` object.
  8265. toJSON : function() {
  8266. return _.clone(this.attributes);
  8267. },
  8268. // Get the value of an attribute.
  8269. get : function(attr) {
  8270. return this.attributes[attr];
  8271. },
  8272. // Get the HTML-escaped value of an attribute.
  8273. escape : function(attr) {
  8274. var html;
  8275. if (html = this._escapedAttributes[attr]) return html;
  8276. var val = this.attributes[attr];
  8277. return this._escapedAttributes[attr] = escapeHTML(val == null ? '' : '' + val);
  8278. },
  8279. // Returns `true` if the attribute contains a value that is not null
  8280. // or undefined.
  8281. has : function(attr) {
  8282. return this.attributes[attr] != null;
  8283. },
  8284. // Set a hash of model attributes on the object, firing `"change"` unless you
  8285. // choose to silence it.
  8286. set : function(attrs, options) {
  8287. // Extract attributes and options.
  8288. options || (options = {});
  8289. if (!attrs) return this;
  8290. if (attrs.attributes) attrs = attrs.attributes;
  8291. var now = this.attributes, escaped = this._escapedAttributes;
  8292. // Run validation.
  8293. if (!options.silent && this.validate && !this._performValidation(attrs, options)) return false;
  8294. // Check for changes of `id`.
  8295. if (this.idAttribute in attrs) this.id = attrs[this.idAttribute];
  8296. // We're about to start triggering change events.
  8297. var alreadyChanging = this._changing;
  8298. this._changing = true;
  8299. // Update attributes.
  8300. for (var attr in attrs) {
  8301. var val = attrs[attr];
  8302. if (!_.isEqual(now[attr], val)) {
  8303. now[attr] = val;
  8304. delete escaped[attr];
  8305. this._changed = true;
  8306. if (!options.silent) this.trigger('change:' + attr, this, val, options);
  8307. }
  8308. }
  8309. // Fire the `"change"` event, if the model has been changed.
  8310. if (!alreadyChanging && !options.silent && this._changed) this.change(options);
  8311. this._changing = false;
  8312. return this;
  8313. },
  8314. // Remove an attribute from the model, firing `"change"` unless you choose
  8315. // to silence it. `unset` is a noop if the attribute doesn't exist.
  8316. unset : function(attr, options) {
  8317. if (!(attr in this.attributes)) return this;
  8318. options || (options = {});
  8319. var value = this.attributes[attr];
  8320. // Run validation.
  8321. var validObj = {};
  8322. validObj[attr] = void 0;
  8323. if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;
  8324. // Remove the attribute.
  8325. delete this.attributes[attr];
  8326. delete this._escapedAttributes[attr];
  8327. if (attr == this.idAttribute) delete this.id;
  8328. this._changed = true;
  8329. if (!options.silent) {
  8330. this.trigger('change:' + attr, this, void 0, options);
  8331. this.change(options);
  8332. }
  8333. return this;
  8334. },
  8335. // Clear all attributes on the model, firing `"change"` unless you choose
  8336. // to silence it.
  8337. clear : function(options) {
  8338. options || (options = {});
  8339. var attr;
  8340. var old = this.attributes;
  8341. // Run validation.
  8342. var validObj = {};
  8343. for (attr in old) validObj[attr] = void 0;
  8344. if (!options.silent && this.validate && !this._performValidation(validObj, options)) return false;
  8345. this.attributes = {};
  8346. this._escapedAttributes = {};
  8347. this._changed = true;
  8348. if (!options.silent) {
  8349. for (attr in old) {
  8350. this.trigger('change:' + attr, this, void 0, options);
  8351. }
  8352. this.change(options);
  8353. }
  8354. return this;
  8355. },
  8356. // Fetch the model from the server. If the server's representation of the
  8357. // model differs from its current attributes, they will be overriden,
  8358. // triggering a `"change"` event.
  8359. fetch : function(options) {
  8360. options || (options = {});
  8361. var model = this;
  8362. var success = options.success;
  8363. options.success = function(resp, status, xhr) {
  8364. if (!model.set(model.parse(resp, xhr), options)) return false;
  8365. if (success) success(model, resp);
  8366. };
  8367. options.error = wrapError(options.error, model, options);
  8368. return (this.sync || Backbone.sync).call(this, 'read', this, options);
  8369. },
  8370. // Set a hash of model attributes, and sync the model to the server.
  8371. // If the server returns an attributes hash that differs, the model's
  8372. // state will be `set` again.
  8373. save : function(attrs, options) {
  8374. options || (options = {});
  8375. if (attrs && !this.set(attrs, options)) return false;
  8376. var model = this;
  8377. var success = options.success;
  8378. options.success = function(resp, status, xhr) {
  8379. if (!model.set(model.parse(resp, xhr), options)) return false;
  8380. if (success) success(model, resp, xhr);
  8381. };
  8382. options.error = wrapError(options.error, model, options);
  8383. var method = this.isNew() ? 'create' : 'update';
  8384. return (this.sync || Backbone.sync).call(this, method, this, options);
  8385. },
  8386. // Destroy this model on the server if it was already persisted. Upon success, the model is removed
  8387. // from its collection, if it has one.
  8388. destroy : function(options) {
  8389. options || (options = {});
  8390. if (this.isNew()) return this.trigger('destroy', this, this.collection, options);
  8391. var model = this;
  8392. var success = options.success;
  8393. options.success = function(resp) {
  8394. model.trigger('destroy', model, model.collection, options);
  8395. if (success) success(model, resp);
  8396. };
  8397. options.error = wrapError(options.error, model, options);
  8398. return (this.sync || Backbone.sync).call(this, 'delete', this, options);
  8399. },
  8400. // Default URL for the model's representation on the server -- if you're
  8401. // using Backbone's restful methods, override this to change the endpoint
  8402. // that will be called.
  8403. url : function() {
  8404. var base = getUrl(this.collection) || this.urlRoot || urlError();
  8405. if (this.isNew()) return base;
  8406. return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);
  8407. },
  8408. // **parse** converts a response into the hash of attributes to be `set` on
  8409. // the model. The default implementation is just to pass the response along.
  8410. parse : function(resp, xhr) {
  8411. return resp;
  8412. },
  8413. // Create a new model with identical attributes to this one.
  8414. clone : function() {
  8415. return new this.constructor(this);
  8416. },
  8417. // A model is new if it has never been saved to the server, and lacks an id.
  8418. isNew : function() {
  8419. return this.id == null;
  8420. },
  8421. // Call this method to manually fire a `change` event for this model.
  8422. // Calling this will cause all objects observing the model to update.
  8423. change : function(options) {
  8424. this.trigger('change', this, options);
  8425. this._previousAttributes = _.clone(this.attributes);
  8426. this._changed = false;
  8427. },
  8428. // Determine if the model has changed since the last `"change"` event.
  8429. // If you specify an attribute name, determine if that attribute has changed.
  8430. hasChanged : function(attr) {
  8431. if (attr) return this._previousAttributes[attr] != this.attributes[attr];
  8432. return this._changed;
  8433. },
  8434. // Return an object containing all the attributes that have changed, or false
  8435. // if there are no changed attributes. Useful for determining what parts of a
  8436. // view need to be updated and/or what attributes need to be persisted to
  8437. // the server.
  8438. changedAttributes : function(now) {
  8439. now || (now = this.attributes);
  8440. var old = this._previousAttributes;
  8441. var changed = false;
  8442. for (var attr in now) {
  8443. if (!_.isEqual(old[attr], now[attr])) {
  8444. changed = changed || {};
  8445. changed[attr] = now[attr];
  8446. }
  8447. }
  8448. return changed;
  8449. },
  8450. // Get the previous value of an attribute, recorded at the time the last
  8451. // `"change"` event was fired.
  8452. previous : function(attr) {
  8453. if (!attr || !this._previousAttributes) return null;
  8454. return this._previousAttributes[attr];
  8455. },
  8456. // Get all of the attributes of the model at the time of the previous
  8457. // `"change"` event.
  8458. previousAttributes : function() {
  8459. return _.clone(this._previousAttributes);
  8460. },
  8461. // Run validation against a set of incoming attributes, returning `true`
  8462. // if all is well. If a specific `error` callback has been passed,
  8463. // call that instead of firing the general `"error"` event.
  8464. _performValidation : function(attrs, options) {
  8465. var error = this.validate(attrs);
  8466. if (error) {
  8467. if (options.error) {
  8468. options.error(this, error, options);
  8469. } else {
  8470. this.trigger('error', this, error, options);
  8471. }
  8472. return false;
  8473. }
  8474. return true;
  8475. }
  8476. });
  8477. // Backbone.Collection
  8478. // -------------------
  8479. // Provides a standard collection class for our sets of models, ordered
  8480. // or unordered. If a `comparator` is specified, the Collection will maintain
  8481. // its models in sort order, as they're added and removed.
  8482. Backbone.Collection = function(models, options) {
  8483. options || (options = {});
  8484. if (options.comparator) this.comparator = options.comparator;
  8485. _.bindAll(this, '_onModelEvent', '_removeReference');
  8486. this._reset();
  8487. if (models) this.reset(models, {silent: true});
  8488. this.initialize.apply(this, arguments);
  8489. };
  8490. // Define the Collection's inheritable methods.
  8491. _.extend(Backbone.Collection.prototype, Backbone.Events, {
  8492. // The default model for a collection is just a **Backbone.Model**.
  8493. // This should be overridden in most cases.
  8494. model : Backbone.Model,
  8495. // Initialize is an empty function by default. Override it with your own
  8496. // initialization logic.
  8497. initialize : function(){},
  8498. // The JSON representation of a Collection is an array of the
  8499. // models' attributes.
  8500. toJSON : function() {
  8501. return this.map(function(model){ return model.toJSON(); });
  8502. },
  8503. // Add a model, or list of models to the set. Pass **silent** to avoid
  8504. // firing the `added` event for every new model.
  8505. add : function(models, options) {
  8506. if (_.isArray(models)) {
  8507. for (var i = 0, l = models.length; i < l; i++) {
  8508. this._add(models[i], options);
  8509. }
  8510. } else {
  8511. this._add(models, options);
  8512. }
  8513. return this;
  8514. },
  8515. // Remove a model, or a list of models from the set. Pass silent to avoid
  8516. // firing the `removed` event for every model removed.
  8517. remove : function(models, options) {
  8518. if (_.isArray(models)) {
  8519. for (var i = 0, l = models.length; i < l; i++) {
  8520. this._remove(models[i], options);
  8521. }
  8522. } else {
  8523. this._remove(models, options);
  8524. }
  8525. return this;
  8526. },
  8527. // Get a model from the set by id.
  8528. get : function(id) {
  8529. if (id == null) return null;
  8530. return this._byId[id.id != null ? id.id : id];
  8531. },
  8532. // Get a model from the set by client id.
  8533. getByCid : function(cid) {
  8534. return cid && this._byCid[cid.cid || cid];
  8535. },
  8536. // Get the model at the given index.
  8537. at: function(index) {
  8538. return this.models[index];
  8539. },
  8540. // Force the collection to re-sort itself. You don't need to call this under normal
  8541. // circumstances, as the set will maintain sort order as each item is added.
  8542. sort : function(options) {
  8543. options || (options = {});
  8544. if (!this.comparator) throw new Error('Cannot sort a set without a comparator');
  8545. this.models = this.sortBy(this.comparator);
  8546. if (!options.silent) this.trigger('reset', this, options);
  8547. return this;
  8548. },
  8549. // Pluck an attribute from each model in the collection.
  8550. pluck : function(attr) {
  8551. return _.map(this.models, function(model){ return model.get(attr); });
  8552. },
  8553. // When you have more items than you want to add or remove individually,
  8554. // you can reset the entire set with a new list of models, without firing
  8555. // any `added` or `removed` events. Fires `reset` when finished.
  8556. reset : function(models, options) {
  8557. models || (models = []);
  8558. options || (options = {});
  8559. this.each(this._removeReference);
  8560. this._reset();
  8561. this.add(models, {silent: true});
  8562. if (!options.silent) this.trigger('reset', this, options);
  8563. return this;
  8564. },
  8565. // Fetch the default set of models for this collection, resetting the
  8566. // collection when they arrive. If `add: true` is passed, appends the
  8567. // models to the collection instead of resetting.
  8568. fetch : function(options) {
  8569. options || (options = {});
  8570. var collection = this;
  8571. var success = options.success;
  8572. options.success = function(resp, status, xhr) {
  8573. collection[options.add ? 'add' : 'reset'](collection.parse(resp, xhr), options);
  8574. if (success) success(collection, resp);
  8575. };
  8576. options.error = wrapError(options.error, collection, options);
  8577. return (this.sync || Backbone.sync).call(this, 'read', this, options);
  8578. },
  8579. // Create a new instance of a model in this collection. After the model
  8580. // has been created on the server, it will be added to the collection.
  8581. // Returns the model, or 'false' if validation on a new model fails.
  8582. create : function(model, options) {
  8583. var coll = this;
  8584. options || (options = {});
  8585. model = this._prepareModel(model, options);
  8586. if (!model) return false;
  8587. var success = options.success;
  8588. options.success = function(nextModel, resp, xhr) {
  8589. coll.add(nextModel, options);
  8590. if (success) success(nextModel, resp, xhr);
  8591. };
  8592. model.save(null, options);
  8593. return model;
  8594. },
  8595. // **parse** converts a response into a list of models to be added to the
  8596. // collection. The default implementation is just to pass it through.
  8597. parse : function(resp, xhr) {
  8598. return resp;
  8599. },
  8600. // Proxy to _'s chain. Can't be proxied the same way the rest of the
  8601. // underscore methods are proxied because it relies on the underscore
  8602. // constructor.
  8603. chain: function () {
  8604. return _(this.models).chain();
  8605. },
  8606. // Reset all internal state. Called when the collection is reset.
  8607. _reset : function(options) {
  8608. this.length = 0;
  8609. this.models = [];
  8610. this._byId = {};
  8611. this._byCid = {};
  8612. },
  8613. // Prepare a model to be added to this collection
  8614. _prepareModel: function(model, options) {
  8615. if (!(model instanceof Backbone.Model)) {
  8616. var attrs = model;
  8617. model = new this.model(attrs, {collection: this});
  8618. if (model.validate && !model._performValidation(attrs, options)) model = false;
  8619. } else if (!model.collection) {
  8620. model.collection = this;
  8621. }
  8622. return model;
  8623. },
  8624. // Internal implementation of adding a single model to the set, updating
  8625. // hash indexes for `id` and `cid` lookups.
  8626. // Returns the model, or 'false' if validation on a new model fails.
  8627. _add : function(model, options) {
  8628. options || (options = {});
  8629. model = this._prepareModel(model, options);
  8630. if (!model) return false;
  8631. var already = this.getByCid(model);
  8632. if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
  8633. this._byId[model.id] = model;
  8634. this._byCid[model.cid] = model;
  8635. var index = options.at != null ? options.at :
  8636. this.comparator ? this.sortedIndex(model, this.comparator) :
  8637. this.length;
  8638. this.models.splice(index, 0, model);
  8639. model.bind('all', this._onModelEvent);
  8640. this.length++;
  8641. if (!options.silent) model.trigger('add', model, this, options);
  8642. return model;
  8643. },
  8644. // Internal implementation of removing a single model from the set, updating
  8645. // hash indexes for `id` and `cid` lookups.
  8646. _remove : function(model, options) {
  8647. options || (options = {});
  8648. model = this.getByCid(model) || this.get(model);
  8649. if (!model) return null;
  8650. delete this._byId[model.id];
  8651. delete this._byCid[model.cid];
  8652. this.models.splice(this.indexOf(model), 1);
  8653. this.length--;
  8654. if (!options.silent) model.trigger('remove', model, this, options);
  8655. this._removeReference(model);
  8656. return model;
  8657. },
  8658. // Internal method to remove a model's ties to a collection.
  8659. _removeReference : function(model) {
  8660. if (this == model.collection) {
  8661. delete model.collection;
  8662. }
  8663. model.unbind('all', this._onModelEvent);
  8664. },
  8665. // Internal method called every time a model in the set fires an event.
  8666. // Sets need to update their indexes when models change ids. All other
  8667. // events simply proxy through. "add" and "remove" events that originate
  8668. // in other collections are ignored.
  8669. _onModelEvent : function(ev, model, collection, options) {
  8670. if ((ev == 'add' || ev == 'remove') && collection != this) return;
  8671. if (ev == 'destroy') {
  8672. this._remove(model, options);
  8673. }
  8674. if (model && ev === 'change:' + model.idAttribute) {
  8675. delete this._byId[model.previous(model.idAttribute)];
  8676. this._byId[model.id] = model;
  8677. }
  8678. this.trigger.apply(this, arguments);
  8679. }
  8680. });
  8681. // Underscore methods that we want to implement on the Collection.
  8682. var methods = ['forEach', 'each', 'map', 'reduce', 'reduceRight', 'find', 'detect',
  8683. 'filter', 'select', 'reject', 'every', 'all', 'some', 'any', 'include',
  8684. 'contains', 'invoke', 'max', 'min', 'sortBy', 'sortedIndex', 'toArray', 'size',
  8685. 'first', 'rest', 'last', 'without', 'indexOf', 'lastIndexOf', 'isEmpty', 'groupBy'];
  8686. // Mix in each Underscore method as a proxy to `Collection#models`.
  8687. _.each(methods, function(method) {
  8688. Backbone.Collection.prototype[method] = function() {
  8689. return _[method].apply(_, [this.models].concat(_.toArray(arguments)));
  8690. };
  8691. });
  8692. // Backbone.Router
  8693. // -------------------
  8694. // Routers map faux-URLs to actions, and fire events when routes are
  8695. // matched. Creating a new one sets its `routes` hash, if not set statically.
  8696. Backbone.Router = function(options) {
  8697. options || (options = {});
  8698. if (options.routes) this.routes = options.routes;
  8699. this._bindRoutes();
  8700. this.initialize.apply(this, arguments);
  8701. };
  8702. // Cached regular expressions for matching named param parts and splatted
  8703. // parts of route strings.
  8704. var namedParam = /:([\w\d]+)/g;
  8705. var splatParam = /\*([\w\d]+)/g;
  8706. var escapeRegExp = /[-[\]{}()+?.,\\^$|#\s]/g;
  8707. // Set up all inheritable **Backbone.Router** properties and methods.
  8708. _.extend(Backbone.Router.prototype, Backbone.Events, {
  8709. // Initialize is an empty function by default. Override it with your own
  8710. // initialization logic.
  8711. initialize : function(){},
  8712. // Manually bind a single named route to a callback. For example:
  8713. //
  8714. // this.route('search/:query/p:num', 'search', function(query, num) {
  8715. // ...
  8716. // });
  8717. //
  8718. route : function(route, name, callback) {
  8719. Backbone.history || (Backbone.history = new Backbone.History);
  8720. if (!_.isRegExp(route)) route = this._routeToRegExp(route);
  8721. Backbone.history.route(route, _.bind(function(fragment) {
  8722. var args = this._extractParameters(route, fragment);
  8723. callback.apply(this, args);
  8724. this.trigger.apply(this, ['route:' + name].concat(args));
  8725. }, this));
  8726. },
  8727. // Simple proxy to `Backbone.history` to save a fragment into the history.
  8728. navigate : function(fragment, triggerRoute) {
  8729. Backbone.history.navigate(fragment, triggerRoute);
  8730. },
  8731. // Bind all defined routes to `Backbone.history`. We have to reverse the
  8732. // order of the routes here to support behavior where the most general
  8733. // routes can be defined at the bottom of the route map.
  8734. _bindRoutes : function() {
  8735. if (!this.routes) return;
  8736. var routes = [];
  8737. for (var route in this.routes) {
  8738. routes.unshift([route, this.routes[route]]);
  8739. }
  8740. for (var i = 0, l = routes.length; i < l; i++) {
  8741. this.route(routes[i][0], routes[i][1], this[routes[i][1]]);
  8742. }
  8743. },
  8744. // Convert a route string into a regular expression, suitable for matching
  8745. // against the current location hash.
  8746. _routeToRegExp : function(route) {
  8747. route = route.replace(escapeRegExp, "\\$&")
  8748. .replace(namedParam, "([^\/]*)")
  8749. .replace(splatParam, "(.*?)");
  8750. return new RegExp('^' + route + '$');
  8751. },
  8752. // Given a route, and a URL fragment that it matches, return the array of
  8753. // extracted parameters.
  8754. _extractParameters : function(route, fragment) {
  8755. return route.exec(fragment).slice(1);
  8756. }
  8757. });
  8758. // Backbone.History
  8759. // ----------------
  8760. // Handles cross-browser history management, based on URL fragments. If the
  8761. // browser does not support `onhashchange`, falls back to polling.
  8762. Backbone.History = function() {
  8763. this.handlers = [];
  8764. _.bindAll(this, 'checkUrl');
  8765. };
  8766. // Cached regex for cleaning hashes.
  8767. var hashStrip = /^#*/;
  8768. // Cached regex for detecting MSIE.
  8769. var isExplorer = /msie [\w.]+/;
  8770. // Has the history handling already been started?
  8771. var historyStarted = false;
  8772. // Set up all inheritable **Backbone.History** properties and methods.
  8773. _.extend(Backbone.History.prototype, {
  8774. // The default interval to poll for hash changes, if necessary, is
  8775. // twenty times a second.
  8776. interval: 50,
  8777. // Get the cross-browser normalized URL fragment, either from the URL,
  8778. // the hash, or the override.
  8779. getFragment : function(fragment, forcePushState) {
  8780. if (fragment == null) {
  8781. if (this._hasPushState || forcePushState) {
  8782. fragment = window.location.pathname;
  8783. var search = window.location.search;
  8784. if (search) fragment += search;
  8785. if (fragment.indexOf(this.options.root) == 0) fragment = fragment.substr(this.options.root.length);
  8786. } else {
  8787. fragment = window.location.hash;
  8788. }
  8789. }
  8790. return decodeURIComponent(fragment.replace(hashStrip, ''));
  8791. },
  8792. // Start the hash change handling, returning `true` if the current URL matches
  8793. // an existing route, and `false` otherwise.
  8794. start : function(options) {
  8795. // Figure out the initial configuration. Do we need an iframe?
  8796. // Is pushState desired ... is it available?
  8797. if (historyStarted) throw new Error("Backbone.history has already been started");
  8798. this.options = _.extend({}, {root: '/'}, this.options, options);
  8799. this._wantsPushState = !!this.options.pushState;
  8800. this._hasPushState = !!(this.options.pushState && window.history && window.history.pushState);
  8801. var fragment = this.getFragment();
  8802. var docMode = document.documentMode;
  8803. var oldIE = (isExplorer.exec(navigator.userAgent.toLowerCase()) && (!docMode || docMode <= 7));
  8804. if (oldIE) {
  8805. this.iframe = $('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo('body')[0].contentWindow;
  8806. this.navigate(fragment);
  8807. }
  8808. // Depending on whether we're using pushState or hashes, and whether
  8809. // 'onhashchange' is supported, determine how we check the URL state.
  8810. if (this._hasPushState) {
  8811. $(window).bind('popstate', this.checkUrl);
  8812. } else if ('onhashchange' in window && !oldIE) {
  8813. $(window).bind('hashchange', this.checkUrl);
  8814. } else {
  8815. setInterval(this.checkUrl, this.interval);
  8816. }
  8817. // Determine if we need to change the base url, for a pushState link
  8818. // opened by a non-pushState browser.
  8819. this.fragment = fragment;
  8820. historyStarted = true;
  8821. var loc = window.location;
  8822. var atRoot = loc.pathname == this.options.root;
  8823. if (this._wantsPushState && !this._hasPushState && !atRoot) {
  8824. this.fragment = this.getFragment(null, true);
  8825. window.location.replace(this.options.root + '#' + this.fragment);
  8826. // Return immediately as browser will do redirect to new url
  8827. return true;
  8828. } else if (this._wantsPushState && this._hasPushState && atRoot && loc.hash) {
  8829. this.fragment = loc.hash.replace(hashStrip, '');
  8830. window.history.replaceState({}, document.title, loc.protocol + '//' + loc.host + this.options.root + this.fragment);
  8831. }
  8832. if (!this.options.silent) {
  8833. return this.loadUrl();
  8834. }
  8835. },
  8836. // Add a route to be tested when the fragment changes. Routes added later may
  8837. // override previous routes.
  8838. route : function(route, callback) {
  8839. this.handlers.unshift({route : route, callback : callback});
  8840. },
  8841. // Checks the current URL to see if it has changed, and if it has,
  8842. // calls `loadUrl`, normalizing across the hidden iframe.
  8843. checkUrl : function(e) {
  8844. var current = this.getFragment();
  8845. if (current == this.fragment && this.iframe) current = this.getFragment(this.iframe.location.hash);
  8846. if (current == this.fragment || current == decodeURIComponent(this.fragment)) return false;
  8847. if (this.iframe) this.navigate(current);
  8848. this.loadUrl() || this.loadUrl(window.location.hash);
  8849. },
  8850. // Attempt to load the current URL fragment. If a route succeeds with a
  8851. // match, returns `true`. If no defined routes matches the fragment,
  8852. // returns `false`.
  8853. loadUrl : function(fragmentOverride) {
  8854. var fragment = this.fragment = this.getFragment(fragmentOverride);
  8855. var matched = _.any(this.handlers, function(handler) {
  8856. if (handler.route.test(fragment)) {
  8857. handler.callback(fragment);
  8858. return true;
  8859. }
  8860. });
  8861. return matched;
  8862. },
  8863. // Save a fragment into the hash history. You are responsible for properly
  8864. // URL-encoding the fragment in advance. This does not trigger
  8865. // a `hashchange` event.
  8866. navigate : function(fragment, triggerRoute) {
  8867. var frag = (fragment || '').replace(hashStrip, '');
  8868. if (this.fragment == frag || this.fragment == decodeURIComponent(frag)) return;
  8869. if (this._hasPushState) {
  8870. var loc = window.location;
  8871. if (frag.indexOf(this.options.root) != 0) frag = this.options.root + frag;
  8872. this.fragment = frag;
  8873. window.history.pushState({}, document.title, loc.protocol + '//' + loc.host + frag);
  8874. } else {
  8875. window.location.hash = this.fragment = frag;
  8876. if (this.iframe && (frag != this.getFragment(this.iframe.location.hash))) {
  8877. this.iframe.document.open().close();
  8878. this.iframe.location.hash = frag;
  8879. }
  8880. }
  8881. if (triggerRoute) this.loadUrl(fragment);
  8882. }
  8883. });
  8884. // Backbone.View
  8885. // -------------
  8886. // Creating a Backbone.View creates its initial element outside of the DOM,
  8887. // if an existing element is not provided...
  8888. Backbone.View = function(options) {
  8889. this.cid = _.uniqueId('view');
  8890. this._configure(options || {});
  8891. this._ensureElement();
  8892. this.delegateEvents();
  8893. this.initialize.apply(this, arguments);
  8894. };
  8895. // Element lookup, scoped to DOM elements within the current view.
  8896. // This should be prefered to global lookups, if you're dealing with
  8897. // a specific view.
  8898. var selectorDelegate = function(selector) {
  8899. return $(selector, this.el);
  8900. };
  8901. // Cached regex to split keys for `delegate`.
  8902. var eventSplitter = /^(\S+)\s*(.*)$/;
  8903. // List of view options to be merged as properties.
  8904. var viewOptions = ['model', 'collection', 'el', 'id', 'attributes', 'className', 'tagName'];
  8905. // Set up all inheritable **Backbone.View** properties and methods.
  8906. _.extend(Backbone.View.prototype, Backbone.Events, {
  8907. // The default `tagName` of a View's element is `"div"`.
  8908. tagName : 'div',
  8909. // Attach the `selectorDelegate` function as the `$` property.
  8910. $ : selectorDelegate,
  8911. // Initialize is an empty function by default. Override it with your own
  8912. // initialization logic.
  8913. initialize : function(){},
  8914. // **render** is the core function that your view should override, in order
  8915. // to populate its element (`this.el`), with the appropriate HTML. The
  8916. // convention is for **render** to always return `this`.
  8917. render : function() {
  8918. return this;
  8919. },
  8920. // Remove this view from the DOM. Note that the view isn't present in the
  8921. // DOM by default, so calling this method may be a no-op.
  8922. remove : function() {
  8923. $(this.el).remove();
  8924. return this;
  8925. },
  8926. // For small amounts of DOM Elements, where a full-blown template isn't
  8927. // needed, use **make** to manufacture elements, one at a time.
  8928. //
  8929. // var el = this.make('li', {'class': 'row'}, this.model.escape('title'));
  8930. //
  8931. make : function(tagName, attributes, content) {
  8932. var el = document.createElement(tagName);
  8933. if (attributes) $(el).attr(attributes);
  8934. if (content) $(el).html(content);
  8935. return el;
  8936. },
  8937. // Set callbacks, where `this.callbacks` is a hash of
  8938. //
  8939. // *{"event selector": "callback"}*
  8940. //
  8941. // {
  8942. // 'mousedown .title': 'edit',
  8943. // 'click .button': 'save'
  8944. // }
  8945. //
  8946. // pairs. Callbacks will be bound to the view, with `this` set properly.
  8947. // Uses event delegation for efficiency.
  8948. // Omitting the selector binds the event to `this.el`.
  8949. // This only works for delegate-able events: not `focus`, `blur`, and
  8950. // not `change`, `submit`, and `reset` in Internet Explorer.
  8951. delegateEvents : function(events) {
  8952. if (!(events || (events = this.events))) return;
  8953. if (_.isFunction(events)) events = events.call(this);
  8954. $(this.el).unbind('.delegateEvents' + this.cid);
  8955. for (var key in events) {
  8956. var method = this[events[key]];
  8957. if (!method) throw new Error('Event "' + events[key] + '" does not exist');
  8958. var match = key.match(eventSplitter);
  8959. var eventName = match[1], selector = match[2];
  8960. method = _.bind(method, this);
  8961. eventName += '.delegateEvents' + this.cid;
  8962. if (selector === '') {
  8963. $(this.el).bind(eventName, method);
  8964. } else {
  8965. $(this.el).delegate(selector, eventName, method);
  8966. }
  8967. }
  8968. },
  8969. // Performs the initial configuration of a View with a set of options.
  8970. // Keys with special meaning *(model, collection, id, className)*, are
  8971. // attached directly to the view.
  8972. _configure : function(options) {
  8973. if (this.options) options = _.extend({}, this.options, options);
  8974. for (var i = 0, l = viewOptions.length; i < l; i++) {
  8975. var attr = viewOptions[i];
  8976. if (options[attr]) this[attr] = options[attr];
  8977. }
  8978. this.options = options;
  8979. },
  8980. // Ensure that the View has a DOM element to render into.
  8981. // If `this.el` is a string, pass it through `$()`, take the first
  8982. // matching element, and re-assign it to `el`. Otherwise, create
  8983. // an element from the `id`, `className` and `tagName` proeprties.
  8984. _ensureElement : function() {
  8985. if (!this.el) {
  8986. var attrs = this.attributes || {};
  8987. if (this.id) attrs.id = this.id;
  8988. if (this.className) attrs['class'] = this.className;
  8989. this.el = this.make(this.tagName, attrs);
  8990. } else if (_.isString(this.el)) {
  8991. this.el = $(this.el).get(0);
  8992. }
  8993. }
  8994. });
  8995. // The self-propagating extend function that Backbone classes use.
  8996. var extend = function (protoProps, classProps) {
  8997. var child = inherits(this, protoProps, classProps);
  8998. child.extend = this.extend;
  8999. return child;
  9000. };
  9001. // Set up inheritance for the model, collection, and view.
  9002. Backbone.Model.extend = Backbone.Collection.extend =
  9003. Backbone.Router.extend = Backbone.View.extend = extend;
  9004. // Map from CRUD to HTTP for our default `Backbone.sync` implementation.
  9005. var methodMap = {
  9006. 'create': 'POST',
  9007. 'update': 'PUT',
  9008. 'delete': 'DELETE',
  9009. 'read' : 'GET'
  9010. };
  9011. // Backbone.sync
  9012. // -------------
  9013. // Override this function to change the manner in which Backbone persists
  9014. // models to the server. You will be passed the type of request, and the
  9015. // model in question. By default, uses makes a RESTful Ajax request
  9016. // to the model's `url()`. Some possible customizations could be:
  9017. //
  9018. // * Use `setTimeout` to batch rapid-fire updates into a single request.
  9019. // * Send up the models as XML instead of JSON.
  9020. // * Persist models via WebSockets instead of Ajax.
  9021. //
  9022. // Turn on `Backbone.emulateHTTP` in order to send `PUT` and `DELETE` requests
  9023. // as `POST`, with a `_method` parameter containing the true HTTP method,
  9024. // as well as all requests with the body as `application/x-www-form-urlencoded` instead of
  9025. // `application/json` with the model in a param named `model`.
  9026. // Useful when interfacing with server-side languages like **PHP** that make
  9027. // it difficult to read the body of `PUT` requests.
  9028. Backbone.sync = function(method, model, options) {
  9029. var type = methodMap[method];
  9030. // Default JSON-request options.
  9031. var params = _.extend({
  9032. type: type,
  9033. dataType: 'json'
  9034. }, options);
  9035. // Ensure that we have a URL.
  9036. if (!params.url) {
  9037. params.url = getUrl(model) || urlError();
  9038. }
  9039. // Ensure that we have the appropriate request data.
  9040. if (!params.data && model && (method == 'create' || method == 'update')) {
  9041. params.contentType = 'application/json';
  9042. params.data = JSON.stringify(model.toJSON());
  9043. }
  9044. // For older servers, emulate JSON by encoding the request into an HTML-form.
  9045. if (Backbone.emulateJSON) {
  9046. params.contentType = 'application/x-www-form-urlencoded';
  9047. params.data = params.data ? {model : params.data} : {};
  9048. }
  9049. // For older servers, emulate HTTP by mimicking the HTTP method with `_method`
  9050. // And an `X-HTTP-Method-Override` header.
  9051. if (Backbone.emulateHTTP) {
  9052. if (type === 'PUT' || type === 'DELETE') {
  9053. if (Backbone.emulateJSON) params.data._method = type;
  9054. params.type = 'POST';
  9055. params.beforeSend = function(xhr) {
  9056. xhr.setRequestHeader('X-HTTP-Method-Override', type);
  9057. };
  9058. }
  9059. }
  9060. // Don't process data on a non-GET request.
  9061. if (params.type !== 'GET' && !Backbone.emulateJSON) {
  9062. params.processData = false;
  9063. }
  9064. // Make the request.
  9065. return $.ajax(params);
  9066. };
  9067. // Helpers
  9068. // -------
  9069. // Shared empty constructor function to aid in prototype-chain creation.
  9070. var ctor = function(){};
  9071. // Helper function to correctly set up the prototype chain, for subclasses.
  9072. // Similar to `goog.inherits`, but uses a hash of prototype properties and
  9073. // class properties to be extended.
  9074. var inherits = function(parent, protoProps, staticProps) {
  9075. var child;
  9076. // The constructor function for the new subclass is either defined by you
  9077. // (the "constructor" property in your `extend` definition), or defaulted
  9078. // by us to simply call `super()`.
  9079. if (protoProps && protoProps.hasOwnProperty('constructor')) {
  9080. child = protoProps.constructor;
  9081. } else {
  9082. child = function(){ return parent.apply(this, arguments); };
  9083. }
  9084. // Inherit class (static) properties from parent.
  9085. _.extend(child, parent);
  9086. // Set the prototype chain to inherit from `parent`, without calling
  9087. // `parent`'s constructor function.
  9088. ctor.prototype = parent.prototype;
  9089. child.prototype = new ctor();
  9090. // Add prototype properties (instance properties) to the subclass,
  9091. // if supplied.
  9092. if (protoProps) _.extend(child.prototype, protoProps);
  9093. // Add static properties to the constructor function, if supplied.
  9094. if (staticProps) _.extend(child, staticProps);
  9095. // Correctly set child's `prototype.constructor`.
  9096. child.prototype.constructor = child;
  9097. // Set a convenience property in case the parent's prototype is needed later.
  9098. child.__super__ = parent.prototype;
  9099. return child;
  9100. };
  9101. // Helper function to get a URL from a Model or Collection as a property
  9102. // or as a function.
  9103. var getUrl = function(object) {
  9104. if (!(object && object.url)) return null;
  9105. return _.isFunction(object.url) ? object.url() : object.url;
  9106. };
  9107. // Throw an error when a URL is needed, and none is supplied.
  9108. var urlError = function() {
  9109. throw new Error('A "url" property or function must be specified');
  9110. };
  9111. // Wrap an optional error callback with a fallback error event.
  9112. var wrapError = function(onError, model, options) {
  9113. return function(resp) {
  9114. if (onError) {
  9115. onError(model, resp, options);
  9116. } else {
  9117. model.trigger('error', model, resp, options);
  9118. }
  9119. };
  9120. };
  9121. // Helper function to escape a string for HTML rendering.
  9122. var escapeHTML = function(string) {
  9123. return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
  9124. };
  9125. }).call(this);
  9126. /**
  9127. * Castor - a cross site POSTing JavaScript logging library for Loggly
  9128. *
  9129. * Copyright (c) 2011 Loggly, Inc.
  9130. * All rights reserved.
  9131. *
  9132. * Author: Kord Campbell <kord@loggly.com>
  9133. * Date: May 2, 2011
  9134. *
  9135. * Uses methods from janky.post, copyright(c) 2011 Thomas Rampelberg <thomas@saunter.org>
  9136. *
  9137. * Sample usage (replace with your own Loggly HTTP input URL):
  9138. <script src="/js/loggly.js" type="text/javascript"></script>
  9139. <script type="text/javascript">
  9140. window.onload=function(){
  9141. castor = new loggly({ url: 'http://logs.loggly.com/inputs/a4e839e9-4227-49aa-9d28-e18e5ba5a818?rt=1', level: 'WARN'});
  9142. castor.log("url="+window.location.href + " browser=" + castor.user_agent + " height=" + castor.browser_size.height);
  9143. }
  9144. </script>
  9145. */
  9146. (function() {
  9147. this.loggly = function(opts) {
  9148. this.user_agent = get_agent();
  9149. this.browser_size = get_size();
  9150. log_methods = {'error': 5, 'warn': 4, 'info': 3, 'debug': 2, 'log': 1};
  9151. if (!opts.url) throw new Error("Please include a Loggly HTTP URL.");
  9152. if (!opts.level) {
  9153. this.level = log_methods['info'];
  9154. } else {
  9155. this.level = log_methods[opts.level];
  9156. }
  9157. this.log = function(data) {
  9158. if (log_methods['log'] == this.level) {
  9159. opts.data = data;
  9160. janky(opts);
  9161. }
  9162. };
  9163. this.debug = function(data) {
  9164. if (log_methods['debug'] >= this.level) {
  9165. opts.data = data;
  9166. janky(opts);
  9167. }
  9168. };
  9169. this.info = function(data) {
  9170. if (log_methods['info'] >= this.level) {
  9171. opts.data = data;
  9172. janky(opts);
  9173. }
  9174. };
  9175. this.warn = function(data) {
  9176. if (log_methods['warn'] >= this.level) {
  9177. opts.data = data;
  9178. janky(opts);
  9179. }
  9180. };
  9181. this.error = function(data) {
  9182. if (log_methods['error'] >= this.level) {
  9183. opts.data = data;
  9184. janky(opts);
  9185. }
  9186. };
  9187. };
  9188. this.janky = function(opts) {
  9189. janky._form(function(iframe, form) {
  9190. form.setAttribute("action", opts.url);
  9191. form.setAttribute("method", "post");
  9192. janky._input(iframe, form, opts.data);
  9193. form.submit();
  9194. setTimeout(function(){
  9195. document.body.removeChild(iframe);
  9196. }, 2000);
  9197. });
  9198. };
  9199. this.janky._form = function(cb) {
  9200. var iframe = document.createElement("iframe");
  9201. document.body.appendChild(iframe);
  9202. iframe.style.display = "none";
  9203. setTimeout(function() {
  9204. var form = iframe.contentWindow.document.createElement("form");
  9205. iframe.contentWindow.document.body.appendChild(form);
  9206. cb(iframe, form);
  9207. }, 0);
  9208. };
  9209. this.janky._input = function(iframe, form, data) {
  9210. var inp = iframe.contentWindow.document.createElement("input");
  9211. inp.setAttribute("type", "hidden");
  9212. inp.setAttribute("name", "source");
  9213. inp.value = "castor " + data;
  9214. form.appendChild(inp);
  9215. };
  9216. this.get_agent = function () {
  9217. return navigator.appCodeName + navigator.appName + navigator.appVersion;
  9218. };
  9219. this.get_size = function () {
  9220. var width = 0; var height = 0;
  9221. if( typeof( window.innerWidth ) == 'number' ) {
  9222. width = window.innerWidth; height = window.innerHeight;
  9223. } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
  9224. width = document.documentElement.clientWidth; height = document.documentElement.clientHeight;
  9225. } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
  9226. width = document.body.clientWidth; height = document.body.clientHeight;
  9227. }
  9228. return {'height': height, 'width': width};
  9229. };
  9230. })();
  9231. jsworld={};jsworld.formatIsoDateTime=function(a,b){if(typeof a==="undefined")a=new Date;if(typeof b==="undefined")b=false;var c=jsworld.formatIsoDate(a)+" "+jsworld.formatIsoTime(a);if(b){var d=a.getHours()-a.getUTCHours();var e=Math.abs(d);var f=a.getUTCMinutes();var g=a.getMinutes();if(g!=f&&f<30&&d<0)e--;if(g!=f&&f>30&&d>0)e--;var h;if(g!=f)h=":30";else h=":00";var i;if(e<10)i="0"+e+h;else i=""+e+h;if(d<0)i="-"+i;else i="+"+i;c=c+i}return c};jsworld.formatIsoDate=function(a){if(typeof a==="undefined")a=new Date;var b=a.getFullYear();var c=a.getMonth()+1;var d=a.getDate();return b+"-"+jsworld._zeroPad(c,2)+"-"+jsworld._zeroPad(d,2)};jsworld.formatIsoTime=function(a){if(typeof a==="undefined")a=new Date;var b=a.getHours();var c=a.getMinutes();var d=a.getSeconds();return jsworld._zeroPad(b,2)+":"+jsworld._zeroPad(c,2)+":"+jsworld._zeroPad(d,2)};jsworld.parseIsoDateTime=function(a){if(typeof a!="string")throw"Error: The parameter must be a string";var b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)[T ](\d\d):(\d\d):(\d\d)/);if(b===null)b=a.match(/^(\d\d\d\d)(\d\d)(\d\d)[T ](\d\d)(\d\d)(\d\d)/);if(b===null)b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)[T ](\d\d)(\d\d)(\d\d)/);if(b===null)b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)[T ](\d\d):(\d\d):(\d\d)/);if(b===null)throw"Error: Invalid ISO-8601 date/time string";var c=parseInt(b[1],10);var d=parseInt(b[2],10);var e=parseInt(b[3],10);var f=parseInt(b[4],10);var g=parseInt(b[5],10);var h=parseInt(b[6],10);if(d<1||d>12||e<1||e>31||f<0||f>23||g<0||g>59||h<0||h>59)throw"Error: Invalid ISO-8601 date/time value";var i=new Date(c,d-1,e,f,g,h);if(i.getDate()!=e||i.getMonth()+1!=d)throw"Error: Invalid date";return i};jsworld.parseIsoDate=function(a){if(typeof a!="string")throw"Error: The parameter must be a string";var b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)/);if(b===null)b=a.match(/^(\d\d\d\d)(\d\d)(\d\d)/);if(b===null)throw"Error: Invalid ISO-8601 date string";var c=parseInt(b[1],10);var d=parseInt(b[2],10);var e=parseInt(b[3],10);if(d<1||d>12||e<1||e>31)throw"Error: Invalid ISO-8601 date value";var f=new Date(c,d-1,e);if(f.getDate()!=e||f.getMonth()+1!=d)throw"Error: Invalid date";return f};jsworld.parseIsoTime=function(a){if(typeof a!="string")throw"Error: The parameter must be a string";var b=a.match(/^(\d\d):(\d\d):(\d\d)/);if(b===null)b=a.match(/^(\d\d)(\d\d)(\d\d)/);if(b===null)throw"Error: Invalid ISO-8601 date/time string";var c=parseInt(b[1],10);var d=parseInt(b[2],10);var e=parseInt(b[3],10);if(c<0||c>23||d<0||d>59||e<0||e>59)throw"Error: Invalid ISO-8601 time value";return new Date(0,0,0,c,d,e)};jsworld._trim=function(a){var b=" \n\r\t\f \u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000";for(var c=0;c<a.length;c++){if(b.indexOf(a.charAt(c))===-1){a=a.substring(c);break}}for(c=a.length-1;c>=0;c--){if(b.indexOf(a.charAt(c))===-1){a=a.substring(0,c+1);break}}return b.indexOf(a.charAt(0))===-1?a:""};jsworld._isNumber=function(a){if(typeof a=="number")return true;if(typeof a!="string")return false;var b=a+"";return/^-?(\d+|\d*\.\d+)$/.test(b)};jsworld._isInteger=function(a){if(typeof a!="number"&&typeof a!="string")return false;var b=a+"";return/^-?\d+$/.test(b)};jsworld._isFloat=function(a){if(typeof a!="number"&&typeof a!="string")return false;var b=a+"";return/^-?\.\d+?$/.test(b)};jsworld._hasOption=function(a,b){if(typeof a!="string"||typeof b!="string")return false;if(b.indexOf(a)!=-1)return true;else return false};jsworld._stringReplaceAll=function(a,b,c){var d;if(b.length==1&&c.length==1){d="";for(var e=0;e<a.length;e++){if(a.charAt(e)==b.charAt(0))d=d+c.charAt(0);else d=d+a.charAt(e)}return d}else{d=a;var f=d.indexOf(b);while(f!=-1){d=d.replace(b,c);f=d.indexOf(b)}return d}};jsworld._stringStartsWith=function(a,b){if(a.length<b.length)return false;for(var c=0;c<b.length;c++){if(a.charAt(c)!=b.charAt(c))return false}return true};jsworld._getPrecision=function(a){if(typeof a!="string")return-1;var b=a.match(/\.(\d)/);if(b)return parseInt(b[1],10);else return-1};jsworld._splitNumber=function(a){if(typeof a=="number")a=a+"";var b={};if(a.charAt(0)=="-")a=a.substring(1);var c=a.split(".");if(!c[1])c[1]="";b.integer=c[0];b.fraction=c[1];return b};jsworld._formatIntegerPart=function(a,b,c){if(c==""||b=="-1")return a;var d=b.split(";");var e="";var f=a.length;var g;while(f>0){if(d.length>0)g=parseInt(d.shift(),10);if(isNaN(g))throw"Error: Invalid grouping";if(g==-1){e=a.substring(0,f)+e;break}f-=g;if(f<1){e=a.substring(0,f+g)+e;break}e=c+a.substring(f,f+g)+e}return e};jsworld._formatFractionPart=function(a,b){for(var c=0;a.length<b;c++)a=a+"0";return a};jsworld._zeroPad=function(a,b){var c=a+"";while(c.length<b)c="0"+c;return c};jsworld._spacePad=function(a,b){var c=a+"";while(c.length<b)c=" "+c;return c};jsworld.Locale=function(a){this._className="jsworld.Locale";this._parseList=function(a,b){var c=[];if(a==null){throw"Names not defined"}else if(typeof a=="object"){c=a}else if(typeof a=="string"){c=a.split(";",b);for(var d=0;d<c.length;d++){if(c[d][0]=='"'&&c[d][c[d].length-1]=='"')c[d]=c[d].slice(1,-1);else throw"Missing double quotes"}}else{throw"Names must be an array or a string"}if(c.length!=b)throw"Expected "+b+" items, got "+c.length;return c};this._validateFormatString=function(a){if(typeof a=="string"&&a.length>0)return a;else throw"Empty or no string"};if(a==null||typeof a!="object")throw"Error: Invalid/missing locale properties";if(typeof a.decimal_point!="string")throw"Error: Invalid/missing decimal_point property";this.decimal_point=a.decimal_point;if(typeof a.thousands_sep!="string")throw"Error: Invalid/missing thousands_sep property";this.thousands_sep=a.thousands_sep;if(typeof a.grouping!="string")throw"Error: Invalid/missing grouping property";this.grouping=a.grouping;if(typeof a.int_curr_symbol!="string")throw"Error: Invalid/missing int_curr_symbol property";if(!/[A-Za-z]{3}.?/.test(a.int_curr_symbol))throw"Error: Invalid int_curr_symbol property";this.int_curr_symbol=a.int_curr_symbol;if(typeof a.currency_symbol!="string")throw"Error: Invalid/missing currency_symbol property";this.currency_symbol=a.currency_symbol;if(typeof a.frac_digits!="number"&&a.frac_digits<0)throw"Error: Invalid/missing frac_digits property";this.frac_digits=a.frac_digits;if(a.mon_decimal_point===null||a.mon_decimal_point==""){if(this.frac_digits>0)throw"Error: Undefined mon_decimal_point property";else a.mon_decimal_point=""}if(typeof a.mon_decimal_point!="string")throw"Error: Invalid/missing mon_decimal_point property";this.mon_decimal_point=a.mon_decimal_point;if(typeof a.mon_thousands_sep!="string")throw"Error: Invalid/missing mon_thousands_sep property";this.mon_thousands_sep=a.mon_thousands_sep;if(typeof a.mon_grouping!="string")throw"Error: Invalid/missing mon_grouping property";this.mon_grouping=a.mon_grouping;if(typeof a.positive_sign!="string")throw"Error: Invalid/missing positive_sign property";this.positive_sign=a.positive_sign;if(typeof a.negative_sign!="string")throw"Error: Invalid/missing negative_sign property";this.negative_sign=a.negative_sign;if(a.p_cs_precedes!==0&&a.p_cs_precedes!==1)throw"Error: Invalid/missing p_cs_precedes property, must be 0 or 1";this.p_cs_precedes=a.p_cs_precedes;if(a.n_cs_precedes!==0&&a.n_cs_precedes!==1)throw"Error: Invalid/missing n_cs_precedes, must be 0 or 1";this.n_cs_precedes=a.n_cs_precedes;if(a.p_sep_by_space!==0&&a.p_sep_by_space!==1&&a.p_sep_by_space!==2)throw"Error: Invalid/missing p_sep_by_space property, must be 0, 1 or 2";this.p_sep_by_space=a.p_sep_by_space;if(a.n_sep_by_space!==0&&a.n_sep_by_space!==1&&a.n_sep_by_space!==2)throw"Error: Invalid/missing n_sep_by_space property, must be 0, 1, or 2";this.n_sep_by_space=a.n_sep_by_space;if(a.p_sign_posn!==0&&a.p_sign_posn!==1&&a.p_sign_posn!==2&&a.p_sign_posn!==3&&a.p_sign_posn!==4)throw"Error: Invalid/missing p_sign_posn property, must be 0, 1, 2, 3 or 4";this.p_sign_posn=a.p_sign_posn;if(a.n_sign_posn!==0&&a.n_sign_posn!==1&&a.n_sign_posn!==2&&a.n_sign_posn!==3&&a.n_sign_posn!==4)throw"Error: Invalid/missing n_sign_posn property, must be 0, 1, 2, 3 or 4";this.n_sign_posn=a.n_sign_posn;if(typeof a.int_frac_digits!="number"&&a.int_frac_digits<0)throw"Error: Invalid/missing int_frac_digits property";this.int_frac_digits=a.int_frac_digits;if(a.int_p_cs_precedes!==0&&a.int_p_cs_precedes!==1)throw"Error: Invalid/missing int_p_cs_precedes property, must be 0 or 1";this.int_p_cs_precedes=a.int_p_cs_precedes;if(a.int_n_cs_precedes!==0&&a.int_n_cs_precedes!==1)throw"Error: Invalid/missing int_n_cs_precedes property, must be 0 or 1";this.int_n_cs_precedes=a.int_n_cs_precedes;if(a.int_p_sep_by_space!==0&&a.int_p_sep_by_space!==1&&a.int_p_sep_by_space!==2)throw"Error: Invalid/missing int_p_sep_by_spacev, must be 0, 1 or 2";this.int_p_sep_by_space=a.int_p_sep_by_space;if(a.int_n_sep_by_space!==0&&a.int_n_sep_by_space!==1&&a.int_n_sep_by_space!==2)throw"Error: Invalid/missing int_n_sep_by_space property, must be 0, 1, or 2";this.int_n_sep_by_space=a.int_n_sep_by_space;if(a.int_p_sign_posn!==0&&a.int_p_sign_posn!==1&&a.int_p_sign_posn!==2&&a.int_p_sign_posn!==3&&a.int_p_sign_posn!==4)throw"Error: Invalid/missing int_p_sign_posn property, must be 0, 1, 2, 3 or 4";this.int_p_sign_posn=a.int_p_sign_posn;if(a.int_n_sign_posn!==0&&a.int_n_sign_posn!==1&&a.int_n_sign_posn!==2&&a.int_n_sign_posn!==3&&a.int_n_sign_posn!==4)throw"Error: Invalid/missing int_n_sign_posn property, must be 0, 1, 2, 3 or 4";this.int_n_sign_posn=a.int_n_sign_posn;if(a==null||typeof a!="object")throw"Error: Invalid/missing time locale properties";try{this.abday=this._parseList(a.abday,7)}catch(b){throw"Error: Invalid abday property: "+b}try{this.day=this._parseList(a.day,7)}catch(b){throw"Error: Invalid day property: "+b}try{this.abmon=this._parseList(a.abmon,12)}catch(b){throw"Error: Invalid abmon property: "+b}try{this.mon=this._parseList(a.mon,12)}catch(b){throw"Error: Invalid mon property: "+b}try{this.d_fmt=this._validateFormatString(a.d_fmt)}catch(b){throw"Error: Invalid d_fmt property: "+b}try{this.t_fmt=this._validateFormatString(a.t_fmt)}catch(b){throw"Error: Invalid t_fmt property: "+b}try{this.d_t_fmt=this._validateFormatString(a.d_t_fmt)}catch(b){throw"Error: Invalid d_t_fmt property: "+b}try{var c=this._parseList(a.am_pm,2);this.am=c[0];this.pm=c[1]}catch(b){this.am="";this.pm=""}this.getAbbreviatedWeekdayName=function(a){if(typeof a=="undefined"||a===null)return this.abday;if(!jsworld._isInteger(a)||a<0||a>6)throw"Error: Invalid weekday argument, must be an integer [0..6]";return this.abday[a]};this.getWeekdayName=function(a){if(typeof a=="undefined"||a===null)return this.day;if(!jsworld._isInteger(a)||a<0||a>6)throw"Error: Invalid weekday argument, must be an integer [0..6]";return this.day[a]};this.getAbbreviatedMonthName=function(a){if(typeof a=="undefined"||a===null)return this.abmon;if(!jsworld._isInteger(a)||a<0||a>11)throw"Error: Invalid month argument, must be an integer [0..11]";return this.abmon[a]};this.getMonthName=function(a){if(typeof a=="undefined"||a===null)return this.mon;if(!jsworld._isInteger(a)||a<0||a>11)throw"Error: Invalid month argument, must be an integer [0..11]";return this.mon[a]};this.getDecimalPoint=function(){return this.decimal_point};this.getCurrencySymbol=function(){return this.currency_symbol};this.getIntCurrencySymbol=function(){return this.int_curr_symbol.substring(0,3)};this.currencySymbolPrecedes=function(){if(this.p_cs_precedes==1)return true;else return false};this.intCurrencySymbolPrecedes=function(){if(this.int_p_cs_precedes==1)return true;else return false};this.getMonetaryDecimalPoint=function(){return this.mon_decimal_point};this.getFractionalDigits=function(){return this.frac_digits};this.getIntFractionalDigits=function(){return this.int_frac_digits}};jsworld.NumericFormatter=function(a){if(typeof a!="object"||a._className!="jsworld.Locale")throw"Constructor error: You must provide a valid jsworld.Locale instance";this.lc=a;this.format=function(a,b){if(typeof a=="string")a=jsworld._trim(a);if(!jsworld._isNumber(a))throw"Error: The input is not a number";var c=parseFloat(a,10);var d=jsworld._getPrecision(b);if(d!=-1)c=Math.round(c*Math.pow(10,d))/Math.pow(10,d);var e=jsworld._splitNumber(String(c));var f;if(c===0)f="0";else f=jsworld._hasOption("^",b)?e.integer:jsworld._formatIntegerPart(e.integer,this.lc.grouping,this.lc.thousands_sep);var g=d!=-1?jsworld._formatFractionPart(e.fraction,d):e.fraction;var h=g.length?f+this.lc.decimal_point+g:f;if(jsworld._hasOption("~",b)||c===0){return h}else{if(jsworld._hasOption("+",b)||c<0){if(c>0)return"+"+h;else if(c<0)return"-"+h;else return h}else{return h}}}};jsworld.DateTimeFormatter=function(a){if(typeof a!="object"||a._className!="jsworld.Locale")throw"Constructor error: You must provide a valid jsworld.Locale instance.";this.lc=a;this.formatDate=function(a){var b=null;if(typeof a=="string"){try{b=jsworld.parseIsoDate(a)}catch(c){b=jsworld.parseIsoDateTime(a)}}else if(a!==null&&typeof a=="object"){b=a}else{throw"Error: Invalid date argument, must be a Date object or an ISO-8601 date/time string"}return this._applyFormatting(b,this.lc.d_fmt)};this.formatTime=function(a){var b=null;if(typeof a=="string"){try{b=jsworld.parseIsoTime(a)}catch(c){b=jsworld.parseIsoDateTime(a)}}else if(a!==null&&typeof a=="object"){b=a}else{throw"Error: Invalid date argument, must be a Date object or an ISO-8601 date/time string"}return this._applyFormatting(b,this.lc.t_fmt)};this.formatDateTime=function(a){var b=null;if(typeof a=="string"){b=jsworld.parseIsoDateTime(a)}else if(a!==null&&typeof a=="object"){b=a}else{throw"Error: Invalid date argument, must be a Date object or an ISO-8601 date/time string"}return this._applyFormatting(b,this.lc.d_t_fmt)};this._applyFormatting=function(a,b){b=b.replace(/%%/g,"%");b=b.replace(/%a/g,this.lc.abday[a.getDay()]);b=b.replace(/%A/g,this.lc.day[a.getDay()]);b=b.replace(/%b/g,this.lc.abmon[a.getMonth()]);b=b.replace(/%B/g,this.lc.mon[a.getMonth()]);b=b.replace(/%d/g,jsworld._zeroPad(a.getDate(),2));b=b.replace(/%e/g,jsworld._spacePad(a.getDate(),2));b=b.replace(/%F/g,a.getFullYear()+"-"+jsworld._zeroPad(a.getMonth()+1,2)+"-"+jsworld._zeroPad(a.getDate(),2));b=b.replace(/%h/g,this.lc.abmon[a.getMonth()]);b=b.replace(/%H/g,jsworld._zeroPad(a.getHours(),2));b=b.replace(/%I/g,jsworld._zeroPad(this._hours12(a.getHours()),2));b=b.replace(/%k/g,a.getHours());b=b.replace(/%l/g,this._hours12(a.getHours()));b=b.replace(/%m/g,jsworld._zeroPad(a.getMonth()+1,2));b=b.replace(/%n/g,"\n");b=b.replace(/%M/g,jsworld._zeroPad(a.getMinutes(),2));b=b.replace(/%p/g,this._getAmPm(a.getHours()));b=b.replace(/%P/g,this._getAmPm(a.getHours()).toLocaleLowerCase());b=b.replace(/%R/g,jsworld._zeroPad(a.getHours(),2)+":"+jsworld._zeroPad(a.getMinutes(),2));b=b.replace(/%S/g,jsworld._zeroPad(a.getSeconds(),2));b=b.replace(/%T/g,jsworld._zeroPad(a.getHours(),2)+":"+jsworld._zeroPad(a.getMinutes(),2)+":"+jsworld._zeroPad(a.getSeconds(),2));b=b.replace(/%w/g,this.lc.day[a.getDay()]);b=b.replace(/%y/g,(new String(a.getFullYear())).substring(2));b=b.replace(/%Y/g,a.getFullYear());b=b.replace(/%Z/g,"");b=b.replace(/%[a-zA-Z]/g,"");return b};this._hours12=function(a){if(a===0)return 12;else if(a>12)return a-12;else return a};this._getAmPm=function(a){if(a===0||a>12)return this.lc.pm;else return this.lc.am}};jsworld.MonetaryFormatter=function(a,b,c){if(typeof a!="object"||a._className!="jsworld.Locale")throw"Constructor error: You must provide a valid jsworld.Locale instance";this.lc=a;this.currencyFractionDigits={AFN:0,ALL:0,AMD:0,BHD:3,BIF:0,BYR:0,CLF:0,CLP:0,COP:0,CRC:0,DJF:0,GNF:0,GYD:0,HUF:0,IDR:0,IQD:0,IRR:0,ISK:0,JOD:3,JPY:0,KMF:0,KRW:0,KWD:3,LAK:0,LBP:0,LYD:3,MGA:0,MMK:0,MNT:0,MRO:0,MUR:0,OMR:3,PKR:0,PYG:0,RSD:0,RWF:0,SLL:0,SOS:0,STD:0,SYP:0,TND:3,TWD:0,TZS:0,UGX:0,UZS:0,VND:0,VUV:0,XAF:0,XOF:0,XPF:0,YER:0,ZMK:0};if(typeof b=="string"){this.currencyCode=b.toUpperCase();var d=this.currencyFractionDigits[this.currencyCode];if(typeof d!="number")d=2;this.lc.frac_digits=d;this.lc.int_frac_digits=d}else{this.currencyCode=this.lc.int_curr_symbol.substring(0,3).toUpperCase()}this.intSep=this.lc.int_curr_symbol.charAt(3);if(this.currencyCode==this.lc.int_curr_symbol.substring(0,3)){this.internationalFormatting=false;this.curSym=this.lc.currency_symbol}else{if(typeof c=="string"){this.curSym=c;this.internationalFormatting=false}else{this.internationalFormatting=true}}this.getCurrencySymbol=function(){return this.curSym};this.currencySymbolPrecedes=function(a){if(typeof a=="string"&&a=="i"){if(this.lc.int_p_cs_precedes==1)return true;else return false}else{if(this.internationalFormatting){if(this.lc.int_p_cs_precedes==1)return true;else return false}else{if(this.lc.p_cs_precedes==1)return true;else return false}}};this.getDecimalPoint=function(){return this.lc.mon_decimal_point};this.getFractionalDigits=function(a){if(typeof a=="string"&&a=="i"){return this.lc.int_frac_digits}else{if(this.internationalFormatting)return this.lc.int_frac_digits;else return this.lc.frac_digits}};this.format=function(a,b){var c;if(typeof a=="string"){a=jsworld._trim(a);c=parseFloat(a);if(typeof c!="number"||isNaN(c))throw"Error: Amount string not a number"}else if(typeof a=="number"){c=a}else{throw"Error: Amount not a number"}var d=jsworld._getPrecision(b);if(d==-1){if(this.internationalFormatting||jsworld._hasOption("i",b))d=this.lc.int_frac_digits;else d=this.lc.frac_digits}c=Math.round(c*Math.pow(10,d))/Math.pow(10,d);var e=jsworld._splitNumber(String(c));var f;if(c===0)f="0";else f=jsworld._hasOption("^",b)?e.integer:jsworld._formatIntegerPart(e.integer,this.lc.mon_grouping,this.lc.mon_thousands_sep);var g;if(d==-1){if(this.internationalFormatting||jsworld._hasOption("i",b))g=jsworld._formatFractionPart(e.fraction,this.lc.int_frac_digits);else g=jsworld._formatFractionPart(e.fraction,this.lc.frac_digits)}else{g=jsworld._formatFractionPart(e.fraction,d)}var h;if(this.lc.frac_digits>0||g.length)h=f+this.lc.mon_decimal_point+g;else h=f;if(jsworld._hasOption("~",b)){return h}else{var i=jsworld._hasOption("!",b)?true:false;var j=c<0?"-":"+";if(this.internationalFormatting||jsworld._hasOption("i",b)){if(i)return this._formatAsInternationalCurrencyWithNoSym(j,h);else return this._formatAsInternationalCurrency(j,h)}else{if(i)return this._formatAsLocalCurrencyWithNoSym(j,h);else return this._formatAsLocalCurrency(j,h)}}};this._formatAsLocalCurrency=function(a,b){if(a=="+"){if(this.lc.p_sign_posn===0&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return"("+b+this.curSym+")"}else if(this.lc.p_sign_posn===0&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return"("+this.curSym+b+")"}else if(this.lc.p_sign_posn===0&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return"("+b+" "+this.curSym+")"}else if(this.lc.p_sign_posn===0&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return"("+this.curSym+" "+b+")"}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return this.lc.positive_sign+b+this.curSym}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+this.curSym+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return this.lc.positive_sign+b+" "+this.curSym}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+this.curSym+" "+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return this.lc.positive_sign+" "+b+this.curSym}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+" "+this.curSym+b}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return b+this.curSym+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.curSym+b+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return b+" "+this.curSym+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.curSym+" "+b+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return b+this.curSym+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.curSym+b+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign+this.curSym}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+this.curSym+b}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return b+" "+this.lc.positive_sign+this.curSym}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+this.curSym+" "+b}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign+" "+this.curSym}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+" "+this.curSym+b}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return b+this.curSym+this.lc.positive_sign}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.curSym+this.lc.positive_sign+b}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return b+" "+this.curSym+this.lc.positive_sign}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.curSym+this.lc.positive_sign+" "+b}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return b+this.curSym+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.curSym+" "+this.lc.positive_sign+b}}else if(a=="-"){if(this.lc.n_sign_posn===0&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return"("+b+this.curSym+")"}else if(this.lc.n_sign_posn===0&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return"("+this.curSym+b+")"}else if(this.lc.n_sign_posn===0&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return"("+b+" "+this.curSym+")"}else if(this.lc.n_sign_posn===0&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return"("+this.curSym+" "+b+")"}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return this.lc.negative_sign+b+this.curSym}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+this.curSym+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return this.lc.negative_sign+b+" "+this.curSym}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+this.curSym+" "+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return this.lc.negative_sign+" "+b+this.curSym}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+this.curSym+b}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return b+this.curSym+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.curSym+b+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return b+" "+this.curSym+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.curSym+" "+b+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return b+this.curSym+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.curSym+b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return b+this.lc.negative_sign+this.curSym}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+this.curSym+b}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return b+" "+this.lc.negative_sign+this.curSym}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+this.curSym+" "+b}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return b+this.lc.negative_sign+" "+this.curSym}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+this.curSym+b}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return b+this.curSym+this.lc.negative_sign}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.curSym+this.lc.negative_sign+b}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return b+" "+this.curSym+this.lc.negative_sign}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.curSym+this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return b+this.curSym+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.curSym+" "+this.lc.negative_sign+b}}throw"Error: Invalid POSIX LC MONETARY definition"};this._formatAsInternationalCurrency=function(a,b){if(a=="+"){if(this.lc.int_p_sign_posn===0&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return"("+b+this.currencyCode+")"}else if(this.lc.int_p_sign_posn===0&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return"("+this.currencyCode+b+")"}else if(this.lc.int_p_sign_posn===0&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return"("+b+this.intSep+this.currencyCode+")"}else if(this.lc.int_p_sign_posn===0&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return"("+this.currencyCode+this.intSep+b+")"}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return this.lc.positive_sign+b+this.currencyCode}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.currencyCode+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return this.lc.positive_sign+b+this.intSep+this.currencyCode}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.currencyCode+this.intSep+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return this.lc.positive_sign+this.intSep+b+this.currencyCode}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+this.currencyCode+b}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return b+this.currencyCode+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.currencyCode+b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.currencyCode+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.currencyCode+this.intSep+b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return b+this.currencyCode+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.currencyCode+b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return b+this.lc.positive_sign+this.currencyCode}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.currencyCode+b}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.lc.positive_sign+this.currencyCode}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.currencyCode+this.intSep+b}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return b+this.lc.positive_sign+this.intSep+this.currencyCode}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+this.currencyCode+b}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return b+this.currencyCode+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.currencyCode+this.lc.positive_sign+b}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.currencyCode+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.currencyCode+this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return b+this.currencyCode+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.currencyCode+this.intSep+this.lc.positive_sign+b}}else if(a=="-"){if(this.lc.int_n_sign_posn===0&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return"("+b+this.currencyCode+")"}else if(this.lc.int_n_sign_posn===0&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return"("+this.currencyCode+b+")"}else if(this.lc.int_n_sign_posn===0&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return"("+b+this.intSep+this.currencyCode+")"}else if(this.lc.int_n_sign_posn===0&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return"("+this.currencyCode+this.intSep+b+")"}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return this.lc.negative_sign+b+this.currencyCode}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.currencyCode+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return this.lc.negative_sign+b+this.intSep+this.currencyCode}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.currencyCode+this.intSep+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return this.lc.negative_sign+this.intSep+b+this.currencyCode}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+this.currencyCode+b}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return b+this.currencyCode+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.currencyCode+b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.currencyCode+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.currencyCode+this.intSep+b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return b+this.currencyCode+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.currencyCode+b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return b+this.lc.negative_sign+this.currencyCode}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.currencyCode+b}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.lc.negative_sign+this.currencyCode}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.currencyCode+this.intSep+b}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return b+this.lc.negative_sign+this.intSep+this.currencyCode}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+this.currencyCode+b}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return b+this.currencyCode+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.currencyCode+this.lc.negative_sign+b}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.currencyCode+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.currencyCode+this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return b+this.currencyCode+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.currencyCode+this.intSep+this.lc.negative_sign+b}}throw"Error: Invalid POSIX LC MONETARY definition"};this._formatAsLocalCurrencyWithNoSym=function(a,b){if(a=="+"){if(this.lc.p_sign_posn===0){return"("+b+")"}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return this.lc.positive_sign+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return this.lc.positive_sign+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return this.lc.positive_sign+" "+b}else if(this.lc.p_sign_posn===1&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+" "+b}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return b+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===2&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return b+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return b+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+" "+b}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===3&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+" "+b}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===0&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===0){return b+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===1&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+" "+b}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===0){return b+" "+this.lc.positive_sign}else if(this.lc.p_sign_posn===4&&this.lc.p_sep_by_space===2&&this.lc.p_cs_precedes===1){return this.lc.positive_sign+b}}else if(a=="-"){if(this.lc.n_sign_posn===0){return"("+b+")"}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return this.lc.negative_sign+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return this.lc.negative_sign+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===1&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return b+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return b+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===2&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+b}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.n_sign_posn===3&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===0&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+b}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===0){return b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===1&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+" "+b}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===0){return b+" "+this.lc.negative_sign}else if(this.lc.n_sign_posn===4&&this.lc.n_sep_by_space===2&&this.lc.n_cs_precedes===1){return this.lc.negative_sign+b}}throw"Error: Invalid POSIX LC MONETARY definition"};this._formatAsInternationalCurrencyWithNoSym=function(a,b){if(a=="+"){if(this.lc.int_p_sign_posn===0){return"("+b+")"}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return this.lc.positive_sign+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return this.lc.positive_sign+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===1&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===2&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===3&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===0){return b+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===0&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+b}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===1&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+this.intSep+b}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===0){return b+this.intSep+this.lc.positive_sign}else if(this.lc.int_p_sign_posn===4&&this.lc.int_p_sep_by_space===2&&this.lc.int_p_cs_precedes===1){return this.lc.positive_sign+b}}else if(a=="-"){if(this.lc.int_n_sign_posn===0){return"("+b+")"}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return this.lc.negative_sign+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return this.lc.negative_sign+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===1&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===2&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+b}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===3&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===0){return b+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===0&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+b}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===1&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+this.intSep+b}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===0){return b+this.intSep+this.lc.negative_sign}else if(this.lc.int_n_sign_posn===4&&this.lc.int_n_sep_by_space===2&&this.lc.int_n_cs_precedes===1){return this.lc.negative_sign+b}}throw"Error: Invalid POSIX LC_MONETARY definition"}};jsworld.NumericParser=function(a){if(typeof a!="object"||a._className!="jsworld.Locale")throw"Constructor error: You must provide a valid jsworld.Locale instance";this.lc=a;this.parse=function(a){if(typeof a!="string")throw"Parse error: Argument must be a string";var b=jsworld._trim(a);b=jsworld._stringReplaceAll(a,this.lc.thousands_sep,"");b=jsworld._stringReplaceAll(b,this.lc.decimal_point,".");if(jsworld._isNumber(b))return parseFloat(b,10);else throw"Parse error: Invalid number string"}};jsworld.DateTimeParser=function(a){if(typeof a!="object"||a._className!="jsworld.Locale")throw"Constructor error: You must provide a valid jsworld.Locale instance.";this.lc=a;this.parseTime=function(a){if(typeof a!="string")throw"Parse error: Argument must be a string";var b=this._extractTokens(this.lc.t_fmt,a);var c=false;if(b.hour!==null&&b.minute!==null&&b.second!==null){c=true}else if(b.hourAmPm!==null&&b.am!==null&&b.minute!==null&&b.second!==null){if(b.am){b.hour=parseInt(b.hourAmPm,10)}else{if(b.hourAmPm==12)b.hour=0;else b.hour=parseInt(b.hourAmPm,10)+12}c=true}if(c)return jsworld._zeroPad(b.hour,2)+":"+jsworld._zeroPad(b.minute,2)+":"+jsworld._zeroPad(b.second,2);else throw"Parse error: Invalid/ambiguous time string"};this.parseDate=function(a){if(typeof a!="string")throw"Parse error: Argument must be a string";var b=this._extractTokens(this.lc.d_fmt,a);var c=false;if(b.year!==null&&b.month!==null&&b.day!==null){c=true}if(c)return jsworld._zeroPad(b.year,4)+"-"+jsworld._zeroPad(b.month,2)+"-"+jsworld._zeroPad(b.day,2);else throw"Parse error: Invalid date string"};this.parseDateTime=function(a){if(typeof a!="string")throw"Parse error: Argument must be a string";var b=this._extractTokens(this.lc.d_t_fmt,a);var c=false;var d=false;if(b.hour!==null&&b.minute!==null&&b.second!==null){c=true}else if(b.hourAmPm!==null&&b.am!==null&&b.minute!==null&&b.second!==null){if(b.am){b.hour=parseInt(b.hourAmPm,10)}else{if(b.hourAmPm==12)b.hour=0;else b.hour=parseInt(b.hourAmPm,10)+12}c=true}if(b.year!==null&&b.month!==null&&b.day!==null){d=true}if(d&&c)return jsworld._zeroPad(b.year,4)+"-"+jsworld._zeroPad(b.month,2)+"-"+jsworld._zeroPad(b.day,2)+" "+jsworld._zeroPad(b.hour,2)+":"+jsworld._zeroPad(b.minute,2)+":"+jsworld._zeroPad(b.second,2);else throw"Parse error: Invalid/ambiguous date/time string"};this._extractTokens=function(a,b){var c={year:null,month:null,day:null,hour:null,hourAmPm:null,am:null,minute:null,second:null,weekday:null};while(a.length>0){if(a.charAt(0)=="%"&&a.charAt(1)!=""){var d=a.substring(0,2);if(d=="%%"){b=b.substring(1)}else if(d=="%a"){for(var e=0;e<this.lc.abday.length;e++){if(jsworld._stringStartsWith(b,this.lc.abday[e])){c.weekday=e;b=b.substring(this.lc.abday[e].length);break}}if(c.weekday===null)throw"Parse error: Unrecognised abbreviated weekday name (%a)"}else if(d=="%A"){for(var e=0;e<this.lc.day.length;e++){if(jsworld._stringStartsWith(b,this.lc.day[e])){c.weekday=e;b=b.substring(this.lc.day[e].length);break}}if(c.weekday===null)throw"Parse error: Unrecognised weekday name (%A)"}else if(d=="%b"||d=="%h"){for(var e=0;e<this.lc.abmon.length;e++){if(jsworld._stringStartsWith(b,this.lc.abmon[e])){c.month=e+1;b=b.substring(this.lc.abmon[e].length);break}}if(c.month===null)throw"Parse error: Unrecognised abbreviated month name (%b)"}else if(d=="%B"){for(var e=0;e<this.lc.mon.length;e++){if(jsworld._stringStartsWith(b,this.lc.mon[e])){c.month=e+1;b=b.substring(this.lc.mon[e].length);break}}if(c.month===null)throw"Parse error: Unrecognised month name (%B)"}else if(d=="%d"){if(/^0[1-9]|[1-2][0-9]|3[0-1]/.test(b)){c.day=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised day of the month (%d)"}else if(d=="%e"){var f=b.match(/^\s?(\d{1,2})/);c.day=parseInt(f,10);if(isNaN(c.day)||c.day<1||c.day>31)throw"Parse error: Unrecognised day of the month (%e)";b=b.substring(f.length)}else if(d=="%F"){if(/^\d\d\d\d/.test(b)){c.year=parseInt(b.substring(0,4),10);b=b.substring(4)}else{throw"Parse error: Unrecognised date (%F)"}if(jsworld._stringStartsWith(b,"-"))b=b.substring(1);else throw"Parse error: Unrecognised date (%F)";if(/^0[1-9]|1[0-2]/.test(b)){c.month=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised date (%F)";if(jsworld._stringStartsWith(b,"-"))b=b.substring(1);else throw"Parse error: Unrecognised date (%F)";if(/^0[1-9]|[1-2][0-9]|3[0-1]/.test(b)){c.day=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised date (%F)"}else if(d=="%H"){if(/^[0-1][0-9]|2[0-3]/.test(b)){c.hour=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised hour (%H)"}else if(d=="%I"){if(/^0[1-9]|1[0-2]/.test(b)){c.hourAmPm=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised hour (%I)"}else if(d=="%k"){var g=b.match(/^(\d{1,2})/);c.hour=parseInt(g,10);if(isNaN(c.hour)||c.hour<0||c.hour>23)throw"Parse error: Unrecognised hour (%k)";b=b.substring(g.length)}else if(d=="%l"){var g=b.match(/^(\d{1,2})/);c.hourAmPm=parseInt(g,10);if(isNaN(c.hourAmPm)||c.hourAmPm<1||c.hourAmPm>12)throw"Parse error: Unrecognised hour (%l)";b=b.substring(g.length)}else if(d=="%m"){if(/^0[1-9]|1[0-2]/.test(b)){c.month=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised month (%m)"}else if(d=="%M"){if(/^[0-5][0-9]/.test(b)){c.minute=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised minute (%M)"}else if(d=="%n"){if(b.charAt(0)=="\n")b=b.substring(1);else throw"Parse error: Unrecognised new line (%n)"}else if(d=="%p"){if(jsworld._stringStartsWith(b,this.lc.am)){c.am=true;b=b.substring(this.lc.am.length)}else if(jsworld._stringStartsWith(b,this.lc.pm)){c.am=false;b=b.substring(this.lc.pm.length)}else throw"Parse error: Unrecognised AM/PM value (%p)"}else if(d=="%P"){if(jsworld._stringStartsWith(b,this.lc.am.toLowerCase())){c.am=true;b=b.substring(this.lc.am.length)}else if(jsworld._stringStartsWith(b,this.lc.pm.toLowerCase())){c.am=false;b=b.substring(this.lc.pm.length)}else throw"Parse error: Unrecognised AM/PM value (%P)"}else if(d=="%R"){if(/^[0-1][0-9]|2[0-3]/.test(b)){c.hour=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised time (%R)";if(jsworld._stringStartsWith(b,":"))b=b.substring(1);else throw"Parse error: Unrecognised time (%R)";if(/^[0-5][0-9]/.test(b)){c.minute=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised time (%R)"}else if(d=="%S"){if(/^[0-5][0-9]/.test(b)){c.second=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised second (%S)"}else if(d=="%T"){if(/^[0-1][0-9]|2[0-3]/.test(b)){c.hour=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised time (%T)";if(jsworld._stringStartsWith(b,":"))b=b.substring(1);else throw"Parse error: Unrecognised time (%T)";if(/^[0-5][0-9]/.test(b)){c.minute=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised time (%T)";if(jsworld._stringStartsWith(b,":"))b=b.substring(1);else throw"Parse error: Unrecognised time (%T)";if(/^[0-5][0-9]/.test(b)){c.second=parseInt(b.substring(0,2),10);b=b.substring(2)}else throw"Parse error: Unrecognised time (%T)"}else if(d=="%w"){if(/^\d/.test(b)){c.weekday=parseInt(b.substring(0,1),10);b=b.substring(1)}else throw"Parse error: Unrecognised weekday number (%w)"}else if(d=="%y"){if(/^\d\d/.test(b)){var h=parseInt(b.substring(0,2),10);if(h>50)c.year=1900+h;else c.year=2e3+h;b=b.substring(2)}else throw"Parse error: Unrecognised year (%y)"}else if(d=="%Y"){if(/^\d\d\d\d/.test(b)){c.year=parseInt(b.substring(0,4),10);b=b.substring(4)}else throw"Parse error: Unrecognised year (%Y)"}else if(d=="%Z"){if(a.length===0)break}a=a.substring(2)}else{if(a.charAt(0)!=b.charAt(0))throw'Parse error: Unexpected symbol "'+b.charAt(0)+'" in date/time string';a=a.substring(1);b=b.substring(1)}}return c}};jsworld.MonetaryParser=function(a){if(typeof a!="object"||a._className!="jsworld.Locale")throw"Constructor error: You must provide a valid jsworld.Locale instance";this.lc=a;this.parse=function(a){if(typeof a!="string")throw"Parse error: Argument must be a string";var b=this._detectCurrencySymbolType(a);var c,d;if(b=="local"){c="local";d=a.replace(this.lc.getCurrencySymbol(),"")}else if(b=="int"){c="int";d=a.replace(this.lc.getIntCurrencySymbol(),"")}else if(b=="none"){c="local";d=a}else throw"Parse error: Internal assert failure";d=jsworld._stringReplaceAll(d,this.lc.mon_thousands_sep,"");d=d.replace(this.lc.mon_decimal_point,".");d=d.replace(/\s*/g,"");d=this._removeLocalNonNegativeSign(d,c);d=this._normaliseNegativeSign(d,c);if(jsworld._isNumber(d))return parseFloat(d,10);else throw"Parse error: Invalid currency amount string"};this._detectCurrencySymbolType=function(a){if(this.lc.getCurrencySymbol().length>this.lc.getIntCurrencySymbol().length){if(a.indexOf(this.lc.getCurrencySymbol())!=-1)return"local";else if(a.indexOf(this.lc.getIntCurrencySymbol())!=-1)return"int";else return"none"}else{if(a.indexOf(this.lc.getIntCurrencySymbol())!=-1)return"int";else if(a.indexOf(this.lc.getCurrencySymbol())!=-1)return"local";else return"none"}};this._removeLocalNonNegativeSign=function(a,b){a=a.replace(this.lc.positive_sign,"");if((b=="local"&&this.lc.p_sign_posn===0||b=="int"&&this.lc.int_p_sign_posn===0)&&/\(\d+\.?\d*\)/.test(a)){a=a.replace("(","");a=a.replace(")","")}return a};this._normaliseNegativeSign=function(a,b){a=a.replace(this.lc.negative_sign,"-");if(b=="local"&&this.lc.n_sign_posn===0||b=="int"&&this.lc.int_n_sign_posn===0){if(/^\(\d+\.?\d*\)$/.test(a)){a=a.replace("(","");a=a.replace(")","");return"-"+a}}if(b=="local"&&this.lc.n_sign_posn==2||b=="int"&&this.lc.int_n_sign_posn==2){if(/^\d+\.?\d*-$/.test(a)){a=a.replace("-","");return"-"+a}}if(b=="local"&&this.lc.n_cs_precedes===0&&this.lc.n_sign_posn==3||b=="local"&&this.lc.n_cs_precedes===0&&this.lc.n_sign_posn==4||b=="int"&&this.lc.int_n_cs_precedes===0&&this.lc.int_n_sign_posn==3||b=="int"&&this.lc.int_n_cs_precedes===0&&this.lc.int_n_sign_posn==4){if(/^\d+\.?\d*-$/.test(a)){a=a.replace("-","");return"-"+a}}return a}}
  9232. if(typeof POSIX_LC == "undefined") var POSIX_LC = {};
  9233. POSIX_LC.en_US = {
  9234. "decimal_point" : ".",
  9235. "thousands_sep" : ",",
  9236. "grouping" : "3",
  9237. "abday" : ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
  9238. "day" : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
  9239. "abmon" : ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
  9240. "mon" : ["January","February","March","April","May","June","July","August","September","October","November","December"],
  9241. "d_fmt" : "%m/%e/%y",
  9242. "t_fmt" : "%I:%M:%S %p",
  9243. "d_t_fmt" : "%B %e, %Y %I:%M:%S %p %Z",
  9244. "am_pm" : ["AM","PM"],
  9245. "int_curr_symbol" : "USD ",
  9246. "currency_symbol" : "\u0024",
  9247. "mon_decimal_point" : ".",
  9248. "mon_thousands_sep" : ",",
  9249. "mon_grouping" : "3",
  9250. "positive_sign" : "",
  9251. "negative_sign" : "-",
  9252. "int_frac_digits" : 2,
  9253. "frac_digits" : 2,
  9254. "p_cs_precedes" : 1,
  9255. "n_cs_precedes" : 1,
  9256. "p_sep_by_space" : 0,
  9257. "n_sep_by_space" : 0,
  9258. "p_sign_posn" : 1,
  9259. "n_sign_posn" : 1,
  9260. "int_p_cs_precedes" : 1,
  9261. "int_n_cs_precedes" : 1,
  9262. "int_p_sep_by_space" : 0,
  9263. "int_n_sep_by_space" : 0,
  9264. "int_p_sign_posn" : 1,
  9265. "int_n_sign_posn" : 1
  9266. }
  9267. if(typeof POSIX_LC == "undefined") var POSIX_LC = {};
  9268. POSIX_LC.fr_FR = {
  9269. "decimal_point" : ",",
  9270. "thousands_sep" : "\u00a0",
  9271. "grouping" : "3",
  9272. "abday" : ["dim.","lun.","mar.",
  9273. "mer.","jeu.","ven.",
  9274. "sam."],
  9275. "day" : ["dimanche","lundi","mardi",
  9276. "mercredi","jeudi","vendredi",
  9277. "samedi"],
  9278. "abmon" : ["janv.","f\u00e9vr.","mars",
  9279. "avr.","mai","juin",
  9280. "juil.","ao\u00fbt","sept.",
  9281. "oct.","nov.","d\u00e9c."],
  9282. "mon" : ["janvier","f\u00e9vrier","mars",
  9283. "avril","mai","juin",
  9284. "juillet","ao\u00fbt","septembre",
  9285. "octobre","novembre","d\u00e9cembre"],
  9286. "d_fmt" : "%d/%m/%y",
  9287. "t_fmt" : "%H:%M:%S",
  9288. "d_t_fmt" : "%e %B %Y %H:%M:%S %Z",
  9289. "am_pm" : ["AM","PM"],
  9290. "int_curr_symbol" : "EUR ",
  9291. "currency_symbol" : "\u20ac",
  9292. "mon_decimal_point" : ",",
  9293. "mon_thousands_sep" : "\u00a0",
  9294. "mon_grouping" : "3",
  9295. "positive_sign" : "",
  9296. "negative_sign" : "-",
  9297. "int_frac_digits" : 2,
  9298. "frac_digits" : 2,
  9299. "p_cs_precedes" : 0,
  9300. "n_cs_precedes" : 0,
  9301. "p_sep_by_space" : 1,
  9302. "n_sep_by_space" : 1,
  9303. "p_sign_posn" : 1,
  9304. "n_sign_posn" : 1,
  9305. "int_p_cs_precedes" : 0,
  9306. "int_n_cs_precedes" : 0,
  9307. "int_p_sep_by_space" : 1,
  9308. "int_n_sep_by_space" : 1,
  9309. "int_p_sign_posn" : 1,
  9310. "int_n_sign_posn" : 1
  9311. };
  9312. /** https://github.com/csnover/js-iso8601 */(function(n,f){var u=n.parse,c=[1,4,5,6,7,10,11];n.parse=function(t){var i,o,a=0;if(o=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(t)){for(var v=0,r;r=c[v];++v)o[r]=+o[r]||0;o[2]=(+o[2]||1)-1,o[3]=+o[3]||1,o[8]!=="Z"&&o[9]!==f&&(a=o[10]*60+o[11],o[9]==="+"&&(a=0-a)),i=n.UTC(o[1],o[2],o[3],o[4],o[5]+a,o[6],o[7])}else i=u?u(t):NaN;return i}})(Date)
  9313. /*!
  9314. * geo-location-javascript v0.4.3
  9315. * http://code.google.com/p/geo-location-javascript/
  9316. *
  9317. * Copyright (c) 2009 Stan Wiechers
  9318. * Licensed under the MIT licenses.
  9319. *
  9320. * Revision: $Rev: 68 $:
  9321. * Author: $Author: whoisstan $:
  9322. * Date: $Date: 2010-02-15 13:42:19 +0100 (Mon, 15 Feb 2010) $:
  9323. */
  9324. var geo_position_js=function() {
  9325. var pub = {};
  9326. var provider=null;
  9327. pub.getCurrentPosition = function(successCallback,errorCallback,options)
  9328. {
  9329. provider.getCurrentPosition(successCallback, errorCallback,options);
  9330. }
  9331. pub.init = function()
  9332. {
  9333. try
  9334. {
  9335. if (typeof(geo_position_js_simulator)!="undefined")
  9336. {
  9337. provider=geo_position_js_simulator;
  9338. }
  9339. else if (typeof(bondi)!="undefined" && typeof(bondi.geolocation)!="undefined")
  9340. {
  9341. provider=bondi.geolocation;
  9342. }
  9343. else if (typeof(navigator.geolocation)!="undefined")
  9344. {
  9345. provider=navigator.geolocation;
  9346. pub.getCurrentPosition = function(successCallback, errorCallback, options)
  9347. {
  9348. function _successCallback(p)
  9349. {
  9350. //for mozilla geode,it returns the coordinates slightly differently
  9351. if(typeof(p.latitude)!="undefined")
  9352. {
  9353. successCallback({timestamp:p.timestamp, coords: {latitude:p.latitude,longitude:p.longitude}});
  9354. }
  9355. else
  9356. {
  9357. successCallback(p);
  9358. }
  9359. }
  9360. provider.getCurrentPosition(_successCallback,errorCallback,options);
  9361. }
  9362. }
  9363. else if(typeof(window.google)!="undefined" && typeof(google.gears)!="undefined")
  9364. {
  9365. provider=google.gears.factory.create('beta.geolocation');
  9366. }
  9367. else if ( typeof(Mojo) !="undefined" && typeof(Mojo.Service.Request)!="Mojo.Service.Request")
  9368. {
  9369. provider=true;
  9370. pub.getCurrentPosition = function(successCallback, errorCallback, options)
  9371. {
  9372. parameters={};
  9373. if(options)
  9374. {
  9375. //http://developer.palm.com/index.php?option=com_content&view=article&id=1673#GPS-getCurrentPosition
  9376. if (options.enableHighAccuracy && options.enableHighAccuracy==true)
  9377. {
  9378. parameters.accuracy=1;
  9379. }
  9380. if (options.maximumAge)
  9381. {
  9382. parameters.maximumAge=options.maximumAge;
  9383. }
  9384. if (options.responseTime)
  9385. {
  9386. if(options.responseTime<5)
  9387. {
  9388. parameters.responseTime=1;
  9389. }
  9390. else if (options.responseTime<20)
  9391. {
  9392. parameters.responseTime=2;
  9393. }
  9394. else
  9395. {
  9396. parameters.timeout=3;
  9397. }
  9398. }
  9399. }
  9400. r=new Mojo.Service.Request('palm://com.palm.location', {
  9401. method:"getCurrentPosition",
  9402. parameters:parameters,
  9403. onSuccess: function(p){successCallback({timestamp:p.timestamp, coords: {latitude:p.latitude, longitude:p.longitude,heading:p.heading}});},
  9404. onFailure: function(e){
  9405. if (e.errorCode==1)
  9406. {
  9407. errorCallback({code:3,message:"Timeout"});
  9408. }
  9409. else if (e.errorCode==2)
  9410. {
  9411. errorCallback({code:2,message:"Position Unavailable"});
  9412. }
  9413. else
  9414. {
  9415. errorCallback({code:0,message:"Unknown Error: webOS-code"+errorCode});
  9416. }
  9417. }
  9418. });
  9419. }
  9420. }
  9421. else if (typeof(device)!="undefined" && typeof(device.getServiceObject)!="undefined")
  9422. {
  9423. provider=device.getServiceObject("Service.Location", "ILocation");
  9424. //override default method implementation
  9425. pub.getCurrentPosition = function(successCallback, errorCallback, options)
  9426. {
  9427. function callback(transId, eventCode, result) {
  9428. if (eventCode == 4)
  9429. {
  9430. errorCallback({message:"Position unavailable", code:2});
  9431. }
  9432. else
  9433. {
  9434. //no timestamp of location given?
  9435. successCallback({timestamp:null, coords: {latitude:result.ReturnValue.Latitude, longitude:result.ReturnValue.Longitude, altitude:result.ReturnValue.Altitude,heading:result.ReturnValue.Heading}});
  9436. }
  9437. }
  9438. //location criteria
  9439. var criteria = new Object();
  9440. criteria.LocationInformationClass = "BasicLocationInformation";
  9441. //make the call
  9442. provider.ILocation.GetLocation(criteria,callback);
  9443. }
  9444. }
  9445. }
  9446. catch (e){
  9447. alert("error="+e);
  9448. if(typeof(console)!="undefined")
  9449. {
  9450. console.log(e);
  9451. }
  9452. return false;
  9453. }
  9454. return provider!=null;
  9455. }
  9456. return pub;
  9457. }();
  9458. // Couldn't get unminified version to work , go here for docs => https://github.com/iamnoah/writeCapture
  9459. (function(E,a){var j=a.document;function A(Q){var Z=j.createElement("div");j.body.insertBefore(Z,null);E.replaceWith(Z,'<script type="text/javascript">'+Q+"<\/script>")}E=E||(function(Q){return{ajax:Q.ajax,$:function(Z){return Q(Z)[0]},replaceWith:function(Z,ad){var ac=Q(Z)[0];var ab=ac.nextSibling,aa=ac.parentNode;Q(ac).remove();if(ab){Q(ab).before(ad)}else{Q(aa).append(ad)}},onLoad:function(Z){Q(Z)},copyAttrs:function(af,ab){var ad=Q(ab),aa=af.attributes;for(var ac=0,Z=aa.length;ac<Z;ac++){if(aa[ac]&&aa[ac].value){try{ad.attr(aa[ac].name,aa[ac].value)}catch(ae){}}}}}})(a.jQuery);E.copyAttrs=E.copyAttrs||function(){};E.onLoad=E.onLoad||function(){throw"error: autoAsync cannot be used without jQuery or defining writeCaptureSupport.onLoad"};function P(ab,aa){for(var Z=0,Q=ab.length;Z<Q;Z++){if(aa(ab[Z])===false){return}}}function v(Q){return Object.prototype.toString.call(Q)==="[object Function]"}function p(Q){return Object.prototype.toString.call(Q)==="[object String]"}function u(aa,Z,Q){return Array.prototype.slice.call(aa,Z||0,Q||aa&&aa.length)}function D(ab,aa){var Q=false;P(ab,Z);function Z(ac){return !(Q=aa(ac))}return Q}function L(Q){this._queue=[];this._children=[];this._parent=Q;if(Q){Q._addChild(this)}}L.prototype={_addChild:function(Q){this._children.push(Q)},push:function(Q){this._queue.push(Q);this._bubble("_doRun")},pause:function(){this._bubble("_doPause")},resume:function(){this._bubble("_doResume")},_bubble:function(Z){var Q=this;while(!Q[Z]){Q=Q._parent}return Q[Z]()},_next:function(){if(D(this._children,Q)){return true}function Q(aa){return aa._next()}var Z=this._queue.shift();if(Z){Z()}return !!Z}};function i(Q){if(Q){return new L(Q)}L.call(this);this.paused=0}i.prototype=(function(){function Q(){}Q.prototype=L.prototype;return new Q()})();i.prototype._doRun=function(){if(!this.running){this.running=true;try{while(this.paused<1&&this._next()){}}finally{this.running=false}}};i.prototype._doPause=function(){this.paused++};i.prototype._doResume=function(){this.paused--;this._doRun()};function M(){}M.prototype={_html:"",open:function(){this._opened=true;if(this._delegate){this._delegate.open()}},write:function(Q){if(this._closed){return}this._written=true;if(this._delegate){this._delegate.write(Q)}else{this._html+=Q}},writeln:function(Q){this.write(Q+"\n")},close:function(){this._closed=true;if(this._delegate){this._delegate.close()}},copyTo:function(Q){this._delegate=Q;Q.foobar=true;if(this._opened){Q.open()}if(this._written){Q.write(this._html)}if(this._closed){Q.close()}}};var e=(function(){var Q={f:j.getElementById};try{Q.f.call(j,"abc");return true}catch(Z){return false}})();function I(Q){P(Q,function(Z){var aa=j.getElementById(Z.id);if(!aa){l("<proxyGetElementById - finish>","no element in writen markup with id "+Z.id);return}P(Z.el.childNodes,function(ab){aa.appendChild(ab)});if(aa.contentWindow){a.setTimeout(function(){Z.el.contentWindow.document.copyTo(aa.contentWindow.document)},1)}E.copyAttrs(Z.el,aa)})}function s(Z,Q){if(Q&&Q[Z]===false){return false}return Q&&Q[Z]||o[Z]}function x(Z,ai){var ae=[],ad=s("proxyGetElementById",ai),ag=s("writeOnGetElementById",ai),Q={write:j.write,writeln:j.writeln,finish:function(){},out:""};Z.state=Q;j.write=ah;j.writeln=aa;if(ad||ag){Q.getEl=j.getElementById;j.getElementById=ab;if(ag){findEl=af}else{findEl=ac;Q.finish=function(){I(ae)}}}function ah(aj){Q.out+=aj}function aa(aj){Q.out+=aj+"\n"}function ac(ak){var aj=j.createElement("div");ae.push({id:ak,el:aj});aj.contentWindow={document:new M()};return aj}function af(al){var aj=E.$(Z.target);var ak=j.createElement("div");aj.parentNode.insertBefore(ak,aj);E.replaceWith(ak,Q.out);Q.out="";return e?Q.getEl.call(j,al):Q.getEl(al)}function ab(ak){var aj=e?Q.getEl.call(j,ak):Q.getEl(ak);return aj||findEl(ak)}return Q}function V(Q){j.write=Q.write;j.writeln=Q.writeln;if(Q.getEl){j.getElementById=Q.getEl}return Q.out}function N(Q){return Q&&Q.replace(/^\s*<!(\[CDATA\[|--)/,"").replace(/(\]\]|--)>\s*$/,"")}function b(){}function d(Z,Q){console.error("Error",Q,"executing code:",Z)}var l=v(a.console&&console.error)?d:b;function S(aa,Z,Q){var ab=x(Z,Q);try{A(N(aa))}catch(ac){l(aa,ac)}finally{V(ab)}return ab}function O(Z){var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(Z);return Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)}function T(Q){return new RegExp(Q+"=(?:([\"'])([\\s\\S]*?)\\1|([^\\s>]+))","i")}function k(Q){var Z=T(Q);return function(aa){var ab=Z.exec(aa)||[];return ab[2]||ab[3]}}var r=/(<script[\s\S]*?>)([\s\S]*?)<\/script>/ig,n=T("src"),X=k("src"),q=k("type"),Y=k("language"),C="__document_write_ajax_callbacks__",B="__document_write_ajax_div-",g="window['"+C+"']['%d']();",m=a[C]={},w='<script type="text/javascript">'+g+"<\/script>",H=0;function c(){return(++H).toString()}function G(Z,aa){var Q;if(v(Z)){Q=Z;Z=null}Z=Z||{};Q=Q||Z&&Z.done;Z.done=aa?function(){aa(Q)}:Q;return Z}var z=new i();var y=[];var f=window._debugWriteCapture?function(){}:function(Q,aa,Z){y.push({type:Q,src:aa,data:Z})};var K=window._debugWriteCapture?function(){}:function(){y.push(arguments)};function W(Q){var Z=c();m[Z]=function(){Q();delete m[Z]};return Z}function J(Q){return w.replace(/%d/,W(Q))}function R(ac,ag,aa,ae){var ad=aa&&new i(aa)||z;ag=G(ag);var ab=s("done",ag);var Q="";var Z=s("fixUrls",ag);if(!v(Z)){Z=function(ah){return ah}}if(v(ab)){Q=J(function(){ad.push(ab)})}return ac.replace(r,af)+Q;function af(aj,av,ai){var an=X(av),am=q(av)||"",aB=Y(av)||"",aA=(!am&&!aB)||am.toLowerCase().indexOf("javascript")!==-1||aB.toLowerCase().indexOf("javascript")!==-1;f("replace",an,aj);if(!aA){return aj}var aw=W(ap),ao=B+aw,au,al={target:"#"+ao,parent:ae};function ap(){ad.push(au)}if(an){an=Z(an);av=av.replace(n,"");if(O(an)){au=az}else{if(s("asyncAll",ag)){au=ay()}else{au=at}}}else{au=ax}function ax(){ah(ai)}function at(){E.ajax({url:an,type:"GET",dataType:"text",async:false,success:function(aC){ah(aC)}})}function ak(aE,aC,aD){l("<XHR for "+an+">",aD);ad.resume()}function aq(){return J(function(){ad.resume()})}function ay(){var aE,aD;function aC(aG,aF){if(!aE){aD=aG;return}try{ah(aG,aq())}catch(aH){l(aG,aH)}}E.ajax({url:an,type:"GET",dataType:"text",async:true,success:aC,error:ak});return function(){aE=true;if(aD){ah(aD)}else{ad.pause()}}}function az(aC){var aE=x(al,ag);ad.pause();f("pause",an);E.ajax({url:an,type:"GET",dataType:"script",success:aD,error:ak});function aD(aH,aG,aF){f("out",an,aE.out);ar(V(aE),J(aE.finish)+aq());f("resume",an)}}function ah(aD,aC){var aE=S(aD,al,ag);aC=J(aE.finish)+(aC||"");ar(aE.out,aC)}function ar(aD,aC){E.replaceWith(al.target,R(aD,null,ad,al)+(aC||""))}return'<div style="display: none" id="'+ao+'"></div>'+av+g.replace(/%d/,aw)+"<\/script>"}}function F(Z,aa){var Q=z;P(Z,function(ab){Q.push(ac);function ac(){ab.action(R(ab.html,ab.options,Q),ab)}});if(aa){Q.push(aa)}}function U(Q){var Z=Q;while(Z&&Z.nodeType===1){Q=Z;Z=Z.lastChild;while(Z&&Z.nodeType!==1){Z=Z.previousSibling}}return Q}function h(Q){var aa=j.write,ad=j.writeln,Z,ab=[];j.writeln=function(ae){j.write(ae+"\n")};var ac;j.write=function(af){var ae=U(j.body);if(ae!==Z){Z=ae;ab.push(ac={el:ae,out:[]})}ac.out.push(af)};E.onLoad(function(){var ah,ak,af,aj,ai;Q=G(Q);ai=Q.done;Q.done=function(){j.write=aa;j.writeln=ad;if(ai){ai()}};for(var ag=0,ae=ab.length;ag<ae;ag++){ah=ab[ag].el;ak=j.createElement("div");ah.parentNode.insertBefore(ak,ah.nextSibling);af=ab[ag].out.join("");aj=ae-ag===1?R(af,Q):R(af);E.replaceWith(ak,aj)}})}var t="writeCapture";var o=a[t]={_original:a[t],fixUrls:function(Q){return Q.replace(/&amp;/g,"&")},noConflict:function(){a[t]=this._original;return this},debug:y,proxyGetElementById:false,_forTest:{Q:i,GLOBAL_Q:z,$:E,matchAttr:k,slice:u,capture:x,uncapture:V,captureWrite:S},replaceWith:function(Q,aa,Z){E.replaceWith(Q,R(aa,Z))},html:function(Q,ab,Z){var aa=E.$(Q);aa.innerHTML="<span/>";E.replaceWith(aa.firstChild,R(ab,Z))},load:function(Q,aa,Z){E.ajax({url:aa,dataType:"text",type:"GET",success:function(ab){o.html(Q,ab,Z)}})},autoAsync:h,sanitize:R,sanitizeSerial:F}})(this.writeCaptureSupport,this);(function(g,d,n){var c={html:h};g.each(["append","prepend","after","before","wrap","wrapAll","replaceWith","wrapInner"],function(){c[this]=i(this)});function a(q){return Object.prototype.toString.call(q)=="[object String]"}function p(u,t,s,r){if(arguments.length==0){return o.call(this)}var q=c[u];if(u=="load"){return l.call(this,t,s,r)}if(!q){j(u)}return b.call(this,t,s,q)}g.fn.writeCapture=p;var k="__writeCaptureJsProxied-fghebd__";function o(){if(this[k]){return this}var r=this;function q(){var t=this,s=false;this[k]=true;g.each(c,function(v){var u=r[v];if(!u){return}t[v]=function(y,x,w){if(!s&&a(y)){try{s=true;return p.call(t,v,y,x,w)}finally{s=false}}return u.apply(t,arguments)}});this.pushStack=function(){return o.call(r.pushStack.apply(t,arguments))};this.endCapture=function(){return r}}q.prototype=r;return new q()}function b(t,s,u){var q,r=this;if(s&&s.done){q=s.done;delete s.done}else{if(g.isFunction(s)){q=s;s=null}}d.sanitizeSerial(g.map(this,function(v){return{html:t,options:s,action:function(w){u.call(v,w)}}}),q&&function(){q.call(r)}||q);return this}function h(q){g(this).html(q)}function i(q){return function(r){g(this)[q](r)}}function l(t,s,v){var r=this,q,u=t.indexOf(" ");if(u>=0){q=t.slice(u,t.length);t=t.slice(0,u)}if(g.isFunction(v)){s=s||{};s.done=v}return g.ajax({url:t,type:s&&s.type||"GET",dataType:"html",data:s&&s.params,complete:f(r,s,q)})}function f(r,s,q){return function(u,t){if(t=="success"||t=="notmodified"){var v=m(u.responseText,q);b.call(r,v,s,h)}}}var e=/jquery-writeCapture-script-placeholder-(\d+)-wc/g;function m(s,r){if(!r||!s){return s}var t=0,q={};return g("<div/>").append(s.replace(/<script(.|\s)*?\/script>/g,function(u){q[t]=u;return"jquery-writeCapture-script-placeholder-"+(t++)+"-wc"})).find(r).html().replace(e,function(u,v){return q[v]})}function j(q){throw"invalid method parameter "+q}g.writeCapture=d})(jQuery,writeCapture.noConflict());
  9460. /*!
  9461. * Amplify Store - Persistent Client-Side Storage 1.0.0
  9462. *
  9463. * Copyright 2011 appendTo LLC. (http://appendto.com/team)
  9464. * Dual licensed under the MIT or GPL licenses.
  9465. * http://appendto.com/open-source-licenses
  9466. *
  9467. * http://amplifyjs.com
  9468. */
  9469. (function( amplify, undefined ) {
  9470. var store = amplify.store = function( key, value, options, type ) {
  9471. var type = store.type;
  9472. if ( options && options.type && options.type in store.types ) {
  9473. type = options.type;
  9474. }
  9475. return store.types[ type ]( key, value, options || {} );
  9476. };
  9477. store.types = {};
  9478. store.type = null;
  9479. store.addType = function( type, storage ) {
  9480. if ( !store.type ) {
  9481. store.type = type;
  9482. }
  9483. store.types[ type ] = storage;
  9484. store[ type ] = function( key, value, options ) {
  9485. options = options || {};
  9486. options.type = type;
  9487. return store( key, value, options );
  9488. };
  9489. }
  9490. store.error = function() {
  9491. return "amplify.store quota exceeded";
  9492. };
  9493. var rprefix = /^__amplify__/;
  9494. function createFromStorageInterface( storageType, storage ) {
  9495. store.addType( storageType, function( key, value, options ) {
  9496. var storedValue, parsed, i, remove,
  9497. ret = value,
  9498. now = (new Date()).getTime();
  9499. if ( !key ) {
  9500. ret = {};
  9501. remove = [];
  9502. i = 0;
  9503. try {
  9504. // accessing the length property works around a localStorage bug
  9505. // in Firefox 4.0 where the keys don't update cross-page
  9506. // we assign to key just to avoid Closure Compiler from removing
  9507. // the access as "useless code"
  9508. // https://bugzilla.mozilla.org/show_bug.cgi?id=662511
  9509. key = storage.length;
  9510. while ( key = storage.key( i++ ) ) {
  9511. if ( rprefix.test( key ) ) {
  9512. parsed = JSON.parse( storage.getItem( key ) );
  9513. if ( parsed.expires && parsed.expires <= now ) {
  9514. remove.push( key );
  9515. } else {
  9516. ret[ key.replace( rprefix, "" ) ] = parsed.data;
  9517. }
  9518. }
  9519. }
  9520. while ( key = remove.pop() ) {
  9521. storage.removeItem( key );
  9522. }
  9523. } catch ( error ) {}
  9524. return ret;
  9525. }
  9526. // protect against name collisions with direct storage
  9527. key = "__amplify__" + key;
  9528. if ( value === undefined ) {
  9529. storedValue = storage.getItem( key );
  9530. parsed = storedValue ? JSON.parse( storedValue ) : { expires: -1 };
  9531. if ( parsed.expires && parsed.expires <= now ) {
  9532. storage.removeItem( key );
  9533. } else {
  9534. return parsed.data;
  9535. }
  9536. } else {
  9537. if ( value === null ) {
  9538. storage.removeItem( key );
  9539. } else {
  9540. parsed = JSON.stringify({
  9541. data: value,
  9542. expires: options.expires ? now + options.expires : null
  9543. });
  9544. try {
  9545. storage.setItem( key, parsed );
  9546. // quota exceeded
  9547. } catch( error ) {
  9548. // expire old data and try again
  9549. store[ storageType ]();
  9550. try {
  9551. storage.setItem( key, parsed );
  9552. } catch( error ) {
  9553. throw store.error();
  9554. }
  9555. }
  9556. }
  9557. }
  9558. return ret;
  9559. });
  9560. }
  9561. // localStorage + sessionStorage
  9562. // IE 8+, Firefox 3.5+, Safari 4+, Chrome 4+, Opera 10.5+, iPhone 2+, Android 2+
  9563. for ( var webStorageType in { localStorage: 1, sessionStorage: 1 } ) {
  9564. // try/catch for file protocol in Firefox
  9565. try {
  9566. if ( window[ webStorageType ].getItem ) {
  9567. createFromStorageInterface( webStorageType, window[ webStorageType ] );
  9568. }
  9569. } catch( e ) {}
  9570. }
  9571. // globalStorage
  9572. // non-standard: Firefox 2+
  9573. // https://developer.mozilla.org/en/dom/storage#globalStorage
  9574. if ( window.globalStorage ) {
  9575. // try/catch for file protocol in Firefox
  9576. try {
  9577. createFromStorageInterface( "globalStorage",
  9578. window.globalStorage[ window.location.hostname ] );
  9579. // Firefox 2.0 and 3.0 have sessionStorage and globalStorage
  9580. // make sure we default to globalStorage
  9581. // but don't default to globalStorage in 3.5+ which also has localStorage
  9582. if ( store.type === "sessionStorage" ) {
  9583. store.type = "globalStorage";
  9584. }
  9585. } catch( e ) {}
  9586. }
  9587. // userData
  9588. // non-standard: IE 5+
  9589. // http://msdn.microsoft.com/en-us/library/ms531424(v=vs.85).aspx
  9590. (function() {
  9591. // IE 9 has quirks in userData that are a huge pain
  9592. // rather than finding a way to detect these quirks
  9593. // we just don't register userData if we have localStorage
  9594. if ( store.types.localStorage ) {
  9595. return;
  9596. }
  9597. // append to html instead of body so we can do this from the head
  9598. var div = document.createElement( "div" ),
  9599. attrKey = "amplify";
  9600. div.style.display = "none";
  9601. document.getElementsByTagName( "head" )[ 0 ].appendChild( div );
  9602. if ( div.addBehavior ) {
  9603. div.addBehavior( "#default#userdata" );
  9604. store.addType( "userData", function( key, value, options ) {
  9605. div.load( attrKey );
  9606. var attr, parsed, prevValue, i, remove,
  9607. ret = value,
  9608. now = (new Date()).getTime();
  9609. if ( !key ) {
  9610. ret = {};
  9611. remove = [];
  9612. i = 0;
  9613. while ( attr = div.XMLDocument.documentElement.attributes[ i++ ] ) {
  9614. parsed = JSON.parse( attr.value );
  9615. if ( parsed.expires && parsed.expires <= now ) {
  9616. remove.push( attr.name );
  9617. } else {
  9618. ret[ attr.name ] = parsed.data;
  9619. }
  9620. }
  9621. while ( key = remove.pop() ) {
  9622. div.removeAttribute( key );
  9623. }
  9624. div.save( attrKey );
  9625. return ret;
  9626. }
  9627. // convert invalid characters to dashes
  9628. // http://www.w3.org/TR/REC-xml/#NT-Name
  9629. // simplified to assume the starting character is valid
  9630. // also removed colon as it is invalid in HTML attribute names
  9631. //key = key.replace( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-" );
  9632. if ( value === undefined ) {
  9633. attr = div.getAttribute( key );
  9634. parsed = attr ? JSON.parse( attr ) : { expires: -1 };
  9635. if ( parsed.expires && parsed.expires <= now ) {
  9636. div.removeAttribute( key );
  9637. } else {
  9638. return parsed.data;
  9639. }
  9640. } else {
  9641. if ( value === null ) {
  9642. div.removeAttribute( key );
  9643. } else {
  9644. // we need to get the previous value in case we need to rollback
  9645. prevValue = div.getAttribute( key );
  9646. parsed = JSON.stringify({
  9647. data: value,
  9648. expires: (options.expires ? (now + options.expires) : null)
  9649. });
  9650. div.setAttribute( key, parsed );
  9651. }
  9652. }
  9653. try {
  9654. div.save( attrKey );
  9655. // quota exceeded
  9656. } catch ( error ) {
  9657. // roll the value back to the previous value
  9658. if ( prevValue === null ) {
  9659. div.removeAttribute( key );
  9660. } else {
  9661. div.setAttribute( key, prevValue );
  9662. }
  9663. // expire old data and try again
  9664. store.userData();
  9665. try {
  9666. div.setAttribute( key, parsed );
  9667. div.save( attrKey );
  9668. } catch ( error ) {
  9669. // roll the value back to the previous value
  9670. if ( prevValue === null ) {
  9671. div.removeAttribute( key );
  9672. } else {
  9673. div.setAttribute( key, prevValue );
  9674. }
  9675. throw store.error();
  9676. }
  9677. }
  9678. return ret;
  9679. });
  9680. }
  9681. }() );
  9682. // in-memory storage
  9683. // fallback for all browsers to enable the API even if we can't persist data
  9684. (function() {
  9685. var memory = {};
  9686. function copy( obj ) {
  9687. return obj === undefined ? undefined : JSON.parse( JSON.stringify( obj ) );
  9688. }
  9689. store.addType( "memory", function( key, value, options ) {
  9690. if ( !key ) {
  9691. return copy( memory );
  9692. }
  9693. if ( value === undefined ) {
  9694. return copy( memory[ key ] );
  9695. }
  9696. if ( value === null ) {
  9697. delete memory[ key ];
  9698. return null;
  9699. }
  9700. memory[ key ] = value;
  9701. if ( options.expires ) {
  9702. setTimeout(function() {
  9703. delete memory[ key ];
  9704. }, options.expires );
  9705. }
  9706. return value;
  9707. });
  9708. }() );
  9709. }( this.amplify = this.amplify || {} ) );
  9710. /*!
  9711. * Modernizr v2.0.6
  9712. * http://www.modernizr.com
  9713. *
  9714. * Copyright (c) 2009-2011 Faruk Ates, Paul Irish, Alex Sexton
  9715. * Dual-licensed under the BSD or MIT licenses: www.modernizr.com/license/
  9716. */
  9717. /*
  9718. * Modernizr tests which native CSS3 and HTML5 features are available in
  9719. * the current UA and makes the results available to you in two ways:
  9720. * as properties on a global Modernizr object, and as classes on the
  9721. * <html> element. This information allows you to progressively enhance
  9722. * your pages with a granular level of control over the experience.
  9723. *
  9724. * Modernizr has an optional (not included) conditional resource loader
  9725. * called Modernizr.load(), based on Yepnope.js (yepnopejs.com).
  9726. * To get a build that includes Modernizr.load(), as well as choosing
  9727. * which tests to include, go to www.modernizr.com/download/
  9728. *
  9729. * Authors Faruk Ates, Paul Irish, Alex Sexton,
  9730. * Contributors Ryan Seddon, Ben Alman
  9731. */
  9732. window.Modernizr = (function( window, document, undefined ) {
  9733. var version = '2.0.6',
  9734. Modernizr = {},
  9735. // option for enabling the HTML classes to be added
  9736. enableClasses = true,
  9737. docElement = document.documentElement,
  9738. docHead = document.head || document.getElementsByTagName('head')[0],
  9739. /**
  9740. * Create our "modernizr" element that we do most feature tests on.
  9741. */
  9742. mod = 'modernizr',
  9743. modElem = document.createElement(mod),
  9744. mStyle = modElem.style,
  9745. /**
  9746. * Create the input element for various Web Forms feature tests.
  9747. */
  9748. inputElem = document.createElement('input'),
  9749. smile = ':)',
  9750. toString = Object.prototype.toString,
  9751. // List of property values to set for css tests. See ticket #21
  9752. prefixes = ' -webkit- -moz- -o- -ms- -khtml- '.split(' '),
  9753. // Following spec is to expose vendor-specific style properties as:
  9754. // elem.style.WebkitBorderRadius
  9755. // and the following would be incorrect:
  9756. // elem.style.webkitBorderRadius
  9757. // Webkit ghosts their properties in lowercase but Opera & Moz do not.
  9758. // Microsoft foregoes prefixes entirely <= IE8, but appears to
  9759. // use a lowercase `ms` instead of the correct `Ms` in IE9
  9760. // More here: http://github.com/Modernizr/Modernizr/issues/issue/21
  9761. domPrefixes = 'Webkit Moz O ms Khtml'.split(' '),
  9762. ns = {'svg': 'http://www.w3.org/2000/svg'},
  9763. tests = {},
  9764. inputs = {},
  9765. attrs = {},
  9766. classes = [],
  9767. featureName, // used in testing loop
  9768. // Inject element with style element and some CSS rules
  9769. injectElementWithStyles = function( rule, callback, nodes, testnames ) {
  9770. var style, ret, node,
  9771. div = document.createElement('div');
  9772. if ( parseInt(nodes, 10) ) {
  9773. // In order not to give false positives we create a node for each test
  9774. // This also allows the method to scale for unspecified uses
  9775. while ( nodes-- ) {
  9776. node = document.createElement('div');
  9777. node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
  9778. div.appendChild(node);
  9779. }
  9780. }
  9781. // <style> elements in IE6-9 are considered 'NoScope' elements and therefore will be removed
  9782. // when injected with innerHTML. To get around this you need to prepend the 'NoScope' element
  9783. // with a 'scoped' element, in our case the soft-hyphen entity as it won't mess with our measurements.
  9784. // http://msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
  9785. style = ['&shy;', '<style>', rule, '</style>'].join('');
  9786. div.id = mod;
  9787. div.innerHTML += style;
  9788. docElement.appendChild(div);
  9789. ret = callback(div, rule);
  9790. div.parentNode.removeChild(div);
  9791. return !!ret;
  9792. },
  9793. // adapted from matchMedia polyfill
  9794. // by Scott Jehl and Paul Irish
  9795. // gist.github.com/786768
  9796. testMediaQuery = function( mq ) {
  9797. if ( window.matchMedia ) {
  9798. return matchMedia(mq).matches;
  9799. }
  9800. var bool;
  9801. injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) {
  9802. bool = (window.getComputedStyle ?
  9803. getComputedStyle(node, null) :
  9804. node.currentStyle)['position'] == 'absolute';
  9805. });
  9806. return bool;
  9807. },
  9808. /**
  9809. * isEventSupported determines if a given element supports the given event
  9810. * function from http://yura.thinkweb2.com/isEventSupported/
  9811. */
  9812. isEventSupported = (function() {
  9813. var TAGNAMES = {
  9814. 'select': 'input', 'change': 'input',
  9815. 'submit': 'form', 'reset': 'form',
  9816. 'error': 'img', 'load': 'img', 'abort': 'img'
  9817. };
  9818. function isEventSupported( eventName, element ) {
  9819. element = element || document.createElement(TAGNAMES[eventName] || 'div');
  9820. eventName = 'on' + eventName;
  9821. // When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those
  9822. var isSupported = eventName in element;
  9823. if ( !isSupported ) {
  9824. // If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element
  9825. if ( !element.setAttribute ) {
  9826. element = document.createElement('div');
  9827. }
  9828. if ( element.setAttribute && element.removeAttribute ) {
  9829. element.setAttribute(eventName, '');
  9830. isSupported = is(element[eventName], 'function');
  9831. // If property was created, "remove it" (by setting value to `undefined`)
  9832. if ( !is(element[eventName], undefined) ) {
  9833. element[eventName] = undefined;
  9834. }
  9835. element.removeAttribute(eventName);
  9836. }
  9837. }
  9838. element = null;
  9839. return isSupported;
  9840. }
  9841. return isEventSupported;
  9842. })();
  9843. // hasOwnProperty shim by kangax needed for Safari 2.0 support
  9844. var _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
  9845. if ( !is(_hasOwnProperty, undefined) && !is(_hasOwnProperty.call, undefined) ) {
  9846. hasOwnProperty = function (object, property) {
  9847. return _hasOwnProperty.call(object, property);
  9848. };
  9849. }
  9850. else {
  9851. hasOwnProperty = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */
  9852. return ((property in object) && is(object.constructor.prototype[property], undefined));
  9853. };
  9854. }
  9855. /**
  9856. * setCss applies given styles to the Modernizr DOM node.
  9857. */
  9858. function setCss( str ) {
  9859. mStyle.cssText = str;
  9860. }
  9861. /**
  9862. * setCssAll extrapolates all vendor-specific css strings.
  9863. */
  9864. function setCssAll( str1, str2 ) {
  9865. return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
  9866. }
  9867. /**
  9868. * is returns a boolean for if typeof obj is exactly type.
  9869. */
  9870. function is( obj, type ) {
  9871. return typeof obj === type;
  9872. }
  9873. /**
  9874. * contains returns a boolean for if substr is found within str.
  9875. */
  9876. function contains( str, substr ) {
  9877. return !!~('' + str).indexOf(substr);
  9878. }
  9879. /**
  9880. * testProps is a generic CSS / DOM property test; if a browser supports
  9881. * a certain property, it won't return undefined for it.
  9882. * A supported CSS property returns empty string when its not yet set.
  9883. */
  9884. function testProps( props, prefixed ) {
  9885. for ( var i in props ) {
  9886. if ( mStyle[ props[i] ] !== undefined ) {
  9887. return prefixed == 'pfx' ? props[i] : true;
  9888. }
  9889. }
  9890. return false;
  9891. }
  9892. /**
  9893. * testPropsAll tests a list of DOM properties we want to check against.
  9894. * We specify literally ALL possible (known and/or likely) properties on
  9895. * the element including the non-vendor prefixed one, for forward-
  9896. * compatibility.
  9897. */
  9898. function testPropsAll( prop, prefixed ) {
  9899. var ucProp = prop.charAt(0).toUpperCase() + prop.substr(1),
  9900. props = (prop + ' ' + domPrefixes.join(ucProp + ' ') + ucProp).split(' ');
  9901. return testProps(props, prefixed);
  9902. }
  9903. /**
  9904. * testBundle tests a list of CSS features that require element and style injection.
  9905. * By bundling them together we can reduce the need to touch the DOM multiple times.
  9906. */
  9907. /*>>testBundle*/
  9908. var testBundle = (function( styles, tests ) {
  9909. var style = styles.join(''),
  9910. len = tests.length;
  9911. injectElementWithStyles(style, function( node, rule ) {
  9912. var style = document.styleSheets[document.styleSheets.length - 1],
  9913. // IE8 will bork if you create a custom build that excludes both fontface and generatedcontent tests.
  9914. // So we check for cssRules and that there is a rule available
  9915. // More here: https://github.com/Modernizr/Modernizr/issues/288 & https://github.com/Modernizr/Modernizr/issues/293
  9916. cssText = style.cssRules && style.cssRules[0] ? style.cssRules[0].cssText : style.cssText || "",
  9917. children = node.childNodes, hash = {};
  9918. while ( len-- ) {
  9919. hash[children[len].id] = children[len];
  9920. }
  9921. /*>>touch*/ Modernizr['touch'] = ('ontouchstart' in window) || hash['touch'].offsetTop === 9; /*>>touch*/
  9922. /*>>csstransforms3d*/ Modernizr['csstransforms3d'] = hash['csstransforms3d'].offsetLeft === 9; /*>>csstransforms3d*/
  9923. /*>>generatedcontent*/Modernizr['generatedcontent'] = hash['generatedcontent'].offsetHeight >= 1; /*>>generatedcontent*/
  9924. /*>>fontface*/ Modernizr['fontface'] = /src/i.test(cssText) &&
  9925. cssText.indexOf(rule.split(' ')[0]) === 0; /*>>fontface*/
  9926. }, len, tests);
  9927. })([
  9928. // Pass in styles to be injected into document
  9929. /*>>fontface*/ '@font-face {font-family:"font";src:url("https://")}' /*>>fontface*/
  9930. /*>>touch*/ ,['@media (',prefixes.join('touch-enabled),('),mod,')',
  9931. '{#touch{top:9px;position:absolute}}'].join('') /*>>touch*/
  9932. /*>>csstransforms3d*/ ,['@media (',prefixes.join('transform-3d),('),mod,')',
  9933. '{#csstransforms3d{left:9px;position:absolute}}'].join('')/*>>csstransforms3d*/
  9934. /*>>generatedcontent*/,['#generatedcontent:after{content:"',smile,'";visibility:hidden}'].join('') /*>>generatedcontent*/
  9935. ],
  9936. [
  9937. /*>>fontface*/ 'fontface' /*>>fontface*/
  9938. /*>>touch*/ ,'touch' /*>>touch*/
  9939. /*>>csstransforms3d*/ ,'csstransforms3d' /*>>csstransforms3d*/
  9940. /*>>generatedcontent*/,'generatedcontent' /*>>generatedcontent*/
  9941. ]);/*>>testBundle*/
  9942. /**
  9943. * Tests
  9944. * -----
  9945. */
  9946. tests['flexbox'] = function() {
  9947. /**
  9948. * setPrefixedValueCSS sets the property of a specified element
  9949. * adding vendor prefixes to the VALUE of the property.
  9950. * @param {Element} element
  9951. * @param {string} property The property name. This will not be prefixed.
  9952. * @param {string} value The value of the property. This WILL be prefixed.
  9953. * @param {string=} extra Additional CSS to append unmodified to the end of
  9954. * the CSS string.
  9955. */
  9956. function setPrefixedValueCSS( element, property, value, extra ) {
  9957. property += ':';
  9958. element.style.cssText = (property + prefixes.join(value + ';' + property)).slice(0, -property.length) + (extra || '');
  9959. }
  9960. /**
  9961. * setPrefixedPropertyCSS sets the property of a specified element
  9962. * adding vendor prefixes to the NAME of the property.
  9963. * @param {Element} element
  9964. * @param {string} property The property name. This WILL be prefixed.
  9965. * @param {string} value The value of the property. This will not be prefixed.
  9966. * @param {string=} extra Additional CSS to append unmodified to the end of
  9967. * the CSS string.
  9968. */
  9969. function setPrefixedPropertyCSS( element, property, value, extra ) {
  9970. element.style.cssText = prefixes.join(property + ':' + value + ';') + (extra || '');
  9971. }
  9972. var c = document.createElement('div'),
  9973. elem = document.createElement('div');
  9974. setPrefixedValueCSS(c, 'display', 'box', 'width:42px;padding:0;');
  9975. setPrefixedPropertyCSS(elem, 'box-flex', '1', 'width:10px;');
  9976. c.appendChild(elem);
  9977. docElement.appendChild(c);
  9978. var ret = elem.offsetWidth === 42;
  9979. c.removeChild(elem);
  9980. docElement.removeChild(c);
  9981. return ret;
  9982. };
  9983. // On the S60 and BB Storm, getContext exists, but always returns undefined
  9984. // http://github.com/Modernizr/Modernizr/issues/issue/97/
  9985. tests['canvas'] = function() {
  9986. var elem = document.createElement('canvas');
  9987. return !!(elem.getContext && elem.getContext('2d'));
  9988. };
  9989. tests['canvastext'] = function() {
  9990. return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));
  9991. };
  9992. // This WebGL test may false positive.
  9993. // But really it's quite impossible to know whether webgl will succeed until after you create the context.
  9994. // You might have hardware that can support a 100x100 webgl canvas, but will not support a 1000x1000 webgl
  9995. // canvas. So this feature inference is weak, but intentionally so.
  9996. // It is known to false positive in FF4 with certain hardware and the iPad 2.
  9997. tests['webgl'] = function() {
  9998. return !!window.WebGLRenderingContext;
  9999. };
  10000. /*
  10001. * The Modernizr.touch test only indicates if the browser supports
  10002. * touch events, which does not necessarily reflect a touchscreen
  10003. * device, as evidenced by tablets running Windows 7 or, alas,
  10004. * the Palm Pre / WebOS (touch) phones.
  10005. *
  10006. * Additionally, Chrome (desktop) used to lie about its support on this,
  10007. * but that has since been rectified: http://crbug.com/36415
  10008. *
  10009. * We also test for Firefox 4 Multitouch Support.
  10010. *
  10011. * For more info, see: http://modernizr.github.com/Modernizr/touch.html
  10012. */
  10013. tests['touch'] = function() {
  10014. return Modernizr['touch'];
  10015. };
  10016. /**
  10017. * geolocation tests for the new Geolocation API specification.
  10018. * This test is a standards compliant-only test; for more complete
  10019. * testing, including a Google Gears fallback, please see:
  10020. * http://code.google.com/p/geo-location-javascript/
  10021. * or view a fallback solution using google's geo API:
  10022. * http://gist.github.com/366184
  10023. */
  10024. tests['geolocation'] = function() {
  10025. return !!navigator.geolocation;
  10026. };
  10027. // Per 1.6:
  10028. // This used to be Modernizr.crosswindowmessaging but the longer
  10029. // name has been deprecated in favor of a shorter and property-matching one.
  10030. // The old API is still available in 1.6, but as of 2.0 will throw a warning,
  10031. // and in the first release thereafter disappear entirely.
  10032. tests['postmessage'] = function() {
  10033. return !!window.postMessage;
  10034. };
  10035. // Web SQL database detection is tricky:
  10036. // In chrome incognito mode, openDatabase is truthy, but using it will
  10037. // throw an exception: http://crbug.com/42380
  10038. // We can create a dummy database, but there is no way to delete it afterwards.
  10039. // Meanwhile, Safari users can get prompted on any database creation.
  10040. // If they do, any page with Modernizr will give them a prompt:
  10041. // http://github.com/Modernizr/Modernizr/issues/closed#issue/113
  10042. // We have chosen to allow the Chrome incognito false positive, so that Modernizr
  10043. // doesn't litter the web with these test databases. As a developer, you'll have
  10044. // to account for this gotcha yourself.
  10045. tests['websqldatabase'] = function() {
  10046. var result = !!window.openDatabase;
  10047. /* if (result){
  10048. try {
  10049. result = !!openDatabase( mod + "testdb", "1.0", mod + "testdb", 2e4);
  10050. } catch(e) {
  10051. }
  10052. } */
  10053. return result;
  10054. };
  10055. // Vendors had inconsistent prefixing with the experimental Indexed DB:
  10056. // - Webkit's implementation is accessible through webkitIndexedDB
  10057. // - Firefox shipped moz_indexedDB before FF4b9, but since then has been mozIndexedDB
  10058. // For speed, we don't test the legacy (and beta-only) indexedDB
  10059. tests['indexedDB'] = function() {
  10060. for ( var i = -1, len = domPrefixes.length; ++i < len; ){
  10061. if ( window[domPrefixes[i].toLowerCase() + 'IndexedDB'] ){
  10062. return true;
  10063. }
  10064. }
  10065. return !!window.indexedDB;
  10066. };
  10067. // documentMode logic from YUI to filter out IE8 Compat Mode
  10068. // which false positives.
  10069. tests['hashchange'] = function() {
  10070. return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7);
  10071. };
  10072. // Per 1.6:
  10073. // This used to be Modernizr.historymanagement but the longer
  10074. // name has been deprecated in favor of a shorter and property-matching one.
  10075. // The old API is still available in 1.6, but as of 2.0 will throw a warning,
  10076. // and in the first release thereafter disappear entirely.
  10077. tests['history'] = function() {
  10078. return !!(window.history && history.pushState);
  10079. };
  10080. tests['draganddrop'] = function() {
  10081. return isEventSupported('dragstart') && isEventSupported('drop');
  10082. };
  10083. // Mozilla is targeting to land MozWebSocket for FF6
  10084. // bugzil.la/659324
  10085. tests['websockets'] = function() {
  10086. for ( var i = -1, len = domPrefixes.length; ++i < len; ){
  10087. if ( window[domPrefixes[i] + 'WebSocket'] ){
  10088. return true;
  10089. }
  10090. }
  10091. return 'WebSocket' in window;
  10092. };
  10093. // http://css-tricks.com/rgba-browser-support/
  10094. tests['rgba'] = function() {
  10095. // Set an rgba() color and check the returned value
  10096. setCss('background-color:rgba(150,255,150,.5)');
  10097. return contains(mStyle.backgroundColor, 'rgba');
  10098. };
  10099. tests['hsla'] = function() {
  10100. // Same as rgba(), in fact, browsers re-map hsla() to rgba() internally,
  10101. // except IE9 who retains it as hsla
  10102. setCss('background-color:hsla(120,40%,100%,.5)');
  10103. return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla');
  10104. };
  10105. tests['multiplebgs'] = function() {
  10106. // Setting multiple images AND a color on the background shorthand property
  10107. // and then querying the style.background property value for the number of
  10108. // occurrences of "url(" is a reliable method for detecting ACTUAL support for this!
  10109. setCss('background:url(https://),url(https://),red url(https://)');
  10110. // If the UA supports multiple backgrounds, there should be three occurrences
  10111. // of the string "url(" in the return value for elemStyle.background
  10112. return /(url\s*\(.*?){3}/.test(mStyle.background);
  10113. };
  10114. // In testing support for a given CSS property, it's legit to test:
  10115. // `elem.style[styleName] !== undefined`
  10116. // If the property is supported it will return an empty string,
  10117. // if unsupported it will return undefined.
  10118. // We'll take advantage of this quick test and skip setting a style
  10119. // on our modernizr element, but instead just testing undefined vs
  10120. // empty string.
  10121. tests['backgroundsize'] = function() {
  10122. return testPropsAll('backgroundSize');
  10123. };
  10124. tests['borderimage'] = function() {
  10125. return testPropsAll('borderImage');
  10126. };
  10127. // Super comprehensive table about all the unique implementations of
  10128. // border-radius: http://muddledramblings.com/table-of-css3-border-radius-compliance
  10129. tests['borderradius'] = function() {
  10130. return testPropsAll('borderRadius');
  10131. };
  10132. // WebOS unfortunately false positives on this test.
  10133. tests['boxshadow'] = function() {
  10134. return testPropsAll('boxShadow');
  10135. };
  10136. // FF3.0 will false positive on this test
  10137. tests['textshadow'] = function() {
  10138. return document.createElement('div').style.textShadow === '';
  10139. };
  10140. tests['opacity'] = function() {
  10141. // Browsers that actually have CSS Opacity implemented have done so
  10142. // according to spec, which means their return values are within the
  10143. // range of [0.0,1.0] - including the leading zero.
  10144. setCssAll('opacity:.55');
  10145. // The non-literal . in this regex is intentional:
  10146. // German Chrome returns this value as 0,55
  10147. // https://github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632
  10148. return /^0.55$/.test(mStyle.opacity);
  10149. };
  10150. tests['cssanimations'] = function() {
  10151. return testPropsAll('animationName');
  10152. };
  10153. tests['csscolumns'] = function() {
  10154. return testPropsAll('columnCount');
  10155. };
  10156. tests['cssgradients'] = function() {
  10157. /**
  10158. * For CSS Gradients syntax, please see:
  10159. * http://webkit.org/blog/175/introducing-css-gradients/
  10160. * https://developer.mozilla.org/en/CSS/-moz-linear-gradient
  10161. * https://developer.mozilla.org/en/CSS/-moz-radial-gradient
  10162. * http://dev.w3.org/csswg/css3-images/#gradients-
  10163. */
  10164. var str1 = 'background-image:',
  10165. str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',
  10166. str3 = 'linear-gradient(left top,#9f9, white);';
  10167. setCss(
  10168. (str1 + prefixes.join(str2 + str1) + prefixes.join(str3 + str1)).slice(0, -str1.length)
  10169. );
  10170. return contains(mStyle.backgroundImage, 'gradient');
  10171. };
  10172. tests['cssreflections'] = function() {
  10173. return testPropsAll('boxReflect');
  10174. };
  10175. tests['csstransforms'] = function() {
  10176. return !!testProps(['transformProperty', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform']);
  10177. };
  10178. tests['csstransforms3d'] = function() {
  10179. var ret = !!testProps(['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']);
  10180. // Webkit’s 3D transforms are passed off to the browser's own graphics renderer.
  10181. // It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in
  10182. // some conditions. As a result, Webkit typically recognizes the syntax but
  10183. // will sometimes throw a false positive, thus we must do a more thorough check:
  10184. if ( ret && 'webkitPerspective' in docElement.style ) {
  10185. // Webkit allows this media query to succeed only if the feature is enabled.
  10186. // `@media (transform-3d),(-o-transform-3d),(-moz-transform-3d),(-ms-transform-3d),(-webkit-transform-3d),(modernizr){ ... }`
  10187. ret = Modernizr['csstransforms3d'];
  10188. }
  10189. return ret;
  10190. };
  10191. tests['csstransitions'] = function() {
  10192. return testPropsAll('transitionProperty');
  10193. };
  10194. /*>>fontface*/
  10195. // @font-face detection routine by Diego Perini
  10196. // http://javascript.nwbox.com/CSSSupport/
  10197. tests['fontface'] = function() {
  10198. return Modernizr['fontface'];
  10199. };
  10200. /*>>fontface*/
  10201. // CSS generated content detection
  10202. tests['generatedcontent'] = function() {
  10203. return Modernizr['generatedcontent'];
  10204. };
  10205. // These tests evaluate support of the video/audio elements, as well as
  10206. // testing what types of content they support.
  10207. //
  10208. // We're using the Boolean constructor here, so that we can extend the value
  10209. // e.g. Modernizr.video // true
  10210. // Modernizr.video.ogg // 'probably'
  10211. //
  10212. // Codec values from : http://github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845
  10213. // thx to NielsLeenheer and zcorpan
  10214. // Note: in FF 3.5.1 and 3.5.0, "no" was a return value instead of empty string.
  10215. // Modernizr does not normalize for that.
  10216. tests['video'] = function() {
  10217. var elem = document.createElement('video'),
  10218. bool = false;
  10219. // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
  10220. try {
  10221. if ( bool = !!elem.canPlayType ) {
  10222. bool = new Boolean(bool);
  10223. bool.ogg = elem.canPlayType('video/ogg; codecs="theora"');
  10224. // Workaround required for IE9, which doesn't report video support without audio codec specified.
  10225. // bug 599718 @ msft connect
  10226. var h264 = 'video/mp4; codecs="avc1.42E01E';
  10227. bool.h264 = elem.canPlayType(h264 + '"') || elem.canPlayType(h264 + ', mp4a.40.2"');
  10228. bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"');
  10229. }
  10230. } catch(e) { }
  10231. return bool;
  10232. };
  10233. tests['audio'] = function() {
  10234. var elem = document.createElement('audio'),
  10235. bool = false;
  10236. try {
  10237. if ( bool = !!elem.canPlayType ) {
  10238. bool = new Boolean(bool);
  10239. bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"');
  10240. bool.mp3 = elem.canPlayType('audio/mpeg;');
  10241. // Mimetypes accepted:
  10242. // https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
  10243. // http://bit.ly/iphoneoscodecs
  10244. bool.wav = elem.canPlayType('audio/wav; codecs="1"');
  10245. bool.m4a = elem.canPlayType('audio/x-m4a;') || elem.canPlayType('audio/aac;');
  10246. }
  10247. } catch(e) { }
  10248. return bool;
  10249. };
  10250. // Firefox has made these tests rather unfun.
  10251. // In FF4, if disabled, window.localStorage should === null.
  10252. // Normally, we could not test that directly and need to do a
  10253. // `('localStorage' in window) && ` test first because otherwise Firefox will
  10254. // throw http://bugzil.la/365772 if cookies are disabled
  10255. // However, in Firefox 4 betas, if dom.storage.enabled == false, just mentioning
  10256. // the property will throw an exception. http://bugzil.la/599479
  10257. // This looks to be fixed for FF4 Final.
  10258. // Because we are forced to try/catch this, we'll go aggressive.
  10259. // FWIW: IE8 Compat mode supports these features completely:
  10260. // http://www.quirksmode.org/dom/html5.html
  10261. // But IE8 doesn't support either with local files
  10262. tests['localstorage'] = function() {
  10263. try {
  10264. return !!localStorage.getItem;
  10265. } catch(e) {
  10266. return false;
  10267. }
  10268. };
  10269. tests['sessionstorage'] = function() {
  10270. try {
  10271. return !!sessionStorage.getItem;
  10272. } catch(e){
  10273. return false;
  10274. }
  10275. };
  10276. tests['webworkers'] = function() {
  10277. return !!window.Worker;
  10278. };
  10279. tests['applicationcache'] = function() {
  10280. return !!window.applicationCache;
  10281. };
  10282. // Thanks to Erik Dahlstrom
  10283. tests['svg'] = function() {
  10284. return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect;
  10285. };
  10286. // specifically for SVG inline in HTML, not within XHTML
  10287. // test page: paulirish.com/demo/inline-svg
  10288. tests['inlinesvg'] = function() {
  10289. var div = document.createElement('div');
  10290. div.innerHTML = '<svg/>';
  10291. return (div.firstChild && div.firstChild.namespaceURI) == ns.svg;
  10292. };
  10293. // Thanks to F1lt3r and lucideer, ticket #35
  10294. tests['smil'] = function() {
  10295. return !!document.createElementNS && /SVG/.test(toString.call(document.createElementNS(ns.svg, 'animate')));
  10296. };
  10297. tests['svgclippaths'] = function() {
  10298. // Possibly returns a false positive in Safari 3.2?
  10299. return !!document.createElementNS && /SVG/.test(toString.call(document.createElementNS(ns.svg, 'clipPath')));
  10300. };
  10301. // input features and input types go directly onto the ret object, bypassing the tests loop.
  10302. // Hold this guy to execute in a moment.
  10303. function webforms() {
  10304. // Run through HTML5's new input attributes to see if the UA understands any.
  10305. // We're using f which is the <input> element created early on
  10306. // Mike Taylr has created a comprehensive resource for testing these attributes
  10307. // when applied to all input types:
  10308. // http://miketaylr.com/code/input-type-attr.html
  10309. // spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  10310. // Only input placeholder is tested while textarea's placeholder is not.
  10311. // Currently Safari 4 and Opera 11 have support only for the input placeholder
  10312. // Both tests are available in feature-detects/forms-placeholder.js
  10313. Modernizr['input'] = (function( props ) {
  10314. for ( var i = 0, len = props.length; i < len; i++ ) {
  10315. attrs[ props[i] ] = !!(props[i] in inputElem);
  10316. }
  10317. return attrs;
  10318. })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
  10319. // Run through HTML5's new input types to see if the UA understands any.
  10320. // This is put behind the tests runloop because it doesn't return a
  10321. // true/false like all the other tests; instead, it returns an object
  10322. // containing each input type with its corresponding true/false value
  10323. // Big thanks to @miketaylr for the html5 forms expertise. http://miketaylr.com/
  10324. Modernizr['inputtypes'] = (function(props) {
  10325. for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {
  10326. inputElem.setAttribute('type', inputElemType = props[i]);
  10327. bool = inputElem.type !== 'text';
  10328. // We first check to see if the type we give it sticks..
  10329. // If the type does, we feed it a textual value, which shouldn't be valid.
  10330. // If the value doesn't stick, we know there's input sanitization which infers a custom UI
  10331. if ( bool ) {
  10332. inputElem.value = smile;
  10333. inputElem.style.cssText = 'position:absolute;visibility:hidden;';
  10334. if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
  10335. docElement.appendChild(inputElem);
  10336. defaultView = document.defaultView;
  10337. // Safari 2-4 allows the smiley as a value, despite making a slider
  10338. bool = defaultView.getComputedStyle &&
  10339. defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
  10340. // Mobile android web browser has false positive, so must
  10341. // check the height to see if the widget is actually there.
  10342. (inputElem.offsetHeight !== 0);
  10343. docElement.removeChild(inputElem);
  10344. } else if ( /^(search|tel)$/.test(inputElemType) ){
  10345. // Spec doesnt define any special parsing or detectable UI
  10346. // behaviors so we pass these through as true
  10347. // Interestingly, opera fails the earlier test, so it doesn't
  10348. // even make it here.
  10349. } else if ( /^(url|email)$/.test(inputElemType) ) {
  10350. // Real url and email support comes with prebaked validation.
  10351. bool = inputElem.checkValidity && inputElem.checkValidity() === false;
  10352. } else if ( /^color$/.test(inputElemType) ) {
  10353. // chuck into DOM and force reflow for Opera bug in 11.00
  10354. // github.com/Modernizr/Modernizr/issues#issue/159
  10355. docElement.appendChild(inputElem);
  10356. docElement.offsetWidth;
  10357. bool = inputElem.value != smile;
  10358. docElement.removeChild(inputElem);
  10359. } else {
  10360. // If the upgraded input compontent rejects the :) text, we got a winner
  10361. bool = inputElem.value != smile;
  10362. }
  10363. }
  10364. inputs[ props[i] ] = !!bool;
  10365. }
  10366. return inputs;
  10367. })('search tel url email datetime date month week time datetime-local number range color'.split(' '));
  10368. }
  10369. // End of test definitions
  10370. // -----------------------
  10371. // Run through all tests and detect their support in the current UA.
  10372. // todo: hypothetically we could be doing an array of tests and use a basic loop here.
  10373. for ( var feature in tests ) {
  10374. if ( hasOwnProperty(tests, feature) ) {
  10375. // run the test, throw the return value into the Modernizr,
  10376. // then based on that boolean, define an appropriate className
  10377. // and push it into an array of classes we'll join later.
  10378. featureName = feature.toLowerCase();
  10379. Modernizr[featureName] = tests[feature]();
  10380. classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
  10381. }
  10382. }
  10383. // input tests need to run.
  10384. Modernizr.input || webforms();
  10385. /**
  10386. * addTest allows the user to define their own feature tests
  10387. * the result will be added onto the Modernizr object,
  10388. * as well as an appropriate className set on the html element
  10389. *
  10390. * @param feature - String naming the feature
  10391. * @param test - Function returning true if feature is supported, false if not
  10392. */
  10393. Modernizr.addTest = function ( feature, test ) {
  10394. if ( typeof feature == "object" ) {
  10395. for ( var key in feature ) {
  10396. if ( hasOwnProperty( feature, key ) ) {
  10397. Modernizr.addTest( key, feature[ key ] );
  10398. }
  10399. }
  10400. } else {
  10401. feature = feature.toLowerCase();
  10402. if ( Modernizr[feature] !== undefined ) {
  10403. // we're going to quit if you're trying to overwrite an existing test
  10404. // if we were to allow it, we'd do this:
  10405. // var re = new RegExp("\\b(no-)?" + feature + "\\b");
  10406. // docElement.className = docElement.className.replace( re, '' );
  10407. // but, no rly, stuff 'em.
  10408. return;
  10409. }
  10410. test = typeof test == "boolean" ? test : !!test();
  10411. docElement.className += ' ' + (test ? '' : 'no-') + feature;
  10412. Modernizr[feature] = test;
  10413. }
  10414. return Modernizr; // allow chaining.
  10415. };
  10416. // Reset modElem.cssText to nothing to reduce memory footprint.
  10417. setCss('');
  10418. modElem = inputElem = null;
  10419. //>>BEGIN IEPP
  10420. // Enable HTML 5 elements for styling (and printing) in IE.
  10421. if ( window.attachEvent && (function(){ var elem = document.createElement('div');
  10422. elem.innerHTML = '<elem></elem>';
  10423. return elem.childNodes.length !== 1; })() ) {
  10424. // iepp v2 by @jon_neal & afarkas : github.com/aFarkas/iepp/
  10425. (function(win, doc) {
  10426. win.iepp = win.iepp || {};
  10427. var iepp = win.iepp,
  10428. elems = iepp.html5elements || 'abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video',
  10429. elemsArr = elems.split('|'),
  10430. elemsArrLen = elemsArr.length,
  10431. elemRegExp = new RegExp('(^|\\s)('+elems+')', 'gi'),
  10432. tagRegExp = new RegExp('<(\/*)('+elems+')', 'gi'),
  10433. filterReg = /^\s*[\{\}]\s*$/,
  10434. ruleRegExp = new RegExp('(^|[^\\n]*?\\s)('+elems+')([^\\n]*)({[\\n\\w\\W]*?})', 'gi'),
  10435. docFrag = doc.createDocumentFragment(),
  10436. html = doc.documentElement,
  10437. head = html.firstChild,
  10438. bodyElem = doc.createElement('body'),
  10439. styleElem = doc.createElement('style'),
  10440. printMedias = /print|all/,
  10441. body;
  10442. function shim(doc) {
  10443. var a = -1;
  10444. while (++a < elemsArrLen)
  10445. // Use createElement so IE allows HTML5-named elements in a document
  10446. doc.createElement(elemsArr[a]);
  10447. }
  10448. iepp.getCSS = function(styleSheetList, mediaType) {
  10449. if(styleSheetList+'' === undefined){return '';}
  10450. var a = -1,
  10451. len = styleSheetList.length,
  10452. styleSheet,
  10453. cssTextArr = [];
  10454. while (++a < len) {
  10455. styleSheet = styleSheetList[a];
  10456. //currently no test for disabled/alternate stylesheets
  10457. if(styleSheet.disabled){continue;}
  10458. mediaType = styleSheet.media || mediaType;
  10459. // Get css from all non-screen stylesheets and their imports
  10460. if (printMedias.test(mediaType)) cssTextArr.push(iepp.getCSS(styleSheet.imports, mediaType), styleSheet.cssText);
  10461. //reset mediaType to all with every new *not imported* stylesheet
  10462. mediaType = 'all';
  10463. }
  10464. return cssTextArr.join('');
  10465. };
  10466. iepp.parseCSS = function(cssText) {
  10467. var cssTextArr = [],
  10468. rule;
  10469. while ((rule = ruleRegExp.exec(cssText)) != null){
  10470. // Replace all html5 element references with iepp substitute classnames
  10471. cssTextArr.push(( (filterReg.exec(rule[1]) ? '\n' : rule[1]) +rule[2]+rule[3]).replace(elemRegExp, '$1.iepp_$2')+rule[4]);
  10472. }
  10473. return cssTextArr.join('\n');
  10474. };
  10475. iepp.writeHTML = function() {
  10476. var a = -1;
  10477. body = body || doc.body;
  10478. while (++a < elemsArrLen) {
  10479. var nodeList = doc.getElementsByTagName(elemsArr[a]),
  10480. nodeListLen = nodeList.length,
  10481. b = -1;
  10482. while (++b < nodeListLen)
  10483. if (nodeList[b].className.indexOf('iepp_') < 0)
  10484. // Append iepp substitute classnames to all html5 elements
  10485. nodeList[b].className += ' iepp_'+elemsArr[a];
  10486. }
  10487. docFrag.appendChild(body);
  10488. html.appendChild(bodyElem);
  10489. // Write iepp substitute print-safe document
  10490. bodyElem.className = body.className;
  10491. bodyElem.id = body.id;
  10492. // Replace HTML5 elements with <font> which is print-safe and shouldn't conflict since it isn't part of html5
  10493. bodyElem.innerHTML = body.innerHTML.replace(tagRegExp, '<$1font');
  10494. };
  10495. iepp._beforePrint = function() {
  10496. // Write iepp custom print CSS
  10497. styleElem.styleSheet.cssText = iepp.parseCSS(iepp.getCSS(doc.styleSheets, 'all'));
  10498. iepp.writeHTML();
  10499. };
  10500. iepp.restoreHTML = function(){
  10501. // Undo everything done in onbeforeprint
  10502. bodyElem.innerHTML = '';
  10503. html.removeChild(bodyElem);
  10504. html.appendChild(body);
  10505. };
  10506. iepp._afterPrint = function(){
  10507. // Undo everything done in onbeforeprint
  10508. iepp.restoreHTML();
  10509. styleElem.styleSheet.cssText = '';
  10510. };
  10511. // Shim the document and iepp fragment
  10512. shim(doc);
  10513. shim(docFrag);
  10514. //
  10515. if(iepp.disablePP){return;}
  10516. // Add iepp custom print style element
  10517. head.insertBefore(styleElem, head.firstChild);
  10518. styleElem.media = 'print';
  10519. styleElem.className = 'iepp-printshim';
  10520. win.attachEvent(
  10521. 'onbeforeprint',
  10522. iepp._beforePrint
  10523. );
  10524. win.attachEvent(
  10525. 'onafterprint',
  10526. iepp._afterPrint
  10527. );
  10528. })(window, document);
  10529. }
  10530. //>>END IEPP
  10531. // Assign private properties to the return object with prefix
  10532. Modernizr._version = version;
  10533. // expose these for the plugin API. Look in the source for how to join() them against your input
  10534. Modernizr._prefixes = prefixes;
  10535. Modernizr._domPrefixes = domPrefixes;
  10536. // Modernizr.mq tests a given media query, live against the current state of the window
  10537. // A few important notes:
  10538. // * If a browser does not support media queries at all (eg. oldIE) the mq() will always return false
  10539. // * A max-width or orientation query will be evaluated against the current state, which may change later.
  10540. // * You must specify values. Eg. If you are testing support for the min-width media query use:
  10541. // Modernizr.mq('(min-width:0)')
  10542. // usage:
  10543. // Modernizr.mq('only screen and (max-width:768)')
  10544. Modernizr.mq = testMediaQuery;
  10545. // Modernizr.hasEvent() detects support for a given event, with an optional element to test on
  10546. // Modernizr.hasEvent('gesturestart', elem)
  10547. Modernizr.hasEvent = isEventSupported;
  10548. // Modernizr.testProp() investigates whether a given style property is recognized
  10549. // Note that the property names must be provided in the camelCase variant.
  10550. // Modernizr.testProp('pointerEvents')
  10551. Modernizr.testProp = function(prop){
  10552. return testProps([prop]);
  10553. };
  10554. // Modernizr.testAllProps() investigates whether a given style property,
  10555. // or any of its vendor-prefixed variants, is recognized
  10556. // Note that the property names must be provided in the camelCase variant.
  10557. // Modernizr.testAllProps('boxSizing')
  10558. Modernizr.testAllProps = testPropsAll;
  10559. // Modernizr.testStyles() allows you to add custom styles to the document and test an element afterwards
  10560. // Modernizr.testStyles('#modernizr { position:absolute }', function(elem, rule){ ... })
  10561. Modernizr.testStyles = injectElementWithStyles;
  10562. // Modernizr.prefixed() returns the prefixed or nonprefixed property name variant of your input
  10563. // Modernizr.prefixed('boxSizing') // 'MozBoxSizing'
  10564. // Properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style.
  10565. // Return values will also be the camelCase variant, if you need to translate that to hypenated style use:
  10566. //
  10567. // str.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-');
  10568. // If you're trying to ascertain which transition end event to bind to, you might do something like...
  10569. //
  10570. // var transEndEventNames = {
  10571. // 'WebkitTransition' : 'webkitTransitionEnd',
  10572. // 'MozTransition' : 'transitionend',
  10573. // 'OTransition' : 'oTransitionEnd',
  10574. // 'msTransition' : 'msTransitionEnd', // maybe?
  10575. // 'transition' : 'transitionEnd'
  10576. // },
  10577. // transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
  10578. Modernizr.prefixed = function(prop){
  10579. return testPropsAll(prop, 'pfx');
  10580. };
  10581. // Remove "no-js" class from <html> element, if it exists:
  10582. docElement.className = docElement.className.replace(/\bno-js\b/, '')
  10583. // Add the new classes to the <html> element.
  10584. + (enableClasses ? ' js ' + classes.join(' ') : '');
  10585. return Modernizr;
  10586. })(this, this.document);
  10587. /**
  10588. * Array prototype extensions.
  10589. * Extends array prototype with the following methods:
  10590. * contains, every, exfiltrate, filter, forEach, getRange, inArray, indexOf, insertAt, map, randomize, removeAt, some, unique
  10591. *
  10592. * This extensions doesn't depend on any other code or overwrite existing methods.
  10593. *
  10594. *
  10595. * Copyright (c) 2007 Harald Hanek (http://js-methods.googlecode.com)
  10596. *
  10597. * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
  10598. * and GPL (http://www.gnu.org/licenses/gpl.html) licenses.
  10599. *
  10600. * @author Harald Hanek
  10601. * @version 0.9
  10602. * @lastchangeddate 10. October 2007 15:46:06
  10603. * @revision 876
  10604. */
  10605. (function(){
  10606. /**
  10607. * Extend the array prototype with the method under the given name if it doesn't currently exist.
  10608. *
  10609. * @private
  10610. */
  10611. function append(name, method)
  10612. {
  10613. if(!Array.prototype[name])
  10614. Array.prototype[name] = method;
  10615. };
  10616. /**
  10617. * Returns true if every element in 'elements' is in the array.
  10618. *
  10619. * @example [1, 2, 1, 4, 5, 4].contains([1, 2, 4]);
  10620. * @result true
  10621. *
  10622. * @name contains
  10623. * @param Array elements
  10624. * @return Boolean
  10625. */
  10626. append("contains", function(elements){
  10627. return this.every(function(element){
  10628. return this.indexOf(element) >= 0; }, elements);
  10629. });
  10630. /**
  10631. * Returns the array without the elements in 'elements'.
  10632. *
  10633. * @example [1, 2, 1, 4, 5, 4].contains([1, 2, 4]);
  10634. * @result true
  10635. *
  10636. * @name exfiltrate
  10637. * @param Array elements
  10638. * @return Boolean
  10639. */
  10640. append("exfiltrate", function(elements){
  10641. return this.filter(function(element){
  10642. return this.indexOf(element) < 0; }, elements);
  10643. });
  10644. /**
  10645. * Tests whether all elements in the array pass the test implemented by the provided function.
  10646. *
  10647. * @example [22, 72, 16, 99, 254].every(function(element, index, array) {
  10648. * return element >= 15;
  10649. * });
  10650. * @result true;
  10651. *
  10652. * @example [12, 72, 16, 99, 254].every(function(element, index, array) {
  10653. * return element >= 15;
  10654. * });
  10655. * @result false;
  10656. *
  10657. * @name every
  10658. * @param Function fn The function to be called for each element.
  10659. * @param Object scope (optional) The scope of the function (defaults to this).
  10660. * @return Boolean
  10661. */
  10662. append("every", function(fn, scope){
  10663. for(var i = 0; i < this.length; i++)
  10664. if(!fn.call(scope || window, this[i], i, this))
  10665. return false;
  10666. return true;
  10667. });
  10668. /**
  10669. * Creates a new array with all elements that pass the test implemented by the provided function.
  10670. *
  10671. * Natively supported in Gecko since version 1.8.
  10672. * http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter
  10673. *
  10674. * @example [12, 5, 8, 1, 44].filter(function(element, index, array) {
  10675. * return element >= 10;
  10676. * });
  10677. * @result [12, 44];
  10678. *
  10679. * @name filter
  10680. * @param Function fn The function to be called for each element.
  10681. * @param Object scope (optional) The scope of the function (defaults to this).
  10682. * @return Array
  10683. */
  10684. append("filter", function(fn, scope){
  10685. var r = [];
  10686. for(var i = 0; i < this.length; i++)
  10687. if(fn.call(scope || window, this[i], i, this))
  10688. r.push(this[i]);
  10689. return r;
  10690. });
  10691. /**
  10692. * Executes a provided function once per array element.
  10693. *
  10694. * Natively supported in Gecko since version 1.8.
  10695. * http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach
  10696. *
  10697. * @example var stuff = "";
  10698. * ["Java", "Script"].forEach(function(element, index, array) {
  10699. * stuff += element;
  10700. * });
  10701. * @result "JavaScript";
  10702. *
  10703. * @name forEach
  10704. * @param Function fn The function to be called for each element.
  10705. * @param Object scope (optional) The scope of the function (defaults to this).
  10706. * @return void
  10707. */
  10708. append("forEach", function(fn, scope){
  10709. for(var i = 0; i < this.length; i++)
  10710. fn.call(scope || window, this[i], i, this);
  10711. });
  10712. /**
  10713. * Returns a range of items in this collection
  10714. *
  10715. * @example [1, 2, 1, 4, 5, 4].getRange(2, 4);
  10716. * @result [1, 4, 5]
  10717. *
  10718. * @name getRange
  10719. * @param Number startIndex (optional) defaults to 0
  10720. * @param Number endIndex (optional) default to the last item
  10721. * @return Array
  10722. */
  10723. append("getRange", function(start, end){
  10724. var items = this;
  10725. if(items.length < 1)
  10726. return [];
  10727. start = start || 0;
  10728. end = Math.min(typeof end == "undefined" ? this.length-1 : end, this.length-1);
  10729. var r = [];
  10730. if(start <= end)
  10731. for(var i = start; i <= end; i++)
  10732. r[r.length] = items[i];
  10733. else
  10734. for(var i = start; i >= end; i--)
  10735. r[r.length] = items[i];
  10736. return r;
  10737. });
  10738. /**
  10739. * Returns the first index at which a given element can be found in the array, or -1 if it is not present.
  10740. *
  10741. * @example [12, 5, 8, 5, 44].indexOf(5);
  10742. * @result 1;
  10743. *
  10744. * @example [12, 5, 8, 5, 44].indexOf(5, 2);
  10745. * @result 3;
  10746. *
  10747. * @name indexOf
  10748. * @param Object subject Object to search for
  10749. * @param Number offset (optional) Index at which to start searching
  10750. * @return Int
  10751. */
  10752. append("indexOf", function(subject, offset){
  10753. for(var i = offset || 0; i < this.length; i++)
  10754. if(this[i] === subject)
  10755. return i;
  10756. return -1;
  10757. });
  10758. /**
  10759. * Checks if a given subject can be found in the array.
  10760. *
  10761. * @example [12, 5, 7, 5].inArray(7);
  10762. * @result true;
  10763. *
  10764. * @example [12, 5, 7, 5].inArray(9);
  10765. * @result false;
  10766. *
  10767. * @name inArray
  10768. * @param Object subject Object to search for
  10769. * @return Boolean
  10770. */
  10771. append("inArray", function(subject){
  10772. for(var i = 0; i < this.length; i++)
  10773. if(subject == this[i])
  10774. return true;
  10775. return false;
  10776. });
  10777. /**
  10778. * Inserts an item at the specified index in the array.
  10779. *
  10780. * @example ['dog', 'cat', 'horse'].insertAt(2, 'mouse');
  10781. * @result ['dog', 'cat', 'mouse', 'horse']
  10782. *
  10783. * @name insertAt
  10784. * @param Number index Position where to insert the element into the array
  10785. * @param Object element The element to insert
  10786. * @return Array
  10787. */
  10788. append("insertAt", function(index, element){
  10789. for(var k = this.length; k > index; k--)
  10790. this[k] = this[k-1];
  10791. this[index] = element;
  10792. return this;
  10793. });
  10794. /**
  10795. * Creates a new array with the results of calling a provided function on every element in this array.
  10796. *
  10797. * Natively supported in Gecko since version 1.8.
  10798. * http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:map
  10799. *
  10800. * @example ["my", "Name", "is", "HARRY"].map(function(element, index, array) {
  10801. * return element.toUpperCase();
  10802. * });
  10803. * @result ["MY", "NAME", "IS", "HARRY"];
  10804. *
  10805. * @example [1, 4, 9].map(Math.sqrt);
  10806. * @result [1, 2, 3];
  10807. *
  10808. * @name map
  10809. * @param Function fn The function to be called for each element.
  10810. * @param Object scope (optional) The scope of the function (defaults to this).
  10811. * @return Array
  10812. */
  10813. append("map", function(fn, scope){
  10814. scope = scope || window;
  10815. var r = [];
  10816. for(var i = 0; i < this.length; i++)
  10817. r[r.length] = fn.call(scope, this[i], i, this);
  10818. return r;
  10819. });
  10820. /**
  10821. * Remove an item from a specified index in the array.
  10822. *
  10823. * @example ['dog', 'cat', 'mouse', 'horse'].deleteAt(2);
  10824. * @result ['dog', 'cat', 'horse']
  10825. *
  10826. * @name removeAt
  10827. * @param Number index The index within the array of the item to remove.
  10828. * @return Array
  10829. */
  10830. append("removeAt", function(index){
  10831. for(var k = index; k < this.length-1; k++)
  10832. this[k] = this[k+1];
  10833. this.length--;
  10834. return this;
  10835. });
  10836. /**
  10837. * Randomize the order of the elements in the Array.
  10838. *
  10839. * @example [2, 3, 4, 5].randomize();
  10840. * @result [5, 2, 3, 4] randomized result
  10841. *
  10842. * @name randomize
  10843. * @return Array
  10844. */
  10845. append("randomize", function(){
  10846. return this.sort(function(){return(Math.round(Math.random())-0.5)});
  10847. //return this.sort(function(){return(Math.round(Math.random())-0.5)}, true);
  10848. });
  10849. /**
  10850. * Tests whether some element in the array passes the test implemented by the provided function.
  10851. *
  10852. * Natively supported in Gecko since version 1.8.
  10853. * http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:some
  10854. *
  10855. * @example [101, 199, 250, 200].some(function(element, index, array) {
  10856. * return element >= 100;
  10857. * });
  10858. * @result true;
  10859. *
  10860. * @example [101, 99, 250, 200].some(function(element, index, array) {
  10861. * return element >= 100;
  10862. * });
  10863. * @result false;
  10864. *
  10865. * @name some
  10866. * @param Function fn The function to be called for each element.
  10867. * @param Object scope (optional) The scope of the function (defaults to this).
  10868. * @return Boolean
  10869. */
  10870. append("some", function(fn, scope){
  10871. for(var i = 0; i < this.length; i++)
  10872. if(fn.call(scope || window, this[i], i, this))
  10873. return true;
  10874. return false;
  10875. });
  10876. /**
  10877. * Returns a new array that contains all unique elements of this array.
  10878. *
  10879. * @example [1, 2, 1, 4, 5, 4].unique();
  10880. * @result [1, 2, 4, 5]
  10881. *
  10882. * @name unique
  10883. * @return Array
  10884. */
  10885. append("unique", function(){
  10886. return this.filter(function(element, index, array){
  10887. return array.indexOf(element) >= index;
  10888. });
  10889. });
  10890. })();
  10891. /*
  10892. Copyright 2011 The greplin-exception-catcher Authors.
  10893. Licensed under the Apache License, Version 2.0 (the "License");
  10894. you may not use this file except in compliance with the License.
  10895. You may obtain a copy of the License at
  10896. http://www.apache.org/licenses/LICENSE-2.0
  10897. Unless required by applicable law or agreed to in writing, software
  10898. distributed under the License is distributed on an "AS IS" BASIS,
  10899. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10900. See the License for the specific language governing permissions and
  10901. limitations under the License.
  10902. ====
  10903. This Javascript file lets web applications get stacktraces for all uncaught JS exceptions and send them to Greplin
  10904. Exception Catcher.
  10905. Features include:
  10906. - Stacktraces in IE 6-8, as well as modern versions of Firefox, Chrome, and Opera
  10907. - Javascript execution entry point information (such as event type and listener) on IE 6-9 and modern versions of
  10908. Firefox, Chrome, Safari, and Opera
  10909. - Redaction of URLs and strings in stacktraces to avoid logging sensitive user information
  10910. Things that aren't done yet:
  10911. - Aggregation. Due to the way GEC works now, this would be impossible to do without losing potentially useful
  10912. information. To do this, GEC needs to be able to aggregate based upon a normalized stacktrace while still providing detailed information for each specific incident of the exception.
  10913. - Can't wrap DOM0 events (<div onclick> for example).
  10914. - Some code cleanup: Since this is a small, self-contained project, I took sort of a "hack it until it works" approach
  10915. to coding it. I'd like to go back and structure the code better sometime, but I probably wont' get around to it
  10916. anytime soon since it works very reliably as it is.
  10917. How to use it:
  10918. 1. Create an endpoint at your server to send this stuff to GEC.
  10919. 2. Modify the call to g.errorCatcher at the end of the file to pass in functions that pass exceptions to GEC and that
  10920. redact URLs respectively. (Note: your URL redaction function will be passed strings that may contain URLs, not bare
  10921. URLs, so keep that in mind)
  10922. 3. Wrap your JS files if you want to capture errors during their initial execution:
  10923. 
try {
 var your_js_here 
}
  10924. catch(e) { window.g && g.handleInitialException && g.handleInitialException(e, '(script filename here)') }
  10925. 
If you use Closure Compiler, just do
  10926. --output_wrapper="window.COMPILED = true; try { %%output%% } catch(e) { window.g && g.handleInitialException && g.handleInitialException(e, '(script filename here)') }"
  10927. 4. This exception catching script can't see exceptions that happen before it's loaded, so make sure it's loaded early in
  10928. your page before most of your other scripts.
  10929. */
  10930. var g = g || {};
  10931. /**
  10932. * Captures uncaught JS exceptions on the page and passes them to GEC.
  10933. * Can capture stacktraces in IE 6-8, Firefox, Chrome, and Opera, and can capture only the top of the stack in IE 9.
  10934. * In Safari, only basic event information is captured.
  10935. * Uses both window.onerror and wrapped DOM prototype interfaces to capture as much information as possible without
  10936. * requiring JS code changes.
  10937. */
  10938. g.errorCatcher = function(reportHandler, redactQueryStrings) {
  10939. g.errorCatcher.reportHandler_ = reportHandler;
  10940. g.errorCatcher.redactQueryStrings_ = redactQueryStrings;
  10941. // commented out part is for weird cases where you have two exception catchers.
  10942. // i haven't tested that case at all though, so i'm commenting it out for now.
  10943. var wrappedProperty = 'WrappedListener'; //+ Math.floor(Math.random() * 10000000).toString(30);
  10944. var supportsJsErrorStack;
  10945. try {
  10946. ({})['undefinedMethod']();
  10947. } catch(error) {
  10948. supportsJsErrorStack = 'stack' in error || 'stacktrace' in error;
  10949. }
  10950. var supportsWindowOnerror = 'onerror' in window && !/^Opera/.test(navigator.userAgent);
  10951. var supportsWindowOnerrorStack = /MSIE /.test(navigator.userAgent);
  10952. // Detecting support based on a whitelist sucks, but we don't want to accidentally log personal information, so we
  10953. // only allow browsers that we know that we can redact stacktrace strings for.
  10954. var supportsDOMWrapping =
  10955. // Chrome
  10956. /Chrom(e|ium)/.test(navigator.userAgent) ||
  10957. // IE 9+
  10958. /MSIE (9\.|[1-9][0-9]+\.)/.test(navigator.userAgent) || // XXX compat mode?
  10959. // Firefox 6+
  10960. /Gecko\/[0-9]/.test(navigator.userAgent) && (parseInt(navigator['buildID'], 10) >= 20110830092941) ||
  10961. // Safari 5.1+ (AppleWebKit/534+)
  10962. /AppleWebKit\/(53[4-9]|5[4-9][0-9]|[6-9][0-9]{2}|[1-9][0-9]{3})/.test(navigator.userAgent) ||
  10963. // Opera 11.50+
  10964. /^Opera.*Presto\/(2\.9|[3-9]|[1-9][0-9])/.test(navigator.userAgent);
  10965. if (supportsDOMWrapping) {
  10966. wrapTimeouts();
  10967. wrapDOMEvents();
  10968. wrapXMLHttpRequest();
  10969. }
  10970. if (supportsWindowOnerror &&
  10971. (!supportsDOMWrapping || (!supportsJsErrorStack && supportsWindowOnerrorStack))) {
  10972. window.onerror = function(errorMessage, url, lineNumber) {
  10973. // Grab the error provided by DOM wrappings, if it's available
  10974. var errorObject = g.errorCatcher.lastDomWrapperError_ || {};
  10975. delete g.errorCatcher.lastDomWrapperError_;
  10976. errorObject.message = errorObject.message || errorMessage;
  10977. errorObject.url = errorObject.url || url;
  10978. errorObject.line = errorObject.line || lineNumber;
  10979. // In IE, get the character offset inside the line of the error from window.event.
  10980. if (window.event && typeof window.event['errorCharacter'] == 'number') {
  10981. errorObject.character = (errorObject.character || window.event['errorCharacter']) + '';
  10982. }
  10983. // If there isn't already a stacktrace generated by the DOM wrappers, try to generate one using the old-fashioned
  10984. // caller method. This only works in IE 6-8. It partially works in IE 9 -- but it only lets you get the top of the
  10985. // stack.
  10986. if (!errorObject.stacktrace && supportsWindowOnerrorStack) {
  10987. try {
  10988. errorObject.stacktrace = g.errorCatcher.getStacktrace(arguments.callee.caller);
  10989. } catch(exception) {
  10990. errorObject.stacktrace = '[error generating stacktrace: ' + exception.message + ']';
  10991. }
  10992. }
  10993. g.errorCatcher.reportException(errorObject);
  10994. };
  10995. }
  10996. /**
  10997. * Wraps setTimeout and setInterval to handle uncaught exceptions in listeners.
  10998. */
  10999. function wrapTimeouts() {
  11000. wrapTimeoutsHelper('setTimeout');
  11001. wrapTimeoutsHelper('setInterval');
  11002. function wrapTimeoutsHelper(timeoutMethodName) {
  11003. var original = window[timeoutMethodName];
  11004. window[timeoutMethodName] = function(listener, delay) {
  11005. if (typeof listener == 'function') {
  11006. var newArgs = Array.prototype.slice.call(arguments);
  11007. newArgs[0] = function() {
  11008. try {
  11009. listener.apply(this, arguments);
  11010. } catch(exception) {
  11011. g.errorCatcher.handleCatchException(
  11012. exception, timeoutMethodName + '(' + g.errorCatcher.stringify(listener) + ', ' + delay + ')');
  11013. }
  11014. };
  11015. return original.apply(this, newArgs);
  11016. } else {
  11017. // If someone passes a string to setTimeout, don't bother wrapping it.
  11018. return original.apply(this, arguments);
  11019. }
  11020. }
  11021. }
  11022. }
  11023. /**
  11024. * Wraps DOM event interfaces (addEventListener and removeEventListener) to add try/catch wrappers to all event
  11025. * listeners.
  11026. */
  11027. function wrapDOMEvents() {
  11028. var eventsWrappedProperty = 'events' + wrappedProperty;
  11029. wrapDOMEventsHelper(window.XMLHttpRequest.prototype);
  11030. wrapDOMEventsHelper(window.Element.prototype);
  11031. wrapDOMEventsHelper(window);
  11032. wrapDOMEventsHelper(window.document);
  11033. // Workaround for Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=456151
  11034. if (document.documentElement.addEventListener != window.Element.prototype.addEventListener) {
  11035. var elementNames =
  11036. ('Unknown,Anchor,Applet,Area,BR,Base,Body,Button,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,' +
  11037. 'FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,IsIndex,LI,Label,Legend,Link,Map,Menu,Meta,Span,OList,' +
  11038. 'Object,OptGroup,Option,Paragraph,Param,Pre,Quote,Script,Select,Style,TableCaption,TableCell,TableCol,' +
  11039. 'Table,TableRow,TableSection,TextArea,Title,UList,Canvas').split(',');
  11040. elementNames.forEach(function(elementName) {
  11041. var constructor = window['HTML' + elementName + 'Element'];
  11042. if (constructor && constructor.prototype) {
  11043. wrapDOMEventsHelper(constructor.prototype);
  11044. }
  11045. });
  11046. }
  11047. function wrapDOMEventsHelper(object) {
  11048. var originalAddEventListener = object.addEventListener;
  11049. var originalRemoveEventListener = object.removeEventListener;
  11050. if (!originalAddEventListener || !originalRemoveEventListener) {
  11051. return;
  11052. }
  11053. object.addEventListener = function(eventType, listener, useCapture) {
  11054. // Dedupe the listener in case it is already listening unwrapped.
  11055. originalRemoveEventListener.apply(this, arguments);
  11056. if (typeof listener != 'function') {
  11057. // TODO(david): Handle a listener that is not a function, but instead an object that implements the
  11058. // EventListener interface (see http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener ).
  11059. originalAddEventListener.apply(this, arguments);
  11060. return;
  11061. }
  11062. listener[eventsWrappedProperty] = listener[eventsWrappedProperty] || {
  11063. innerListener: listener,
  11064. 'handleEvent': g.errorCatcher.listenerWrapper_
  11065. };
  11066. originalAddEventListener.call(this, eventType, listener[eventsWrappedProperty], useCapture);
  11067. };
  11068. object.removeEventListener = function(eventType, listener, useCapture) {
  11069. // Remove unwrapped listener, just to be sure.
  11070. originalRemoveEventListener.apply(this, arguments);
  11071. if (typeof listener != 'function') {
  11072. return;
  11073. }
  11074. if (listener[eventsWrappedProperty]) {
  11075. originalRemoveEventListener.call(this, eventType, listener[eventsWrappedProperty], useCapture);
  11076. }
  11077. };
  11078. }
  11079. }
  11080. /**
  11081. * Wrap XMLHttpRequest onreadystatechange listeners to handle uncaught JS exceptions.
  11082. * This only affects the .onreadystatechange property. The addEventListener property is handled by wrapDOMEvents.
  11083. */
  11084. function wrapXMLHttpRequest() {
  11085. var xhrWrappedProperty = 'xhr' + wrappedProperty;
  11086. var ctor = XMLHttpRequest, instance = new XMLHttpRequest;
  11087. if (!/(AppleWebKit|MSIE)/.test(navigator.userAgent) ||
  11088. (Object.getOwnPropertyDescriptor(ctor.prototype, 'onreadystatechange') || {}).configurable &&
  11089. instance.__lookupSetter__ && instance.__lookupSetter__('onreadystatechange')) {
  11090. // The browser has good support for manipulating XMLHttpRequest prototypes.
  11091. var onreadystatechangeSetter = instance.__lookupSetter__('onreadystatechange');
  11092. ctor.prototype.__defineGetter__('onreadystatechange', function() {
  11093. return this[xhrWrappedProperty];
  11094. });
  11095. ctor.prototype.__defineSetter__('onreadystatechange', function(listener) {
  11096. this[xhrWrappedProperty] = listener;
  11097. onreadystatechangeSetter.call(this, wrappedReadyStateChange);
  11098. });
  11099. } else {
  11100. // Chrome and Safari have problems with this. Instead, check to see if onreadystatechange needs to be wrapped
  11101. // from a readystatechange event listener.
  11102. var send = instance.send;
  11103. var addEventListener = instance.addEventListener;
  11104. XMLHttpRequest.prototype.send = function() {
  11105. addEventListener.call(this, 'readystatechange', wrapReadyStateChange, true);
  11106. return send.apply(this, arguments);
  11107. }
  11108. }
  11109. function wrappedReadyStateChange() {
  11110. try {
  11111. var onreadystatechange =
  11112. (this.onreadystatechange == arguments.callee ?
  11113. this[xhrWrappedProperty] : this.onreadystatechange);
  11114. this[xhrWrappedProperty].apply(this, arguments);
  11115. } catch(exception) {
  11116. // TODO(david): Expose some information about the xmlhttprequest to the exception logging (maybe request url)
  11117. g.errorCatcher.handleCatchException(exception, 'onreadystatechange');
  11118. }
  11119. }
  11120. // Used in the wrapped XHR::send handler to wrap onreadystatechange in response to addEventListener
  11121. // readystatechange events that fire first.
  11122. function wrapReadyStateChange() {
  11123. if (this.onreadystatechange && this.onreadystatechange != wrappedReadyStateChange) {
  11124. this[xhrWrappedProperty] = this.onreadystatechange;
  11125. this.onreadystatechange = wrappedReadyStateChange;
  11126. }
  11127. }
  11128. }
  11129. };
  11130. /**
  11131. * Time that the last error was reported. Used for rate-limiting.
  11132. * @type {number}
  11133. */
  11134. g.errorCatcher.lastError_ = 0;
  11135. /**
  11136. * Delay between reporting errors. Increases dynamically.
  11137. * @type {number}
  11138. */
  11139. g.errorCatcher.errorDelay_ = 10;
  11140. /**
  11141. * Wrapper for addEventListener/removeEventListener listeners. Global to avoid potential memory/performance impacts of a
  11142. * function closure for each event listener. This is a handleEvent property of the EventHandler object passed to
  11143. * addEventListener. It accesses other properties of that object to read exception information.
  11144. * @param {Event} eventObject The DOM event.
  11145. */
  11146. g.errorCatcher.listenerWrapper_ = function(eventObject) {
  11147. try {
  11148. return this.innerListener.apply(eventObject.target, arguments);
  11149. } catch(exception) {
  11150. g.errorCatcher.handleCatchException(
  11151. exception, eventObject.type + ' listener ' + g.errorCatcher.stringify(this.innerListener) + ' on ' +
  11152. g.errorCatcher.stringify(eventObject.currentTarget));
  11153. }
  11154. };
  11155. /**
  11156. * Passes an exception to GEC.
  11157. * TODO(david): show a message to the user. Let the user elect to send more detailed error information (un-redacted
  11158. * strings).
  11159. * @param {Object} errorObject An object describing the error.
  11160. */
  11161. g.errorCatcher.reportException = function(errorObject) {
  11162. var d = (new Date).getTime();
  11163. if (d - g.errorCatcher.lastError_ < g.errorCatcher.errorDelay_) {
  11164. // Rate limited
  11165. return;
  11166. }
  11167. g.errorCatcher.lastError_ = d;
  11168. g.errorCatcher.errorDelay_ = g.errorCatcher.errorDelay_ * 2;
  11169. errorObj = {
  11170. 'msg':g.errorCatcher.redactQueryStrings_(errorObject.message || ''),
  11171. 'line': errorObject.line + (typeof errorObject.character == 'string' ? ':' + errorObject.character : ''),
  11172. 'trace':'Type: ' + errorObject.name + '\nUser-agent: ' + navigator.userAgent +
  11173. '\nURL: ' + g.errorCatcher.redactQueryStrings_(location.href) + '\n\n' +
  11174. g.errorCatcher.redactQueryStrings_(errorObject.stacktrace || ''),
  11175. 'ts': Math.floor(new Date().getTime() / 1000),
  11176. 'name':g.errorCatcher.redactQueryStrings_(errorObject.context || '') || 'unidentified JS thread'};
  11177. g.errorCatcher.reportHandler_(errorObj);
  11178. };
  11179. /**
  11180. * Handles exceptions from the try { } catch { } block added around all of our compiled JS by our Closure Compiler
  11181. * configuration. This handles exceptions that occur during the intiial execution of the script.
  11182. * @param {Error} caughtException The caught exception.
  11183. * @param {string} fileName The name of the JS file where the exception occured.
  11184. */
  11185. g.errorCatcher.handleInitialException = function(caughtException, fileName) {
  11186. g.errorCatcher.handleCatchException(caughtException, 'Initial execution of ' + fileName);
  11187. };
  11188. /**
  11189. * Handles a caught exception. When window.onerror is available, the exception is re-thrown so that additional
  11190. * information from window.onerror can be added. Otherwise, the exception is passed to reportException, where it is
  11191. * sent to GEC and potentially displayed to the user.
  11192. * @param {Error} caughtException The caught JS exception.
  11193. * @param context
  11194. */
  11195. g.errorCatcher.handleCatchException = function(caughtException, context) {
  11196. if (!(caughtException instanceof window.Error)) {
  11197. caughtException = new Error(caughtException);
  11198. }
  11199. var errorObject = {};
  11200. errorObject.context = context;
  11201. errorObject.name = caughtException.name;
  11202. // Opera has both stacktrace and stack. Stacktrace is much more detailed, so use that when available.
  11203. errorObject.stacktrace = caughtException['stacktrace'] || caughtException['stack'];
  11204. if (/Gecko/.test(navigator.userAgent) && !/AppleWebKit/.test(navigator.userAgent)) {
  11205. errorObject.stacktrace = g.errorCatcher.redactFirefoxStacktraceStrings(errorObject.stacktrace);
  11206. }
  11207. errorObject.message = caughtException.message;
  11208. errorObject.number = caughtException.number;
  11209. var matches;
  11210. if ('lineNumber' in caughtException) {
  11211. errorObject.line = caughtException['lineNumber'];
  11212. } else if ('line' in caughtException) {
  11213. errorObject.line = caughtException['line'];
  11214. } else if (/Chrom(e|ium)/.test(navigator.userAgent)) {
  11215. matches = caughtException.stack.match(/\:(\d+)\:(\d+)\)(\n|$)/);
  11216. if (matches) {
  11217. errorObject.line = matches[1];
  11218. errorObject.character = matches[2];
  11219. }
  11220. } else if (/Opera/.test(navigator.userAgent)) {
  11221. matches = (errorObject['stacktrace'] || '').match(/Error thrown at line (\d+), column (\d+)/);
  11222. if (matches) {
  11223. errorObject.line = matches[1];
  11224. errorObject.character = matches[2];
  11225. } else {
  11226. matches = (errorObject['stacktrace'] || '').match(/Error thrown at line (\d+)/);
  11227. if (matches){
  11228. errorObject.line = matches[1];
  11229. }
  11230. }
  11231. }
  11232. if (window.onerror) {
  11233. // window.onerror is still needed to get stack in IE, so we need to re-throw the error to that.
  11234. g.errorCatcher.lastDomWrapperError_ = errorObject;
  11235. throw caughtException;
  11236. } else {
  11237. g.errorCatcher.reportException(errorObject);
  11238. }
  11239. };
  11240. /**
  11241. * @param {Function} opt_topFunction The function at the top of the stack; if omitted, the caller of makeStacktrace is
  11242. * used.
  11243. * @return {string} A string showing the stack of functions and arguments.
  11244. */
  11245. g.errorCatcher.getStacktrace = function(opt_topFunction) {
  11246. var stacktrace = '';
  11247. var func = opt_topFunction || arguments.callee.caller;
  11248. var used = [];
  11249. var length = 0;
  11250. stacktraceLoop: do {
  11251. stacktrace += g.errorCatcher.getFunctionName(func) + g.errorCatcher.getFunctionArgumentsString(func) + '\n';
  11252. used.push(func);
  11253. try {
  11254. func = func.caller;
  11255. for (var i = 0; i < used.length; i++) {
  11256. if (used[i] == func) {
  11257. stacktrace += g.errorCatcher.getFunctionName(func) + '(???)\n(...)\n';
  11258. break stacktraceLoop;
  11259. }
  11260. }
  11261. } catch(exception) {
  11262. stacktrace += '(???' + exception.message + ')\n';
  11263. break stacktraceLoop;
  11264. }
  11265. if (length > 50) {
  11266. stacktrace += '(...)\n';
  11267. }
  11268. } while (func);
  11269. return stacktrace;
  11270. };
  11271. /**
  11272. * @param {string} string The string to shorten.
  11273. * @param {number} maxLength The maximum length of the new string.
  11274. * @return {string} The string, shortened if it exceeds maxLength.
  11275. */
  11276. g.errorCatcher.shortenString = function(string, maxLength) {
  11277. if (string.length > maxLength) {
  11278. string = string.substr(0, maxLength) + '...';
  11279. }
  11280. return string;
  11281. };
  11282. /**
  11283. * @param {Function} func The function to get the name of.
  11284. * @return {string} The name of the function, or a snippet of the function's source code if it is an anonymous function.
  11285. */
  11286. g.errorCatcher.getFunctionName = function(func) {
  11287. var name;
  11288. try {
  11289. if ('name' in Function.prototype && func.name) {
  11290. name = func.name;
  11291. } else {
  11292. var funcStr = func.toString();
  11293. var matches = /function ([^\(]+)/.exec(funcStr);
  11294. name = matches && matches[1] || '[anonymous function: ' + g.errorCatcher.shortenString(func.toString(), 90) + ']';
  11295. }
  11296. } catch(exception) {
  11297. name = '[inaccessible function]'
  11298. }
  11299. return name;
  11300. };
  11301. /**
  11302. * @param func The function to get a string describing the arguments for. Must be in the current callstack.
  11303. * @return {string} A string of the arguments passed to the function.
  11304. */
  11305. g.errorCatcher.getFunctionArgumentsString = function(func) {
  11306. var argsStrings = [];
  11307. try {
  11308. var args = func.arguments;
  11309. if (args) {
  11310. for (var i = 0, length = args.length; i < length; i++) {
  11311. argsStrings.push(g.errorCatcher.stringify(args[i]));
  11312. }
  11313. }
  11314. } catch(exception) {
  11315. argsStrings.push('...?');
  11316. }
  11317. return '(' + argsStrings.join(',') + ')';
  11318. };
  11319. /**
  11320. * Converts objects and primitives to strings describing them. String inputs are redacted.
  11321. * @param {*} thing The object or primitive to describe.
  11322. * @return {string} String describing the input.
  11323. */
  11324. g.errorCatcher.stringify = function(thing) {
  11325. var string = '[???]';
  11326. try {
  11327. var type = typeof thing;
  11328. string = '[' + type + '?]';
  11329. switch (type) {
  11330. case 'undefined':
  11331. string = 'undefined';
  11332. break;
  11333. case 'number':
  11334. case 'boolean':
  11335. string = thing.toString();
  11336. break;
  11337. case 'object':
  11338. if (thing == null) {
  11339. string = 'null';
  11340. break;
  11341. }
  11342. if (thing instanceof Date) {
  11343. string = 'new Date("' + thing.toString() + '")';
  11344. break;
  11345. }
  11346. var toStringValue = thing.toString();
  11347. if (/^\[[a-z ]*\]$/i.test(toStringValue)) {
  11348. string = toStringValue;
  11349. break;
  11350. }
  11351. if (typeof thing.length == 'number') {
  11352. string = '[arraylike object, length = ' + thing.length + ']';
  11353. break;
  11354. }
  11355. string = '[object]';
  11356. break;
  11357. case 'string':
  11358. string = '"' + g.errorCatcher.redactString(thing) + '"';
  11359. break;
  11360. case 'function':
  11361. string = '/* function */ ' + g.errorCatcher.getFunctionName(thing);
  11362. break;
  11363. default:
  11364. string = '[' + type + '???]';
  11365. break;
  11366. }
  11367. } catch(exception) { }
  11368. return string;
  11369. };
  11370. /**
  11371. * Finds quoted strings in a Firefox stacktrace and replaces them with redacted versions. Handles pesky escaped quotes
  11372. * too. This relies on Firefox's specific stringification/escaping behavior and might not work as consistently in other
  11373. * browsers.
  11374. * @param {string} stacktraceStr The stacktrace to redact strings from.
  11375. * @return {string} The stacktrace, with strings redacted.
  11376. */
  11377. g.errorCatcher.redactFirefoxStacktraceStrings = function(stacktraceStr) {
  11378. if (!/\"/.test(stacktraceStr)) {
  11379. return stacktraceStr;
  11380. }
  11381. // We can safely use new ecmascript array methods because this code only runs in Firefox.
  11382. return stacktraceStr.split('\n').map(function(stacktraceLine) {
  11383. var quoteLocations = [];
  11384. var index = 0;
  11385. do {
  11386. index = (stacktraceLine.indexOf('"', index + 1));
  11387. if (index != -1) {
  11388. quoteLocations.push(index);
  11389. }
  11390. } while (index != -1);
  11391. quoteLocations = quoteLocations.filter(function(quoteLocation) {
  11392. var backslashCount = 0, index = quoteLocation;
  11393. while (index--) {
  11394. if (stacktraceLine.charAt(index) != '\\') {
  11395. break;
  11396. }
  11397. backslashCount = backslashCount + 1;
  11398. }
  11399. // If a quotation mark is preceded by a non-even number of backslashes, it is escaped. Otherwise, only the
  11400. // backslashes are escaped.
  11401. // \" escaped quote
  11402. // \\" escaped backslash, unescaped quote
  11403. // \\\" escaped backslash, escaped quote
  11404. // (etc)
  11405. return (backslashCount % 2 == 0);
  11406. });
  11407. if (quoteLocations.length % 2 == 1) {
  11408. quoteLocations.push(stacktraceLine.length);
  11409. }
  11410. for (var i = quoteLocations.length - 1; i > 0; i -= 2) {
  11411. stacktraceLine = stacktraceLine.substr(0, quoteLocations[i - 1] + 1) +
  11412. g.errorCatcher.redactString(stacktraceLine.substring(quoteLocations[i - 1] + 1, quoteLocations[i])) +
  11413. stacktraceLine.substr(quoteLocations[i]);
  11414. }
  11415. return stacktraceLine;
  11416. }).join('\n');
  11417. };
  11418. /**
  11419. * Redacts a string for user privacy.
  11420. * @param {string} str The string to redact.
  11421. * @return {string} The redacted string.
  11422. */
  11423. g.errorCatcher.redactString = function(str) {
  11424. return '[string redacted]';
  11425. // This commented out alternative attempts to at least make certain types of string (HTML, for example) maintain a
  11426. // recognizable pattern.
  11427. // return g.errorCatcher.shortenString(str.replace(/[a-z]/g, 'x').replace(/[A-Z]/g, 'X').replace(/[0-9]/g, '#').replace(
  11428. // /[^\\\s\[\]<>xX\"\'\(\)\.\,\?\!\#\=\:\;\&\|\@\_\-]/g, '*'), 150).replace(/\r/g, '').replace(/\n/g, '\\n');
  11429. };
  11430. // g.errorCatcher can cause problems with debuggers (it breaks the Firebug console, for example), so it should be
  11431. // disabled in development environments. This if statements g.errorCatcher if you're using
  11432. if (!/dev/.test(window.location.host)) {
  11433. g.errorCatcher(function(errorObj) {
  11434. var key = '27461631-f992-4f72-b94d-b98996ef1a53';
  11435. var host = 'https://logs.loggly.com';
  11436. castor = new loggly({url: host+'/inputs/'+key+'?rt=1', level: 'log'});
  11437. castor.error(JSON.stringify({host: window.location.host, error: errorObj}));
  11438. }, function(str) {
  11439. // this is the URL redaction function. this one just removes ?q= paramter values, but you should adapt this to your own application if needed.
  11440. return str.replace(/([\#\?\&][Qq]\=)[^\=\&\#\s]*/g, '$1[redacted]');
  11441. });
  11442. }
  11443. /*
  11444. * Copyright 2010 Matthew Eernisse (mde@fleegix.org)
  11445. * and Open Source Applications Foundation
  11446. *
  11447. * Licensed under the Apache License, Version 2.0 (the "License");
  11448. * you may not use this file except in compliance with the License.
  11449. * You may obtain a copy of the License at
  11450. *
  11451. * http://www.apache.org/licenses/LICENSE-2.0
  11452. *
  11453. * Unless required by applicable law or agreed to in writing, software
  11454. * distributed under the License is distributed on an "AS IS" BASIS,
  11455. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11456. * See the License for the specific language governing permissions and
  11457. * limitations under the License.
  11458. *
  11459. * Credits: Ideas included from incomplete JS implementation of Olson
  11460. * parser, "XMLDAte" by Philippe Goetz (philippe.goetz@wanadoo.fr)
  11461. *
  11462. * Contributions:
  11463. * Jan Niehusmann
  11464. * Ricky Romero
  11465. * Preston Hunt (prestonhunt@gmail.com),
  11466. * Dov. B Katz (dov.katz@morganstanley.com),
  11467. * Peter Bergström (pbergstr@mac.com)
  11468. */
  11469. if (typeof timezoneJS == 'undefined') { timezoneJS = {}; }
  11470. timezoneJS.Date = function () {
  11471. var args = Array.prototype.slice.apply(arguments);
  11472. var t = null;
  11473. var dt = null;
  11474. var tz = null;
  11475. var utc = false;
  11476. // No args -- create a floating date based on the current local offset
  11477. if (args.length === 0) {
  11478. dt = new Date();
  11479. }
  11480. // Date string or timestamp -- assumes floating
  11481. else if (args.length == 1) {
  11482. dt = new Date(args[0]);
  11483. }
  11484. // year, month, [date,] [hours,] [minutes,] [seconds,] [milliseconds,] [tzId,] [utc]
  11485. else {
  11486. t = args[args.length-1];
  11487. // Last arg is utc
  11488. if (typeof t == 'boolean') {
  11489. utc = args.pop();
  11490. tz = args.pop();
  11491. }
  11492. // Last arg is tzId
  11493. else if (typeof t == 'string') {
  11494. tz = args.pop();
  11495. if (tz == 'Etc/UTC' || tz == 'Etc/GMT') {
  11496. utc = true;
  11497. }
  11498. }
  11499. // Date string (e.g., '12/27/2006')
  11500. t = args[args.length-1];
  11501. if (typeof t == 'string') {
  11502. dt = new Date(args[0]);
  11503. }
  11504. // Date part numbers
  11505. else {
  11506. var a = [];
  11507. for (var i = 0; i < 8; i++) {
  11508. a[i] = args[i] || 0;
  11509. }
  11510. dt = new Date(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7]);
  11511. }
  11512. }
  11513. this._useCache = false;
  11514. this._tzInfo = {};
  11515. this._tzAbbr = '';
  11516. this._day = 0;
  11517. this.year = 0;
  11518. this.month = 0;
  11519. this.date = 0;
  11520. this.hours= 0;
  11521. this.minutes = 0;
  11522. this.seconds = 0;
  11523. this.milliseconds = 0;
  11524. this.timezone = tz || null;
  11525. this.utc = utc || false;
  11526. this.setFromDateObjProxy(dt);
  11527. };
  11528. timezoneJS.Date.prototype = {
  11529. getDate: function () { return this.date; },
  11530. getDay: function () { return this._day; },
  11531. getFullYear: function () { return this.year; },
  11532. getMonth: function () { return this.month; },
  11533. getYear: function () { return this.year; },
  11534. getHours: function () {
  11535. return this.hours;
  11536. },
  11537. getMilliseconds: function () {
  11538. return this.milliseconds;
  11539. },
  11540. getMinutes: function () {
  11541. return this.minutes;
  11542. },
  11543. getSeconds: function () {
  11544. return this.seconds;
  11545. },
  11546. getTime: function () {
  11547. var dt = Date.UTC(this.year, this.month, this.date,
  11548. this.hours, this.minutes, this.seconds, this.milliseconds);
  11549. return dt + (this.getTimezoneOffset()*60*1000);
  11550. },
  11551. getTimezone: function () {
  11552. return this.timezone;
  11553. },
  11554. getTimezoneOffset: function () {
  11555. var info = this.getTimezoneInfo();
  11556. return info.tzOffset;
  11557. },
  11558. getTimezoneAbbreviation: function () {
  11559. var info = this.getTimezoneInfo();
  11560. return info.tzAbbr;
  11561. },
  11562. getTimezoneInfo: function () {
  11563. var res;
  11564. if (this.utc) {
  11565. res = { tzOffset: 0,
  11566. tzAbbr: 'UTC' };
  11567. }
  11568. else {
  11569. if (this._useCache) {
  11570. res = this._tzInfo;
  11571. }
  11572. else {
  11573. if (this.timezone) {
  11574. var dt = new Date(Date.UTC(this.year, this.month, this.date,
  11575. this.hours, this.minutes, this.seconds, this.milliseconds));
  11576. var tz = this.timezone;
  11577. res = timezoneJS.timezone.getTzInfo(dt, tz);
  11578. }
  11579. // Floating -- use local offset
  11580. else {
  11581. res = { tzOffset: this.getLocalOffset(),
  11582. tzAbbr: null };
  11583. }
  11584. this._tzInfo = res;
  11585. this._useCache = true;
  11586. }
  11587. }
  11588. return res;
  11589. },
  11590. getUTCDate: function () {
  11591. return this.getUTCDateProxy().getUTCDate();
  11592. },
  11593. getUTCDay: function () {
  11594. return this.getUTCDateProxy().getUTCDay();
  11595. },
  11596. getUTCFullYear: function () {
  11597. return this.getUTCDateProxy().getUTCFullYear();
  11598. },
  11599. getUTCHours: function () {
  11600. return this.getUTCDateProxy().getUTCHours();
  11601. },
  11602. getUTCMilliseconds: function () {
  11603. return this.getUTCDateProxy().getUTCMilliseconds();
  11604. },
  11605. getUTCMinutes: function () {
  11606. return this.getUTCDateProxy().getUTCMinutes();
  11607. },
  11608. getUTCMonth: function () {
  11609. return this.getUTCDateProxy().getUTCMonth();
  11610. },
  11611. getUTCSeconds: function () {
  11612. return this.getUTCDateProxy().getUTCSeconds();
  11613. },
  11614. setDate: function (n) {
  11615. this.setAttribute('date', n);
  11616. },
  11617. setFullYear: function (n) {
  11618. this.setAttribute('year', n);
  11619. },
  11620. setMonth: function (n) {
  11621. this.setAttribute('month', n);
  11622. },
  11623. setYear: function (n) {
  11624. this.setUTCAttribute('year', n);
  11625. },
  11626. setHours: function (n) {
  11627. this.setAttribute('hours', n);
  11628. },
  11629. setMilliseconds: function (n) {
  11630. this.setAttribute('milliseconds', n);
  11631. },
  11632. setMinutes: function (n) {
  11633. this.setAttribute('minutes', n);
  11634. },
  11635. setSeconds: function (n) {
  11636. this.setAttribute('seconds', n);
  11637. },
  11638. setTime: function (n) {
  11639. if (isNaN(n)) { throw new Error('Units must be a number.'); }
  11640. var dt = new Date(0);
  11641. dt.setUTCMilliseconds(n - (this.getTimezoneOffset()*60*1000));
  11642. this.setFromDateObjProxy(dt, true);
  11643. },
  11644. setUTCDate: function (n) {
  11645. this.setUTCAttribute('date', n);
  11646. },
  11647. setUTCFullYear: function (n) {
  11648. this.setUTCAttribute('year', n);
  11649. },
  11650. setUTCHours: function (n) {
  11651. this.setUTCAttribute('hours', n);
  11652. },
  11653. setUTCMilliseconds: function (n) {
  11654. this.setUTCAttribute('milliseconds', n);
  11655. },
  11656. setUTCMinutes: function (n) {
  11657. this.setUTCAttribute('minutes', n);
  11658. },
  11659. setUTCMonth: function (n) {
  11660. this.setUTCAttribute('month', n);
  11661. },
  11662. setUTCSeconds: function (n) {
  11663. this.setUTCAttribute('seconds', n);
  11664. },
  11665. toGMTString: function () {},
  11666. toLocaleString: function () {},
  11667. toLocaleDateString: function () {},
  11668. toLocaleTimeString: function () {},
  11669. toSource: function () {},
  11670. toString: function () {
  11671. // Get a quick looky at what's in there
  11672. var str = this.getFullYear() + '-' + (this.getMonth()+1) + '-' + this.getDate();
  11673. var hou = this.getHours() || 12;
  11674. hou = String(hou);
  11675. var min = String(this.getMinutes());
  11676. if (min.length == 1) { min = '0' + min; }
  11677. var sec = String(this.getSeconds());
  11678. if (sec.length == 1) { sec = '0' + sec; }
  11679. str += ' ' + hou;
  11680. str += ':' + min;
  11681. str += ':' + sec;
  11682. return str;
  11683. },
  11684. toUTCString: function () {},
  11685. valueOf: function () {
  11686. return this.getTime();
  11687. },
  11688. clone: function () {
  11689. return new timezoneJS.Date(this.year, this.month, this.date,
  11690. this.hours, this.minutes, this.seconds, this.milliseconds,
  11691. this.timezone);
  11692. },
  11693. setFromDateObjProxy: function (dt, fromUTC) {
  11694. this.year = fromUTC ? dt.getUTCFullYear() : dt.getFullYear();
  11695. this.month = fromUTC ? dt.getUTCMonth() : dt.getMonth();
  11696. this.date = fromUTC ? dt.getUTCDate() : dt.getDate();
  11697. this.hours = fromUTC ? dt.getUTCHours() : dt.getHours();
  11698. this.minutes = fromUTC ? dt.getUTCMinutes() : dt.getMinutes();
  11699. this.seconds = fromUTC ? dt.getUTCSeconds() : dt.getSeconds();
  11700. this.milliseconds = fromUTC ? dt.getUTCMilliseconds() : dt.getMilliseconds();
  11701. this._day = fromUTC ? dt.getUTCDay() : dt.getDay();
  11702. this._useCache = false;
  11703. },
  11704. getUTCDateProxy: function () {
  11705. var dt = new Date(Date.UTC(this.year, this.month, this.date,
  11706. this.hours, this.minutes, this.seconds, this.milliseconds));
  11707. dt.setUTCMinutes(dt.getUTCMinutes() + this.getTimezoneOffset());
  11708. return dt;
  11709. },
  11710. setAttribute: function (unit, n) {
  11711. if (isNaN(n)) { throw new Error('Units must be a number.'); }
  11712. var dt = new Date(this.year, this.month, this.date,
  11713. this.hours, this.minutes, this.seconds, this.milliseconds);
  11714. var meth = unit == 'year' ? 'FullYear' : unit.substr(0, 1).toUpperCase() +
  11715. unit.substr(1);
  11716. dt['set' + meth](n);
  11717. this.setFromDateObjProxy(dt);
  11718. },
  11719. setUTCAttribute: function (unit, n) {
  11720. if (isNaN(n)) { throw new Error('Units must be a number.'); }
  11721. var meth = unit == 'year' ? 'FullYear' : unit.substr(0, 1).toUpperCase() +
  11722. unit.substr(1);
  11723. var dt = this.getUTCDateProxy();
  11724. dt['setUTC' + meth](n);
  11725. dt.setUTCMinutes(dt.getUTCMinutes() - this.getTimezoneOffset());
  11726. this.setFromDateObjProxy(dt, true);
  11727. },
  11728. setTimezone: function (tz) {
  11729. if (tz == 'Etc/UTC' || tz == 'Etc/GMT') {
  11730. this.utc = true;
  11731. } else {
  11732. this.utc = false;
  11733. }
  11734. this.timezone = tz;
  11735. this._useCache = false;
  11736. },
  11737. removeTimezone: function () {
  11738. this.utc = false;
  11739. this.timezone = null;
  11740. this._useCache = false;
  11741. },
  11742. civilToJulianDayNumber: function (y, m, d) {
  11743. var a;
  11744. // Adjust for zero-based JS-style array
  11745. m++;
  11746. if (m > 12) {
  11747. a = parseInt(m/12, 10);
  11748. m = m % 12;
  11749. y += a;
  11750. }
  11751. if (m <= 2) {
  11752. y -= 1;
  11753. m += 12;
  11754. }
  11755. a = Math.floor(y / 100);
  11756. var b = 2 - a + Math.floor(a / 4);
  11757. jDt = Math.floor(365.25 * (y + 4716)) +
  11758. Math.floor(30.6001 * (m + 1)) +
  11759. d + b - 1524;
  11760. return jDt;
  11761. },
  11762. getLocalOffset: function () {
  11763. var dt = this;
  11764. var d = new Date(dt.getYear(), dt.getMonth(), dt.getDate(),
  11765. dt.getHours(), dt.getMinutes(), dt.getSeconds());
  11766. return d.getTimezoneOffset();
  11767. },
  11768. convertToTimezone: function(tz) {
  11769. var dt = new Date();
  11770. res = timezoneJS.timezone.getTzInfo(dt, tz);
  11771. convert_offset = this.getTimezoneOffset() - res.tzOffset // offset in minutes
  11772. converted_date = new timezoneJS.Date(this + convert_offset*60*1000)
  11773. this.setFromDateObjProxy(converted_date, true)
  11774. this.setTimezone(tz)
  11775. }
  11776. };
  11777. timezoneJS.timezone = new function() {
  11778. var _this = this;
  11779. var monthMap = { 'jan': 0, 'feb': 1, 'mar': 2, 'apr': 3,'may': 4, 'jun': 5, 'jul': 6, 'aug': 7, 'sep': 8, 'oct': 9, 'nov': 10, 'dec': 11 };
  11780. var dayMap = {'sun': 0,'mon' :1, 'tue': 2, 'wed': 3, 'thu': 4, 'fri': 5, 'sat': 6 };
  11781. var regionMap = {'EST':'northamerica','MST':'northamerica','HST':'northamerica','EST5EDT':'northamerica','CST6CDT':'northamerica','MST7MDT':'northamerica','PST8PDT':'northamerica','America':'northamerica','Pacific':'australasia','Atlantic':'europe','Africa':'africa','Indian':'africa','Antarctica':'antarctica','Asia':'asia','Australia':'australasia','Europe':'europe','WET':'europe','CET':'europe','MET':'europe','EET':'europe'};
  11782. var regionExceptions = {'Pacific/Honolulu':'northamerica','Atlantic/Bermuda':'northamerica','Atlantic/Cape_Verde':'africa','Atlantic/St_Helena':'africa','Indian/Kerguelen':'antarctica','Indian/Chagos':'asia','Indian/Maldives':'asia','Indian/Christmas':'australasia','Indian/Cocos':'australasia','America/Danmarkshavn':'europe','America/Scoresbysund':'europe','America/Godthab':'europe','America/Thule':'europe','Asia/Yekaterinburg':'europe','Asia/Omsk':'europe','Asia/Novosibirsk':'europe','Asia/Krasnoyarsk':'europe','Asia/Irkutsk':'europe','Asia/Yakutsk':'europe','Asia/Vladivostok':'europe','Asia/Sakhalin':'europe','Asia/Magadan':'europe','Asia/Kamchatka':'europe','Asia/Anadyr':'europe','Africa/Ceuta':'europe','America/Argentina/Buenos_Aires':'southamerica','America/Argentina/Cordoba':'southamerica','America/Argentina/Tucuman':'southamerica','America/Argentina/La_Rioja':'southamerica','America/Argentina/San_Juan':'southamerica','America/Argentina/Jujuy':'southamerica','America/Argentina/Catamarca':'southamerica','America/Argentina/Mendoza':'southamerica','America/Argentina/Rio_Gallegos':'southamerica','America/Argentina/Ushuaia':'southamerica','America/Aruba':'southamerica','America/La_Paz':'southamerica','America/Noronha':'southamerica','America/Belem':'southamerica','America/Fortaleza':'southamerica','America/Recife':'southamerica','America/Araguaina':'southamerica','America/Maceio':'southamerica','America/Bahia':'southamerica','America/Sao_Paulo':'southamerica','America/Campo_Grande':'southamerica','America/Cuiaba':'southamerica','America/Porto_Velho':'southamerica','America/Boa_Vista':'southamerica','America/Manaus':'southamerica','America/Eirunepe':'southamerica','America/Rio_Branco':'southamerica','America/Santiago':'southamerica','Pacific/Easter':'southamerica','America/Bogota':'southamerica','America/Curacao':'southamerica','America/Guayaquil':'southamerica','Pacific/Galapagos':'southamerica','Atlantic/Stanley':'southamerica','America/Cayenne':'southamerica','America/Guyana':'southamerica','America/Asuncion':'southamerica','America/Lima':'southamerica','Atlantic/South_Georgia':'southamerica','America/Paramaribo':'southamerica','America/Port_of_Spain':'southamerica','America/Montevideo':'southamerica','America/Caracas':'southamerica'};
  11783. function invalidTZError(t) {
  11784. throw new Error('Timezone "' + t + '" is either incorrect, or not loaded in the timezone registry.');
  11785. }
  11786. function getRegionForTimezone(tz) {
  11787. var exc = regionExceptions[tz];
  11788. var ret;
  11789. if (exc) {
  11790. return exc;
  11791. }
  11792. else {
  11793. reg = tz.split('/')[0];
  11794. ret = regionMap[reg];
  11795. // If there's nothing listed in the main regions for
  11796. // this TZ, check the 'backward' links
  11797. if (!ret) {
  11798. var link = _this.zones[tz];
  11799. if (typeof link == 'string') {
  11800. return getRegionForTimezone(link);
  11801. }
  11802. }
  11803. return ret;
  11804. }
  11805. }
  11806. function parseTimeString(str) {
  11807. var pat = /(\d+)(?::0*(\d*))?(?::0*(\d*))?([wsugz])?$/;
  11808. var hms = str.match(pat);
  11809. hms[1] = parseInt(hms[1], 10);
  11810. hms[2] = hms[2] ? parseInt(hms[2], 10) : 0;
  11811. hms[3] = hms[3] ? parseInt(hms[3], 10) : 0;
  11812. return hms;
  11813. }
  11814. function getZone(dt, tz) {
  11815. var t = tz;
  11816. var zoneList = _this.zones[t];
  11817. // Follow links to get to an acutal zone
  11818. while (typeof zoneList == "string") {
  11819. t = zoneList;
  11820. zoneList = _this.zones[t];
  11821. }
  11822. for(var i = 0; i < zoneList.length; i++) {
  11823. var z = zoneList[i];
  11824. if (!z[3]) { break; }
  11825. var yea = parseInt(z[3], 10);
  11826. var mon = 11;
  11827. var dat = 31;
  11828. if (z[4]) {
  11829. mon = monthMap[z[4].substr(0, 3).toLowerCase()];
  11830. dat = parseInt(z[5], 10);
  11831. }
  11832. var t = z[6] ? z[6] : '23:59:59';
  11833. t = parseTimeString(t);
  11834. var d = Date.UTC(yea, mon, dat, t[1], t[2], t[3]);
  11835. if (dt.getTime() < d) { break; }
  11836. }
  11837. if (i == zoneList.length) { throw new Error('No Zone found for "' + timezone + '" on ' + dt); }
  11838. return zoneList[i];
  11839. }
  11840. function getBasicOffset(z) {
  11841. var off = parseTimeString(z[0]);
  11842. var adj = z[0].indexOf('-') == 0 ? -1 : 1
  11843. off = adj * (((off[1] * 60 + off[2]) *60 + off[3]) * 1000);
  11844. return -off/60/1000;
  11845. }
  11846. // if isUTC is true, date is given in UTC, otherwise it's given
  11847. // in local time (ie. date.getUTC*() returns local time components)
  11848. function getRule( date, zone, isUTC ) {
  11849. var ruleset = zone[1];
  11850. var basicOffset = getBasicOffset( zone );
  11851. // Convert a date to UTC. Depending on the 'type' parameter, the date
  11852. // parameter may be:
  11853. // 'u', 'g', 'z': already UTC (no adjustment)
  11854. // 's': standard time (adjust for time zone offset but not for DST)
  11855. // 'w': wall clock time (adjust for both time zone and DST offset)
  11856. //
  11857. // DST adjustment is done using the rule given as third argument
  11858. var convertDateToUTC = function( date, type, rule ) {
  11859. var offset = 0;
  11860. if(type == 'u' || type == 'g' || type == 'z') { // UTC
  11861. offset = 0;
  11862. } else if(type == 's') { // Standard Time
  11863. offset = basicOffset;
  11864. } else if(type == 'w' || !type ) { // Wall Clock Time
  11865. offset = getAdjustedOffset(basicOffset,rule);
  11866. } else {
  11867. throw("unknown type "+type);
  11868. }
  11869. offset *= 60*1000; // to millis
  11870. return new Date( date.getTime() + offset );
  11871. }
  11872. // Step 1: Find applicable rules for this year.
  11873. // Step 2: Sort the rules by effective date.
  11874. // Step 3: Check requested date to see if a rule has yet taken effect this year. If not,
  11875. // Step 4: Get the rules for the previous year. If there isn't an applicable rule for last year, then
  11876. // there probably is no current time offset since they seem to explicitly turn off the offset
  11877. // when someone stops observing DST.
  11878. // FIXME if this is not the case and we'll walk all the way back (ugh).
  11879. // Step 5: Sort the rules by effective date.
  11880. // Step 6: Apply the most recent rule before the current time.
  11881. var convertRuleToExactDateAndTime = function( yearAndRule, prevRule )
  11882. {
  11883. var year = yearAndRule[0];
  11884. var rule = yearAndRule[1];
  11885. // Assume that the rule applies to the year of the given date.
  11886. var months = {
  11887. "Jan": 0, "Feb": 1, "Mar": 2, "Apr": 3, "May": 4, "Jun": 5,
  11888. "Jul": 6, "Aug": 7, "Sep": 8, "Oct": 9, "Nov": 10, "Dec": 11
  11889. };
  11890. var days = {
  11891. "sun": 0, "mon": 1, "tue": 2, "wed": 3, "thu": 4, "fri": 5, "sat": 6
  11892. }
  11893. var hms = parseTimeString( rule[ 5 ] );
  11894. var effectiveDate;
  11895. if ( !isNaN( rule[ 4 ] ) ) // If we have a specific date, use that!
  11896. {
  11897. effectiveDate = new Date( Date.UTC( year, months[ rule[ 3 ] ], rule[ 4 ], hms[ 1 ], hms[ 2 ], hms[ 3 ], 0 ) );
  11898. }
  11899. else // Let's hunt for the date.
  11900. {
  11901. var targetDay,
  11902. operator;
  11903. if ( rule[ 4 ].substr( 0, 4 ) === "last" ) // Example: lastThu
  11904. {
  11905. // Start at the last day of the month and work backward.
  11906. effectiveDate = new Date( Date.UTC( year, months[ rule[ 3 ] ] + 1, 1, hms[ 1 ] - 24, hms[ 2 ], hms[ 3 ], 0 ) );
  11907. targetDay = days[ rule[ 4 ].substr( 4, 3 ).toLowerCase( ) ];
  11908. operator = "<=";
  11909. }
  11910. else // Example: Sun>=15
  11911. {
  11912. // Start at the specified date.
  11913. effectiveDate = new Date( Date.UTC( year, months[ rule[ 3 ] ], rule[ 4 ].substr( 5 ), hms[ 1 ], hms[ 2 ], hms[ 3 ], 0 ) );
  11914. targetDay = days[ rule[ 4 ].substr( 0, 3 ).toLowerCase( ) ];
  11915. operator = rule[ 4 ].substr( 3, 2 );
  11916. }
  11917. var ourDay = effectiveDate.getUTCDay( );
  11918. if ( operator === ">=" ) // Go forwards.
  11919. {
  11920. effectiveDate.setUTCDate( effectiveDate.getUTCDate( ) + ( targetDay - ourDay + ( ( targetDay < ourDay ) ? 7 : 0 ) ) );
  11921. }
  11922. else // Go backwards. Looking for the last of a certain day, or operator is "<=" (less likely).
  11923. {
  11924. effectiveDate.setUTCDate( effectiveDate.getUTCDate( ) + ( targetDay - ourDay - ( ( targetDay > ourDay ) ? 7 : 0 ) ) );
  11925. }
  11926. }
  11927. // if previous rule is given, correct for the fact that the starting time of the current
  11928. // rule may be specified in local time
  11929. if(prevRule) {
  11930. effectiveDate = convertDateToUTC(effectiveDate, hms[4], prevRule);
  11931. }
  11932. return effectiveDate;
  11933. }
  11934. var findApplicableRules = function( year, ruleset )
  11935. {
  11936. var applicableRules = [];
  11937. for ( var i in ruleset )
  11938. {