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