/home/mip/mip/public/vendor/laravel-filemanager/files/folder-1/821668/sweetalert2.tar
LICENSE 0000664 00000002111 15243426217 0005554 0 ustar 00 The MIT License (MIT)
Copyright (c) 2014 Tristan Edwards & Limon Monte
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
src/sweetalert2.scss 0000664 00000031627 15243426217 0010512 0 ustar 00 // SweetAlert2
// github.com/limonte/sweetalert2
@import 'colors';
body {
&.swal2-shown {
overflow-y: hidden;
}
&.swal2-iosfix {
position: fixed;
left: 0;
right: 0;
}
}
.swal2-container {
// centering
display: flex;
align-items: center;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
padding: 10px;
// backdrop
background-color: transparent;
z-index: 1060;
&.swal2-fade {
transition: background-color .1s;
}
&.swal2-shown {
background-color: $swal2-overlay;
}
}
.swal2-modal {
background-color: $swal2-white;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
border-radius: 5px;
box-sizing: border-box;
text-align: center;
margin: auto;
overflow-x: hidden;
overflow-y: auto;
display: none;
position: relative;
max-width: 100%;
&:focus {
outline: none;
}
&.swal2-loading {
overflow-y: hidden;
}
.swal2-title {
color: lighten($swal2-black, 35);
font-size: 30px;
text-align: center;
font-weight: 600;
text-transform: none;
position: relative;
margin: 0 0 .4em;
padding: 0;
display: block;
word-wrap: break-word;
}
.swal2-buttonswrapper {
margin-top: 15px;
&:not(.swal2-loading) {
.swal2-styled {
&[disabled] {
opacity: .4;
cursor: no-drop;
}
}
}
&.swal2-loading {
.swal2-styled {
&.swal2-confirm {
box-sizing: border-box;
border: 4px solid transparent;
border-color: transparent;
width: 40px;
height: 40px;
padding: 0;
margin: 7.5px;
vertical-align: top;
background-color: transparent !important;
color: transparent;
cursor: default;
border-radius: 100%;
animation: rotate-loading 1.5s linear 0s infinite normal;
user-select: none;
}
&.swal2-cancel {
margin-left: 30px;
margin-right: 30px;
}
}
:not(.swal2-styled) {
&.swal2-confirm {
&::after {
display: inline-block;
content: '';
margin-left: 5px 0 15px;
vertical-align: -1px;
height: 15px;
width: 15px;
border: 3px solid lighten($swal2-black, 60);
box-shadow: 1px 1px 1px $swal2-white;
border-right-color: transparent;
border-radius: 50%;
animation: rotate-loading 1.5s linear 0s infinite normal;
}
}
}
}
}
.swal2-styled {
border: 0;
border-radius: 3px;
box-shadow: none;
color: $swal2-white;
cursor: pointer;
font-size: 17px;
font-weight: 500;
margin: 15px 5px 0;
padding: 10px 32px;
}
.swal2-image {
margin: 20px auto;
max-width: 100%;
}
.swal2-close {
background: $swal2-transparent;
border: 0;
margin: 0;
padding: 0;
width: 38px;
height: 40px;
font-size: 36px;
line-height: 40px;
font-family: serif;
position: absolute;
top: 5px;
right: 8px;
cursor: pointer;
color: $swal2-close-button;
transition: color .1s ease;
&:hover {
color: $swal2-close-button-hover;
}
}
> .swal2-input,
> .swal2-file,
> .swal2-textarea,
> .swal2-select,
> .swal2-radio,
> .swal2-checkbox {
display: none;
}
.swal2-content {
font-size: 18px;
text-align: center;
font-weight: 300;
position: relative;
float: none;
margin: 0;
padding: 0;
line-height: normal;
color: lighten($swal2-black, 33);
word-wrap: break-word;
}
.swal2-input,
.swal2-file,
.swal2-textarea,
.swal2-select,
.swal2-radio,
.swal2-checkbox {
margin: 20px auto;
}
.swal2-input,
.swal2-file,
.swal2-textarea {
width: 100%;
box-sizing: border-box;
font-size: 18px;
border-radius: 3px;
border: 1px solid $swal2-input-border;
box-shadow: inset 0 1px 1px $swal2-input-box-shadow;
transition: border-color box-shadow .3s;
&.swal2-inputerror {
border-color: $swal2-error !important;
box-shadow: 0 0 2px $swal2-error !important;
}
&:focus {
outline: none;
border: 1px solid $swal2-input-border-focus;
box-shadow: 0 0 3px $swal2-input-box-shadow-focus;
&::placeholder {
transition: opacity .3s .03s ease;
opacity: .8;
}
}
&::placeholder {
color: lighten($swal2-black, 90);
}
}
.swal2-range {
input {
float: left;
width: 80%;
}
output {
float: right;
width: 20%;
font-size: 20px;
font-weight: 600;
text-align: center;
}
input,
output {
height: 43px;
line-height: 43px;
vertical-align: middle;
margin: 20px auto;
padding: 0;
}
}
.swal2-input {
height: 43px;
padding: 0 12px;
&[type='number'] {
max-width: 150px;
}
}
.swal2-file {
font-size: 20px;
}
.swal2-textarea {
height: 108px;
padding: 12px;
}
.swal2-select {
color: lighten($swal2-black, 33);
font-size: inherit;
padding: 5px 10px;
min-width: 40%;
max-width: 100%;
}
.swal2-radio {
border: 0;
label {
&:not(:first-child) {
margin-left: 20px;
}
}
input,
span {
vertical-align: middle;
}
input {
margin: 0 3px 0 0;
}
}
.swal2-checkbox {
color: lighten($swal2-black, 33);
input,
span {
vertical-align: middle;
}
}
.swal2-validationerror {
background-color: lighten($swal2-black, 94);
margin: 0 -20px;
overflow: hidden;
padding: 10px;
color: lighten($swal2-black, 50);
font-size: 16px;
font-weight: 300;
display: none;
&::before {
content: '!';
display: inline-block;
width: 24px;
height: 24px;
border-radius: 50%;
background-color: $swal2-validationerror-background;
color: $swal2-validationerror-color;
line-height: 24px;
text-align: center;
margin-right: 10px;
}
}
}
@supports (-ms-accelerator: true) {
.swal2-range {
input {
width: 100% !important;
}
output {
display: none;
}
}
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.swal2-range {
input {
width: 100% !important;
}
output {
display: none;
}
}
}
.swal2-icon {
width: 80px;
height: 80px;
border: 4px solid transparent;
border-radius: 50%;
margin: 20px auto 30px;
padding: 0;
position: relative;
box-sizing: content-box;
cursor: default;
user-select: none;
&.swal2-error {
border-color: $swal2-error;
.swal2-x-mark {
position: relative;
display: block;
}
[class^='swal2-x-mark-line'] {
position: absolute;
height: 5px;
width: 47px;
background-color: $swal2-error;
display: block;
top: 37px;
border-radius: 2px;
&[class$='left'] {
transform: rotate(45deg);
left: 17px;
}
&[class$='right'] {
transform: rotate(-45deg);
right: 16px;
}
}
}
&.swal2-warning {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: $swal2-warning;
border-color: lighten($swal2-warning, 7);
font-size: 60px;
line-height: 80px;
text-align: center;
}
&.swal2-info {
font-family: 'Open Sans', sans-serif;
color: $swal2-info;
border-color: lighten($swal2-info, 20);
font-size: 60px;
line-height: 80px;
text-align: center;
}
&.swal2-question {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: $swal2-question;
border-color: lighten($swal2-question, 20);
font-size: 60px;
line-height: 80px;
text-align: center;
}
&.swal2-success {
border-color: $swal2-success;
[class^='swal2-success-circular-line'] { // Emulate moving circular line
border-radius: 50%;
position: absolute;
width: 60px;
height: 120px;
transform: rotate(45deg);
&[class$='left'] {
border-radius: 120px 0 0 120px;
top: -7px;
left: -33px;
transform: rotate(-45deg);
transform-origin: 60px 60px;
}
&[class$='right'] {
border-radius: 0 120px 120px 0;
top: -11px;
left: 30px;
transform: rotate(-45deg);
transform-origin: 0 60px;
}
}
.swal2-success-ring { // Ring
width: 80px;
height: 80px;
border: 4px solid $swal2-success-border;
border-radius: 50%;
box-sizing: content-box;
position: absolute;
left: -4px;
top: -4px;
z-index: 2;
}
.swal2-success-fix { // Hide corners left from animation
width: 7px;
height: 90px;
position: absolute;
left: 28px;
top: 8px;
z-index: 1;
transform: rotate(-45deg);
}
[class^='swal2-success-line'] {
height: 5px;
background-color: $swal2-success;
display: block;
border-radius: 2px;
position: absolute;
z-index: 2;
&[class$='tip'] {
width: 25px;
left: 14px;
top: 46px;
transform: rotate(45deg);
}
&[class$='long'] {
width: 47px;
right: 8px;
top: 38px;
transform: rotate(-45deg);
}
}
}
}
.swal2-progresssteps {
$lightblue: #add8e6;
$blue: #3085d6;
font-weight: 600;
margin: 0 0 20px;
padding: 0;
li {
display: inline-block;
position: relative;
}
.swal2-progresscircle {
background: $blue;
border-radius: 2em;
color: $swal2-white;
height: 2em;
line-height: 2em;
text-align: center;
width: 2em;
z-index: 20;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
&.swal2-activeprogressstep {
background: $blue;
~ .swal2-progresscircle {
background: $lightblue;
}
~ .swal2-progressline {
background: $lightblue;
}
}
}
.swal2-progressline {
background: $blue;
height: .4em;
margin: 0 -1px;
z-index: 10;
}
}
// github.com/limonte/sweetalert2/issues/268
[class^='swal2'] {
-webkit-tap-highlight-color: $swal2-transparent;
}
// Animations
@mixin keyframes($animation-name) {
@keyframes #{$animation-name} {
@content;
}
}
@mixin animation($str) {
animation: #{$str};
}
// Modal animation
@include keyframes(showSweetAlert) {
0% {
transform: scale(.7);
}
45% {
transform: scale(1.05);
}
80% {
transform: scale(.95);
}
100% {
transform: scale(1);
}
}
@include keyframes(hideSweetAlert) {
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(.5);
opacity: 0;
}
}
.swal2-show {
@include animation('showSweetAlert 0.3s');
&.swal2-noanimation {
@include animation('none');
}
}
.swal2-hide {
@include animation('hideSweetAlert 0.15s forwards');
&.swal2-noanimation {
@include animation('none');
}
}
// Success icon animation
@include keyframes(animate-success-tip) {
0% {
width: 0;
left: 1px;
top: 19px;
}
54% {
width: 0;
left: 1px;
top: 19px;
}
70% {
width: 50px;
left: -8px;
top: 37px;
}
84% {
width: 17px;
left: 21px;
top: 48px;
}
100% {
width: 25px;
left: 14px;
top: 45px;
}
}
@include keyframes(animate-success-long) {
0% {
width: 0;
right: 46px;
top: 54px;
}
65% {
width: 0;
right: 46px;
top: 54px;
}
84% {
width: 55px;
right: 0;
top: 35px;
}
100% {
width: 47px;
right: 8px;
top: 38px;
}
}
@include keyframes(rotatePlaceholder) {
0% {
transform: rotate(-45deg);
}
5% {
transform: rotate(-45deg);
}
12% {
transform: rotate(-405deg);
}
100% {
transform: rotate(-405deg);
}
}
.swal2-animate-success-line-tip {
@include animation('animate-success-tip 0.75s');
}
.swal2-animate-success-line-long {
@include animation('animate-success-long 0.75s');
}
.swal2-success {
&.swal2-animate-success-icon {
.swal2-success-circular-line-right {
@include animation('rotatePlaceholder 4.25s ease-in');
}
}
}
// Error icon animation
@include keyframes(animate-error-icon) {
0% {
transform: rotateX(100deg);
opacity: 0;
}
100% {
transform: rotateX(0deg);
opacity: 1;
}
}
.swal2-animate-error-icon {
@include animation('animate-error-icon 0.5s');
}
@include keyframes(animate-x-mark) {
0% {
transform: scale(.4);
margin-top: 26px;
opacity: 0;
}
50% {
transform: scale(.4);
margin-top: 26px;
opacity: 0;
}
80% {
transform: scale(1.15);
margin-top: -6px;
}
100% {
transform: scale(1);
margin-top: 0;
opacity: 1;
}
}
.swal2-animate-x-mark {
@include animation('animate-x-mark 0.5s');
}
@include keyframes(rotate-loading) {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
src/sweetalert2.js 0000664 00000105367 15243426217 0010156 0 ustar 00 import defaultParams from './utils/params.js'
import { swalClasses, iconTypes } from './utils/classes.js'
import { colorLuminance } from './utils/utils.js'
import * as dom from './utils/dom.js'
let modalParams = Object.assign({}, defaultParams)
let queue = []
let swal2Observer
/*
* Set type, text and actions on modal
*/
const setParameters = (params) => {
const modal = dom.getModal() || dom.init(params)
for (let param in params) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn(`SweetAlert2: Unknown parameter "${param}"`)
}
}
// Set modal width
modal.style.width = (typeof params.width === 'number') ? params.width + 'px' : params.width
modal.style.padding = params.padding + 'px'
modal.style.background = params.background
const successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix')
for (let i = 0; i < successIconParts.length; i++) {
successIconParts[i].style.background = params.background
}
const title = dom.getTitle()
const content = dom.getContent()
const buttonsWrapper = dom.getButtonsWrapper()
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
const closeButton = dom.getCloseButton()
// Title
if (params.titleText) {
title.innerText = params.titleText
} else {
title.innerHTML = params.title.split('\n').join('<br>')
}
// Content
if (params.text || params.html) {
if (typeof params.html === 'object') {
content.innerHTML = ''
if (0 in params.html) {
for (let i = 0; i in params.html; i++) {
content.appendChild(params.html[i].cloneNode(true))
}
} else {
content.appendChild(params.html.cloneNode(true))
}
} else if (params.html) {
content.innerHTML = params.html
} else if (params.text) {
content.textContent = params.text
}
dom.show(content)
} else {
dom.hide(content)
}
// Close button
if (params.showCloseButton) {
dom.show(closeButton)
} else {
dom.hide(closeButton)
}
// Custom Class
modal.className = swalClasses.modal
if (params.customClass) {
dom.addClass(modal, params.customClass)
}
// Progress steps
let progressStepsContainer = dom.getProgressSteps()
let currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10)
if (params.progressSteps.length) {
dom.show(progressStepsContainer)
dom.empty(progressStepsContainer)
if (currentProgressStep >= params.progressSteps.length) {
console.warn(
'SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' +
'(currentProgressStep like JS arrays starts from 0)'
)
}
params.progressSteps.forEach((step, index) => {
let circle = document.createElement('li')
dom.addClass(circle, swalClasses.progresscircle)
circle.innerHTML = step
if (index === currentProgressStep) {
dom.addClass(circle, swalClasses.activeprogressstep)
}
progressStepsContainer.appendChild(circle)
if (index !== params.progressSteps.length - 1) {
let line = document.createElement('li')
dom.addClass(line, swalClasses.progressline)
line.style.width = params.progressStepsDistance
progressStepsContainer.appendChild(line)
}
})
} else {
dom.hide(progressStepsContainer)
}
// Icon
const icons = dom.getIcons()
for (let i = 0; i < icons.length; i++) {
dom.hide(icons[i])
}
if (params.type) {
let validType = false
for (let iconType in iconTypes) {
if (params.type === iconType) {
validType = true
break
}
}
if (!validType) {
console.error(`SweetAlert2: Unknown alert type: ${params.type}`)
return false
}
const icon = modal.querySelector(`.${swalClasses.icon}.${iconTypes[params.type]}`)
dom.show(icon)
// Animate icon
if (params.animation) {
switch (params.type) {
case 'success':
dom.addClass(icon, 'swal2-animate-success-icon')
dom.addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip')
dom.addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long')
break
case 'error':
dom.addClass(icon, 'swal2-animate-error-icon')
dom.addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark')
break
default:
break
}
}
}
// Custom image
const image = dom.getImage()
if (params.imageUrl) {
image.setAttribute('src', params.imageUrl)
dom.show(image)
if (params.imageWidth) {
image.setAttribute('width', params.imageWidth)
} else {
image.removeAttribute('width')
}
if (params.imageHeight) {
image.setAttribute('height', params.imageHeight)
} else {
image.removeAttribute('height')
}
image.className = swalClasses.image
if (params.imageClass) {
dom.addClass(image, params.imageClass)
}
} else {
dom.hide(image)
}
// Cancel button
if (params.showCancelButton) {
cancelButton.style.display = 'inline-block'
} else {
dom.hide(cancelButton)
}
// Confirm button
if (params.showConfirmButton) {
dom.removeStyleProperty(confirmButton, 'display')
} else {
dom.hide(confirmButton)
}
// Buttons wrapper
if (!params.showConfirmButton && !params.showCancelButton) {
dom.hide(buttonsWrapper)
} else {
dom.show(buttonsWrapper)
}
// Edit text on cancel and confirm buttons
confirmButton.innerHTML = params.confirmButtonText
cancelButton.innerHTML = params.cancelButtonText
// Set buttons to selected background colors
if (params.buttonsStyling) {
confirmButton.style.backgroundColor = params.confirmButtonColor
cancelButton.style.backgroundColor = params.cancelButtonColor
}
// Add buttons custom classes
confirmButton.className = swalClasses.confirm
dom.addClass(confirmButton, params.confirmButtonClass)
cancelButton.className = swalClasses.cancel
dom.addClass(cancelButton, params.cancelButtonClass)
// Buttons styling
if (params.buttonsStyling) {
dom.addClass(confirmButton, swalClasses.styled)
dom.addClass(cancelButton, swalClasses.styled)
} else {
dom.removeClass(confirmButton, swalClasses.styled)
dom.removeClass(cancelButton, swalClasses.styled)
confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = ''
cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = ''
}
// CSS animation
if (params.animation === true) {
dom.removeClass(modal, swalClasses.noanimation)
} else {
dom.addClass(modal, swalClasses.noanimation)
}
}
/*
* Animations
*/
const openModal = (animation, onComplete) => {
const container = dom.getContainer()
const modal = dom.getModal()
if (animation) {
dom.addClass(modal, swalClasses.show)
dom.addClass(container, swalClasses.fade)
dom.removeClass(modal, swalClasses.hide)
} else {
dom.removeClass(modal, swalClasses.fade)
}
dom.show(modal)
// scrolling is 'hidden' until animation is done, after that 'auto'
container.style.overflowY = 'hidden'
if (dom.animationEndEvent && !dom.hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(dom.animationEndEvent, function swalCloseEventFinished () {
modal.removeEventListener(dom.animationEndEvent, swalCloseEventFinished)
container.style.overflowY = 'auto'
})
} else {
container.style.overflowY = 'auto'
}
dom.addClass(document.documentElement, swalClasses.shown)
dom.addClass(document.body, swalClasses.shown)
dom.addClass(container, swalClasses.shown)
fixScrollbar()
iOSfix()
dom.states.previousActiveElement = document.activeElement
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal)
})
}
}
const fixScrollbar = () => {
// for queues, do not do this more than once
if (dom.states.previousBodyPadding !== null) {
return
}
// if the body has overflow
if (document.body.scrollHeight > window.innerHeight) {
// add padding so the content doesn't shift after removal of scrollbar
dom.states.previousBodyPadding = document.body.style.paddingRight
document.body.style.paddingRight = dom.measureScrollbar() + 'px'
}
}
const undoScrollbar = () => {
if (dom.states.previousBodyPadding !== null) {
document.body.style.paddingRight = dom.states.previousBodyPadding
dom.states.previousBodyPadding = null
}
}
// Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
const iOSfix = () => {
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream
if (iOS && !dom.hasClass(document.body, swalClasses.iosfix)) {
const offset = document.body.scrollTop
document.body.style.top = (offset * -1) + 'px'
dom.addClass(document.body, swalClasses.iosfix)
}
}
const undoIOSfix = () => {
if (dom.hasClass(document.body, swalClasses.iosfix)) {
const offset = parseInt(document.body.style.top, 10)
dom.removeClass(document.body, swalClasses.iosfix)
document.body.style.top = ''
document.body.scrollTop = (offset * -1)
}
}
// SweetAlert entry point
const sweetAlert = (...args) => {
if (args[0] === undefined) {
console.error('SweetAlert2 expects at least 1 attribute!')
return false
}
let params = Object.assign({}, modalParams)
switch (typeof args[0]) {
case 'string':
[params.title, params.html, params.type] = args
break
case 'object':
Object.assign(params, args[0])
params.extraParams = args[0].extraParams
if (params.input === 'email' && params.inputValidator === null) {
params.inputValidator = (email) => {
return new Promise((resolve, reject) => {
const emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/
if (emailRegex.test(email)) {
resolve()
} else {
reject('Invalid email address')
}
})
}
}
if (params.input === 'url' && params.inputValidator === null) {
params.inputValidator = (url) => {
return new Promise((resolve, reject) => {
// taken from https://stackoverflow.com/a/3809435/1331425
const urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/
if (urlRegex.test(url)) {
resolve()
} else {
reject('Invalid URL')
}
})
}
}
break
default:
console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + typeof args[0])
return false
}
setParameters(params)
const container = dom.getContainer()
const modal = dom.getModal()
return new Promise((resolve, reject) => {
// Close on timer
if (params.timer) {
modal.timeout = setTimeout(() => {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('timer')
} else {
resolve({dismiss: 'timer'})
}
}, params.timer)
}
// Get input element by specified type or, if type isn't specified, by params.input
const getInput = (inputType) => {
inputType = inputType || params.input
if (!inputType) {
return null
}
switch (inputType) {
case 'select':
case 'textarea':
case 'file':
return dom.getChildByClass(modal, swalClasses[inputType])
case 'checkbox':
return modal.querySelector(`.${swalClasses.checkbox} input`)
case 'radio':
return modal.querySelector(`.${swalClasses.radio} input:checked`) ||
modal.querySelector(`.${swalClasses.radio} input:first-child`)
case 'range':
return modal.querySelector(`.${swalClasses.range} input`)
default:
return dom.getChildByClass(modal, swalClasses.input)
}
}
// Get the value of the modal input
const getInputValue = () => {
const input = getInput()
if (!input) {
return null
}
switch (params.input) {
case 'checkbox':
return input.checked ? 1 : 0
case 'radio':
return input.checked ? input.value : null
case 'file':
return input.files.length ? input.files[0] : null
default:
return params.inputAutoTrim ? input.value.trim() : input.value
}
}
// input autofocus
if (params.input) {
setTimeout(() => {
const input = getInput()
if (input) {
dom.focusInput(input)
}
}, 0)
}
const confirm = (value) => {
if (params.showLoaderOnConfirm) {
sweetAlert.showLoading()
}
if (params.preConfirm) {
params.preConfirm(value, params.extraParams).then(
(preConfirmValue) => {
sweetAlert.closeModal(params.onClose)
resolve(preConfirmValue || value)
},
(error) => {
sweetAlert.hideLoading()
if (error) {
sweetAlert.showValidationError(error)
}
}
)
} else {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
resolve(value)
} else {
resolve({value: value})
}
}
}
// Mouse interactions
const onButtonEvent = (event) => {
const e = event || window.event
const target = e.target || e.srcElement
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
const targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target))
const targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target))
switch (e.type) {
case 'mouseover':
case 'mouseup':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1)
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1)
}
}
break
case 'mouseout':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = params.confirmButtonColor
} else if (targetedCancel) {
cancelButton.style.backgroundColor = params.cancelButtonColor
}
}
break
case 'mousedown':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2)
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2)
}
}
break
case 'click':
// Clicked 'confirm'
if (targetedConfirm && sweetAlert.isVisible()) {
sweetAlert.disableButtons()
if (params.input) {
const inputValue = getInputValue()
if (params.inputValidator) {
sweetAlert.disableInput()
params.inputValidator(inputValue, params.extraParams).then(
() => {
sweetAlert.enableButtons()
sweetAlert.enableInput()
confirm(inputValue)
},
(error) => {
sweetAlert.enableButtons()
sweetAlert.enableInput()
if (error) {
sweetAlert.showValidationError(error)
}
}
)
} else {
confirm(inputValue)
}
} else {
confirm(true)
}
// Clicked 'cancel'
} else if (targetedCancel && sweetAlert.isVisible()) {
sweetAlert.disableButtons()
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('cancel')
} else {
resolve({dismiss: 'cancel'})
}
}
break
default:
}
}
const buttons = modal.querySelectorAll('button')
for (let i = 0; i < buttons.length; i++) {
buttons[i].onclick = onButtonEvent
buttons[i].onmouseover = onButtonEvent
buttons[i].onmouseout = onButtonEvent
buttons[i].onmousedown = onButtonEvent
}
// Closing modal by close button
dom.getCloseButton().onclick = () => {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('close')
} else {
resolve({dismiss: 'close'})
}
}
// Closing modal by overlay click
container.onclick = (e) => {
if (e.target !== container) {
return
}
if (params.allowOutsideClick) {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('overlay')
} else {
resolve({dismiss: 'overlay'})
}
}
}
const buttonsWrapper = dom.getButtonsWrapper()
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
// Reverse buttons (Confirm on the right side)
if (params.reverseButtons) {
confirmButton.parentNode.insertBefore(cancelButton, confirmButton)
} else {
confirmButton.parentNode.insertBefore(confirmButton, cancelButton)
}
// Focus handling
const setFocus = (index, increment) => {
const focusableElements = dom.getFocusableElements(params.focusCancel)
// search for visible elements and select the next possible match
for (let i = 0; i < focusableElements.length; i++) {
index = index + increment
// rollover to first item
if (index === focusableElements.length) {
index = 0
// go to last item
} else if (index === -1) {
index = focusableElements.length - 1
}
// determine if element is visible
const el = focusableElements[index]
if (dom.isVisible(el)) {
return el.focus()
}
}
}
const handleKeyDown = (event) => {
const e = event || window.event
const keyCode = e.keyCode || e.which
if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
// Don't do work on keys we don't care about.
return
}
const targetElement = e.target || e.srcElement
const focusableElements = dom.getFocusableElements(params.focusCancel)
let btnIndex = -1 // Find the button - note, this is a nodelist, not an array.
for (let i = 0; i < focusableElements.length; i++) {
if (targetElement === focusableElements[i]) {
btnIndex = i
break
}
}
// TAB
if (keyCode === 9) {
if (!e.shiftKey) {
// Cycle to the next button
setFocus(btnIndex, 1)
} else {
// Cycle to the prev button
setFocus(btnIndex, -1)
}
e.stopPropagation()
e.preventDefault()
// ARROWS - switch focus between buttons
} else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
// focus Cancel button if Confirm button is currently focused
if (document.activeElement === confirmButton && dom.isVisible(cancelButton)) {
cancelButton.focus()
// and vice versa
} else if (document.activeElement === cancelButton && dom.isVisible(confirmButton)) {
confirmButton.focus()
}
// ENTER/SPACE
} else if (keyCode === 13 || keyCode === 32) {
if (btnIndex === -1 && params.allowEnterKey) {
// ENTER/SPACE clicked outside of a button.
if (params.focusCancel) {
dom.fireClick(cancelButton, e)
} else {
dom.fireClick(confirmButton, e)
}
e.stopPropagation()
e.preventDefault()
}
// ESC
} else if (keyCode === 27 && params.allowEscapeKey === true) {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('esc')
} else {
resolve({dismiss: 'esc'})
}
}
}
if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
dom.states.previousWindowKeyDown = window.onkeydown
window.onkeydown = handleKeyDown
}
// Loading state
if (params.buttonsStyling) {
confirmButton.style.borderLeftColor = params.confirmButtonColor
confirmButton.style.borderRightColor = params.confirmButtonColor
}
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
sweetAlert.hideLoading = sweetAlert.disableLoading = () => {
if (!params.showConfirmButton) {
dom.hide(confirmButton)
if (!params.showCancelButton) {
dom.hide(dom.getButtonsWrapper())
}
}
dom.removeClass(buttonsWrapper, swalClasses.loading)
dom.removeClass(modal, swalClasses.loading)
confirmButton.disabled = false
cancelButton.disabled = false
}
sweetAlert.getTitle = () => dom.getTitle()
sweetAlert.getContent = () => dom.getContent()
sweetAlert.getInput = () => getInput()
sweetAlert.getImage = () => dom.getImage()
sweetAlert.getButtonsWrapper = () => dom.getButtonsWrapper()
sweetAlert.getConfirmButton = () => dom.getConfirmButton()
sweetAlert.getCancelButton = () => dom.getCancelButton()
sweetAlert.enableButtons = () => {
confirmButton.disabled = false
cancelButton.disabled = false
}
sweetAlert.disableButtons = () => {
confirmButton.disabled = true
cancelButton.disabled = true
}
sweetAlert.enableConfirmButton = () => {
confirmButton.disabled = false
}
sweetAlert.disableConfirmButton = () => {
confirmButton.disabled = true
}
sweetAlert.enableInput = () => {
const input = getInput()
if (!input) {
return false
}
if (input.type === 'radio') {
const radiosContainer = input.parentNode.parentNode
const radios = radiosContainer.querySelectorAll('input')
for (let i = 0; i < radios.length; i++) {
radios[i].disabled = false
}
} else {
input.disabled = false
}
}
sweetAlert.disableInput = () => {
const input = getInput()
if (!input) {
return false
}
if (input && input.type === 'radio') {
const radiosContainer = input.parentNode.parentNode
const radios = radiosContainer.querySelectorAll('input')
for (let i = 0; i < radios.length; i++) {
radios[i].disabled = true
}
} else {
input.disabled = true
}
}
// Set modal min-height to disable scrolling inside the modal
sweetAlert.recalculateHeight = dom.debounce(() => {
const modal = dom.getModal()
if (!modal) {
return
}
const prevState = modal.style.display
modal.style.minHeight = ''
dom.show(modal)
modal.style.minHeight = (modal.scrollHeight + 1) + 'px'
modal.style.display = prevState
}, 50)
// Show block with validation error
sweetAlert.showValidationError = (error) => {
const validationError = dom.getValidationError()
validationError.innerHTML = error
dom.show(validationError)
const input = getInput()
if (input) {
dom.focusInput(input)
dom.addClass(input, swalClasses.inputerror)
}
}
// Hide block with validation error
sweetAlert.resetValidationError = () => {
const validationError = dom.getValidationError()
dom.hide(validationError)
sweetAlert.recalculateHeight()
const input = getInput()
if (input) {
dom.removeClass(input, swalClasses.inputerror)
}
}
sweetAlert.getProgressSteps = () => {
return params.progressSteps
}
sweetAlert.setProgressSteps = (progressSteps) => {
params.progressSteps = progressSteps
setParameters(params)
}
sweetAlert.showProgressSteps = () => {
dom.show(dom.getProgressSteps())
}
sweetAlert.hideProgressSteps = () => {
dom.hide(dom.getProgressSteps())
}
sweetAlert.enableButtons()
sweetAlert.hideLoading()
sweetAlert.resetValidationError()
// inputs
const inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea']
let input
for (let i = 0; i < inputTypes.length; i++) {
const inputClass = swalClasses[inputTypes[i]]
const inputContainer = dom.getChildByClass(modal, inputClass)
input = getInput(inputTypes[i])
// set attributes
if (input) {
for (let j in input.attributes) {
if (input.attributes.hasOwnProperty(j)) {
const attrName = input.attributes[j].name
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName)
}
}
}
for (let attr in params.inputAttributes) {
input.setAttribute(attr, params.inputAttributes[attr])
}
}
// set class
inputContainer.className = inputClass
if (params.inputClass) {
dom.addClass(inputContainer, params.inputClass)
}
dom.hide(inputContainer)
}
let populateInputOptions
switch (params.input) {
case 'text':
case 'email':
case 'password':
case 'number':
case 'tel':
case 'url':
input = dom.getChildByClass(modal, swalClasses.input)
input.value = params.inputValue
input.placeholder = params.inputPlaceholder
input.type = params.input
dom.show(input)
break
case 'file':
input = dom.getChildByClass(modal, swalClasses.file)
input.placeholder = params.inputPlaceholder
input.type = params.input
dom.show(input)
break
case 'range':
const range = dom.getChildByClass(modal, swalClasses.range)
const rangeInput = range.querySelector('input')
const rangeOutput = range.querySelector('output')
rangeInput.value = params.inputValue
rangeInput.type = params.input
rangeOutput.value = params.inputValue
dom.show(range)
break
case 'select':
const select = dom.getChildByClass(modal, swalClasses.select)
select.innerHTML = ''
if (params.inputPlaceholder) {
const placeholder = document.createElement('option')
placeholder.innerHTML = params.inputPlaceholder
placeholder.value = ''
placeholder.disabled = true
placeholder.selected = true
select.appendChild(placeholder)
}
populateInputOptions = (inputOptions) => {
for (let optionValue in inputOptions) {
const option = document.createElement('option')
option.value = optionValue
option.innerHTML = inputOptions[optionValue]
if (params.inputValue === optionValue) {
option.selected = true
}
select.appendChild(option)
}
dom.show(select)
select.focus()
}
break
case 'radio':
const radio = dom.getChildByClass(modal, swalClasses.radio)
radio.innerHTML = ''
populateInputOptions = (inputOptions) => {
for (let radioValue in inputOptions) {
const radioInput = document.createElement('input')
const radioLabel = document.createElement('label')
const radioLabelSpan = document.createElement('span')
radioInput.type = 'radio'
radioInput.name = swalClasses.radio
radioInput.value = radioValue
if (params.inputValue === radioValue) {
radioInput.checked = true
}
radioLabelSpan.innerHTML = inputOptions[radioValue]
radioLabel.appendChild(radioInput)
radioLabel.appendChild(radioLabelSpan)
radioLabel.for = radioInput.id
radio.appendChild(radioLabel)
}
dom.show(radio)
const radios = radio.querySelectorAll('input')
if (radios.length) {
radios[0].focus()
}
}
break
case 'checkbox':
const checkbox = dom.getChildByClass(modal, swalClasses.checkbox)
const checkboxInput = getInput('checkbox')
checkboxInput.type = 'checkbox'
checkboxInput.value = 1
checkboxInput.id = swalClasses.checkbox
checkboxInput.checked = Boolean(params.inputValue)
let label = checkbox.getElementsByTagName('span')
if (label.length) {
checkbox.removeChild(label[0])
}
label = document.createElement('span')
label.innerHTML = params.inputPlaceholder
checkbox.appendChild(label)
dom.show(checkbox)
break
case 'textarea':
const textarea = dom.getChildByClass(modal, swalClasses.textarea)
textarea.value = params.inputValue
textarea.placeholder = params.inputPlaceholder
dom.show(textarea)
break
case null:
break
default:
console.error(`SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "${params.input}"`)
break
}
if (params.input === 'select' || params.input === 'radio') {
if (params.inputOptions instanceof Promise) {
sweetAlert.showLoading()
params.inputOptions.then((inputOptions) => {
sweetAlert.hideLoading()
populateInputOptions(inputOptions)
})
} else if (typeof params.inputOptions === 'object') {
populateInputOptions(params.inputOptions)
} else {
console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + typeof params.inputOptions)
}
}
openModal(params.animation, params.onOpen)
// Focus the first element (input or button)
if (params.allowEnterKey) {
setFocus(-1, 1)
} else {
if (document.activeElement) {
document.activeElement.blur()
}
}
// fix scroll
dom.getContainer().scrollTop = 0
// Observe changes inside the modal and adjust height
if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
swal2Observer = new MutationObserver(sweetAlert.recalculateHeight)
swal2Observer.observe(modal, {childList: true, characterData: true, subtree: true})
}
})
}
/*
* Global function to determine if swal2 modal is shown
*/
sweetAlert.isVisible = () => {
return !!dom.getModal()
}
/*
* Global function for chaining sweetAlert modals
*/
sweetAlert.queue = (steps) => {
queue = steps
const resetQueue = () => {
queue = []
document.body.removeAttribute('data-swal2-queue-step')
}
let queueResult = []
return new Promise((resolve, reject) => {
(function step (i, callback) {
if (i < queue.length) {
document.body.setAttribute('data-swal2-queue-step', i)
sweetAlert(queue[i]).then(
(result) => {
queueResult.push(result)
step(i + 1, callback)
},
(dismiss) => {
resetQueue()
reject(dismiss)
}
)
} else {
resetQueue()
resolve(queueResult)
}
})(0)
})
}
/*
* Global function for getting the index of current modal in queue
*/
sweetAlert.getQueueStep = () => document.body.getAttribute('data-swal2-queue-step')
/*
* Global function for inserting a modal to the queue
*/
sweetAlert.insertQueueStep = (step, index) => {
if (index && index < queue.length) {
return queue.splice(index, 0, step)
}
return queue.push(step)
}
/*
* Global function for deleting a modal from the queue
*/
sweetAlert.deleteQueueStep = (index) => {
if (typeof queue[index] !== 'undefined') {
queue.splice(index, 1)
}
}
/*
* Global function to close sweetAlert
*/
sweetAlert.close = sweetAlert.closeModal = (onComplete) => {
const container = dom.getContainer()
const modal = dom.getModal()
if (!modal) {
return
}
dom.removeClass(modal, swalClasses.show)
dom.addClass(modal, swalClasses.hide)
clearTimeout(modal.timeout)
dom.resetPrevState()
const removeModalAndResetState = () => {
if (container.parentNode) {
container.parentNode.removeChild(container)
}
dom.removeClass(document.documentElement, swalClasses.shown)
dom.removeClass(document.body, swalClasses.shown)
undoScrollbar()
undoIOSfix()
}
// If animation is supported, animate
if (dom.animationEndEvent && !dom.hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(dom.animationEndEvent, function swalCloseEventFinished () {
modal.removeEventListener(dom.animationEndEvent, swalCloseEventFinished)
if (dom.hasClass(modal, swalClasses.hide)) {
removeModalAndResetState()
}
})
} else {
// Otherwise, remove immediately
removeModalAndResetState()
}
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal)
})
}
}
/*
* Global function to click 'Confirm' button
*/
sweetAlert.clickConfirm = () => dom.getConfirmButton().click()
/*
* Global function to click 'Cancel' button
*/
sweetAlert.clickCancel = () => dom.getCancelButton().click()
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
sweetAlert.showLoading = sweetAlert.enableLoading = () => {
const modal = dom.getModal()
if (!modal) {
sweetAlert('')
}
const buttonsWrapper = dom.getButtonsWrapper()
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
dom.show(buttonsWrapper)
dom.show(confirmButton, 'inline-block')
dom.addClass(buttonsWrapper, swalClasses.loading)
dom.addClass(modal, swalClasses.loading)
confirmButton.disabled = true
cancelButton.disabled = true
}
/**
* Set default params for each popup
* @param {Object} userParams
*/
sweetAlert.setDefaults = (userParams) => {
if (!userParams || typeof userParams !== 'object') {
return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object')
}
for (let param in userParams) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn(`SweetAlert2: Unknown parameter "${param}"`)
delete userParams[param]
}
}
Object.assign(modalParams, userParams)
}
/**
* Reset default params for each popup
*/
sweetAlert.resetDefaults = () => {
modalParams = Object.assign({}, defaultParams)
}
sweetAlert.noop = () => { }
sweetAlert.version = ''
sweetAlert.default = sweetAlert
export default sweetAlert
src/utils/utils.js 0000664 00000001453 15243426217 0010204 0 ustar 00 /*
* Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
*/
export const colorLuminance = (hex, lum) => {
// Validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '')
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
}
lum = lum || 0
// Convert to decimal and change luminosity
let rgb = '#'
for (let i = 0; i < 3; i++) {
let c = parseInt(hex.substr(i * 2, 2), 16)
c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16)
rgb += ('00' + c).substr(c.length)
}
return rgb
}
export const uniqueArray = (arr) => {
const result = []
for (var i in arr) {
if (result.indexOf(arr[i]) === -1) {
result.push(arr[i])
}
}
return result
}
src/utils/params.js 0000664 00000002022 15243426217 0010320 0 ustar 00 export default {
title: '',
titleText: '',
text: '',
html: '',
type: null,
customClass: '',
target: 'body',
animation: true,
allowOutsideClick: true,
allowEscapeKey: true,
allowEnterKey: true,
showConfirmButton: true,
showCancelButton: false,
preConfirm: null,
confirmButtonText: 'OK',
confirmButtonColor: '#3085d6',
confirmButtonClass: null,
cancelButtonText: 'Cancel',
cancelButtonColor: '#aaa',
cancelButtonClass: null,
buttonsStyling: true,
reverseButtons: false,
focusCancel: false,
showCloseButton: false,
showLoaderOnConfirm: false,
imageUrl: null,
imageWidth: null,
imageHeight: null,
imageClass: null,
timer: null,
width: 500,
padding: 20,
background: '#fff',
input: null,
inputPlaceholder: '',
inputValue: '',
inputOptions: {},
inputAutoTrim: true,
inputClass: null,
inputAttributes: {},
inputValidator: null,
progressSteps: [],
currentProgressStep: null,
progressStepsDistance: '40px',
onOpen: null,
onClose: null,
useRejections: true
}
src/utils/classes.js 0000664 00000001366 15243426217 0010504 0 ustar 00 export const swalPrefix = 'swal2-'
export const prefix = (items) => {
const result = {}
for (const i in items) {
result[items[i]] = swalPrefix + items[i]
}
return result
}
export const swalClasses = prefix([
'container',
'shown',
'iosfix',
'modal',
'overlay',
'fade',
'show',
'hide',
'noanimation',
'close',
'title',
'content',
'buttonswrapper',
'confirm',
'cancel',
'icon',
'image',
'input',
'file',
'range',
'select',
'radio',
'checkbox',
'textarea',
'inputerror',
'validationerror',
'progresssteps',
'activeprogressstep',
'progresscircle',
'progressline',
'loading',
'styled'
])
export const iconTypes = prefix([
'success',
'warning',
'info',
'question',
'error'
])
src/utils/dom.js 0000664 00000023547 15243426217 0007633 0 ustar 00 /* global MouseEvent */
import { default as sweetAlert } from '../sweetalert2.js'
import { swalClasses, iconTypes } from './classes.js'
import { uniqueArray } from './utils.js'
// Remember state in cases where opening and handling a modal will fiddle with it.
export const states = {
previousWindowKeyDown: null,
previousActiveElement: null,
previousBodyPadding: null
}
/*
* Add modal + overlay to DOM
*/
export const init = (params) => {
if (typeof document === 'undefined') {
console.error('SweetAlert2 requires document to initialize')
return
}
const container = document.createElement('div')
container.className = swalClasses.container
container.innerHTML = sweetHTML
let targetElement = document.querySelector(params.target)
if (!targetElement) {
console.warn(`SweetAlert2: Can't find the target "${params.target}"`)
targetElement = document.body
}
targetElement.appendChild(container)
const modal = getModal()
const input = getChildByClass(modal, swalClasses.input)
const file = getChildByClass(modal, swalClasses.file)
const range = modal.querySelector(`.${swalClasses.range} input`)
const rangeOutput = modal.querySelector(`.${swalClasses.range} output`)
const select = getChildByClass(modal, swalClasses.select)
const checkbox = modal.querySelector(`.${swalClasses.checkbox} input`)
const textarea = getChildByClass(modal, swalClasses.textarea)
input.oninput = () => {
sweetAlert.resetValidationError()
}
input.onkeydown = (event) => {
setTimeout(() => {
if (event.keyCode === 13 && params.allowEnterKey) {
event.stopPropagation()
sweetAlert.clickConfirm()
}
}, 0)
}
file.onchange = () => {
sweetAlert.resetValidationError()
}
range.oninput = () => {
sweetAlert.resetValidationError()
rangeOutput.value = range.value
}
range.onchange = () => {
sweetAlert.resetValidationError()
range.previousSibling.value = range.value
}
select.onchange = () => {
sweetAlert.resetValidationError()
}
checkbox.onchange = () => {
sweetAlert.resetValidationError()
}
textarea.oninput = () => {
sweetAlert.resetValidationError()
}
return modal
}
/*
* Manipulate DOM
*/
const sweetHTML = `
<div role="dialog" aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses.content}" class="${swalClasses.modal}" tabindex="-1">
<ul class="${swalClasses.progresssteps}"></ul>
<div class="${swalClasses.icon} ${iconTypes.error}">
<span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>
</div>
<div class="${swalClasses.icon} ${iconTypes.question}">?</div>
<div class="${swalClasses.icon} ${iconTypes.warning}">!</div>
<div class="${swalClasses.icon} ${iconTypes.info}">i</div>
<div class="${swalClasses.icon} ${iconTypes.success}">
<div class="swal2-success-circular-line-left"></div>
<span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
<div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>
<div class="swal2-success-circular-line-right"></div>
</div>
<img class="${swalClasses.image}">
<h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
<div id="${swalClasses.content}" class="${swalClasses.content}"></div>
<input class="${swalClasses.input}">
<input type="file" class="${swalClasses.file}">
<div class="${swalClasses.range}">
<output></output>
<input type="range">
</div>
<select class="${swalClasses.select}"></select>
<div class="${swalClasses.radio}"></div>
<label for="${swalClasses.checkbox}" class="${swalClasses.checkbox}">
<input type="checkbox">
</label>
<textarea class="${swalClasses.textarea}"></textarea>
<div class="${swalClasses.validationerror}"></div>
<div class="${swalClasses.buttonswrapper}">
<button type="button" class="${swalClasses.confirm}">OK</button>
<button type="button" class="${swalClasses.cancel}">Cancel</button>
</div>
<button type="button" class="${swalClasses.close}" aria-label="Close this dialog">×</button>
</div>
`.replace(/(^|\n)\s*/g, '')
export const getContainer = () => document.body.querySelector('.' + swalClasses.container)
export const getModal = () => getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null
export const getIcons = () => {
const modal = getModal()
return modal.querySelectorAll('.' + swalClasses.icon)
}
export const elementByClass = (className) => getContainer() ? getContainer().querySelector('.' + className) : null
export const getTitle = () => elementByClass(swalClasses.title)
export const getContent = () => elementByClass(swalClasses.content)
export const getImage = () => elementByClass(swalClasses.image)
export const getButtonsWrapper = () => elementByClass(swalClasses.buttonswrapper)
export const getProgressSteps = () => elementByClass(swalClasses.progresssteps)
export const getValidationError = () => elementByClass(swalClasses.validationerror)
export const getConfirmButton = () => elementByClass(swalClasses.confirm)
export const getCancelButton = () => elementByClass(swalClasses.cancel)
export const getCloseButton = () => elementByClass(swalClasses.close)
export const getFocusableElements = (focusCancel) => {
const buttons = [getConfirmButton(), getCancelButton()]
if (focusCancel) {
buttons.reverse()
}
const focusableElements = buttons.concat(Array.prototype.slice.call(
getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')
))
return uniqueArray(focusableElements)
}
export const hasClass = (elem, className) => {
if (elem.classList) {
return elem.classList.contains(className)
}
return false
}
export const focusInput = (input) => {
input.focus()
// place cursor at end of text in text input
if (input.type !== 'file') {
// http://stackoverflow.com/a/2345915/1331425
const val = input.value
input.value = ''
input.value = val
}
}
export const addClass = (elem, className) => {
if (!elem || !className) {
return
}
const classes = className.split(/\s+/).filter(Boolean)
classes.forEach((className) => {
elem.classList.add(className)
})
}
export const removeClass = (elem, className) => {
if (!elem || !className) {
return
}
const classes = className.split(/\s+/).filter(Boolean)
classes.forEach((className) => {
elem.classList.remove(className)
})
}
export const getChildByClass = (elem, className) => {
for (let i = 0; i < elem.childNodes.length; i++) {
if (hasClass(elem.childNodes[i], className)) {
return elem.childNodes[i]
}
}
}
export const show = (elem, display) => {
if (!display) {
display = 'block'
}
elem.style.opacity = ''
elem.style.display = display
}
export const hide = (elem) => {
elem.style.opacity = ''
elem.style.display = 'none'
}
export const empty = (elem) => {
while (elem.firstChild) {
elem.removeChild(elem.firstChild)
}
}
// borrowed from jqeury $(elem).is(':visible') implementation
export const isVisible = (elem) => elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length
export const removeStyleProperty = (elem, property) => {
if (elem.style.removeProperty) {
elem.style.removeProperty(property)
} else {
elem.style.removeAttribute(property)
}
}
export const fireClick = (node) => {
if (!isVisible(node)) {
return false
}
// Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/
// Then fixed for today's Chrome browser.
if (typeof MouseEvent === 'function') {
// Up-to-date approach
const mevt = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
})
node.dispatchEvent(mevt)
} else if (document.createEvent) {
// Fallback
const evt = document.createEvent('MouseEvents')
evt.initEvent('click', false, false)
node.dispatchEvent(evt)
} else if (document.createEventObject) {
node.fireEvent('onclick')
} else if (typeof node.onclick === 'function') {
node.onclick()
}
}
export const animationEndEvent = (() => {
const testEl = document.createElement('div')
const transEndEventNames = {
'WebkitAnimation': 'webkitAnimationEnd',
'OAnimation': 'oAnimationEnd oanimationend',
'msAnimation': 'MSAnimationEnd',
'animation': 'animationend'
}
for (const i in transEndEventNames) {
if (transEndEventNames.hasOwnProperty(i) &&
testEl.style[i] !== undefined) {
return transEndEventNames[i]
}
}
return false
})()
// Reset previous window keydown handler and focued element
export const resetPrevState = () => {
window.onkeydown = states.previousWindowKeyDown
if (states.previousActiveElement && states.previousActiveElement.focus) {
let x = window.scrollX
let y = window.scrollY
states.previousActiveElement.focus()
if (x && y) { // IE has no scrollX/scrollY support
window.scrollTo(x, y)
}
}
}
// Measure width of scrollbar
// https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
export const measureScrollbar = () => {
var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints
if (supportsTouch) {
return 0
}
const scrollDiv = document.createElement('div')
scrollDiv.style.width = '50px'
scrollDiv.style.height = '50px'
scrollDiv.style.overflow = 'scroll'
document.body.appendChild(scrollDiv)
const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
document.body.removeChild(scrollDiv)
return scrollbarWidth
}
// JavaScript Debounce Function
// Simplivied version of https://davidwalsh.name/javascript-debounce-function
export const debounce = (func, wait) => {
let timeout
return () => {
const later = () => {
timeout = null
func()
}
clearTimeout(timeout)
timeout = setTimeout(later, wait)
}
}
src/colors.scss 0000664 00000001634 15243426217 0007545 0 ustar 00 $swal2-white: #fff !default;
$swal2-black: #000 !default;
$swal2-transparent: rgba($swal2-black, 0) !default;
$swal2-success: #a5dc86 !default;
$swal2-success-border: rgba($swal2-success, .2) !default;
$swal2-error: #f27474 !default;
$swal2-warning: #f8bb86 !default;
$swal2-info: #3fc3ee !default;
$swal2-question: #87adbd !default;
$swal2-overlay: rgba($swal2-black, .4) !default;
$swal2-close-button: lighten($swal2-black, 80) !default;
$swal2-close-button-hover: #d55 !default;
$swal2-input-border: lighten($swal2-black, 85) !default;
$swal2-input-border-focus: #b4dbed !default;
$swal2-input-box-shadow: rgba($swal2-black, .06) !default;
$swal2-input-box-shadow-focus: #c4e6f5 !default;
$swal2-validationerror-background: #ea7d7d !default;
$swal2-validationerror-color: $swal2-white !default;
package.json 0000664 00000010467 15243426217 0007052 0 ustar 00 {
"_args": [
[
{
"raw": "sweetalert2",
"scope": null,
"escapedName": "sweetalert2",
"name": "sweetalert2",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"D:\\"
]
],
"_from": "sweetalert2@latest",
"_id": "sweetalert2@6.6.5",
"_inCache": true,
"_location": "/sweetalert2",
"_nodeVersion": "7.10.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/sweetalert2-6.6.5.tgz_1496696262717_0.5821304954588413"
},
"_npmUser": {
"name": "limonte",
"email": "limon.monte@gmail.com"
},
"_npmVersion": "4.2.0",
"_phantomChildren": {},
"_requested": {
"raw": "sweetalert2",
"scope": null,
"escapedName": "sweetalert2",
"name": "sweetalert2",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-6.6.5.tgz",
"_shasum": "ffffc1064711ff7870bc8aefe1678f95ecc290db",
"_shrinkwrap": null,
"_spec": "sweetalert2",
"_where": "D:\\",
"author": {
"name": "Limon Monte",
"email": "limon.monte@gmail.com",
"url": "https://limonte.github.io"
},
"bugs": {
"url": "https://github.com/limonte/sweetalert2/issues"
},
"contributors": [
{
"name": "Johan Fagerberg",
"url": "https://github.com/birjolaxew"
},
{
"name": "Morgan Touverey-Quilling",
"email": "mtouverey@alembic-dev.com",
"url": "https://github.com/toverux"
},
{
"name": "Sam Turrell",
"email": "sam@samturrell.co.uk",
"url": "http://samturrell.co.uk"
},
{
"name": "Tristan Edwards",
"email": "tristan.edwards@me.com",
"url": "http://tristanedwards.me"
},
{
"name": "Leo Correa",
"email": "lcorr005@gmail.com",
"url": "https://leonardocorrea.com/"
},
{
"name": "Joseph Schultz",
"url": "https://github.com/acupajoe"
}
],
"dependencies": {},
"description": "A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert",
"devDependencies": {
"babel-plugin-external-helpers": "latest",
"babel-plugin-transform-object-assign": "latest",
"babel-preset-es2015": "latest",
"gulp": "latest",
"gulp-autoprefixer": "latest",
"gulp-clean-css": "latest",
"gulp-rename": "latest",
"gulp-rollup": "latest",
"gulp-sass": "latest",
"gulp-sass-lint": "latest",
"gulp-standard": "^8.0.0",
"gulp-uglify": "latest",
"rollup": "latest",
"rollup-plugin-babel": "latest",
"standard": "^8.0.0",
"testem": "latest",
"uglify-js": "latest"
},
"directories": {},
"dist": {
"shasum": "ffffc1064711ff7870bc8aefe1678f95ecc290db",
"tarball": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-6.6.5.tgz"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"dist",
"src",
"sweetalert2.d.ts"
],
"gitHead": "d73e218940dafc45ca998099dcafc9bf2d244349",
"homepage": "https://limonte.github.io/sweetalert2/",
"jsnext:main": "src/sweetalert2.js",
"keywords": [
"sweetalert",
"sweetalert2",
"alert",
"prompt"
],
"license": "MIT",
"main": "dist/sweetalert2.js",
"maintainers": [
{
"name": "birjolaxew",
"email": "johanringmann@gmail.com"
},
{
"name": "jdcrensh",
"email": "jdcrensh@gmail.com"
},
{
"name": "limonte",
"email": "limon.monte@gmail.com"
},
{
"name": "samturrell",
"email": "sam@samturrell.co.uk"
},
{
"name": "toverux",
"email": "mtouverey@methodinthemadness.eu"
}
],
"name": "sweetalert2",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/limonte/sweetalert2.git"
},
"scripts": {
"assume-dist-unchanged": "git ls-files dist | tr '\\n' ' ' | xargs git update-index --assume-unchanged",
"no-assume-dist-unchanged": "git ls-files dist | tr '\\n' ' ' | xargs git update-index --no-assume-unchanged",
"test": "testem ci"
},
"standard": {
"ignore": [
"dist/"
],
"global": [
"gemini",
"MutationObserver"
]
},
"types": "sweetalert2.d.ts",
"version": "6.6.5"
}
dist/sweetalert2.min.js 0000664 00000054157 15243426217 0011114 0 ustar 00 !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Sweetalert2=t()}(this,function(){"use strict";var e={title:"",titleText:"",text:"",html:"",type:null,customClass:"",target:"body",animation:!0,allowOutsideClick:!0,allowEscapeKey:!0,allowEnterKey:!0,showConfirmButton:!0,showCancelButton:!1,preConfirm:null,confirmButtonText:"OK",confirmButtonColor:"#3085d6",confirmButtonClass:null,cancelButtonText:"Cancel",cancelButtonColor:"#aaa",cancelButtonClass:null,buttonsStyling:!0,reverseButtons:!1,focusCancel:!1,showCloseButton:!1,showLoaderOnConfirm:!1,imageUrl:null,imageWidth:null,imageHeight:null,imageClass:null,timer:null,width:500,padding:20,background:"#fff",input:null,inputPlaceholder:"",inputValue:"",inputOptions:{},inputAutoTrim:!0,inputClass:null,inputAttributes:{},inputValidator:null,progressSteps:[],currentProgressStep:null,progressStepsDistance:"40px",onOpen:null,onClose:null,useRejections:!0},t=function(e){var t={};for(var n in e)t[e[n]]="swal2-"+e[n];return t},n=t(["container","shown","iosfix","modal","overlay","fade","show","hide","noanimation","close","title","content","buttonswrapper","confirm","cancel","icon","image","input","file","range","select","radio","checkbox","textarea","inputerror","validationerror","progresssteps","activeprogressstep","progresscircle","progressline","loading","styled"]),o=t(["success","warning","info","question","error"]),r=function(e,t){(e=String(e).replace(/[^0-9a-f]/gi,"")).length<6&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),t=t||0;for(var n="#",o=0;o<3;o++){var r=parseInt(e.substr(2*o,2),16);n+=("00"+(r=Math.round(Math.min(Math.max(0,r+r*t),255)).toString(16))).substr(r.length)}return n},i=function(e){var t=[];for(var n in e)-1===t.indexOf(e[n])&&t.push(e[n]);return t},a={previousWindowKeyDown:null,previousActiveElement:null,previousBodyPadding:null},l=function(e){if("undefined"!=typeof document){var t=document.createElement("div");t.className=n.container,t.innerHTML=s;var o=document.querySelector(e.target);o||(console.warn("SweetAlert2: Can't find the target \""+e.target+'"'),o=document.body),o.appendChild(t);var r=c(),i=A(r,n.input),a=A(r,n.file),l=r.querySelector("."+n.range+" input"),u=r.querySelector("."+n.range+" output"),d=A(r,n.select),p=r.querySelector("."+n.checkbox+" input"),f=A(r,n.textarea);return i.oninput=function(){$.resetValidationError()},i.onkeydown=function(t){setTimeout(function(){13===t.keyCode&&e.allowEnterKey&&(t.stopPropagation(),$.clickConfirm())},0)},a.onchange=function(){$.resetValidationError()},l.oninput=function(){$.resetValidationError(),u.value=l.value},l.onchange=function(){$.resetValidationError(),l.previousSibling.value=l.value},d.onchange=function(){$.resetValidationError()},p.onchange=function(){$.resetValidationError()},f.oninput=function(){$.resetValidationError()},r}console.error("SweetAlert2 requires document to initialize")},s=('\n <div role="dialog" aria-labelledby="'+n.title+'" aria-describedby="'+n.content+'" class="'+n.modal+'" tabindex="-1">\n <ul class="'+n.progresssteps+'"></ul>\n <div class="'+n.icon+" "+o.error+'">\n <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n </div>\n <div class="'+n.icon+" "+o.question+'">?</div>\n <div class="'+n.icon+" "+o.warning+'">!</div>\n <div class="'+n.icon+" "+o.info+'">i</div>\n <div class="'+n.icon+" "+o.success+'">\n <div class="swal2-success-circular-line-left"></div>\n <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n <div class="swal2-success-circular-line-right"></div>\n </div>\n <img class="'+n.image+'">\n <h2 class="'+n.title+'" id="'+n.title+'"></h2>\n <div id="'+n.content+'" class="'+n.content+'"></div>\n <input class="'+n.input+'">\n <input type="file" class="'+n.file+'">\n <div class="'+n.range+'">\n <output></output>\n <input type="range">\n </div>\n <select class="'+n.select+'"></select>\n <div class="'+n.radio+'"></div>\n <label for="'+n.checkbox+'" class="'+n.checkbox+'">\n <input type="checkbox">\n </label>\n <textarea class="'+n.textarea+'"></textarea>\n <div class="'+n.validationerror+'"></div>\n <div class="'+n.buttonswrapper+'">\n <button type="button" class="'+n.confirm+'">OK</button>\n <button type="button" class="'+n.cancel+'">Cancel</button>\n </div>\n <button type="button" class="'+n.close+'" aria-label="Close this dialog">×</button>\n </div>\n').replace(/(^|\n)\s*/g,""),u=function(){return document.body.querySelector("."+n.container)},c=function(){return u()?u().querySelector("."+n.modal):null},d=function(){return c().querySelectorAll("."+n.icon)},p=function(e){return u()?u().querySelector("."+e):null},f=function(){return p(n.title)},m=function(){return p(n.content)},v=function(){return p(n.image)},h=function(){return p(n.buttonswrapper)},g=function(){return p(n.progresssteps)},y=function(){return p(n.validationerror)},b=function(){return p(n.confirm)},w=function(){return p(n.cancel)},C=function(){return p(n.close)},k=function(e){var t=[b(),w()];e&&t.reverse();var n=t.concat(Array.prototype.slice.call(c().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')));return i(n)},x=function(e,t){return!!e.classList&&e.classList.contains(t)},S=function(e){if(e.focus(),"file"!==e.type){var t=e.value;e.value="",e.value=t}},E=function(e,t){e&&t&&t.split(/\s+/).filter(Boolean).forEach(function(t){e.classList.add(t)})},B=function(e,t){e&&t&&t.split(/\s+/).filter(Boolean).forEach(function(t){e.classList.remove(t)})},A=function(e,t){for(var n=0;n<e.childNodes.length;n++)if(x(e.childNodes[n],t))return e.childNodes[n]},P=function(e,t){t||(t="block"),e.style.opacity="",e.style.display=t},T=function(e){e.style.opacity="",e.style.display="none"},L=function(e){for(;e.firstChild;)e.removeChild(e.firstChild)},M=function(e){return e.offsetWidth||e.offsetHeight||e.getClientRects().length},q=function(e,t){e.style.removeProperty?e.style.removeProperty(t):e.style.removeAttribute(t)},V=function(e){if(!M(e))return!1;if("function"==typeof MouseEvent){var t=new MouseEvent("click",{view:window,bubbles:!1,cancelable:!0});e.dispatchEvent(t)}else if(document.createEvent){var n=document.createEvent("MouseEvents");n.initEvent("click",!1,!1),e.dispatchEvent(n)}else document.createEventObject?e.fireEvent("onclick"):"function"==typeof e.onclick&&e.onclick()},O=function(){var e=document.createElement("div"),t={WebkitAnimation:"webkitAnimationEnd",OAnimation:"oAnimationEnd oanimationend",msAnimation:"MSAnimationEnd",animation:"animationend"};for(var n in t)if(t.hasOwnProperty(n)&&void 0!==e.style[n])return t[n];return!1}(),H=function(){if(window.onkeydown=a.previousWindowKeyDown,a.previousActiveElement&&a.previousActiveElement.focus){var e=window.scrollX,t=window.scrollY;a.previousActiveElement.focus(),e&&t&&window.scrollTo(e,t)}},N=function(){if("ontouchstart"in window||navigator.msMaxTouchPoints)return 0;var e=document.createElement("div");e.style.width="50px",e.style.height="50px",e.style.overflow="scroll",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t},j=function(e,t){var n=void 0;return function(){var o=function(){n=null,e()};clearTimeout(n),n=setTimeout(o,t)}},R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},K=I({},e),D=[],W=void 0,U=function(t){var r=c()||l(t);for(var i in t)e.hasOwnProperty(i)||"extraParams"===i||console.warn('SweetAlert2: Unknown parameter "'+i+'"');r.style.width="number"==typeof t.width?t.width+"px":t.width,r.style.padding=t.padding+"px",r.style.background=t.background;for(var a=r.querySelectorAll("[class^=swal2-success-circular-line], .swal2-success-fix"),s=0;s<a.length;s++)a[s].style.background=t.background;var u=f(),p=m(),y=h(),k=b(),x=w(),S=C();if(t.titleText?u.innerText=t.titleText:u.innerHTML=t.title.split("\n").join("<br>"),t.text||t.html){if("object"===R(t.html))if(p.innerHTML="",0 in t.html)for(var A=0;A in t.html;A++)p.appendChild(t.html[A].cloneNode(!0));else p.appendChild(t.html.cloneNode(!0));else t.html?p.innerHTML=t.html:t.text&&(p.textContent=t.text);P(p)}else T(p);t.showCloseButton?P(S):T(S),r.className=n.modal,t.customClass&&E(r,t.customClass);var M=g(),V=parseInt(null===t.currentProgressStep?$.getQueueStep():t.currentProgressStep,10);t.progressSteps.length?(P(M),L(M),V>=t.progressSteps.length&&console.warn("SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length (currentProgressStep like JS arrays starts from 0)"),t.progressSteps.forEach(function(e,o){var r=document.createElement("li");if(E(r,n.progresscircle),r.innerHTML=e,o===V&&E(r,n.activeprogressstep),M.appendChild(r),o!==t.progressSteps.length-1){var i=document.createElement("li");E(i,n.progressline),i.style.width=t.progressStepsDistance,M.appendChild(i)}})):T(M);for(var O=d(),H=0;H<O.length;H++)T(O[H]);if(t.type){var N=!1;for(var j in o)if(t.type===j){N=!0;break}if(!N)return console.error("SweetAlert2: Unknown alert type: "+t.type),!1;var I=r.querySelector("."+n.icon+"."+o[t.type]);if(P(I),t.animation)switch(t.type){case"success":E(I,"swal2-animate-success-icon"),E(I.querySelector(".swal2-success-line-tip"),"swal2-animate-success-line-tip"),E(I.querySelector(".swal2-success-line-long"),"swal2-animate-success-line-long");break;case"error":E(I,"swal2-animate-error-icon"),E(I.querySelector(".swal2-x-mark"),"swal2-animate-x-mark")}}var K=v();t.imageUrl?(K.setAttribute("src",t.imageUrl),P(K),t.imageWidth?K.setAttribute("width",t.imageWidth):K.removeAttribute("width"),t.imageHeight?K.setAttribute("height",t.imageHeight):K.removeAttribute("height"),K.className=n.image,t.imageClass&&E(K,t.imageClass)):T(K),t.showCancelButton?x.style.display="inline-block":T(x),t.showConfirmButton?q(k,"display"):T(k),t.showConfirmButton||t.showCancelButton?P(y):T(y),k.innerHTML=t.confirmButtonText,x.innerHTML=t.cancelButtonText,t.buttonsStyling&&(k.style.backgroundColor=t.confirmButtonColor,x.style.backgroundColor=t.cancelButtonColor),k.className=n.confirm,E(k,t.confirmButtonClass),x.className=n.cancel,E(x,t.cancelButtonClass),t.buttonsStyling?(E(k,n.styled),E(x,n.styled)):(B(k,n.styled),B(x,n.styled),k.style.backgroundColor=k.style.borderLeftColor=k.style.borderRightColor="",x.style.backgroundColor=x.style.borderLeftColor=x.style.borderRightColor=""),!0===t.animation?B(r,n.noanimation):E(r,n.noanimation)},z=function(e,t){var o=u(),r=c();e?(E(r,n.show),E(o,n.fade),B(r,n.hide)):B(r,n.fade),P(r),o.style.overflowY="hidden",O&&!x(r,n.noanimation)?r.addEventListener(O,function e(){r.removeEventListener(O,e),o.style.overflowY="auto"}):o.style.overflowY="auto",E(document.documentElement,n.shown),E(document.body,n.shown),E(o,n.shown),Z(),Y(),a.previousActiveElement=document.activeElement,null!==t&&"function"==typeof t&&setTimeout(function(){t(r)})},Z=function(){null===a.previousBodyPadding&&document.body.scrollHeight>window.innerHeight&&(a.previousBodyPadding=document.body.style.paddingRight,document.body.style.paddingRight=N()+"px")},Q=function(){null!==a.previousBodyPadding&&(document.body.style.paddingRight=a.previousBodyPadding,a.previousBodyPadding=null)},Y=function(){if(/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream&&!x(document.body,n.iosfix)){var e=document.body.scrollTop;document.body.style.top=-1*e+"px",E(document.body,n.iosfix)}},_=function(){if(x(document.body,n.iosfix)){var e=parseInt(document.body.style.top,10);B(document.body,n.iosfix),document.body.style.top="",document.body.scrollTop=-1*e}},$=function e(){for(var t=arguments.length,o=Array(t),i=0;i<t;i++)o[i]=arguments[i];if(void 0===o[0])return console.error("SweetAlert2 expects at least 1 attribute!"),!1;var l=I({},K);switch(R(o[0])){case"string":l.title=o[0],l.html=o[1],l.type=o[2];break;case"object":I(l,o[0]),l.extraParams=o[0].extraParams,"email"===l.input&&null===l.inputValidator&&(l.inputValidator=function(e){return new Promise(function(t,n){/^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/.test(e)?t():n("Invalid email address")})}),"url"===l.input&&null===l.inputValidator&&(l.inputValidator=function(e){return new Promise(function(t,n){/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/.test(e)?t():n("Invalid URL")})});break;default:return console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got '+R(o[0])),!1}U(l);var s=u(),d=c();return new Promise(function(t,o){l.timer&&(d.timeout=setTimeout(function(){e.closeModal(l.onClose),l.useRejections?o("timer"):t({dismiss:"timer"})},l.timer));var i=function(e){if(!(e=e||l.input))return null;switch(e){case"select":case"textarea":case"file":return A(d,n[e]);case"checkbox":return d.querySelector("."+n.checkbox+" input");case"radio":return d.querySelector("."+n.radio+" input:checked")||d.querySelector("."+n.radio+" input:first-child");case"range":return d.querySelector("."+n.range+" input");default:return A(d,n.input)}},p=function(){var e=i();if(!e)return null;switch(l.input){case"checkbox":return e.checked?1:0;case"radio":return e.checked?e.value:null;case"file":return e.files.length?e.files[0]:null;default:return l.inputAutoTrim?e.value.trim():e.value}};l.input&&setTimeout(function(){var e=i();e&&S(e)},0);for(var x=function(n){l.showLoaderOnConfirm&&e.showLoading(),l.preConfirm?l.preConfirm(n,l.extraParams).then(function(o){e.closeModal(l.onClose),t(o||n)},function(t){e.hideLoading(),t&&e.showValidationError(t)}):(e.closeModal(l.onClose),t(l.useRejections?n:{value:n}))},L=function(n){var i=n||window.event,a=i.target||i.srcElement,s=b(),u=w(),c=s&&(s===a||s.contains(a)),d=u&&(u===a||u.contains(a));switch(i.type){case"mouseover":case"mouseup":l.buttonsStyling&&(c?s.style.backgroundColor=r(l.confirmButtonColor,-.1):d&&(u.style.backgroundColor=r(l.cancelButtonColor,-.1)));break;case"mouseout":l.buttonsStyling&&(c?s.style.backgroundColor=l.confirmButtonColor:d&&(u.style.backgroundColor=l.cancelButtonColor));break;case"mousedown":l.buttonsStyling&&(c?s.style.backgroundColor=r(l.confirmButtonColor,-.2):d&&(u.style.backgroundColor=r(l.cancelButtonColor,-.2)));break;case"click":if(c&&e.isVisible())if(e.disableButtons(),l.input){var f=p();l.inputValidator?(e.disableInput(),l.inputValidator(f,l.extraParams).then(function(){e.enableButtons(),e.enableInput(),x(f)},function(t){e.enableButtons(),e.enableInput(),t&&e.showValidationError(t)})):x(f)}else x(!0);else d&&e.isVisible()&&(e.disableButtons(),e.closeModal(l.onClose),l.useRejections?o("cancel"):t({dismiss:"cancel"}))}},q=d.querySelectorAll("button"),O=0;O<q.length;O++)q[O].onclick=L,q[O].onmouseover=L,q[O].onmouseout=L,q[O].onmousedown=L;C().onclick=function(){e.closeModal(l.onClose),l.useRejections?o("close"):t({dismiss:"close"})},s.onclick=function(n){n.target===s&&l.allowOutsideClick&&(e.closeModal(l.onClose),l.useRejections?o("overlay"):t({dismiss:"overlay"}))};var H=h(),N=b(),I=w();l.reverseButtons?N.parentNode.insertBefore(I,N):N.parentNode.insertBefore(N,I);var K=function(e,t){for(var n=k(l.focusCancel),o=0;o<n.length;o++){(e+=t)===n.length?e=0:-1===e&&(e=n.length-1);var r=n[e];if(M(r))return r.focus()}},D=function(n){var r=n||window.event,i=r.keyCode||r.which;if(-1!==[9,13,32,27,37,38,39,40].indexOf(i)){for(var a=r.target||r.srcElement,s=k(l.focusCancel),u=-1,c=0;c<s.length;c++)if(a===s[c]){u=c;break}9===i?(r.shiftKey?K(u,-1):K(u,1),r.stopPropagation(),r.preventDefault()):37===i||38===i||39===i||40===i?document.activeElement===N&&M(I)?I.focus():document.activeElement===I&&M(N)&&N.focus():13===i||32===i?-1===u&&l.allowEnterKey&&(V(l.focusCancel?I:N),r.stopPropagation(),r.preventDefault()):27===i&&!0===l.allowEscapeKey&&(e.closeModal(l.onClose),l.useRejections?o("esc"):t({dismiss:"esc"}))}};window.onkeydown&&window.onkeydown.toString()===D.toString()||(a.previousWindowKeyDown=window.onkeydown,window.onkeydown=D),l.buttonsStyling&&(N.style.borderLeftColor=l.confirmButtonColor,N.style.borderRightColor=l.confirmButtonColor),e.hideLoading=e.disableLoading=function(){l.showConfirmButton||(T(N),l.showCancelButton||T(h())),B(H,n.loading),B(d,n.loading),N.disabled=!1,I.disabled=!1},e.getTitle=function(){return f()},e.getContent=function(){return m()},e.getInput=function(){return i()},e.getImage=function(){return v()},e.getButtonsWrapper=function(){return h()},e.getConfirmButton=function(){return b()},e.getCancelButton=function(){return w()},e.enableButtons=function(){N.disabled=!1,I.disabled=!1},e.disableButtons=function(){N.disabled=!0,I.disabled=!0},e.enableConfirmButton=function(){N.disabled=!1},e.disableConfirmButton=function(){N.disabled=!0},e.enableInput=function(){var e=i();if(!e)return!1;if("radio"===e.type)for(var t=e.parentNode.parentNode.querySelectorAll("input"),n=0;n<t.length;n++)t[n].disabled=!1;else e.disabled=!1},e.disableInput=function(){var e=i();if(!e)return!1;if(e&&"radio"===e.type)for(var t=e.parentNode.parentNode.querySelectorAll("input"),n=0;n<t.length;n++)t[n].disabled=!0;else e.disabled=!0},e.recalculateHeight=j(function(){var e=c();if(e){var t=e.style.display;e.style.minHeight="",P(e),e.style.minHeight=e.scrollHeight+1+"px",e.style.display=t}},50),e.showValidationError=function(e){var t=y();t.innerHTML=e,P(t);var o=i();o&&(S(o),E(o,n.inputerror))},e.resetValidationError=function(){var t=y();T(t),e.recalculateHeight();var o=i();o&&B(o,n.inputerror)},e.getProgressSteps=function(){return l.progressSteps},e.setProgressSteps=function(e){l.progressSteps=e,U(l)},e.showProgressSteps=function(){P(g())},e.hideProgressSteps=function(){T(g())},e.enableButtons(),e.hideLoading(),e.resetValidationError();for(var Z=["input","file","range","select","radio","checkbox","textarea"],Q=void 0,Y=0;Y<Z.length;Y++){var _=n[Z[Y]],$=A(d,_);if(Q=i(Z[Y])){for(var J in Q.attributes)if(Q.attributes.hasOwnProperty(J)){var X=Q.attributes[J].name;"type"!==X&&"value"!==X&&Q.removeAttribute(X)}for(var F in l.inputAttributes)Q.setAttribute(F,l.inputAttributes[F])}$.className=_,l.inputClass&&E($,l.inputClass),T($)}var G=void 0;switch(l.input){case"text":case"email":case"password":case"number":case"tel":case"url":(Q=A(d,n.input)).value=l.inputValue,Q.placeholder=l.inputPlaceholder,Q.type=l.input,P(Q);break;case"file":(Q=A(d,n.file)).placeholder=l.inputPlaceholder,Q.type=l.input,P(Q);break;case"range":var ee=A(d,n.range),te=ee.querySelector("input"),ne=ee.querySelector("output");te.value=l.inputValue,te.type=l.input,ne.value=l.inputValue,P(ee);break;case"select":var oe=A(d,n.select);if(oe.innerHTML="",l.inputPlaceholder){var re=document.createElement("option");re.innerHTML=l.inputPlaceholder,re.value="",re.disabled=!0,re.selected=!0,oe.appendChild(re)}G=function(e){for(var t in e){var n=document.createElement("option");n.value=t,n.innerHTML=e[t],l.inputValue===t&&(n.selected=!0),oe.appendChild(n)}P(oe),oe.focus()};break;case"radio":var ie=A(d,n.radio);ie.innerHTML="",G=function(e){for(var t in e){var o=document.createElement("input"),r=document.createElement("label"),i=document.createElement("span");o.type="radio",o.name=n.radio,o.value=t,l.inputValue===t&&(o.checked=!0),i.innerHTML=e[t],r.appendChild(o),r.appendChild(i),r.for=o.id,ie.appendChild(r)}P(ie);var a=ie.querySelectorAll("input");a.length&&a[0].focus()};break;case"checkbox":var ae=A(d,n.checkbox),le=i("checkbox");le.type="checkbox",le.value=1,le.id=n.checkbox,le.checked=Boolean(l.inputValue);var se=ae.getElementsByTagName("span");se.length&&ae.removeChild(se[0]),(se=document.createElement("span")).innerHTML=l.inputPlaceholder,ae.appendChild(se),P(ae);break;case"textarea":var ue=A(d,n.textarea);ue.value=l.inputValue,ue.placeholder=l.inputPlaceholder,P(ue);break;case null:break;default:console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "'+l.input+'"')}"select"!==l.input&&"radio"!==l.input||(l.inputOptions instanceof Promise?(e.showLoading(),l.inputOptions.then(function(t){e.hideLoading(),G(t)})):"object"===R(l.inputOptions)?G(l.inputOptions):console.error("SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got "+R(l.inputOptions))),z(l.animation,l.onOpen),l.allowEnterKey?K(-1,1):document.activeElement&&document.activeElement.blur(),u().scrollTop=0,"undefined"==typeof MutationObserver||W||(W=new MutationObserver(e.recalculateHeight)).observe(d,{childList:!0,characterData:!0,subtree:!0})})};return $.isVisible=function(){return!!c()},$.queue=function(e){D=e;var t=function(){D=[],document.body.removeAttribute("data-swal2-queue-step")},n=[];return new Promise(function(e,o){!function r(i,a){i<D.length?(document.body.setAttribute("data-swal2-queue-step",i),$(D[i]).then(function(e){n.push(e),r(i+1,a)},function(e){t(),o(e)})):(t(),e(n))}(0)})},$.getQueueStep=function(){return document.body.getAttribute("data-swal2-queue-step")},$.insertQueueStep=function(e,t){return t&&t<D.length?D.splice(t,0,e):D.push(e)},$.deleteQueueStep=function(e){void 0!==D[e]&&D.splice(e,1)},$.close=$.closeModal=function(e){var t=u(),o=c();if(o){B(o,n.show),E(o,n.hide),clearTimeout(o.timeout),H();var r=function(){t.parentNode&&t.parentNode.removeChild(t),B(document.documentElement,n.shown),B(document.body,n.shown),Q(),_()};O&&!x(o,n.noanimation)?o.addEventListener(O,function e(){o.removeEventListener(O,e),x(o,n.hide)&&r()}):r(),null!==e&&"function"==typeof e&&setTimeout(function(){e(o)})}},$.clickConfirm=function(){return b().click()},$.clickCancel=function(){return w().click()},$.showLoading=$.enableLoading=function(){var e=c();e||$("");var t=h(),o=b(),r=w();P(t),P(o,"inline-block"),E(t,n.loading),E(e,n.loading),o.disabled=!0,r.disabled=!0},$.setDefaults=function(t){if(!t||"object"!==(void 0===t?"undefined":R(t)))return console.error("SweetAlert2: the argument for setDefaults() is required and has to be a object");for(var n in t)e.hasOwnProperty(n)||"extraParams"===n||(console.warn('SweetAlert2: Unknown parameter "'+n+'"'),delete t[n]);I(K,t)},$.resetDefaults=function(){K=I({},e)},$.noop=function(){},$.version="6.6.5",$.default=$,$}),window.Sweetalert2&&(window.sweetAlert=window.swal=window.Sweetalert2); dist/sweetalert2.js 0000664 00000142302 15243426217 0010320 0 ustar 00 /*!
* sweetalert2 v6.6.5
* Released under the MIT License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Sweetalert2 = factory());
}(this, (function () { 'use strict';
var defaultParams = {
title: '',
titleText: '',
text: '',
html: '',
type: null,
customClass: '',
target: 'body',
animation: true,
allowOutsideClick: true,
allowEscapeKey: true,
allowEnterKey: true,
showConfirmButton: true,
showCancelButton: false,
preConfirm: null,
confirmButtonText: 'OK',
confirmButtonColor: '#3085d6',
confirmButtonClass: null,
cancelButtonText: 'Cancel',
cancelButtonColor: '#aaa',
cancelButtonClass: null,
buttonsStyling: true,
reverseButtons: false,
focusCancel: false,
showCloseButton: false,
showLoaderOnConfirm: false,
imageUrl: null,
imageWidth: null,
imageHeight: null,
imageClass: null,
timer: null,
width: 500,
padding: 20,
background: '#fff',
input: null,
inputPlaceholder: '',
inputValue: '',
inputOptions: {},
inputAutoTrim: true,
inputClass: null,
inputAttributes: {},
inputValidator: null,
progressSteps: [],
currentProgressStep: null,
progressStepsDistance: '40px',
onOpen: null,
onClose: null,
useRejections: true
};
var swalPrefix = 'swal2-';
var prefix = function prefix(items) {
var result = {};
for (var i in items) {
result[items[i]] = swalPrefix + items[i];
}
return result;
};
var swalClasses = prefix(['container', 'shown', 'iosfix', 'modal', 'overlay', 'fade', 'show', 'hide', 'noanimation', 'close', 'title', 'content', 'buttonswrapper', 'confirm', 'cancel', 'icon', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea', 'inputerror', 'validationerror', 'progresssteps', 'activeprogressstep', 'progresscircle', 'progressline', 'loading', 'styled']);
var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
/*
* Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
*/
var colorLuminance = function colorLuminance(hex, lum) {
// Validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
lum = lum || 0;
// Convert to decimal and change luminosity
var rgb = '#';
for (var i = 0; i < 3; i++) {
var c = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
rgb += ('00' + c).substr(c.length);
}
return rgb;
};
var uniqueArray = function uniqueArray(arr) {
var result = [];
for (var i in arr) {
if (result.indexOf(arr[i]) === -1) {
result.push(arr[i]);
}
}
return result;
};
/* global MouseEvent */
// Remember state in cases where opening and handling a modal will fiddle with it.
var states = {
previousWindowKeyDown: null,
previousActiveElement: null,
previousBodyPadding: null
/*
* Add modal + overlay to DOM
*/
};var init = function init(params) {
if (typeof document === 'undefined') {
console.error('SweetAlert2 requires document to initialize');
return;
}
var container = document.createElement('div');
container.className = swalClasses.container;
container.innerHTML = sweetHTML;
var targetElement = document.querySelector(params.target);
if (!targetElement) {
console.warn('SweetAlert2: Can\'t find the target "' + params.target + '"');
targetElement = document.body;
}
targetElement.appendChild(container);
var modal = getModal();
var input = getChildByClass(modal, swalClasses.input);
var file = getChildByClass(modal, swalClasses.file);
var range = modal.querySelector('.' + swalClasses.range + ' input');
var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
var select = getChildByClass(modal, swalClasses.select);
var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
var textarea = getChildByClass(modal, swalClasses.textarea);
input.oninput = function () {
sweetAlert.resetValidationError();
};
input.onkeydown = function (event) {
setTimeout(function () {
if (event.keyCode === 13 && params.allowEnterKey) {
event.stopPropagation();
sweetAlert.clickConfirm();
}
}, 0);
};
file.onchange = function () {
sweetAlert.resetValidationError();
};
range.oninput = function () {
sweetAlert.resetValidationError();
rangeOutput.value = range.value;
};
range.onchange = function () {
sweetAlert.resetValidationError();
range.previousSibling.value = range.value;
};
select.onchange = function () {
sweetAlert.resetValidationError();
};
checkbox.onchange = function () {
sweetAlert.resetValidationError();
};
textarea.oninput = function () {
sweetAlert.resetValidationError();
};
return modal;
};
/*
* Manipulate DOM
*/
var sweetHTML = ('\n <div role="dialog" aria-labelledby="' + swalClasses.title + '" aria-describedby="' + swalClasses.content + '" class="' + swalClasses.modal + '" tabindex="-1">\n <ul class="' + swalClasses.progresssteps + '"></ul>\n <div class="' + swalClasses.icon + ' ' + iconTypes.error + '">\n <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n </div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.question + '">?</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.warning + '">!</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.info + '">i</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.success + '">\n <div class="swal2-success-circular-line-left"></div>\n <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n <div class="swal2-success-circular-line-right"></div>\n </div>\n <img class="' + swalClasses.image + '">\n <h2 class="' + swalClasses.title + '" id="' + swalClasses.title + '"></h2>\n <div id="' + swalClasses.content + '" class="' + swalClasses.content + '"></div>\n <input class="' + swalClasses.input + '">\n <input type="file" class="' + swalClasses.file + '">\n <div class="' + swalClasses.range + '">\n <output></output>\n <input type="range">\n </div>\n <select class="' + swalClasses.select + '"></select>\n <div class="' + swalClasses.radio + '"></div>\n <label for="' + swalClasses.checkbox + '" class="' + swalClasses.checkbox + '">\n <input type="checkbox">\n </label>\n <textarea class="' + swalClasses.textarea + '"></textarea>\n <div class="' + swalClasses.validationerror + '"></div>\n <div class="' + swalClasses.buttonswrapper + '">\n <button type="button" class="' + swalClasses.confirm + '">OK</button>\n <button type="button" class="' + swalClasses.cancel + '">Cancel</button>\n </div>\n <button type="button" class="' + swalClasses.close + '" aria-label="Close this dialog">×</button>\n </div>\n').replace(/(^|\n)\s*/g, '');
var getContainer = function getContainer() {
return document.body.querySelector('.' + swalClasses.container);
};
var getModal = function getModal() {
return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
};
var getIcons = function getIcons() {
var modal = getModal();
return modal.querySelectorAll('.' + swalClasses.icon);
};
var elementByClass = function elementByClass(className) {
return getContainer() ? getContainer().querySelector('.' + className) : null;
};
var getTitle = function getTitle() {
return elementByClass(swalClasses.title);
};
var getContent = function getContent() {
return elementByClass(swalClasses.content);
};
var getImage = function getImage() {
return elementByClass(swalClasses.image);
};
var getButtonsWrapper = function getButtonsWrapper() {
return elementByClass(swalClasses.buttonswrapper);
};
var getProgressSteps = function getProgressSteps() {
return elementByClass(swalClasses.progresssteps);
};
var getValidationError = function getValidationError() {
return elementByClass(swalClasses.validationerror);
};
var getConfirmButton = function getConfirmButton() {
return elementByClass(swalClasses.confirm);
};
var getCancelButton = function getCancelButton() {
return elementByClass(swalClasses.cancel);
};
var getCloseButton = function getCloseButton() {
return elementByClass(swalClasses.close);
};
var getFocusableElements = function getFocusableElements(focusCancel) {
var buttons = [getConfirmButton(), getCancelButton()];
if (focusCancel) {
buttons.reverse();
}
var focusableElements = buttons.concat(Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')));
return uniqueArray(focusableElements);
};
var hasClass = function hasClass(elem, className) {
if (elem.classList) {
return elem.classList.contains(className);
}
return false;
};
var focusInput = function focusInput(input) {
input.focus
// place cursor at end of text in text input
();if (input.type !== 'file') {
// http://stackoverflow.com/a/2345915/1331425
var val = input.value;
input.value = '';
input.value = val;
}
};
var addClass = function addClass(elem, className) {
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/).filter(Boolean);
classes.forEach(function (className) {
elem.classList.add(className);
});
};
var removeClass = function removeClass(elem, className) {
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/).filter(Boolean);
classes.forEach(function (className) {
elem.classList.remove(className);
});
};
var getChildByClass = function getChildByClass(elem, className) {
for (var i = 0; i < elem.childNodes.length; i++) {
if (hasClass(elem.childNodes[i], className)) {
return elem.childNodes[i];
}
}
};
var show = function show(elem, display) {
if (!display) {
display = 'block';
}
elem.style.opacity = '';
elem.style.display = display;
};
var hide = function hide(elem) {
elem.style.opacity = '';
elem.style.display = 'none';
};
var empty = function empty(elem) {
while (elem.firstChild) {
elem.removeChild(elem.firstChild);
}
};
// borrowed from jqeury $(elem).is(':visible') implementation
var isVisible = function isVisible(elem) {
return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
};
var removeStyleProperty = function removeStyleProperty(elem, property) {
if (elem.style.removeProperty) {
elem.style.removeProperty(property);
} else {
elem.style.removeAttribute(property);
}
};
var fireClick = function fireClick(node) {
if (!isVisible(node)) {
return false;
}
// Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/
// Then fixed for today's Chrome browser.
if (typeof MouseEvent === 'function') {
// Up-to-date approach
var mevt = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
node.dispatchEvent(mevt);
} else if (document.createEvent) {
// Fallback
var evt = document.createEvent('MouseEvents');
evt.initEvent('click', false, false);
node.dispatchEvent(evt);
} else if (document.createEventObject) {
node.fireEvent('onclick');
} else if (typeof node.onclick === 'function') {
node.onclick();
}
};
var animationEndEvent = function () {
var testEl = document.createElement('div');
var transEndEventNames = {
'WebkitAnimation': 'webkitAnimationEnd',
'OAnimation': 'oAnimationEnd oanimationend',
'msAnimation': 'MSAnimationEnd',
'animation': 'animationend'
};
for (var i in transEndEventNames) {
if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
return transEndEventNames[i];
}
}
return false;
}
// Reset previous window keydown handler and focued element
();var resetPrevState = function resetPrevState() {
window.onkeydown = states.previousWindowKeyDown;
if (states.previousActiveElement && states.previousActiveElement.focus) {
var x = window.scrollX;
var y = window.scrollY;
states.previousActiveElement.focus();
if (x && y) {
// IE has no scrollX/scrollY support
window.scrollTo(x, y);
}
}
};
// Measure width of scrollbar
// https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
var measureScrollbar = function measureScrollbar() {
var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
if (supportsTouch) {
return 0;
}
var scrollDiv = document.createElement('div');
scrollDiv.style.width = '50px';
scrollDiv.style.height = '50px';
scrollDiv.style.overflow = 'scroll';
document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
};
// JavaScript Debounce Function
// Simplivied version of https://davidwalsh.name/javascript-debounce-function
var debounce = function debounce(func, wait) {
var timeout = void 0;
return function () {
var later = function later() {
timeout = null;
func();
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var modalParams = _extends({}, defaultParams);
var queue = [];
var swal2Observer = void 0;
/*
* Set type, text and actions on modal
*/
var setParameters = function setParameters(params) {
var modal = getModal() || init(params);
for (var param in params) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn('SweetAlert2: Unknown parameter "' + param + '"');
}
}
// Set modal width
modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
modal.style.padding = params.padding + 'px';
modal.style.background = params.background;
var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
for (var i = 0; i < successIconParts.length; i++) {
successIconParts[i].style.background = params.background;
}
var title = getTitle();
var content = getContent();
var buttonsWrapper = getButtonsWrapper();
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton();
var closeButton = getCloseButton
// Title
();if (params.titleText) {
title.innerText = params.titleText;
} else {
title.innerHTML = params.title.split('\n').join('<br>');
}
// Content
if (params.text || params.html) {
if (_typeof(params.html) === 'object') {
content.innerHTML = '';
if (0 in params.html) {
for (var _i = 0; _i in params.html; _i++) {
content.appendChild(params.html[_i].cloneNode(true));
}
} else {
content.appendChild(params.html.cloneNode(true));
}
} else if (params.html) {
content.innerHTML = params.html;
} else if (params.text) {
content.textContent = params.text;
}
show(content);
} else {
hide(content);
}
// Close button
if (params.showCloseButton) {
show(closeButton);
} else {
hide(closeButton);
}
// Custom Class
modal.className = swalClasses.modal;
if (params.customClass) {
addClass(modal, params.customClass);
}
// Progress steps
var progressStepsContainer = getProgressSteps();
var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
if (params.progressSteps.length) {
show(progressStepsContainer);
empty(progressStepsContainer);
if (currentProgressStep >= params.progressSteps.length) {
console.warn('SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
}
params.progressSteps.forEach(function (step, index) {
var circle = document.createElement('li');
addClass(circle, swalClasses.progresscircle);
circle.innerHTML = step;
if (index === currentProgressStep) {
addClass(circle, swalClasses.activeprogressstep);
}
progressStepsContainer.appendChild(circle);
if (index !== params.progressSteps.length - 1) {
var line = document.createElement('li');
addClass(line, swalClasses.progressline);
line.style.width = params.progressStepsDistance;
progressStepsContainer.appendChild(line);
}
});
} else {
hide(progressStepsContainer);
}
// Icon
var icons = getIcons();
for (var _i2 = 0; _i2 < icons.length; _i2++) {
hide(icons[_i2]);
}
if (params.type) {
var validType = false;
for (var iconType in iconTypes) {
if (params.type === iconType) {
validType = true;
break;
}
}
if (!validType) {
console.error('SweetAlert2: Unknown alert type: ' + params.type);
return false;
}
var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
show(icon
// Animate icon
);if (params.animation) {
switch (params.type) {
case 'success':
addClass(icon, 'swal2-animate-success-icon');
addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
break;
case 'error':
addClass(icon, 'swal2-animate-error-icon');
addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
break;
default:
break;
}
}
}
// Custom image
var image = getImage();
if (params.imageUrl) {
image.setAttribute('src', params.imageUrl);
show(image);
if (params.imageWidth) {
image.setAttribute('width', params.imageWidth);
} else {
image.removeAttribute('width');
}
if (params.imageHeight) {
image.setAttribute('height', params.imageHeight);
} else {
image.removeAttribute('height');
}
image.className = swalClasses.image;
if (params.imageClass) {
addClass(image, params.imageClass);
}
} else {
hide(image);
}
// Cancel button
if (params.showCancelButton) {
cancelButton.style.display = 'inline-block';
} else {
hide(cancelButton);
}
// Confirm button
if (params.showConfirmButton) {
removeStyleProperty(confirmButton, 'display');
} else {
hide(confirmButton);
}
// Buttons wrapper
if (!params.showConfirmButton && !params.showCancelButton) {
hide(buttonsWrapper);
} else {
show(buttonsWrapper);
}
// Edit text on cancel and confirm buttons
confirmButton.innerHTML = params.confirmButtonText;
cancelButton.innerHTML = params.cancelButtonText;
// Set buttons to selected background colors
if (params.buttonsStyling) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
cancelButton.style.backgroundColor = params.cancelButtonColor;
}
// Add buttons custom classes
confirmButton.className = swalClasses.confirm;
addClass(confirmButton, params.confirmButtonClass);
cancelButton.className = swalClasses.cancel;
addClass(cancelButton, params.cancelButtonClass
// Buttons styling
);if (params.buttonsStyling) {
addClass(confirmButton, swalClasses.styled);
addClass(cancelButton, swalClasses.styled);
} else {
removeClass(confirmButton, swalClasses.styled);
removeClass(cancelButton, swalClasses.styled);
confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
}
// CSS animation
if (params.animation === true) {
removeClass(modal, swalClasses.noanimation);
} else {
addClass(modal, swalClasses.noanimation);
}
};
/*
* Animations
*/
var openModal = function openModal(animation, onComplete) {
var container = getContainer();
var modal = getModal();
if (animation) {
addClass(modal, swalClasses.show);
addClass(container, swalClasses.fade);
removeClass(modal, swalClasses.hide);
} else {
removeClass(modal, swalClasses.fade);
}
show(modal
// scrolling is 'hidden' until animation is done, after that 'auto'
);container.style.overflowY = 'hidden';
if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
container.style.overflowY = 'auto';
});
} else {
container.style.overflowY = 'auto';
}
addClass(document.documentElement, swalClasses.shown);
addClass(document.body, swalClasses.shown);
addClass(container, swalClasses.shown);
fixScrollbar();
iOSfix();
states.previousActiveElement = document.activeElement;
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal);
});
}
};
var fixScrollbar = function fixScrollbar() {
// for queues, do not do this more than once
if (states.previousBodyPadding !== null) {
return;
}
// if the body has overflow
if (document.body.scrollHeight > window.innerHeight) {
// add padding so the content doesn't shift after removal of scrollbar
states.previousBodyPadding = document.body.style.paddingRight;
document.body.style.paddingRight = measureScrollbar() + 'px';
}
};
var undoScrollbar = function undoScrollbar() {
if (states.previousBodyPadding !== null) {
document.body.style.paddingRight = states.previousBodyPadding;
states.previousBodyPadding = null;
}
};
// Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
var iOSfix = function iOSfix() {
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
var offset = document.body.scrollTop;
document.body.style.top = offset * -1 + 'px';
addClass(document.body, swalClasses.iosfix);
}
};
var undoIOSfix = function undoIOSfix() {
if (hasClass(document.body, swalClasses.iosfix)) {
var offset = parseInt(document.body.style.top, 10);
removeClass(document.body, swalClasses.iosfix);
document.body.style.top = '';
document.body.scrollTop = offset * -1;
}
};
// SweetAlert entry point
var sweetAlert = function sweetAlert() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args[0] === undefined) {
console.error('SweetAlert2 expects at least 1 attribute!');
return false;
}
var params = _extends({}, modalParams);
switch (_typeof(args[0])) {
case 'string':
params.title = args[0];
params.html = args[1];
params.type = args[2];
break;
case 'object':
_extends(params, args[0]);
params.extraParams = args[0].extraParams;
if (params.input === 'email' && params.inputValidator === null) {
params.inputValidator = function (email) {
return new Promise(function (resolve, reject) {
var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
if (emailRegex.test(email)) {
resolve();
} else {
reject('Invalid email address');
}
});
};
}
if (params.input === 'url' && params.inputValidator === null) {
params.inputValidator = function (url) {
return new Promise(function (resolve, reject) {
// taken from https://stackoverflow.com/a/3809435/1331425
var urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/;
if (urlRegex.test(url)) {
resolve();
} else {
reject('Invalid URL');
}
});
};
}
break;
default:
console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
return false;
}
setParameters(params);
var container = getContainer();
var modal = getModal();
return new Promise(function (resolve, reject) {
// Close on timer
if (params.timer) {
modal.timeout = setTimeout(function () {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('timer');
} else {
resolve({ dismiss: 'timer' });
}
}, params.timer);
}
// Get input element by specified type or, if type isn't specified, by params.input
var getInput = function getInput(inputType) {
inputType = inputType || params.input;
if (!inputType) {
return null;
}
switch (inputType) {
case 'select':
case 'textarea':
case 'file':
return getChildByClass(modal, swalClasses[inputType]);
case 'checkbox':
return modal.querySelector('.' + swalClasses.checkbox + ' input');
case 'radio':
return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
case 'range':
return modal.querySelector('.' + swalClasses.range + ' input');
default:
return getChildByClass(modal, swalClasses.input);
}
};
// Get the value of the modal input
var getInputValue = function getInputValue() {
var input = getInput();
if (!input) {
return null;
}
switch (params.input) {
case 'checkbox':
return input.checked ? 1 : 0;
case 'radio':
return input.checked ? input.value : null;
case 'file':
return input.files.length ? input.files[0] : null;
default:
return params.inputAutoTrim ? input.value.trim() : input.value;
}
};
// input autofocus
if (params.input) {
setTimeout(function () {
var input = getInput();
if (input) {
focusInput(input);
}
}, 0);
}
var confirm = function confirm(value) {
if (params.showLoaderOnConfirm) {
sweetAlert.showLoading();
}
if (params.preConfirm) {
params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
sweetAlert.closeModal(params.onClose);
resolve(preConfirmValue || value);
}, function (error) {
sweetAlert.hideLoading();
if (error) {
sweetAlert.showValidationError(error);
}
});
} else {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
resolve(value);
} else {
resolve({ value: value });
}
}
};
// Mouse interactions
var onButtonEvent = function onButtonEvent(event) {
var e = event || window.event;
var target = e.target || e.srcElement;
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton();
var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
switch (e.type) {
case 'mouseover':
case 'mouseup':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
}
}
break;
case 'mouseout':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
} else if (targetedCancel) {
cancelButton.style.backgroundColor = params.cancelButtonColor;
}
}
break;
case 'mousedown':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
}
}
break;
case 'click':
// Clicked 'confirm'
if (targetedConfirm && sweetAlert.isVisible()) {
sweetAlert.disableButtons();
if (params.input) {
var inputValue = getInputValue();
if (params.inputValidator) {
sweetAlert.disableInput();
params.inputValidator(inputValue, params.extraParams).then(function () {
sweetAlert.enableButtons();
sweetAlert.enableInput();
confirm(inputValue);
}, function (error) {
sweetAlert.enableButtons();
sweetAlert.enableInput();
if (error) {
sweetAlert.showValidationError(error);
}
});
} else {
confirm(inputValue);
}
} else {
confirm(true);
}
// Clicked 'cancel'
} else if (targetedCancel && sweetAlert.isVisible()) {
sweetAlert.disableButtons();
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('cancel');
} else {
resolve({ dismiss: 'cancel' });
}
}
break;
default:
}
};
var buttons = modal.querySelectorAll('button');
for (var i = 0; i < buttons.length; i++) {
buttons[i].onclick = onButtonEvent;
buttons[i].onmouseover = onButtonEvent;
buttons[i].onmouseout = onButtonEvent;
buttons[i].onmousedown = onButtonEvent;
}
// Closing modal by close button
getCloseButton().onclick = function () {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('close');
} else {
resolve({ dismiss: 'close' });
}
};
// Closing modal by overlay click
container.onclick = function (e) {
if (e.target !== container) {
return;
}
if (params.allowOutsideClick) {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('overlay');
} else {
resolve({ dismiss: 'overlay' });
}
}
};
var buttonsWrapper = getButtonsWrapper();
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton
// Reverse buttons (Confirm on the right side)
();if (params.reverseButtons) {
confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
} else {
confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
}
// Focus handling
var setFocus = function setFocus(index, increment) {
var focusableElements = getFocusableElements(params.focusCancel
// search for visible elements and select the next possible match
);for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
index = index + increment;
// rollover to first item
if (index === focusableElements.length) {
index = 0;
// go to last item
} else if (index === -1) {
index = focusableElements.length - 1;
}
// determine if element is visible
var el = focusableElements[index];
if (isVisible(el)) {
return el.focus();
}
}
};
var handleKeyDown = function handleKeyDown(event) {
var e = event || window.event;
var keyCode = e.keyCode || e.which;
if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
// Don't do work on keys we don't care about.
return;
}
var targetElement = e.target || e.srcElement;
var focusableElements = getFocusableElements(params.focusCancel);
var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
if (targetElement === focusableElements[_i4]) {
btnIndex = _i4;
break;
}
}
// TAB
if (keyCode === 9) {
if (!e.shiftKey) {
// Cycle to the next button
setFocus(btnIndex, 1);
} else {
// Cycle to the prev button
setFocus(btnIndex, -1);
}
e.stopPropagation();
e.preventDefault
// ARROWS - switch focus between buttons
();
} else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
// focus Cancel button if Confirm button is currently focused
if (document.activeElement === confirmButton && isVisible(cancelButton)) {
cancelButton.focus
// and vice versa
();
} else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
confirmButton.focus();
}
// ENTER/SPACE
} else if (keyCode === 13 || keyCode === 32) {
if (btnIndex === -1 && params.allowEnterKey) {
// ENTER/SPACE clicked outside of a button.
if (params.focusCancel) {
fireClick(cancelButton, e);
} else {
fireClick(confirmButton, e);
}
e.stopPropagation();
e.preventDefault();
}
// ESC
} else if (keyCode === 27 && params.allowEscapeKey === true) {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('esc');
} else {
resolve({ dismiss: 'esc' });
}
}
};
if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
states.previousWindowKeyDown = window.onkeydown;
window.onkeydown = handleKeyDown;
}
// Loading state
if (params.buttonsStyling) {
confirmButton.style.borderLeftColor = params.confirmButtonColor;
confirmButton.style.borderRightColor = params.confirmButtonColor;
}
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
if (!params.showConfirmButton) {
hide(confirmButton);
if (!params.showCancelButton) {
hide(getButtonsWrapper());
}
}
removeClass(buttonsWrapper, swalClasses.loading);
removeClass(modal, swalClasses.loading);
confirmButton.disabled = false;
cancelButton.disabled = false;
};
sweetAlert.getTitle = function () {
return getTitle();
};
sweetAlert.getContent = function () {
return getContent();
};
sweetAlert.getInput = function () {
return getInput();
};
sweetAlert.getImage = function () {
return getImage();
};
sweetAlert.getButtonsWrapper = function () {
return getButtonsWrapper();
};
sweetAlert.getConfirmButton = function () {
return getConfirmButton();
};
sweetAlert.getCancelButton = function () {
return getCancelButton();
};
sweetAlert.enableButtons = function () {
confirmButton.disabled = false;
cancelButton.disabled = false;
};
sweetAlert.disableButtons = function () {
confirmButton.disabled = true;
cancelButton.disabled = true;
};
sweetAlert.enableConfirmButton = function () {
confirmButton.disabled = false;
};
sweetAlert.disableConfirmButton = function () {
confirmButton.disabled = true;
};
sweetAlert.enableInput = function () {
var input = getInput();
if (!input) {
return false;
}
if (input.type === 'radio') {
var radiosContainer = input.parentNode.parentNode;
var radios = radiosContainer.querySelectorAll('input');
for (var _i5 = 0; _i5 < radios.length; _i5++) {
radios[_i5].disabled = false;
}
} else {
input.disabled = false;
}
};
sweetAlert.disableInput = function () {
var input = getInput();
if (!input) {
return false;
}
if (input && input.type === 'radio') {
var radiosContainer = input.parentNode.parentNode;
var radios = radiosContainer.querySelectorAll('input');
for (var _i6 = 0; _i6 < radios.length; _i6++) {
radios[_i6].disabled = true;
}
} else {
input.disabled = true;
}
};
// Set modal min-height to disable scrolling inside the modal
sweetAlert.recalculateHeight = debounce(function () {
var modal = getModal();
if (!modal) {
return;
}
var prevState = modal.style.display;
modal.style.minHeight = '';
show(modal);
modal.style.minHeight = modal.scrollHeight + 1 + 'px';
modal.style.display = prevState;
}, 50
// Show block with validation error
);sweetAlert.showValidationError = function (error) {
var validationError = getValidationError();
validationError.innerHTML = error;
show(validationError);
var input = getInput();
if (input) {
focusInput(input);
addClass(input, swalClasses.inputerror);
}
};
// Hide block with validation error
sweetAlert.resetValidationError = function () {
var validationError = getValidationError();
hide(validationError);
sweetAlert.recalculateHeight();
var input = getInput();
if (input) {
removeClass(input, swalClasses.inputerror);
}
};
sweetAlert.getProgressSteps = function () {
return params.progressSteps;
};
sweetAlert.setProgressSteps = function (progressSteps) {
params.progressSteps = progressSteps;
setParameters(params);
};
sweetAlert.showProgressSteps = function () {
show(getProgressSteps());
};
sweetAlert.hideProgressSteps = function () {
hide(getProgressSteps());
};
sweetAlert.enableButtons();
sweetAlert.hideLoading();
sweetAlert.resetValidationError
// inputs
();var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
var input = void 0;
for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
var inputClass = swalClasses[inputTypes[_i7]];
var inputContainer = getChildByClass(modal, inputClass);
input = getInput(inputTypes[_i7]
// set attributes
);if (input) {
for (var j in input.attributes) {
if (input.attributes.hasOwnProperty(j)) {
var attrName = input.attributes[j].name;
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName);
}
}
}
for (var attr in params.inputAttributes) {
input.setAttribute(attr, params.inputAttributes[attr]);
}
}
// set class
inputContainer.className = inputClass;
if (params.inputClass) {
addClass(inputContainer, params.inputClass);
}
hide(inputContainer);
}
var populateInputOptions = void 0;
switch (params.input) {
case 'text':
case 'email':
case 'password':
case 'number':
case 'tel':
case 'url':
input = getChildByClass(modal, swalClasses.input);
input.value = params.inputValue;
input.placeholder = params.inputPlaceholder;
input.type = params.input;
show(input);
break;
case 'file':
input = getChildByClass(modal, swalClasses.file);
input.placeholder = params.inputPlaceholder;
input.type = params.input;
show(input);
break;
case 'range':
var range = getChildByClass(modal, swalClasses.range);
var rangeInput = range.querySelector('input');
var rangeOutput = range.querySelector('output');
rangeInput.value = params.inputValue;
rangeInput.type = params.input;
rangeOutput.value = params.inputValue;
show(range);
break;
case 'select':
var select = getChildByClass(modal, swalClasses.select);
select.innerHTML = '';
if (params.inputPlaceholder) {
var placeholder = document.createElement('option');
placeholder.innerHTML = params.inputPlaceholder;
placeholder.value = '';
placeholder.disabled = true;
placeholder.selected = true;
select.appendChild(placeholder);
}
populateInputOptions = function populateInputOptions(inputOptions) {
for (var optionValue in inputOptions) {
var option = document.createElement('option');
option.value = optionValue;
option.innerHTML = inputOptions[optionValue];
if (params.inputValue === optionValue) {
option.selected = true;
}
select.appendChild(option);
}
show(select);
select.focus();
};
break;
case 'radio':
var radio = getChildByClass(modal, swalClasses.radio);
radio.innerHTML = '';
populateInputOptions = function populateInputOptions(inputOptions) {
for (var radioValue in inputOptions) {
var radioInput = document.createElement('input');
var radioLabel = document.createElement('label');
var radioLabelSpan = document.createElement('span');
radioInput.type = 'radio';
radioInput.name = swalClasses.radio;
radioInput.value = radioValue;
if (params.inputValue === radioValue) {
radioInput.checked = true;
}
radioLabelSpan.innerHTML = inputOptions[radioValue];
radioLabel.appendChild(radioInput);
radioLabel.appendChild(radioLabelSpan);
radioLabel.for = radioInput.id;
radio.appendChild(radioLabel);
}
show(radio);
var radios = radio.querySelectorAll('input');
if (radios.length) {
radios[0].focus();
}
};
break;
case 'checkbox':
var checkbox = getChildByClass(modal, swalClasses.checkbox);
var checkboxInput = getInput('checkbox');
checkboxInput.type = 'checkbox';
checkboxInput.value = 1;
checkboxInput.id = swalClasses.checkbox;
checkboxInput.checked = Boolean(params.inputValue);
var label = checkbox.getElementsByTagName('span');
if (label.length) {
checkbox.removeChild(label[0]);
}
label = document.createElement('span');
label.innerHTML = params.inputPlaceholder;
checkbox.appendChild(label);
show(checkbox);
break;
case 'textarea':
var textarea = getChildByClass(modal, swalClasses.textarea);
textarea.value = params.inputValue;
textarea.placeholder = params.inputPlaceholder;
show(textarea);
break;
case null:
break;
default:
console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
break;
}
if (params.input === 'select' || params.input === 'radio') {
if (params.inputOptions instanceof Promise) {
sweetAlert.showLoading();
params.inputOptions.then(function (inputOptions) {
sweetAlert.hideLoading();
populateInputOptions(inputOptions);
});
} else if (_typeof(params.inputOptions) === 'object') {
populateInputOptions(params.inputOptions);
} else {
console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
}
}
openModal(params.animation, params.onOpen
// Focus the first element (input or button)
);if (params.allowEnterKey) {
setFocus(-1, 1);
} else {
if (document.activeElement) {
document.activeElement.blur();
}
}
// fix scroll
getContainer().scrollTop = 0;
// Observe changes inside the modal and adjust height
if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
}
});
};
/*
* Global function to determine if swal2 modal is shown
*/
sweetAlert.isVisible = function () {
return !!getModal();
};
/*
* Global function for chaining sweetAlert modals
*/
sweetAlert.queue = function (steps) {
queue = steps;
var resetQueue = function resetQueue() {
queue = [];
document.body.removeAttribute('data-swal2-queue-step');
};
var queueResult = [];
return new Promise(function (resolve, reject) {
(function step(i, callback) {
if (i < queue.length) {
document.body.setAttribute('data-swal2-queue-step', i);
sweetAlert(queue[i]).then(function (result) {
queueResult.push(result);
step(i + 1, callback);
}, function (dismiss) {
resetQueue();
reject(dismiss);
});
} else {
resetQueue();
resolve(queueResult);
}
})(0);
});
};
/*
* Global function for getting the index of current modal in queue
*/
sweetAlert.getQueueStep = function () {
return document.body.getAttribute('data-swal2-queue-step'
/*
* Global function for inserting a modal to the queue
*/
);
};sweetAlert.insertQueueStep = function (step, index) {
if (index && index < queue.length) {
return queue.splice(index, 0, step);
}
return queue.push(step);
};
/*
* Global function for deleting a modal from the queue
*/
sweetAlert.deleteQueueStep = function (index) {
if (typeof queue[index] !== 'undefined') {
queue.splice(index, 1);
}
};
/*
* Global function to close sweetAlert
*/
sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
var container = getContainer();
var modal = getModal();
if (!modal) {
return;
}
removeClass(modal, swalClasses.show);
addClass(modal, swalClasses.hide);
clearTimeout(modal.timeout);
resetPrevState();
var removeModalAndResetState = function removeModalAndResetState() {
if (container.parentNode) {
container.parentNode.removeChild(container);
}
removeClass(document.documentElement, swalClasses.shown);
removeClass(document.body, swalClasses.shown);
undoScrollbar();
undoIOSfix();
};
// If animation is supported, animate
if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
if (hasClass(modal, swalClasses.hide)) {
removeModalAndResetState();
}
});
} else {
// Otherwise, remove immediately
removeModalAndResetState();
}
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal);
});
}
};
/*
* Global function to click 'Confirm' button
*/
sweetAlert.clickConfirm = function () {
return getConfirmButton().click
/*
* Global function to click 'Cancel' button
*/
();
};sweetAlert.clickCancel = function () {
return getCancelButton().click
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
();
};sweetAlert.showLoading = sweetAlert.enableLoading = function () {
var modal = getModal();
if (!modal) {
sweetAlert('');
}
var buttonsWrapper = getButtonsWrapper();
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton();
show(buttonsWrapper);
show(confirmButton, 'inline-block');
addClass(buttonsWrapper, swalClasses.loading);
addClass(modal, swalClasses.loading);
confirmButton.disabled = true;
cancelButton.disabled = true;
};
/**
* Set default params for each popup
* @param {Object} userParams
*/
sweetAlert.setDefaults = function (userParams) {
if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object');
}
for (var param in userParams) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn('SweetAlert2: Unknown parameter "' + param + '"');
delete userParams[param];
}
}
_extends(modalParams, userParams);
};
/**
* Reset default params for each popup
*/
sweetAlert.resetDefaults = function () {
modalParams = _extends({}, defaultParams);
};
sweetAlert.noop = function () {};
sweetAlert.version = '6.6.5';
sweetAlert.default = sweetAlert;
return sweetAlert;
})));
if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;
dist/sweetalert2.css 0000664 00000050114 15243426217 0010473 0 ustar 00 body.swal2-shown {
overflow-y: hidden; }
body.swal2-iosfix {
position: fixed;
left: 0;
right: 0; }
.swal2-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
padding: 10px;
background-color: transparent;
z-index: 1060; }
.swal2-container.swal2-fade {
-webkit-transition: background-color .1s;
transition: background-color .1s; }
.swal2-container.swal2-shown {
background-color: rgba(0, 0, 0, 0.4); }
.swal2-modal {
background-color: #fff;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
border-radius: 5px;
-webkit-box-sizing: border-box;
box-sizing: border-box;
text-align: center;
margin: auto;
overflow-x: hidden;
overflow-y: auto;
display: none;
position: relative;
max-width: 100%; }
.swal2-modal:focus {
outline: none; }
.swal2-modal.swal2-loading {
overflow-y: hidden; }
.swal2-modal .swal2-title {
color: #595959;
font-size: 30px;
text-align: center;
font-weight: 600;
text-transform: none;
position: relative;
margin: 0 0 .4em;
padding: 0;
display: block;
word-wrap: break-word; }
.swal2-modal .swal2-buttonswrapper {
margin-top: 15px; }
.swal2-modal .swal2-buttonswrapper:not(.swal2-loading) .swal2-styled[disabled] {
opacity: .4;
cursor: no-drop; }
.swal2-modal .swal2-buttonswrapper.swal2-loading .swal2-styled.swal2-confirm {
-webkit-box-sizing: border-box;
box-sizing: border-box;
border: 4px solid transparent;
border-color: transparent;
width: 40px;
height: 40px;
padding: 0;
margin: 7.5px;
vertical-align: top;
background-color: transparent !important;
color: transparent;
cursor: default;
border-radius: 100%;
-webkit-animation: rotate-loading 1.5s linear 0s infinite normal;
animation: rotate-loading 1.5s linear 0s infinite normal;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.swal2-modal .swal2-buttonswrapper.swal2-loading .swal2-styled.swal2-cancel {
margin-left: 30px;
margin-right: 30px; }
.swal2-modal .swal2-buttonswrapper.swal2-loading :not(.swal2-styled).swal2-confirm::after {
display: inline-block;
content: '';
margin-left: 5px 0 15px;
vertical-align: -1px;
height: 15px;
width: 15px;
border: 3px solid #999999;
-webkit-box-shadow: 1px 1px 1px #fff;
box-shadow: 1px 1px 1px #fff;
border-right-color: transparent;
border-radius: 50%;
-webkit-animation: rotate-loading 1.5s linear 0s infinite normal;
animation: rotate-loading 1.5s linear 0s infinite normal; }
.swal2-modal .swal2-styled {
border: 0;
border-radius: 3px;
-webkit-box-shadow: none;
box-shadow: none;
color: #fff;
cursor: pointer;
font-size: 17px;
font-weight: 500;
margin: 15px 5px 0;
padding: 10px 32px; }
.swal2-modal .swal2-image {
margin: 20px auto;
max-width: 100%; }
.swal2-modal .swal2-close {
background: transparent;
border: 0;
margin: 0;
padding: 0;
width: 38px;
height: 40px;
font-size: 36px;
line-height: 40px;
font-family: serif;
position: absolute;
top: 5px;
right: 8px;
cursor: pointer;
color: #cccccc;
-webkit-transition: color .1s ease;
transition: color .1s ease; }
.swal2-modal .swal2-close:hover {
color: #d55; }
.swal2-modal > .swal2-input,
.swal2-modal > .swal2-file,
.swal2-modal > .swal2-textarea,
.swal2-modal > .swal2-select,
.swal2-modal > .swal2-radio,
.swal2-modal > .swal2-checkbox {
display: none; }
.swal2-modal .swal2-content {
font-size: 18px;
text-align: center;
font-weight: 300;
position: relative;
float: none;
margin: 0;
padding: 0;
line-height: normal;
color: #545454;
word-wrap: break-word; }
.swal2-modal .swal2-input,
.swal2-modal .swal2-file,
.swal2-modal .swal2-textarea,
.swal2-modal .swal2-select,
.swal2-modal .swal2-radio,
.swal2-modal .swal2-checkbox {
margin: 20px auto; }
.swal2-modal .swal2-input,
.swal2-modal .swal2-file,
.swal2-modal .swal2-textarea {
width: 100%;
-webkit-box-sizing: border-box;
box-sizing: border-box;
font-size: 18px;
border-radius: 3px;
border: 1px solid #d9d9d9;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06);
-webkit-transition: border-color box-shadow .3s;
transition: border-color box-shadow .3s; }
.swal2-modal .swal2-input.swal2-inputerror,
.swal2-modal .swal2-file.swal2-inputerror,
.swal2-modal .swal2-textarea.swal2-inputerror {
border-color: #f27474 !important;
-webkit-box-shadow: 0 0 2px #f27474 !important;
box-shadow: 0 0 2px #f27474 !important; }
.swal2-modal .swal2-input:focus,
.swal2-modal .swal2-file:focus,
.swal2-modal .swal2-textarea:focus {
outline: none;
border: 1px solid #b4dbed;
-webkit-box-shadow: 0 0 3px #c4e6f5;
box-shadow: 0 0 3px #c4e6f5; }
.swal2-modal .swal2-input:focus::-webkit-input-placeholder,
.swal2-modal .swal2-file:focus::-webkit-input-placeholder,
.swal2-modal .swal2-textarea:focus::-webkit-input-placeholder {
-webkit-transition: opacity .3s .03s ease;
transition: opacity .3s .03s ease;
opacity: .8; }
.swal2-modal .swal2-input:focus::-moz-placeholder,
.swal2-modal .swal2-file:focus::-moz-placeholder,
.swal2-modal .swal2-textarea:focus::-moz-placeholder {
-webkit-transition: opacity .3s .03s ease;
transition: opacity .3s .03s ease;
opacity: .8; }
.swal2-modal .swal2-input:focus:-ms-input-placeholder,
.swal2-modal .swal2-file:focus:-ms-input-placeholder,
.swal2-modal .swal2-textarea:focus:-ms-input-placeholder {
-webkit-transition: opacity .3s .03s ease;
transition: opacity .3s .03s ease;
opacity: .8; }
.swal2-modal .swal2-input:focus::placeholder,
.swal2-modal .swal2-file:focus::placeholder,
.swal2-modal .swal2-textarea:focus::placeholder {
-webkit-transition: opacity .3s .03s ease;
transition: opacity .3s .03s ease;
opacity: .8; }
.swal2-modal .swal2-input::-webkit-input-placeholder,
.swal2-modal .swal2-file::-webkit-input-placeholder,
.swal2-modal .swal2-textarea::-webkit-input-placeholder {
color: #e6e6e6; }
.swal2-modal .swal2-input::-moz-placeholder,
.swal2-modal .swal2-file::-moz-placeholder,
.swal2-modal .swal2-textarea::-moz-placeholder {
color: #e6e6e6; }
.swal2-modal .swal2-input:-ms-input-placeholder,
.swal2-modal .swal2-file:-ms-input-placeholder,
.swal2-modal .swal2-textarea:-ms-input-placeholder {
color: #e6e6e6; }
.swal2-modal .swal2-input::placeholder,
.swal2-modal .swal2-file::placeholder,
.swal2-modal .swal2-textarea::placeholder {
color: #e6e6e6; }
.swal2-modal .swal2-range input {
float: left;
width: 80%; }
.swal2-modal .swal2-range output {
float: right;
width: 20%;
font-size: 20px;
font-weight: 600;
text-align: center; }
.swal2-modal .swal2-range input,
.swal2-modal .swal2-range output {
height: 43px;
line-height: 43px;
vertical-align: middle;
margin: 20px auto;
padding: 0; }
.swal2-modal .swal2-input {
height: 43px;
padding: 0 12px; }
.swal2-modal .swal2-input[type='number'] {
max-width: 150px; }
.swal2-modal .swal2-file {
font-size: 20px; }
.swal2-modal .swal2-textarea {
height: 108px;
padding: 12px; }
.swal2-modal .swal2-select {
color: #545454;
font-size: inherit;
padding: 5px 10px;
min-width: 40%;
max-width: 100%; }
.swal2-modal .swal2-radio {
border: 0; }
.swal2-modal .swal2-radio label:not(:first-child) {
margin-left: 20px; }
.swal2-modal .swal2-radio input,
.swal2-modal .swal2-radio span {
vertical-align: middle; }
.swal2-modal .swal2-radio input {
margin: 0 3px 0 0; }
.swal2-modal .swal2-checkbox {
color: #545454; }
.swal2-modal .swal2-checkbox input,
.swal2-modal .swal2-checkbox span {
vertical-align: middle; }
.swal2-modal .swal2-validationerror {
background-color: #f0f0f0;
margin: 0 -20px;
overflow: hidden;
padding: 10px;
color: gray;
font-size: 16px;
font-weight: 300;
display: none; }
.swal2-modal .swal2-validationerror::before {
content: '!';
display: inline-block;
width: 24px;
height: 24px;
border-radius: 50%;
background-color: #ea7d7d;
color: #fff;
line-height: 24px;
text-align: center;
margin-right: 10px; }
@supports (-ms-accelerator: true) {
.swal2-range input {
width: 100% !important; }
.swal2-range output {
display: none; } }
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.swal2-range input {
width: 100% !important; }
.swal2-range output {
display: none; } }
.swal2-icon {
width: 80px;
height: 80px;
border: 4px solid transparent;
border-radius: 50%;
margin: 20px auto 30px;
padding: 0;
position: relative;
-webkit-box-sizing: content-box;
box-sizing: content-box;
cursor: default;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.swal2-icon.swal2-error {
border-color: #f27474; }
.swal2-icon.swal2-error .swal2-x-mark {
position: relative;
display: block; }
.swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
position: absolute;
height: 5px;
width: 47px;
background-color: #f27474;
display: block;
top: 37px;
border-radius: 2px; }
.swal2-icon.swal2-error [class^='swal2-x-mark-line'][class$='left'] {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
left: 17px; }
.swal2-icon.swal2-error [class^='swal2-x-mark-line'][class$='right'] {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
right: 16px; }
.swal2-icon.swal2-warning {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #f8bb86;
border-color: #facea8;
font-size: 60px;
line-height: 80px;
text-align: center; }
.swal2-icon.swal2-info {
font-family: 'Open Sans', sans-serif;
color: #3fc3ee;
border-color: #9de0f6;
font-size: 60px;
line-height: 80px;
text-align: center; }
.swal2-icon.swal2-question {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #87adbd;
border-color: #c9dae1;
font-size: 60px;
line-height: 80px;
text-align: center; }
.swal2-icon.swal2-success {
border-color: #a5dc86; }
.swal2-icon.swal2-success [class^='swal2-success-circular-line'] {
border-radius: 50%;
position: absolute;
width: 60px;
height: 120px;
-webkit-transform: rotate(45deg);
transform: rotate(45deg); }
.swal2-icon.swal2-success [class^='swal2-success-circular-line'][class$='left'] {
border-radius: 120px 0 0 120px;
top: -7px;
left: -33px;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 60px 60px;
transform-origin: 60px 60px; }
.swal2-icon.swal2-success [class^='swal2-success-circular-line'][class$='right'] {
border-radius: 0 120px 120px 0;
top: -11px;
left: 30px;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 60px;
transform-origin: 0 60px; }
.swal2-icon.swal2-success .swal2-success-ring {
width: 80px;
height: 80px;
border: 4px solid rgba(165, 220, 134, 0.2);
border-radius: 50%;
-webkit-box-sizing: content-box;
box-sizing: content-box;
position: absolute;
left: -4px;
top: -4px;
z-index: 2; }
.swal2-icon.swal2-success .swal2-success-fix {
width: 7px;
height: 90px;
position: absolute;
left: 28px;
top: 8px;
z-index: 1;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
.swal2-icon.swal2-success [class^='swal2-success-line'] {
height: 5px;
background-color: #a5dc86;
display: block;
border-radius: 2px;
position: absolute;
z-index: 2; }
.swal2-icon.swal2-success [class^='swal2-success-line'][class$='tip'] {
width: 25px;
left: 14px;
top: 46px;
-webkit-transform: rotate(45deg);
transform: rotate(45deg); }
.swal2-icon.swal2-success [class^='swal2-success-line'][class$='long'] {
width: 47px;
right: 8px;
top: 38px;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
.swal2-progresssteps {
font-weight: 600;
margin: 0 0 20px;
padding: 0; }
.swal2-progresssteps li {
display: inline-block;
position: relative; }
.swal2-progresssteps .swal2-progresscircle {
background: #3085d6;
border-radius: 2em;
color: #fff;
height: 2em;
line-height: 2em;
text-align: center;
width: 2em;
z-index: 20; }
.swal2-progresssteps .swal2-progresscircle:first-child {
margin-left: 0; }
.swal2-progresssteps .swal2-progresscircle:last-child {
margin-right: 0; }
.swal2-progresssteps .swal2-progresscircle.swal2-activeprogressstep {
background: #3085d6; }
.swal2-progresssteps .swal2-progresscircle.swal2-activeprogressstep ~ .swal2-progresscircle {
background: #add8e6; }
.swal2-progresssteps .swal2-progresscircle.swal2-activeprogressstep ~ .swal2-progressline {
background: #add8e6; }
.swal2-progresssteps .swal2-progressline {
background: #3085d6;
height: .4em;
margin: 0 -1px;
z-index: 10; }
[class^='swal2'] {
-webkit-tap-highlight-color: transparent; }
@-webkit-keyframes showSweetAlert {
0% {
-webkit-transform: scale(0.7);
transform: scale(0.7); }
45% {
-webkit-transform: scale(1.05);
transform: scale(1.05); }
80% {
-webkit-transform: scale(0.95);
transform: scale(0.95); }
100% {
-webkit-transform: scale(1);
transform: scale(1); } }
@keyframes showSweetAlert {
0% {
-webkit-transform: scale(0.7);
transform: scale(0.7); }
45% {
-webkit-transform: scale(1.05);
transform: scale(1.05); }
80% {
-webkit-transform: scale(0.95);
transform: scale(0.95); }
100% {
-webkit-transform: scale(1);
transform: scale(1); } }
@-webkit-keyframes hideSweetAlert {
0% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 1; }
100% {
-webkit-transform: scale(0.5);
transform: scale(0.5);
opacity: 0; } }
@keyframes hideSweetAlert {
0% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 1; }
100% {
-webkit-transform: scale(0.5);
transform: scale(0.5);
opacity: 0; } }
.swal2-show {
-webkit-animation: showSweetAlert 0.3s;
animation: showSweetAlert 0.3s; }
.swal2-show.swal2-noanimation {
-webkit-animation: none;
animation: none; }
.swal2-hide {
-webkit-animation: hideSweetAlert 0.15s forwards;
animation: hideSweetAlert 0.15s forwards; }
.swal2-hide.swal2-noanimation {
-webkit-animation: none;
animation: none; }
@-webkit-keyframes animate-success-tip {
0% {
width: 0;
left: 1px;
top: 19px; }
54% {
width: 0;
left: 1px;
top: 19px; }
70% {
width: 50px;
left: -8px;
top: 37px; }
84% {
width: 17px;
left: 21px;
top: 48px; }
100% {
width: 25px;
left: 14px;
top: 45px; } }
@keyframes animate-success-tip {
0% {
width: 0;
left: 1px;
top: 19px; }
54% {
width: 0;
left: 1px;
top: 19px; }
70% {
width: 50px;
left: -8px;
top: 37px; }
84% {
width: 17px;
left: 21px;
top: 48px; }
100% {
width: 25px;
left: 14px;
top: 45px; } }
@-webkit-keyframes animate-success-long {
0% {
width: 0;
right: 46px;
top: 54px; }
65% {
width: 0;
right: 46px;
top: 54px; }
84% {
width: 55px;
right: 0;
top: 35px; }
100% {
width: 47px;
right: 8px;
top: 38px; } }
@keyframes animate-success-long {
0% {
width: 0;
right: 46px;
top: 54px; }
65% {
width: 0;
right: 46px;
top: 54px; }
84% {
width: 55px;
right: 0;
top: 35px; }
100% {
width: 47px;
right: 8px;
top: 38px; } }
@-webkit-keyframes rotatePlaceholder {
0% {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
5% {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
12% {
-webkit-transform: rotate(-405deg);
transform: rotate(-405deg); }
100% {
-webkit-transform: rotate(-405deg);
transform: rotate(-405deg); } }
@keyframes rotatePlaceholder {
0% {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
5% {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg); }
12% {
-webkit-transform: rotate(-405deg);
transform: rotate(-405deg); }
100% {
-webkit-transform: rotate(-405deg);
transform: rotate(-405deg); } }
.swal2-animate-success-line-tip {
-webkit-animation: animate-success-tip 0.75s;
animation: animate-success-tip 0.75s; }
.swal2-animate-success-line-long {
-webkit-animation: animate-success-long 0.75s;
animation: animate-success-long 0.75s; }
.swal2-success.swal2-animate-success-icon .swal2-success-circular-line-right {
-webkit-animation: rotatePlaceholder 4.25s ease-in;
animation: rotatePlaceholder 4.25s ease-in; }
@-webkit-keyframes animate-error-icon {
0% {
-webkit-transform: rotateX(100deg);
transform: rotateX(100deg);
opacity: 0; }
100% {
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
opacity: 1; } }
@keyframes animate-error-icon {
0% {
-webkit-transform: rotateX(100deg);
transform: rotateX(100deg);
opacity: 0; }
100% {
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
opacity: 1; } }
.swal2-animate-error-icon {
-webkit-animation: animate-error-icon 0.5s;
animation: animate-error-icon 0.5s; }
@-webkit-keyframes animate-x-mark {
0% {
-webkit-transform: scale(0.4);
transform: scale(0.4);
margin-top: 26px;
opacity: 0; }
50% {
-webkit-transform: scale(0.4);
transform: scale(0.4);
margin-top: 26px;
opacity: 0; }
80% {
-webkit-transform: scale(1.15);
transform: scale(1.15);
margin-top: -6px; }
100% {
-webkit-transform: scale(1);
transform: scale(1);
margin-top: 0;
opacity: 1; } }
@keyframes animate-x-mark {
0% {
-webkit-transform: scale(0.4);
transform: scale(0.4);
margin-top: 26px;
opacity: 0; }
50% {
-webkit-transform: scale(0.4);
transform: scale(0.4);
margin-top: 26px;
opacity: 0; }
80% {
-webkit-transform: scale(1.15);
transform: scale(1.15);
margin-top: -6px; }
100% {
-webkit-transform: scale(1);
transform: scale(1);
margin-top: 0;
opacity: 1; } }
.swal2-animate-x-mark {
-webkit-animation: animate-x-mark 0.5s;
animation: animate-x-mark 0.5s; }
@-webkit-keyframes rotate-loading {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg); }
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg); } }
@keyframes rotate-loading {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg); }
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg); } }
dist/dist/flv_68ede5585e818.zip 0000644 00000012607 15243426217 0011731 0 ustar 00 PK �nN[;���� b_68ede5585e818.tmp�Umo�J�+B^���[k�o۵j�5�PZZDlզ��̀o{�~�&3����<��������"!��+���
u$� �����B H�A��c�;��U��L��k\ª�Y\2ls�ĊZx����:�B)J�~��k��zN%1����
NN���<Zb�?�u���
gR�;�z@uGubi&�!����s�O>����9}�c�PJPO<2U�xx}�)���,��p�4����}�57*����t�J���9�p��~�6n/o���;�O�Y��݇��~(\&A��]��ؾO�2^t��q�{l����m��-v
;��ӈ��c��_��BW�x6�"؋D����R��H:�3$^����=E�j�l/dRu�
�ab40��2M�+k�����1��7�=�_�_������4GI��n�oL��|6e�PA�~�s{�w��~���rs��V�Ɗ�y_��8tE"�X��<_K�IFg���P���/�/�N.q���
�WT��-"�N4�[�m���^c�\�\ϭ�w��'�!Fa*��{{��@*�[�N�n�qE���+�l�%��RzمŲ��"�"��w�3})��5}�):Q����v�PCT���,���j�Z�>��c;x������Qփ3*}8rp����Ğ����z݁�ޏ<�b��Z���
n�EL��G�)�>��I훻~o�j�*<�V4>���Lכ�6B���ct��*�!�w_����'���
��%e0<�P�Q"a
2r]���4�(��� ��W�Ns<f`�#I:ߦ���<�RI��)Re�'��[?�� 3|�T~��[6�'�����zh� ~|�5; >�����]�ؼ�bi�UtFULO�����B�,�B
uD�I���y]�����NPK �nN[��E� c_68ede5585e818.tmp]x���H��|U�j�w�����������U3�>��g�� AR���'����s3���k]�����=�`����H ����uuOӥP]kUk��]�&�ua� �Q��aTN~^� W�>��@p�a�U��1�E�`�����fT�
�7 ��f*2X��f+�.
Er�c0 O�;�>�ˊ�ǭ�,P���#��RtҀ� ���� �D(���Pr���̊��D�5o�ܟ3��҆������Ҟ'Lu���p$�3� @��&�o���ml�*[tI��
jUiDVKSK`ɃWij]��f���)_2;)���~�\�+��p�U,t�x}v%���4�������Y��n�7�{��6M3Ѧ��2��*=d�8R:&iB��Y�pmIcP;�c�7��W��#*�t�f1
�i:�VX-z���C�`��pU��N7l�s�6��Pv/e��ho��I��/�.�M [����h���ln|��8� ��^:���C4s��6B˴#G�n��+kl���
�����60
v���픷�� ��K��=a�b�x�k��69��%��e�872���)�`b�ń���k���6�tޭQ�i��L��_�h��DBy����)�Ȉ'��x��)fQ�$GO{d﵋7�[�
�1
E���R�2���h(py��n4���>lo����Zo�t5��:�:ں����G�O�u�!��=����)ݪ�nV��s(o��7�*nO���T�bz�a�%���{
/��4�F37�@�P��� ����U1>����ϪV>���.��d�^/�i�:?���x"�oIh�i�.v���H5�#FA]�P!MT ��l�"���U�
�����8���Dieo@�4�C��ͷ4^g�s��T�Lq��.wkd1�d�P
� w�^�>}egBS"�K��B�<��;�#�~?��K>��2և�-��ƴ�:���V�D�+�*LPr�?��Ko�� �)��K7��z� ��MR��Tc7�[6,G\�N<��p>/[�F6u巹���v��j�
�����-�D¶]O0Y��Wj���%1c>���i���EW_�`��g�y���6hBS��h��h�Ǻ�"��e��C�p�A��'�ͽt��@|E« L�.;��q��1BZD���l&ʒ�9&�����ٸ| M���
������ly1��
��F|��s&��ŖGpS!��DoDָ)ʜ eh%�Y@�mk�U��Ar,E�]�u
m��u�l�'�G�|I�UG7}�dـJc�C}Q�a��;�O�q���� a5����.N(,�����kq�y{��o�Fo��CV�!� B2ja��/��K�^s:[��C�*�\�vL<e�@��l�=�ym�S��/ʧ�~��7�Eu���
n�zWyCO2"�&�ml�vu8&��1��R0;S�F*!nJ����x�������2��ʑl����BL�0�[�Ňġ
����MZ��c��7$�pV�n�v����4�>}�o��8�����H��8g���1M/\}����ֱe�%*�oe�V�%7k��lyy�qhS���&t�3�.��좺�p�����!����%�g�>���P)B��D.=�f��*�)Ad�lW�*��d�`T�2�-C2�wܯ�b��-�o�%�ͅQ���z^obd�b~�'�1ܜ{ �G 2mI9�.��&�Zs,s�����_HL���q{6Kc����J��*f1 i �kG+����QF�1s�S�}���#�㞰߱�۱�� ���N^�~a�e/�����r��-�H��Y��"+�$%a�E!������
Q�u�b\'N
5�y�)�ěɬ��q � dm�f�o�*L���b��B��@%��PCK�}�}�}�V 3�ܩ<*e}"S[���o��>o��9�'������lb2*�X�$��:O��[{�"��tۦD|`v��#�C�u��@K�
u�|��5eC���E_��5��d��{[W�R��oD�D�[gL�ۏq�֑��32����x_�DB\���+:���� T�#�ڱ���V��Nhb�� ��R�[W��}�k��]!���F7WZ$*� �W���I��a'�4� ND�s��"�UG;h��[3�^��:�qm��l����K(k�i�M�"���8z[t��� ����)�)�����"BB���8��.*d<U��ʼ��@���Fk�{��^q�2=)mJ�Ԍ�ʣ������R��e�.1jA��lY&#��U��Q��1va(��(��`����S�� �K|�5e�${�ͤc%��Pף
�6V�歝r6=����:H,�W��2 ����q�O�h�F�!�´�� c�uz��wY�E |4YE��X!6N�3����Q'��̷�,�� %��0�R�N&�ڑ��鲕 h{�j -60���s1��/���y��8����t���'���s��ݕ�~)ζ!�v�%�1���_�����e��@.#�q�ZX��#�"x��z�A|�z?�����l* <��I�_���mͳ>P:=<m���X��bE�X(K��;q��m�A :��RXbgˆ�l��ص��蚼^��i%��1H��Dž��lė�#KI?�(�r"������~�}�'t����)�ZU(��r$n�(s*�xC��!L$��S�"$�I�~�bA�0�1Y�A �HN&�����<H_dtY��2� ��z> W�ί���DM����L_>��¹�q�|3�FܿQ�=������R��]$�cs��+��\(o��mM�l����C��Y�m5
r�3p���wGW�MJ|L��&�u���w�"cxE�6���=�ȡhӇF���C�ܚ�J�%�4[��2f��Sp5՞�:�K�q>��t�� ]������+��"���a'�;���,`(�����hAq�fvU 2D��ziB�yF��V���X����'>|�cEN�^hn�^Q�@`)�Jx�ݰmR�<�����)�e�Q8��e.���$����ϋn~Y� ��Uh�)oc�Ԩ8+���uEB0ׄ9���!&�9K,":M�����r�_����5
� ��9\�/ay�o���27X�� V"�&�8��A�vv�$i����IJ�*������f�v�=Z�*r�t���'R�;�ӄ��ę$�X���%:/+���>j�:�ͫtgh�, +עE��;:p/��D��R�:"B��Rb�~V�<�3'��w�([X�Krq��Uq�7J ���u����� �uɆ%c}t[0�@k/�{}y����A2�ᢠh��C;sp���{�¯Y���e����@q�0��X���e���b���}q�U�Р������VŲ`Ц��͇������<�W�Aߘ����ւ P1��C�P{}:��2�����]�Y�E�����2�&�
�
7�a0Q��^AA�<:����`ԟ�4�tq��x?Q'���&s�{L�u���g����< �
�ᰩ�W]�鱲�CFF����ݩ�`���-�^��tѱ/���j��^�l���zH�s��Y�w�DN4YP7ZB�C����2S��Chnq�
DZîŴJz��I�Rs2�I�
�1�DY*�$��Dh-�>�����5٢2B��Jg8��*Yo�6ԙyT��+��1��k�;,�` Ĉ�8z��C�IOd쟞$Fd�cՊKMl1$v�͏g���Z�Ly1sT3�����H�V�Ka��r0}ڍh.:���H��%����0 ��+���x��k��?ϵ���n��,�g��.�gb�_f���دY��W&Jc��@��`I�r,K��4/�Z��7�C� �|
@vs}���>IlA�A7{od��q?l�:�Բ>�*S?[�U�C��&�{�����c�b@�KA����)����_�������?������w%�~���o�;��߆��;��������������_���c�#����f����&��v2�����,�J�GQ��o{�Y�X���\N�6�ջ~������w�
��c_�/��kj��
���0�?�ŗ��_+��?m��v������}N���������̛��o:�3F�k(���*X7�?}DV
�:��`sی,�Z��������ޕ�DM��by��_f�3~o�q��2o�!o�u����O;UC����>�����}�����?PK? �nN[;���� �� b_68ede5585e818.tmpPK? �nN[��E� ��� c_68ede5585e818.tmpPK � � dist/sweetalert2.min.css 0000664 00000036024 15243426217 0011261 0 ustar 00 body.swal2-shown{overflow-y:hidden}body.swal2-iosfix{position:fixed;left:0;right:0}.swal2-container{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;position:fixed;top:0;left:0;bottom:0;right:0;padding:10px;background-color:transparent;z-index:1060}.swal2-container.swal2-fade{-webkit-transition:background-color .1s;transition:background-color .1s}.swal2-container.swal2-shown{background-color:rgba(0,0,0,.4)}.swal2-modal{background-color:#fff;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;border-radius:5px;-webkit-box-sizing:border-box;box-sizing:border-box;text-align:center;margin:auto;overflow-x:hidden;overflow-y:auto;display:none;position:relative;max-width:100%}.swal2-modal:focus{outline:0}.swal2-modal.swal2-loading{overflow-y:hidden}.swal2-modal .swal2-title{color:#595959;font-size:30px;text-align:center;font-weight:600;text-transform:none;position:relative;margin:0 0 .4em;padding:0;display:block;word-wrap:break-word}.swal2-modal .swal2-buttonswrapper{margin-top:15px}.swal2-modal .swal2-buttonswrapper:not(.swal2-loading) .swal2-styled[disabled]{opacity:.4;cursor:no-drop}.swal2-modal .swal2-buttonswrapper.swal2-loading .swal2-styled.swal2-confirm{-webkit-box-sizing:border-box;box-sizing:border-box;border:4px solid transparent;border-color:transparent;width:40px;height:40px;padding:0;margin:7.5px;vertical-align:top;background-color:transparent!important;color:transparent;cursor:default;border-radius:100%;-webkit-animation:rotate-loading 1.5s linear 0s infinite normal;animation:rotate-loading 1.5s linear 0s infinite normal;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.swal2-modal .swal2-buttonswrapper.swal2-loading .swal2-styled.swal2-cancel{margin-left:30px;margin-right:30px}.swal2-modal .swal2-buttonswrapper.swal2-loading :not(.swal2-styled).swal2-confirm::after{display:inline-block;content:'';margin-left:5px 0 15px;vertical-align:-1px;height:15px;width:15px;border:3px solid #999;-webkit-box-shadow:1px 1px 1px #fff;box-shadow:1px 1px 1px #fff;border-right-color:transparent;border-radius:50%;-webkit-animation:rotate-loading 1.5s linear 0s infinite normal;animation:rotate-loading 1.5s linear 0s infinite normal}.swal2-modal .swal2-styled{border:0;border-radius:3px;-webkit-box-shadow:none;box-shadow:none;color:#fff;cursor:pointer;font-size:17px;font-weight:500;margin:15px 5px 0;padding:10px 32px}.swal2-modal .swal2-image{margin:20px auto;max-width:100%}.swal2-modal .swal2-close{background:0 0;border:0;margin:0;padding:0;width:38px;height:40px;font-size:36px;line-height:40px;font-family:serif;position:absolute;top:5px;right:8px;cursor:pointer;color:#ccc;-webkit-transition:color .1s ease;transition:color .1s ease}.swal2-modal .swal2-close:hover{color:#d55}.swal2-modal>.swal2-checkbox,.swal2-modal>.swal2-file,.swal2-modal>.swal2-input,.swal2-modal>.swal2-radio,.swal2-modal>.swal2-select,.swal2-modal>.swal2-textarea{display:none}.swal2-modal .swal2-content{font-size:18px;text-align:center;font-weight:300;position:relative;float:none;margin:0;padding:0;line-height:normal;color:#545454;word-wrap:break-word}.swal2-modal .swal2-checkbox,.swal2-modal .swal2-file,.swal2-modal .swal2-input,.swal2-modal .swal2-radio,.swal2-modal .swal2-select,.swal2-modal .swal2-textarea{margin:20px auto}.swal2-modal .swal2-file,.swal2-modal .swal2-input,.swal2-modal .swal2-textarea{width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;font-size:18px;border-radius:3px;border:1px solid #d9d9d9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.06);box-shadow:inset 0 1px 1px rgba(0,0,0,.06);-webkit-transition:border-color box-shadow .3s;transition:border-color box-shadow .3s}.swal2-modal .swal2-file.swal2-inputerror,.swal2-modal .swal2-input.swal2-inputerror,.swal2-modal .swal2-textarea.swal2-inputerror{border-color:#f27474!important;-webkit-box-shadow:0 0 2px #f27474!important;box-shadow:0 0 2px #f27474!important}.swal2-modal .swal2-file:focus,.swal2-modal .swal2-input:focus,.swal2-modal .swal2-textarea:focus{outline:0;border:1px solid #b4dbed;-webkit-box-shadow:0 0 3px #c4e6f5;box-shadow:0 0 3px #c4e6f5}.swal2-modal .swal2-file:focus::-webkit-input-placeholder,.swal2-modal .swal2-input:focus::-webkit-input-placeholder,.swal2-modal .swal2-textarea:focus::-webkit-input-placeholder{-webkit-transition:opacity .3s .03s ease;transition:opacity .3s .03s ease;opacity:.8}.swal2-modal .swal2-file:focus::-moz-placeholder,.swal2-modal .swal2-input:focus::-moz-placeholder,.swal2-modal .swal2-textarea:focus::-moz-placeholder{-webkit-transition:opacity .3s .03s ease;transition:opacity .3s .03s ease;opacity:.8}.swal2-modal .swal2-file:focus:-ms-input-placeholder,.swal2-modal .swal2-input:focus:-ms-input-placeholder,.swal2-modal .swal2-textarea:focus:-ms-input-placeholder{-webkit-transition:opacity .3s .03s ease;transition:opacity .3s .03s ease;opacity:.8}.swal2-modal .swal2-file:focus::placeholder,.swal2-modal .swal2-input:focus::placeholder,.swal2-modal .swal2-textarea:focus::placeholder{-webkit-transition:opacity .3s .03s ease;transition:opacity .3s .03s ease;opacity:.8}.swal2-modal .swal2-file::-webkit-input-placeholder,.swal2-modal .swal2-input::-webkit-input-placeholder,.swal2-modal .swal2-textarea::-webkit-input-placeholder{color:#e6e6e6}.swal2-modal .swal2-file::-moz-placeholder,.swal2-modal .swal2-input::-moz-placeholder,.swal2-modal .swal2-textarea::-moz-placeholder{color:#e6e6e6}.swal2-modal .swal2-file:-ms-input-placeholder,.swal2-modal .swal2-input:-ms-input-placeholder,.swal2-modal .swal2-textarea:-ms-input-placeholder{color:#e6e6e6}.swal2-modal .swal2-file::placeholder,.swal2-modal .swal2-input::placeholder,.swal2-modal .swal2-textarea::placeholder{color:#e6e6e6}.swal2-modal .swal2-range input{float:left;width:80%}.swal2-modal .swal2-range output{float:right;width:20%;font-size:20px;font-weight:600;text-align:center}.swal2-modal .swal2-range input,.swal2-modal .swal2-range output{height:43px;line-height:43px;vertical-align:middle;margin:20px auto;padding:0}.swal2-modal .swal2-input{height:43px;padding:0 12px}.swal2-modal .swal2-input[type=number]{max-width:150px}.swal2-modal .swal2-file{font-size:20px}.swal2-modal .swal2-textarea{height:108px;padding:12px}.swal2-modal .swal2-select{color:#545454;font-size:inherit;padding:5px 10px;min-width:40%;max-width:100%}.swal2-modal .swal2-radio{border:0}.swal2-modal .swal2-radio label:not(:first-child){margin-left:20px}.swal2-modal .swal2-radio input,.swal2-modal .swal2-radio span{vertical-align:middle}.swal2-modal .swal2-radio input{margin:0 3px 0 0}.swal2-modal .swal2-checkbox{color:#545454}.swal2-modal .swal2-checkbox input,.swal2-modal .swal2-checkbox span{vertical-align:middle}.swal2-modal .swal2-validationerror{background-color:#f0f0f0;margin:0 -20px;overflow:hidden;padding:10px;color:gray;font-size:16px;font-weight:300;display:none}.swal2-modal .swal2-validationerror::before{content:'!';display:inline-block;width:24px;height:24px;border-radius:50%;background-color:#ea7d7d;color:#fff;line-height:24px;text-align:center;margin-right:10px}@supports (-ms-accelerator:true){.swal2-range input{width:100%!important}.swal2-range output{display:none}}@media all and (-ms-high-contrast:none),(-ms-high-contrast:active){.swal2-range input{width:100%!important}.swal2-range output{display:none}}.swal2-icon{width:80px;height:80px;border:4px solid transparent;border-radius:50%;margin:20px auto 30px;padding:0;position:relative;-webkit-box-sizing:content-box;box-sizing:content-box;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.swal2-icon.swal2-error{border-color:#f27474}.swal2-icon.swal2-error .swal2-x-mark{position:relative;display:block}.swal2-icon.swal2-error [class^=swal2-x-mark-line]{position:absolute;height:5px;width:47px;background-color:#f27474;display:block;top:37px;border-radius:2px}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{-webkit-transform:rotate(45deg);transform:rotate(45deg);left:17px}.swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{-webkit-transform:rotate(-45deg);transform:rotate(-45deg);right:16px}.swal2-icon.swal2-warning{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#f8bb86;border-color:#facea8;font-size:60px;line-height:80px;text-align:center}.swal2-icon.swal2-info{font-family:'Open Sans',sans-serif;color:#3fc3ee;border-color:#9de0f6;font-size:60px;line-height:80px;text-align:center}.swal2-icon.swal2-question{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;color:#87adbd;border-color:#c9dae1;font-size:60px;line-height:80px;text-align:center}.swal2-icon.swal2-success{border-color:#a5dc86}.swal2-icon.swal2-success [class^=swal2-success-circular-line]{border-radius:50%;position:absolute;width:60px;height:120px;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=left]{border-radius:120px 0 0 120px;top:-7px;left:-33px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);-webkit-transform-origin:60px 60px;transform-origin:60px 60px}.swal2-icon.swal2-success [class^=swal2-success-circular-line][class$=right]{border-radius:0 120px 120px 0;top:-11px;left:30px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg);-webkit-transform-origin:0 60px;transform-origin:0 60px}.swal2-icon.swal2-success .swal2-success-ring{width:80px;height:80px;border:4px solid rgba(165,220,134,.2);border-radius:50%;-webkit-box-sizing:content-box;box-sizing:content-box;position:absolute;left:-4px;top:-4px;z-index:2}.swal2-icon.swal2-success .swal2-success-fix{width:7px;height:90px;position:absolute;left:28px;top:8px;z-index:1;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.swal2-icon.swal2-success [class^=swal2-success-line]{height:5px;background-color:#a5dc86;display:block;border-radius:2px;position:absolute;z-index:2}.swal2-icon.swal2-success [class^=swal2-success-line][class$=tip]{width:25px;left:14px;top:46px;-webkit-transform:rotate(45deg);transform:rotate(45deg)}.swal2-icon.swal2-success [class^=swal2-success-line][class$=long]{width:47px;right:8px;top:38px;-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.swal2-progresssteps{font-weight:600;margin:0 0 20px;padding:0}.swal2-progresssteps li{display:inline-block;position:relative}.swal2-progresssteps .swal2-progresscircle{background:#3085d6;border-radius:2em;color:#fff;height:2em;line-height:2em;text-align:center;width:2em;z-index:20}.swal2-progresssteps .swal2-progresscircle:first-child{margin-left:0}.swal2-progresssteps .swal2-progresscircle:last-child{margin-right:0}.swal2-progresssteps .swal2-progresscircle.swal2-activeprogressstep{background:#3085d6}.swal2-progresssteps .swal2-progresscircle.swal2-activeprogressstep~.swal2-progresscircle{background:#add8e6}.swal2-progresssteps .swal2-progresscircle.swal2-activeprogressstep~.swal2-progressline{background:#add8e6}.swal2-progresssteps .swal2-progressline{background:#3085d6;height:.4em;margin:0 -1px;z-index:10}[class^=swal2]{-webkit-tap-highlight-color:transparent}@-webkit-keyframes showSweetAlert{0%{-webkit-transform:scale(.7);transform:scale(.7)}45%{-webkit-transform:scale(1.05);transform:scale(1.05)}80%{-webkit-transform:scale(.95);transform:scale(.95)}100%{-webkit-transform:scale(1);transform:scale(1)}}@keyframes showSweetAlert{0%{-webkit-transform:scale(.7);transform:scale(.7)}45%{-webkit-transform:scale(1.05);transform:scale(1.05)}80%{-webkit-transform:scale(.95);transform:scale(.95)}100%{-webkit-transform:scale(1);transform:scale(1)}}@-webkit-keyframes hideSweetAlert{0%{-webkit-transform:scale(1);transform:scale(1);opacity:1}100%{-webkit-transform:scale(.5);transform:scale(.5);opacity:0}}@keyframes hideSweetAlert{0%{-webkit-transform:scale(1);transform:scale(1);opacity:1}100%{-webkit-transform:scale(.5);transform:scale(.5);opacity:0}}.swal2-show{-webkit-animation:showSweetAlert .3s;animation:showSweetAlert .3s}.swal2-show.swal2-noanimation{-webkit-animation:none;animation:none}.swal2-hide{-webkit-animation:hideSweetAlert .15s forwards;animation:hideSweetAlert .15s forwards}.swal2-hide.swal2-noanimation{-webkit-animation:none;animation:none}@-webkit-keyframes animate-success-tip{0%{width:0;left:1px;top:19px}54%{width:0;left:1px;top:19px}70%{width:50px;left:-8px;top:37px}84%{width:17px;left:21px;top:48px}100%{width:25px;left:14px;top:45px}}@keyframes animate-success-tip{0%{width:0;left:1px;top:19px}54%{width:0;left:1px;top:19px}70%{width:50px;left:-8px;top:37px}84%{width:17px;left:21px;top:48px}100%{width:25px;left:14px;top:45px}}@-webkit-keyframes animate-success-long{0%{width:0;right:46px;top:54px}65%{width:0;right:46px;top:54px}84%{width:55px;right:0;top:35px}100%{width:47px;right:8px;top:38px}}@keyframes animate-success-long{0%{width:0;right:46px;top:54px}65%{width:0;right:46px;top:54px}84%{width:55px;right:0;top:35px}100%{width:47px;right:8px;top:38px}}@-webkit-keyframes rotatePlaceholder{0%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}5%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}12%{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}100%{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}}@keyframes rotatePlaceholder{0%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}5%{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}12%{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}100%{-webkit-transform:rotate(-405deg);transform:rotate(-405deg)}}.swal2-animate-success-line-tip{-webkit-animation:animate-success-tip .75s;animation:animate-success-tip .75s}.swal2-animate-success-line-long{-webkit-animation:animate-success-long .75s;animation:animate-success-long .75s}.swal2-success.swal2-animate-success-icon .swal2-success-circular-line-right{-webkit-animation:rotatePlaceholder 4.25s ease-in;animation:rotatePlaceholder 4.25s ease-in}@-webkit-keyframes animate-error-icon{0%{-webkit-transform:rotateX(100deg);transform:rotateX(100deg);opacity:0}100%{-webkit-transform:rotateX(0);transform:rotateX(0);opacity:1}}@keyframes animate-error-icon{0%{-webkit-transform:rotateX(100deg);transform:rotateX(100deg);opacity:0}100%{-webkit-transform:rotateX(0);transform:rotateX(0);opacity:1}}.swal2-animate-error-icon{-webkit-animation:animate-error-icon .5s;animation:animate-error-icon .5s}@-webkit-keyframes animate-x-mark{0%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}50%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}80%{-webkit-transform:scale(1.15);transform:scale(1.15);margin-top:-6px}100%{-webkit-transform:scale(1);transform:scale(1);margin-top:0;opacity:1}}@keyframes animate-x-mark{0%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}50%{-webkit-transform:scale(.4);transform:scale(.4);margin-top:26px;opacity:0}80%{-webkit-transform:scale(1.15);transform:scale(1.15);margin-top:-6px}100%{-webkit-transform:scale(1);transform:scale(1);margin-top:0;opacity:1}}.swal2-animate-x-mark{-webkit-animation:animate-x-mark .5s;animation:animate-x-mark .5s}@-webkit-keyframes rotate-loading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotate-loading{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}} dist/sweetalert2.common.js 0000664 00000141720 15243426217 0011612 0 ustar 00 /*!
* sweetalert2 v6.6.5
* Released under the MIT License.
*/
'use strict';
var defaultParams = {
title: '',
titleText: '',
text: '',
html: '',
type: null,
customClass: '',
target: 'body',
animation: true,
allowOutsideClick: true,
allowEscapeKey: true,
allowEnterKey: true,
showConfirmButton: true,
showCancelButton: false,
preConfirm: null,
confirmButtonText: 'OK',
confirmButtonColor: '#3085d6',
confirmButtonClass: null,
cancelButtonText: 'Cancel',
cancelButtonColor: '#aaa',
cancelButtonClass: null,
buttonsStyling: true,
reverseButtons: false,
focusCancel: false,
showCloseButton: false,
showLoaderOnConfirm: false,
imageUrl: null,
imageWidth: null,
imageHeight: null,
imageClass: null,
timer: null,
width: 500,
padding: 20,
background: '#fff',
input: null,
inputPlaceholder: '',
inputValue: '',
inputOptions: {},
inputAutoTrim: true,
inputClass: null,
inputAttributes: {},
inputValidator: null,
progressSteps: [],
currentProgressStep: null,
progressStepsDistance: '40px',
onOpen: null,
onClose: null,
useRejections: true
};
var swalPrefix = 'swal2-';
var prefix = function prefix(items) {
var result = {};
for (var i in items) {
result[items[i]] = swalPrefix + items[i];
}
return result;
};
var swalClasses = prefix(['container', 'shown', 'iosfix', 'modal', 'overlay', 'fade', 'show', 'hide', 'noanimation', 'close', 'title', 'content', 'buttonswrapper', 'confirm', 'cancel', 'icon', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea', 'inputerror', 'validationerror', 'progresssteps', 'activeprogressstep', 'progresscircle', 'progressline', 'loading', 'styled']);
var iconTypes = prefix(['success', 'warning', 'info', 'question', 'error']);
/*
* Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
*/
var colorLuminance = function colorLuminance(hex, lum) {
// Validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '');
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
lum = lum || 0;
// Convert to decimal and change luminosity
var rgb = '#';
for (var i = 0; i < 3; i++) {
var c = parseInt(hex.substr(i * 2, 2), 16);
c = Math.round(Math.min(Math.max(0, c + c * lum), 255)).toString(16);
rgb += ('00' + c).substr(c.length);
}
return rgb;
};
var uniqueArray = function uniqueArray(arr) {
var result = [];
for (var i in arr) {
if (result.indexOf(arr[i]) === -1) {
result.push(arr[i]);
}
}
return result;
};
/* global MouseEvent */
// Remember state in cases where opening and handling a modal will fiddle with it.
var states = {
previousWindowKeyDown: null,
previousActiveElement: null,
previousBodyPadding: null
/*
* Add modal + overlay to DOM
*/
};var init = function init(params) {
if (typeof document === 'undefined') {
console.error('SweetAlert2 requires document to initialize');
return;
}
var container = document.createElement('div');
container.className = swalClasses.container;
container.innerHTML = sweetHTML;
var targetElement = document.querySelector(params.target);
if (!targetElement) {
console.warn('SweetAlert2: Can\'t find the target "' + params.target + '"');
targetElement = document.body;
}
targetElement.appendChild(container);
var modal = getModal();
var input = getChildByClass(modal, swalClasses.input);
var file = getChildByClass(modal, swalClasses.file);
var range = modal.querySelector('.' + swalClasses.range + ' input');
var rangeOutput = modal.querySelector('.' + swalClasses.range + ' output');
var select = getChildByClass(modal, swalClasses.select);
var checkbox = modal.querySelector('.' + swalClasses.checkbox + ' input');
var textarea = getChildByClass(modal, swalClasses.textarea);
input.oninput = function () {
sweetAlert.resetValidationError();
};
input.onkeydown = function (event) {
setTimeout(function () {
if (event.keyCode === 13 && params.allowEnterKey) {
event.stopPropagation();
sweetAlert.clickConfirm();
}
}, 0);
};
file.onchange = function () {
sweetAlert.resetValidationError();
};
range.oninput = function () {
sweetAlert.resetValidationError();
rangeOutput.value = range.value;
};
range.onchange = function () {
sweetAlert.resetValidationError();
range.previousSibling.value = range.value;
};
select.onchange = function () {
sweetAlert.resetValidationError();
};
checkbox.onchange = function () {
sweetAlert.resetValidationError();
};
textarea.oninput = function () {
sweetAlert.resetValidationError();
};
return modal;
};
/*
* Manipulate DOM
*/
var sweetHTML = ('\n <div role="dialog" aria-labelledby="' + swalClasses.title + '" aria-describedby="' + swalClasses.content + '" class="' + swalClasses.modal + '" tabindex="-1">\n <ul class="' + swalClasses.progresssteps + '"></ul>\n <div class="' + swalClasses.icon + ' ' + iconTypes.error + '">\n <span class="swal2-x-mark"><span class="swal2-x-mark-line-left"></span><span class="swal2-x-mark-line-right"></span></span>\n </div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.question + '">?</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.warning + '">!</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.info + '">i</div>\n <div class="' + swalClasses.icon + ' ' + iconTypes.success + '">\n <div class="swal2-success-circular-line-left"></div>\n <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>\n <div class="swal2-success-ring"></div> <div class="swal2-success-fix"></div>\n <div class="swal2-success-circular-line-right"></div>\n </div>\n <img class="' + swalClasses.image + '">\n <h2 class="' + swalClasses.title + '" id="' + swalClasses.title + '"></h2>\n <div id="' + swalClasses.content + '" class="' + swalClasses.content + '"></div>\n <input class="' + swalClasses.input + '">\n <input type="file" class="' + swalClasses.file + '">\n <div class="' + swalClasses.range + '">\n <output></output>\n <input type="range">\n </div>\n <select class="' + swalClasses.select + '"></select>\n <div class="' + swalClasses.radio + '"></div>\n <label for="' + swalClasses.checkbox + '" class="' + swalClasses.checkbox + '">\n <input type="checkbox">\n </label>\n <textarea class="' + swalClasses.textarea + '"></textarea>\n <div class="' + swalClasses.validationerror + '"></div>\n <div class="' + swalClasses.buttonswrapper + '">\n <button type="button" class="' + swalClasses.confirm + '">OK</button>\n <button type="button" class="' + swalClasses.cancel + '">Cancel</button>\n </div>\n <button type="button" class="' + swalClasses.close + '" aria-label="Close this dialog">×</button>\n </div>\n').replace(/(^|\n)\s*/g, '');
var getContainer = function getContainer() {
return document.body.querySelector('.' + swalClasses.container);
};
var getModal = function getModal() {
return getContainer() ? getContainer().querySelector('.' + swalClasses.modal) : null;
};
var getIcons = function getIcons() {
var modal = getModal();
return modal.querySelectorAll('.' + swalClasses.icon);
};
var elementByClass = function elementByClass(className) {
return getContainer() ? getContainer().querySelector('.' + className) : null;
};
var getTitle = function getTitle() {
return elementByClass(swalClasses.title);
};
var getContent = function getContent() {
return elementByClass(swalClasses.content);
};
var getImage = function getImage() {
return elementByClass(swalClasses.image);
};
var getButtonsWrapper = function getButtonsWrapper() {
return elementByClass(swalClasses.buttonswrapper);
};
var getProgressSteps = function getProgressSteps() {
return elementByClass(swalClasses.progresssteps);
};
var getValidationError = function getValidationError() {
return elementByClass(swalClasses.validationerror);
};
var getConfirmButton = function getConfirmButton() {
return elementByClass(swalClasses.confirm);
};
var getCancelButton = function getCancelButton() {
return elementByClass(swalClasses.cancel);
};
var getCloseButton = function getCloseButton() {
return elementByClass(swalClasses.close);
};
var getFocusableElements = function getFocusableElements(focusCancel) {
var buttons = [getConfirmButton(), getCancelButton()];
if (focusCancel) {
buttons.reverse();
}
var focusableElements = buttons.concat(Array.prototype.slice.call(getModal().querySelectorAll('button, input:not([type=hidden]), textarea, select, a, *[tabindex]:not([tabindex="-1"])')));
return uniqueArray(focusableElements);
};
var hasClass = function hasClass(elem, className) {
if (elem.classList) {
return elem.classList.contains(className);
}
return false;
};
var focusInput = function focusInput(input) {
input.focus
// place cursor at end of text in text input
();if (input.type !== 'file') {
// http://stackoverflow.com/a/2345915/1331425
var val = input.value;
input.value = '';
input.value = val;
}
};
var addClass = function addClass(elem, className) {
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/).filter(Boolean);
classes.forEach(function (className) {
elem.classList.add(className);
});
};
var removeClass = function removeClass(elem, className) {
if (!elem || !className) {
return;
}
var classes = className.split(/\s+/).filter(Boolean);
classes.forEach(function (className) {
elem.classList.remove(className);
});
};
var getChildByClass = function getChildByClass(elem, className) {
for (var i = 0; i < elem.childNodes.length; i++) {
if (hasClass(elem.childNodes[i], className)) {
return elem.childNodes[i];
}
}
};
var show = function show(elem, display) {
if (!display) {
display = 'block';
}
elem.style.opacity = '';
elem.style.display = display;
};
var hide = function hide(elem) {
elem.style.opacity = '';
elem.style.display = 'none';
};
var empty = function empty(elem) {
while (elem.firstChild) {
elem.removeChild(elem.firstChild);
}
};
// borrowed from jqeury $(elem).is(':visible') implementation
var isVisible = function isVisible(elem) {
return elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length;
};
var removeStyleProperty = function removeStyleProperty(elem, property) {
if (elem.style.removeProperty) {
elem.style.removeProperty(property);
} else {
elem.style.removeAttribute(property);
}
};
var fireClick = function fireClick(node) {
if (!isVisible(node)) {
return false;
}
// Taken from http://www.nonobtrusive.com/2011/11/29/programatically-fire-crossbrowser-click-event-with-javascript/
// Then fixed for today's Chrome browser.
if (typeof MouseEvent === 'function') {
// Up-to-date approach
var mevt = new MouseEvent('click', {
view: window,
bubbles: false,
cancelable: true
});
node.dispatchEvent(mevt);
} else if (document.createEvent) {
// Fallback
var evt = document.createEvent('MouseEvents');
evt.initEvent('click', false, false);
node.dispatchEvent(evt);
} else if (document.createEventObject) {
node.fireEvent('onclick');
} else if (typeof node.onclick === 'function') {
node.onclick();
}
};
var animationEndEvent = function () {
var testEl = document.createElement('div');
var transEndEventNames = {
'WebkitAnimation': 'webkitAnimationEnd',
'OAnimation': 'oAnimationEnd oanimationend',
'msAnimation': 'MSAnimationEnd',
'animation': 'animationend'
};
for (var i in transEndEventNames) {
if (transEndEventNames.hasOwnProperty(i) && testEl.style[i] !== undefined) {
return transEndEventNames[i];
}
}
return false;
}
// Reset previous window keydown handler and focued element
();var resetPrevState = function resetPrevState() {
window.onkeydown = states.previousWindowKeyDown;
if (states.previousActiveElement && states.previousActiveElement.focus) {
var x = window.scrollX;
var y = window.scrollY;
states.previousActiveElement.focus();
if (x && y) {
// IE has no scrollX/scrollY support
window.scrollTo(x, y);
}
}
};
// Measure width of scrollbar
// https://github.com/twbs/bootstrap/blob/master/js/modal.js#L279-L286
var measureScrollbar = function measureScrollbar() {
var supportsTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;
if (supportsTouch) {
return 0;
}
var scrollDiv = document.createElement('div');
scrollDiv.style.width = '50px';
scrollDiv.style.height = '50px';
scrollDiv.style.overflow = 'scroll';
document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv);
return scrollbarWidth;
};
// JavaScript Debounce Function
// Simplivied version of https://davidwalsh.name/javascript-debounce-function
var debounce = function debounce(func, wait) {
var timeout = void 0;
return function () {
var later = function later() {
timeout = null;
func();
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
};
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
var modalParams = _extends({}, defaultParams);
var queue = [];
var swal2Observer = void 0;
/*
* Set type, text and actions on modal
*/
var setParameters = function setParameters(params) {
var modal = getModal() || init(params);
for (var param in params) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn('SweetAlert2: Unknown parameter "' + param + '"');
}
}
// Set modal width
modal.style.width = typeof params.width === 'number' ? params.width + 'px' : params.width;
modal.style.padding = params.padding + 'px';
modal.style.background = params.background;
var successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
for (var i = 0; i < successIconParts.length; i++) {
successIconParts[i].style.background = params.background;
}
var title = getTitle();
var content = getContent();
var buttonsWrapper = getButtonsWrapper();
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton();
var closeButton = getCloseButton
// Title
();if (params.titleText) {
title.innerText = params.titleText;
} else {
title.innerHTML = params.title.split('\n').join('<br>');
}
// Content
if (params.text || params.html) {
if (_typeof(params.html) === 'object') {
content.innerHTML = '';
if (0 in params.html) {
for (var _i = 0; _i in params.html; _i++) {
content.appendChild(params.html[_i].cloneNode(true));
}
} else {
content.appendChild(params.html.cloneNode(true));
}
} else if (params.html) {
content.innerHTML = params.html;
} else if (params.text) {
content.textContent = params.text;
}
show(content);
} else {
hide(content);
}
// Close button
if (params.showCloseButton) {
show(closeButton);
} else {
hide(closeButton);
}
// Custom Class
modal.className = swalClasses.modal;
if (params.customClass) {
addClass(modal, params.customClass);
}
// Progress steps
var progressStepsContainer = getProgressSteps();
var currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10);
if (params.progressSteps.length) {
show(progressStepsContainer);
empty(progressStepsContainer);
if (currentProgressStep >= params.progressSteps.length) {
console.warn('SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
}
params.progressSteps.forEach(function (step, index) {
var circle = document.createElement('li');
addClass(circle, swalClasses.progresscircle);
circle.innerHTML = step;
if (index === currentProgressStep) {
addClass(circle, swalClasses.activeprogressstep);
}
progressStepsContainer.appendChild(circle);
if (index !== params.progressSteps.length - 1) {
var line = document.createElement('li');
addClass(line, swalClasses.progressline);
line.style.width = params.progressStepsDistance;
progressStepsContainer.appendChild(line);
}
});
} else {
hide(progressStepsContainer);
}
// Icon
var icons = getIcons();
for (var _i2 = 0; _i2 < icons.length; _i2++) {
hide(icons[_i2]);
}
if (params.type) {
var validType = false;
for (var iconType in iconTypes) {
if (params.type === iconType) {
validType = true;
break;
}
}
if (!validType) {
console.error('SweetAlert2: Unknown alert type: ' + params.type);
return false;
}
var icon = modal.querySelector('.' + swalClasses.icon + '.' + iconTypes[params.type]);
show(icon
// Animate icon
);if (params.animation) {
switch (params.type) {
case 'success':
addClass(icon, 'swal2-animate-success-icon');
addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip');
addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long');
break;
case 'error':
addClass(icon, 'swal2-animate-error-icon');
addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark');
break;
default:
break;
}
}
}
// Custom image
var image = getImage();
if (params.imageUrl) {
image.setAttribute('src', params.imageUrl);
show(image);
if (params.imageWidth) {
image.setAttribute('width', params.imageWidth);
} else {
image.removeAttribute('width');
}
if (params.imageHeight) {
image.setAttribute('height', params.imageHeight);
} else {
image.removeAttribute('height');
}
image.className = swalClasses.image;
if (params.imageClass) {
addClass(image, params.imageClass);
}
} else {
hide(image);
}
// Cancel button
if (params.showCancelButton) {
cancelButton.style.display = 'inline-block';
} else {
hide(cancelButton);
}
// Confirm button
if (params.showConfirmButton) {
removeStyleProperty(confirmButton, 'display');
} else {
hide(confirmButton);
}
// Buttons wrapper
if (!params.showConfirmButton && !params.showCancelButton) {
hide(buttonsWrapper);
} else {
show(buttonsWrapper);
}
// Edit text on cancel and confirm buttons
confirmButton.innerHTML = params.confirmButtonText;
cancelButton.innerHTML = params.cancelButtonText;
// Set buttons to selected background colors
if (params.buttonsStyling) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
cancelButton.style.backgroundColor = params.cancelButtonColor;
}
// Add buttons custom classes
confirmButton.className = swalClasses.confirm;
addClass(confirmButton, params.confirmButtonClass);
cancelButton.className = swalClasses.cancel;
addClass(cancelButton, params.cancelButtonClass
// Buttons styling
);if (params.buttonsStyling) {
addClass(confirmButton, swalClasses.styled);
addClass(cancelButton, swalClasses.styled);
} else {
removeClass(confirmButton, swalClasses.styled);
removeClass(cancelButton, swalClasses.styled);
confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = '';
cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = '';
}
// CSS animation
if (params.animation === true) {
removeClass(modal, swalClasses.noanimation);
} else {
addClass(modal, swalClasses.noanimation);
}
};
/*
* Animations
*/
var openModal = function openModal(animation, onComplete) {
var container = getContainer();
var modal = getModal();
if (animation) {
addClass(modal, swalClasses.show);
addClass(container, swalClasses.fade);
removeClass(modal, swalClasses.hide);
} else {
removeClass(modal, swalClasses.fade);
}
show(modal
// scrolling is 'hidden' until animation is done, after that 'auto'
);container.style.overflowY = 'hidden';
if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
container.style.overflowY = 'auto';
});
} else {
container.style.overflowY = 'auto';
}
addClass(document.documentElement, swalClasses.shown);
addClass(document.body, swalClasses.shown);
addClass(container, swalClasses.shown);
fixScrollbar();
iOSfix();
states.previousActiveElement = document.activeElement;
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal);
});
}
};
var fixScrollbar = function fixScrollbar() {
// for queues, do not do this more than once
if (states.previousBodyPadding !== null) {
return;
}
// if the body has overflow
if (document.body.scrollHeight > window.innerHeight) {
// add padding so the content doesn't shift after removal of scrollbar
states.previousBodyPadding = document.body.style.paddingRight;
document.body.style.paddingRight = measureScrollbar() + 'px';
}
};
var undoScrollbar = function undoScrollbar() {
if (states.previousBodyPadding !== null) {
document.body.style.paddingRight = states.previousBodyPadding;
states.previousBodyPadding = null;
}
};
// Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
var iOSfix = function iOSfix() {
var iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
if (iOS && !hasClass(document.body, swalClasses.iosfix)) {
var offset = document.body.scrollTop;
document.body.style.top = offset * -1 + 'px';
addClass(document.body, swalClasses.iosfix);
}
};
var undoIOSfix = function undoIOSfix() {
if (hasClass(document.body, swalClasses.iosfix)) {
var offset = parseInt(document.body.style.top, 10);
removeClass(document.body, swalClasses.iosfix);
document.body.style.top = '';
document.body.scrollTop = offset * -1;
}
};
// SweetAlert entry point
var sweetAlert = function sweetAlert() {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (args[0] === undefined) {
console.error('SweetAlert2 expects at least 1 attribute!');
return false;
}
var params = _extends({}, modalParams);
switch (_typeof(args[0])) {
case 'string':
params.title = args[0];
params.html = args[1];
params.type = args[2];
break;
case 'object':
_extends(params, args[0]);
params.extraParams = args[0].extraParams;
if (params.input === 'email' && params.inputValidator === null) {
params.inputValidator = function (email) {
return new Promise(function (resolve, reject) {
var emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
if (emailRegex.test(email)) {
resolve();
} else {
reject('Invalid email address');
}
});
};
}
if (params.input === 'url' && params.inputValidator === null) {
params.inputValidator = function (url) {
return new Promise(function (resolve, reject) {
// taken from https://stackoverflow.com/a/3809435/1331425
var urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/;
if (urlRegex.test(url)) {
resolve();
} else {
reject('Invalid URL');
}
});
};
}
break;
default:
console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + _typeof(args[0]));
return false;
}
setParameters(params);
var container = getContainer();
var modal = getModal();
return new Promise(function (resolve, reject) {
// Close on timer
if (params.timer) {
modal.timeout = setTimeout(function () {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('timer');
} else {
resolve({ dismiss: 'timer' });
}
}, params.timer);
}
// Get input element by specified type or, if type isn't specified, by params.input
var getInput = function getInput(inputType) {
inputType = inputType || params.input;
if (!inputType) {
return null;
}
switch (inputType) {
case 'select':
case 'textarea':
case 'file':
return getChildByClass(modal, swalClasses[inputType]);
case 'checkbox':
return modal.querySelector('.' + swalClasses.checkbox + ' input');
case 'radio':
return modal.querySelector('.' + swalClasses.radio + ' input:checked') || modal.querySelector('.' + swalClasses.radio + ' input:first-child');
case 'range':
return modal.querySelector('.' + swalClasses.range + ' input');
default:
return getChildByClass(modal, swalClasses.input);
}
};
// Get the value of the modal input
var getInputValue = function getInputValue() {
var input = getInput();
if (!input) {
return null;
}
switch (params.input) {
case 'checkbox':
return input.checked ? 1 : 0;
case 'radio':
return input.checked ? input.value : null;
case 'file':
return input.files.length ? input.files[0] : null;
default:
return params.inputAutoTrim ? input.value.trim() : input.value;
}
};
// input autofocus
if (params.input) {
setTimeout(function () {
var input = getInput();
if (input) {
focusInput(input);
}
}, 0);
}
var confirm = function confirm(value) {
if (params.showLoaderOnConfirm) {
sweetAlert.showLoading();
}
if (params.preConfirm) {
params.preConfirm(value, params.extraParams).then(function (preConfirmValue) {
sweetAlert.closeModal(params.onClose);
resolve(preConfirmValue || value);
}, function (error) {
sweetAlert.hideLoading();
if (error) {
sweetAlert.showValidationError(error);
}
});
} else {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
resolve(value);
} else {
resolve({ value: value });
}
}
};
// Mouse interactions
var onButtonEvent = function onButtonEvent(event) {
var e = event || window.event;
var target = e.target || e.srcElement;
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton();
var targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target));
var targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target));
switch (e.type) {
case 'mouseover':
case 'mouseup':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1);
}
}
break;
case 'mouseout':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = params.confirmButtonColor;
} else if (targetedCancel) {
cancelButton.style.backgroundColor = params.cancelButtonColor;
}
}
break;
case 'mousedown':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2);
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2);
}
}
break;
case 'click':
// Clicked 'confirm'
if (targetedConfirm && sweetAlert.isVisible()) {
sweetAlert.disableButtons();
if (params.input) {
var inputValue = getInputValue();
if (params.inputValidator) {
sweetAlert.disableInput();
params.inputValidator(inputValue, params.extraParams).then(function () {
sweetAlert.enableButtons();
sweetAlert.enableInput();
confirm(inputValue);
}, function (error) {
sweetAlert.enableButtons();
sweetAlert.enableInput();
if (error) {
sweetAlert.showValidationError(error);
}
});
} else {
confirm(inputValue);
}
} else {
confirm(true);
}
// Clicked 'cancel'
} else if (targetedCancel && sweetAlert.isVisible()) {
sweetAlert.disableButtons();
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('cancel');
} else {
resolve({ dismiss: 'cancel' });
}
}
break;
default:
}
};
var buttons = modal.querySelectorAll('button');
for (var i = 0; i < buttons.length; i++) {
buttons[i].onclick = onButtonEvent;
buttons[i].onmouseover = onButtonEvent;
buttons[i].onmouseout = onButtonEvent;
buttons[i].onmousedown = onButtonEvent;
}
// Closing modal by close button
getCloseButton().onclick = function () {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('close');
} else {
resolve({ dismiss: 'close' });
}
};
// Closing modal by overlay click
container.onclick = function (e) {
if (e.target !== container) {
return;
}
if (params.allowOutsideClick) {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('overlay');
} else {
resolve({ dismiss: 'overlay' });
}
}
};
var buttonsWrapper = getButtonsWrapper();
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton
// Reverse buttons (Confirm on the right side)
();if (params.reverseButtons) {
confirmButton.parentNode.insertBefore(cancelButton, confirmButton);
} else {
confirmButton.parentNode.insertBefore(confirmButton, cancelButton);
}
// Focus handling
var setFocus = function setFocus(index, increment) {
var focusableElements = getFocusableElements(params.focusCancel
// search for visible elements and select the next possible match
);for (var _i3 = 0; _i3 < focusableElements.length; _i3++) {
index = index + increment;
// rollover to first item
if (index === focusableElements.length) {
index = 0;
// go to last item
} else if (index === -1) {
index = focusableElements.length - 1;
}
// determine if element is visible
var el = focusableElements[index];
if (isVisible(el)) {
return el.focus();
}
}
};
var handleKeyDown = function handleKeyDown(event) {
var e = event || window.event;
var keyCode = e.keyCode || e.which;
if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
// Don't do work on keys we don't care about.
return;
}
var targetElement = e.target || e.srcElement;
var focusableElements = getFocusableElements(params.focusCancel);
var btnIndex = -1; // Find the button - note, this is a nodelist, not an array.
for (var _i4 = 0; _i4 < focusableElements.length; _i4++) {
if (targetElement === focusableElements[_i4]) {
btnIndex = _i4;
break;
}
}
// TAB
if (keyCode === 9) {
if (!e.shiftKey) {
// Cycle to the next button
setFocus(btnIndex, 1);
} else {
// Cycle to the prev button
setFocus(btnIndex, -1);
}
e.stopPropagation();
e.preventDefault
// ARROWS - switch focus between buttons
();
} else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
// focus Cancel button if Confirm button is currently focused
if (document.activeElement === confirmButton && isVisible(cancelButton)) {
cancelButton.focus
// and vice versa
();
} else if (document.activeElement === cancelButton && isVisible(confirmButton)) {
confirmButton.focus();
}
// ENTER/SPACE
} else if (keyCode === 13 || keyCode === 32) {
if (btnIndex === -1 && params.allowEnterKey) {
// ENTER/SPACE clicked outside of a button.
if (params.focusCancel) {
fireClick(cancelButton, e);
} else {
fireClick(confirmButton, e);
}
e.stopPropagation();
e.preventDefault();
}
// ESC
} else if (keyCode === 27 && params.allowEscapeKey === true) {
sweetAlert.closeModal(params.onClose);
if (params.useRejections) {
reject('esc');
} else {
resolve({ dismiss: 'esc' });
}
}
};
if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
states.previousWindowKeyDown = window.onkeydown;
window.onkeydown = handleKeyDown;
}
// Loading state
if (params.buttonsStyling) {
confirmButton.style.borderLeftColor = params.confirmButtonColor;
confirmButton.style.borderRightColor = params.confirmButtonColor;
}
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
sweetAlert.hideLoading = sweetAlert.disableLoading = function () {
if (!params.showConfirmButton) {
hide(confirmButton);
if (!params.showCancelButton) {
hide(getButtonsWrapper());
}
}
removeClass(buttonsWrapper, swalClasses.loading);
removeClass(modal, swalClasses.loading);
confirmButton.disabled = false;
cancelButton.disabled = false;
};
sweetAlert.getTitle = function () {
return getTitle();
};
sweetAlert.getContent = function () {
return getContent();
};
sweetAlert.getInput = function () {
return getInput();
};
sweetAlert.getImage = function () {
return getImage();
};
sweetAlert.getButtonsWrapper = function () {
return getButtonsWrapper();
};
sweetAlert.getConfirmButton = function () {
return getConfirmButton();
};
sweetAlert.getCancelButton = function () {
return getCancelButton();
};
sweetAlert.enableButtons = function () {
confirmButton.disabled = false;
cancelButton.disabled = false;
};
sweetAlert.disableButtons = function () {
confirmButton.disabled = true;
cancelButton.disabled = true;
};
sweetAlert.enableConfirmButton = function () {
confirmButton.disabled = false;
};
sweetAlert.disableConfirmButton = function () {
confirmButton.disabled = true;
};
sweetAlert.enableInput = function () {
var input = getInput();
if (!input) {
return false;
}
if (input.type === 'radio') {
var radiosContainer = input.parentNode.parentNode;
var radios = radiosContainer.querySelectorAll('input');
for (var _i5 = 0; _i5 < radios.length; _i5++) {
radios[_i5].disabled = false;
}
} else {
input.disabled = false;
}
};
sweetAlert.disableInput = function () {
var input = getInput();
if (!input) {
return false;
}
if (input && input.type === 'radio') {
var radiosContainer = input.parentNode.parentNode;
var radios = radiosContainer.querySelectorAll('input');
for (var _i6 = 0; _i6 < radios.length; _i6++) {
radios[_i6].disabled = true;
}
} else {
input.disabled = true;
}
};
// Set modal min-height to disable scrolling inside the modal
sweetAlert.recalculateHeight = debounce(function () {
var modal = getModal();
if (!modal) {
return;
}
var prevState = modal.style.display;
modal.style.minHeight = '';
show(modal);
modal.style.minHeight = modal.scrollHeight + 1 + 'px';
modal.style.display = prevState;
}, 50
// Show block with validation error
);sweetAlert.showValidationError = function (error) {
var validationError = getValidationError();
validationError.innerHTML = error;
show(validationError);
var input = getInput();
if (input) {
focusInput(input);
addClass(input, swalClasses.inputerror);
}
};
// Hide block with validation error
sweetAlert.resetValidationError = function () {
var validationError = getValidationError();
hide(validationError);
sweetAlert.recalculateHeight();
var input = getInput();
if (input) {
removeClass(input, swalClasses.inputerror);
}
};
sweetAlert.getProgressSteps = function () {
return params.progressSteps;
};
sweetAlert.setProgressSteps = function (progressSteps) {
params.progressSteps = progressSteps;
setParameters(params);
};
sweetAlert.showProgressSteps = function () {
show(getProgressSteps());
};
sweetAlert.hideProgressSteps = function () {
hide(getProgressSteps());
};
sweetAlert.enableButtons();
sweetAlert.hideLoading();
sweetAlert.resetValidationError
// inputs
();var inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
var input = void 0;
for (var _i7 = 0; _i7 < inputTypes.length; _i7++) {
var inputClass = swalClasses[inputTypes[_i7]];
var inputContainer = getChildByClass(modal, inputClass);
input = getInput(inputTypes[_i7]
// set attributes
);if (input) {
for (var j in input.attributes) {
if (input.attributes.hasOwnProperty(j)) {
var attrName = input.attributes[j].name;
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName);
}
}
}
for (var attr in params.inputAttributes) {
input.setAttribute(attr, params.inputAttributes[attr]);
}
}
// set class
inputContainer.className = inputClass;
if (params.inputClass) {
addClass(inputContainer, params.inputClass);
}
hide(inputContainer);
}
var populateInputOptions = void 0;
switch (params.input) {
case 'text':
case 'email':
case 'password':
case 'number':
case 'tel':
case 'url':
input = getChildByClass(modal, swalClasses.input);
input.value = params.inputValue;
input.placeholder = params.inputPlaceholder;
input.type = params.input;
show(input);
break;
case 'file':
input = getChildByClass(modal, swalClasses.file);
input.placeholder = params.inputPlaceholder;
input.type = params.input;
show(input);
break;
case 'range':
var range = getChildByClass(modal, swalClasses.range);
var rangeInput = range.querySelector('input');
var rangeOutput = range.querySelector('output');
rangeInput.value = params.inputValue;
rangeInput.type = params.input;
rangeOutput.value = params.inputValue;
show(range);
break;
case 'select':
var select = getChildByClass(modal, swalClasses.select);
select.innerHTML = '';
if (params.inputPlaceholder) {
var placeholder = document.createElement('option');
placeholder.innerHTML = params.inputPlaceholder;
placeholder.value = '';
placeholder.disabled = true;
placeholder.selected = true;
select.appendChild(placeholder);
}
populateInputOptions = function populateInputOptions(inputOptions) {
for (var optionValue in inputOptions) {
var option = document.createElement('option');
option.value = optionValue;
option.innerHTML = inputOptions[optionValue];
if (params.inputValue === optionValue) {
option.selected = true;
}
select.appendChild(option);
}
show(select);
select.focus();
};
break;
case 'radio':
var radio = getChildByClass(modal, swalClasses.radio);
radio.innerHTML = '';
populateInputOptions = function populateInputOptions(inputOptions) {
for (var radioValue in inputOptions) {
var radioInput = document.createElement('input');
var radioLabel = document.createElement('label');
var radioLabelSpan = document.createElement('span');
radioInput.type = 'radio';
radioInput.name = swalClasses.radio;
radioInput.value = radioValue;
if (params.inputValue === radioValue) {
radioInput.checked = true;
}
radioLabelSpan.innerHTML = inputOptions[radioValue];
radioLabel.appendChild(radioInput);
radioLabel.appendChild(radioLabelSpan);
radioLabel.for = radioInput.id;
radio.appendChild(radioLabel);
}
show(radio);
var radios = radio.querySelectorAll('input');
if (radios.length) {
radios[0].focus();
}
};
break;
case 'checkbox':
var checkbox = getChildByClass(modal, swalClasses.checkbox);
var checkboxInput = getInput('checkbox');
checkboxInput.type = 'checkbox';
checkboxInput.value = 1;
checkboxInput.id = swalClasses.checkbox;
checkboxInput.checked = Boolean(params.inputValue);
var label = checkbox.getElementsByTagName('span');
if (label.length) {
checkbox.removeChild(label[0]);
}
label = document.createElement('span');
label.innerHTML = params.inputPlaceholder;
checkbox.appendChild(label);
show(checkbox);
break;
case 'textarea':
var textarea = getChildByClass(modal, swalClasses.textarea);
textarea.value = params.inputValue;
textarea.placeholder = params.inputPlaceholder;
show(textarea);
break;
case null:
break;
default:
console.error('SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "' + params.input + '"');
break;
}
if (params.input === 'select' || params.input === 'radio') {
if (params.inputOptions instanceof Promise) {
sweetAlert.showLoading();
params.inputOptions.then(function (inputOptions) {
sweetAlert.hideLoading();
populateInputOptions(inputOptions);
});
} else if (_typeof(params.inputOptions) === 'object') {
populateInputOptions(params.inputOptions);
} else {
console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + _typeof(params.inputOptions));
}
}
openModal(params.animation, params.onOpen
// Focus the first element (input or button)
);if (params.allowEnterKey) {
setFocus(-1, 1);
} else {
if (document.activeElement) {
document.activeElement.blur();
}
}
// fix scroll
getContainer().scrollTop = 0;
// Observe changes inside the modal and adjust height
if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
swal2Observer = new MutationObserver(sweetAlert.recalculateHeight);
swal2Observer.observe(modal, { childList: true, characterData: true, subtree: true });
}
});
};
/*
* Global function to determine if swal2 modal is shown
*/
sweetAlert.isVisible = function () {
return !!getModal();
};
/*
* Global function for chaining sweetAlert modals
*/
sweetAlert.queue = function (steps) {
queue = steps;
var resetQueue = function resetQueue() {
queue = [];
document.body.removeAttribute('data-swal2-queue-step');
};
var queueResult = [];
return new Promise(function (resolve, reject) {
(function step(i, callback) {
if (i < queue.length) {
document.body.setAttribute('data-swal2-queue-step', i);
sweetAlert(queue[i]).then(function (result) {
queueResult.push(result);
step(i + 1, callback);
}, function (dismiss) {
resetQueue();
reject(dismiss);
});
} else {
resetQueue();
resolve(queueResult);
}
})(0);
});
};
/*
* Global function for getting the index of current modal in queue
*/
sweetAlert.getQueueStep = function () {
return document.body.getAttribute('data-swal2-queue-step'
/*
* Global function for inserting a modal to the queue
*/
);
};sweetAlert.insertQueueStep = function (step, index) {
if (index && index < queue.length) {
return queue.splice(index, 0, step);
}
return queue.push(step);
};
/*
* Global function for deleting a modal from the queue
*/
sweetAlert.deleteQueueStep = function (index) {
if (typeof queue[index] !== 'undefined') {
queue.splice(index, 1);
}
};
/*
* Global function to close sweetAlert
*/
sweetAlert.close = sweetAlert.closeModal = function (onComplete) {
var container = getContainer();
var modal = getModal();
if (!modal) {
return;
}
removeClass(modal, swalClasses.show);
addClass(modal, swalClasses.hide);
clearTimeout(modal.timeout);
resetPrevState();
var removeModalAndResetState = function removeModalAndResetState() {
if (container.parentNode) {
container.parentNode.removeChild(container);
}
removeClass(document.documentElement, swalClasses.shown);
removeClass(document.body, swalClasses.shown);
undoScrollbar();
undoIOSfix();
};
// If animation is supported, animate
if (animationEndEvent && !hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(animationEndEvent, function swalCloseEventFinished() {
modal.removeEventListener(animationEndEvent, swalCloseEventFinished);
if (hasClass(modal, swalClasses.hide)) {
removeModalAndResetState();
}
});
} else {
// Otherwise, remove immediately
removeModalAndResetState();
}
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal);
});
}
};
/*
* Global function to click 'Confirm' button
*/
sweetAlert.clickConfirm = function () {
return getConfirmButton().click
/*
* Global function to click 'Cancel' button
*/
();
};sweetAlert.clickCancel = function () {
return getCancelButton().click
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
();
};sweetAlert.showLoading = sweetAlert.enableLoading = function () {
var modal = getModal();
if (!modal) {
sweetAlert('');
}
var buttonsWrapper = getButtonsWrapper();
var confirmButton = getConfirmButton();
var cancelButton = getCancelButton();
show(buttonsWrapper);
show(confirmButton, 'inline-block');
addClass(buttonsWrapper, swalClasses.loading);
addClass(modal, swalClasses.loading);
confirmButton.disabled = true;
cancelButton.disabled = true;
};
/**
* Set default params for each popup
* @param {Object} userParams
*/
sweetAlert.setDefaults = function (userParams) {
if (!userParams || (typeof userParams === 'undefined' ? 'undefined' : _typeof(userParams)) !== 'object') {
return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object');
}
for (var param in userParams) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn('SweetAlert2: Unknown parameter "' + param + '"');
delete userParams[param];
}
}
_extends(modalParams, userParams);
};
/**
* Reset default params for each popup
*/
sweetAlert.resetDefaults = function () {
modalParams = _extends({}, defaultParams);
};
sweetAlert.noop = function () {};
sweetAlert.version = '6.6.5';
sweetAlert.default = sweetAlert;
module.exports = sweetAlert;
if (window.Sweetalert2) window.sweetAlert = window.swal = window.Sweetalert2;
README.md 0000664 00000042455 15243426217 0006045 0 ustar 00 SweetAlert2
-----------
[](https://travis-ci.org/limonte/sweetalert2)
[](https://www.npmjs.com/package/sweetalert2)
[](http://standardjs.com/)
[](http://isitmaintained.com/project/limonte/sweetalert2 "Average time to resolve an issue")
[](https://gitter.im/sweetalert2/Lobby)
[](https://www.paypal.me/limonte/5eur)
A beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies.
What's the difference between SweetAlert and SweetAlert2?
---------------------------------------------------------
- [Reason of creating this fork is inactivity of original SweetAlert plugin](http://stackoverflow.com/a/27842854/1331425)
- [SweetAlert to SweetAlert2 migration guide](https://github.com/limonte/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2)
---
[See SweetAlert2 in action!](https://limonte.github.io/sweetalert2/)
<img src="https://raw.github.com/limonte/sweetalert2/master/assets/sweetalert2.gif" width="686">
Installation
------------
```bash
npm install --save sweetalert2
```
Or:
```bash
bower install --save sweetalert2
```
Or download from CDN: [cdnjs.com/limonte-sweetalert2](https://cdnjs.com/libraries/limonte-sweetalert2)
Usage
-----
```html
<script src="bower_components/sweetalert2/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" type="text/css" href="bower_components/sweetalert2/dist/sweetalert2.min.css">
<!-- Include a polyfill for ES6 Promises (optional) for IE11, UC Browser and Android browser support -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/core-js/2.4.1/core.js"></script>
```
Or:
```js
// ES6 Modules or TypeScript
import swal from 'sweetalert2'
// CommonJS
const swal = require('sweetalert2')
```
Please note that TypeScript is supported, so you don't have to install a third-party declaration file.
Examples
--------
The most basic message:
```js
swal('Hello world!')
```
A message signaling an error:
```js
swal('Oops...', 'Something went wrong!', 'error')
```
Handling the result of SweetAlert2 modal:
```js
swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keep it'
}).then(function() {
swal(
'Deleted!',
'Your imaginary file has been deleted.',
'success'
)
}, function(dismiss) {
// dismiss can be 'overlay', 'cancel', 'close', 'esc', 'timer'
if (dismiss === 'cancel') {
swal(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
```
[View more examples](https://limonte.github.io/sweetalert2/)
Handling Dismissals
-------------------
When an alert is dismissed by the user, the Promise returned by `swal()` will reject with a string documenting the reason it was dismissed:
| String | Description | Related configuration |
| ----------- | ------------------------------------------------------- | --------------------- |
| `'overlay'` | The user clicked the overlay. | `allowOutsideClick` |
| `'cancel'` | The user clicked the cancel button. | `showCancelButton` |
| `'close'` | The user clicked the close button. | `showCloseButton` |
| `'esc'` | The user pressed the <kbd>Esc</kbd> key. | `allowEscapeKey` |
| `'timer'` | The timer ran out, and the alert closed automatically. | `timer` |
If rejections are not handled, it will be logged as an error. To avoid this, add a rejection handler to the Promise. Alternatively, you can use `.catch(swal.noop)` as a quick way to simply suppress the errors:
```js
swal(...)
.catch(swal.noop)
```
Modal Types
-----------
| `success` | `error` | `warning` | `info` | `question` |
| ------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
|  |  |  |  |  |
Configuration
-------------
| Argument | Default value | Description |
| ----------------------- | -------------------- | ----------- |
| `title` | `null` | The title of the modal, as HTML. It can either be added to the object under the key "title" or passed as the first parameter of the function. |
| `titleText` | `null` | The title of the modal, as text. Useful to avoid HTML injection. |
| `text` | `null` | A description for the modal. It can either be added to the object under the key "text" or passed as the second parameter of the function. |
| `html` | `null` | A HTML description for the modal. If `text` and `html` parameters are provided in the same time, "text" will be used. |
| `type` | `null` | The type of the modal. SweetAlert2 comes with [5 built-in types](#modal-types) which will show a corresponding icon animation: `warning`, `error`, `success`, `info` and `question`. It can either be put in the array under the key `type` or passed as the third parameter of the function. |
| `target` | `'body'` | The container element for adding modal into. |
| `input` | `null` | Input field type, can be `'text'`, `'email'`, `'password'`, `'number'`, `'tel'`, `'range'`, `'textarea'`, `'select'`, `'radio'`, `'checkbox'`, `'file'` and `'url'`. |
| `width` | `'500px'` | Modal window width, including paddings (`box-sizing: border-box`). Can be in `px` or `%`. |
| `padding` | `20` | Modal window padding. |
| `background` | `'#fff'` | Modal window background (CSS `background` property). |
| `customClass` | `null` | A custom CSS class for the modal. |
| `timer` | `null` | Auto close timer of the modal. Set in ms (milliseconds). |
| `animation` | `true` | If set to `false`, modal CSS animation will be disabled. |
| `allowOutsideClick` | `true` | If set to `false`, the user can't dismiss the modal by clicking outside it. |
| `allowEscapeKey` | `true` | If set to `false`, the user can't dismiss the modal by pressing the <kbd>Esc</kbd> key. |
| `allowEnterKey` | `true` | If set to `false`, the user can't confirm the modal by pressing the <kbd>Enter</kbd> or <kbd>Space</kbd> keys, unless they manually focus the confirm button. |
| `showConfirmButton` | `true` | If set to `false`, a "Confirm"-button will not be shown. It can be useful when you're using `html` parameter for custom HTML description. |
| `showCancelButton` | `false` | If set to `true`, a "Cancel"-button will be shown, which the user can click on to dismiss the modal. |
| `confirmButtonText` | `'OK'` | Use this to change the text on the "Confirm"-button. |
| `cancelButtonText` | `'Cancel'` | Use this to change the text on the "Cancel"-button. |
| `confirmButtonColor` | `'#3085d6'` | Use this to change the background color of the "Confirm"-button (must be a HEX value). |
| `cancelButtonColor` | `'#aaa'` | Use this to change the background color of the "Cancel"-button (must be a HEX value). |
| `confirmButtonClass` | `null` | A custom CSS class for the "Confirm"-button. |
| `cancelButtonClass` | `null` | A custom CSS class for the "Cancel"-button. |
| `buttonsStyling` | `true` | Apply default styling to buttons. If you want to use your own classes (e.g. Bootstrap classes) set this parameter to `false`. |
| `reverseButtons` | `false` | Set to `true` if you want to invert default buttons positions ("Confirm"-button on the right side). |
| `focusCancel` | `false` | Set to `true` if you want to focus the "Cancel"-button by default. |
| `showCloseButton` | `false` | Set to `true` to show close button in top right corner of the modal. |
| `showLoaderOnConfirm` | `false` | Set to `true` to disable buttons and show that something is loading. Useful for AJAX requests. |
| `preConfirm` | `null` | Function to execute before confirm, should return Promise, see <a href="https://limonte.github.io/sweetalert2/#ajax-request">usage example</a>. |
| `imageUrl` | `null` | Add an image for the modal. Should contain a string with the path or URL to the image. |
| `imageWidth` | `null` | If imageUrl is set, you can specify imageWidth to describes image width in px. |
| `imageHeight` | `null` | Custom image height in px. |
| `imageClass` | `null` | A custom CSS class for the image. |
| `inputPlaceholder` | `''` | Input field placeholder. |
| `inputValue` | `''` | Input field initial value. |
| `inputOptions` | `{}` or `Promise` | If `input` parameter is set to `'select'` or `'radio'`, you can provide options. Object keys will represent options values, object values will represent options text values. |
| `inputAutoTrim` | `true` | Automatically remove whitespaces from both ends of a result string. Set this parameter to `false` to disable auto-trimming. |
| `inputAttributes` | `{}` | HTML input attributes (e.g. `'min'`, `'max'`, `'autocomplete'`, `'accept'`), that are added to the input field. Object keys will represent attributes names, object values will represent attributes values. |
| `inputValidator` | `null` | Validator for input field, should return Promise, see <a href="https://limonte.github.io/sweetalert2/#select-box">usage example</a>. |
| `inputClass` | `null` | A custom CSS class for the input field. |
| `progressSteps` | `[]` | Progress steps, useful for modal queues, see <a href="https://limonte.github.io/sweetalert2/#chaining-modals">usage example</a>. |
| `currentProgressStep` | `null` | Current active progress step. The default is `swal.getQueueStep()`. |
| `progressStepsDistance` | `'40px'` | Distance between progress steps. |
| `onOpen` | `null` | Function to run when modal opens, provides modal DOM element as the first argument. |
| `onClose` | `null` | Function to run when modal closes, provides modal DOM element as the first argument. |
| `useRejections` | `true` | Determines whether dismissals (outside click, cancel button, close button, esc key) should reject, or resolve with an object of the format `{ dismiss: reason }`. Set it to `false` to get a cleaner control flow when using `await`, as explained in [#485](https://github.com/limonte/sweetalert2/issues/485). |
You can redefine default params by using `swal.setDefaults(customParams)` where `customParams` is an object.
Methods
-------
| Method | Description |
| ----------------------------------------------- | ----------- |
| `swal.isVisible()` | Determine if modal is shown. |
| `swal.setDefaults({Object})` | If you end up using a lot of the same settings when calling SweetAlert2, you can use setDefaults at the start of your program to set them once and for all! |
| `swal.resetDefaults()` | Resets settings to their default value. |
| `swal.close()` or `swal.closeModal()` | Close the currently open SweetAlert2 modal programmatically. |
| `swal.getTitle()` | Get the modal title. |
| `swal.getContent()` | Get the modal content. |
| `swal.getImage()` | Get the image. |
| `swal.getConfirmButton()` | Get the "Confirm" button. |
| `swal.getCancelButton()` | Get the "Cancel" button. |
| `swal.enableButtons()` | Enable "Confirm" and "Cancel" buttons. |
| `swal.disableButtons()` | Disable "Confirm" and "Cancel" buttons. |
| `swal.enableConfirmButton()` | Enable the "Confirm"-button only. |
| `swal.disableConfirmButton()` | Disable the "Confirm"-button only. |
| `swal.enableLoading()` or `swal.showLoading()` | Disable buttons and show loader. This is useful with AJAX requests. |
| `swal.disableLoading()` or `swal.hideLoading()` | Enable buttons and hide loader. |
| `swal.clickConfirm()` | Click the "Confirm"-button programmatically. |
| `swal.clickCancel()` | Click the "Cancel"-button programmatically. |
| `swal.showValidationError(error)` | Show validation error message. |
| `swal.resetValidationError()` | Hide validation error message. |
| `swal.getInput()` | Get the input DOM node, this method works with `input` parameter. |
| `swal.disableInput()` | Disable input. A disabled input element is unusable and un-clickable. |
| `swal.enableInput()` | Enable input. |
| `swal.queue([Array])` | Provide array of SweetAlert2 parameters to show multiple modals, one modal after another or a function that returns alert parameters given modal number. See [usage example](https://limonte.github.io/sweetalert2/#chaining-modals). |
| `swal.getQueueStep()` | Get the index of current modal in queue. When there's no active queue, `null` will be returned. |
| `swal.insertQueueStep()` | Insert a modal to queue, you can specify modal positioning with second parameter. By default a modal will be added to the end of a queue. |
| `swal.deleteQueueStep(index)` | Delete a modal at `index` from queue. |
| `swal.getProgressSteps()` | Progress steps getter. |
| `swal.setProgressSteps([])` | Progress steps setter. |
| `swal.showProgressSteps()` | Show progress steps. |
| `swal.hideProgressSteps()` | Hide progress steps. |
Browser compatibility
---------------------
| IE11* | Edge | Chrome | Firefox | Safari | Opera | Android Browser* | UC Browser* |
|-------|------|--------|---------|--------|-------|------------------|-------------|
| ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
\* ES6 Promise polyfill should be included, see [usage example](#usage).
Note that SweetAlert2 **does not** and **will not** provide support or functionality of any kind on IE10 and lower.
Contributing
------------
If you would like to contribute enhancements or fixes, please do the following:
1. Fork the `sweetalert2` repository and clone it locally.
2. Make sure you have [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) installed.
3. When in the SweetAlert2 directory, run `npm install` or `yarn install` to install dependencies.
4. Start gulp watcher `gulp watch` to automatically build and minify the SCSS and JS-files.
5. Check that your code is compliant with code linters: `gulp lint`.
6. Ensure that you didn't break any of tests: `npm test`.
7. Make sure that `dist/*` files aren't committed and create a pull request.
Related projects
----------------
- [toverux/ngsweetalert2](https://github.com/toverux/ngsweetalert2) - SweetAlert2 directive for Angular 2+
- [lishengzxc/vue-sweetalert](https://github.com/lishengzxc/vue-sweetalert) - SweetAlert2 plugin for Vue.js
- [limonte/sweetalert2-webpack-demo](https://github.com/limonte/sweetalert2-webpack-demo) - SweetAlert2 + webpack demo
Donations
---------
If you liked this plugin, you can donate to support it:
- https://www.paypal.me/limonte/5eur
sweetalert2.d.ts 0000664 00000037170 15243426217 0007617 0 ustar 00 declare module 'sweetalert2' {
/**
* Shorthand function to display a simple SweetAlert modal.
*
* ex.
* import swal from 'sweetalert2';
* swal('The Internet?', 'That thing is still around?', 'question');
*/
function swal(title: string, message?: string, type?: SweetAlertType): Promise<any>;
/**
* Function to display a SweetAlert modal, with an object of options, all being optional.
* See the SweetAlertOptions interface for the list of accepted fields and values.
*
* ex.
* import swal from 'sweetalert2';
* swal({
* title: 'Auto close alert!',
* text: 'I will close in 2 seconds.',
* timer: 2000
* })
*/
function swal(settings: SweetAlertOptions): Promise<any>;
/**
* A namespace inside the default function, containing utility function for controlling the currently-displayed modal.
*
* ex.
* import swal from 'sweetalert2';
*
* swal('Hey user!', 'I don\'t like you.', 'warning');
*
* if(swal.isVisible()) { // instant regret
* swal.close();
* }
*/
namespace swal {
/**
* Determine if modal is shown.
* Be aware that the library returns a trueish or falsy value, not a real boolean.
*/
function isVisible(): boolean;
/**
* If you end up using a lot of the same settings when calling SweetAlert2,
* you can use setDefaults at the start of your program to set them once and for all!
*/
function setDefaults(defaultOptions: SweetAlertOptions): void;
/**
* Resets settings to their default value.
*/
function resetDefaults(): void;
/**
* Close the currently open SweetAlert2 modal programmatically.
*/
function close(onComplete?: (modalElement: HTMLElement) => void): void;
/**
* Get the modal title.
*/
function getTitle(): HTMLElement;
/**
* Get the modal content.
*/
function getContent(): HTMLElement;
/**
* Get the image.
*/
function getImage(): HTMLElement;
/**
* Get the "Confirm" button.
*/
function getConfirmButton(): HTMLElement;
/**
* Get the "Cancel" button.
*/
function getCancelButton(): HTMLElement;
/**
* Enable "Confirm" and "Cancel" buttons.
*/
function enableButtons(): void;
/**
* Disable "Confirm" and "Cancel" buttons.
*/
function disableButtons(): void;
/**
* Enable the "Confirm"-button only.
*/
function enableConfirmButton(): void;
/**
* Disable the "Confirm"-button only.
*/
function disableConfirmButton(): void;
/**
* Disable buttons and show loader. This is useful with AJAX requests.
*/
function showLoading(): void;
/**
* Enable buttons and hide loader.
*/
function hideLoading(): void;
/**
* Click the "Confirm"-button programmatically.
*/
function clickConfirm(): void;
/**
* Click the "Cancel"-button programmatically.
*/
function clickCancel(): void;
/**
* Show validation error message.
*/
function showValidationError(error: string): void;
/**
* Hide validation error message.
*/
function resetValidationError(): void;
/**
* Get the input DOM node, this method works with input parameter.
*/
function getInput(): HTMLElement;
/**
* Disable input. A disabled input element is unusable and un-clickable.
*/
function disableInput(): void;
/**
* Enable input.
*/
function enableInput(): void;
/**
* Provide array of SweetAlert2 parameters to show multiple modals, one modal after another.
*/
function queue(steps: (SweetAlertOptions|string)[]): Promise<any>;
/**
* Get the index of current modal in queue. When there's no active queue, null will be returned.
*/
function getQueueStep(): string|null;
/**
* Insert a modal to queue, you can specify modal positioning with second parameter.
* By default a modal will be added to the end of a queue.
*/
function insertQueueStep(step: SweetAlertOptions, index?: number): number;
/**
* Delete a modal at index from queue.
*/
function deleteQueueStep(index: number): void;
/**
* Progress steps getter.
*/
function getProgressSteps(): string[];
/**
* Progress steps setter.
*/
function setProgressSteps(steps: string[]): void;
/**
* Show progress steps.
*/
function showProgressSteps(): void;
/**
* Hide progress steps.
*/
function hideProgressSteps(): void;
/**
* An utility function to make SweetAlert rejections silencious (no error in the console when clicking Cancel).
* ex. swal(...).catch(swal.noop)
*/
function noop(): void;
}
export type SweetAlertType = 'success'|'error'|'warning'|'info'|'question'|undefined;
export type SweetAlertInputType = 'text'|'email'|'password'|'number'|'tel'|'range'|'textarea'|'select'|'radio'|'checkbox'|'file'|'url'|undefined;
export type SweetAlertInputOptions = { [inputValue: string]: string };
export type SweetAlertInputAttributes = { [attribute: string]: string };
export interface SweetAlertOptions {
/**
* The title of the modal, as HTML.
* It can either be added to the object under the key "title" or passed as the first parameter of the function.
*
* @default null
*/
title?: string;
/**
* The title of the modal, as text. Useful to avoid HTML injection.
*
* @default null
*/
titleText?: string;
/**
* A description for the modal.
* It can either be added to the object under the key "text" or passed as the second parameter of the function.
*
* @default null
*/
text?: string;
/**
* A HTML description for the modal.
* If "text" and "html" parameters are provided in the same time, "text" will be used.
*
* @default null
*/
html?: string;
/**
* The type of the modal.
* SweetAlert2 comes with 5 built-in types which will show a corresponding icon animation: warning, error, success, info and question.
* It can either be put in the array under the key "type" or passed as the third parameter of the function.
*
* @default null
*/
type?: SweetAlertType;
/**
* The container element for adding modal into (query selector only).
*
* @default 'body'
*/
target?: string;
/**
* Input field type, can be text, email, password, number, tel, range, textarea, select, radio, checkbox, file and url.
*
* @default null
*/
input?: SweetAlertInputType;
/**
* Modal window width, including paddings (box-sizing: border-box). Can be in px or %.
*
* @default '500px'
*/
width?: number|string;
/**
* Modal window padding.
*
* @default 20
*/
padding?: number;
/**
* Modal window background (CSS background property).
*
* @default '#fff'
*/
background?: string;
/**
* A custom CSS class for the modal.
*
* @default null
*/
customClass?: string;
/**
* Auto close timer of the modal. Set in ms (milliseconds).
*
* @default null
*/
timer?: number;
/**
* If set to false, modal CSS animation will be disabled.
*
* @default true
*/
animation?: boolean;
/**
* If set to false, the user can't dismiss the modal by clicking outside it.
*
* @default true
*/
allowOutsideClick?: boolean;
/**
* If set to false, the user can't dismiss the modal by pressing the Escape key.
*
* @default true
*/
allowEscapeKey?: boolean
/**
* If set to false, the user can't confirm the modal by pressing the Enter or Space keys,
* unless they manually focus the confirm button.
*
* @default true
*/
allowEnterKey?: boolean;
/**
* If set to false, a "Confirm"-button will not be shown.
* It can be useful when you're using custom HTML description.
*
* @default true
*/
showConfirmButton?: boolean;
/**
* If set to true, a "Cancel"-button will be shown, which the user can click on to dismiss the modal.
*
* @default false
*/
showCancelButton?: boolean;
/**
* Use this to change the text on the "Confirm"-button.
*
* @default 'OK'
*/
confirmButtonText?: string;
/**
* Use this to change the text on the "Cancel"-button.
*
* @default 'Cancel'
*/
cancelButtonText?: string;
/**
* Use this to change the background color of the "Confirm"-button (must be a HEX value).
*
* @default '#3085d6'
*/
confirmButtonColor?: string;
/**
* Use this to change the background color of the "Cancel"-button (must be a HEX value).
*
* @default '#aaa'
*/
cancelButtonColor?: string;
/**
* A custom CSS class for the "Confirm"-button.
*
* @default null
*/
confirmButtonClass?: string;
/**
* A custom CSS class for the "Cancel"-button.
*
* @default null
*/
cancelButtonClass?: string;
/**
* Whether to apply the default swal2 styling to buttons.
* If you want to use your own classes (e.g. Bootstrap classes) set this parameter to false.
*
* @default true
*/
buttonsStyling?: boolean;
/**
* Set to true if you want to invert default buttons positions.
*
* @default false
*/
reverseButtons?: boolean;
/**
* Set to true if you want to focus the "Cancel"-button by default.
*
* @default false
*/
focusCancel?: boolean;
/**
* Set to true to show close button in top right corner of the modal.
*
* @default false
*/
showCloseButton?: boolean;
/**
* Set to true to disable buttons and show that something is loading. Useful for AJAX requests.
*
* @default false
*/
showLoaderOnConfirm?: boolean;
/**
* Function to execute before confirm, should return Promise.
*
* ex.
* swal({
* title: 'Multiple inputs',
* html:
* '<input id="swal-input1" class="swal2-input" autofocus>' +
* '<input id="swal-input2" class="swal2-input">',
* preConfirm: () => Promise.resolve([$('#swal-input1').val(), $('#swal-input2').val()])
* }).then(result => swal(JSON.stringify(result));
*
* @default null
*/
preConfirm?: (inputValue: any) => Promise<any>;
/**
* Add a customized icon for the modal. Should contain a string with the path or URL to the image.
*
* @default null
*/
imageUrl?: string;
/**
* If imageUrl is set, you can specify imageWidth to describes image width in px.
*
* @default null
*/
imageWidth?: number;
/**
* If imageUrl is set, you can specify imageHeight to describes image height in px.
*
* @default null
*/
imageHeight?: number;
/**
* A custom CSS class for the customized icon.
*
* @default null
*/
imageClass?: string;
/**
* Input field placeholder.
*
* @default ''
*/
inputPlaceholder?: string;
/**
* Input field initial value.
*
* @default ''
*/
inputValue?: any;
/**
* If input parameter is set to "select" or "radio", you can provide options.
* Object keys will represent options values, object values will represent options text values.
*/
inputOptions?: SweetAlertInputOptions|Promise<SweetAlertInputOptions>;
/**
* Automatically remove whitespaces from both ends of a result string.
* Set this parameter to false to disable auto-trimming.
*
* @default true
*/
inputAutoTrim?: boolean;
/**
* HTML input attributes (e.g. min, max, step, accept...), that are added to the input field.
*
* ex.
* swal({
* title: 'Select a file',
* input: 'file',
* inputAttributes: {
* accept: 'image/*'
* }
* })
*
* @default null
*/
inputAttributes?: SweetAlertInputAttributes;
/**
* Validator for input field, should return a Promise.
*
* ex.
* swal({
* title: 'Select color',
* input: 'radio',
* inputValidator: result => new Promise((resolve, reject) => {
* result ? resolve() : reject('You need to select something!');
* })
* })
*
* @default null
*/
inputValidator?: (result: any) => Promise<void>;
/**
* A custom CSS class for the input field.
*
* @default null
*/
inputClass?: string;
/**
* Progress steps, useful for modal queues, see usage example.
*
* @default []
*/
progressSteps?: SweetAlertOptions[];
/**
* Current active progress step.
*
* @default swal.getQueueStep()
*/
currentProgressStep?: string;
/**
* Distance between progress steps.
*
* @default '40px'
*/
progressStepsDistance?: string;
/**
* Function to run when modal opens, provides modal DOM element as the first argument.
*
* @default null
*/
onOpen?: (modalElement: HTMLElement) => void;
/**
* Function to run when modal closes, provides modal DOM element as the first argument.
*
* @default null
*/
onClose?: (modalElement: HTMLElement) => void;
/**
* Determines whether dismissals (outside click, cancel button, close button, esc key) should reject, or resolve with an object of the format `{ dismiss: reason }`.
* Set it to `false` to get a cleaner control flow when using `await`, as explained here: https://github.com/limonte/sweetalert2/issues/485
*
* @default true
*/
useRejections?: boolean;
}
export default swal;
}