migrate to new git
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { error } from '../utils/utils.js'
|
||||
|
||||
const isJqueryElement = (elem) => typeof elem === 'object' && elem.jquery
|
||||
const isElement = (elem) => elem instanceof Element || isJqueryElement(elem)
|
||||
|
||||
export const argsToParams = (args) => {
|
||||
const params = {}
|
||||
if (typeof args[0] === 'object' && !isElement(args[0])) {
|
||||
Object.assign(params, args[0])
|
||||
} else {
|
||||
['title', 'html', 'icon'].forEach((name, index) => {
|
||||
const arg = args[index]
|
||||
if (typeof arg === 'string' || isElement(arg)) {
|
||||
params[name] = arg
|
||||
} else if (arg !== undefined) {
|
||||
error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`)
|
||||
}
|
||||
})
|
||||
}
|
||||
return params
|
||||
}
|
||||
40
web/App_Script/sweetalert2-9.10.9/src/staticMethods/dom.js
Normal file
40
web/App_Script/sweetalert2-9.10.9/src/staticMethods/dom.js
Normal file
@@ -0,0 +1,40 @@
|
||||
import * as dom from '../utils/dom/index.js'
|
||||
import * as domUtils from '../utils/dom/domUtils.js'
|
||||
|
||||
export {
|
||||
getContainer,
|
||||
getPopup,
|
||||
getTitle,
|
||||
getContent,
|
||||
getHtmlContainer,
|
||||
getImage,
|
||||
getIcon,
|
||||
getIcons,
|
||||
getCloseButton,
|
||||
getActions,
|
||||
getConfirmButton,
|
||||
getCancelButton,
|
||||
getHeader,
|
||||
getFooter,
|
||||
getTimerProgressBar,
|
||||
getFocusableElements,
|
||||
getValidationMessage,
|
||||
isLoading
|
||||
} from '../utils/dom/index.js'
|
||||
|
||||
/*
|
||||
* Global function to determine if SweetAlert2 popup is shown
|
||||
*/
|
||||
export const isVisible = () => {
|
||||
return domUtils.isVisible(dom.getPopup())
|
||||
}
|
||||
|
||||
/*
|
||||
* Global function to click 'Confirm' button
|
||||
*/
|
||||
export const clickConfirm = () => dom.getConfirmButton() && dom.getConfirmButton().click()
|
||||
|
||||
/*
|
||||
* Global function to click 'Cancel' button
|
||||
*/
|
||||
export const clickCancel = () => dom.getCancelButton() && dom.getCancelButton().click()
|
||||
@@ -0,0 +1,4 @@
|
||||
export function fire (...args) {
|
||||
const Swal = this
|
||||
return new Swal(...args)
|
||||
}
|
||||
27
web/App_Script/sweetalert2-9.10.9/src/staticMethods/mixin.js
Normal file
27
web/App_Script/sweetalert2-9.10.9/src/staticMethods/mixin.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Returns an extended version of `Swal` containing `params` as defaults.
|
||||
* Useful for reusing Swal configuration.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* Before:
|
||||
* const textPromptOptions = { input: 'text', showCancelButton: true }
|
||||
* const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
|
||||
* const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
|
||||
*
|
||||
* After:
|
||||
* const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
|
||||
* const {value: firstName} = await TextPrompt('What is your first name?')
|
||||
* const {value: lastName} = await TextPrompt('What is your last name?')
|
||||
*
|
||||
* @param mixinParams
|
||||
*/
|
||||
export function mixin (mixinParams) {
|
||||
class MixinSwal extends this {
|
||||
_main (params) {
|
||||
return super._main(Object.assign({}, mixinParams, params))
|
||||
}
|
||||
}
|
||||
|
||||
return MixinSwal
|
||||
}
|
||||
60
web/App_Script/sweetalert2-9.10.9/src/staticMethods/queue.js
Normal file
60
web/App_Script/sweetalert2-9.10.9/src/staticMethods/queue.js
Normal file
@@ -0,0 +1,60 @@
|
||||
import * as dom from '../utils/dom/index.js'
|
||||
|
||||
// private global state for the queue feature
|
||||
let currentSteps = []
|
||||
|
||||
/*
|
||||
* Global function for chaining sweetAlert popups
|
||||
*/
|
||||
export const queue = function (steps) {
|
||||
const Swal = this
|
||||
currentSteps = steps
|
||||
|
||||
const resetAndResolve = (resolve, value) => {
|
||||
currentSteps = []
|
||||
resolve(value)
|
||||
}
|
||||
|
||||
const queueResult = []
|
||||
return new Promise((resolve) => {
|
||||
(function step (i, callback) {
|
||||
if (i < currentSteps.length) {
|
||||
document.body.setAttribute('data-swal2-queue-step', i)
|
||||
Swal.fire(currentSteps[i]).then((result) => {
|
||||
if (typeof result.value !== 'undefined') {
|
||||
queueResult.push(result.value)
|
||||
step(i + 1, callback)
|
||||
} else {
|
||||
resetAndResolve(resolve, { dismiss: result.dismiss })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
resetAndResolve(resolve, { value: queueResult })
|
||||
}
|
||||
})(0)
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
* Global function for getting the index of current popup in queue
|
||||
*/
|
||||
export const getQueueStep = () => dom.getContainer() && dom.getContainer().getAttribute('data-queue-step')
|
||||
|
||||
/*
|
||||
* Global function for inserting a popup to the queue
|
||||
*/
|
||||
export const insertQueueStep = (step, index) => {
|
||||
if (index && index < currentSteps.length) {
|
||||
return currentSteps.splice(index, 0, step)
|
||||
}
|
||||
return currentSteps.push(step)
|
||||
}
|
||||
|
||||
/*
|
||||
* Global function for deleting a popup from the queue
|
||||
*/
|
||||
export const deleteQueueStep = (index) => {
|
||||
if (typeof currentSteps[index] !== 'undefined') {
|
||||
currentSteps.splice(index, 1)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import * as dom from '../utils/dom/index.js'
|
||||
import Swal from '../sweetalert2.js'
|
||||
import { swalClasses } from '../utils/classes.js'
|
||||
|
||||
/**
|
||||
* Show spinner instead of Confirm button
|
||||
*/
|
||||
const showLoading = () => {
|
||||
let popup = dom.getPopup()
|
||||
if (!popup) {
|
||||
Swal.fire()
|
||||
}
|
||||
popup = dom.getPopup()
|
||||
const actions = dom.getActions()
|
||||
const confirmButton = dom.getConfirmButton()
|
||||
|
||||
dom.show(actions)
|
||||
dom.show(confirmButton, 'inline-block')
|
||||
dom.addClass([popup, actions], swalClasses.loading)
|
||||
confirmButton.disabled = true
|
||||
|
||||
popup.setAttribute('data-loading', true)
|
||||
popup.setAttribute('aria-busy', true)
|
||||
popup.focus()
|
||||
}
|
||||
|
||||
export {
|
||||
showLoading,
|
||||
showLoading as enableLoading
|
||||
}
|
||||
63
web/App_Script/sweetalert2-9.10.9/src/staticMethods/timer.js
Normal file
63
web/App_Script/sweetalert2-9.10.9/src/staticMethods/timer.js
Normal file
@@ -0,0 +1,63 @@
|
||||
import { animateTimerProgressBar, stopTimerProgressBar } from '../utils/dom/domUtils.js'
|
||||
import globalState from '../globalState.js'
|
||||
|
||||
/**
|
||||
* If `timer` parameter is set, returns number of milliseconds of timer remained.
|
||||
* Otherwise, returns undefined.
|
||||
*/
|
||||
export const getTimerLeft = () => {
|
||||
return globalState.timeout && globalState.timeout.getTimerLeft()
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop timer. Returns number of milliseconds of timer remained.
|
||||
* If `timer` parameter isn't set, returns undefined.
|
||||
*/
|
||||
export const stopTimer = () => {
|
||||
if (globalState.timeout) {
|
||||
stopTimerProgressBar()
|
||||
return globalState.timeout.stop()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume timer. Returns number of milliseconds of timer remained.
|
||||
* If `timer` parameter isn't set, returns undefined.
|
||||
*/
|
||||
export const resumeTimer = () => {
|
||||
if (globalState.timeout) {
|
||||
const remaining = globalState.timeout.start()
|
||||
animateTimerProgressBar(remaining)
|
||||
return remaining
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume timer. Returns number of milliseconds of timer remained.
|
||||
* If `timer` parameter isn't set, returns undefined.
|
||||
*/
|
||||
export const toggleTimer = () => {
|
||||
const timer = globalState.timeout
|
||||
return timer && (timer.running ? stopTimer() : resumeTimer())
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase timer. Returns number of milliseconds of an updated timer.
|
||||
* If `timer` parameter isn't set, returns undefined.
|
||||
*/
|
||||
export const increaseTimer = (n) => {
|
||||
if (globalState.timeout) {
|
||||
const remaining = globalState.timeout.increase(n)
|
||||
animateTimerProgressBar(remaining, true)
|
||||
return remaining
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if timer is running. Returns true if timer is running
|
||||
* or false if timer is paused or stopped.
|
||||
* If `timer` parameter isn't set, returns undefined
|
||||
*/
|
||||
export const isTimerRunning = () => {
|
||||
return globalState.timeout && globalState.timeout.isRunning()
|
||||
}
|
||||
Reference in New Issue
Block a user