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