vue-izitoast
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -1,1539 +0,1 @@ | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["vue-izitoast"] = factory(); | ||
else | ||
root["vue-izitoast"] = factory(); | ||
})(typeof self !== 'undefined' ? self : this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony export (immutable) */ __webpack_exports__["default"] = plugin; | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_izitoast__ = __webpack_require__(1); | ||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_izitoast___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_izitoast__); | ||
function plugin(Vue, options = {}) { | ||
if (options && options.constructor !== Object) throw 'Options must be a object'; | ||
const version = Vue.version && Number(Vue.version.split('.')[0]) || -1; | ||
if (false) { | ||
console.warn('already installed.'); | ||
return; | ||
} | ||
plugin.installed = true; | ||
if (false) { | ||
console.warn(`vue-izitoast (${plugin.version}) need to use Vue 2.0 or later (Vue: ${Vue.version}).`); | ||
return; | ||
} | ||
const defaultOptions = { | ||
zindex: 99999, | ||
layout: 1, | ||
balloon: false, | ||
close: true, | ||
closeOnEscape: false, | ||
rtl: false, | ||
position: 'bottomRight', | ||
timeout: 5000, | ||
animateInside: true, | ||
drag: true, | ||
pauseOnHover: true, | ||
resetOnHover: false, | ||
transitionIn: 'fadeInUp', | ||
transitionOut: 'fadeOut', | ||
transitionInMobile: 'fadeInUp', | ||
transitionOutMobile: 'fadeOutDown', | ||
buttons: {}, | ||
inputs: {}, | ||
onOpening: function () {}, | ||
onOpened: function () {}, | ||
onClosing: function () {}, | ||
onClosed: function () {} | ||
}; | ||
__WEBPACK_IMPORTED_MODULE_0_izitoast___default.a.settings(Object.assign({}, defaultOptions, options)); | ||
const toasts = new Vue({ | ||
_izi: __WEBPACK_IMPORTED_MODULE_0_izitoast___default.a, | ||
_checkParams(message, title, options) { | ||
if (!message || message.constructor !== String) throw 'Message must be a string'; | ||
if (title && title.constructor !== String) throw 'Title must be a string'; | ||
if (options && options.constructor !== Object) throw 'Options must be a object'; | ||
}, | ||
_checkEventNames(eventName) { | ||
if (!eventName || eventName.constructor !== String) throw 'Event Name must be a string'; | ||
if (eventName !== 'iziToast-open' && eventName !== 'iziToast-close') throw 'Event Name has only two possible values: iziToast-open or iziToast-close'; | ||
}, | ||
methods: { | ||
show(message, title = '', options = {}) { | ||
this.$options._checkParams(message, title, options); | ||
this.$options._izi.show(Object.assign({}, options, { message, title })); | ||
}, | ||
hide(toast = null, options = {}) { | ||
if (toast && toast.constructor !== String) toast = document.querySelector(toast); | ||
if (!toast || toast.constructor !== HTMLDivElement) toast = document.querySelector('.iziToast'); | ||
if (options && options.constructor !== Object) throw 'Options must be a object'; | ||
this.$options._izi.hide(options, toast); | ||
}, | ||
progress(toast, options = {}, callback = () => {}) { | ||
if (toast && toast.constructor !== String) toast = document.querySelector(toast); | ||
if (!toast || toast.constructor !== HTMLDivElement) toast = document.querySelector('.iziToast'); | ||
if (options && options.constructor !== Object) throw 'Options must be a object'; | ||
if (callback && callback.constructor !== Function) throw 'Callback must be a function'; | ||
return this.$options._izi.progress(toast, options, callback); | ||
}, | ||
destroy() { | ||
this.$options._izi.destroy(); | ||
}, | ||
info(message, title = '', options = {}) { | ||
this.$options._checkParams(message, title, options); | ||
this.$options._izi.info(Object.assign({}, options, { message, title })); | ||
}, | ||
success(message, title = '', options = {}) { | ||
this.$options._checkParams(message, title, options); | ||
this.$options._izi.success(Object.assign({}, options, { message, title })); | ||
}, | ||
warning(message, title = '', options = {}) { | ||
this.$options._checkParams(message, title, options); | ||
this.$options._izi.warning(Object.assign({}, options, { message, title })); | ||
}, | ||
error(message, title = '', options = {}) { | ||
this.$options._checkParams(message, title, options); | ||
this.$options._izi.error(Object.assign({}, options, { message, title })); | ||
}, | ||
question(message, title = '', options = {}) { | ||
this.$options._checkParams(message, title, options); | ||
this.$options._izi.question(Object.assign({}, options, { message, title })); | ||
}, | ||
on(eventName, callback) { | ||
this.$options._checkEventNames(eventName); | ||
if (!callback || callback.constructor !== Function) throw 'Callback must be a function'; | ||
document.addEventListener(eventName, callback); | ||
}, | ||
off(eventName) { | ||
this.$options._checkEventNames(eventName); | ||
document.removeEventListener(eventName); | ||
} | ||
} | ||
}); | ||
Object.defineProperty(Vue.prototype, '$toast', { | ||
get() { | ||
return toasts; | ||
} | ||
}); | ||
} | ||
if (typeof window !== 'undefined' && window.Vue) { | ||
window.Vue.use(plugin); | ||
} | ||
/***/ }), | ||
/* 1 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/* WEBPACK VAR INJECTION */(function(global) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/* | ||
* iziToast | v1.4.0 | ||
* http://izitoast.marcelodolce.com | ||
* by Marcelo Dolce. | ||
*/ | ||
(function (root, factory) { | ||
if(true) { | ||
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory(root)), | ||
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? | ||
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), | ||
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); | ||
} else if(typeof exports === 'object') { | ||
module.exports = factory(root); | ||
} else { | ||
root.iziToast = factory(root); | ||
} | ||
})(typeof global !== 'undefined' ? global : window || this.window || this.global, function (root) { | ||
'use strict'; | ||
// | ||
// Variables | ||
// | ||
var $iziToast = {}, | ||
PLUGIN_NAME = 'iziToast', | ||
BODY = document.querySelector('body'), | ||
ISMOBILE = (/Mobi/.test(navigator.userAgent)) ? true : false, | ||
ISCHROME = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor), | ||
ISFIREFOX = typeof InstallTrigger !== 'undefined', | ||
ACCEPTSTOUCH = 'ontouchstart' in document.documentElement, | ||
POSITIONS = ['bottomRight','bottomLeft','bottomCenter','topRight','topLeft','topCenter','center'], | ||
THEMES = { | ||
info: { | ||
color: 'blue', | ||
icon: 'ico-info' | ||
}, | ||
success: { | ||
color: 'green', | ||
icon: 'ico-success' | ||
}, | ||
warning: { | ||
color: 'orange', | ||
icon: 'ico-warning' | ||
}, | ||
error: { | ||
color: 'red', | ||
icon: 'ico-error' | ||
}, | ||
question: { | ||
color: 'yellow', | ||
icon: 'ico-question' | ||
} | ||
}, | ||
MOBILEWIDTH = 568, | ||
CONFIG = {}; | ||
$iziToast.children = {}; | ||
// Default settings | ||
var defaults = { | ||
id: null, | ||
class: '', | ||
title: '', | ||
titleColor: '', | ||
titleSize: '', | ||
titleLineHeight: '', | ||
message: '', | ||
messageColor: '', | ||
messageSize: '', | ||
messageLineHeight: '', | ||
backgroundColor: '', | ||
theme: 'light', // dark | ||
color: '', // blue, red, green, yellow | ||
icon: '', | ||
iconText: '', | ||
iconColor: '', | ||
iconUrl: null, | ||
image: '', | ||
imageWidth: 50, | ||
maxWidth: null, | ||
zindex: null, | ||
layout: 1, | ||
balloon: false, | ||
close: true, | ||
closeOnEscape: false, | ||
closeOnClick: false, | ||
displayMode: 0, | ||
position: 'bottomRight', // bottomRight, bottomLeft, topRight, topLeft, topCenter, bottomCenter, center | ||
target: '', | ||
targetFirst: true, | ||
timeout: 5000, | ||
rtl: false, | ||
animateInside: true, | ||
drag: true, | ||
pauseOnHover: true, | ||
resetOnHover: false, | ||
progressBar: true, | ||
progressBarColor: '', | ||
progressBarEasing: 'linear', | ||
overlay: false, | ||
overlayClose: false, | ||
overlayColor: 'rgba(0, 0, 0, 0.6)', | ||
transitionIn: 'fadeInUp', // bounceInLeft, bounceInRight, bounceInUp, bounceInDown, fadeIn, fadeInDown, fadeInUp, fadeInLeft, fadeInRight, flipInX | ||
transitionOut: 'fadeOut', // fadeOut, fadeOutUp, fadeOutDown, fadeOutLeft, fadeOutRight, flipOutX | ||
transitionInMobile: 'fadeInUp', | ||
transitionOutMobile: 'fadeOutDown', | ||
buttons: {}, | ||
inputs: {}, | ||
onOpening: function () {}, | ||
onOpened: function () {}, | ||
onClosing: function () {}, | ||
onClosed: function () {} | ||
}; | ||
// | ||
// Methods | ||
// | ||
/** | ||
* Polyfill for remove() method | ||
*/ | ||
if(!('remove' in Element.prototype)) { | ||
Element.prototype.remove = function() { | ||
if(this.parentNode) { | ||
this.parentNode.removeChild(this); | ||
} | ||
}; | ||
} | ||
/* | ||
* Polyfill for CustomEvent for IE >= 9 | ||
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill | ||
*/ | ||
if(typeof window.CustomEvent !== 'function') { | ||
var CustomEventPolyfill = function (event, params) { | ||
params = params || { bubbles: false, cancelable: false, detail: undefined }; | ||
var evt = document.createEvent('CustomEvent'); | ||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); | ||
return evt; | ||
}; | ||
CustomEventPolyfill.prototype = window.Event.prototype; | ||
window.CustomEvent = CustomEventPolyfill; | ||
} | ||
/** | ||
* A simple forEach() implementation for Arrays, Objects and NodeLists | ||
* @private | ||
* @param {Array|Object|NodeList} collection Collection of items to iterate | ||
* @param {Function} callback Callback function for each iteration | ||
* @param {Array|Object|NodeList} scope Object/NodeList/Array that forEach is iterating over (aka `this`) | ||
*/ | ||
var forEach = function (collection, callback, scope) { | ||
if(Object.prototype.toString.call(collection) === '[object Object]') { | ||
for (var prop in collection) { | ||
if(Object.prototype.hasOwnProperty.call(collection, prop)) { | ||
callback.call(scope, collection[prop], prop, collection); | ||
} | ||
} | ||
} else { | ||
if(collection){ | ||
for (var i = 0, len = collection.length; i < len; i++) { | ||
callback.call(scope, collection[i], i, collection); | ||
} | ||
} | ||
} | ||
}; | ||
/** | ||
* Merge defaults with user options | ||
* @private | ||
* @param {Object} defaults Default settings | ||
* @param {Object} options User options | ||
* @returns {Object} Merged values of defaults and options | ||
*/ | ||
var extend = function (defaults, options) { | ||
var extended = {}; | ||
forEach(defaults, function (value, prop) { | ||
extended[prop] = defaults[prop]; | ||
}); | ||
forEach(options, function (value, prop) { | ||
extended[prop] = options[prop]; | ||
}); | ||
return extended; | ||
}; | ||
/** | ||
* Create a fragment DOM elements | ||
* @private | ||
*/ | ||
var createFragElem = function(htmlStr) { | ||
var frag = document.createDocumentFragment(), | ||
temp = document.createElement('div'); | ||
temp.innerHTML = htmlStr; | ||
while (temp.firstChild) { | ||
frag.appendChild(temp.firstChild); | ||
} | ||
return frag; | ||
}; | ||
/** | ||
* Generate new ID | ||
* @private | ||
*/ | ||
var generateId = function(params) { | ||
var newId = btoa(encodeURIComponent(params)); | ||
return newId.replace(/=/g, ""); | ||
}; | ||
/** | ||
* Check if is a color | ||
* @private | ||
*/ | ||
var isColor = function(color){ | ||
if( color.substring(0,1) == '#' || color.substring(0,3) == 'rgb' || color.substring(0,3) == 'hsl' ){ | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
}; | ||
/** | ||
* Check if is a Base64 string | ||
* @private | ||
*/ | ||
var isBase64 = function(str) { | ||
try { | ||
return btoa(atob(str)) == str; | ||
} catch (err) { | ||
return false; | ||
} | ||
}; | ||
/** | ||
* Drag method of toasts | ||
* @private | ||
*/ | ||
var drag = function() { | ||
return { | ||
move: function(toast, instance, settings, xpos) { | ||
var opacity, | ||
opacityRange = 0.3, | ||
distance = 180; | ||
if(xpos !== 0){ | ||
toast.classList.add(PLUGIN_NAME+'-dragged'); | ||
toast.style.transform = 'translateX('+xpos + 'px)'; | ||
if(xpos > 0){ | ||
opacity = (distance-xpos) / distance; | ||
if(opacity < opacityRange){ | ||
instance.hide(extend(settings, { transitionOut: 'fadeOutRight', transitionOutMobile: 'fadeOutRight' }), toast, 'drag'); | ||
} | ||
} else { | ||
opacity = (distance+xpos) / distance; | ||
if(opacity < opacityRange){ | ||
instance.hide(extend(settings, { transitionOut: 'fadeOutLeft', transitionOutMobile: 'fadeOutLeft' }), toast, 'drag'); | ||
} | ||
} | ||
toast.style.opacity = opacity; | ||
if(opacity < opacityRange){ | ||
if(ISCHROME || ISFIREFOX) | ||
toast.style.left = xpos+'px'; | ||
toast.parentNode.style.opacity = opacityRange; | ||
this.stopMoving(toast, null); | ||
} | ||
} | ||
}, | ||
startMoving: function(toast, instance, settings, e) { | ||
e = e || window.event; | ||
var posX = ((ACCEPTSTOUCH) ? e.touches[0].clientX : e.clientX), | ||
toastLeft = toast.style.transform.replace('px)', ''); | ||
toastLeft = toastLeft.replace('translateX(', ''); | ||
var offsetX = posX - toastLeft; | ||
if(settings.transitionIn){ | ||
toast.classList.remove(settings.transitionIn); | ||
} | ||
if(settings.transitionInMobile){ | ||
toast.classList.remove(settings.transitionInMobile); | ||
} | ||
toast.style.transition = ''; | ||
if(ACCEPTSTOUCH) { | ||
document.ontouchmove = function(e) { | ||
e.preventDefault(); | ||
e = e || window.event; | ||
var posX = e.touches[0].clientX, | ||
finalX = posX - offsetX; | ||
drag.move(toast, instance, settings, finalX); | ||
}; | ||
} else { | ||
document.onmousemove = function(e) { | ||
e.preventDefault(); | ||
e = e || window.event; | ||
var posX = e.clientX, | ||
finalX = posX - offsetX; | ||
drag.move(toast, instance, settings, finalX); | ||
}; | ||
} | ||
}, | ||
stopMoving: function(toast, e) { | ||
if(ACCEPTSTOUCH) { | ||
document.ontouchmove = function() {}; | ||
} else { | ||
document.onmousemove = function() {}; | ||
} | ||
toast.style.opacity = ''; | ||
toast.style.transform = ''; | ||
if(toast.classList.contains(PLUGIN_NAME+'-dragged')){ | ||
toast.classList.remove(PLUGIN_NAME+'-dragged'); | ||
toast.style.transition = 'transform 0.4s ease, opacity 0.4s ease'; | ||
setTimeout(function() { | ||
toast.style.transition = ''; | ||
}, 400); | ||
} | ||
} | ||
}; | ||
}(); | ||
$iziToast.setSetting = function (ref, option, value) { | ||
$iziToast.children[ref][option] = value; | ||
}; | ||
$iziToast.getSetting = function (ref, option) { | ||
return $iziToast.children[ref][option]; | ||
}; | ||
/** | ||
* Destroy the current initialization. | ||
* @public | ||
*/ | ||
$iziToast.destroy = function () { | ||
forEach(document.querySelectorAll('.'+PLUGIN_NAME+'-overlay'), function(element, index) { | ||
element.remove(); | ||
}); | ||
forEach(document.querySelectorAll('.'+PLUGIN_NAME+'-wrapper'), function(element, index) { | ||
element.remove(); | ||
}); | ||
forEach(document.querySelectorAll('.'+PLUGIN_NAME), function(element, index) { | ||
element.remove(); | ||
}); | ||
this.children = {}; | ||
// Remove event listeners | ||
document.removeEventListener(PLUGIN_NAME+'-opened', {}, false); | ||
document.removeEventListener(PLUGIN_NAME+'-opening', {}, false); | ||
document.removeEventListener(PLUGIN_NAME+'-closing', {}, false); | ||
document.removeEventListener(PLUGIN_NAME+'-closed', {}, false); | ||
document.removeEventListener('keyup', {}, false); | ||
// Reset variables | ||
CONFIG = {}; | ||
}; | ||
/** | ||
* Initialize Plugin | ||
* @public | ||
* @param {Object} options User settings | ||
*/ | ||
$iziToast.settings = function (options) { | ||
// Destroy any existing initializations | ||
$iziToast.destroy(); | ||
CONFIG = options; | ||
defaults = extend(defaults, options || {}); | ||
}; | ||
/** | ||
* Building themes functions. | ||
* @public | ||
* @param {Object} options User settings | ||
*/ | ||
forEach(THEMES, function (theme, name) { | ||
$iziToast[name] = function (options) { | ||
var settings = extend(CONFIG, options || {}); | ||
settings = extend(theme, settings || {}); | ||
this.show(settings); | ||
}; | ||
}); | ||
/** | ||
* Do the calculation to move the progress bar | ||
* @private | ||
*/ | ||
$iziToast.progress = function (options, $toast, callback) { | ||
var that = this, | ||
ref = $toast.getAttribute('data-iziToast-ref'), | ||
settings = extend(this.children[ref], options || {}), | ||
$elem = $toast.querySelector('.'+PLUGIN_NAME+'-progressbar div'); | ||
return { | ||
start: function() { | ||
if(typeof settings.time.REMAINING == 'undefined'){ | ||
$toast.classList.remove(PLUGIN_NAME+'-reseted'); | ||
if($elem !== null){ | ||
$elem.style.transition = 'width '+ settings.timeout +'ms '+settings.progressBarEasing; | ||
$elem.style.width = '0%'; | ||
} | ||
settings.time.START = new Date().getTime(); | ||
settings.time.END = settings.time.START + settings.timeout; | ||
settings.time.TIMER = setTimeout(function() { | ||
clearTimeout(settings.time.TIMER); | ||
if(!$toast.classList.contains(PLUGIN_NAME+'-closing')){ | ||
that.hide(settings, $toast, 'timeout'); | ||
if(typeof callback === 'function'){ | ||
callback.apply(that); | ||
} | ||
} | ||
}, settings.timeout); | ||
that.setSetting(ref, 'time', settings.time); | ||
} | ||
}, | ||
pause: function() { | ||
if(typeof settings.time.START !== 'undefined' && !$toast.classList.contains(PLUGIN_NAME+'-paused') && !$toast.classList.contains(PLUGIN_NAME+'-reseted')){ | ||
$toast.classList.add(PLUGIN_NAME+'-paused'); | ||
settings.time.REMAINING = settings.time.END - new Date().getTime(); | ||
clearTimeout(settings.time.TIMER); | ||
that.setSetting(ref, 'time', settings.time); | ||
if($elem !== null){ | ||
var computedStyle = window.getComputedStyle($elem), | ||
propertyWidth = computedStyle.getPropertyValue('width'); | ||
$elem.style.transition = 'none'; | ||
$elem.style.width = propertyWidth; | ||
} | ||
if(typeof callback === 'function'){ | ||
setTimeout(function() { | ||
callback.apply(that); | ||
}, 10); | ||
} | ||
} | ||
}, | ||
resume: function() { | ||
if(typeof settings.time.REMAINING !== 'undefined'){ | ||
$toast.classList.remove(PLUGIN_NAME+'-paused'); | ||
if($elem !== null){ | ||
$elem.style.transition = 'width '+ settings.time.REMAINING +'ms '+settings.progressBarEasing; | ||
$elem.style.width = '0%'; | ||
} | ||
settings.time.END = new Date().getTime() + settings.time.REMAINING; | ||
settings.time.TIMER = setTimeout(function() { | ||
clearTimeout(settings.time.TIMER); | ||
if(!$toast.classList.contains(PLUGIN_NAME+'-closing')){ | ||
that.hide(settings, $toast, 'timeout'); | ||
if(typeof callback === 'function'){ | ||
callback.apply(that); | ||
} | ||
} | ||
}, settings.time.REMAINING); | ||
that.setSetting(ref, 'time', settings.time); | ||
} else { | ||
this.start(); | ||
} | ||
}, | ||
reset: function(){ | ||
clearTimeout(settings.time.TIMER); | ||
delete settings.time.REMAINING; | ||
that.setSetting(ref, 'time', settings.time); | ||
$toast.classList.add(PLUGIN_NAME+'-reseted'); | ||
$toast.classList.remove(PLUGIN_NAME+'-paused'); | ||
if($elem !== null){ | ||
$elem.style.transition = 'none'; | ||
$elem.style.width = '100%'; | ||
} | ||
if(typeof callback === 'function'){ | ||
setTimeout(function() { | ||
callback.apply(that); | ||
}, 10); | ||
} | ||
} | ||
}; | ||
}; | ||
/** | ||
* Close the specific Toast | ||
* @public | ||
* @param {Object} options User settings | ||
*/ | ||
$iziToast.hide = function (options, $toast, closedBy) { | ||
if(typeof $toast != 'object'){ | ||
$toast = document.querySelector($toast); | ||
} | ||
var that = this, | ||
settings = extend(this.children[$toast.getAttribute('data-iziToast-ref')], options || {}); | ||
settings.closedBy = closedBy || null; | ||
delete settings.time.REMAINING; | ||
$toast.classList.add(PLUGIN_NAME+'-closing'); | ||
// Overlay | ||
(function(){ | ||
var $overlay = document.querySelector('.'+PLUGIN_NAME+'-overlay'); | ||
if($overlay !== null){ | ||
var refs = $overlay.getAttribute('data-iziToast-ref'); | ||
refs = refs.split(','); | ||
var index = refs.indexOf(String(settings.ref)); | ||
if(index !== -1){ | ||
refs.splice(index, 1); | ||
} | ||
$overlay.setAttribute('data-iziToast-ref', refs.join()); | ||
if(refs.length === 0){ | ||
$overlay.classList.remove('fadeIn'); | ||
$overlay.classList.add('fadeOut'); | ||
setTimeout(function() { | ||
$overlay.remove(); | ||
}, 700); | ||
} | ||
} | ||
})(); | ||
if(settings.transitionIn){ | ||
$toast.classList.remove(settings.transitionIn); | ||
} | ||
if(settings.transitionInMobile){ | ||
$toast.classList.remove(settings.transitionInMobile); | ||
} | ||
if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){ | ||
if(settings.transitionOutMobile) | ||
$toast.classList.add(settings.transitionOutMobile); | ||
} else { | ||
if(settings.transitionOut) | ||
$toast.classList.add(settings.transitionOut); | ||
} | ||
var H = $toast.parentNode.offsetHeight; | ||
$toast.parentNode.style.height = H+'px'; | ||
$toast.style.pointerEvents = 'none'; | ||
if(!ISMOBILE || window.innerWidth > MOBILEWIDTH){ | ||
$toast.parentNode.style.transitionDelay = '0.2s'; | ||
} | ||
try { | ||
var event = new CustomEvent(PLUGIN_NAME+'-closing', {detail: settings, bubbles: true, cancelable: true}); | ||
document.dispatchEvent(event); | ||
} catch(ex){ | ||
console.warn(ex); | ||
} | ||
setTimeout(function() { | ||
$toast.parentNode.style.height = '0px'; | ||
$toast.parentNode.style.overflow = ''; | ||
setTimeout(function(){ | ||
delete that.children[settings.ref]; | ||
$toast.parentNode.remove(); | ||
try { | ||
var event = new CustomEvent(PLUGIN_NAME+'-closed', {detail: settings, bubbles: true, cancelable: true}); | ||
document.dispatchEvent(event); | ||
} catch(ex){ | ||
console.warn(ex); | ||
} | ||
if(typeof settings.onClosed !== 'undefined'){ | ||
settings.onClosed.apply(null, [settings, $toast, closedBy]); | ||
} | ||
}, 1000); | ||
}, 200); | ||
if(typeof settings.onClosing !== 'undefined'){ | ||
settings.onClosing.apply(null, [settings, $toast, closedBy]); | ||
} | ||
}; | ||
/** | ||
* Create and show the Toast | ||
* @public | ||
* @param {Object} options User settings | ||
*/ | ||
$iziToast.show = function (options) { | ||
var that = this; | ||
// Merge user options with defaults | ||
var settings = extend(CONFIG, options || {}); | ||
settings = extend(defaults, settings); | ||
settings.time = {}; | ||
if(settings.id === null){ | ||
settings.id = generateId(settings.title+settings.message+settings.color); | ||
} | ||
if(settings.displayMode === 1 || settings.displayMode == 'once'){ | ||
try { | ||
if(document.querySelectorAll('.'+PLUGIN_NAME+'#'+settings.id).length > 0){ | ||
return false; | ||
} | ||
} catch (exc) { | ||
console.warn('['+PLUGIN_NAME+'] Could not find an element with this selector: '+'#'+settings.id+'. Try to set an valid id.'); | ||
} | ||
} | ||
if(settings.displayMode === 2 || settings.displayMode == 'replace'){ | ||
try { | ||
forEach(document.querySelectorAll('.'+PLUGIN_NAME+'#'+settings.id), function(element, index) { | ||
that.hide(settings, element, 'replaced'); | ||
}); | ||
} catch (exc) { | ||
console.warn('['+PLUGIN_NAME+'] Could not find an element with this selector: '+'#'+settings.id+'. Try to set an valid id.'); | ||
} | ||
} | ||
settings.ref = new Date().getTime() + Math.floor((Math.random() * 10000000) + 1); | ||
$iziToast.children[settings.ref] = settings; | ||
var $DOM = { | ||
body: document.querySelector('body'), | ||
overlay: document.createElement('div'), | ||
toast: document.createElement('div'), | ||
toastBody: document.createElement('div'), | ||
toastTexts: document.createElement('div'), | ||
toastCapsule: document.createElement('div'), | ||
cover: document.createElement('div'), | ||
buttons: document.createElement('div'), | ||
inputs: document.createElement('div'), | ||
icon: !settings.iconUrl ? document.createElement('i') : document.createElement('img'), | ||
wrapper: null | ||
}; | ||
$DOM.toast.setAttribute('data-iziToast-ref', settings.ref); | ||
$DOM.toast.appendChild($DOM.toastBody); | ||
$DOM.toastCapsule.appendChild($DOM.toast); | ||
// CSS Settings | ||
(function(){ | ||
$DOM.toast.classList.add(PLUGIN_NAME); | ||
$DOM.toast.classList.add(PLUGIN_NAME+'-opening'); | ||
$DOM.toastCapsule.classList.add(PLUGIN_NAME+'-capsule'); | ||
$DOM.toastBody.classList.add(PLUGIN_NAME + '-body'); | ||
$DOM.toastTexts.classList.add(PLUGIN_NAME + '-texts'); | ||
if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){ | ||
if(settings.transitionInMobile) | ||
$DOM.toast.classList.add(settings.transitionInMobile); | ||
} else { | ||
if(settings.transitionIn) | ||
$DOM.toast.classList.add(settings.transitionIn); | ||
} | ||
if(settings.class){ | ||
var classes = settings.class.split(' '); | ||
forEach(classes, function (value, index) { | ||
$DOM.toast.classList.add(value); | ||
}); | ||
} | ||
if(settings.id){ $DOM.toast.id = settings.id; } | ||
if(settings.rtl){ | ||
$DOM.toast.classList.add(PLUGIN_NAME + '-rtl'); | ||
$DOM.toast.setAttribute('dir', 'rtl'); | ||
} | ||
if(settings.layout > 1){ $DOM.toast.classList.add(PLUGIN_NAME+'-layout'+settings.layout); } | ||
if(settings.balloon){ $DOM.toast.classList.add(PLUGIN_NAME+'-balloon'); } | ||
if(settings.maxWidth){ | ||
if( !isNaN(settings.maxWidth) ){ | ||
$DOM.toast.style.maxWidth = settings.maxWidth+'px'; | ||
} else { | ||
$DOM.toast.style.maxWidth = settings.maxWidth; | ||
} | ||
} | ||
if(settings.theme !== '' || settings.theme !== 'light') { | ||
$DOM.toast.classList.add(PLUGIN_NAME+'-theme-'+settings.theme); | ||
} | ||
if(settings.color) { //#, rgb, rgba, hsl | ||
if( isColor(settings.color) ){ | ||
$DOM.toast.style.background = settings.color; | ||
} else { | ||
$DOM.toast.classList.add(PLUGIN_NAME+'-color-'+settings.color); | ||
} | ||
} | ||
if(settings.backgroundColor) { | ||
$DOM.toast.style.background = settings.backgroundColor; | ||
if(settings.balloon){ | ||
$DOM.toast.style.borderColor = settings.backgroundColor; | ||
} | ||
} | ||
})(); | ||
// Cover image | ||
(function(){ | ||
if(settings.image) { | ||
$DOM.cover.classList.add(PLUGIN_NAME + '-cover'); | ||
$DOM.cover.style.width = settings.imageWidth + 'px'; | ||
if(isBase64(settings.image.replace(/ /g,''))){ | ||
$DOM.cover.style.backgroundImage = 'url(data:image/png;base64,' + settings.image.replace(/ /g,'') + ')'; | ||
} else { | ||
$DOM.cover.style.backgroundImage = 'url(' + settings.image + ')'; | ||
} | ||
if(settings.rtl){ | ||
$DOM.toastBody.style.marginRight = (settings.imageWidth + 10) + 'px'; | ||
} else { | ||
$DOM.toastBody.style.marginLeft = (settings.imageWidth + 10) + 'px'; | ||
} | ||
$DOM.toast.appendChild($DOM.cover); | ||
} | ||
})(); | ||
// Button close | ||
(function(){ | ||
if(settings.close){ | ||
$DOM.buttonClose = document.createElement('button'); | ||
$DOM.buttonClose.type = 'button'; | ||
$DOM.buttonClose.classList.add(PLUGIN_NAME + '-close'); | ||
$DOM.buttonClose.addEventListener('click', function (e) { | ||
var button = e.target; | ||
that.hide(settings, $DOM.toast, 'button'); | ||
}); | ||
$DOM.toast.appendChild($DOM.buttonClose); | ||
} else { | ||
if(settings.rtl){ | ||
$DOM.toast.style.paddingLeft = '18px'; | ||
} else { | ||
$DOM.toast.style.paddingRight = '18px'; | ||
} | ||
} | ||
})(); | ||
// Progress Bar & Timeout | ||
(function(){ | ||
if(settings.progressBar){ | ||
$DOM.progressBar = document.createElement('div'); | ||
$DOM.progressBarDiv = document.createElement('div'); | ||
$DOM.progressBar.classList.add(PLUGIN_NAME + '-progressbar'); | ||
$DOM.progressBarDiv.style.background = settings.progressBarColor; | ||
$DOM.progressBar.appendChild($DOM.progressBarDiv); | ||
$DOM.toast.appendChild($DOM.progressBar); | ||
} | ||
if(settings.timeout) { | ||
if(settings.pauseOnHover && !settings.resetOnHover){ | ||
$DOM.toast.addEventListener('mouseenter', function (e) { | ||
that.progress(settings, $DOM.toast).pause(); | ||
}); | ||
$DOM.toast.addEventListener('mouseleave', function (e) { | ||
that.progress(settings, $DOM.toast).resume(); | ||
}); | ||
} | ||
if(settings.resetOnHover){ | ||
$DOM.toast.addEventListener('mouseenter', function (e) { | ||
that.progress(settings, $DOM.toast).reset(); | ||
}); | ||
$DOM.toast.addEventListener('mouseleave', function (e) { | ||
that.progress(settings, $DOM.toast).start(); | ||
}); | ||
} | ||
} | ||
})(); | ||
// Icon | ||
(function(){ | ||
if(settings.iconUrl) { | ||
$DOM.icon.setAttribute('class', PLUGIN_NAME + '-icon'); | ||
$DOM.icon.setAttribute('src', settings.iconUrl); | ||
} else if(settings.icon) { | ||
$DOM.icon.setAttribute('class', PLUGIN_NAME + '-icon ' + settings.icon); | ||
if(settings.iconText){ | ||
$DOM.icon.appendChild(document.createTextNode(settings.iconText)); | ||
} | ||
if(settings.iconColor){ | ||
$DOM.icon.style.color = settings.iconColor; | ||
} | ||
} | ||
if(settings.icon || settings.iconUrl) { | ||
if(settings.rtl){ | ||
$DOM.toastBody.style.paddingRight = '33px'; | ||
} else { | ||
$DOM.toastBody.style.paddingLeft = '33px'; | ||
} | ||
$DOM.toastBody.appendChild($DOM.icon); | ||
} | ||
})(); | ||
// Title & Message | ||
(function(){ | ||
if(settings.title.length > 0) { | ||
$DOM.strong = document.createElement('strong'); | ||
$DOM.strong.classList.add(PLUGIN_NAME + '-title'); | ||
$DOM.strong.appendChild(createFragElem(settings.title)); | ||
$DOM.toastTexts.appendChild($DOM.strong); | ||
if(settings.titleColor) { | ||
$DOM.strong.style.color = settings.titleColor; | ||
} | ||
if(settings.titleSize) { | ||
if( !isNaN(settings.titleSize) ){ | ||
$DOM.strong.style.fontSize = settings.titleSize+'px'; | ||
} else { | ||
$DOM.strong.style.fontSize = settings.titleSize; | ||
} | ||
} | ||
if(settings.titleLineHeight) { | ||
if( !isNaN(settings.titleSize) ){ | ||
$DOM.strong.style.lineHeight = settings.titleLineHeight+'px'; | ||
} else { | ||
$DOM.strong.style.lineHeight = settings.titleLineHeight; | ||
} | ||
} | ||
} | ||
if(settings.message.length > 0) { | ||
$DOM.p = document.createElement('p'); | ||
$DOM.p.classList.add(PLUGIN_NAME + '-message'); | ||
$DOM.p.appendChild(createFragElem(settings.message)); | ||
$DOM.toastTexts.appendChild($DOM.p); | ||
if(settings.messageColor) { | ||
$DOM.p.style.color = settings.messageColor; | ||
} | ||
if(settings.messageSize) { | ||
if( !isNaN(settings.titleSize) ){ | ||
$DOM.p.style.fontSize = settings.messageSize+'px'; | ||
} else { | ||
$DOM.p.style.fontSize = settings.messageSize; | ||
} | ||
} | ||
if(settings.messageLineHeight) { | ||
if( !isNaN(settings.titleSize) ){ | ||
$DOM.p.style.lineHeight = settings.messageLineHeight+'px'; | ||
} else { | ||
$DOM.p.style.lineHeight = settings.messageLineHeight; | ||
} | ||
} | ||
} | ||
if(settings.title.length > 0 && settings.message.length > 0) { | ||
if(settings.rtl){ | ||
$DOM.strong.style.marginLeft = '10px'; | ||
} else if(settings.layout !== 2 && !settings.rtl) { | ||
$DOM.strong.style.marginRight = '10px'; | ||
} | ||
} | ||
})(); | ||
$DOM.toastBody.appendChild($DOM.toastTexts); | ||
// Inputs | ||
var $inputs; | ||
(function(){ | ||
if(settings.inputs.length > 0) { | ||
$DOM.inputs.classList.add(PLUGIN_NAME + '-inputs'); | ||
forEach(settings.inputs, function (value, index) { | ||
$DOM.inputs.appendChild(createFragElem(value[0])); | ||
$inputs = $DOM.inputs.childNodes; | ||
$inputs[index].classList.add(PLUGIN_NAME + '-inputs-child'); | ||
if(value[3]){ | ||
setTimeout(function() { | ||
$inputs[index].focus(); | ||
}, 300); | ||
} | ||
$inputs[index].addEventListener(value[1], function (e) { | ||
var ts = value[2]; | ||
return ts(that, $DOM.toast, this, e); | ||
}); | ||
}); | ||
$DOM.toastBody.appendChild($DOM.inputs); | ||
} | ||
})(); | ||
// Buttons | ||
(function(){ | ||
if(settings.buttons.length > 0) { | ||
$DOM.buttons.classList.add(PLUGIN_NAME + '-buttons'); | ||
forEach(settings.buttons, function (value, index) { | ||
$DOM.buttons.appendChild(createFragElem(value[0])); | ||
var $btns = $DOM.buttons.childNodes; | ||
$btns[index].classList.add(PLUGIN_NAME + '-buttons-child'); | ||
if(value[2]){ | ||
setTimeout(function() { | ||
$btns[index].focus(); | ||
}, 300); | ||
} | ||
$btns[index].addEventListener('click', function (e) { | ||
e.preventDefault(); | ||
var ts = value[1]; | ||
return ts(that, $DOM.toast, this, e, $inputs); | ||
}); | ||
}); | ||
} | ||
$DOM.toastBody.appendChild($DOM.buttons); | ||
})(); | ||
if(settings.message.length > 0 && (settings.inputs.length > 0 || settings.buttons.length > 0)) { | ||
$DOM.p.style.marginBottom = '0'; | ||
} | ||
if(settings.inputs.length > 0 || settings.buttons.length > 0){ | ||
if(settings.rtl){ | ||
$DOM.toastTexts.style.marginLeft = '10px'; | ||
} else { | ||
$DOM.toastTexts.style.marginRight = '10px'; | ||
} | ||
if(settings.inputs.length > 0 && settings.buttons.length > 0){ | ||
if(settings.rtl){ | ||
$DOM.inputs.style.marginLeft = '8px'; | ||
} else { | ||
$DOM.inputs.style.marginRight = '8px'; | ||
} | ||
} | ||
} | ||
// Wrap | ||
(function(){ | ||
$DOM.toastCapsule.style.visibility = 'hidden'; | ||
setTimeout(function() { | ||
var H = $DOM.toast.offsetHeight; | ||
var style = $DOM.toast.currentStyle || window.getComputedStyle($DOM.toast); | ||
var marginTop = style.marginTop; | ||
marginTop = marginTop.split('px'); | ||
marginTop = parseInt(marginTop[0]); | ||
var marginBottom = style.marginBottom; | ||
marginBottom = marginBottom.split('px'); | ||
marginBottom = parseInt(marginBottom[0]); | ||
$DOM.toastCapsule.style.visibility = ''; | ||
$DOM.toastCapsule.style.height = (H+marginBottom+marginTop)+'px'; | ||
setTimeout(function() { | ||
$DOM.toastCapsule.style.height = 'auto'; | ||
if(settings.target){ | ||
$DOM.toastCapsule.style.overflow = 'visible'; | ||
} | ||
}, 500); | ||
if(settings.timeout) { | ||
that.progress(settings, $DOM.toast).start(); | ||
} | ||
}, 100); | ||
})(); | ||
// Target | ||
(function(){ | ||
var position = settings.position; | ||
if(settings.target){ | ||
$DOM.wrapper = document.querySelector(settings.target); | ||
$DOM.wrapper.classList.add(PLUGIN_NAME + '-target'); | ||
if(settings.targetFirst) { | ||
$DOM.wrapper.insertBefore($DOM.toastCapsule, $DOM.wrapper.firstChild); | ||
} else { | ||
$DOM.wrapper.appendChild($DOM.toastCapsule); | ||
} | ||
} else { | ||
if( POSITIONS.indexOf(settings.position) == -1 ){ | ||
console.warn('['+PLUGIN_NAME+'] Incorrect position.\nIt can be › ' + POSITIONS); | ||
return; | ||
} | ||
if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){ | ||
if(settings.position == 'bottomLeft' || settings.position == 'bottomRight' || settings.position == 'bottomCenter'){ | ||
position = PLUGIN_NAME+'-wrapper-bottomCenter'; | ||
} | ||
else if(settings.position == 'topLeft' || settings.position == 'topRight' || settings.position == 'topCenter'){ | ||
position = PLUGIN_NAME+'-wrapper-topCenter'; | ||
} | ||
else { | ||
position = PLUGIN_NAME+'-wrapper-center'; | ||
} | ||
} else { | ||
position = PLUGIN_NAME+'-wrapper-'+position; | ||
} | ||
$DOM.wrapper = document.querySelector('.' + PLUGIN_NAME + '-wrapper.'+position); | ||
if(!$DOM.wrapper) { | ||
$DOM.wrapper = document.createElement('div'); | ||
$DOM.wrapper.classList.add(PLUGIN_NAME + '-wrapper'); | ||
$DOM.wrapper.classList.add(position); | ||
document.body.appendChild($DOM.wrapper); | ||
} | ||
if(settings.position == 'topLeft' || settings.position == 'topCenter' || settings.position == 'topRight'){ | ||
$DOM.wrapper.insertBefore($DOM.toastCapsule, $DOM.wrapper.firstChild); | ||
} else { | ||
$DOM.wrapper.appendChild($DOM.toastCapsule); | ||
} | ||
} | ||
if(!isNaN(settings.zindex)) { | ||
$DOM.wrapper.style.zIndex = settings.zindex; | ||
} else { | ||
console.warn('['+PLUGIN_NAME+'] Invalid zIndex.'); | ||
} | ||
})(); | ||
// Overlay | ||
(function(){ | ||
if(settings.overlay) { | ||
if( document.querySelector('.'+PLUGIN_NAME+'-overlay.fadeIn') !== null ){ | ||
$DOM.overlay = document.querySelector('.'+PLUGIN_NAME+'-overlay'); | ||
$DOM.overlay.setAttribute('data-iziToast-ref', $DOM.overlay.getAttribute('data-iziToast-ref') + ',' + settings.ref); | ||
if(!isNaN(settings.zindex) && settings.zindex !== null) { | ||
$DOM.overlay.style.zIndex = settings.zindex-1; | ||
} | ||
} else { | ||
$DOM.overlay.classList.add(PLUGIN_NAME+'-overlay'); | ||
$DOM.overlay.classList.add('fadeIn'); | ||
$DOM.overlay.style.background = settings.overlayColor; | ||
$DOM.overlay.setAttribute('data-iziToast-ref', settings.ref); | ||
if(!isNaN(settings.zindex) && settings.zindex !== null) { | ||
$DOM.overlay.style.zIndex = settings.zindex-1; | ||
} | ||
document.querySelector('body').appendChild($DOM.overlay); | ||
} | ||
if(settings.overlayClose) { | ||
$DOM.overlay.removeEventListener('click', {}); | ||
$DOM.overlay.addEventListener('click', function (e) { | ||
that.hide(settings, $DOM.toast, 'overlay'); | ||
}); | ||
} else { | ||
$DOM.overlay.removeEventListener('click', {}); | ||
} | ||
} | ||
})(); | ||
// Inside animations | ||
(function(){ | ||
if(settings.animateInside){ | ||
$DOM.toast.classList.add(PLUGIN_NAME+'-animateInside'); | ||
var animationTimes = [200, 100, 300]; | ||
if(settings.transitionIn == 'bounceInLeft' || settings.transitionIn == 'bounceInRight'){ | ||
animationTimes = [400, 200, 400]; | ||
} | ||
if(settings.title.length > 0) { | ||
setTimeout(function(){ | ||
$DOM.strong.classList.add('slideIn'); | ||
}, animationTimes[0]); | ||
} | ||
if(settings.message.length > 0) { | ||
setTimeout(function(){ | ||
$DOM.p.classList.add('slideIn'); | ||
}, animationTimes[1]); | ||
} | ||
if(settings.icon || settings.iconUrl) { | ||
setTimeout(function(){ | ||
$DOM.icon.classList.add('revealIn'); | ||
}, animationTimes[2]); | ||
} | ||
var counter = 150; | ||
if(settings.buttons.length > 0 && $DOM.buttons) { | ||
setTimeout(function(){ | ||
forEach($DOM.buttons.childNodes, function(element, index) { | ||
setTimeout(function(){ | ||
element.classList.add('revealIn'); | ||
}, counter); | ||
counter = counter + 150; | ||
}); | ||
}, settings.inputs.length > 0 ? 150 : 0); | ||
} | ||
if(settings.inputs.length > 0 && $DOM.inputs) { | ||
counter = 150; | ||
forEach($DOM.inputs.childNodes, function(element, index) { | ||
setTimeout(function(){ | ||
element.classList.add('revealIn'); | ||
}, counter); | ||
counter = counter + 150; | ||
}); | ||
} | ||
} | ||
})(); | ||
settings.onOpening.apply(null, [settings, $DOM.toast]); | ||
try { | ||
var event = new CustomEvent(PLUGIN_NAME + '-opening', {detail: settings, bubbles: true, cancelable: true}); | ||
document.dispatchEvent(event); | ||
} catch(ex){ | ||
console.warn(ex); | ||
} | ||
setTimeout(function() { | ||
$DOM.toast.classList.remove(PLUGIN_NAME+'-opening'); | ||
$DOM.toast.classList.add(PLUGIN_NAME+'-opened'); | ||
try { | ||
var event = new CustomEvent(PLUGIN_NAME + '-opened', {detail: settings, bubbles: true, cancelable: true}); | ||
document.dispatchEvent(event); | ||
} catch(ex){ | ||
console.warn(ex); | ||
} | ||
settings.onOpened.apply(null, [settings, $DOM.toast]); | ||
}, 1000); | ||
if(settings.drag){ | ||
if(ACCEPTSTOUCH) { | ||
$DOM.toast.addEventListener('touchstart', function(e) { | ||
drag.startMoving(this, that, settings, e); | ||
}, false); | ||
$DOM.toast.addEventListener('touchend', function(e) { | ||
drag.stopMoving(this, e); | ||
}, false); | ||
} else { | ||
$DOM.toast.addEventListener('mousedown', function(e) { | ||
e.preventDefault(); | ||
drag.startMoving(this, that, settings, e); | ||
}, false); | ||
$DOM.toast.addEventListener('mouseup', function(e) { | ||
e.preventDefault(); | ||
drag.stopMoving(this, e); | ||
}, false); | ||
} | ||
} | ||
if(settings.closeOnEscape) { | ||
document.addEventListener('keyup', function (evt) { | ||
evt = evt || window.event; | ||
if(evt.keyCode == 27) { | ||
that.hide(settings, $DOM.toast, 'esc'); | ||
} | ||
}); | ||
} | ||
if(settings.closeOnClick) { | ||
$DOM.toast.addEventListener('click', function (evt) { | ||
that.hide(settings, $DOM.toast, 'toast'); | ||
}); | ||
} | ||
that.toast = $DOM.toast; | ||
}; | ||
return $iziToast; | ||
}); | ||
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) | ||
/***/ }), | ||
/* 2 */ | ||
/***/ (function(module, exports) { | ||
var g; | ||
// This works in non-strict mode | ||
g = (function() { | ||
return this; | ||
})(); | ||
try { | ||
// This works if eval is allowed (see CSP) | ||
g = g || Function("return this")() || (1,eval)("this"); | ||
} catch(e) { | ||
// This works if the window reference is available | ||
if(typeof window === "object") | ||
g = window; | ||
} | ||
// g can still be undefined, but nothing to do about it... | ||
// We return undefined, instead of nothing here, so it's | ||
// easier to handle this case. if(!global) { ...} | ||
module.exports = g; | ||
/***/ }) | ||
/******/ ]); | ||
}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.VueIziToast=e():t.VueIziToast=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function i(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=t,i.c=e,i.d=function(t,e,o){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(i.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)i.d(o,n,function(e){return t[e]}.bind(null,n));return o},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=4)}([function(t,e){t.exports=function(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}},function(t,e){function i(t,e){for(var i=0;i<e.length;i++){var o=e[i];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}t.exports=function(t,e,o){return e&&i(t.prototype,e),o&&i(t,o),t}},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e,i){(function(i){var o,n,s;void 0!==i||window||this.window||this.global,n=[],o=function(t){"use strict";var e={},i=(document.querySelector("body"),!!/Mobi/.test(navigator.userAgent)),o=/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor),n="undefined"!=typeof InstallTrigger,s="ontouchstart"in document.documentElement,a=["bottomRight","bottomLeft","bottomCenter","topRight","topLeft","topCenter","center"],r={};e.children={};var l={id:null,class:"",title:"",titleColor:"",titleSize:"",titleLineHeight:"",message:"",messageColor:"",messageSize:"",messageLineHeight:"",backgroundColor:"",theme:"light",color:"",icon:"",iconText:"",iconColor:"",iconUrl:null,image:"",imageWidth:50,maxWidth:null,zindex:null,layout:1,balloon:!1,close:!0,closeOnEscape:!1,closeOnClick:!1,displayMode:0,position:"bottomRight",target:"",targetFirst:!0,timeout:5e3,rtl:!1,animateInside:!0,drag:!0,pauseOnHover:!0,resetOnHover:!1,progressBar:!0,progressBarColor:"",progressBarEasing:"linear",overlay:!1,overlayClose:!1,overlayColor:"rgba(0, 0, 0, 0.6)",transitionIn:"fadeInUp",transitionOut:"fadeOut",transitionInMobile:"fadeInUp",transitionOutMobile:"fadeOutDown",buttons:{},inputs:{},onOpening:function(){},onOpened:function(){},onClosing:function(){},onClosed:function(){}};if("remove"in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),"function"!=typeof window.CustomEvent){var c=function(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var i=document.createEvent("CustomEvent");return i.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),i};c.prototype=window.Event.prototype,window.CustomEvent=c}var u=function(t,e,i){if("[object Object]"===Object.prototype.toString.call(t))for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.call(i,t[o],o,t);else if(t)for(var n=0,s=t.length;n<s;n++)e.call(i,t[n],n,t)},d=function(t,e){var i={};return u(t,function(e,o){i[o]=t[o]}),u(e,function(t,o){i[o]=e[o]}),i},p=function(t){var e=document.createDocumentFragment(),i=document.createElement("div");for(i.innerHTML=t;i.firstChild;)e.appendChild(i.firstChild);return e},m={move:function(t,e,i,s){var a;0!==s&&(t.classList.add("iziToast-dragged"),t.style.transform="translateX("+s+"px)",s>0?(a=(180-s)/180)<.3&&e.hide(d(i,{transitionOut:"fadeOutRight",transitionOutMobile:"fadeOutRight"}),t,"drag"):(a=(180+s)/180)<.3&&e.hide(d(i,{transitionOut:"fadeOutLeft",transitionOutMobile:"fadeOutLeft"}),t,"drag"),t.style.opacity=a,a<.3&&((o||n)&&(t.style.left=s+"px"),t.parentNode.style.opacity=.3,this.stopMoving(t,null)))},startMoving:function(t,e,i,o){o=o||window.event;var n=s?o.touches[0].clientX:o.clientX,a=t.style.transform.replace("px)",""),r=n-(a=a.replace("translateX(",""));i.transitionIn&&t.classList.remove(i.transitionIn),i.transitionInMobile&&t.classList.remove(i.transitionInMobile),t.style.transition="",s?document.ontouchmove=function(o){o.preventDefault();var n=(o=o||window.event).touches[0].clientX-r;m.move(t,e,i,n)}:document.onmousemove=function(o){o.preventDefault();var n=(o=o||window.event).clientX-r;m.move(t,e,i,n)}},stopMoving:function(t,e){s?document.ontouchmove=function(){}:document.onmousemove=function(){},t.style.opacity="",t.style.transform="",t.classList.contains("iziToast-dragged")&&(t.classList.remove("iziToast-dragged"),t.style.transition="transform 0.4s ease, opacity 0.4s ease",setTimeout(function(){t.style.transition=""},400))}};return e.setSetting=function(t,i,o){e.children[t][i]=o},e.getSetting=function(t,i){return e.children[t][i]},e.destroy=function(){u(document.querySelectorAll(".iziToast-overlay"),function(t,e){t.remove()}),u(document.querySelectorAll(".iziToast-wrapper"),function(t,e){t.remove()}),u(document.querySelectorAll(".iziToast"),function(t,e){t.remove()}),this.children={},document.removeEventListener("iziToast-opened",{},!1),document.removeEventListener("iziToast-opening",{},!1),document.removeEventListener("iziToast-closing",{},!1),document.removeEventListener("iziToast-closed",{},!1),document.removeEventListener("keyup",{},!1),r={}},e.settings=function(t){e.destroy(),r=t,l=d(l,t||{})},u({info:{color:"blue",icon:"ico-info"},success:{color:"green",icon:"ico-success"},warning:{color:"orange",icon:"ico-warning"},error:{color:"red",icon:"ico-error"},question:{color:"yellow",icon:"ico-question"}},function(t,i){e[i]=function(e){var i=d(r,e||{});i=d(t,i||{}),this.show(i)}}),e.progress=function(t,e,i){var o=this,n=e.getAttribute("data-iziToast-ref"),s=d(this.children[n],t||{}),a=e.querySelector(".iziToast-progressbar div");return{start:function(){void 0===s.time.REMAINING&&(e.classList.remove("iziToast-reseted"),null!==a&&(a.style.transition="width "+s.timeout+"ms "+s.progressBarEasing,a.style.width="0%"),s.time.START=(new Date).getTime(),s.time.END=s.time.START+s.timeout,s.time.TIMER=setTimeout(function(){clearTimeout(s.time.TIMER),e.classList.contains("iziToast-closing")||(o.hide(s,e,"timeout"),"function"==typeof i&&i.apply(o))},s.timeout),o.setSetting(n,"time",s.time))},pause:function(){if(void 0!==s.time.START&&!e.classList.contains("iziToast-paused")&&!e.classList.contains("iziToast-reseted")){if(e.classList.add("iziToast-paused"),s.time.REMAINING=s.time.END-(new Date).getTime(),clearTimeout(s.time.TIMER),o.setSetting(n,"time",s.time),null!==a){var t=window.getComputedStyle(a).getPropertyValue("width");a.style.transition="none",a.style.width=t}"function"==typeof i&&setTimeout(function(){i.apply(o)},10)}},resume:function(){void 0!==s.time.REMAINING?(e.classList.remove("iziToast-paused"),null!==a&&(a.style.transition="width "+s.time.REMAINING+"ms "+s.progressBarEasing,a.style.width="0%"),s.time.END=(new Date).getTime()+s.time.REMAINING,s.time.TIMER=setTimeout(function(){clearTimeout(s.time.TIMER),e.classList.contains("iziToast-closing")||(o.hide(s,e,"timeout"),"function"==typeof i&&i.apply(o))},s.time.REMAINING),o.setSetting(n,"time",s.time)):this.start()},reset:function(){clearTimeout(s.time.TIMER),delete s.time.REMAINING,o.setSetting(n,"time",s.time),e.classList.add("iziToast-reseted"),e.classList.remove("iziToast-paused"),null!==a&&(a.style.transition="none",a.style.width="100%"),"function"==typeof i&&setTimeout(function(){i.apply(o)},10)}}},e.hide=function(t,e,o){"object"!=typeof e&&(e=document.querySelector(e));var n=this,s=d(this.children[e.getAttribute("data-iziToast-ref")],t||{});s.closedBy=o||null,delete s.time.REMAINING,e.classList.add("iziToast-closing"),function(){var t=document.querySelector(".iziToast-overlay");if(null!==t){var e=t.getAttribute("data-iziToast-ref"),i=(e=e.split(",")).indexOf(String(s.ref));-1!==i&&e.splice(i,1),t.setAttribute("data-iziToast-ref",e.join()),0===e.length&&(t.classList.remove("fadeIn"),t.classList.add("fadeOut"),setTimeout(function(){t.remove()},700))}}(),s.transitionIn&&e.classList.remove(s.transitionIn),s.transitionInMobile&&e.classList.remove(s.transitionInMobile),i||window.innerWidth<=568?s.transitionOutMobile&&e.classList.add(s.transitionOutMobile):s.transitionOut&&e.classList.add(s.transitionOut);var a=e.parentNode.offsetHeight;e.parentNode.style.height=a+"px",e.style.pointerEvents="none",(!i||window.innerWidth>568)&&(e.parentNode.style.transitionDelay="0.2s");try{var r=new CustomEvent("iziToast-closing",{detail:s,bubbles:!0,cancelable:!0});document.dispatchEvent(r)}catch(t){console.warn(t)}setTimeout(function(){e.parentNode.style.height="0px",e.parentNode.style.overflow="",setTimeout(function(){delete n.children[s.ref],e.parentNode.remove();try{var t=new CustomEvent("iziToast-closed",{detail:s,bubbles:!0,cancelable:!0});document.dispatchEvent(t)}catch(t){console.warn(t)}void 0!==s.onClosed&&s.onClosed.apply(null,[s,e,o])},1e3)},200),void 0!==s.onClosing&&s.onClosing.apply(null,[s,e,o])},e.show=function(t){var o,n=this,c=d(r,t||{});if((c=d(l,c)).time={},null===c.id&&(c.id=(o=c.title+c.message+c.color,btoa(encodeURIComponent(o)).replace(/=/g,""))),1===c.displayMode||"once"==c.displayMode)try{if(document.querySelectorAll(".iziToast#"+c.id).length>0)return!1}catch(t){console.warn("[iziToast] Could not find an element with this selector: #"+c.id+". Try to set an valid id.")}if(2===c.displayMode||"replace"==c.displayMode)try{u(document.querySelectorAll(".iziToast#"+c.id),function(t,e){n.hide(c,t,"replaced")})}catch(t){console.warn("[iziToast] Could not find an element with this selector: #"+c.id+". Try to set an valid id.")}c.ref=(new Date).getTime()+Math.floor(1e7*Math.random()+1),e.children[c.ref]=c;var f,g={body:document.querySelector("body"),overlay:document.createElement("div"),toast:document.createElement("div"),toastBody:document.createElement("div"),toastTexts:document.createElement("div"),toastCapsule:document.createElement("div"),cover:document.createElement("div"),buttons:document.createElement("div"),inputs:document.createElement("div"),icon:c.iconUrl?document.createElement("img"):document.createElement("i"),wrapper:null};g.toast.setAttribute("data-iziToast-ref",c.ref),g.toast.appendChild(g.toastBody),g.toastCapsule.appendChild(g.toast),function(){if(g.toast.classList.add("iziToast"),g.toast.classList.add("iziToast-opening"),g.toastCapsule.classList.add("iziToast-capsule"),g.toastBody.classList.add("iziToast-body"),g.toastTexts.classList.add("iziToast-texts"),i||window.innerWidth<=568?c.transitionInMobile&&g.toast.classList.add(c.transitionInMobile):c.transitionIn&&g.toast.classList.add(c.transitionIn),c.class){var t=c.class.split(" ");u(t,function(t,e){g.toast.classList.add(t)})}var e;c.id&&(g.toast.id=c.id),c.rtl&&(g.toast.classList.add("iziToast-rtl"),g.toast.setAttribute("dir","rtl")),c.layout>1&&g.toast.classList.add("iziToast-layout"+c.layout),c.balloon&&g.toast.classList.add("iziToast-balloon"),c.maxWidth&&(isNaN(c.maxWidth)?g.toast.style.maxWidth=c.maxWidth:g.toast.style.maxWidth=c.maxWidth+"px"),""===c.theme&&"light"===c.theme||g.toast.classList.add("iziToast-theme-"+c.theme),c.color&&("#"==(e=c.color).substring(0,1)||"rgb"==e.substring(0,3)||"hsl"==e.substring(0,3)?g.toast.style.background=c.color:g.toast.classList.add("iziToast-color-"+c.color)),c.backgroundColor&&(g.toast.style.background=c.backgroundColor,c.balloon&&(g.toast.style.borderColor=c.backgroundColor))}(),c.image&&(g.cover.classList.add("iziToast-cover"),g.cover.style.width=c.imageWidth+"px",function(t){try{return btoa(atob(t))==t}catch(t){return!1}}(c.image.replace(/ /g,""))?g.cover.style.backgroundImage="url(data:image/png;base64,"+c.image.replace(/ /g,"")+")":g.cover.style.backgroundImage="url("+c.image+")",c.rtl?g.toastBody.style.marginRight=c.imageWidth+10+"px":g.toastBody.style.marginLeft=c.imageWidth+10+"px",g.toast.appendChild(g.cover)),c.close?(g.buttonClose=document.createElement("button"),g.buttonClose.type="button",g.buttonClose.classList.add("iziToast-close"),g.buttonClose.addEventListener("click",function(t){t.target,n.hide(c,g.toast,"button")}),g.toast.appendChild(g.buttonClose)):c.rtl?g.toast.style.paddingLeft="18px":g.toast.style.paddingRight="18px",c.progressBar&&(g.progressBar=document.createElement("div"),g.progressBarDiv=document.createElement("div"),g.progressBar.classList.add("iziToast-progressbar"),g.progressBarDiv.style.background=c.progressBarColor,g.progressBar.appendChild(g.progressBarDiv),g.toast.appendChild(g.progressBar)),c.timeout&&(c.pauseOnHover&&!c.resetOnHover&&(g.toast.addEventListener("mouseenter",function(t){n.progress(c,g.toast).pause()}),g.toast.addEventListener("mouseleave",function(t){n.progress(c,g.toast).resume()})),c.resetOnHover&&(g.toast.addEventListener("mouseenter",function(t){n.progress(c,g.toast).reset()}),g.toast.addEventListener("mouseleave",function(t){n.progress(c,g.toast).start()}))),c.iconUrl?(g.icon.setAttribute("class","iziToast-icon"),g.icon.setAttribute("src",c.iconUrl)):c.icon&&(g.icon.setAttribute("class","iziToast-icon "+c.icon),c.iconText&&g.icon.appendChild(document.createTextNode(c.iconText)),c.iconColor&&(g.icon.style.color=c.iconColor)),(c.icon||c.iconUrl)&&(c.rtl?g.toastBody.style.paddingRight="33px":g.toastBody.style.paddingLeft="33px",g.toastBody.appendChild(g.icon)),c.title.length>0&&(g.strong=document.createElement("strong"),g.strong.classList.add("iziToast-title"),g.strong.appendChild(p(c.title)),g.toastTexts.appendChild(g.strong),c.titleColor&&(g.strong.style.color=c.titleColor),c.titleSize&&(isNaN(c.titleSize)?g.strong.style.fontSize=c.titleSize:g.strong.style.fontSize=c.titleSize+"px"),c.titleLineHeight&&(isNaN(c.titleSize)?g.strong.style.lineHeight=c.titleLineHeight:g.strong.style.lineHeight=c.titleLineHeight+"px")),c.message.length>0&&(g.p=document.createElement("p"),g.p.classList.add("iziToast-message"),g.p.appendChild(p(c.message)),g.toastTexts.appendChild(g.p),c.messageColor&&(g.p.style.color=c.messageColor),c.messageSize&&(isNaN(c.titleSize)?g.p.style.fontSize=c.messageSize:g.p.style.fontSize=c.messageSize+"px"),c.messageLineHeight&&(isNaN(c.titleSize)?g.p.style.lineHeight=c.messageLineHeight:g.p.style.lineHeight=c.messageLineHeight+"px")),c.title.length>0&&c.message.length>0&&(c.rtl?g.strong.style.marginLeft="10px":2===c.layout||c.rtl||(g.strong.style.marginRight="10px")),g.toastBody.appendChild(g.toastTexts),c.inputs.length>0&&(g.inputs.classList.add("iziToast-inputs"),u(c.inputs,function(t,e){g.inputs.appendChild(p(t[0])),(f=g.inputs.childNodes)[e].classList.add("iziToast-inputs-child"),t[3]&&setTimeout(function(){f[e].focus()},300),f[e].addEventListener(t[1],function(e){return(0,t[2])(n,g.toast,this,e)})}),g.toastBody.appendChild(g.inputs)),c.buttons.length>0&&(g.buttons.classList.add("iziToast-buttons"),u(c.buttons,function(t,e){g.buttons.appendChild(p(t[0]));var i=g.buttons.childNodes;i[e].classList.add("iziToast-buttons-child"),t[2]&&setTimeout(function(){i[e].focus()},300),i[e].addEventListener("click",function(e){return e.preventDefault(),(0,t[1])(n,g.toast,this,e,f)})})),g.toastBody.appendChild(g.buttons),c.message.length>0&&(c.inputs.length>0||c.buttons.length>0)&&(g.p.style.marginBottom="0"),(c.inputs.length>0||c.buttons.length>0)&&(c.rtl?g.toastTexts.style.marginLeft="10px":g.toastTexts.style.marginRight="10px",c.inputs.length>0&&c.buttons.length>0&&(c.rtl?g.inputs.style.marginLeft="8px":g.inputs.style.marginRight="8px")),g.toastCapsule.style.visibility="hidden",setTimeout(function(){var t=g.toast.offsetHeight,e=g.toast.currentStyle||window.getComputedStyle(g.toast),i=e.marginTop;i=i.split("px"),i=parseInt(i[0]);var o=e.marginBottom;o=o.split("px"),o=parseInt(o[0]),g.toastCapsule.style.visibility="",g.toastCapsule.style.height=t+o+i+"px",setTimeout(function(){g.toastCapsule.style.height="auto",c.target&&(g.toastCapsule.style.overflow="visible")},500),c.timeout&&n.progress(c,g.toast).start()},100),function(){var t=c.position;if(c.target)g.wrapper=document.querySelector(c.target),g.wrapper.classList.add("iziToast-target"),c.targetFirst?g.wrapper.insertBefore(g.toastCapsule,g.wrapper.firstChild):g.wrapper.appendChild(g.toastCapsule);else{if(-1==a.indexOf(c.position))return void console.warn("[iziToast] Incorrect position.\nIt can be › "+a);t=i||window.innerWidth<=568?"bottomLeft"==c.position||"bottomRight"==c.position||"bottomCenter"==c.position?"iziToast-wrapper-bottomCenter":"topLeft"==c.position||"topRight"==c.position||"topCenter"==c.position?"iziToast-wrapper-topCenter":"iziToast-wrapper-center":"iziToast-wrapper-"+t,g.wrapper=document.querySelector(".iziToast-wrapper."+t),g.wrapper||(g.wrapper=document.createElement("div"),g.wrapper.classList.add("iziToast-wrapper"),g.wrapper.classList.add(t),document.body.appendChild(g.wrapper)),"topLeft"==c.position||"topCenter"==c.position||"topRight"==c.position?g.wrapper.insertBefore(g.toastCapsule,g.wrapper.firstChild):g.wrapper.appendChild(g.toastCapsule)}isNaN(c.zindex)?console.warn("[iziToast] Invalid zIndex."):g.wrapper.style.zIndex=c.zindex}(),c.overlay&&(null!==document.querySelector(".iziToast-overlay.fadeIn")?(g.overlay=document.querySelector(".iziToast-overlay"),g.overlay.setAttribute("data-iziToast-ref",g.overlay.getAttribute("data-iziToast-ref")+","+c.ref),isNaN(c.zindex)||null===c.zindex||(g.overlay.style.zIndex=c.zindex-1)):(g.overlay.classList.add("iziToast-overlay"),g.overlay.classList.add("fadeIn"),g.overlay.style.background=c.overlayColor,g.overlay.setAttribute("data-iziToast-ref",c.ref),isNaN(c.zindex)||null===c.zindex||(g.overlay.style.zIndex=c.zindex-1),document.querySelector("body").appendChild(g.overlay)),c.overlayClose?(g.overlay.removeEventListener("click",{}),g.overlay.addEventListener("click",function(t){n.hide(c,g.toast,"overlay")})):g.overlay.removeEventListener("click",{})),function(){if(c.animateInside){g.toast.classList.add("iziToast-animateInside");var t=[200,100,300];"bounceInLeft"!=c.transitionIn&&"bounceInRight"!=c.transitionIn||(t=[400,200,400]),c.title.length>0&&setTimeout(function(){g.strong.classList.add("slideIn")},t[0]),c.message.length>0&&setTimeout(function(){g.p.classList.add("slideIn")},t[1]),(c.icon||c.iconUrl)&&setTimeout(function(){g.icon.classList.add("revealIn")},t[2]);var e=150;c.buttons.length>0&&g.buttons&&setTimeout(function(){u(g.buttons.childNodes,function(t,i){setTimeout(function(){t.classList.add("revealIn")},e),e+=150})},c.inputs.length>0?150:0),c.inputs.length>0&&g.inputs&&(e=150,u(g.inputs.childNodes,function(t,i){setTimeout(function(){t.classList.add("revealIn")},e),e+=150}))}}(),c.onOpening.apply(null,[c,g.toast]);try{var v=new CustomEvent("iziToast-opening",{detail:c,bubbles:!0,cancelable:!0});document.dispatchEvent(v)}catch(t){console.warn(t)}setTimeout(function(){g.toast.classList.remove("iziToast-opening"),g.toast.classList.add("iziToast-opened");try{var t=new CustomEvent("iziToast-opened",{detail:c,bubbles:!0,cancelable:!0});document.dispatchEvent(t)}catch(t){console.warn(t)}c.onOpened.apply(null,[c,g.toast])},1e3),c.drag&&(s?(g.toast.addEventListener("touchstart",function(t){m.startMoving(this,n,c,t)},!1),g.toast.addEventListener("touchend",function(t){m.stopMoving(this,t)},!1)):(g.toast.addEventListener("mousedown",function(t){t.preventDefault(),m.startMoving(this,n,c,t)},!1),g.toast.addEventListener("mouseup",function(t){t.preventDefault(),m.stopMoving(this,t)},!1))),c.closeOnEscape&&document.addEventListener("keyup",function(t){27==(t=t||window.event).keyCode&&n.hide(c,g.toast,"esc")}),c.closeOnClick&&g.toast.addEventListener("click",function(t){n.hide(c,g.toast,"toast")}),n.toast=g.toast},e}(),void 0===(s="function"==typeof o?o.apply(e,n):o)||(t.exports=s)}).call(this,i(6))},function(t,e,i){t.exports=i(5)},function(t,e,i){"use strict";i.r(e),i.d(e,"devMode",function(){return p}),i.d(e,"default",function(){return m}),i.d(e,"install",function(){return f});var o=i(2),n=i.n(o),s=i(1),a=i.n(s),r=i(0),l=i.n(r),c=i(3),u=i.n(c);function d(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,o)}return i}function p(){return!1}var m=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n()(this,t),l()(this,"_izi",u.a),l()(this,"accessorName","$toast"),l()(this,"initialized",!1);this.options=function(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?d(i,!0).forEach(function(e){l()(t,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):d(i).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))})}return t}({},{zindex:99999,layout:1,balloon:!1,close:!0,closeOnEscape:!1,rtl:!1,position:"bottomRight",timeout:5e3,animateInside:!0,drag:!0,pauseOnHover:!0,resetOnHover:!1,transitionIn:"fadeInUp",transitionOut:"fadeOut",transitionInMobile:"fadeInUp",transitionOutMobile:"fadeOutDown",buttons:{},inputs:{},onOpening:function(){},onOpened:function(){},onClosing:function(){},onClosed:function(){}},{},e),this._izi.settings(this.options)}return a()(t,null,[{key:"_checkParams",value:function(t,e,i){if(!t||t.constructor!==String)throw"Message must be a string";if(e&&e.constructor!==String)throw"Title must be a string";if(i&&i.constructor!==Object)throw"Options must be a object"}},{key:"_checkEventNames",value:function(t){if(!t||t.constructor!==String)throw"Event Name must be a string";if("iziToast-open"!==t&&"iziToast-close"!==t)throw"Event Name has only two possible values: iziToast-open or iziToast-close"}},{key:"_initToast",value:function(t){return t&&t.constructor!==String&&(t=document.querySelector(t)),t&&t.constructor===HTMLDivElement||(t=document.querySelector(".iziToast")),t}},{key:"_validateOptions",value:function(t){if(t&&t.constructor!==Object)throw"Options must be a object"}},{key:"_validateCallback",value:function(t){if(t&&t.constructor!==Function)throw"Callback must be a function"}}]),a()(t,[{key:"init",value:function(t){this.initialized||(this.initialized=!0)}},{key:"show",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t._checkParams(e,i,o),this._izi.show(Object.assign({},o,{message:e,title:i}))}},{key:"hide",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=t._initToast(e),t._validateOptions(i),this._izi.hide(i,e)}},{key:"progress",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){};return e=t._initToast(e),t._validateOptions(i),t._validateCallback(o),this._izi.progress(e,i,o)}},{key:"destroy",value:function(){this._izi.destroy()}},{key:"info",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t._checkParams(e,i,o),this._izi.info(Object.assign({},o,{message:e,title:i}))}},{key:"success",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t._checkParams(e,i,o),this._izi.success(Object.assign({},o,{message:e,title:i}))}},{key:"warning",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t._checkParams(e,i,o),this._izi.warning(Object.assign({},o,{message:e,title:i}))}},{key:"error",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t._checkParams(e,i,o),this._izi.error(Object.assign({},o,{message:e,title:i}))}},{key:"question",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t._checkParams(e,i,o),this._izi.question(Object.assign({},o,{message:e,title:i}))}},{key:"on",value:function(e,i){t._checkEventNames(e),t._validateCallback(i),document.addEventListener(e,i)}},{key:"off",value:function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(){};t._checkEventNames(e),document.removeEventListener(e,i)}}]),t}();function f(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.constructor!==Object)throw"Options must be a object";f.installed&&t||(t.mixin({beforeCreate:function(){var i=this.$options.parent,o=null;i&&i.__$VueIziToastInstance?(o=i.__$VueIziToastInstance).init(t):o=new m(e),o&&(this.__$VueIziToastInstance=o,this[o.accessorName]=o)}}),f.installed=!0)}m.install=f,"undefined"!=typeof window&&window.Vue&&window.Vue.use(m)},function(t,e){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(t){"object"==typeof window&&(i=window)}t.exports=i}])}); |
{ | ||
"name": "vue-izitoast", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "Elegant, responsive, flexible and lightweight notification plugin implemented for Vue 2 of iziToast", | ||
"main": "dist/vue-izitoast.js", | ||
"types": "src/types/index.d.ts", | ||
"files": [ | ||
"dist/vue-izitoast.js", | ||
"dist/vue-izitoast.min.js" | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "node build/build.js" | ||
"test": "run-p cypress:run example", | ||
"test:dev": "run-p cypress:open example", | ||
"cypress:run": "cypress run", | ||
"cypress:open": "cypress open", | ||
"storybook": "start-storybook", | ||
"storybook:build": "build-storybook -o docs", | ||
"build": "cross-env NODE_ENV=production webpack --config webpack.config.js", | ||
"example": "poi -s examples/index.js", | ||
"deploy": "run-s build storybook:build" | ||
}, | ||
@@ -36,44 +45,59 @@ "homepage": "https://github.com/arthurvasconcelos/vue-izitoast#readme", | ||
], | ||
"engines": { | ||
"node": "^6.11.4 || ^8.7.0 || ^9.0.0 || ^10.0.0", | ||
"npm": "^3.10.10 || ^5.4.2 || ^6.0.0", | ||
"yarn": "^1.0.0" | ||
}, | ||
"author": "Arthur Vasconcelos <vasconcelos.arthur@gmail.com> (http://arthurvasconcelos.com.br/)", | ||
"license": "MIT", | ||
"author": "Arthur Vasconcelos <vasconcelos.arthur@gmail.com> (https://arthurvasconcelos.com.br/)", | ||
"license": "Apache-2.0", | ||
"private": false, | ||
"dependencies": { | ||
"izitoast": "^1.3.0" | ||
"izitoast": "^1.4.0" | ||
}, | ||
"peerDependencies": { | ||
"izitoast": "^1.3.0", | ||
"vue": "^2.0.0" | ||
"izitoast": "^1.4.0", | ||
"vue": "^2.6.x" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.5.5", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-transform-runtime": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"@storybook/addon-notes": "^5.1.11", | ||
"@storybook/vue": "^5.1.11", | ||
"babel-core": "^6.26.3", | ||
"babel-eslint": "^8.2.3", | ||
"babel-loader": "^7.1.4", | ||
"babel-eslint": "^10.0.2", | ||
"babel-loader": "^8.0.6", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-stage-3": "^6.24.1", | ||
"chalk": "^2.4.1", | ||
"compression-webpack-plugin": "^1.1.6", | ||
"cross-env": "^5.1.5", | ||
"babel-preset-vue": "^2.0.2", | ||
"chalk": "^2.4.2", | ||
"compression-webpack-plugin": "^3.0.0", | ||
"cross-env": "^5.2.0", | ||
"cross-spawn": "^6.0.5", | ||
"eslint": "^4.19.1", | ||
"eslint-friendly-formatter": "^3.0.0", | ||
"eslint-loader": "^1.9.0", | ||
"eslint-plugin-import": "^2.12.0", | ||
"cypress": "^3.4.1", | ||
"eslint": "^6.2.1", | ||
"eslint-config-prettier": "^6.1.0", | ||
"eslint-friendly-formatter": "^4.0.1", | ||
"eslint-loader": "^2.2.1", | ||
"eslint-plugin-import": "^2.18.2", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"friendly-errors-webpack-plugin": "^1.7.0", | ||
"ora": "^1.4.0", | ||
"rimraf": "^2.6.2", | ||
"semver": "^5.5.0", | ||
"shelljs": "^0.8.2", | ||
"uglify-es": "^3.3.9", | ||
"uglifyjs-webpack-plugin": "^1.2.5", | ||
"webpack": "^3.12.0", | ||
"webpack-bundle-analyzer": "^2.12.0", | ||
"webpack-dev-middleware": "^2.0.6", | ||
"webpack-merge": "^4.1.2" | ||
"husky": "^3.0.4", | ||
"lint-staged": "^9.2.3", | ||
"npm-run-all": "^4.1.5", | ||
"ora": "^3.4.0", | ||
"poi": "^12.7.2", | ||
"prettier": "^1.18.2", | ||
"rimraf": "^3.0.0", | ||
"semver": "^6.3.0", | ||
"shelljs": "^0.8.3", | ||
"uglifyjs-webpack-plugin": "^2.2.0", | ||
"vue": "^2.6.10", | ||
"vue-html-loader": "^1.2.4", | ||
"vue-loader": "^15.7.1", | ||
"vue-style-loader": "^4.1.2", | ||
"vue-template-compiler": "^2.6.10", | ||
"webpack": "^4.39.2", | ||
"webpack-bundle-analyzer": "^3.4.1", | ||
"webpack-cli": "^3.3.7", | ||
"webpack-dev-middleware": "^3.7.0", | ||
"webpack-merge": "^4.2.1" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
7
0
55906
45
241
1
1
Updatedizitoast@^1.4.0