noty.js 79 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124
  1. /*
  2. @package NOTY - Dependency-free notification library
  3. @version version: 3.2.0-beta
  4. @contributors https://github.com/needim/noty/graphs/contributors
  5. @documentation Examples and Documentation - https://ned.im/noty
  6. @license Licensed under the MIT licenses: http://www.opensource.org/licenses/mit-license.php
  7. */
  8. (function webpackUniversalModuleDefinition(root, factory) {
  9. if(typeof exports === 'object' && typeof module === 'object')
  10. module.exports = factory();
  11. else if(typeof define === 'function' && define.amd)
  12. define("Noty", [], factory);
  13. else if(typeof exports === 'object')
  14. exports["Noty"] = factory();
  15. else
  16. root["Noty"] = factory();
  17. })(this, function() {
  18. return /******/ (function(modules) { // webpackBootstrap
  19. /******/ // The module cache
  20. /******/ var installedModules = {};
  21. /******/
  22. /******/ // The require function
  23. /******/ function __webpack_require__(moduleId) {
  24. /******/
  25. /******/ // Check if module is in cache
  26. /******/ if(installedModules[moduleId]) {
  27. /******/ return installedModules[moduleId].exports;
  28. /******/ }
  29. /******/ // Create a new module (and put it into the cache)
  30. /******/ var module = installedModules[moduleId] = {
  31. /******/ i: moduleId,
  32. /******/ l: false,
  33. /******/ exports: {}
  34. /******/ };
  35. /******/
  36. /******/ // Execute the module function
  37. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38. /******/
  39. /******/ // Flag the module as loaded
  40. /******/ module.l = true;
  41. /******/
  42. /******/ // Return the exports of the module
  43. /******/ return module.exports;
  44. /******/ }
  45. /******/
  46. /******/
  47. /******/ // expose the modules object (__webpack_modules__)
  48. /******/ __webpack_require__.m = modules;
  49. /******/
  50. /******/ // expose the module cache
  51. /******/ __webpack_require__.c = installedModules;
  52. /******/
  53. /******/ // identity function for calling harmony imports with the correct context
  54. /******/ __webpack_require__.i = function(value) { return value; };
  55. /******/
  56. /******/ // define getter function for harmony exports
  57. /******/ __webpack_require__.d = function(exports, name, getter) {
  58. /******/ if(!__webpack_require__.o(exports, name)) {
  59. /******/ Object.defineProperty(exports, name, {
  60. /******/ configurable: false,
  61. /******/ enumerable: true,
  62. /******/ get: getter
  63. /******/ });
  64. /******/ }
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "";
  81. /******/
  82. /******/ // Load entry module and return exports
  83. /******/ return __webpack_require__(__webpack_require__.s = 6);
  84. /******/ })
  85. /************************************************************************/
  86. /******/ ([
  87. /* 0 */
  88. /***/ (function(module, exports, __webpack_require__) {
  89. "use strict";
  90. Object.defineProperty(exports, "__esModule", {
  91. value: true
  92. });
  93. exports.css = exports.deepExtend = exports.animationEndEvents = undefined;
  94. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  95. exports.inArray = inArray;
  96. exports.stopPropagation = stopPropagation;
  97. exports.generateID = generateID;
  98. exports.outerHeight = outerHeight;
  99. exports.addListener = addListener;
  100. exports.hasClass = hasClass;
  101. exports.addClass = addClass;
  102. exports.removeClass = removeClass;
  103. exports.remove = remove;
  104. exports.classList = classList;
  105. exports.visibilityChangeFlow = visibilityChangeFlow;
  106. exports.createAudioElements = createAudioElements;
  107. var _api = __webpack_require__(1);
  108. var API = _interopRequireWildcard(_api);
  109. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  110. var animationEndEvents = exports.animationEndEvents = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
  111. function inArray(needle, haystack, argStrict) {
  112. var key = void 0;
  113. var strict = !!argStrict;
  114. if (strict) {
  115. for (key in haystack) {
  116. if (haystack.hasOwnProperty(key) && haystack[key] === needle) {
  117. return true;
  118. }
  119. }
  120. } else {
  121. for (key in haystack) {
  122. if (haystack.hasOwnProperty(key) && haystack[key] === needle) {
  123. return true;
  124. }
  125. }
  126. }
  127. return false;
  128. }
  129. function stopPropagation(evt) {
  130. evt = evt || window.event;
  131. if (typeof evt.stopPropagation !== 'undefined') {
  132. evt.stopPropagation();
  133. } else {
  134. evt.cancelBubble = true;
  135. }
  136. }
  137. var deepExtend = exports.deepExtend = function deepExtend(out) {
  138. out = out || {};
  139. for (var i = 1; i < arguments.length; i++) {
  140. var obj = arguments[i];
  141. if (!obj) continue;
  142. for (var key in obj) {
  143. if (obj.hasOwnProperty(key)) {
  144. if (Array.isArray(obj[key])) {
  145. out[key] = obj[key];
  146. } else if (_typeof(obj[key]) === 'object' && obj[key] !== null) {
  147. out[key] = deepExtend(out[key], obj[key]);
  148. } else {
  149. out[key] = obj[key];
  150. }
  151. }
  152. }
  153. }
  154. return out;
  155. };
  156. function generateID() {
  157. var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  158. var id = 'noty_' + prefix + '_';
  159. id += 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  160. var r = Math.random() * 16 | 0;
  161. var v = c === 'x' ? r : r & 0x3 | 0x8;
  162. return v.toString(16);
  163. });
  164. return id;
  165. }
  166. function outerHeight(el) {
  167. var height = el.offsetHeight;
  168. var style = window.getComputedStyle(el);
  169. height += parseInt(style.marginTop) + parseInt(style.marginBottom);
  170. return height;
  171. }
  172. var css = exports.css = function () {
  173. var cssPrefixes = ['Webkit', 'O', 'Moz', 'ms'];
  174. var cssProps = {};
  175. function camelCase(string) {
  176. return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function (match, letter) {
  177. return letter.toUpperCase();
  178. });
  179. }
  180. function getVendorProp(name) {
  181. var style = document.body.style;
  182. if (name in style) return name;
  183. var i = cssPrefixes.length;
  184. var capName = name.charAt(0).toUpperCase() + name.slice(1);
  185. var vendorName = void 0;
  186. while (i--) {
  187. vendorName = cssPrefixes[i] + capName;
  188. if (vendorName in style) return vendorName;
  189. }
  190. return name;
  191. }
  192. function getStyleProp(name) {
  193. name = camelCase(name);
  194. return cssProps[name] || (cssProps[name] = getVendorProp(name));
  195. }
  196. function applyCss(element, prop, value) {
  197. prop = getStyleProp(prop);
  198. element.style[prop] = value;
  199. }
  200. return function (element, properties) {
  201. var args = arguments;
  202. var prop = void 0;
  203. var value = void 0;
  204. if (args.length === 2) {
  205. for (prop in properties) {
  206. if (properties.hasOwnProperty(prop)) {
  207. value = properties[prop];
  208. if (value !== undefined && properties.hasOwnProperty(prop)) {
  209. applyCss(element, prop, value);
  210. }
  211. }
  212. }
  213. } else {
  214. applyCss(element, args[1], args[2]);
  215. }
  216. };
  217. }();
  218. function addListener(el, events, cb) {
  219. var useCapture = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
  220. events = events.split(' ');
  221. for (var i = 0; i < events.length; i++) {
  222. if (document.addEventListener) {
  223. el.addEventListener(events[i], cb, useCapture);
  224. } else if (document.attachEvent) {
  225. el.attachEvent('on' + events[i], cb);
  226. }
  227. }
  228. }
  229. function hasClass(element, name) {
  230. var list = typeof element === 'string' ? element : classList(element);
  231. return list.indexOf(' ' + name + ' ') >= 0;
  232. }
  233. function addClass(element, name) {
  234. var oldList = classList(element);
  235. var newList = oldList + name;
  236. if (hasClass(oldList, name)) return;
  237. // Trim the opening space.
  238. element.className = newList.substring(1);
  239. }
  240. function removeClass(element, name) {
  241. var oldList = classList(element);
  242. var newList = void 0;
  243. if (!hasClass(element, name)) return;
  244. // Replace the class name.
  245. newList = oldList.replace(' ' + name + ' ', ' ');
  246. // Trim the opening and closing spaces.
  247. element.className = newList.substring(1, newList.length - 1);
  248. }
  249. function remove(element) {
  250. if (element.parentNode) {
  251. element.parentNode.removeChild(element);
  252. }
  253. }
  254. function classList(element) {
  255. return (' ' + (element && element.className || '') + ' ').replace(/\s+/gi, ' ');
  256. }
  257. function visibilityChangeFlow() {
  258. var hidden = void 0;
  259. var visibilityChange = void 0;
  260. if (typeof document.hidden !== 'undefined') {
  261. // Opera 12.10 and Firefox 18 and later support
  262. hidden = 'hidden';
  263. visibilityChange = 'visibilitychange';
  264. } else if (typeof document.msHidden !== 'undefined') {
  265. hidden = 'msHidden';
  266. visibilityChange = 'msvisibilitychange';
  267. } else if (typeof document.webkitHidden !== 'undefined') {
  268. hidden = 'webkitHidden';
  269. visibilityChange = 'webkitvisibilitychange';
  270. }
  271. function onVisibilityChange() {
  272. API.PageHidden = document[hidden];
  273. handleVisibilityChange();
  274. }
  275. function onBlur() {
  276. API.PageHidden = true;
  277. handleVisibilityChange();
  278. }
  279. function onFocus() {
  280. API.PageHidden = false;
  281. handleVisibilityChange();
  282. }
  283. function handleVisibilityChange() {
  284. if (API.PageHidden) stopAll();else resumeAll();
  285. }
  286. function stopAll() {
  287. setTimeout(function () {
  288. Object.keys(API.Store).forEach(function (id) {
  289. if (API.Store.hasOwnProperty(id)) {
  290. if (API.Store[id].options.visibilityControl) {
  291. API.Store[id].stop();
  292. }
  293. }
  294. });
  295. }, 100);
  296. }
  297. function resumeAll() {
  298. setTimeout(function () {
  299. Object.keys(API.Store).forEach(function (id) {
  300. if (API.Store.hasOwnProperty(id)) {
  301. if (API.Store[id].options.visibilityControl) {
  302. API.Store[id].resume();
  303. }
  304. }
  305. });
  306. API.queueRenderAll();
  307. }, 100);
  308. }
  309. if (visibilityChange) {
  310. addListener(document, visibilityChange, onVisibilityChange);
  311. }
  312. addListener(window, 'blur', onBlur);
  313. addListener(window, 'focus', onFocus);
  314. }
  315. function createAudioElements(ref) {
  316. if (ref.hasSound) {
  317. var audioElement = document.createElement('audio');
  318. ref.options.sounds.sources.forEach(function (s) {
  319. var source = document.createElement('source');
  320. source.src = s;
  321. source.type = 'audio/' + getExtension(s);
  322. audioElement.appendChild(source);
  323. });
  324. if (ref.barDom) {
  325. ref.barDom.appendChild(audioElement);
  326. } else {
  327. document.querySelector('body').appendChild(audioElement);
  328. }
  329. audioElement.volume = ref.options.sounds.volume;
  330. if (!ref.soundPlayed) {
  331. audioElement.play();
  332. ref.soundPlayed = true;
  333. }
  334. audioElement.onended = function () {
  335. remove(audioElement);
  336. };
  337. }
  338. }
  339. function getExtension(fileName) {
  340. return fileName.match(/\.([^.]+)$/)[1];
  341. }
  342. /***/ }),
  343. /* 1 */
  344. /***/ (function(module, exports, __webpack_require__) {
  345. "use strict";
  346. Object.defineProperty(exports, "__esModule", {
  347. value: true
  348. });
  349. exports.Defaults = exports.Store = exports.Queues = exports.DefaultMaxVisible = exports.docTitle = exports.DocModalCount = exports.PageHidden = undefined;
  350. exports.getQueueCounts = getQueueCounts;
  351. exports.addToQueue = addToQueue;
  352. exports.removeFromQueue = removeFromQueue;
  353. exports.queueRender = queueRender;
  354. exports.queueRenderAll = queueRenderAll;
  355. exports.ghostFix = ghostFix;
  356. exports.build = build;
  357. exports.hasButtons = hasButtons;
  358. exports.handleModal = handleModal;
  359. exports.handleModalClose = handleModalClose;
  360. exports.queueClose = queueClose;
  361. exports.dequeueClose = dequeueClose;
  362. exports.fire = fire;
  363. exports.openFlow = openFlow;
  364. exports.closeFlow = closeFlow;
  365. var _utils = __webpack_require__(0);
  366. var Utils = _interopRequireWildcard(_utils);
  367. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  368. var PageHidden = exports.PageHidden = false;
  369. var DocModalCount = exports.DocModalCount = 0;
  370. var DocTitleProps = {
  371. originalTitle: null,
  372. count: 0,
  373. changed: false,
  374. timer: -1
  375. };
  376. var docTitle = exports.docTitle = {
  377. increment: function increment() {
  378. DocTitleProps.count++;
  379. docTitle._update();
  380. },
  381. decrement: function decrement() {
  382. DocTitleProps.count--;
  383. if (DocTitleProps.count <= 0) {
  384. docTitle._clear();
  385. return;
  386. }
  387. docTitle._update();
  388. },
  389. _update: function _update() {
  390. var title = document.title;
  391. if (!DocTitleProps.changed) {
  392. DocTitleProps.originalTitle = title;
  393. document.title = '(' + DocTitleProps.count + ') ' + title;
  394. DocTitleProps.changed = true;
  395. } else {
  396. document.title = '(' + DocTitleProps.count + ') ' + DocTitleProps.originalTitle;
  397. }
  398. },
  399. _clear: function _clear() {
  400. if (DocTitleProps.changed) {
  401. DocTitleProps.count = 0;
  402. document.title = DocTitleProps.originalTitle;
  403. DocTitleProps.changed = false;
  404. }
  405. }
  406. };
  407. var DefaultMaxVisible = exports.DefaultMaxVisible = 5;
  408. var Queues = exports.Queues = {
  409. global: {
  410. maxVisible: DefaultMaxVisible,
  411. queue: []
  412. }
  413. };
  414. var Store = exports.Store = {};
  415. var Defaults = exports.Defaults = {
  416. type: 'alert',
  417. layout: 'topRight',
  418. theme: 'mint',
  419. text: '',
  420. timeout: false,
  421. progressBar: true,
  422. closeWith: ['click'],
  423. animation: {
  424. open: 'noty_effects_open',
  425. close: 'noty_effects_close'
  426. },
  427. id: false,
  428. force: false,
  429. killer: false,
  430. queue: 'global',
  431. container: false,
  432. buttons: [],
  433. callbacks: {
  434. beforeShow: null,
  435. onShow: null,
  436. afterShow: null,
  437. onClose: null,
  438. afterClose: null,
  439. onClick: null,
  440. onHover: null,
  441. onTemplate: null
  442. },
  443. sounds: {
  444. sources: [],
  445. volume: 1,
  446. conditions: []
  447. },
  448. titleCount: {
  449. conditions: []
  450. },
  451. modal: false,
  452. visibilityControl: false
  453. /**
  454. * @param {string} queueName
  455. * @return {object}
  456. */
  457. };function getQueueCounts() {
  458. var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'global';
  459. var count = 0;
  460. var max = DefaultMaxVisible;
  461. if (Queues.hasOwnProperty(queueName)) {
  462. max = Queues[queueName].maxVisible;
  463. Object.keys(Store).forEach(function (i) {
  464. if (Store[i].options.queue === queueName && !Store[i].closed) count++;
  465. });
  466. }
  467. return {
  468. current: count,
  469. maxVisible: max
  470. };
  471. }
  472. /**
  473. * @param {Noty} ref
  474. * @return {void}
  475. */
  476. function addToQueue(ref) {
  477. if (!Queues.hasOwnProperty(ref.options.queue)) {
  478. Queues[ref.options.queue] = { maxVisible: DefaultMaxVisible, queue: [] };
  479. }
  480. Queues[ref.options.queue].queue.push(ref);
  481. }
  482. /**
  483. * @param {Noty} ref
  484. * @return {void}
  485. */
  486. function removeFromQueue(ref) {
  487. if (Queues.hasOwnProperty(ref.options.queue)) {
  488. var queue = [];
  489. Object.keys(Queues[ref.options.queue].queue).forEach(function (i) {
  490. if (Queues[ref.options.queue].queue[i].id !== ref.id) {
  491. queue.push(Queues[ref.options.queue].queue[i]);
  492. }
  493. });
  494. Queues[ref.options.queue].queue = queue;
  495. }
  496. }
  497. /**
  498. * @param {string} queueName
  499. * @return {void}
  500. */
  501. function queueRender() {
  502. var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'global';
  503. if (Queues.hasOwnProperty(queueName)) {
  504. var noty = Queues[queueName].queue.shift();
  505. if (noty) noty.show();
  506. }
  507. }
  508. /**
  509. * @return {void}
  510. */
  511. function queueRenderAll() {
  512. Object.keys(Queues).forEach(function (queueName) {
  513. queueRender(queueName);
  514. });
  515. }
  516. /**
  517. * @param {Noty} ref
  518. * @return {void}
  519. */
  520. function ghostFix(ref) {
  521. var ghostID = Utils.generateID('ghost');
  522. var ghost = document.createElement('div');
  523. ghost.setAttribute('id', ghostID);
  524. Utils.css(ghost, {
  525. height: Utils.outerHeight(ref.barDom) + 'px'
  526. });
  527. ref.barDom.insertAdjacentHTML('afterend', ghost.outerHTML);
  528. Utils.remove(ref.barDom);
  529. ghost = document.getElementById(ghostID);
  530. Utils.addClass(ghost, 'noty_fix_effects_height');
  531. Utils.addListener(ghost, Utils.animationEndEvents, function () {
  532. Utils.remove(ghost);
  533. });
  534. }
  535. /**
  536. * @param {Noty} ref
  537. * @return {void}
  538. */
  539. function build(ref) {
  540. findOrCreateContainer(ref);
  541. var markup = '<div class="noty_body">' + ref.options.text + '</div>' + buildButtons(ref) + '<div class="noty_progressbar"></div>';
  542. ref.barDom = document.createElement('div');
  543. ref.barDom.setAttribute('id', ref.id);
  544. Utils.addClass(ref.barDom, 'noty_bar noty_type__' + ref.options.type + ' noty_theme__' + ref.options.theme);
  545. ref.barDom.innerHTML = markup;
  546. fire(ref, 'onTemplate');
  547. }
  548. /**
  549. * @param {Noty} ref
  550. * @return {boolean}
  551. */
  552. function hasButtons(ref) {
  553. return !!(ref.options.buttons && Object.keys(ref.options.buttons).length);
  554. }
  555. /**
  556. * @param {Noty} ref
  557. * @return {string}
  558. */
  559. function buildButtons(ref) {
  560. if (hasButtons(ref)) {
  561. var buttons = document.createElement('div');
  562. Utils.addClass(buttons, 'noty_buttons');
  563. Object.keys(ref.options.buttons).forEach(function (key) {
  564. buttons.appendChild(ref.options.buttons[key].dom);
  565. });
  566. ref.options.buttons.forEach(function (btn) {
  567. buttons.appendChild(btn.dom);
  568. });
  569. return buttons.outerHTML;
  570. }
  571. return '';
  572. }
  573. /**
  574. * @param {Noty} ref
  575. * @return {void}
  576. */
  577. function handleModal(ref) {
  578. if (ref.options.modal) {
  579. if (DocModalCount === 0) {
  580. createModal(ref);
  581. }
  582. exports.DocModalCount = DocModalCount += 1;
  583. }
  584. }
  585. /**
  586. * @param {Noty} ref
  587. * @return {void}
  588. */
  589. function handleModalClose(ref) {
  590. if (ref.options.modal && DocModalCount > 0) {
  591. exports.DocModalCount = DocModalCount -= 1;
  592. if (DocModalCount <= 0) {
  593. var modal = document.querySelector('.noty_modal');
  594. if (modal) {
  595. Utils.removeClass(modal, 'noty_modal_open');
  596. Utils.addClass(modal, 'noty_modal_close');
  597. Utils.addListener(modal, Utils.animationEndEvents, function () {
  598. Utils.remove(modal);
  599. });
  600. }
  601. }
  602. }
  603. }
  604. /**
  605. * @return {void}
  606. */
  607. function createModal() {
  608. var body = document.querySelector('body');
  609. var modal = document.createElement('div');
  610. Utils.addClass(modal, 'noty_modal');
  611. body.insertBefore(modal, body.firstChild);
  612. Utils.addClass(modal, 'noty_modal_open');
  613. Utils.addListener(modal, Utils.animationEndEvents, function () {
  614. Utils.removeClass(modal, 'noty_modal_open');
  615. });
  616. }
  617. /**
  618. * @param {Noty} ref
  619. * @return {void}
  620. */
  621. function findOrCreateContainer(ref) {
  622. if (ref.options.container) {
  623. ref.layoutDom = document.querySelector(ref.options.container);
  624. return;
  625. }
  626. var layoutID = 'noty_layout__' + ref.options.layout;
  627. ref.layoutDom = document.querySelector('div#' + layoutID);
  628. if (!ref.layoutDom) {
  629. ref.layoutDom = document.createElement('div');
  630. ref.layoutDom.setAttribute('id', layoutID);
  631. ref.layoutDom.setAttribute('role', 'alert');
  632. ref.layoutDom.setAttribute('aria-live', 'polite');
  633. Utils.addClass(ref.layoutDom, 'noty_layout');
  634. document.querySelector('body').appendChild(ref.layoutDom);
  635. }
  636. }
  637. /**
  638. * @param {Noty} ref
  639. * @return {void}
  640. */
  641. function queueClose(ref) {
  642. if (ref.options.timeout) {
  643. if (ref.options.progressBar && ref.progressDom) {
  644. Utils.css(ref.progressDom, {
  645. transition: 'width ' + ref.options.timeout + 'ms linear',
  646. width: '0%'
  647. });
  648. }
  649. clearTimeout(ref.closeTimer);
  650. ref.closeTimer = setTimeout(function () {
  651. ref.close();
  652. }, ref.options.timeout);
  653. }
  654. }
  655. /**
  656. * @param {Noty} ref
  657. * @return {void}
  658. */
  659. function dequeueClose(ref) {
  660. if (ref.options.timeout && ref.closeTimer) {
  661. clearTimeout(ref.closeTimer);
  662. ref.closeTimer = -1;
  663. if (ref.options.progressBar && ref.progressDom) {
  664. Utils.css(ref.progressDom, {
  665. transition: 'width 0ms linear',
  666. width: '100%'
  667. });
  668. }
  669. }
  670. }
  671. /**
  672. * @param {Noty} ref
  673. * @param {string} eventName
  674. * @return {void}
  675. */
  676. function fire(ref, eventName) {
  677. if (ref.listeners.hasOwnProperty(eventName)) {
  678. ref.listeners[eventName].forEach(function (cb) {
  679. if (typeof cb === 'function') {
  680. cb.apply(ref);
  681. }
  682. });
  683. }
  684. }
  685. /**
  686. * @param {Noty} ref
  687. * @return {void}
  688. */
  689. function openFlow(ref) {
  690. fire(ref, 'afterShow');
  691. queueClose(ref);
  692. Utils.addListener(ref.barDom, 'mouseenter', function () {
  693. dequeueClose(ref);
  694. });
  695. Utils.addListener(ref.barDom, 'mouseleave', function () {
  696. queueClose(ref);
  697. });
  698. }
  699. /**
  700. * @param {Noty} ref
  701. * @return {void}
  702. */
  703. function closeFlow(ref) {
  704. delete Store[ref.id];
  705. ref.closing = false;
  706. fire(ref, 'afterClose');
  707. Utils.remove(ref.barDom);
  708. if (ref.layoutDom.querySelectorAll('.noty_bar').length === 0 && !ref.options.container) {
  709. Utils.remove(ref.layoutDom);
  710. }
  711. if (Utils.inArray('docVisible', ref.options.titleCount.conditions) || Utils.inArray('docHidden', ref.options.titleCount.conditions)) {
  712. docTitle.decrement();
  713. }
  714. queueRender(ref.options.queue);
  715. }
  716. /***/ }),
  717. /* 2 */
  718. /***/ (function(module, exports, __webpack_require__) {
  719. "use strict";
  720. Object.defineProperty(exports, "__esModule", {
  721. value: true
  722. });
  723. exports.NotyButton = undefined;
  724. var _utils = __webpack_require__(0);
  725. var Utils = _interopRequireWildcard(_utils);
  726. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  727. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  728. var NotyButton = exports.NotyButton = function NotyButton(html, classes, cb) {
  729. var _this = this;
  730. var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  731. _classCallCheck(this, NotyButton);
  732. this.dom = document.createElement('button');
  733. this.dom.innerHTML = html;
  734. this.id = attributes.id = attributes.id || Utils.generateID('button');
  735. this.cb = cb;
  736. Object.keys(attributes).forEach(function (propertyName) {
  737. _this.dom.setAttribute(propertyName, attributes[propertyName]);
  738. });
  739. Utils.addClass(this.dom, classes || 'noty_btn');
  740. return this;
  741. };
  742. /***/ }),
  743. /* 3 */
  744. /***/ (function(module, exports, __webpack_require__) {
  745. "use strict";
  746. Object.defineProperty(exports, "__esModule", {
  747. value: true
  748. });
  749. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  750. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  751. var Push = exports.Push = function () {
  752. function Push() {
  753. var workerPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/service-worker.js';
  754. _classCallCheck(this, Push);
  755. this.subData = {};
  756. this.workerPath = workerPath;
  757. this.listeners = {
  758. onPermissionGranted: [],
  759. onPermissionDenied: [],
  760. onSubscriptionSuccess: [],
  761. onSubscriptionCancel: [],
  762. onWorkerError: [],
  763. onWorkerSuccess: [],
  764. onWorkerNotSupported: []
  765. };
  766. return this;
  767. }
  768. /**
  769. * @param {string} eventName
  770. * @param {function} cb
  771. * @return {Push}
  772. */
  773. _createClass(Push, [{
  774. key: 'on',
  775. value: function on(eventName) {
  776. var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
  777. if (typeof cb === 'function' && this.listeners.hasOwnProperty(eventName)) {
  778. this.listeners[eventName].push(cb);
  779. }
  780. return this;
  781. }
  782. }, {
  783. key: 'fire',
  784. value: function fire(eventName) {
  785. var _this = this;
  786. var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  787. if (this.listeners.hasOwnProperty(eventName)) {
  788. this.listeners[eventName].forEach(function (cb) {
  789. if (typeof cb === 'function') {
  790. cb.apply(_this, params);
  791. }
  792. });
  793. }
  794. }
  795. }, {
  796. key: 'create',
  797. value: function create() {
  798. console.log('NOT IMPLEMENTED YET');
  799. }
  800. /**
  801. * @return {boolean}
  802. */
  803. }, {
  804. key: 'isSupported',
  805. value: function isSupported() {
  806. var result = false;
  807. try {
  808. result = window.Notification || window.webkitNotifications || navigator.mozNotification || window.external && window.external.msIsSiteMode() !== undefined;
  809. } catch (e) {}
  810. return result;
  811. }
  812. /**
  813. * @return {string}
  814. */
  815. }, {
  816. key: 'getPermissionStatus',
  817. value: function getPermissionStatus() {
  818. var perm = 'default';
  819. if (window.Notification && window.Notification.permissionLevel) {
  820. perm = window.Notification.permissionLevel;
  821. } else if (window.webkitNotifications && window.webkitNotifications.checkPermission) {
  822. switch (window.webkitNotifications.checkPermission()) {
  823. case 1:
  824. perm = 'default';
  825. break;
  826. case 0:
  827. perm = 'granted';
  828. break;
  829. default:
  830. perm = 'denied';
  831. }
  832. } else if (window.Notification && window.Notification.permission) {
  833. perm = window.Notification.permission;
  834. } else if (navigator.mozNotification) {
  835. perm = 'granted';
  836. } else if (window.external && window.external.msIsSiteMode() !== undefined) {
  837. perm = window.external.msIsSiteMode() ? 'granted' : 'default';
  838. }
  839. return perm.toString().toLowerCase();
  840. }
  841. /**
  842. * @return {string}
  843. */
  844. }, {
  845. key: 'getEndpoint',
  846. value: function getEndpoint(subscription) {
  847. var endpoint = subscription.endpoint;
  848. var subscriptionId = subscription.subscriptionId;
  849. // fix for Chrome < 45
  850. if (subscriptionId && endpoint.indexOf(subscriptionId) === -1) {
  851. endpoint += '/' + subscriptionId;
  852. }
  853. return endpoint;
  854. }
  855. /**
  856. * @return {boolean}
  857. */
  858. }, {
  859. key: 'isSWRegistered',
  860. value: function isSWRegistered() {
  861. try {
  862. return navigator.serviceWorker.controller.state === 'activated';
  863. } catch (e) {
  864. return false;
  865. }
  866. }
  867. /**
  868. * @return {void}
  869. */
  870. }, {
  871. key: 'unregisterWorker',
  872. value: function unregisterWorker() {
  873. var self = this;
  874. if ('serviceWorker' in navigator) {
  875. navigator.serviceWorker.getRegistrations().then(function (registrations) {
  876. var _iteratorNormalCompletion = true;
  877. var _didIteratorError = false;
  878. var _iteratorError = undefined;
  879. try {
  880. for (var _iterator = registrations[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
  881. var registration = _step.value;
  882. registration.unregister();
  883. self.fire('onSubscriptionCancel');
  884. }
  885. } catch (err) {
  886. _didIteratorError = true;
  887. _iteratorError = err;
  888. } finally {
  889. try {
  890. if (!_iteratorNormalCompletion && _iterator.return) {
  891. _iterator.return();
  892. }
  893. } finally {
  894. if (_didIteratorError) {
  895. throw _iteratorError;
  896. }
  897. }
  898. }
  899. });
  900. }
  901. }
  902. /**
  903. * @return {void}
  904. */
  905. }, {
  906. key: 'requestSubscription',
  907. value: function requestSubscription() {
  908. var _this2 = this;
  909. var userVisibleOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
  910. var self = this;
  911. var current = this.getPermissionStatus();
  912. var cb = function cb(result) {
  913. if (result === 'granted') {
  914. _this2.fire('onPermissionGranted');
  915. if ('serviceWorker' in navigator) {
  916. navigator.serviceWorker.register(_this2.workerPath).then(function () {
  917. navigator.serviceWorker.ready.then(function (serviceWorkerRegistration) {
  918. self.fire('onWorkerSuccess');
  919. serviceWorkerRegistration.pushManager.subscribe({
  920. userVisibleOnly: userVisibleOnly
  921. }).then(function (subscription) {
  922. var key = subscription.getKey('p256dh');
  923. var token = subscription.getKey('auth');
  924. self.subData = {
  925. endpoint: self.getEndpoint(subscription),
  926. p256dh: key ? window.btoa(String.fromCharCode.apply(null, new Uint8Array(key))) : null,
  927. auth: token ? window.btoa(String.fromCharCode.apply(null, new Uint8Array(token))) : null
  928. };
  929. self.fire('onSubscriptionSuccess', [self.subData]);
  930. }).catch(function (err) {
  931. self.fire('onWorkerError', [err]);
  932. });
  933. });
  934. });
  935. } else {
  936. self.fire('onWorkerNotSupported');
  937. }
  938. } else if (result === 'denied') {
  939. _this2.fire('onPermissionDenied');
  940. _this2.unregisterWorker();
  941. }
  942. };
  943. if (current === 'default') {
  944. if (window.Notification && window.Notification.requestPermission) {
  945. window.Notification.requestPermission(cb);
  946. } else if (window.webkitNotifications && window.webkitNotifications.checkPermission) {
  947. window.webkitNotifications.requestPermission(cb);
  948. }
  949. } else {
  950. cb(current);
  951. }
  952. }
  953. }]);
  954. return Push;
  955. }();
  956. /***/ }),
  957. /* 4 */
  958. /***/ (function(module, exports, __webpack_require__) {
  959. /* WEBPACK VAR INJECTION */(function(process, global) {var require;/*!
  960. * @overview es6-promise - a tiny implementation of Promises/A+.
  961. * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
  962. * @license Licensed under MIT license
  963. * See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
  964. * @version 4.1.1
  965. */
  966. (function (global, factory) {
  967. true ? module.exports = factory() :
  968. typeof define === 'function' && define.amd ? define(factory) :
  969. (global.ES6Promise = factory());
  970. }(this, (function () { 'use strict';
  971. function objectOrFunction(x) {
  972. var type = typeof x;
  973. return x !== null && (type === 'object' || type === 'function');
  974. }
  975. function isFunction(x) {
  976. return typeof x === 'function';
  977. }
  978. var _isArray = undefined;
  979. if (Array.isArray) {
  980. _isArray = Array.isArray;
  981. } else {
  982. _isArray = function (x) {
  983. return Object.prototype.toString.call(x) === '[object Array]';
  984. };
  985. }
  986. var isArray = _isArray;
  987. var len = 0;
  988. var vertxNext = undefined;
  989. var customSchedulerFn = undefined;
  990. var asap = function asap(callback, arg) {
  991. queue[len] = callback;
  992. queue[len + 1] = arg;
  993. len += 2;
  994. if (len === 2) {
  995. // If len is 2, that means that we need to schedule an async flush.
  996. // If additional callbacks are queued before the queue is flushed, they
  997. // will be processed by this flush that we are scheduling.
  998. if (customSchedulerFn) {
  999. customSchedulerFn(flush);
  1000. } else {
  1001. scheduleFlush();
  1002. }
  1003. }
  1004. };
  1005. function setScheduler(scheduleFn) {
  1006. customSchedulerFn = scheduleFn;
  1007. }
  1008. function setAsap(asapFn) {
  1009. asap = asapFn;
  1010. }
  1011. var browserWindow = typeof window !== 'undefined' ? window : undefined;
  1012. var browserGlobal = browserWindow || {};
  1013. var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
  1014. var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
  1015. // test for web worker but not in IE10
  1016. var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
  1017. // node
  1018. function useNextTick() {
  1019. // node version 0.10.x displays a deprecation warning when nextTick is used recursively
  1020. // see https://github.com/cujojs/when/issues/410 for details
  1021. return function () {
  1022. return process.nextTick(flush);
  1023. };
  1024. }
  1025. // vertx
  1026. function useVertxTimer() {
  1027. if (typeof vertxNext !== 'undefined') {
  1028. return function () {
  1029. vertxNext(flush);
  1030. };
  1031. }
  1032. return useSetTimeout();
  1033. }
  1034. function useMutationObserver() {
  1035. var iterations = 0;
  1036. var observer = new BrowserMutationObserver(flush);
  1037. var node = document.createTextNode('');
  1038. observer.observe(node, { characterData: true });
  1039. return function () {
  1040. node.data = iterations = ++iterations % 2;
  1041. };
  1042. }
  1043. // web worker
  1044. function useMessageChannel() {
  1045. var channel = new MessageChannel();
  1046. channel.port1.onmessage = flush;
  1047. return function () {
  1048. return channel.port2.postMessage(0);
  1049. };
  1050. }
  1051. function useSetTimeout() {
  1052. // Store setTimeout reference so es6-promise will be unaffected by
  1053. // other code modifying setTimeout (like sinon.useFakeTimers())
  1054. var globalSetTimeout = setTimeout;
  1055. return function () {
  1056. return globalSetTimeout(flush, 1);
  1057. };
  1058. }
  1059. var queue = new Array(1000);
  1060. function flush() {
  1061. for (var i = 0; i < len; i += 2) {
  1062. var callback = queue[i];
  1063. var arg = queue[i + 1];
  1064. callback(arg);
  1065. queue[i] = undefined;
  1066. queue[i + 1] = undefined;
  1067. }
  1068. len = 0;
  1069. }
  1070. function attemptVertx() {
  1071. try {
  1072. var r = require;
  1073. var vertx = __webpack_require__(9);
  1074. vertxNext = vertx.runOnLoop || vertx.runOnContext;
  1075. return useVertxTimer();
  1076. } catch (e) {
  1077. return useSetTimeout();
  1078. }
  1079. }
  1080. var scheduleFlush = undefined;
  1081. // Decide what async method to use to triggering processing of queued callbacks:
  1082. if (isNode) {
  1083. scheduleFlush = useNextTick();
  1084. } else if (BrowserMutationObserver) {
  1085. scheduleFlush = useMutationObserver();
  1086. } else if (isWorker) {
  1087. scheduleFlush = useMessageChannel();
  1088. } else if (browserWindow === undefined && "function" === 'function') {
  1089. scheduleFlush = attemptVertx();
  1090. } else {
  1091. scheduleFlush = useSetTimeout();
  1092. }
  1093. function then(onFulfillment, onRejection) {
  1094. var _arguments = arguments;
  1095. var parent = this;
  1096. var child = new this.constructor(noop);
  1097. if (child[PROMISE_ID] === undefined) {
  1098. makePromise(child);
  1099. }
  1100. var _state = parent._state;
  1101. if (_state) {
  1102. (function () {
  1103. var callback = _arguments[_state - 1];
  1104. asap(function () {
  1105. return invokeCallback(_state, child, callback, parent._result);
  1106. });
  1107. })();
  1108. } else {
  1109. subscribe(parent, child, onFulfillment, onRejection);
  1110. }
  1111. return child;
  1112. }
  1113. /**
  1114. `Promise.resolve` returns a promise that will become resolved with the
  1115. passed `value`. It is shorthand for the following:
  1116. ```javascript
  1117. let promise = new Promise(function(resolve, reject){
  1118. resolve(1);
  1119. });
  1120. promise.then(function(value){
  1121. // value === 1
  1122. });
  1123. ```
  1124. Instead of writing the above, your code now simply becomes the following:
  1125. ```javascript
  1126. let promise = Promise.resolve(1);
  1127. promise.then(function(value){
  1128. // value === 1
  1129. });
  1130. ```
  1131. @method resolve
  1132. @static
  1133. @param {Any} value value that the returned promise will be resolved with
  1134. Useful for tooling.
  1135. @return {Promise} a promise that will become fulfilled with the given
  1136. `value`
  1137. */
  1138. function resolve$1(object) {
  1139. /*jshint validthis:true */
  1140. var Constructor = this;
  1141. if (object && typeof object === 'object' && object.constructor === Constructor) {
  1142. return object;
  1143. }
  1144. var promise = new Constructor(noop);
  1145. resolve(promise, object);
  1146. return promise;
  1147. }
  1148. var PROMISE_ID = Math.random().toString(36).substring(16);
  1149. function noop() {}
  1150. var PENDING = void 0;
  1151. var FULFILLED = 1;
  1152. var REJECTED = 2;
  1153. var GET_THEN_ERROR = new ErrorObject();
  1154. function selfFulfillment() {
  1155. return new TypeError("You cannot resolve a promise with itself");
  1156. }
  1157. function cannotReturnOwn() {
  1158. return new TypeError('A promises callback cannot return that same promise.');
  1159. }
  1160. function getThen(promise) {
  1161. try {
  1162. return promise.then;
  1163. } catch (error) {
  1164. GET_THEN_ERROR.error = error;
  1165. return GET_THEN_ERROR;
  1166. }
  1167. }
  1168. function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
  1169. try {
  1170. then$$1.call(value, fulfillmentHandler, rejectionHandler);
  1171. } catch (e) {
  1172. return e;
  1173. }
  1174. }
  1175. function handleForeignThenable(promise, thenable, then$$1) {
  1176. asap(function (promise) {
  1177. var sealed = false;
  1178. var error = tryThen(then$$1, thenable, function (value) {
  1179. if (sealed) {
  1180. return;
  1181. }
  1182. sealed = true;
  1183. if (thenable !== value) {
  1184. resolve(promise, value);
  1185. } else {
  1186. fulfill(promise, value);
  1187. }
  1188. }, function (reason) {
  1189. if (sealed) {
  1190. return;
  1191. }
  1192. sealed = true;
  1193. reject(promise, reason);
  1194. }, 'Settle: ' + (promise._label || ' unknown promise'));
  1195. if (!sealed && error) {
  1196. sealed = true;
  1197. reject(promise, error);
  1198. }
  1199. }, promise);
  1200. }
  1201. function handleOwnThenable(promise, thenable) {
  1202. if (thenable._state === FULFILLED) {
  1203. fulfill(promise, thenable._result);
  1204. } else if (thenable._state === REJECTED) {
  1205. reject(promise, thenable._result);
  1206. } else {
  1207. subscribe(thenable, undefined, function (value) {
  1208. return resolve(promise, value);
  1209. }, function (reason) {
  1210. return reject(promise, reason);
  1211. });
  1212. }
  1213. }
  1214. function handleMaybeThenable(promise, maybeThenable, then$$1) {
  1215. if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
  1216. handleOwnThenable(promise, maybeThenable);
  1217. } else {
  1218. if (then$$1 === GET_THEN_ERROR) {
  1219. reject(promise, GET_THEN_ERROR.error);
  1220. GET_THEN_ERROR.error = null;
  1221. } else if (then$$1 === undefined) {
  1222. fulfill(promise, maybeThenable);
  1223. } else if (isFunction(then$$1)) {
  1224. handleForeignThenable(promise, maybeThenable, then$$1);
  1225. } else {
  1226. fulfill(promise, maybeThenable);
  1227. }
  1228. }
  1229. }
  1230. function resolve(promise, value) {
  1231. if (promise === value) {
  1232. reject(promise, selfFulfillment());
  1233. } else if (objectOrFunction(value)) {
  1234. handleMaybeThenable(promise, value, getThen(value));
  1235. } else {
  1236. fulfill(promise, value);
  1237. }
  1238. }
  1239. function publishRejection(promise) {
  1240. if (promise._onerror) {
  1241. promise._onerror(promise._result);
  1242. }
  1243. publish(promise);
  1244. }
  1245. function fulfill(promise, value) {
  1246. if (promise._state !== PENDING) {
  1247. return;
  1248. }
  1249. promise._result = value;
  1250. promise._state = FULFILLED;
  1251. if (promise._subscribers.length !== 0) {
  1252. asap(publish, promise);
  1253. }
  1254. }
  1255. function reject(promise, reason) {
  1256. if (promise._state !== PENDING) {
  1257. return;
  1258. }
  1259. promise._state = REJECTED;
  1260. promise._result = reason;
  1261. asap(publishRejection, promise);
  1262. }
  1263. function subscribe(parent, child, onFulfillment, onRejection) {
  1264. var _subscribers = parent._subscribers;
  1265. var length = _subscribers.length;
  1266. parent._onerror = null;
  1267. _subscribers[length] = child;
  1268. _subscribers[length + FULFILLED] = onFulfillment;
  1269. _subscribers[length + REJECTED] = onRejection;
  1270. if (length === 0 && parent._state) {
  1271. asap(publish, parent);
  1272. }
  1273. }
  1274. function publish(promise) {
  1275. var subscribers = promise._subscribers;
  1276. var settled = promise._state;
  1277. if (subscribers.length === 0) {
  1278. return;
  1279. }
  1280. var child = undefined,
  1281. callback = undefined,
  1282. detail = promise._result;
  1283. for (var i = 0; i < subscribers.length; i += 3) {
  1284. child = subscribers[i];
  1285. callback = subscribers[i + settled];
  1286. if (child) {
  1287. invokeCallback(settled, child, callback, detail);
  1288. } else {
  1289. callback(detail);
  1290. }
  1291. }
  1292. promise._subscribers.length = 0;
  1293. }
  1294. function ErrorObject() {
  1295. this.error = null;
  1296. }
  1297. var TRY_CATCH_ERROR = new ErrorObject();
  1298. function tryCatch(callback, detail) {
  1299. try {
  1300. return callback(detail);
  1301. } catch (e) {
  1302. TRY_CATCH_ERROR.error = e;
  1303. return TRY_CATCH_ERROR;
  1304. }
  1305. }
  1306. function invokeCallback(settled, promise, callback, detail) {
  1307. var hasCallback = isFunction(callback),
  1308. value = undefined,
  1309. error = undefined,
  1310. succeeded = undefined,
  1311. failed = undefined;
  1312. if (hasCallback) {
  1313. value = tryCatch(callback, detail);
  1314. if (value === TRY_CATCH_ERROR) {
  1315. failed = true;
  1316. error = value.error;
  1317. value.error = null;
  1318. } else {
  1319. succeeded = true;
  1320. }
  1321. if (promise === value) {
  1322. reject(promise, cannotReturnOwn());
  1323. return;
  1324. }
  1325. } else {
  1326. value = detail;
  1327. succeeded = true;
  1328. }
  1329. if (promise._state !== PENDING) {
  1330. // noop
  1331. } else if (hasCallback && succeeded) {
  1332. resolve(promise, value);
  1333. } else if (failed) {
  1334. reject(promise, error);
  1335. } else if (settled === FULFILLED) {
  1336. fulfill(promise, value);
  1337. } else if (settled === REJECTED) {
  1338. reject(promise, value);
  1339. }
  1340. }
  1341. function initializePromise(promise, resolver) {
  1342. try {
  1343. resolver(function resolvePromise(value) {
  1344. resolve(promise, value);
  1345. }, function rejectPromise(reason) {
  1346. reject(promise, reason);
  1347. });
  1348. } catch (e) {
  1349. reject(promise, e);
  1350. }
  1351. }
  1352. var id = 0;
  1353. function nextId() {
  1354. return id++;
  1355. }
  1356. function makePromise(promise) {
  1357. promise[PROMISE_ID] = id++;
  1358. promise._state = undefined;
  1359. promise._result = undefined;
  1360. promise._subscribers = [];
  1361. }
  1362. function Enumerator$1(Constructor, input) {
  1363. this._instanceConstructor = Constructor;
  1364. this.promise = new Constructor(noop);
  1365. if (!this.promise[PROMISE_ID]) {
  1366. makePromise(this.promise);
  1367. }
  1368. if (isArray(input)) {
  1369. this.length = input.length;
  1370. this._remaining = input.length;
  1371. this._result = new Array(this.length);
  1372. if (this.length === 0) {
  1373. fulfill(this.promise, this._result);
  1374. } else {
  1375. this.length = this.length || 0;
  1376. this._enumerate(input);
  1377. if (this._remaining === 0) {
  1378. fulfill(this.promise, this._result);
  1379. }
  1380. }
  1381. } else {
  1382. reject(this.promise, validationError());
  1383. }
  1384. }
  1385. function validationError() {
  1386. return new Error('Array Methods must be provided an Array');
  1387. }
  1388. Enumerator$1.prototype._enumerate = function (input) {
  1389. for (var i = 0; this._state === PENDING && i < input.length; i++) {
  1390. this._eachEntry(input[i], i);
  1391. }
  1392. };
  1393. Enumerator$1.prototype._eachEntry = function (entry, i) {
  1394. var c = this._instanceConstructor;
  1395. var resolve$$1 = c.resolve;
  1396. if (resolve$$1 === resolve$1) {
  1397. var _then = getThen(entry);
  1398. if (_then === then && entry._state !== PENDING) {
  1399. this._settledAt(entry._state, i, entry._result);
  1400. } else if (typeof _then !== 'function') {
  1401. this._remaining--;
  1402. this._result[i] = entry;
  1403. } else if (c === Promise$2) {
  1404. var promise = new c(noop);
  1405. handleMaybeThenable(promise, entry, _then);
  1406. this._willSettleAt(promise, i);
  1407. } else {
  1408. this._willSettleAt(new c(function (resolve$$1) {
  1409. return resolve$$1(entry);
  1410. }), i);
  1411. }
  1412. } else {
  1413. this._willSettleAt(resolve$$1(entry), i);
  1414. }
  1415. };
  1416. Enumerator$1.prototype._settledAt = function (state, i, value) {
  1417. var promise = this.promise;
  1418. if (promise._state === PENDING) {
  1419. this._remaining--;
  1420. if (state === REJECTED) {
  1421. reject(promise, value);
  1422. } else {
  1423. this._result[i] = value;
  1424. }
  1425. }
  1426. if (this._remaining === 0) {
  1427. fulfill(promise, this._result);
  1428. }
  1429. };
  1430. Enumerator$1.prototype._willSettleAt = function (promise, i) {
  1431. var enumerator = this;
  1432. subscribe(promise, undefined, function (value) {
  1433. return enumerator._settledAt(FULFILLED, i, value);
  1434. }, function (reason) {
  1435. return enumerator._settledAt(REJECTED, i, reason);
  1436. });
  1437. };
  1438. /**
  1439. `Promise.all` accepts an array of promises, and returns a new promise which
  1440. is fulfilled with an array of fulfillment values for the passed promises, or
  1441. rejected with the reason of the first passed promise to be rejected. It casts all
  1442. elements of the passed iterable to promises as it runs this algorithm.
  1443. Example:
  1444. ```javascript
  1445. let promise1 = resolve(1);
  1446. let promise2 = resolve(2);
  1447. let promise3 = resolve(3);
  1448. let promises = [ promise1, promise2, promise3 ];
  1449. Promise.all(promises).then(function(array){
  1450. // The array here would be [ 1, 2, 3 ];
  1451. });
  1452. ```
  1453. If any of the `promises` given to `all` are rejected, the first promise
  1454. that is rejected will be given as an argument to the returned promises's
  1455. rejection handler. For example:
  1456. Example:
  1457. ```javascript
  1458. let promise1 = resolve(1);
  1459. let promise2 = reject(new Error("2"));
  1460. let promise3 = reject(new Error("3"));
  1461. let promises = [ promise1, promise2, promise3 ];
  1462. Promise.all(promises).then(function(array){
  1463. // Code here never runs because there are rejected promises!
  1464. }, function(error) {
  1465. // error.message === "2"
  1466. });
  1467. ```
  1468. @method all
  1469. @static
  1470. @param {Array} entries array of promises
  1471. @param {String} label optional string for labeling the promise.
  1472. Useful for tooling.
  1473. @return {Promise} promise that is fulfilled when all `promises` have been
  1474. fulfilled, or rejected if any of them become rejected.
  1475. @static
  1476. */
  1477. function all$1(entries) {
  1478. return new Enumerator$1(this, entries).promise;
  1479. }
  1480. /**
  1481. `Promise.race` returns a new promise which is settled in the same way as the
  1482. first passed promise to settle.
  1483. Example:
  1484. ```javascript
  1485. let promise1 = new Promise(function(resolve, reject){
  1486. setTimeout(function(){
  1487. resolve('promise 1');
  1488. }, 200);
  1489. });
  1490. let promise2 = new Promise(function(resolve, reject){
  1491. setTimeout(function(){
  1492. resolve('promise 2');
  1493. }, 100);
  1494. });
  1495. Promise.race([promise1, promise2]).then(function(result){
  1496. // result === 'promise 2' because it was resolved before promise1
  1497. // was resolved.
  1498. });
  1499. ```
  1500. `Promise.race` is deterministic in that only the state of the first
  1501. settled promise matters. For example, even if other promises given to the
  1502. `promises` array argument are resolved, but the first settled promise has
  1503. become rejected before the other promises became fulfilled, the returned
  1504. promise will become rejected:
  1505. ```javascript
  1506. let promise1 = new Promise(function(resolve, reject){
  1507. setTimeout(function(){
  1508. resolve('promise 1');
  1509. }, 200);
  1510. });
  1511. let promise2 = new Promise(function(resolve, reject){
  1512. setTimeout(function(){
  1513. reject(new Error('promise 2'));
  1514. }, 100);
  1515. });
  1516. Promise.race([promise1, promise2]).then(function(result){
  1517. // Code here never runs
  1518. }, function(reason){
  1519. // reason.message === 'promise 2' because promise 2 became rejected before
  1520. // promise 1 became fulfilled
  1521. });
  1522. ```
  1523. An example real-world use case is implementing timeouts:
  1524. ```javascript
  1525. Promise.race([ajax('foo.json'), timeout(5000)])
  1526. ```
  1527. @method race
  1528. @static
  1529. @param {Array} promises array of promises to observe
  1530. Useful for tooling.
  1531. @return {Promise} a promise which settles in the same way as the first passed
  1532. promise to settle.
  1533. */
  1534. function race$1(entries) {
  1535. /*jshint validthis:true */
  1536. var Constructor = this;
  1537. if (!isArray(entries)) {
  1538. return new Constructor(function (_, reject) {
  1539. return reject(new TypeError('You must pass an array to race.'));
  1540. });
  1541. } else {
  1542. return new Constructor(function (resolve, reject) {
  1543. var length = entries.length;
  1544. for (var i = 0; i < length; i++) {
  1545. Constructor.resolve(entries[i]).then(resolve, reject);
  1546. }
  1547. });
  1548. }
  1549. }
  1550. /**
  1551. `Promise.reject` returns a promise rejected with the passed `reason`.
  1552. It is shorthand for the following:
  1553. ```javascript
  1554. let promise = new Promise(function(resolve, reject){
  1555. reject(new Error('WHOOPS'));
  1556. });
  1557. promise.then(function(value){
  1558. // Code here doesn't run because the promise is rejected!
  1559. }, function(reason){
  1560. // reason.message === 'WHOOPS'
  1561. });
  1562. ```
  1563. Instead of writing the above, your code now simply becomes the following:
  1564. ```javascript
  1565. let promise = Promise.reject(new Error('WHOOPS'));
  1566. promise.then(function(value){
  1567. // Code here doesn't run because the promise is rejected!
  1568. }, function(reason){
  1569. // reason.message === 'WHOOPS'
  1570. });
  1571. ```
  1572. @method reject
  1573. @static
  1574. @param {Any} reason value that the returned promise will be rejected with.
  1575. Useful for tooling.
  1576. @return {Promise} a promise rejected with the given `reason`.
  1577. */
  1578. function reject$1(reason) {
  1579. /*jshint validthis:true */
  1580. var Constructor = this;
  1581. var promise = new Constructor(noop);
  1582. reject(promise, reason);
  1583. return promise;
  1584. }
  1585. function needsResolver() {
  1586. throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
  1587. }
  1588. function needsNew() {
  1589. throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
  1590. }
  1591. /**
  1592. Promise objects represent the eventual result of an asynchronous operation. The
  1593. primary way of interacting with a promise is through its `then` method, which
  1594. registers callbacks to receive either a promise's eventual value or the reason
  1595. why the promise cannot be fulfilled.
  1596. Terminology
  1597. -----------
  1598. - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
  1599. - `thenable` is an object or function that defines a `then` method.
  1600. - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
  1601. - `exception` is a value that is thrown using the throw statement.
  1602. - `reason` is a value that indicates why a promise was rejected.
  1603. - `settled` the final resting state of a promise, fulfilled or rejected.
  1604. A promise can be in one of three states: pending, fulfilled, or rejected.
  1605. Promises that are fulfilled have a fulfillment value and are in the fulfilled
  1606. state. Promises that are rejected have a rejection reason and are in the
  1607. rejected state. A fulfillment value is never a thenable.
  1608. Promises can also be said to *resolve* a value. If this value is also a
  1609. promise, then the original promise's settled state will match the value's
  1610. settled state. So a promise that *resolves* a promise that rejects will
  1611. itself reject, and a promise that *resolves* a promise that fulfills will
  1612. itself fulfill.
  1613. Basic Usage:
  1614. ------------
  1615. ```js
  1616. let promise = new Promise(function(resolve, reject) {
  1617. // on success
  1618. resolve(value);
  1619. // on failure
  1620. reject(reason);
  1621. });
  1622. promise.then(function(value) {
  1623. // on fulfillment
  1624. }, function(reason) {
  1625. // on rejection
  1626. });
  1627. ```
  1628. Advanced Usage:
  1629. ---------------
  1630. Promises shine when abstracting away asynchronous interactions such as
  1631. `XMLHttpRequest`s.
  1632. ```js
  1633. function getJSON(url) {
  1634. return new Promise(function(resolve, reject){
  1635. let xhr = new XMLHttpRequest();
  1636. xhr.open('GET', url);
  1637. xhr.onreadystatechange = handler;
  1638. xhr.responseType = 'json';
  1639. xhr.setRequestHeader('Accept', 'application/json');
  1640. xhr.send();
  1641. function handler() {
  1642. if (this.readyState === this.DONE) {
  1643. if (this.status === 200) {
  1644. resolve(this.response);
  1645. } else {
  1646. reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
  1647. }
  1648. }
  1649. };
  1650. });
  1651. }
  1652. getJSON('/posts.json').then(function(json) {
  1653. // on fulfillment
  1654. }, function(reason) {
  1655. // on rejection
  1656. });
  1657. ```
  1658. Unlike callbacks, promises are great composable primitives.
  1659. ```js
  1660. Promise.all([
  1661. getJSON('/posts'),
  1662. getJSON('/comments')
  1663. ]).then(function(values){
  1664. values[0] // => postsJSON
  1665. values[1] // => commentsJSON
  1666. return values;
  1667. });
  1668. ```
  1669. @class Promise
  1670. @param {function} resolver
  1671. Useful for tooling.
  1672. @constructor
  1673. */
  1674. function Promise$2(resolver) {
  1675. this[PROMISE_ID] = nextId();
  1676. this._result = this._state = undefined;
  1677. this._subscribers = [];
  1678. if (noop !== resolver) {
  1679. typeof resolver !== 'function' && needsResolver();
  1680. this instanceof Promise$2 ? initializePromise(this, resolver) : needsNew();
  1681. }
  1682. }
  1683. Promise$2.all = all$1;
  1684. Promise$2.race = race$1;
  1685. Promise$2.resolve = resolve$1;
  1686. Promise$2.reject = reject$1;
  1687. Promise$2._setScheduler = setScheduler;
  1688. Promise$2._setAsap = setAsap;
  1689. Promise$2._asap = asap;
  1690. Promise$2.prototype = {
  1691. constructor: Promise$2,
  1692. /**
  1693. The primary way of interacting with a promise is through its `then` method,
  1694. which registers callbacks to receive either a promise's eventual value or the
  1695. reason why the promise cannot be fulfilled.
  1696. ```js
  1697. findUser().then(function(user){
  1698. // user is available
  1699. }, function(reason){
  1700. // user is unavailable, and you are given the reason why
  1701. });
  1702. ```
  1703. Chaining
  1704. --------
  1705. The return value of `then` is itself a promise. This second, 'downstream'
  1706. promise is resolved with the return value of the first promise's fulfillment
  1707. or rejection handler, or rejected if the handler throws an exception.
  1708. ```js
  1709. findUser().then(function (user) {
  1710. return user.name;
  1711. }, function (reason) {
  1712. return 'default name';
  1713. }).then(function (userName) {
  1714. // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
  1715. // will be `'default name'`
  1716. });
  1717. findUser().then(function (user) {
  1718. throw new Error('Found user, but still unhappy');
  1719. }, function (reason) {
  1720. throw new Error('`findUser` rejected and we're unhappy');
  1721. }).then(function (value) {
  1722. // never reached
  1723. }, function (reason) {
  1724. // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
  1725. // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
  1726. });
  1727. ```
  1728. If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
  1729. ```js
  1730. findUser().then(function (user) {
  1731. throw new PedagogicalException('Upstream error');
  1732. }).then(function (value) {
  1733. // never reached
  1734. }).then(function (value) {
  1735. // never reached
  1736. }, function (reason) {
  1737. // The `PedgagocialException` is propagated all the way down to here
  1738. });
  1739. ```
  1740. Assimilation
  1741. ------------
  1742. Sometimes the value you want to propagate to a downstream promise can only be
  1743. retrieved asynchronously. This can be achieved by returning a promise in the
  1744. fulfillment or rejection handler. The downstream promise will then be pending
  1745. until the returned promise is settled. This is called *assimilation*.
  1746. ```js
  1747. findUser().then(function (user) {
  1748. return findCommentsByAuthor(user);
  1749. }).then(function (comments) {
  1750. // The user's comments are now available
  1751. });
  1752. ```
  1753. If the assimliated promise rejects, then the downstream promise will also reject.
  1754. ```js
  1755. findUser().then(function (user) {
  1756. return findCommentsByAuthor(user);
  1757. }).then(function (comments) {
  1758. // If `findCommentsByAuthor` fulfills, we'll have the value here
  1759. }, function (reason) {
  1760. // If `findCommentsByAuthor` rejects, we'll have the reason here
  1761. });
  1762. ```
  1763. Simple Example
  1764. --------------
  1765. Synchronous Example
  1766. ```javascript
  1767. let result;
  1768. try {
  1769. result = findResult();
  1770. // success
  1771. } catch(reason) {
  1772. // failure
  1773. }
  1774. ```
  1775. Errback Example
  1776. ```js
  1777. findResult(function(result, err){
  1778. if (err) {
  1779. // failure
  1780. } else {
  1781. // success
  1782. }
  1783. });
  1784. ```
  1785. Promise Example;
  1786. ```javascript
  1787. findResult().then(function(result){
  1788. // success
  1789. }, function(reason){
  1790. // failure
  1791. });
  1792. ```
  1793. Advanced Example
  1794. --------------
  1795. Synchronous Example
  1796. ```javascript
  1797. let author, books;
  1798. try {
  1799. author = findAuthor();
  1800. books = findBooksByAuthor(author);
  1801. // success
  1802. } catch(reason) {
  1803. // failure
  1804. }
  1805. ```
  1806. Errback Example
  1807. ```js
  1808. function foundBooks(books) {
  1809. }
  1810. function failure(reason) {
  1811. }
  1812. findAuthor(function(author, err){
  1813. if (err) {
  1814. failure(err);
  1815. // failure
  1816. } else {
  1817. try {
  1818. findBoooksByAuthor(author, function(books, err) {
  1819. if (err) {
  1820. failure(err);
  1821. } else {
  1822. try {
  1823. foundBooks(books);
  1824. } catch(reason) {
  1825. failure(reason);
  1826. }
  1827. }
  1828. });
  1829. } catch(error) {
  1830. failure(err);
  1831. }
  1832. // success
  1833. }
  1834. });
  1835. ```
  1836. Promise Example;
  1837. ```javascript
  1838. findAuthor().
  1839. then(findBooksByAuthor).
  1840. then(function(books){
  1841. // found books
  1842. }).catch(function(reason){
  1843. // something went wrong
  1844. });
  1845. ```
  1846. @method then
  1847. @param {Function} onFulfilled
  1848. @param {Function} onRejected
  1849. Useful for tooling.
  1850. @return {Promise}
  1851. */
  1852. then: then,
  1853. /**
  1854. `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
  1855. as the catch block of a try/catch statement.
  1856. ```js
  1857. function findAuthor(){
  1858. throw new Error('couldn't find that author');
  1859. }
  1860. // synchronous
  1861. try {
  1862. findAuthor();
  1863. } catch(reason) {
  1864. // something went wrong
  1865. }
  1866. // async with promises
  1867. findAuthor().catch(function(reason){
  1868. // something went wrong
  1869. });
  1870. ```
  1871. @method catch
  1872. @param {Function} onRejection
  1873. Useful for tooling.
  1874. @return {Promise}
  1875. */
  1876. 'catch': function _catch(onRejection) {
  1877. return this.then(null, onRejection);
  1878. }
  1879. };
  1880. /*global self*/
  1881. function polyfill$1() {
  1882. var local = undefined;
  1883. if (typeof global !== 'undefined') {
  1884. local = global;
  1885. } else if (typeof self !== 'undefined') {
  1886. local = self;
  1887. } else {
  1888. try {
  1889. local = Function('return this')();
  1890. } catch (e) {
  1891. throw new Error('polyfill failed because global object is unavailable in this environment');
  1892. }
  1893. }
  1894. var P = local.Promise;
  1895. if (P) {
  1896. var promiseToString = null;
  1897. try {
  1898. promiseToString = Object.prototype.toString.call(P.resolve());
  1899. } catch (e) {
  1900. // silently ignored
  1901. }
  1902. if (promiseToString === '[object Promise]' && !P.cast) {
  1903. return;
  1904. }
  1905. }
  1906. local.Promise = Promise$2;
  1907. }
  1908. // Strange compat..
  1909. Promise$2.polyfill = polyfill$1;
  1910. Promise$2.Promise = Promise$2;
  1911. return Promise$2;
  1912. })));
  1913. //# sourceMappingURL=es6-promise.map
  1914. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7), __webpack_require__(8)))
  1915. /***/ }),
  1916. /* 5 */
  1917. /***/ (function(module, exports) {
  1918. // removed by extract-text-webpack-plugin
  1919. /***/ }),
  1920. /* 6 */
  1921. /***/ (function(module, exports, __webpack_require__) {
  1922. "use strict";
  1923. Object.defineProperty(exports, "__esModule", {
  1924. value: true
  1925. });
  1926. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); /* global VERSION */
  1927. __webpack_require__(5);
  1928. var _es6Promise = __webpack_require__(4);
  1929. var _es6Promise2 = _interopRequireDefault(_es6Promise);
  1930. var _utils = __webpack_require__(0);
  1931. var Utils = _interopRequireWildcard(_utils);
  1932. var _api = __webpack_require__(1);
  1933. var API = _interopRequireWildcard(_api);
  1934. var _button = __webpack_require__(2);
  1935. var _push = __webpack_require__(3);
  1936. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  1937. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1938. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1939. var Noty = function () {
  1940. /**
  1941. * @param {object} options
  1942. * @return {Noty}
  1943. */
  1944. function Noty() {
  1945. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1946. _classCallCheck(this, Noty);
  1947. this.options = Utils.deepExtend({}, API.Defaults, options);
  1948. if (API.Store[this.options.id]) {
  1949. return API.Store[this.options.id];
  1950. }
  1951. this.id = this.options.id || Utils.generateID('bar');
  1952. this.closeTimer = -1;
  1953. this.barDom = null;
  1954. this.layoutDom = null;
  1955. this.progressDom = null;
  1956. this.showing = false;
  1957. this.shown = false;
  1958. this.closed = false;
  1959. this.closing = false;
  1960. this.killable = this.options.timeout || this.options.closeWith.length > 0;
  1961. this.hasSound = this.options.sounds.sources.length > 0;
  1962. this.soundPlayed = false;
  1963. this.listeners = {
  1964. beforeShow: [],
  1965. onShow: [],
  1966. afterShow: [],
  1967. onClose: [],
  1968. afterClose: [],
  1969. onClick: [],
  1970. onHover: [],
  1971. onTemplate: []
  1972. };
  1973. this.promises = {
  1974. show: null,
  1975. close: null
  1976. };
  1977. this.on('beforeShow', this.options.callbacks.beforeShow);
  1978. this.on('onShow', this.options.callbacks.onShow);
  1979. this.on('afterShow', this.options.callbacks.afterShow);
  1980. this.on('onClose', this.options.callbacks.onClose);
  1981. this.on('afterClose', this.options.callbacks.afterClose);
  1982. this.on('onClick', this.options.callbacks.onClick);
  1983. this.on('onHover', this.options.callbacks.onHover);
  1984. this.on('onTemplate', this.options.callbacks.onTemplate);
  1985. return this;
  1986. }
  1987. /**
  1988. * @param {string} eventName
  1989. * @param {function} cb
  1990. * @return {Noty}
  1991. */
  1992. _createClass(Noty, [{
  1993. key: 'on',
  1994. value: function on(eventName) {
  1995. var cb = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
  1996. if (typeof cb === 'function' && this.listeners.hasOwnProperty(eventName)) {
  1997. this.listeners[eventName].push(cb);
  1998. }
  1999. return this;
  2000. }
  2001. /**
  2002. * @return {Noty}
  2003. */
  2004. }, {
  2005. key: 'show',
  2006. value: function show() {
  2007. var _this = this;
  2008. if (this.showing || this.shown) {
  2009. return this; // preventing multiple show
  2010. }
  2011. if (this.options.killer === true) {
  2012. Noty.closeAll();
  2013. } else if (typeof this.options.killer === 'string') {
  2014. Noty.closeAll(this.options.killer);
  2015. }
  2016. var queueCounts = API.getQueueCounts(this.options.queue);
  2017. if (queueCounts.current >= queueCounts.maxVisible || API.PageHidden && this.options.visibilityControl) {
  2018. API.addToQueue(this);
  2019. if (API.PageHidden && this.hasSound && Utils.inArray('docHidden', this.options.sounds.conditions)) {
  2020. Utils.createAudioElements(this);
  2021. }
  2022. if (API.PageHidden && Utils.inArray('docHidden', this.options.titleCount.conditions)) {
  2023. API.docTitle.increment();
  2024. }
  2025. return this;
  2026. }
  2027. API.Store[this.id] = this;
  2028. API.fire(this, 'beforeShow');
  2029. this.showing = true;
  2030. if (this.closing) {
  2031. this.showing = false;
  2032. return this;
  2033. }
  2034. API.build(this);
  2035. API.handleModal(this);
  2036. if (this.options.force) {
  2037. this.layoutDom.insertBefore(this.barDom, this.layoutDom.firstChild);
  2038. } else {
  2039. this.layoutDom.appendChild(this.barDom);
  2040. }
  2041. if (this.hasSound && !this.soundPlayed && Utils.inArray('docVisible', this.options.sounds.conditions)) {
  2042. Utils.createAudioElements(this);
  2043. }
  2044. if (Utils.inArray('docVisible', this.options.titleCount.conditions)) {
  2045. API.docTitle.increment();
  2046. }
  2047. this.shown = true;
  2048. this.closed = false;
  2049. // bind button events if any
  2050. if (API.hasButtons(this)) {
  2051. Object.keys(this.options.buttons).forEach(function (key) {
  2052. var btn = _this.barDom.querySelector('#' + _this.options.buttons[key].id);
  2053. Utils.addListener(btn, 'click', function (e) {
  2054. Utils.stopPropagation(e);
  2055. _this.options.buttons[key].cb(_this);
  2056. });
  2057. });
  2058. }
  2059. this.progressDom = this.barDom.querySelector('.noty_progressbar');
  2060. if (Utils.inArray('click', this.options.closeWith)) {
  2061. Utils.addClass(this.barDom, 'noty_close_with_click');
  2062. Utils.addListener(this.barDom, 'click', function (e) {
  2063. Utils.stopPropagation(e);
  2064. API.fire(_this, 'onClick');
  2065. _this.close();
  2066. }, false);
  2067. }
  2068. Utils.addListener(this.barDom, 'mouseenter', function () {
  2069. API.fire(_this, 'onHover');
  2070. }, false);
  2071. if (this.options.timeout) Utils.addClass(this.barDom, 'noty_has_timeout');
  2072. if (this.options.progressBar) {
  2073. Utils.addClass(this.barDom, 'noty_has_progressbar');
  2074. }
  2075. if (Utils.inArray('button', this.options.closeWith)) {
  2076. Utils.addClass(this.barDom, 'noty_close_with_button');
  2077. var closeButton = document.createElement('div');
  2078. Utils.addClass(closeButton, 'noty_close_button');
  2079. closeButton.innerHTML = '×';
  2080. this.barDom.appendChild(closeButton);
  2081. Utils.addListener(closeButton, 'click', function (e) {
  2082. Utils.stopPropagation(e);
  2083. _this.close();
  2084. }, false);
  2085. }
  2086. API.fire(this, 'onShow');
  2087. if (this.options.animation.open === null) {
  2088. this.promises.show = new _es6Promise2.default(function (resolve) {
  2089. resolve();
  2090. });
  2091. } else if (typeof this.options.animation.open === 'function') {
  2092. this.promises.show = new _es6Promise2.default(this.options.animation.open.bind(this));
  2093. } else {
  2094. Utils.addClass(this.barDom, this.options.animation.open);
  2095. this.promises.show = new _es6Promise2.default(function (resolve) {
  2096. Utils.addListener(_this.barDom, Utils.animationEndEvents, function () {
  2097. Utils.removeClass(_this.barDom, _this.options.animation.open);
  2098. resolve();
  2099. });
  2100. });
  2101. }
  2102. this.promises.show.then(function () {
  2103. var _t = _this;
  2104. setTimeout(function () {
  2105. API.openFlow(_t);
  2106. }, 100);
  2107. });
  2108. return this;
  2109. }
  2110. /**
  2111. * @return {Noty}
  2112. */
  2113. }, {
  2114. key: 'stop',
  2115. value: function stop() {
  2116. API.dequeueClose(this);
  2117. return this;
  2118. }
  2119. /**
  2120. * @return {Noty}
  2121. */
  2122. }, {
  2123. key: 'resume',
  2124. value: function resume() {
  2125. API.queueClose(this);
  2126. return this;
  2127. }
  2128. /**
  2129. * @param {int|boolean} ms
  2130. * @return {Noty}
  2131. */
  2132. }, {
  2133. key: 'setTimeout',
  2134. value: function (_setTimeout) {
  2135. function setTimeout(_x) {
  2136. return _setTimeout.apply(this, arguments);
  2137. }
  2138. setTimeout.toString = function () {
  2139. return _setTimeout.toString();
  2140. };
  2141. return setTimeout;
  2142. }(function (ms) {
  2143. this.stop();
  2144. this.options.timeout = ms;
  2145. if (this.barDom) {
  2146. if (this.options.timeout) {
  2147. Utils.addClass(this.barDom, 'noty_has_timeout');
  2148. } else {
  2149. Utils.removeClass(this.barDom, 'noty_has_timeout');
  2150. }
  2151. var _t = this;
  2152. setTimeout(function () {
  2153. // ugly fix for progressbar display bug
  2154. _t.resume();
  2155. }, 100);
  2156. }
  2157. return this;
  2158. })
  2159. /**
  2160. * @param {string} html
  2161. * @param {boolean} optionsOverride
  2162. * @return {Noty}
  2163. */
  2164. }, {
  2165. key: 'setText',
  2166. value: function setText(html) {
  2167. var optionsOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2168. if (this.barDom) {
  2169. this.barDom.querySelector('.noty_body').innerHTML = html;
  2170. }
  2171. if (optionsOverride) this.options.text = html;
  2172. return this;
  2173. }
  2174. /**
  2175. * @param {string} type
  2176. * @param {boolean} optionsOverride
  2177. * @return {Noty}
  2178. */
  2179. }, {
  2180. key: 'setType',
  2181. value: function setType(type) {
  2182. var _this2 = this;
  2183. var optionsOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2184. if (this.barDom) {
  2185. var classList = Utils.classList(this.barDom).split(' ');
  2186. classList.forEach(function (c) {
  2187. if (c.substring(0, 11) === 'noty_type__') {
  2188. Utils.removeClass(_this2.barDom, c);
  2189. }
  2190. });
  2191. Utils.addClass(this.barDom, 'noty_type__' + type);
  2192. }
  2193. if (optionsOverride) this.options.type = type;
  2194. return this;
  2195. }
  2196. /**
  2197. * @param {string} theme
  2198. * @param {boolean} optionsOverride
  2199. * @return {Noty}
  2200. */
  2201. }, {
  2202. key: 'setTheme',
  2203. value: function setTheme(theme) {
  2204. var _this3 = this;
  2205. var optionsOverride = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
  2206. if (this.barDom) {
  2207. var classList = Utils.classList(this.barDom).split(' ');
  2208. classList.forEach(function (c) {
  2209. if (c.substring(0, 12) === 'noty_theme__') {
  2210. Utils.removeClass(_this3.barDom, c);
  2211. }
  2212. });
  2213. Utils.addClass(this.barDom, 'noty_theme__' + theme);
  2214. }
  2215. if (optionsOverride) this.options.theme = theme;
  2216. return this;
  2217. }
  2218. /**
  2219. * @return {Noty}
  2220. */
  2221. }, {
  2222. key: 'close',
  2223. value: function close() {
  2224. var _this4 = this;
  2225. if (this.closed) return this;
  2226. if (!this.shown) {
  2227. // it's in the queue
  2228. API.removeFromQueue(this);
  2229. return this;
  2230. }
  2231. API.fire(this, 'onClose');
  2232. this.closing = true;
  2233. if (this.options.animation.close === null || this.options.animation.close === false) {
  2234. this.promises.close = new _es6Promise2.default(function (resolve) {
  2235. resolve();
  2236. });
  2237. } else if (typeof this.options.animation.close === 'function') {
  2238. this.promises.close = new _es6Promise2.default(this.options.animation.close.bind(this));
  2239. } else {
  2240. Utils.addClass(this.barDom, this.options.animation.close);
  2241. this.promises.close = new _es6Promise2.default(function (resolve) {
  2242. Utils.addListener(_this4.barDom, Utils.animationEndEvents, function () {
  2243. if (_this4.options.force) {
  2244. Utils.remove(_this4.barDom);
  2245. } else {
  2246. API.ghostFix(_this4);
  2247. }
  2248. resolve();
  2249. });
  2250. });
  2251. }
  2252. this.promises.close.then(function () {
  2253. API.closeFlow(_this4);
  2254. API.handleModalClose(_this4);
  2255. });
  2256. this.closed = true;
  2257. return this;
  2258. }
  2259. // API functions
  2260. /**
  2261. * @param {boolean|string} queueName
  2262. * @return {Noty}
  2263. */
  2264. }], [{
  2265. key: 'closeAll',
  2266. value: function closeAll() {
  2267. var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  2268. Object.keys(API.Store).forEach(function (id) {
  2269. if (queueName) {
  2270. if (API.Store[id].options.queue === queueName && API.Store[id].killable) {
  2271. API.Store[id].close();
  2272. }
  2273. } else if (API.Store[id].killable) {
  2274. API.Store[id].close();
  2275. }
  2276. });
  2277. return this;
  2278. }
  2279. /**
  2280. * @param {string} queueName
  2281. * @return {Noty}
  2282. */
  2283. }, {
  2284. key: 'clearQueue',
  2285. value: function clearQueue() {
  2286. var queueName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'global';
  2287. if (API.Queues.hasOwnProperty(queueName)) {
  2288. API.Queues[queueName].queue = [];
  2289. }
  2290. return this;
  2291. }
  2292. /**
  2293. * @return {API.Queues}
  2294. */
  2295. }, {
  2296. key: 'overrideDefaults',
  2297. /**
  2298. * @param {Object} obj
  2299. * @return {Noty}
  2300. */
  2301. value: function overrideDefaults(obj) {
  2302. API.Defaults = Utils.deepExtend({}, API.Defaults, obj);
  2303. return this;
  2304. }
  2305. /**
  2306. * @param {int} amount
  2307. * @param {string} queueName
  2308. * @return {Noty}
  2309. */
  2310. }, {
  2311. key: 'setMaxVisible',
  2312. value: function setMaxVisible() {
  2313. var amount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : API.DefaultMaxVisible;
  2314. var queueName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'global';
  2315. if (!API.Queues.hasOwnProperty(queueName)) {
  2316. API.Queues[queueName] = { maxVisible: amount, queue: [] };
  2317. }
  2318. API.Queues[queueName].maxVisible = amount;
  2319. return this;
  2320. }
  2321. /**
  2322. * @param {string} innerHtml
  2323. * @param {String} classes
  2324. * @param {Function} cb
  2325. * @param {Object} attributes
  2326. * @return {NotyButton}
  2327. */
  2328. }, {
  2329. key: 'button',
  2330. value: function button(innerHtml) {
  2331. var classes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  2332. var cb = arguments[2];
  2333. var attributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  2334. return new _button.NotyButton(innerHtml, classes, cb, attributes);
  2335. }
  2336. /**
  2337. * @return {string}
  2338. */
  2339. }, {
  2340. key: 'version',
  2341. value: function version() {
  2342. return "3.2.0-beta";
  2343. }
  2344. /**
  2345. * @param {String} workerPath
  2346. * @return {Push}
  2347. */
  2348. }, {
  2349. key: 'Push',
  2350. value: function Push(workerPath) {
  2351. return new _push.Push(workerPath);
  2352. }
  2353. }, {
  2354. key: 'Queues',
  2355. get: function get() {
  2356. return API.Queues;
  2357. }
  2358. /**
  2359. * @return {API.PageHidden}
  2360. */
  2361. }, {
  2362. key: 'PageHidden',
  2363. get: function get() {
  2364. return API.PageHidden;
  2365. }
  2366. }]);
  2367. return Noty;
  2368. }();
  2369. // Document visibility change controller
  2370. exports.default = Noty;
  2371. if (typeof window !== 'undefined') {
  2372. Utils.visibilityChangeFlow();
  2373. }
  2374. module.exports = exports['default'];
  2375. /***/ }),
  2376. /* 7 */
  2377. /***/ (function(module, exports) {
  2378. // shim for using process in browser
  2379. var process = module.exports = {};
  2380. // cached from whatever global is present so that test runners that stub it
  2381. // don't break things. But we need to wrap it in a try catch in case it is
  2382. // wrapped in strict mode code which doesn't define any globals. It's inside a
  2383. // function because try/catches deoptimize in certain engines.
  2384. var cachedSetTimeout;
  2385. var cachedClearTimeout;
  2386. function defaultSetTimout() {
  2387. throw new Error('setTimeout has not been defined');
  2388. }
  2389. function defaultClearTimeout () {
  2390. throw new Error('clearTimeout has not been defined');
  2391. }
  2392. (function () {
  2393. try {
  2394. if (typeof setTimeout === 'function') {
  2395. cachedSetTimeout = setTimeout;
  2396. } else {
  2397. cachedSetTimeout = defaultSetTimout;
  2398. }
  2399. } catch (e) {
  2400. cachedSetTimeout = defaultSetTimout;
  2401. }
  2402. try {
  2403. if (typeof clearTimeout === 'function') {
  2404. cachedClearTimeout = clearTimeout;
  2405. } else {
  2406. cachedClearTimeout = defaultClearTimeout;
  2407. }
  2408. } catch (e) {
  2409. cachedClearTimeout = defaultClearTimeout;
  2410. }
  2411. } ())
  2412. function runTimeout(fun) {
  2413. if (cachedSetTimeout === setTimeout) {
  2414. //normal enviroments in sane situations
  2415. return setTimeout(fun, 0);
  2416. }
  2417. // if setTimeout wasn't available but was latter defined
  2418. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  2419. cachedSetTimeout = setTimeout;
  2420. return setTimeout(fun, 0);
  2421. }
  2422. try {
  2423. // when when somebody has screwed with setTimeout but no I.E. maddness
  2424. return cachedSetTimeout(fun, 0);
  2425. } catch(e){
  2426. try {
  2427. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2428. return cachedSetTimeout.call(null, fun, 0);
  2429. } catch(e){
  2430. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  2431. return cachedSetTimeout.call(this, fun, 0);
  2432. }
  2433. }
  2434. }
  2435. function runClearTimeout(marker) {
  2436. if (cachedClearTimeout === clearTimeout) {
  2437. //normal enviroments in sane situations
  2438. return clearTimeout(marker);
  2439. }
  2440. // if clearTimeout wasn't available but was latter defined
  2441. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  2442. cachedClearTimeout = clearTimeout;
  2443. return clearTimeout(marker);
  2444. }
  2445. try {
  2446. // when when somebody has screwed with setTimeout but no I.E. maddness
  2447. return cachedClearTimeout(marker);
  2448. } catch (e){
  2449. try {
  2450. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2451. return cachedClearTimeout.call(null, marker);
  2452. } catch (e){
  2453. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  2454. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  2455. return cachedClearTimeout.call(this, marker);
  2456. }
  2457. }
  2458. }
  2459. var queue = [];
  2460. var draining = false;
  2461. var currentQueue;
  2462. var queueIndex = -1;
  2463. function cleanUpNextTick() {
  2464. if (!draining || !currentQueue) {
  2465. return;
  2466. }
  2467. draining = false;
  2468. if (currentQueue.length) {
  2469. queue = currentQueue.concat(queue);
  2470. } else {
  2471. queueIndex = -1;
  2472. }
  2473. if (queue.length) {
  2474. drainQueue();
  2475. }
  2476. }
  2477. function drainQueue() {
  2478. if (draining) {
  2479. return;
  2480. }
  2481. var timeout = runTimeout(cleanUpNextTick);
  2482. draining = true;
  2483. var len = queue.length;
  2484. while(len) {
  2485. currentQueue = queue;
  2486. queue = [];
  2487. while (++queueIndex < len) {
  2488. if (currentQueue) {
  2489. currentQueue[queueIndex].run();
  2490. }
  2491. }
  2492. queueIndex = -1;
  2493. len = queue.length;
  2494. }
  2495. currentQueue = null;
  2496. draining = false;
  2497. runClearTimeout(timeout);
  2498. }
  2499. process.nextTick = function (fun) {
  2500. var args = new Array(arguments.length - 1);
  2501. if (arguments.length > 1) {
  2502. for (var i = 1; i < arguments.length; i++) {
  2503. args[i - 1] = arguments[i];
  2504. }
  2505. }
  2506. queue.push(new Item(fun, args));
  2507. if (queue.length === 1 && !draining) {
  2508. runTimeout(drainQueue);
  2509. }
  2510. };
  2511. // v8 likes predictible objects
  2512. function Item(fun, array) {
  2513. this.fun = fun;
  2514. this.array = array;
  2515. }
  2516. Item.prototype.run = function () {
  2517. this.fun.apply(null, this.array);
  2518. };
  2519. process.title = 'browser';
  2520. process.browser = true;
  2521. process.env = {};
  2522. process.argv = [];
  2523. process.version = ''; // empty string to avoid regexp issues
  2524. process.versions = {};
  2525. function noop() {}
  2526. process.on = noop;
  2527. process.addListener = noop;
  2528. process.once = noop;
  2529. process.off = noop;
  2530. process.removeListener = noop;
  2531. process.removeAllListeners = noop;
  2532. process.emit = noop;
  2533. process.prependListener = noop;
  2534. process.prependOnceListener = noop;
  2535. process.listeners = function (name) { return [] }
  2536. process.binding = function (name) {
  2537. throw new Error('process.binding is not supported');
  2538. };
  2539. process.cwd = function () { return '/' };
  2540. process.chdir = function (dir) {
  2541. throw new Error('process.chdir is not supported');
  2542. };
  2543. process.umask = function() { return 0; };
  2544. /***/ }),
  2545. /* 8 */
  2546. /***/ (function(module, exports) {
  2547. var g;
  2548. // This works in non-strict mode
  2549. g = (function() {
  2550. return this;
  2551. })();
  2552. try {
  2553. // This works if eval is allowed (see CSP)
  2554. g = g || Function("return this")() || (1,eval)("this");
  2555. } catch(e) {
  2556. // This works if the window reference is available
  2557. if(typeof window === "object")
  2558. g = window;
  2559. }
  2560. // g can still be undefined, but nothing to do about it...
  2561. // We return undefined, instead of nothing here, so it's
  2562. // easier to handle this case. if(!global) { ...}
  2563. module.exports = g;
  2564. /***/ }),
  2565. /* 9 */
  2566. /***/ (function(module, exports) {
  2567. /* (ignored) */
  2568. /***/ })
  2569. /******/ ]);
  2570. });
  2571. //# sourceMappingURL=noty.js.map