amazeui.ie8polyfill.js 111 KB

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