amazeui.ie8polyfill.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293
  1. /*! Amaze UI v2.5.2 ~ IE8 Fucker | by Amaze UI Team | (c) 2016 AllMobilize, Inc. | Licensed under MIT | 2016-01-26T11:06:52+0800 */
  2. // Console-polyfill. MIT license.
  3. // https://github.com/paulmillr/console-polyfill
  4. // Make it safe to do console.log() always.
  5. (function(global) {
  6. 'use strict';
  7. global.console = global.console || {};
  8. var con = global.console;
  9. var prop, method;
  10. var empty = {};
  11. var dummy = function() {};
  12. var properties = 'memory'.split(',');
  13. var methods = ('assert,clear,count,debug,dir,dirxml,error,exception,group,' +
  14. 'groupCollapsed,groupEnd,info,log,markTimeline,profile,profiles,profileEnd,' +
  15. 'show,table,time,timeEnd,timeline,timelineEnd,timeStamp,trace,warn').split(',');
  16. while (prop = properties.pop()) if (!con[prop]) con[prop] = empty;
  17. while (method = methods.pop()) if (!con[method]) con[method] = dummy;
  18. })(typeof window === 'undefined' ? this : window);
  19. // Using `this` for web workers while maintaining compatibility with browser
  20. // targeted script loaders such as Browserify or Webpack where the only way to
  21. // get to the global object is via `window`.
  22. /*!
  23. * https://github.com/es-shims/es5-shim
  24. * @license es5-shim Copyright 2009-2015 by contributors, MIT License
  25. * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
  26. */
  27. // vim: ts=4 sts=4 sw=4 expandtab
  28. // Add semicolon to prevent IIFE from being passed as argument to concatenated code.
  29. ;
  30. // UMD (Universal Module Definition)
  31. // see https://github.com/umdjs/umd/blob/master/returnExports.js
  32. (function (root, factory) {
  33. 'use strict';
  34. /* global define, exports, module */
  35. if (typeof define === 'function' && define.amd) {
  36. // AMD. Register as an anonymous module.
  37. define(factory);
  38. } else if (typeof exports === 'object') {
  39. // Node. Does not work with strict CommonJS, but
  40. // only CommonJS-like enviroments that support module.exports,
  41. // like Node.
  42. module.exports = factory();
  43. } else {
  44. // Browser globals (root is window)
  45. root.returnExports = factory();
  46. }
  47. }(this, function () {
  48. var call = Function.prototype.call;
  49. var prototypeOfObject = Object.prototype;
  50. var owns = call.bind(prototypeOfObject.hasOwnProperty);
  51. // If JS engine supports accessors creating shortcuts.
  52. var defineGetter;
  53. var defineSetter;
  54. var lookupGetter;
  55. var lookupSetter;
  56. var supportsAccessors = owns(prototypeOfObject, '__defineGetter__');
  57. if (supportsAccessors) {
  58. /* eslint-disable no-underscore-dangle */
  59. defineGetter = call.bind(prototypeOfObject.__defineGetter__);
  60. defineSetter = call.bind(prototypeOfObject.__defineSetter__);
  61. lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
  62. lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
  63. /* eslint-enable no-underscore-dangle */
  64. }
  65. // ES5 15.2.3.2
  66. // http://es5.github.com/#x15.2.3.2
  67. if (!Object.getPrototypeOf) {
  68. // https://github.com/es-shims/es5-shim/issues#issue/2
  69. // http://ejohn.org/blog/objectgetprototypeof/
  70. // recommended by fschaefer on github
  71. //
  72. // sure, and webreflection says ^_^
  73. // ... this will nerever possibly return null
  74. // ... Opera Mini breaks here with infinite loops
  75. Object.getPrototypeOf = function getPrototypeOf(object) {
  76. /* eslint-disable no-proto */
  77. var proto = object.__proto__;
  78. /* eslint-enable no-proto */
  79. if (proto || proto === null) {
  80. return proto;
  81. } else if (object.constructor) {
  82. return object.constructor.prototype;
  83. } else {
  84. return prototypeOfObject;
  85. }
  86. };
  87. }
  88. // ES5 15.2.3.3
  89. // http://es5.github.com/#x15.2.3.3
  90. var doesGetOwnPropertyDescriptorWork = function doesGetOwnPropertyDescriptorWork(object) {
  91. try {
  92. object.sentinel = 0;
  93. return Object.getOwnPropertyDescriptor(object, 'sentinel').value === 0;
  94. } catch (exception) {
  95. return false;
  96. }
  97. };
  98. // check whether getOwnPropertyDescriptor works if it's given. Otherwise, shim partially.
  99. if (Object.defineProperty) {
  100. var getOwnPropertyDescriptorWorksOnObject = doesGetOwnPropertyDescriptorWork({});
  101. var getOwnPropertyDescriptorWorksOnDom = typeof document === 'undefined' ||
  102. doesGetOwnPropertyDescriptorWork(document.createElement('div'));
  103. if (!getOwnPropertyDescriptorWorksOnDom || !getOwnPropertyDescriptorWorksOnObject) {
  104. var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
  105. }
  106. }
  107. if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
  108. var ERR_NON_OBJECT = 'Object.getOwnPropertyDescriptor called on a non-object: ';
  109. /* eslint-disable no-proto */
  110. Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
  111. if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
  112. throw new TypeError(ERR_NON_OBJECT + object);
  113. }
  114. // make a valiant attempt to use the real getOwnPropertyDescriptor
  115. // for I8's DOM elements.
  116. if (getOwnPropertyDescriptorFallback) {
  117. try {
  118. return getOwnPropertyDescriptorFallback.call(Object, object, property);
  119. } catch (exception) {
  120. // try the shim if the real one doesn't work
  121. }
  122. }
  123. var descriptor;
  124. // If object does not owns property return undefined immediately.
  125. if (!owns(object, property)) {
  126. return descriptor;
  127. }
  128. // If object has a property then it's for sure both `enumerable` and
  129. // `configurable`.
  130. descriptor = { enumerable: true, configurable: true };
  131. // If JS engine supports accessor properties then property may be a
  132. // getter or setter.
  133. if (supportsAccessors) {
  134. // Unfortunately `__lookupGetter__` will return a getter even
  135. // if object has own non getter property along with a same named
  136. // inherited getter. To avoid misbehavior we temporary remove
  137. // `__proto__` so that `__lookupGetter__` will return getter only
  138. // if it's owned by an object.
  139. var prototype = object.__proto__;
  140. var notPrototypeOfObject = object !== prototypeOfObject;
  141. // avoid recursion problem, breaking in Opera Mini when
  142. // Object.getOwnPropertyDescriptor(Object.prototype, 'toString')
  143. // or any other Object.prototype accessor
  144. if (notPrototypeOfObject) {
  145. object.__proto__ = prototypeOfObject;
  146. }
  147. var getter = lookupGetter(object, property);
  148. var setter = lookupSetter(object, property);
  149. if (notPrototypeOfObject) {
  150. // Once we have getter and setter we can put values back.
  151. object.__proto__ = prototype;
  152. }
  153. if (getter || setter) {
  154. if (getter) {
  155. descriptor.get = getter;
  156. }
  157. if (setter) {
  158. descriptor.set = setter;
  159. }
  160. // If it was accessor property we're done and return here
  161. // in order to avoid adding `value` to the descriptor.
  162. return descriptor;
  163. }
  164. }
  165. // If we got this far we know that object has an own property that is
  166. // not an accessor so we set it as a value and return descriptor.
  167. descriptor.value = object[property];
  168. descriptor.writable = true;
  169. return descriptor;
  170. };
  171. /* eslint-enable no-proto */
  172. }
  173. // ES5 15.2.3.4
  174. // http://es5.github.com/#x15.2.3.4
  175. if (!Object.getOwnPropertyNames) {
  176. Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
  177. return Object.keys(object);
  178. };
  179. }
  180. // ES5 15.2.3.5
  181. // http://es5.github.com/#x15.2.3.5
  182. if (!Object.create) {
  183. // Contributed by Brandon Benvie, October, 2012
  184. var createEmpty;
  185. var supportsProto = !({ __proto__: null } instanceof Object);
  186. // the following produces false positives
  187. // in Opera Mini => not a reliable check
  188. // Object.prototype.__proto__ === null
  189. // Check for document.domain and active x support
  190. // No need to use active x approach when document.domain is not set
  191. // see https://github.com/es-shims/es5-shim/issues/150
  192. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  193. /* global ActiveXObject */
  194. var shouldUseActiveX = function shouldUseActiveX() {
  195. // return early if document.domain not set
  196. if (!document.domain) {
  197. return false;
  198. }
  199. try {
  200. return !!new ActiveXObject('htmlfile');
  201. } catch (exception) {
  202. return false;
  203. }
  204. };
  205. // This supports IE8 when document.domain is used
  206. // see https://github.com/es-shims/es5-shim/issues/150
  207. // variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346
  208. var getEmptyViaActiveX = function getEmptyViaActiveX() {
  209. var empty;
  210. var xDoc;
  211. xDoc = new ActiveXObject('htmlfile');
  212. xDoc.write('<script><\/script>');
  213. xDoc.close();
  214. empty = xDoc.parentWindow.Object.prototype;
  215. xDoc = null;
  216. return empty;
  217. };
  218. // The original implementation using an iframe
  219. // before the activex approach was added
  220. // see https://github.com/es-shims/es5-shim/issues/150
  221. var getEmptyViaIFrame = function getEmptyViaIFrame() {
  222. var iframe = document.createElement('iframe');
  223. var parent = document.body || document.documentElement;
  224. var empty;
  225. iframe.style.display = 'none';
  226. parent.appendChild(iframe);
  227. /* eslint-disable no-script-url */
  228. iframe.src = 'javascript:';
  229. /* eslint-enable no-script-url */
  230. empty = iframe.contentWindow.Object.prototype;
  231. parent.removeChild(iframe);
  232. iframe = null;
  233. return empty;
  234. };
  235. /* global document */
  236. if (supportsProto || typeof document === 'undefined') {
  237. createEmpty = function () {
  238. return { __proto__: null };
  239. };
  240. } else {
  241. // In old IE __proto__ can't be used to manually set `null`, nor does
  242. // any other method exist to make an object that inherits from nothing,
  243. // aside from Object.prototype itself. Instead, create a new global
  244. // object and *steal* its Object.prototype and strip it bare. This is
  245. // used as the prototype to create nullary objects.
  246. createEmpty = function () {
  247. // Determine which approach to use
  248. // see https://github.com/es-shims/es5-shim/issues/150
  249. var empty = shouldUseActiveX() ? getEmptyViaActiveX() : getEmptyViaIFrame();
  250. delete empty.constructor;
  251. delete empty.hasOwnProperty;
  252. delete empty.propertyIsEnumerable;
  253. delete empty.isPrototypeOf;
  254. delete empty.toLocaleString;
  255. delete empty.toString;
  256. delete empty.valueOf;
  257. /* eslint-disable no-proto */
  258. empty.__proto__ = null;
  259. /* eslint-enable no-proto */
  260. var Empty = function Empty() {};
  261. Empty.prototype = empty;
  262. // short-circuit future calls
  263. createEmpty = function () {
  264. return new Empty();
  265. };
  266. return new Empty();
  267. };
  268. }
  269. Object.create = function create(prototype, properties) {
  270. var object;
  271. var Type = function Type() {}; // An empty constructor.
  272. if (prototype === null) {
  273. object = createEmpty();
  274. } else {
  275. if (typeof prototype !== 'object' && typeof prototype !== 'function') {
  276. // In the native implementation `parent` can be `null`
  277. // OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
  278. // Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
  279. // like they are in modern browsers. Using `Object.create` on DOM elements
  280. // is...err...probably inappropriate, but the native version allows for it.
  281. throw new TypeError('Object prototype may only be an Object or null'); // same msg as Chrome
  282. }
  283. Type.prototype = prototype;
  284. object = new Type();
  285. // IE has no built-in implementation of `Object.getPrototypeOf`
  286. // neither `__proto__`, but this manually setting `__proto__` will
  287. // guarantee that `Object.getPrototypeOf` will work as expected with
  288. // objects created using `Object.create`
  289. /* eslint-disable no-proto */
  290. object.__proto__ = prototype;
  291. /* eslint-enable no-proto */
  292. }
  293. if (properties !== void 0) {
  294. Object.defineProperties(object, properties);
  295. }
  296. return object;
  297. };
  298. }
  299. // ES5 15.2.3.6
  300. // http://es5.github.com/#x15.2.3.6
  301. // Patch for WebKit and IE8 standard mode
  302. // Designed by hax <hax.github.com>
  303. // related issue: https://github.com/es-shims/es5-shim/issues#issue/5
  304. // IE8 Reference:
  305. // http://msdn.microsoft.com/en-us/library/dd282900.aspx
  306. // http://msdn.microsoft.com/en-us/library/dd229916.aspx
  307. // WebKit Bugs:
  308. // https://bugs.webkit.org/show_bug.cgi?id=36423
  309. var doesDefinePropertyWork = function doesDefinePropertyWork(object) {
  310. try {
  311. Object.defineProperty(object, 'sentinel', {});
  312. return 'sentinel' in object;
  313. } catch (exception) {
  314. return false;
  315. }
  316. };
  317. // check whether defineProperty works if it's given. Otherwise,
  318. // shim partially.
  319. if (Object.defineProperty) {
  320. var definePropertyWorksOnObject = doesDefinePropertyWork({});
  321. var definePropertyWorksOnDom = typeof document === 'undefined' ||
  322. doesDefinePropertyWork(document.createElement('div'));
  323. if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
  324. var definePropertyFallback = Object.defineProperty,
  325. definePropertiesFallback = Object.defineProperties;
  326. }
  327. }
  328. if (!Object.defineProperty || definePropertyFallback) {
  329. var ERR_NON_OBJECT_DESCRIPTOR = 'Property description must be an object: ';
  330. var ERR_NON_OBJECT_TARGET = 'Object.defineProperty called on non-object: ';
  331. var ERR_ACCESSORS_NOT_SUPPORTED = 'getters & setters can not be defined on this javascript engine';
  332. Object.defineProperty = function defineProperty(object, property, descriptor) {
  333. if ((typeof object !== 'object' && typeof object !== 'function') || object === null) {
  334. throw new TypeError(ERR_NON_OBJECT_TARGET + object);
  335. }
  336. if ((typeof descriptor !== 'object' && typeof descriptor !== 'function') || descriptor === null) {
  337. throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
  338. }
  339. // make a valiant attempt to use the real defineProperty
  340. // for I8's DOM elements.
  341. if (definePropertyFallback) {
  342. try {
  343. return definePropertyFallback.call(Object, object, property, descriptor);
  344. } catch (exception) {
  345. // try the shim if the real one doesn't work
  346. }
  347. }
  348. // If it's a data property.
  349. if ('value' in descriptor) {
  350. // fail silently if 'writable', 'enumerable', or 'configurable'
  351. // are requested but not supported
  352. /*
  353. // alternate approach:
  354. if ( // can't implement these features; allow false but not true
  355. ('writable' in descriptor && !descriptor.writable) ||
  356. ('enumerable' in descriptor && !descriptor.enumerable) ||
  357. ('configurable' in descriptor && !descriptor.configurable)
  358. ))
  359. throw new RangeError(
  360. 'This implementation of Object.defineProperty does not support configurable, enumerable, or writable.'
  361. );
  362. */
  363. if (supportsAccessors && (lookupGetter(object, property) || lookupSetter(object, property))) {
  364. // As accessors are supported only on engines implementing
  365. // `__proto__` we can safely override `__proto__` while defining
  366. // a property to make sure that we don't hit an inherited
  367. // accessor.
  368. /* eslint-disable no-proto */
  369. var prototype = object.__proto__;
  370. object.__proto__ = prototypeOfObject;
  371. // Deleting a property anyway since getter / setter may be
  372. // defined on object itself.
  373. delete object[property];
  374. object[property] = descriptor.value;
  375. // Setting original `__proto__` back now.
  376. object.__proto__ = prototype;
  377. /* eslint-enable no-proto */
  378. } else {
  379. object[property] = descriptor.value;
  380. }
  381. } else {
  382. if (!supportsAccessors) {
  383. throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
  384. }
  385. // If we got that far then getters and setters can be defined !!
  386. if ('get' in descriptor) {
  387. defineGetter(object, property, descriptor.get);
  388. }
  389. if ('set' in descriptor) {
  390. defineSetter(object, property, descriptor.set);
  391. }
  392. }
  393. return object;
  394. };
  395. }
  396. // ES5 15.2.3.7
  397. // http://es5.github.com/#x15.2.3.7
  398. if (!Object.defineProperties || definePropertiesFallback) {
  399. Object.defineProperties = function defineProperties(object, properties) {
  400. // make a valiant attempt to use the real defineProperties
  401. if (definePropertiesFallback) {
  402. try {
  403. return definePropertiesFallback.call(Object, object, properties);
  404. } catch (exception) {
  405. // try the shim if the real one doesn't work
  406. }
  407. }
  408. Object.keys(properties).forEach(function (property) {
  409. if (property !== '__proto__') {
  410. Object.defineProperty(object, property, properties[property]);
  411. }
  412. });
  413. return object;
  414. };
  415. }
  416. // ES5 15.2.3.8
  417. // http://es5.github.com/#x15.2.3.8
  418. if (!Object.seal) {
  419. Object.seal = function seal(object) {
  420. if (Object(object) !== object) {
  421. throw new TypeError('Object.seal can only be called on Objects.');
  422. }
  423. // this is misleading and breaks feature-detection, but
  424. // allows "securable" code to "gracefully" degrade to working
  425. // but insecure code.
  426. return object;
  427. };
  428. }
  429. // ES5 15.2.3.9
  430. // http://es5.github.com/#x15.2.3.9
  431. if (!Object.freeze) {
  432. Object.freeze = function freeze(object) {
  433. if (Object(object) !== object) {
  434. throw new TypeError('Object.freeze can only be called on Objects.');
  435. }
  436. // this is misleading and breaks feature-detection, but
  437. // allows "securable" code to "gracefully" degrade to working
  438. // but insecure code.
  439. return object;
  440. };
  441. }
  442. // detect a Rhino bug and patch it
  443. try {
  444. Object.freeze(function () {});
  445. } catch (exception) {
  446. Object.freeze = (function (freezeObject) {
  447. return function freeze(object) {
  448. if (typeof object === 'function') {
  449. return object;
  450. } else {
  451. return freezeObject(object);
  452. }
  453. };
  454. }(Object.freeze));
  455. }
  456. // ES5 15.2.3.10
  457. // http://es5.github.com/#x15.2.3.10
  458. if (!Object.preventExtensions) {
  459. Object.preventExtensions = function preventExtensions(object) {
  460. if (Object(object) !== object) {
  461. throw new TypeError('Object.preventExtensions can only be called on Objects.');
  462. }
  463. // this is misleading and breaks feature-detection, but
  464. // allows "securable" code to "gracefully" degrade to working
  465. // but insecure code.
  466. return object;
  467. };
  468. }
  469. // ES5 15.2.3.11
  470. // http://es5.github.com/#x15.2.3.11
  471. if (!Object.isSealed) {
  472. Object.isSealed = function isSealed(object) {
  473. if (Object(object) !== object) {
  474. throw new TypeError('Object.isSealed can only be called on Objects.');
  475. }
  476. return false;
  477. };
  478. }
  479. // ES5 15.2.3.12
  480. // http://es5.github.com/#x15.2.3.12
  481. if (!Object.isFrozen) {
  482. Object.isFrozen = function isFrozen(object) {
  483. if (Object(object) !== object) {
  484. throw new TypeError('Object.isFrozen can only be called on Objects.');
  485. }
  486. return false;
  487. };
  488. }
  489. // ES5 15.2.3.13
  490. // http://es5.github.com/#x15.2.3.13
  491. if (!Object.isExtensible) {
  492. Object.isExtensible = function isExtensible(object) {
  493. // 1. If Type(O) is not Object throw a TypeError exception.
  494. if (Object(object) !== object) {
  495. throw new TypeError('Object.isExtensible can only be called on Objects.');
  496. }
  497. // 2. Return the Boolean value of the [[Extensible]] internal property of O.
  498. var name = '';
  499. while (owns(object, name)) {
  500. name += '?';
  501. }
  502. object[name] = true;
  503. var returnValue = owns(object, name);
  504. delete object[name];
  505. return returnValue;
  506. };
  507. }
  508. }));
  509. /*!
  510. * https://github.com/es-shims/es5-shim
  511. * @license es5-shim Copyright 2009-2015 by contributors, MIT License
  512. * see https://github.com/es-shims/es5-shim/blob/master/LICENSE
  513. */
  514. // vim: ts=4 sts=4 sw=4 expandtab
  515. // Add semicolon to prevent IIFE from being passed as argument to concatenated code.
  516. ;
  517. // UMD (Universal Module Definition)
  518. // see https://github.com/umdjs/umd/blob/master/returnExports.js
  519. (function (root, factory) {
  520. 'use strict';
  521. /* global define, exports, module */
  522. if (typeof define === 'function' && define.amd) {
  523. // AMD. Register as an anonymous module.
  524. define(factory);
  525. } else if (typeof exports === 'object') {
  526. // Node. Does not work with strict CommonJS, but
  527. // only CommonJS-like enviroments that support module.exports,
  528. // like Node.
  529. module.exports = factory();
  530. } else {
  531. // Browser globals (root is window)
  532. root.returnExports = factory();
  533. }
  534. }(this, function () {
  535. /**
  536. * Brings an environment as close to ECMAScript 5 compliance
  537. * as is possible with the facilities of erstwhile engines.
  538. *
  539. * Annotated ES5: http://es5.github.com/ (specific links below)
  540. * ES5 Spec: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
  541. * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
  542. */
  543. // Shortcut to an often accessed properties, in order to avoid multiple
  544. // dereference that costs universally.
  545. var ArrayPrototype = Array.prototype;
  546. var ObjectPrototype = Object.prototype;
  547. var FunctionPrototype = Function.prototype;
  548. var StringPrototype = String.prototype;
  549. var NumberPrototype = Number.prototype;
  550. var array_slice = ArrayPrototype.slice;
  551. var array_splice = ArrayPrototype.splice;
  552. var array_push = ArrayPrototype.push;
  553. var array_unshift = ArrayPrototype.unshift;
  554. var array_concat = ArrayPrototype.concat;
  555. var call = FunctionPrototype.call;
  556. // Having a toString local variable name breaks in Opera so use to_string.
  557. var to_string = ObjectPrototype.toString;
  558. var isArray = Array.isArray || function isArray(obj) {
  559. return to_string.call(obj) === '[object Array]';
  560. };
  561. var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
  562. var isCallable; /* inlined from https://npmjs.com/is-callable */ var fnToStr = Function.prototype.toString, tryFunctionObject = function tryFunctionObject(value) { try { fnToStr.call(value); return true; } catch (e) { return false; } }, fnClass = '[object Function]', genClass = '[object GeneratorFunction]'; isCallable = function isCallable(value) { if (typeof value !== 'function') { return false; } if (hasToStringTag) { return tryFunctionObject(value); } var strClass = to_string.call(value); return strClass === fnClass || strClass === genClass; };
  563. var isRegex; /* inlined from https://npmjs.com/is-regex */ var regexExec = RegExp.prototype.exec, tryRegexExec = function tryRegexExec(value) { try { regexExec.call(value); return true; } catch (e) { return false; } }, regexClass = '[object RegExp]'; isRegex = function isRegex(value) { if (typeof value !== 'object') { return false; } return hasToStringTag ? tryRegexExec(value) : to_string.call(value) === regexClass; };
  564. var isString; /* inlined from https://npmjs.com/is-string */ var strValue = String.prototype.valueOf, tryStringObject = function tryStringObject(value) { try { strValue.call(value); return true; } catch (e) { return false; } }, stringClass = '[object String]'; isString = function isString(value) { if (typeof value === 'string') { return true; } if (typeof value !== 'object') { return false; } return hasToStringTag ? tryStringObject(value) : to_string.call(value) === stringClass; };
  565. var isArguments = function isArguments(value) {
  566. var str = to_string.call(value);
  567. var isArgs = str === '[object Arguments]';
  568. if (!isArgs) {
  569. isArgs = !isArray(value) &&
  570. value !== null &&
  571. typeof value === 'object' &&
  572. typeof value.length === 'number' &&
  573. value.length >= 0 &&
  574. isCallable(value.callee);
  575. }
  576. return isArgs;
  577. };
  578. /* inlined from http://npmjs.com/define-properties */
  579. var defineProperties = (function (has) {
  580. var supportsDescriptors = Object.defineProperty && (function () {
  581. try {
  582. var obj = {};
  583. Object.defineProperty(obj, 'x', { enumerable: false, value: obj });
  584. for (var _ in obj) { return false; }
  585. return obj.x === obj;
  586. } catch (e) { /* this is ES3 */
  587. return false;
  588. }
  589. }());
  590. // Define configurable, writable and non-enumerable props
  591. // if they don't exist.
  592. var defineProperty;
  593. if (supportsDescriptors) {
  594. defineProperty = function (object, name, method, forceAssign) {
  595. if (!forceAssign && (name in object)) { return; }
  596. Object.defineProperty(object, name, {
  597. configurable: true,
  598. enumerable: false,
  599. writable: true,
  600. value: method
  601. });
  602. };
  603. } else {
  604. defineProperty = function (object, name, method, forceAssign) {
  605. if (!forceAssign && (name in object)) { return; }
  606. object[name] = method;
  607. };
  608. }
  609. return function defineProperties(object, map, forceAssign) {
  610. for (var name in map) {
  611. if (has.call(map, name)) {
  612. defineProperty(object, name, map[name], forceAssign);
  613. }
  614. }
  615. };
  616. }(ObjectPrototype.hasOwnProperty));
  617. //
  618. // Util
  619. // ======
  620. //
  621. /* replaceable with https://npmjs.com/package/es-abstract /helpers/isPrimitive */
  622. var isPrimitive = function isPrimitive(input) {
  623. var type = typeof input;
  624. return input === null || (type !== 'object' && type !== 'function');
  625. };
  626. var ES = {
  627. // ES5 9.4
  628. // http://es5.github.com/#x9.4
  629. // http://jsperf.com/to-integer
  630. /* replaceable with https://npmjs.com/package/es-abstract ES5.ToInteger */
  631. ToInteger: function ToInteger(num) {
  632. var n = +num;
  633. if (n !== n) { // isNaN
  634. n = 0;
  635. } else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
  636. n = (n > 0 || -1) * Math.floor(Math.abs(n));
  637. }
  638. return n;
  639. },
  640. /* replaceable with https://npmjs.com/package/es-abstract ES5.ToPrimitive */
  641. ToPrimitive: function ToPrimitive(input) {
  642. var val, valueOf, toStr;
  643. if (isPrimitive(input)) {
  644. return input;
  645. }
  646. valueOf = input.valueOf;
  647. if (isCallable(valueOf)) {
  648. val = valueOf.call(input);
  649. if (isPrimitive(val)) {
  650. return val;
  651. }
  652. }
  653. toStr = input.toString;
  654. if (isCallable(toStr)) {
  655. val = toStr.call(input);
  656. if (isPrimitive(val)) {
  657. return val;
  658. }
  659. }
  660. throw new TypeError();
  661. },
  662. // ES5 9.9
  663. // http://es5.github.com/#x9.9
  664. /* replaceable with https://npmjs.com/package/es-abstract ES5.ToObject */
  665. ToObject: function (o) {
  666. /* jshint eqnull: true */
  667. if (o == null) { // this matches both null and undefined
  668. throw new TypeError("can't convert " + o + ' to object');
  669. }
  670. return Object(o);
  671. },
  672. /* replaceable with https://npmjs.com/package/es-abstract ES5.ToUint32 */
  673. ToUint32: function ToUint32(x) {
  674. return x >>> 0;
  675. }
  676. };
  677. //
  678. // Function
  679. // ========
  680. //
  681. // ES-5 15.3.4.5
  682. // http://es5.github.com/#x15.3.4.5
  683. var Empty = function Empty() {};
  684. defineProperties(FunctionPrototype, {
  685. bind: function bind(that) { // .length is 1
  686. // 1. Let Target be the this value.
  687. var target = this;
  688. // 2. If IsCallable(Target) is false, throw a TypeError exception.
  689. if (!isCallable(target)) {
  690. throw new TypeError('Function.prototype.bind called on incompatible ' + target);
  691. }
  692. // 3. Let A be a new (possibly empty) internal list of all of the
  693. // argument values provided after thisArg (arg1, arg2 etc), in order.
  694. // XXX slicedArgs will stand in for "A" if used
  695. var args = array_slice.call(arguments, 1); // for normal call
  696. // 4. Let F be a new native ECMAScript object.
  697. // 11. Set the [[Prototype]] internal property of F to the standard
  698. // built-in Function prototype object as specified in 15.3.3.1.
  699. // 12. Set the [[Call]] internal property of F as described in
  700. // 15.3.4.5.1.
  701. // 13. Set the [[Construct]] internal property of F as described in
  702. // 15.3.4.5.2.
  703. // 14. Set the [[HasInstance]] internal property of F as described in
  704. // 15.3.4.5.3.
  705. var bound;
  706. var binder = function () {
  707. if (this instanceof bound) {
  708. // 15.3.4.5.2 [[Construct]]
  709. // When the [[Construct]] internal method of a function object,
  710. // F that was created using the bind function is called with a
  711. // list of arguments ExtraArgs, the following steps are taken:
  712. // 1. Let target be the value of F's [[TargetFunction]]
  713. // internal property.
  714. // 2. If target has no [[Construct]] internal method, a
  715. // TypeError exception is thrown.
  716. // 3. Let boundArgs be the value of F's [[BoundArgs]] internal
  717. // property.
  718. // 4. Let args be a new list containing the same values as the
  719. // list boundArgs in the same order followed by the same
  720. // values as the list ExtraArgs in the same order.
  721. // 5. Return the result of calling the [[Construct]] internal
  722. // method of target providing args as the arguments.
  723. var result = target.apply(
  724. this,
  725. array_concat.call(args, array_slice.call(arguments))
  726. );
  727. if (Object(result) === result) {
  728. return result;
  729. }
  730. return this;
  731. } else {
  732. // 15.3.4.5.1 [[Call]]
  733. // When the [[Call]] internal method of a function object, F,
  734. // which was created using the bind function is called with a
  735. // this value and a list of arguments ExtraArgs, the following
  736. // steps are taken:
  737. // 1. Let boundArgs be the value of F's [[BoundArgs]] internal
  738. // property.
  739. // 2. Let boundThis be the value of F's [[BoundThis]] internal
  740. // property.
  741. // 3. Let target be the value of F's [[TargetFunction]] internal
  742. // property.
  743. // 4. Let args be a new list containing the same values as the
  744. // list boundArgs in the same order followed by the same
  745. // values as the list ExtraArgs in the same order.
  746. // 5. Return the result of calling the [[Call]] internal method
  747. // of target providing boundThis as the this value and
  748. // providing args as the arguments.
  749. // equiv: target.call(this, ...boundArgs, ...args)
  750. return target.apply(
  751. that,
  752. array_concat.call(args, array_slice.call(arguments))
  753. );
  754. }
  755. };
  756. // 15. If the [[Class]] internal property of Target is "Function", then
  757. // a. Let L be the length property of Target minus the length of A.
  758. // b. Set the length own property of F to either 0 or L, whichever is
  759. // larger.
  760. // 16. Else set the length own property of F to 0.
  761. var boundLength = Math.max(0, target.length - args.length);
  762. // 17. Set the attributes of the length own property of F to the values
  763. // specified in 15.3.5.1.
  764. var boundArgs = [];
  765. for (var i = 0; i < boundLength; i++) {
  766. boundArgs.push('$' + i);
  767. }
  768. // XXX Build a dynamic function with desired amount of arguments is the only
  769. // way to set the length property of a function.
  770. // In environments where Content Security Policies enabled (Chrome extensions,
  771. // for ex.) all use of eval or Function costructor throws an exception.
  772. // However in all of these environments Function.prototype.bind exists
  773. // and so this code will never be executed.
  774. bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this, arguments); }')(binder);
  775. if (target.prototype) {
  776. Empty.prototype = target.prototype;
  777. bound.prototype = new Empty();
  778. // Clean up dangling references.
  779. Empty.prototype = null;
  780. }
  781. // TODO
  782. // 18. Set the [[Extensible]] internal property of F to true.
  783. // TODO
  784. // 19. Let thrower be the [[ThrowTypeError]] function Object (13.2.3).
  785. // 20. Call the [[DefineOwnProperty]] internal method of F with
  786. // arguments "caller", PropertyDescriptor {[[Get]]: thrower, [[Set]]:
  787. // thrower, [[Enumerable]]: false, [[Configurable]]: false}, and
  788. // false.
  789. // 21. Call the [[DefineOwnProperty]] internal method of F with
  790. // arguments "arguments", PropertyDescriptor {[[Get]]: thrower,
  791. // [[Set]]: thrower, [[Enumerable]]: false, [[Configurable]]: false},
  792. // and false.
  793. // TODO
  794. // NOTE Function objects created using Function.prototype.bind do not
  795. // have a prototype property or the [[Code]], [[FormalParameters]], and
  796. // [[Scope]] internal properties.
  797. // XXX can't delete prototype in pure-js.
  798. // 22. Return F.
  799. return bound;
  800. }
  801. });
  802. // _Please note: Shortcuts are defined after `Function.prototype.bind` as we
  803. // us it in defining shortcuts.
  804. var owns = call.bind(ObjectPrototype.hasOwnProperty);
  805. //
  806. // Array
  807. // =====
  808. //
  809. // ES5 15.4.4.12
  810. // http://es5.github.com/#x15.4.4.12
  811. var spliceNoopReturnsEmptyArray = (function () {
  812. var a = [1, 2];
  813. var result = a.splice();
  814. return a.length === 2 && isArray(result) && result.length === 0;
  815. }());
  816. defineProperties(ArrayPrototype, {
  817. // Safari 5.0 bug where .splice() returns undefined
  818. splice: function splice(start, deleteCount) {
  819. if (arguments.length === 0) {
  820. return [];
  821. } else {
  822. return array_splice.apply(this, arguments);
  823. }
  824. }
  825. }, !spliceNoopReturnsEmptyArray);
  826. var spliceWorksWithEmptyObject = (function () {
  827. var obj = {};
  828. ArrayPrototype.splice.call(obj, 0, 0, 1);
  829. return obj.length === 1;
  830. }());
  831. defineProperties(ArrayPrototype, {
  832. splice: function splice(start, deleteCount) {
  833. if (arguments.length === 0) { return []; }
  834. var args = arguments;
  835. this.length = Math.max(ES.ToInteger(this.length), 0);
  836. if (arguments.length > 0 && typeof deleteCount !== 'number') {
  837. args = array_slice.call(arguments);
  838. if (args.length < 2) {
  839. args.push(this.length - start);
  840. } else {
  841. args[1] = ES.ToInteger(deleteCount);
  842. }
  843. }
  844. return array_splice.apply(this, args);
  845. }
  846. }, !spliceWorksWithEmptyObject);
  847. // ES5 15.4.4.12
  848. // http://es5.github.com/#x15.4.4.13
  849. // Return len+argCount.
  850. // [bugfix, ielt8]
  851. // IE < 8 bug: [].unshift(0) === undefined but should be "1"
  852. var hasUnshiftReturnValueBug = [].unshift(0) !== 1;
  853. defineProperties(ArrayPrototype, {
  854. unshift: function () {
  855. array_unshift.apply(this, arguments);
  856. return this.length;
  857. }
  858. }, hasUnshiftReturnValueBug);
  859. // ES5 15.4.3.2
  860. // http://es5.github.com/#x15.4.3.2
  861. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
  862. defineProperties(Array, { isArray: isArray });
  863. // The IsCallable() check in the Array functions
  864. // has been replaced with a strict check on the
  865. // internal class of the object to trap cases where
  866. // the provided function was actually a regular
  867. // expression literal, which in V8 and
  868. // JavaScriptCore is a typeof "function". Only in
  869. // V8 are regular expression literals permitted as
  870. // reduce parameters, so it is desirable in the
  871. // general case for the shim to match the more
  872. // strict and common behavior of rejecting regular
  873. // expressions.
  874. // ES5 15.4.4.18
  875. // http://es5.github.com/#x15.4.4.18
  876. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
  877. // Check failure of by-index access of string characters (IE < 9)
  878. // and failure of `0 in boxedString` (Rhino)
  879. var boxedString = Object('a');
  880. var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
  881. var properlyBoxesContext = function properlyBoxed(method) {
  882. // Check node 0.6.21 bug where third parameter is not boxed
  883. var properlyBoxesNonStrict = true;
  884. var properlyBoxesStrict = true;
  885. if (method) {
  886. method.call('foo', function (_, __, context) {
  887. if (typeof context !== 'object') { properlyBoxesNonStrict = false; }
  888. });
  889. method.call([1], function () {
  890. 'use strict';
  891. properlyBoxesStrict = typeof this === 'string';
  892. }, 'x');
  893. }
  894. return !!method && properlyBoxesNonStrict && properlyBoxesStrict;
  895. };
  896. defineProperties(ArrayPrototype, {
  897. forEach: function forEach(callbackfn /*, thisArg*/) {
  898. var object = ES.ToObject(this);
  899. var self = splitString && isString(this) ? this.split('') : object;
  900. var i = -1;
  901. var length = self.length >>> 0;
  902. var T;
  903. if (arguments.length > 1) {
  904. T = arguments[1];
  905. }
  906. // If no callback function or if callback is not a callable function
  907. if (!isCallable(callbackfn)) {
  908. throw new TypeError('Array.prototype.forEach callback must be a function');
  909. }
  910. while (++i < length) {
  911. if (i in self) {
  912. // Invoke the callback function with call, passing arguments:
  913. // context, property value, property key, thisArg object
  914. if (typeof T !== 'undefined') {
  915. callbackfn.call(T, self[i], i, object);
  916. } else {
  917. callbackfn(self[i], i, object);
  918. }
  919. }
  920. }
  921. }
  922. }, !properlyBoxesContext(ArrayPrototype.forEach));
  923. // ES5 15.4.4.19
  924. // http://es5.github.com/#x15.4.4.19
  925. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
  926. defineProperties(ArrayPrototype, {
  927. map: function map(callbackfn/*, thisArg*/) {
  928. var object = ES.ToObject(this);
  929. var self = splitString && isString(this) ? this.split('') : object;
  930. var length = self.length >>> 0;
  931. var result = Array(length);
  932. var T;
  933. if (arguments.length > 1) {
  934. T = arguments[1];
  935. }
  936. // If no callback function or if callback is not a callable function
  937. if (!isCallable(callbackfn)) {
  938. throw new TypeError('Array.prototype.map callback must be a function');
  939. }
  940. for (var i = 0; i < length; i++) {
  941. if (i in self) {
  942. if (typeof T !== 'undefined') {
  943. result[i] = callbackfn.call(T, self[i], i, object);
  944. } else {
  945. result[i] = callbackfn(self[i], i, object);
  946. }
  947. }
  948. }
  949. return result;
  950. }
  951. }, !properlyBoxesContext(ArrayPrototype.map));
  952. // ES5 15.4.4.20
  953. // http://es5.github.com/#x15.4.4.20
  954. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
  955. defineProperties(ArrayPrototype, {
  956. filter: function filter(callbackfn /*, thisArg*/) {
  957. var object = ES.ToObject(this);
  958. var self = splitString && isString(this) ? this.split('') : object;
  959. var length = self.length >>> 0;
  960. var result = [];
  961. var value;
  962. var T;
  963. if (arguments.length > 1) {
  964. T = arguments[1];
  965. }
  966. // If no callback function or if callback is not a callable function
  967. if (!isCallable(callbackfn)) {
  968. throw new TypeError('Array.prototype.filter callback must be a function');
  969. }
  970. for (var i = 0; i < length; i++) {
  971. if (i in self) {
  972. value = self[i];
  973. if (typeof T === 'undefined' ? callbackfn(value, i, object) : callbackfn.call(T, value, i, object)) {
  974. result.push(value);
  975. }
  976. }
  977. }
  978. return result;
  979. }
  980. }, !properlyBoxesContext(ArrayPrototype.filter));
  981. // ES5 15.4.4.16
  982. // http://es5.github.com/#x15.4.4.16
  983. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
  984. defineProperties(ArrayPrototype, {
  985. every: function every(callbackfn /*, thisArg*/) {
  986. var object = ES.ToObject(this);
  987. var self = splitString && isString(this) ? this.split('') : object;
  988. var length = self.length >>> 0;
  989. var T;
  990. if (arguments.length > 1) {
  991. T = arguments[1];
  992. }
  993. // If no callback function or if callback is not a callable function
  994. if (!isCallable(callbackfn)) {
  995. throw new TypeError('Array.prototype.every callback must be a function');
  996. }
  997. for (var i = 0; i < length; i++) {
  998. if (i in self && !(typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
  999. return false;
  1000. }
  1001. }
  1002. return true;
  1003. }
  1004. }, !properlyBoxesContext(ArrayPrototype.every));
  1005. // ES5 15.4.4.17
  1006. // http://es5.github.com/#x15.4.4.17
  1007. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
  1008. defineProperties(ArrayPrototype, {
  1009. some: function some(callbackfn/*, thisArg */) {
  1010. var object = ES.ToObject(this);
  1011. var self = splitString && isString(this) ? this.split('') : object;
  1012. var length = self.length >>> 0;
  1013. var T;
  1014. if (arguments.length > 1) {
  1015. T = arguments[1];
  1016. }
  1017. // If no callback function or if callback is not a callable function
  1018. if (!isCallable(callbackfn)) {
  1019. throw new TypeError('Array.prototype.some callback must be a function');
  1020. }
  1021. for (var i = 0; i < length; i++) {
  1022. if (i in self && (typeof T === 'undefined' ? callbackfn(self[i], i, object) : callbackfn.call(T, self[i], i, object))) {
  1023. return true;
  1024. }
  1025. }
  1026. return false;
  1027. }
  1028. }, !properlyBoxesContext(ArrayPrototype.some));
  1029. // ES5 15.4.4.21
  1030. // http://es5.github.com/#x15.4.4.21
  1031. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
  1032. var reduceCoercesToObject = false;
  1033. if (ArrayPrototype.reduce) {
  1034. reduceCoercesToObject = typeof ArrayPrototype.reduce.call('es5', function (_, __, ___, list) { return list; }) === 'object';
  1035. }
  1036. defineProperties(ArrayPrototype, {
  1037. reduce: function reduce(callbackfn /*, initialValue*/) {
  1038. var object = ES.ToObject(this);
  1039. var self = splitString && isString(this) ? this.split('') : object;
  1040. var length = self.length >>> 0;
  1041. // If no callback function or if callback is not a callable function
  1042. if (!isCallable(callbackfn)) {
  1043. throw new TypeError('Array.prototype.reduce callback must be a function');
  1044. }
  1045. // no value to return if no initial value and an empty array
  1046. if (length === 0 && arguments.length === 1) {
  1047. throw new TypeError('reduce of empty array with no initial value');
  1048. }
  1049. var i = 0;
  1050. var result;
  1051. if (arguments.length >= 2) {
  1052. result = arguments[1];
  1053. } else {
  1054. do {
  1055. if (i in self) {
  1056. result = self[i++];
  1057. break;
  1058. }
  1059. // if array contains no values, no initial value to return
  1060. if (++i >= length) {
  1061. throw new TypeError('reduce of empty array with no initial value');
  1062. }
  1063. } while (true);
  1064. }
  1065. for (; i < length; i++) {
  1066. if (i in self) {
  1067. result = callbackfn(result, self[i], i, object);
  1068. }
  1069. }
  1070. return result;
  1071. }
  1072. }, !reduceCoercesToObject);
  1073. // ES5 15.4.4.22
  1074. // http://es5.github.com/#x15.4.4.22
  1075. // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
  1076. var reduceRightCoercesToObject = false;
  1077. if (ArrayPrototype.reduceRight) {
  1078. reduceRightCoercesToObject = typeof ArrayPrototype.reduceRight.call('es5', function (_, __, ___, list) { return list; }) === 'object';
  1079. }
  1080. defineProperties(ArrayPrototype, {
  1081. reduceRight: function reduceRight(callbackfn/*, initial*/) {
  1082. var object = ES.ToObject(this);
  1083. var self = splitString && isString(this) ? this.split('') : object;
  1084. var length = self.length >>> 0;
  1085. // If no callback function or if callback is not a callable function
  1086. if (!isCallable(callbackfn)) {
  1087. throw new TypeError('Array.prototype.reduceRight callback must be a function');
  1088. }
  1089. // no value to return if no initial value, empty array
  1090. if (length === 0 && arguments.length === 1) {
  1091. throw new TypeError('reduceRight of empty array with no initial value');
  1092. }
  1093. var result;
  1094. var i = length - 1;
  1095. if (arguments.length >= 2) {
  1096. result = arguments[1];
  1097. } else {
  1098. do {
  1099. if (i in self) {
  1100. result = self[i--];
  1101. break;
  1102. }
  1103. // if array contains no values, no initial value to return
  1104. if (--i < 0) {
  1105. throw new TypeError('reduceRight of empty array with no initial value');
  1106. }
  1107. } while (true);
  1108. }
  1109. if (i < 0) {
  1110. return result;
  1111. }
  1112. do {
  1113. if (i in self) {
  1114. result = callbackfn(result, self[i], i, object);
  1115. }
  1116. } while (i--);
  1117. return result;
  1118. }
  1119. }, !reduceRightCoercesToObject);
  1120. // ES5 15.4.4.14
  1121. // http://es5.github.com/#x15.4.4.14
  1122. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
  1123. var hasFirefox2IndexOfBug = Array.prototype.indexOf && [0, 1].indexOf(1, 2) !== -1;
  1124. defineProperties(ArrayPrototype, {
  1125. indexOf: function indexOf(searchElement /*, fromIndex */) {
  1126. var self = splitString && isString(this) ? this.split('') : ES.ToObject(this);
  1127. var length = self.length >>> 0;
  1128. if (length === 0) {
  1129. return -1;
  1130. }
  1131. var i = 0;
  1132. if (arguments.length > 1) {
  1133. i = ES.ToInteger(arguments[1]);
  1134. }
  1135. // handle negative indices
  1136. i = i >= 0 ? i : Math.max(0, length + i);
  1137. for (; i < length; i++) {
  1138. if (i in self && self[i] === searchElement) {
  1139. return i;
  1140. }
  1141. }
  1142. return -1;
  1143. }
  1144. }, hasFirefox2IndexOfBug);
  1145. // ES5 15.4.4.15
  1146. // http://es5.github.com/#x15.4.4.15
  1147. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
  1148. var hasFirefox2LastIndexOfBug = Array.prototype.lastIndexOf && [0, 1].lastIndexOf(0, -3) !== -1;
  1149. defineProperties(ArrayPrototype, {
  1150. lastIndexOf: function lastIndexOf(searchElement /*, fromIndex */) {
  1151. var self = splitString && isString(this) ? this.split('') : ES.ToObject(this);
  1152. var length = self.length >>> 0;
  1153. if (length === 0) {
  1154. return -1;
  1155. }
  1156. var i = length - 1;
  1157. if (arguments.length > 1) {
  1158. i = Math.min(i, ES.ToInteger(arguments[1]));
  1159. }
  1160. // handle negative indices
  1161. i = i >= 0 ? i : length - Math.abs(i);
  1162. for (; i >= 0; i--) {
  1163. if (i in self && searchElement === self[i]) {
  1164. return i;
  1165. }
  1166. }
  1167. return -1;
  1168. }
  1169. }, hasFirefox2LastIndexOfBug);
  1170. //
  1171. // Object
  1172. // ======
  1173. //
  1174. // ES5 15.2.3.14
  1175. // http://es5.github.com/#x15.2.3.14
  1176. // http://whattheheadsaid.com/2010/10/a-safer-object-keys-compatibility-implementation
  1177. var hasDontEnumBug = !({ 'toString': null }).propertyIsEnumerable('toString'),
  1178. hasProtoEnumBug = function () {}.propertyIsEnumerable('prototype'),
  1179. hasStringEnumBug = !owns('x', '0'),
  1180. dontEnums = [
  1181. 'toString',
  1182. 'toLocaleString',
  1183. 'valueOf',
  1184. 'hasOwnProperty',
  1185. 'isPrototypeOf',
  1186. 'propertyIsEnumerable',
  1187. 'constructor'
  1188. ],
  1189. dontEnumsLength = dontEnums.length;
  1190. defineProperties(Object, {
  1191. keys: function keys(object) {
  1192. var isFn = isCallable(object),
  1193. isArgs = isArguments(object),
  1194. isObject = object !== null && typeof object === 'object',
  1195. isStr = isObject && isString(object);
  1196. if (!isObject && !isFn && !isArgs) {
  1197. throw new TypeError('Object.keys called on a non-object');
  1198. }
  1199. var theKeys = [];
  1200. var skipProto = hasProtoEnumBug && isFn;
  1201. if ((isStr && hasStringEnumBug) || isArgs) {
  1202. for (var i = 0; i < object.length; ++i) {
  1203. theKeys.push(String(i));
  1204. }
  1205. }
  1206. if (!isArgs) {
  1207. for (var name in object) {
  1208. if (!(skipProto && name === 'prototype') && owns(object, name)) {
  1209. theKeys.push(String(name));
  1210. }
  1211. }
  1212. }
  1213. if (hasDontEnumBug) {
  1214. var ctor = object.constructor,
  1215. skipConstructor = ctor && ctor.prototype === object;
  1216. for (var j = 0; j < dontEnumsLength; j++) {
  1217. var dontEnum = dontEnums[j];
  1218. if (!(skipConstructor && dontEnum === 'constructor') && owns(object, dontEnum)) {
  1219. theKeys.push(dontEnum);
  1220. }
  1221. }
  1222. }
  1223. return theKeys;
  1224. }
  1225. });
  1226. var keysWorksWithArguments = Object.keys && (function () {
  1227. // Safari 5.0 bug
  1228. return Object.keys(arguments).length === 2;
  1229. }(1, 2));
  1230. var originalKeys = Object.keys;
  1231. defineProperties(Object, {
  1232. keys: function keys(object) {
  1233. if (isArguments(object)) {
  1234. return originalKeys(ArrayPrototype.slice.call(object));
  1235. } else {
  1236. return originalKeys(object);
  1237. }
  1238. }
  1239. }, !keysWorksWithArguments);
  1240. //
  1241. // Date
  1242. // ====
  1243. //
  1244. // ES5 15.9.5.43
  1245. // http://es5.github.com/#x15.9.5.43
  1246. // This function returns a String value represent the instance in time
  1247. // represented by this Date object. The format of the String is the Date Time
  1248. // string format defined in 15.9.1.15. All fields are present in the String.
  1249. // The time zone is always UTC, denoted by the suffix Z. If the time value of
  1250. // this object is not a finite Number a RangeError exception is thrown.
  1251. var negativeDate = -62198755200000;
  1252. var negativeYearString = '-000001';
  1253. var hasNegativeDateBug = Date.prototype.toISOString && new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1;
  1254. defineProperties(Date.prototype, {
  1255. toISOString: function toISOString() {
  1256. var result, length, value, year, month;
  1257. if (!isFinite(this)) {
  1258. throw new RangeError('Date.prototype.toISOString called on non-finite value.');
  1259. }
  1260. year = this.getUTCFullYear();
  1261. month = this.getUTCMonth();
  1262. // see https://github.com/es-shims/es5-shim/issues/111
  1263. year += Math.floor(month / 12);
  1264. month = (month % 12 + 12) % 12;
  1265. // the date time string format is specified in 15.9.1.15.
  1266. result = [month + 1, this.getUTCDate(), this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
  1267. year = (
  1268. (year < 0 ? '-' : (year > 9999 ? '+' : '')) +
  1269. ('00000' + Math.abs(year)).slice((0 <= year && year <= 9999) ? -4 : -6)
  1270. );
  1271. length = result.length;
  1272. while (length--) {
  1273. value = result[length];
  1274. // pad months, days, hours, minutes, and seconds to have two
  1275. // digits.
  1276. if (value < 10) {
  1277. result[length] = '0' + value;
  1278. }
  1279. }
  1280. // pad milliseconds to have three digits.
  1281. return (
  1282. year + '-' + result.slice(0, 2).join('-') +
  1283. 'T' + result.slice(2).join(':') + '.' +
  1284. ('000' + this.getUTCMilliseconds()).slice(-3) + 'Z'
  1285. );
  1286. }
  1287. }, hasNegativeDateBug);
  1288. // ES5 15.9.5.44
  1289. // http://es5.github.com/#x15.9.5.44
  1290. // This function provides a String representation of a Date object for use by
  1291. // JSON.stringify (15.12.3).
  1292. var dateToJSONIsSupported = (function () {
  1293. try {
  1294. return Date.prototype.toJSON &&
  1295. new Date(NaN).toJSON() === null &&
  1296. new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
  1297. Date.prototype.toJSON.call({ // generic
  1298. toISOString: function () { return true; }
  1299. });
  1300. } catch (e) {
  1301. return false;
  1302. }
  1303. }());
  1304. if (!dateToJSONIsSupported) {
  1305. Date.prototype.toJSON = function toJSON(key) {
  1306. // When the toJSON method is called with argument key, the following
  1307. // steps are taken:
  1308. // 1. Let O be the result of calling ToObject, giving it the this
  1309. // value as its argument.
  1310. // 2. Let tv be ES.ToPrimitive(O, hint Number).
  1311. var O = Object(this);
  1312. var tv = ES.ToPrimitive(O);
  1313. // 3. If tv is a Number and is not finite, return null.
  1314. if (typeof tv === 'number' && !isFinite(tv)) {
  1315. return null;
  1316. }
  1317. // 4. Let toISO be the result of calling the [[Get]] internal method of
  1318. // O with argument "toISOString".
  1319. var toISO = O.toISOString;
  1320. // 5. If IsCallable(toISO) is false, throw a TypeError exception.
  1321. if (!isCallable(toISO)) {
  1322. throw new TypeError('toISOString property is not callable');
  1323. }
  1324. // 6. Return the result of calling the [[Call]] internal method of
  1325. // toISO with O as the this value and an empty argument list.
  1326. return toISO.call(O);
  1327. // NOTE 1 The argument is ignored.
  1328. // NOTE 2 The toJSON function is intentionally generic; it does not
  1329. // require that its this value be a Date object. Therefore, it can be
  1330. // transferred to other kinds of objects for use as a method. However,
  1331. // it does require that any such object have a toISOString method. An
  1332. // object is free to use the argument key to filter its
  1333. // stringification.
  1334. };
  1335. }
  1336. // ES5 15.9.4.2
  1337. // http://es5.github.com/#x15.9.4.2
  1338. // based on work shared by Daniel Friesen (dantman)
  1339. // http://gist.github.com/303249
  1340. var supportsExtendedYears = Date.parse('+033658-09-27T01:46:40.000Z') === 1e15;
  1341. var acceptsInvalidDates = !isNaN(Date.parse('2012-04-04T24:00:00.500Z')) || !isNaN(Date.parse('2012-11-31T23:59:59.000Z')) || !isNaN(Date.parse('2012-12-31T23:59:60.000Z'));
  1342. var doesNotParseY2KNewYear = isNaN(Date.parse('2000-01-01T00:00:00.000Z'));
  1343. if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
  1344. // XXX global assignment won't work in embeddings that use
  1345. // an alternate object for the context.
  1346. /* global Date: true */
  1347. /* eslint-disable no-undef */
  1348. Date = (function (NativeDate) {
  1349. /* eslint-enable no-undef */
  1350. // Date.length === 7
  1351. var DateShim = function Date(Y, M, D, h, m, s, ms) {
  1352. var length = arguments.length;
  1353. var date;
  1354. if (this instanceof NativeDate) {
  1355. date = length === 1 && String(Y) === Y ? // isString(Y)
  1356. // We explicitly pass it through parse:
  1357. new NativeDate(DateShim.parse(Y)) :
  1358. // We have to manually make calls depending on argument
  1359. // length here
  1360. length >= 7 ? new NativeDate(Y, M, D, h, m, s, ms) :
  1361. length >= 6 ? new NativeDate(Y, M, D, h, m, s) :
  1362. length >= 5 ? new NativeDate(Y, M, D, h, m) :
  1363. length >= 4 ? new NativeDate(Y, M, D, h) :
  1364. length >= 3 ? new NativeDate(Y, M, D) :
  1365. length >= 2 ? new NativeDate(Y, M) :
  1366. length >= 1 ? new NativeDate(Y) :
  1367. new NativeDate();
  1368. } else {
  1369. date = NativeDate.apply(this, arguments);
  1370. }
  1371. // Prevent mixups with unfixed Date object
  1372. defineProperties(date, { constructor: DateShim }, true);
  1373. return date;
  1374. };
  1375. // 15.9.1.15 Date Time String Format.
  1376. var isoDateExpression = new RegExp('^' +
  1377. '(\\d{4}|[+-]\\d{6})' + // four-digit year capture or sign +
  1378. // 6-digit extended year
  1379. '(?:-(\\d{2})' + // optional month capture
  1380. '(?:-(\\d{2})' + // optional day capture
  1381. '(?:' + // capture hours:minutes:seconds.milliseconds
  1382. 'T(\\d{2})' + // hours capture
  1383. ':(\\d{2})' + // minutes capture
  1384. '(?:' + // optional :seconds.milliseconds
  1385. ':(\\d{2})' + // seconds capture
  1386. '(?:(\\.\\d{1,}))?' + // milliseconds capture
  1387. ')?' +
  1388. '(' + // capture UTC offset component
  1389. 'Z|' + // UTC capture
  1390. '(?:' + // offset specifier +/-hours:minutes
  1391. '([-+])' + // sign capture
  1392. '(\\d{2})' + // hours offset capture
  1393. ':(\\d{2})' + // minutes offset capture
  1394. ')' +
  1395. ')?)?)?)?' +
  1396. '$');
  1397. var months = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
  1398. var dayFromMonth = function dayFromMonth(year, month) {
  1399. var t = month > 1 ? 1 : 0;
  1400. return (
  1401. months[month] +
  1402. Math.floor((year - 1969 + t) / 4) -
  1403. Math.floor((year - 1901 + t) / 100) +
  1404. Math.floor((year - 1601 + t) / 400) +
  1405. 365 * (year - 1970)
  1406. );
  1407. };
  1408. var toUTC = function toUTC(t) {
  1409. return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
  1410. };
  1411. // Copy any custom methods a 3rd party library may have added
  1412. for (var key in NativeDate) {
  1413. if (owns(NativeDate, key)) {
  1414. DateShim[key] = NativeDate[key];
  1415. }
  1416. }
  1417. // Copy "native" methods explicitly; they may be non-enumerable
  1418. defineProperties(DateShim, {
  1419. now: NativeDate.now,
  1420. UTC: NativeDate.UTC
  1421. }, true);
  1422. DateShim.prototype = NativeDate.prototype;
  1423. defineProperties(DateShim.prototype, {
  1424. constructor: DateShim
  1425. }, true);
  1426. // Upgrade Date.parse to handle simplified ISO 8601 strings
  1427. var parseShim = function parse(string) {
  1428. var match = isoDateExpression.exec(string);
  1429. if (match) {
  1430. // parse months, days, hours, minutes, seconds, and milliseconds
  1431. // provide default values if necessary
  1432. // parse the UTC offset component
  1433. var year = Number(match[1]),
  1434. month = Number(match[2] || 1) - 1,
  1435. day = Number(match[3] || 1) - 1,
  1436. hour = Number(match[4] || 0),
  1437. minute = Number(match[5] || 0),
  1438. second = Number(match[6] || 0),
  1439. millisecond = Math.floor(Number(match[7] || 0) * 1000),
  1440. // When time zone is missed, local offset should be used
  1441. // (ES 5.1 bug)
  1442. // see https://bugs.ecmascript.org/show_bug.cgi?id=112
  1443. isLocalTime = Boolean(match[4] && !match[8]),
  1444. signOffset = match[9] === '-' ? 1 : -1,
  1445. hourOffset = Number(match[10] || 0),
  1446. minuteOffset = Number(match[11] || 0),
  1447. result;
  1448. if (
  1449. hour < (
  1450. minute > 0 || second > 0 || millisecond > 0 ?
  1451. 24 : 25
  1452. ) &&
  1453. minute < 60 && second < 60 && millisecond < 1000 &&
  1454. month > -1 && month < 12 && hourOffset < 24 &&
  1455. minuteOffset < 60 && // detect invalid offsets
  1456. day > -1 &&
  1457. day < (
  1458. dayFromMonth(year, month + 1) -
  1459. dayFromMonth(year, month)
  1460. )
  1461. ) {
  1462. result = (
  1463. (dayFromMonth(year, month) + day) * 24 +
  1464. hour +
  1465. hourOffset * signOffset
  1466. ) * 60;
  1467. result = (
  1468. (result + minute + minuteOffset * signOffset) * 60 +
  1469. second
  1470. ) * 1000 + millisecond;
  1471. if (isLocalTime) {
  1472. result = toUTC(result);
  1473. }
  1474. if (-8.64e15 <= result && result <= 8.64e15) {
  1475. return result;
  1476. }
  1477. }
  1478. return NaN;
  1479. }
  1480. return NativeDate.parse.apply(this, arguments);
  1481. };
  1482. defineProperties(DateShim, { parse: parseShim });
  1483. return DateShim;
  1484. }(Date));
  1485. /* global Date: false */
  1486. }
  1487. // ES5 15.9.4.4
  1488. // http://es5.github.com/#x15.9.4.4
  1489. if (!Date.now) {
  1490. Date.now = function now() {
  1491. return new Date().getTime();
  1492. };
  1493. }
  1494. //
  1495. // Number
  1496. // ======
  1497. //
  1498. // ES5.1 15.7.4.5
  1499. // http://es5.github.com/#x15.7.4.5
  1500. var hasToFixedBugs = NumberPrototype.toFixed && (
  1501. (0.00008).toFixed(3) !== '0.000' ||
  1502. (0.9).toFixed(0) !== '1' ||
  1503. (1.255).toFixed(2) !== '1.25' ||
  1504. (1000000000000000128).toFixed(0) !== '1000000000000000128'
  1505. );
  1506. var toFixedHelpers = {
  1507. base: 1e7,
  1508. size: 6,
  1509. data: [0, 0, 0, 0, 0, 0],
  1510. multiply: function multiply(n, c) {
  1511. var i = -1;
  1512. var c2 = c;
  1513. while (++i < toFixedHelpers.size) {
  1514. c2 += n * toFixedHelpers.data[i];
  1515. toFixedHelpers.data[i] = c2 % toFixedHelpers.base;
  1516. c2 = Math.floor(c2 / toFixedHelpers.base);
  1517. }
  1518. },
  1519. divide: function divide(n) {
  1520. var i = toFixedHelpers.size, c = 0;
  1521. while (--i >= 0) {
  1522. c += toFixedHelpers.data[i];
  1523. toFixedHelpers.data[i] = Math.floor(c / n);
  1524. c = (c % n) * toFixedHelpers.base;
  1525. }
  1526. },
  1527. numToString: function numToString() {
  1528. var i = toFixedHelpers.size;
  1529. var s = '';
  1530. while (--i >= 0) {
  1531. if (s !== '' || i === 0 || toFixedHelpers.data[i] !== 0) {
  1532. var t = String(toFixedHelpers.data[i]);
  1533. if (s === '') {
  1534. s = t;
  1535. } else {
  1536. s += '0000000'.slice(0, 7 - t.length) + t;
  1537. }
  1538. }
  1539. }
  1540. return s;
  1541. },
  1542. pow: function pow(x, n, acc) {
  1543. return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
  1544. },
  1545. log: function log(x) {
  1546. var n = 0;
  1547. var x2 = x;
  1548. while (x2 >= 4096) {
  1549. n += 12;
  1550. x2 /= 4096;
  1551. }
  1552. while (x2 >= 2) {
  1553. n += 1;
  1554. x2 /= 2;
  1555. }
  1556. return n;
  1557. }
  1558. };
  1559. defineProperties(NumberPrototype, {
  1560. toFixed: function toFixed(fractionDigits) {
  1561. var f, x, s, m, e, z, j, k;
  1562. // Test for NaN and round fractionDigits down
  1563. f = Number(fractionDigits);
  1564. f = f !== f ? 0 : Math.floor(f);
  1565. if (f < 0 || f > 20) {
  1566. throw new RangeError('Number.toFixed called with invalid number of decimals');
  1567. }
  1568. x = Number(this);
  1569. // Test for NaN
  1570. if (x !== x) {
  1571. return 'NaN';
  1572. }
  1573. // If it is too big or small, return the string value of the number
  1574. if (x <= -1e21 || x >= 1e21) {
  1575. return String(x);
  1576. }
  1577. s = '';
  1578. if (x < 0) {
  1579. s = '-';
  1580. x = -x;
  1581. }
  1582. m = '0';
  1583. if (x > 1e-21) {
  1584. // 1e-21 < x < 1e21
  1585. // -70 < log2(x) < 70
  1586. e = toFixedHelpers.log(x * toFixedHelpers.pow(2, 69, 1)) - 69;
  1587. z = (e < 0 ? x * toFixedHelpers.pow(2, -e, 1) : x / toFixedHelpers.pow(2, e, 1));
  1588. z *= 0x10000000000000; // Math.pow(2, 52);
  1589. e = 52 - e;
  1590. // -18 < e < 122
  1591. // x = z / 2 ^ e
  1592. if (e > 0) {
  1593. toFixedHelpers.multiply(0, z);
  1594. j = f;
  1595. while (j >= 7) {
  1596. toFixedHelpers.multiply(1e7, 0);
  1597. j -= 7;
  1598. }
  1599. toFixedHelpers.multiply(toFixedHelpers.pow(10, j, 1), 0);
  1600. j = e - 1;
  1601. while (j >= 23) {
  1602. toFixedHelpers.divide(1 << 23);
  1603. j -= 23;
  1604. }
  1605. toFixedHelpers.divide(1 << j);
  1606. toFixedHelpers.multiply(1, 1);
  1607. toFixedHelpers.divide(2);
  1608. m = toFixedHelpers.numToString();
  1609. } else {
  1610. toFixedHelpers.multiply(0, z);
  1611. toFixedHelpers.multiply(1 << (-e), 0);
  1612. m = toFixedHelpers.numToString() + '0.00000000000000000000'.slice(2, 2 + f);
  1613. }
  1614. }
  1615. if (f > 0) {
  1616. k = m.length;
  1617. if (k <= f) {
  1618. m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
  1619. } else {
  1620. m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
  1621. }
  1622. } else {
  1623. m = s + m;
  1624. }
  1625. return m;
  1626. }
  1627. }, hasToFixedBugs);
  1628. //
  1629. // String
  1630. // ======
  1631. //
  1632. // ES5 15.5.4.14
  1633. // http://es5.github.com/#x15.5.4.14
  1634. // [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
  1635. // Many browsers do not split properly with regular expressions or they
  1636. // do not perform the split correctly under obscure conditions.
  1637. // See http://blog.stevenlevithan.com/archives/cross-browser-split
  1638. // I've tested in many browsers and this seems to cover the deviant ones:
  1639. // 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
  1640. // '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
  1641. // 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
  1642. // [undefined, "t", undefined, "e", ...]
  1643. // ''.split(/.?/) should be [], not [""]
  1644. // '.'.split(/()()/) should be ["."], not ["", "", "."]
  1645. var string_split = StringPrototype.split;
  1646. if (
  1647. 'ab'.split(/(?:ab)*/).length !== 2 ||
  1648. '.'.split(/(.?)(.?)/).length !== 4 ||
  1649. 'tesst'.split(/(s)*/)[1] === 't' ||
  1650. 'test'.split(/(?:)/, -1).length !== 4 ||
  1651. ''.split(/.?/).length ||
  1652. '.'.split(/()()/).length > 1
  1653. ) {
  1654. (function () {
  1655. var compliantExecNpcg = typeof (/()??/).exec('')[1] === 'undefined'; // NPCG: nonparticipating capturing group
  1656. StringPrototype.split = function (separator, limit) {
  1657. var string = this;
  1658. if (typeof separator === 'undefined' && limit === 0) {
  1659. return [];
  1660. }
  1661. // If `separator` is not a regex, use native split
  1662. if (!isRegex(separator)) {
  1663. return string_split.call(this, separator, limit);
  1664. }
  1665. var output = [];
  1666. var flags = (separator.ignoreCase ? 'i' : '') +
  1667. (separator.multiline ? 'm' : '') +
  1668. (separator.extended ? 'x' : '') + // Proposed for ES6
  1669. (separator.sticky ? 'y' : ''), // Firefox 3+
  1670. lastLastIndex = 0,
  1671. // Make `global` and avoid `lastIndex` issues by working with a copy
  1672. separator2, match, lastIndex, lastLength;
  1673. var separatorCopy = new RegExp(separator.source, flags + 'g');
  1674. string += ''; // Type-convert
  1675. if (!compliantExecNpcg) {
  1676. // Doesn't need flags gy, but they don't hurt
  1677. separator2 = new RegExp('^' + separatorCopy.source + '$(?!\\s)', flags);
  1678. }
  1679. /* Values for `limit`, per the spec:
  1680. * If undefined: 4294967295 // Math.pow(2, 32) - 1
  1681. * If 0, Infinity, or NaN: 0
  1682. * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
  1683. * If negative number: 4294967296 - Math.floor(Math.abs(limit))
  1684. * If other: Type-convert, then use the above rules
  1685. */
  1686. var splitLimit = typeof limit === 'undefined' ?
  1687. -1 >>> 0 : // Math.pow(2, 32) - 1
  1688. ES.ToUint32(limit);
  1689. match = separatorCopy.exec(string);
  1690. while (match) {
  1691. // `separatorCopy.lastIndex` is not reliable cross-browser
  1692. lastIndex = match.index + match[0].length;
  1693. if (lastIndex > lastLastIndex) {
  1694. output.push(string.slice(lastLastIndex, match.index));
  1695. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  1696. // nonparticipating capturing groups
  1697. if (!compliantExecNpcg && match.length > 1) {
  1698. /* eslint-disable no-loop-func */
  1699. match[0].replace(separator2, function () {
  1700. for (var i = 1; i < arguments.length - 2; i++) {
  1701. if (typeof arguments[i] === 'undefined') {
  1702. match[i] = void 0;
  1703. }
  1704. }
  1705. });
  1706. /* eslint-enable no-loop-func */
  1707. }
  1708. if (match.length > 1 && match.index < string.length) {
  1709. array_push.apply(output, match.slice(1));
  1710. }
  1711. lastLength = match[0].length;
  1712. lastLastIndex = lastIndex;
  1713. if (output.length >= splitLimit) {
  1714. break;
  1715. }
  1716. }
  1717. if (separatorCopy.lastIndex === match.index) {
  1718. separatorCopy.lastIndex++; // Avoid an infinite loop
  1719. }
  1720. match = separatorCopy.exec(string);
  1721. }
  1722. if (lastLastIndex === string.length) {
  1723. if (lastLength || !separatorCopy.test('')) {
  1724. output.push('');
  1725. }
  1726. } else {
  1727. output.push(string.slice(lastLastIndex));
  1728. }
  1729. return output.length > splitLimit ? output.slice(0, splitLimit) : output;
  1730. };
  1731. }());
  1732. // [bugfix, chrome]
  1733. // If separator is undefined, then the result array contains just one String,
  1734. // which is the this value (converted to a String). If limit is not undefined,
  1735. // then the output array is truncated so that it contains no more than limit
  1736. // elements.
  1737. // "0".split(undefined, 0) -> []
  1738. } else if ('0'.split(void 0, 0).length) {
  1739. StringPrototype.split = function split(separator, limit) {
  1740. if (typeof separator === 'undefined' && limit === 0) { return []; }
  1741. return string_split.call(this, separator, limit);
  1742. };
  1743. }
  1744. var str_replace = StringPrototype.replace;
  1745. var replaceReportsGroupsCorrectly = (function () {
  1746. var groups = [];
  1747. 'x'.replace(/x(.)?/g, function (match, group) {
  1748. groups.push(group);
  1749. });
  1750. return groups.length === 1 && typeof groups[0] === 'undefined';
  1751. }());
  1752. if (!replaceReportsGroupsCorrectly) {
  1753. StringPrototype.replace = function replace(searchValue, replaceValue) {
  1754. var isFn = isCallable(replaceValue);
  1755. var hasCapturingGroups = isRegex(searchValue) && (/\)[*?]/).test(searchValue.source);
  1756. if (!isFn || !hasCapturingGroups) {
  1757. return str_replace.call(this, searchValue, replaceValue);
  1758. } else {
  1759. var wrappedReplaceValue = function (match) {
  1760. var length = arguments.length;
  1761. var originalLastIndex = searchValue.lastIndex;
  1762. searchValue.lastIndex = 0;
  1763. var args = searchValue.exec(match) || [];
  1764. searchValue.lastIndex = originalLastIndex;
  1765. args.push(arguments[length - 2], arguments[length - 1]);
  1766. return replaceValue.apply(this, args);
  1767. };
  1768. return str_replace.call(this, searchValue, wrappedReplaceValue);
  1769. }
  1770. };
  1771. }
  1772. // ECMA-262, 3rd B.2.3
  1773. // Not an ECMAScript standard, although ECMAScript 3rd Edition has a
  1774. // non-normative section suggesting uniform semantics and it should be
  1775. // normalized across all browsers
  1776. // [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
  1777. var string_substr = StringPrototype.substr;
  1778. var hasNegativeSubstrBug = ''.substr && '0b'.substr(-1) !== 'b';
  1779. defineProperties(StringPrototype, {
  1780. substr: function substr(start, length) {
  1781. var normalizedStart = start;
  1782. if (start < 0) {
  1783. normalizedStart = Math.max(this.length + start, 0);
  1784. }
  1785. return string_substr.call(this, normalizedStart, length);
  1786. }
  1787. }, hasNegativeSubstrBug);
  1788. // ES5 15.5.4.20
  1789. // whitespace from: http://es5.github.io/#x15.5.4.20
  1790. var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
  1791. '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
  1792. '\u2029\uFEFF';
  1793. var zeroWidth = '\u200b';
  1794. var wsRegexChars = '[' + ws + ']';
  1795. var trimBeginRegexp = new RegExp('^' + wsRegexChars + wsRegexChars + '*');
  1796. var trimEndRegexp = new RegExp(wsRegexChars + wsRegexChars + '*$');
  1797. var hasTrimWhitespaceBug = StringPrototype.trim && (ws.trim() || !zeroWidth.trim());
  1798. defineProperties(StringPrototype, {
  1799. // http://blog.stevenlevithan.com/archives/faster-trim-javascript
  1800. // http://perfectionkills.com/whitespace-deviations/
  1801. trim: function trim() {
  1802. if (typeof this === 'undefined' || this === null) {
  1803. throw new TypeError("can't convert " + this + ' to object');
  1804. }
  1805. return String(this).replace(trimBeginRegexp, '').replace(trimEndRegexp, '');
  1806. }
  1807. }, hasTrimWhitespaceBug);
  1808. // ES-5 15.1.2.2
  1809. if (parseInt(ws + '08') !== 8 || parseInt(ws + '0x16') !== 22) {
  1810. /* global parseInt: true */
  1811. parseInt = (function (origParseInt) {
  1812. var hexRegex = /^0[xX]/;
  1813. return function parseInt(str, radix) {
  1814. var string = String(str).trim();
  1815. var defaultedRadix = Number(radix) || (hexRegex.test(string) ? 16 : 10);
  1816. return origParseInt(string, defaultedRadix);
  1817. };
  1818. }(parseInt));
  1819. }
  1820. }));
  1821. !window.addEventListener && (function (WindowPrototype, DocumentPrototype, ElementPrototype, addEventListener, removeEventListener, dispatchEvent, registry) {
  1822. WindowPrototype[addEventListener] = DocumentPrototype[addEventListener] = ElementPrototype[addEventListener] = function (type, listener) {
  1823. var target = this;
  1824. registry.unshift([target, type, listener, function (event) {
  1825. event.currentTarget = target;
  1826. event.preventDefault = function () { event.returnValue = false };
  1827. event.stopPropagation = function () { event.cancelBubble = true };
  1828. event.target = event.srcElement || target;
  1829. listener.call(target, event);
  1830. }]);
  1831. this.attachEvent("on" + type, registry[0][3]);
  1832. };
  1833. WindowPrototype[removeEventListener] = DocumentPrototype[removeEventListener] = ElementPrototype[removeEventListener] = function (type, listener) {
  1834. for (var index = 0, register; register = registry[index]; ++index) {
  1835. if (register[0] == this && register[1] == type && register[2] == listener) {
  1836. return this.detachEvent("on" + type, registry.splice(index, 1)[0][3]);
  1837. }
  1838. }
  1839. };
  1840. WindowPrototype[dispatchEvent] = DocumentPrototype[dispatchEvent] = ElementPrototype[dispatchEvent] = function (eventObject) {
  1841. return this.fireEvent("on" + eventObject.type, eventObject);
  1842. };
  1843. })(Window.prototype, HTMLDocument.prototype, Element.prototype, "addEventListener", "removeEventListener", "dispatchEvent", []);
  1844. /**
  1845. * Module: rem - v1.3.4
  1846. * Description: A polyfill to parse CSS links and rewrite pixel equivalents into head for non supporting browsers
  1847. * Date Built: 2014-07-02
  1848. * Copyright (c) 2014 | Chuck Carpenter <chuck.carpenter@me.com>,Lucas Serven <lserven@gmail.com>;
  1849. * @see https://github.com/chuckcarpenter/REM-unit-polyfill
  1850. **/
  1851. (function (window, undefined) {
  1852. "use strict";
  1853. // test for REM unit support
  1854. var cssremunit = function() {
  1855. var div = document.createElement( 'div' );
  1856. div.style.cssText = 'font-size: 1rem;';
  1857. return (/rem/).test(div.style.fontSize);
  1858. },
  1859. // filter returned links for stylesheets
  1860. isStyleSheet = function () {
  1861. var styles = document.getElementsByTagName('link'),
  1862. filteredLinks = [];
  1863. for ( var i = 0; i < styles.length; i++) {
  1864. if ( styles[i].rel.toLowerCase() === 'stylesheet' && styles[i].getAttribute('data-norem') === null ) {
  1865. filteredLinks.push( styles[i].href );
  1866. }
  1867. }
  1868. return filteredLinks;
  1869. },
  1870. processLinks = function () {
  1871. //prepare to match each link
  1872. for( var i = 0; i < links.length; i++ ){
  1873. xhr( links[i], storeCSS );
  1874. }
  1875. },
  1876. storeCSS = function ( response, link ) {
  1877. preCSS.push(response.responseText);
  1878. CSSLinks.push(link);
  1879. if( CSSLinks.length === links.length ){
  1880. for( var j = 0; j < CSSLinks.length; j++ ){
  1881. matchCSS( preCSS[j], CSSLinks[j] );
  1882. }
  1883. if( ( links = importLinks.slice(0) ).length > 0 ){ //after finishing all current links, set links equal to the new imports found
  1884. CSSLinks = [];
  1885. preCSS = [];
  1886. importLinks = [];
  1887. processLinks();
  1888. } else {
  1889. buildCSS();
  1890. }
  1891. }
  1892. },
  1893. matchCSS = function ( sheetCSS, link ) { // collect all of the rules from the xhr response texts and match them to a pattern
  1894. var clean = removeMediaQueries( sheetCSS ).replace(/\/\*[\s\S]*?\*\//g, ''), // remove MediaQueries and comments
  1895. pattern = /[\w\d\s\-\/\\\[\]:,.'"*()<>+~%#^$_=|@]+\{[\w\d\s\-\/\\%#:!;,.'"*()]+\d*\.?\d+rem[\w\d\s\-\/\\%#:!;,.'"*()]*\}/g, //find selectors that use rem in one or more of their rules
  1896. current = clean.match(pattern),
  1897. remPattern =/\d*\.?\d+rem/g,
  1898. remCurrent = clean.match(remPattern),
  1899. sheetPathPattern = /(.*\/)/,
  1900. sheetPath = sheetPathPattern.exec(link)[0], //relative path to css file specified in @import
  1901. importPattern = /@import (?:url\()?['"]?([^'\)"]*)['"]?\)?[^;]*/gm, //matches all @import variations outlined at: https://developer.mozilla.org/en-US/docs/Web/CSS/@import
  1902. importStatement;
  1903. while( (importStatement = importPattern.exec(sheetCSS)) !== null ){
  1904. if( importStatement[1].indexOf("/") === 0 ) { // check if the value of importStatement[1] is a root relative path, in which case it shouldn't be concatenated with sheetPath
  1905. importLinks.push( importStatement[1] );
  1906. } else {
  1907. importLinks.push( sheetPath + importStatement[1] );
  1908. }
  1909. }
  1910. if( current !== null && current.length !== 0 ){
  1911. found = found.concat( current ); // save all of the blocks of rules with rem in a property
  1912. foundProps = foundProps.concat( remCurrent ); // save all of the properties with rem
  1913. }
  1914. },
  1915. buildCSS = function () { // first build each individual rule from elements in the found array and then add it to the string of rules.
  1916. var pattern = /[\w\d\s\-\/\\%#:,.'"*()]+\d*\.?\d+rem[\w\d\s\-\/\\%#:!,.'"*()]*[;}]/g; // find properties with rem values in them
  1917. for( var i = 0; i < found.length; i++ ){
  1918. rules = rules + found[i].substr(0,found[i].indexOf("{")+1); // save the selector portion of each rule with a rem value
  1919. var current = found[i].match( pattern );
  1920. for( var j = 0; j<current.length; j++ ){ // build a new set of with only the selector and properties that have rem in the value
  1921. rules = rules + current[j];
  1922. if( j === current.length-1 && rules[rules.length-1] !== "}" ){
  1923. rules = rules + "\n}";
  1924. }
  1925. }
  1926. }
  1927. parseCSS();
  1928. },
  1929. parseCSS = function () { // replace each set of parentheses with evaluated content
  1930. for( var i = 0; i < foundProps.length; i++ ){
  1931. css[i] = Math.round( parseFloat(foundProps[i].substr(0,foundProps[i].length-3)*fontSize) ) + 'px';
  1932. }
  1933. loadCSS();
  1934. },
  1935. loadCSS = function () { // replace and load the new rules
  1936. for( var i = 0; i < css.length; i++ ){ // only run this loop as many times as css has entries
  1937. if( css[i] ){
  1938. rules = rules.replace( foundProps[i],css[i] ); // replace old rules with our processed rules
  1939. }
  1940. }
  1941. var remcss = document.createElement( 'style' );
  1942. remcss.setAttribute( 'type', 'text/css' );
  1943. remcss.id = 'remReplace';
  1944. document.getElementsByTagName( 'head' )[0].appendChild( remcss ); // create the new element
  1945. if( remcss.styleSheet ) {
  1946. remcss.styleSheet.cssText = rules; // IE8 will not support innerHTML on read-only elements, such as STYLE
  1947. } else {
  1948. remcss.appendChild( document.createTextNode( rules ) );
  1949. }
  1950. },
  1951. xhr = function ( url, callback ) { // create new XMLHttpRequest object and run it
  1952. try {
  1953. //try to create a request object
  1954. //arranging the two conditions this way is for IE7/8's benefit
  1955. //so that it works with any combination of ActiveX or Native XHR settings,
  1956. //as long as one or the other is enabled; but if both are enabled
  1957. //it prefers ActiveX, which means it still works with local files
  1958. //(Native XHR in IE7/8 is blocked and throws "access is denied",
  1959. // but ActiveX is permitted if the user allows it [default is to prompt])
  1960. var xhr = window.ActiveXObject ? ( new ActiveXObject('Microsoft.XMLHTTP') || new ActiveXObject('Msxml2.XMLHTTP') ) : new XMLHttpRequest();
  1961. xhr.open( 'GET', url, true );
  1962. xhr.onreadystatechange = function() {
  1963. if ( xhr.readyState === 4 ){
  1964. callback(xhr, url);
  1965. } // else { callback function on AJAX error }
  1966. };
  1967. xhr.send( null );
  1968. } catch (e){
  1969. if ( window.XDomainRequest ) {
  1970. var xdr = new XDomainRequest();
  1971. xdr.open('get', url);
  1972. xdr.onload = function() {
  1973. callback(xdr, url);
  1974. };
  1975. xdr.onerror = function() {
  1976. return false; // xdr load fail
  1977. };
  1978. xdr.send();
  1979. }
  1980. }
  1981. },
  1982. // Remove queries.
  1983. removeMediaQueries = function(css) {
  1984. // Test for Media Query support
  1985. if ( !window.matchMedia && !window.msMatchMedia ) {
  1986. // If the browser doesn't support media queries, we find all @media declarations in the CSS and remove them.
  1987. // Note: Since @rules can't be nested in the CSS spec, we're safe to just check for the closest following "}}" to the "@media".
  1988. css = css.replace(/@media[\s\S]*?\}\s*\}/g, "");
  1989. }
  1990. return css;
  1991. };
  1992. if( !cssremunit() ){ // this checks if the rem value is supported
  1993. var rules = '', // initialize the rules variable in this scope so it can be used later
  1994. links = isStyleSheet(), // initialize the array holding the sheets urls for use later
  1995. importLinks = [], //initialize the array holding the import sheet urls for use later
  1996. found = [], // initialize the array holding the found rules for use later
  1997. foundProps = [], // initialize the array holding the found properties for use later
  1998. preCSS = [], // initialize array that holds css before being parsed
  1999. CSSLinks = [], //initialize array holding css links returned from xhr
  2000. css = [], // initialize the array holding the parsed rules for use later
  2001. fontSize = '';
  2002. // Notice: rem is a "root em" that means that in case when html element size was changed by css
  2003. // or style we should not change document.documentElement.fontSize to 1em - only body size should be changed
  2004. // to 1em for calculation
  2005. fontSize = (function () {
  2006. var doc = document,
  2007. docElement = doc.documentElement,
  2008. body = doc.body || doc.createElement('body'),
  2009. isFakeBody = !doc.body,
  2010. div = doc.createElement('div'),
  2011. currentSize = body.style.fontSize,
  2012. size;
  2013. if ( isFakeBody ) {
  2014. docElement.appendChild( body );
  2015. }
  2016. div.style.cssText = 'width:1em; position:absolute; visibility:hidden; padding: 0;';
  2017. body.style.fontSize = '1em';
  2018. body.appendChild( div );
  2019. size = div.offsetWidth;
  2020. if ( isFakeBody ) {
  2021. docElement.removeChild( body );
  2022. }
  2023. else {
  2024. body.removeChild( div );
  2025. body.style.fontSize = currentSize;
  2026. }
  2027. return size;
  2028. }());
  2029. processLinks();
  2030. } // else { do nothing, you are awesome and have REM support }
  2031. })(window);
  2032. /*! Respond.js v1.4.2: min/max-width media query polyfill
  2033. * Copyright 2014 Scott Jehl
  2034. * Licensed under MIT
  2035. * http://j.mp/respondjs */
  2036. !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='&shy;<style media="'+a+'"> #mq-test-1 { width: 42px; }</style>',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){v(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))},g=function(a){return a.replace(c.regex.minmaxwh,"").match(c.regex.other)};if(c.ajax=f,c.queue=d,c.unsupportedmq=g,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,comments:/\/\*[^*]*\*+([^/][^*]*\*+)*\//gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,maxw:/\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/,minmaxwh:/\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi,other:/\([^\)]*\)/g},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var h,i,j,k=a.document,l=k.documentElement,m=[],n=[],o=[],p={},q=30,r=k.getElementsByTagName("head")[0]||l,s=k.getElementsByTagName("base")[0],t=r.getElementsByTagName("link"),u=function(){var a,b=k.createElement("div"),c=k.body,d=l.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=k.createElement("body"),c.style.background="none"),l.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&l.insertBefore(c,l.firstChild),a=b.offsetWidth,f?l.removeChild(c):c.removeChild(b),l.style.fontSize=d,e&&(c.style.fontSize=e),a=j=parseFloat(a)},v=function(b){var c="clientWidth",d=l[c],e="CSS1Compat"===k.compatMode&&d||k.body[c]||d,f={},g=t[t.length-1],p=(new Date).getTime();if(b&&h&&q>p-h)return a.clearTimeout(i),i=a.setTimeout(v,q),void 0;h=p;for(var s in m)if(m.hasOwnProperty(s)){var w=m[s],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?j||u():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?j||u():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(n[w.rules]))}for(var C in o)o.hasOwnProperty(C)&&o[C]&&o[C].parentNode===r&&r.removeChild(o[C]);o.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=k.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,r.insertBefore(E,g.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(k.createTextNode(F)),o.push(E)}},w=function(a,b,d){var e=a.replace(c.regex.comments,"").replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var h=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},i=!f&&d;b.length&&(b+="/"),i&&(f=1);for(var j=0;f>j;j++){var k,l,o,p;i?(k=d,n.push(h(a))):(k=e[j].match(c.regex.findStyles)&&RegExp.$1,n.push(RegExp.$2&&h(RegExp.$2))),o=k.split(","),p=o.length;for(var q=0;p>q;q++)l=o[q],g(l)||m.push({media:l.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:n.length-1,hasquery:l.indexOf("(")>-1,minw:l.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:l.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}v()},x=function(){if(d.length){var b=d.shift();f(b.href,function(c){w(c,b.href,b.media),p[b.href]=!0,a.setTimeout(function(){x()},0)})}},y=function(){for(var b=0;b<t.length;b++){var c=t[b],e=c.href,f=c.media,g=c.rel&&"stylesheet"===c.rel.toLowerCase();e&&g&&!p[e]&&(c.styleSheet&&c.styleSheet.rawCssText?(w(c.styleSheet.rawCssText,e,f),p[e]=!0):(!/^([a-zA-Z:]*\/\/)/.test(e)&&!s||e.replace(RegExp.$1,"").split("/")[0]===a.location.host)&&("//"===e.substring(0,2)&&(e=a.location.protocol+e),d.push({href:e,media:f})))}x()};y(),c.update=y,c.getEmValue=u,a.addEventListener?a.addEventListener("resize",b,!1):a.attachEvent&&a.attachEvent("onresize",b)}}(this);