1/* 2* Ultimate Membership Pro - SweetAlert 3*/ 4"use strict"; 5;(function(window, document, undefined) { 6"use strict"; 7 8(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 9'use strict'; 10 11Object.defineProperty(exports, "__esModule", { 12 value: true 13}); 14var defaultParams = { 15 title: '', 16 text: '', 17 type: null, 18 allowOutsideClick: false, 19 showConfirmButton: true, 20 showCancelButton: false, 21 closeOnConfirm: true, 22 closeOnCancel: true, 23 confirmButtonText: 'OK', 24 confirmButtonClass: 'btn-primary', 25 cancelButtonText: 'Cancel', 26 cancelButtonClass: 'btn-default', 27 containerClass: '', 28 titleClass: '', 29 textClass: '', 30 imageUrl: null, 31 imageSize: null, 32 timer: null, 33 customClass: '', 34 html: false, 35 animation: true, 36 allowEscapeKey: true, 37 inputType: 'text', 38 inputPlaceholder: '', 39 inputValue: '', 40 showLoaderOnConfirm: false 41}; 42 43exports.default = defaultParams; 44 45},{}],2:[function(require,module,exports){ 46'use strict'; 47 48Object.defineProperty(exports, "__esModule", { 49 value: true 50}); 51exports.handleCancel = exports.handleConfirm = exports.handleButton = undefined; 52 53var _handleSwalDom = require('./handle-swal-dom'); 54 55var _handleDom = require('./handle-dom'); 56 57/* 58 * User clicked on "Confirm"/"OK" or "Cancel" 59 */ 60var handleButton = function handleButton(event, params, modal) { 61 var e = event || window.event; 62 var target = e.target || e.srcElement; 63 64 var targetedConfirm = target.className.indexOf('confirm') !== -1; 65 var targetedOverlay = target.className.indexOf('sweet-overlay') !== -1; 66 var modalIsVisible = (0, _handleDom.hasClass)(modal, 'visible'); 67 var doneFunctionExists = params.doneFunction && modal.getAttribute('data-has-done-function') === 'true'; 68 69 // Since the user can change the background-color of the confirm button programmatically, 70 // we must calculate what the color should be on hover/active 71 var normalColor, hoverColor, activeColor; 72 if (targetedConfirm && params.confirmButtonColor) { 73 normalColor = params.confirmButtonColor; 74 hoverColor = colorLuminance(normalColor, -0.04); 75 activeColor = colorLuminance(normalColor, -0.14); 76 } 77 78 function shouldSetConfirmButtonColor(color) { 79 if (targetedConfirm && params.confirmButtonColor) { 80 target.style.backgroundColor = color; 81 } 82 } 83 84 switch (e.type) { 85 case 'click': 86 var clickedOnModal = modal === target; 87 var clickedOnModalChild = (0, _handleDom.isDescendant)(modal, target); 88 89 // Ignore click outside if allowOutsideClick is false 90 if (!clickedOnModal && !clickedOnModalChild && modalIsVisible && !params.allowOutsideClick) { 91 break; 92 } 93 94 if (targetedConfirm && doneFunctionExists && modalIsVisible) { 95 handleConfirm(modal, params); 96 } else if (doneFunctionExists && modalIsVisible || targetedOverlay) { 97 handleCancel(modal, params); 98 } else if ((0, _handleDom.isDescendant)(modal, target) && target.tagName === 'BUTTON') { 99 sweetAlert.close(); 100 } 101 break; 102 } 103}; 104 105/* 106 * User clicked on "Confirm"/"OK" 107 */ 108var handleConfirm = function handleConfirm(modal, params) { 109 var callbackValue = true; 110 111 if ((0, _handleDom.hasClass)(modal, 'show-input')) { 112 callbackValue = modal.querySelector('input').value; 113 114 if (!callbackValue) { 115 callbackValue = ''; 116 } 117 } 118 119 params.doneFunction(callbackValue); 120 121 if (params.closeOnConfirm) { 122 sweetAlert.close(); 123 } 124 // Disable cancel and confirm button if the parameter is true 125 if (params.showLoaderOnConfirm) { 126 sweetAlert.disableButtons(); 127 } 128}; 129 130/* 131 * User clicked on "Cancel" 132 */ 133var handleCancel = function handleCancel(modal, params) { 134 // Check if callback function expects a parameter (to track cancel actions) 135 var functionAsStr = String(params.doneFunction).replace(/\s/g, ''); 136 var functionHandlesCancel = functionAsStr.substring(0, 9) === 'function(' && functionAsStr.substring(9, 10) !== ')'; 137 138 if (functionHandlesCancel) { 139 params.doneFunction(false); 140 } 141 142 if (params.closeOnCancel) { 143 sweetAlert.close(); 144 } 145}; 146 147exports.handleButton = handleButton; 148exports.handleConfirm = handleConfirm; 149exports.handleCancel = handleCancel; 150 151},{"./handle-dom":3,"./handle-swal-dom":5}],3:[function(require,module,exports){ 152'use strict'; 153 154Object.defineProperty(exports, "__esModule", { 155 value: true 156}); 157var hasClass = function hasClass(elem, className) { 158 return new RegExp(' ' + className + ' ').test(' ' + elem.className + ' '); 159};
160 161var addClass = function addClass(elem, className) { 162 if (!hasClass(elem, className)) { 163 elem.className += ' ' + className; 164 } 165}; 166 167var removeClass = function removeClass(elem, className) { 168 var newClass = ' ' + elem.className.replace(/[\t\r\n]/g, ' ') + ' '; 169 if (hasClass(elem, className)) { 170 while (newClass.indexOf(' ' + className + ' ') >= 0) { 171 newClass = newClass.replace(' ' + className + ' ', ' '); 172 } 173 elem.className = newClass.replace(/^\s+|\s+$/g, ''); 174 } 175}; 176 177var escapeHtml = function escapeHtml(str) { 178 var div = document.createElement('div'); 179 div.appendChild(document.createTextNode(str)); 180 return div.innerHTML; 181}; 182 183var _show = function _show(elem) { 184 elem.style.opacity = ''; 185 elem.style.display = 'block'; 186}; 187 188var show = function show(elems) { 189 if (elems && !elems.length) { 190 return _show(elems); 191 } 192 for (var i = 0; i < elems.length; ++i) { 193 _show(elems[i]); 194 } 195}; 196 197var _hide = function _hide(elem) { 198 elem.style.opacity = ''; 199 elem.style.display = 'none'; 200}; 201 202var hide = function hide(elems) { 203 if (elems && !elems.length) { 204 return _hide(elems); 205 } 206 for (var i = 0; i < elems.length; ++i) { 207 _hide(elems[i]); 208 } 209}; 210 211var isDescendant = function isDescendant(parent, child) { 212 var node = child.parentNode; 213 while (node !== null) { 214 if (node === parent) { 215 return true; 216 } 217 node = node.parentNode; 218 } 219 return false; 220}; 221 222var getTopMargin = function getTopMargin(elem) { 223 elem.style.left = '-9999px'; 224 elem.style.display = 'block'; 225 226 var height = elem.clientHeight, 227 padding; 228 if (typeof getComputedStyle !== "undefined") { 229 // IE 8 230 padding = parseInt(getComputedStyle(elem).getPropertyValue('padding-top'), 10); 231 } else { 232 padding = parseInt(elem.currentStyle.padding); 233 } 234 235 elem.style.left = ''; 236 elem.style.display = 'none'; 237 return '-' + parseInt((height + padding) / 2) + 'px'; 238}; 239 240var fadeIn = function fadeIn(elem, interval) { 241 if (+elem.style.opacity < 1) { 242 interval = interval || 16; 243 elem.style.opacity = 0; 244 elem.style.display = 'block'; 245 var last = +new Date(); 246 var tick = function tick() { 247 elem.style.opacity = +elem.style.opacity + (new Date() - last) / 100; 248 last = +new Date(); 249 250 if (+elem.style.opacity < 1) { 251 setTimeout(tick, interval); 252 } 253 }; 254 tick(); 255 } 256 elem.style.display = 'block'; //fallback IE8 257}; 258 259var fadeOut = function fadeOut(elem, interval) { 260 interval = interval || 16; 261 elem.style.opacity = 1; 262 var last = +new Date(); 263 var tick = function tick() { 264 elem.style.opacity = +elem.style.opacity - (new Date() - last) / 100; 265 last = +new Date(); 266 267 if (+elem.style.opacity > 0) { 268 setTimeout(tick, interval); 269 } else { 270 elem.style.display = 'none'; 271 } 272 }; 273 tick(); 274}; 275 276var fireClick = function fireClick(node) { 277 // Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/ 278 // Then fixed for today's Chrome browser. 279 if (typeof MouseEvent === 'function') { 280 // Up-to-date approach 281 var mevt = new MouseEvent('click', { 282 view: window, 283 bubbles: false, 284 cancelable: true 285 }); 286 node.dispatchEvent(mevt); 287 } else if (document.createEvent) { 288 // Fallback 289 var evt = document.createEvent('MouseEvents'); 290 evt.initEvent('click', false, false); 291 node.dispatchEvent(evt); 292 } else if (document.createEventObject) { 293 node.fireEvent('onclick'); 294 } else if (typeof node.onclick === 'function') { 295 node.onclick(); 296 } 297}; 298 299var stopEventPropagation = function stopEventPropagation(e) { 300 // In particular, make sure the space bar doesn't scroll the main window. 301 if (typeof e.stopPropagation === 'function') { 302 e.stopPropagation(); 303 e.preventDefault(); 304 } else if (window.event && window.event.hasOwnProperty('cancelBubble')) { 305 window.event.cancelBubble = true; 306 } 307}; 308 309exports.hasClass = hasClass; 310exports.addClass = addClass; 311exports.removeClass = removeClass; 312exports.escapeHtml = escapeHtml; 313exports._show = _show; 314exports.show = show; 315exports._hide = _hide; 316exports.hide = hide; 317exports.isDescendant = isDescendant; 318exports.getTopMargin = getTopMargin; 319exports.fadeIn = fadeIn; 320exports.fadeOut = fadeOut; 321exports.fireClick = fireClick; 322exports.stopEventPropagation = stopEventPropagation; 323 324},{}],4:[function(require,module,exports){ 325'use strict'; 326 327Object.defineProperty(exports, "__esModule", { 328 value: true 329}); 330 331var _handleDom = require('./handle-dom'); 332 333var _handleSwalDom = require('./handle-swal-dom'); 334 335var handleKeyDown = function handleKeyDown(event, params, modal) { 336 var e = event || window.event; 337 var keyCode = e.keyCode || e.which; 338 339 var $okButton = modal.querySelector('button.confirm'); 340 var $cancelButton = modal.querySelector('button.cancel'); 341 var $modalButtons = modal.querySelectorAll('button[tabindex]'); 342 343 if ([9, 13, 32, 27].indexOf(keyCode) === -1) { 344 // Don't do work on keys we don't care about. 345 return; 346 } 347 348 var $targetElement = e.target || e.srcElement; 349 350 var btnIndex = -1; // Find the button - note, this is a nodelist, not an array. 351 for (var i = 0; i < $modalButtons.length; i++) { 352 if ($targetElement === $modalButtons[i]) { 353 btnIndex = i; 354 break; 355 } 356 } 357 358 if (keyCode === 9) { 359 // TAB 360 if (btnIndex === -1) { 361 // No button focused. Jump to the confirm button. 362 $targetElement = $okButton; 363 } else { 364 // Cycle to the next button 365 if (btnIndex === $modalButtons.length - 1) { 366 $targetElement = $modalButtons[0]; 367 } else { 368 $targetElement = $modalButtons[btnIndex + 1]; 369 } 370 } 371 372 (0, _handleDom.stopEventPropagation)(e); 373 $targetElement.focus(); 374 375 if (params.confirmButtonColor) { 376 (0, _handleSwalDom.setFocusStyle)($targetElement, params.confirmButtonColor); 377 } 378 } else { 379 if (keyCode === 13) { 380 if ($targetElement.tagName === 'INPUT') { 381 $targetElement = $okButton; 382 $okButton.focus(); 383 } 384 385 if (btnIndex === -1) { 386 // ENTER/SPACE clicked outside of a button. 387 $targetElement = $okButton; 388 } else {
389 // Do nothing - let the browser handle it. 390 $targetElement = undefined; 391 } 392 } else if (keyCode === 27 && params.allowEscapeKey === true) { 393 $targetElement = $cancelButton; 394 (0, _handleDom.fireClick)($targetElement, e); 395 } else { 396 // Fallback - let the browser handle it. 397 $targetElement = undefined; 398 } 399 } 400}; 401 402exports.default = handleKeyDown; 403 404},{"./handle-dom":3,"./handle-swal-dom":5}],5:[function(require,module,exports){ 405'use strict'; 406 407Object.defineProperty(exports, "__esModule", { 408 value: true 409}); 410exports.fixVerticalPosition = exports.resetInputError = exports.resetInput = exports.openModal = exports.getInput = exports.getOverlay = exports.getModal = exports.sweetAlertInitialize = undefined; 411 412var _handleDom = require('./handle-dom'); 413 414var _defaultParams = require('./default-params'); 415 416var _defaultParams2 = _interopRequireDefault(_defaultParams); 417 418var _injectedHtml = require('./injected-html'); 419 420var _injectedHtml2 = _interopRequireDefault(_injectedHtml); 421 422function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 423 424var modalClass = '.sweet-alert'; 425var overlayClass = '.sweet-overlay'; 426 427/* 428 * Add modal + overlay to DOM 429 */ 430 431 432var sweetAlertInitialize = function sweetAlertInitialize() { 433 var sweetWrap = document.createElement('div'); 434 sweetWrap.innerHTML = _injectedHtml2.default; 435 436 // Append elements to body 437 while (sweetWrap.firstChild) { 438 document.body.appendChild(sweetWrap.firstChild); 439 } 440}; 441 442/* 443 * Get DOM element of modal 444 */ 445var getModal = function getModal() { 446 var $modal = document.querySelector(modalClass); 447 448 if (!$modal) { 449 sweetAlertInitialize(); 450 $modal = getModal(); 451 } 452 453 return $modal; 454}; 455 456/* 457 * Get DOM element of input (in modal) 458 */ 459var getInput = function getInput() { 460 var $modal = getModal(); 461 if ($modal) { 462 return $modal.querySelector('input'); 463 } 464}; 465 466/* 467 * Get DOM element of overlay 468 */ 469var getOverlay = function getOverlay() { 470 return document.querySelector(overlayClass); 471}; 472 473/* 474 * Animation when opening modal 475 */ 476var openModal = function openModal(callback) { 477 var $modal = getModal(); 478 (0, _handleDom.fadeIn)(getOverlay(), 10); 479 (0, _handleDom.show)($modal); 480 (0, _handleDom.addClass)($modal, 'showSweetAlert'); 481 (0, _handleDom.removeClass)($modal, 'hideSweetAlert'); 482 483 window.previousActiveElement = document.activeElement; 484 var $okButton = $modal.querySelector('button.confirm'); 485 $okButton.focus(); 486 487 setTimeout(function () { 488 (0, _handleDom.addClass)($modal, 'visible'); 489 }, 500); 490 491 var timer = $modal.getAttribute('data-timer'); 492 493 if (timer !== 'null' && timer !== '') { 494 var timerCallback = callback; 495 $modal.timeout = setTimeout(function () { 496 var doneFunctionExists = (timerCallback || null) && $modal.getAttribute('data-has-done-function') === 'true'; 497 if (doneFunctionExists) { 498 timerCallback(null); 499 } else { 500 sweetAlert.close(); 501 } 502 }, timer); 503 } 504}; 505 506/* 507 * Reset the styling of the input 508 * (for example if errors have been shown) 509 */ 510var resetInput = function resetInput() { 511 var $modal = getModal(); 512 var $input = getInput(); 513 514 (0, _handleDom.removeClass)($modal, 'show-input'); 515 $input.value = _defaultParams2.default.inputValue; 516 $input.setAttribute('type', _defaultParams2.default.inputType); 517 $input.setAttribute('placeholder', _defaultParams2.default.inputPlaceholder); 518 519 resetInputError(); 520}; 521 522var resetInputError = function resetInputError(event) { 523 // If press enter => ignore 524 if (event && event.keyCode === 13) { 525 return false; 526 } 527 528 var $modal = getModal(); 529 530 var $errorIcon = $modal.querySelector('.sa-input-error'); 531 (0, _handleDom.removeClass)($errorIcon, 'show'); 532 533 var $errorContainer = $modal.querySelector('.form-group'); 534 (0, _handleDom.removeClass)($errorContainer, 'has-error'); 535}; 536 537/* 538 * Set "margin-top"-property on modal based on its computed height 539 */ 540var fixVerticalPosition = function fixVerticalPosition() { 541 var $modal = getModal(); 542 $modal.style.marginTop = (0, _handleDom.getTopMargin)(getModal()); 543}; 544 545exports.sweetAlertInitialize = sweetAlertInitialize; 546exports.getModal = getModal; 547exports.getOverlay = getOverlay; 548exports.getInput = getInput; 549exports.openModal = openModal; 550exports.resetInput = resetInput; 551exports.resetInputError = resetInputError; 552exports.fixVerticalPosition = fixVerticalPosition; 553 554},{"./default-params":1,"./handle-dom":3,"./injected-html":6}],6:[function(require,module,exports){ 555"use strict"; 556 557Object.defineProperty(exports, "__esModule", { 558 value: true 559}); 560var injectedHTML = 561 562// Dark overlay 563"<div class=\"sweet-overlay\" tabIndex=\"-1\"></div>" + 564 565// Modal 566"<div class=\"sweet-alert\" tabIndex=\"-1\">" + 567 568// Error icon 569"<div class=\"sa-icon sa-error\">
569\n <span class=\"sa-x-mark\">\n <span class=\"sa-line sa-left\"></span>\n <span class=\"sa-line sa-right\"></span>\n </span>\n </div>" + 570 571// Warning icon 572"<div class=\"sa-icon sa-warning\">\n <span class=\"sa-body\"></span>\n <span class=\"sa-dot\"></span>\n </div>" + 573 574// Info icon 575"<div class=\"sa-icon sa-info\"></div>" + 576 577// Success icon 578"<div class=\"sa-icon sa-success\">\n <span class=\"sa-line sa-tip\"></span>\n <span class=\"sa-line sa-long\"></span>\n\n <div class=\"sa-placeholder\"></div>\n <div class=\"sa-fix\"></div>\n </div>" + "<div class=\"sa-icon sa-custom\"></div>" + 579 580// Title, text and input 581"<h2>Title</h2>\n <p class=\"lead text-muted\">Text</p>\n <div class=\"form-group\">\n <input type=\"text\" class=\"form-control\" tabIndex=\"3\" />\n <span class=\"sa-input-error help-block\">\n <span class=\"glyphicon glyphicon-exclamation-sign\"></span> <span class=\"sa-help-text\">Not valid</span>\n </span>\n </div>" + 582 583// Cancel and confirm buttons 584"<div class=\"sa-button-container\">\n <button class=\"cancel btn btn-lg\" tabIndex=\"2\">Cancel</button>\n <div class=\"sa-confirm-button-container\">\n <button class=\"confirm btn btn-lg\" tabIndex=\"1\">OK</button>" + 585 586// Loading animation 587"<div class=\"la-ball-fall\">\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n </div>" + 588 589// End of modal 590"</div>"; 591 592exports.default = injectedHTML; 593 594},{}],7:[function(require,module,exports){ 595'use strict'; 596 597Object.defineProperty(exports, "__esModule", { 598 value: true 599}); 600 601var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; 602 603var _utils = require('./utils'); 604 605var _handleSwalDom = require('./handle-swal-dom'); 606 607var _handleDom = require('./handle-dom'); 608 609var alertTypes = ['error', 'warning', 'info', 'success', 'input', 'prompt']; 610 611/* 612 * Set type, text and actions on modal 613 */ 614var setParameters = function setParameters(params) { 615 var modal = (0, _handleSwalDom.getModal)(); 616 617 var $title = modal.querySelector('h2'); 618 var $text = modal.querySelector('p'); 619 var $cancelBtn = modal.querySelector('button.cancel'); 620 var $confirmBtn = modal.querySelector('button.confirm'); 621 622 /* 623 * Title 624 */ 625 $title.innerHTML = params.html ? params.title : (0, _handleDom.escapeHtml)(params.title).split('\n').join('<br>'); 626 627 /* 628 * Text 629 */ 630 $text.innerHTML = params.html ? params.text : (0, _handleDom.escapeHtml)(params.text || '').split('\n').join('<br>'); 631 if (params.text) (0, _handleDom.show)($text); 632 633 /* 634 * Custom class 635 */ 636 if (params.customClass) { 637 (0, _handleDom.addClass)(modal, params.customClass); 638 modal.setAttribute('data-custom-class', params.customClass); 639 } else { 640 // Find previously set classes and remove them 641 var customClass = modal.getAttribute('data-custom-class'); 642 (0, _handleDom.removeClass)(modal, customClass); 643 modal.setAttribute('data-custom-class', ''); 644 } 645 646 /* 647 * Icon 648 */ 649 (0, _handleDom.hide)(modal.querySelectorAll('.sa-icon')); 650 651 if (params.type && !(0, _utils.isIE8)()) { 652 var _ret = function () { 653 654 var validType = false; 655 656 for (var i = 0; i < alertTypes.length; i++) { 657 if (params.type === alertTypes[i]) { 658 validType = true; 659 break; 660 } 661 } 662 663 if (!validType) { 664 logStr('Unknown alert type: ' + params.type); 665 return { 666 v: false 667 }; 668 } 669 670 var typesWithIcons = ['success', 'error', 'warning', 'info']; 671 var $icon = void 0; 672 673 if (typesWithIcons.indexOf(params.type) !== -1) { 674 $icon = modal.querySelector('.sa-icon.' + 'sa-' + params.type); 675 (0, _handleDom.show)($icon); 676 } 677 678 var $input = (0, _handleSwalDom.getInput)(); 679 680 // Animate icon 681 switch (params.type) { 682 683 case 'success': 684 (0, _handleDom.addClass)($icon, 'animate'); 685 (0, _handleDom.addClass)($icon.querySelector('.sa-tip'), 'animateSuccessTip'); 686 (0, _handleDom.addClass)($icon.querySelector('.sa-long'), 'animateSuccessLong'); 687 break; 688 689 case 'error': 690 (0, _handleDom.addClass)($icon, 'animateErrorIcon'); 691 (0, _handleDom.addClass)($icon.querySelector('.sa-x-mark'), 'animateXMark'); 692 break; 693 694 case 'warning': 695 (0, _handleDom.addClass)($icon, 'pulseWarning'); 696 (0, _handleDom.addClass)($icon.querySelector('.sa-body'), 'pulseWarningIns'); 697 (0, _handleDom.addClass)($icon.querySelector('.sa-dot'), 'pulseWarningIns'); 698 break; 699 700 case 'input': 701 case 'prompt': 702 $input.setAttribute('type', params.inputType); 703 $input.value = params.inputValue; 704 $input.setAttribute('placeholder', params.inputPlaceholder); 705 (0, _handleDom.addClass)(modal, 'show-input'); 706 setTimeout(function () { 707 $input.focus(); 708 $input.addEventListener('keyup', swal.resetInputError); 709 }, 400); 710 break; 711 } 712 }(); 713 714 if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; 715 } 716 717 /* 718 * Custom image 719 */ 720 if (params.imageUrl) { 721 var $customIcon = modal.querySelector('.sa-icon.sa-custom'); 722 723 $customIcon.style.backgroundImage = 'url(' + params.imageUrl + ')'; 724 (0, _handleDom.show)($customIcon); 725 726 var _imgWidth = 80; 727 var _imgHeight = 80; 728 729 if (params.imageSize) { 730 var dimensions = params.imageSize.toString().split('x'); 731 var imgWidth = dimensions[0]; 732 var imgHeight = dimensions[1]; 733 734 if (!imgWidth || !imgHeight) { 735 logStr('Parameter imageSize expects value with format WIDTHxHEIGHT, got ' + params.imageSize); 736 } else { 737 _imgWidth = imgWidth; 738 _imgHeight = imgHeight; 739 } 740 } 741 742 $customIcon.setAttribute('style', $customIcon.getAttribute('style') + 'width:' + _imgWidth + 'px; height:' + _imgHeight + 'px'); 743 } 744 745 /* 746 * Show cancel button? 747 */ 748 modal.setAttribute('data-has-cancel-button', params.showCancelButton); 749 if (params.showCancelButton) { 750 $cancelBtn.style.display = 'inline-block'; 751 } else { 752 (0, _handleDom.hide)($cancelBtn); 753 } 754 755 /* 756 * Show confirm button? 757 */ 758 modal.setAttribute('data-has-confirm-button', params.showConfirmButton); 759 if (params.showConfirmButton) { 760 $confirmBtn.style.display = 'inline-block'; 761 } else { 762 (0, _handleDom.hide)($confirmBtn); 763 } 764 765 /* 766 * Custom text on cancel/confirm buttons 767 */ 768 if (params.cancelButtonText) { 769 $cancelBtn.innerHTML = (0, _handleDom.escapeHtml)(params.cancelButtonText); 770 } 771 if (params.confirmButtonText) { 772 $confirmBtn.innerHTML = (0, _handleDom.escapeHtml)(params.confirmButtonText); 773 } 774 775 /* 776 * Reset confirm buttons to default class (Ugly fix) 777 */ 778 $confirmBtn.className = 'confirm btn btn-lg'; 779 780 /* 781 * Attach selected class to the sweet alert modal 782 */ 783 (0, _handleDom.addClass)(modal, params.containerClass); 784 785 /* 786 * Set confirm button to selected class 787 */ 788 (0, _handleDom.addClass)($confirmBtn, params.confirmButtonClass); 789 790 /* 791 * Set cancel button to selected class 792 */ 793 (0, _handleDom.addClass)($cancelBtn, params.cancelButtonClass); 794 795 /* 796 * Set title to selected class 797 */ 798 (0, _handleDom.addClass)($title, params.titleClass); 799 800 /* 801 * Set text to selected class 802 */ 803 (0, _handleDom.addClass)($text, params.textClass); 804 805 /* 806 * Allow outside click 807 */ 808 modal.setAttribute('data-allow-outside-click', params.allowOutsideClick); 809 810 /* 811 * Callback function 812 */ 813 var hasDoneFunction = params.doneFunction ? true : false; 814 modal.setAttribute('data-has-done-function', hasDoneFunction); 815 816 /* 817 * Animation 818 */ 819 if (!params.animation) { 820 modal.setAttribute('data-animation', 'none'); 821 } else if (typeof params.animation === 'string') { 822 modal.setAttribute('data-animation', params.animation); // Custom animation 823 } else { 824 modal.setAttribute('data-animation', 'pop'); 825 } 826 827 /* 828 * Timer 829 */ 830 modal.setAttribute('data-timer', params.timer); 831};
832 833exports.default = setParameters; 834 835},{"./handle-dom":3,"./handle-swal-dom":5,"./utils":8}],8:[function(require,module,exports){ 836'use strict'; 837 838Object.defineProperty(exports, "__esModule", { 839 value: true 840}); 841/* 842 * Allow user to pass their own params 843 */ 844var extend = function extend(a, b) { 845 for (var key in b) { 846 if (b.hasOwnProperty(key)) { 847 a[key] = b[key]; 848 } 849 } 850 return a; 851}; 852 853/* 854 * Check if the user is using Internet Explorer 8 (for fallbacks) 855 */ 856var isIE8 = function isIE8() { 857 return window.attachEvent && !window.addEventListener; 858}; 859 860/* 861 * IE compatible logging for developers 862 */ 863var logStr = function logStr(string) { 864 if (window.console) { 865 // IE... 866 window.console.log('SweetAlert: ' + string); 867 } 868}; 869 870exports.extend = extend; 871exports.isIE8 = isIE8; 872exports.logStr = logStr; 873 874},{}],9:[function(require,module,exports){ 875'use strict'; 876 877Object.defineProperty(exports, "__esModule", { 878 value: true 879}); 880 881var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; // SweetAlert 882// 2014-2015 (c) - Tristan Edwards 883// github.com/t4t5/sweetalert 884 885/* 886 * jQuery-like functions for manipulating the DOM 887 */ 888 889 890/* 891 * Handy utilities 892 */ 893 894 895/* 896 * Handle sweetAlert's DOM elements 897 */ 898 899 900// Handle button events and keyboard events 901 902 903// Default values 904 905 906var _handleDom = require('./modules/handle-dom'); 907 908var _utils = require('./modules/utils'); 909 910var _handleSwalDom = require('./modules/handle-swal-dom'); 911 912var _handleClick = require('./modules/handle-click'); 913 914var _handleKey = require('./modules/handle-key'); 915 916var _handleKey2 = _interopRequireDefault(_handleKey); 917 918var _defaultParams = require('./modules/default-params'); 919 920var _defaultParams2 = _interopRequireDefault(_defaultParams); 921 922var _setParams = require('./modules/set-params'); 923 924var _setParams2 = _interopRequireDefault(_setParams); 925 926function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 927 928/* 929 * Remember state in cases where opening and handling a modal will fiddle with it. 930 * (We also use window.previousActiveElement as a global variable) 931 */ 932var previousWindowKeyDown; 933var lastFocusedButton; 934 935/* 936 * Global sweetAlert function 937 * (this is what the user calls) 938 */ 939var sweetAlert, _swal; 940 941exports.default = sweetAlert = _swal = function swal() { 942 var customizations = arguments[0]; 943 944 (0, _handleDom.addClass)(document.body, 'stop-scrolling'); 945 (0, _handleSwalDom.resetInput)(); 946 947 /* 948 * Use argument if defined or default value from params object otherwise. 949 * Supports the case where a default value is boolean true and should be 950 * overridden by a corresponding explicit argument which is boolean false. 951 */ 952 function argumentOrDefault(key) { 953 var args = customizations; 954 return args[key] === undefined ? _defaultParams2.default[key] : args[key]; 955 } 956 957 if (customizations === undefined) { 958 (0, _utils.logStr)('SweetAlert expects at least 1 attribute!'); 959 return false; 960 } 961 962 var params = (0, _utils.extend)({}, _defaultParams2.default); 963 964 switch (typeof customizations === 'undefined' ? 'undefined' : _typeof(customizations)) { 965 966 // Ex: swal("Hello", "Just testing", "info"); 967 case 'string': 968 params.title = customizations; 969 params.text = arguments[1] || ''; 970 params.type = arguments[2] || ''; 971 break; 972 973 // Ex: swal({ title:"Hello", text: "Just testing", type: "info" }); 974 case 'object': 975 if (customizations.title === undefined) { 976 (0, _utils.logStr)('Missing "title" argument!'); 977 return false; 978 } 979 980 params.title = customizations.title; 981 982 for (var customName in _defaultParams2.default) { 983 params[customName] = argumentOrDefault(customName); 984 } 985 986 // Show "Confirm" instead of "OK" if cancel button is visible 987 params.confirmButtonText = params.showCancelButton ? 'Confirm' : _defaultParams2.default.confirmButtonText; 988 params.confirmButtonText = argumentOrDefault('confirmButtonText'); 989 990 // Callback function when clicking on "OK"/"Cancel" 991 params.doneFunction = arguments[1] || null; 992 993 break; 994 995 default: 996 (0, _utils.logStr)('Unexpected type of argument! Expected "string" or "object", got ' + (typeof customizations === 'undefined' ? 'undefined' : _typeof(customizations))); 997 return false; 998 999 } 1000 1001 (0, _setParams2.default)(params); 1002 (0, _handleSwalDom.fixVerticalPosition)(); 1003 (0, _handleSwalDom.openModal)(arguments[1]); 1004 1005 // Modal interactions 1006 var modal = (0, _handleSwalDom.getModal)(); 1007 1008 /* 1009 * Make sure all modal buttons respond to all events 1010 */ 1011 var $buttons = modal.querySelectorAll('button'); 1012 var buttonEvents = ['onclick']; 1013 var onButtonEvent = function onButtonEvent(e) { 1014 return (0, _handleClick.handleButton)(e, params, modal); 1015 }; 1016 1017 for (var btnIndex = 0; btnIndex < $buttons.length; btnIndex++) { 1018 for (var evtIndex = 0; evtIndex < buttonEvents.length; evtIndex++) { 1019 var btnEvt = buttonEvents[evtIndex]; 1020 $buttons[btnIndex][btnEvt] = onButtonEvent; 1021 } 1022 } 1023 1024 // Clicking outside the modal dismisses it (if allowed by user) 1025 (0, _handleSwalDom.getOverlay)().onclick = onButtonEvent; 1026 1027 previousWindowKeyDown = window.onkeydown; 1028 1029 var onKeyEvent = function onKeyEvent(e) { 1030 return (0, _handleKey2.default)(e, params, modal); 1031 }; 1032 window.onkeydown = onKeyEvent; 1033 1034 window.onfocus = function () { 1035 // When the user has focused away and focused back from the whole window. 1036 setTimeout(function () { 1037 // Put in a timeout to jump out of the event sequence. 1038 // Calling focus() in the event sequence confuses things. 1039 if (lastFocusedButton !== undefined) { 1040 lastFocusedButton.focus(); 1041 lastFocusedButton = undefined; 1042 } 1043 }, 0); 1044 }; 1045 1046 // Show alert with enabled buttons always 1047 _swal.enableButtons(); 1048}; 1049 1050/* 1051 * Set default params for each popup 1052 * @param {Object} userParams 1053 */ 1054 1055 1056sweetAlert.setDefaults = _swal.setDefaults = function (userParams) { 1057 if (!userParams) { 1058 throw new Error('userParams is required'); 1059 } 1060 if ((typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') { 1061 throw new Error('userParams has to be a object'); 1062 } 1063 1064 (0, _utils.extend)(_defaultParams2.default, userParams); 1065}; 1066 1067/* 1068 * Animation when closing modal 1069 */ 1070sweetAlert.close = _swal.close = function () { 1071 var modal = (0, _handleSwalDom.getModal)(); 1072 1073 (0, _handleDom.fadeOut)((0, _handleSwalDom.getOverlay)(), 5); 1074 (0, _handleDom.fadeOut)(modal, 5); 1075 (0, _handleDom.removeClass)(modal, 'showSweetAlert'); 1076 (0, _handleDom.addClass)(modal, 'hideSweetAlert'); 1077 (0, _handleDom.removeClass)(modal, 'visible'); 1078 1079 /* 1080 * Reset icon animations 1081 */ 1082 var $successIcon = modal.querySelector('.sa-icon.sa-success'); 1083 (0, _handleDom.removeClass)($successIcon, 'animate'); 1084 (0, _handleDom.removeClass)($successIcon.querySelector('.sa-tip'), 'animateSuccessTip'); 1085 (0, _handleDom.removeClass)($successIcon.querySelector('.sa-long'), 'animateSuccessLong'); 1086 1087 var $errorIcon = modal.querySelector('.sa-icon.sa-error'); 1088 (0, _handleDom.removeClass)($errorIcon, 'animateErrorIcon'); 1089 (0, _handleDom.removeClass)($errorIcon.querySelector('.sa-x-mark'), 'animateXMark'); 1090 1091 var $warningIcon = modal.querySelector('.sa-icon.sa-warning'); 1092 (0, _handleDom.removeClass)($warningIcon, 'pulseWarning'); 1093 (0, _handleDom.removeClass)($warningIcon.querySelector('.sa-body'), 'pulseWarningIns'); 1094 (0, _handleDom.removeClass)($warningIcon.querySelector('.sa-dot'), 'pulseWarningIns'); 1095 1096 // Reset custom class (delay so that UI changes aren't visible) 1097 setTimeout(function () { 1098 var customClass = modal.getAttribute('data-custom-class'); 1099 (0, _handleDom.removeClass)(modal, customClass); 1100 }, 300); 1101 1102 // Make page scrollable again 1103 (0, _handleDom.removeClass)(document.body, 'stop-scrolling'); 1104 1105 // Reset the page to its previous state 1106 window.onkeydown = previousWindowKeyDown; 1107 if (window.previousActiveElement) { 1108 window.previousActiveElement.focus(); 1109 } 1110 lastFocusedButton = undefined; 1111 clearTimeout(modal.timeout); 1112 1113 return true; 1114}; 1115 1116/* 1117 * Validation of the input field is done by user 1118 * If something is wrong => call showInputError with errorMessage 1119 */ 1120sweetAlert.showInputError = _swal.showInputError = function (errorMessage) { 1121 var modal = (0, _handleSwalDom.getModal)(); 1122 1123 var $errorIcon = modal.querySelector('.sa-input-error'); 1124 (0, _handleDom.addClass)($errorIcon, 'show'); 1125 1126 var $errorContainer = modal.querySelector('.form-group'); 1127 (0, _handleDom.addClass)($errorContainer, 'has-error'); 1128 1129 $errorContainer.querySelector('.sa-help-text').innerHTML = errorMessage; 1130 1131 setTimeout(function () { 1132 sweetAlert.enableButtons(); 1133 }, 1); 1134 1135 modal.querySelector('input').focus(); 1136}; 1137 1138/* 1139 * Reset input error DOM elements 1140 */ 1141sweetAlert.resetInputError = _swal.resetInputError = function (event) { 1142 // If press enter => ignore 1143 if (event && event.keyCode === 13) { 1144 return false; 1145 } 1146 1147 var $modal = (0, _handleSwalDom.getModal)(); 1148 1149 var $errorIcon = $modal.querySelector('.sa-input-error'); 1150 (0, _handleDom.removeClass)($errorIcon, 'show'); 1151 1152 var $errorContainer = $modal.querySelector('.form-group'); 1153 (0, _handleDom.removeClass)($errorContainer, 'has-error'); 1154};
1155 1156/* 1157 * Disable confirm and cancel buttons 1158 */ 1159sweetAlert.disableButtons = _swal.disableButtons = function (event) { 1160 var modal = (0, _handleSwalDom.getModal)(); 1161 var $confirmButton = modal.querySelector('button.confirm'); 1162 var $cancelButton = modal.querySelector('button.cancel'); 1163 $confirmButton.disabled = true; 1164 $cancelButton.disabled = true; 1165}; 1166 1167/* 1168 * Enable confirm and cancel buttons 1169 */ 1170sweetAlert.enableButtons = _swal.enableButtons = function (event) { 1171 var modal = (0, _handleSwalDom.getModal)(); 1172 var $confirmButton = modal.querySelector('button.confirm'); 1173 var $cancelButton = modal.querySelector('button.cancel'); 1174 $confirmButton.disabled = false; 1175 $cancelButton.disabled = false; 1176}; 1177 1178if (typeof window !== 'undefined') { 1179 // The 'handle-click' module requires 1180 // that 'sweetAlert' was set as global. 1181 window.sweetAlert = window.ihcSwal = sweetAlert; 1182} else { 1183 (0, _utils.logStr)('SweetAlert is a frontend module!'); 1184} 1185 1186},{"./modules/default-params":1,"./modules/handle-click":2,"./modules/handle-dom":3,"./modules/handle-key":4,"./modules/handle-swal-dom":5,"./modules/set-params":7,"./modules/utils":8}]},{},[9]); 1187 1188/* 1189 * Use SweetAlert with RequireJS 1190 */ 1191 1192if (typeof define === 'function' && define.amd) { 1193 define(function () { 1194 return sweetAlert; 1195 }); 1196} else if (typeof module !== 'undefined' && module.exports) { 1197 module.exports = sweetAlert; 1198} 1199 1200})(window, document);
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.