mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-28 19:35:15 +00:00
273 lines
8.0 KiB
JavaScript
273 lines
8.0 KiB
JavaScript
/*!
|
|
* Bootstrap toast.js v4.6.0 (https://getbootstrap.com/)
|
|
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
*/
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
|
|
typeof define === 'function' && define.amd ? define(['jquery', './util'], factory) :
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Toast = factory(global.jQuery, global.Util));
|
|
}(this, (function ($, Util) { 'use strict';
|
|
|
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
|
|
var $__default = /*#__PURE__*/_interopDefaultLegacy($);
|
|
var Util__default = /*#__PURE__*/_interopDefaultLegacy(Util);
|
|
|
|
function _defineProperties(target, props) {
|
|
for (var i = 0; i < props.length; i++) {
|
|
var descriptor = props[i];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor) descriptor.writable = true;
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
}
|
|
|
|
function _extends() {
|
|
_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;
|
|
};
|
|
|
|
return _extends.apply(this, arguments);
|
|
}
|
|
|
|
/**
|
|
* ------------------------------------------------------------------------
|
|
* Constants
|
|
* ------------------------------------------------------------------------
|
|
*/
|
|
|
|
var NAME = 'toast';
|
|
var VERSION = '4.6.0';
|
|
var DATA_KEY = 'bs.toast';
|
|
var EVENT_KEY = "." + DATA_KEY;
|
|
var JQUERY_NO_CONFLICT = $__default['default'].fn[NAME];
|
|
var EVENT_CLICK_DISMISS = "click.dismiss" + EVENT_KEY;
|
|
var EVENT_HIDE = "hide" + EVENT_KEY;
|
|
var EVENT_HIDDEN = "hidden" + EVENT_KEY;
|
|
var EVENT_SHOW = "show" + EVENT_KEY;
|
|
var EVENT_SHOWN = "shown" + EVENT_KEY;
|
|
var CLASS_NAME_FADE = 'fade';
|
|
var CLASS_NAME_HIDE = 'hide';
|
|
var CLASS_NAME_SHOW = 'show';
|
|
var CLASS_NAME_SHOWING = 'showing';
|
|
var DefaultType = {
|
|
animation: 'boolean',
|
|
autohide: 'boolean',
|
|
delay: 'number'
|
|
};
|
|
var Default = {
|
|
animation: true,
|
|
autohide: true,
|
|
delay: 500
|
|
};
|
|
var SELECTOR_DATA_DISMISS = '[data-dismiss="toast"]';
|
|
/**
|
|
* ------------------------------------------------------------------------
|
|
* Class Definition
|
|
* ------------------------------------------------------------------------
|
|
*/
|
|
|
|
var Toast = /*#__PURE__*/function () {
|
|
function Toast(element, config) {
|
|
this._element = element;
|
|
this._config = this._getConfig(config);
|
|
this._timeout = null;
|
|
|
|
this._setListeners();
|
|
} // Getters
|
|
|
|
|
|
var _proto = Toast.prototype;
|
|
|
|
// Public
|
|
_proto.show = function show() {
|
|
var _this = this;
|
|
|
|
var showEvent = $__default['default'].Event(EVENT_SHOW);
|
|
$__default['default'](this._element).trigger(showEvent);
|
|
|
|
if (showEvent.isDefaultPrevented()) {
|
|
return;
|
|
}
|
|
|
|
this._clearTimeout();
|
|
|
|
if (this._config.animation) {
|
|
this._element.classList.add(CLASS_NAME_FADE);
|
|
}
|
|
|
|
var complete = function complete() {
|
|
_this._element.classList.remove(CLASS_NAME_SHOWING);
|
|
|
|
_this._element.classList.add(CLASS_NAME_SHOW);
|
|
|
|
$__default['default'](_this._element).trigger(EVENT_SHOWN);
|
|
|
|
if (_this._config.autohide) {
|
|
_this._timeout = setTimeout(function () {
|
|
_this.hide();
|
|
}, _this._config.delay);
|
|
}
|
|
};
|
|
|
|
this._element.classList.remove(CLASS_NAME_HIDE);
|
|
|
|
Util__default['default'].reflow(this._element);
|
|
|
|
this._element.classList.add(CLASS_NAME_SHOWING);
|
|
|
|
if (this._config.animation) {
|
|
var transitionDuration = Util__default['default'].getTransitionDurationFromElement(this._element);
|
|
$__default['default'](this._element).one(Util__default['default'].TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
|
|
} else {
|
|
complete();
|
|
}
|
|
};
|
|
|
|
_proto.hide = function hide() {
|
|
if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
|
|
return;
|
|
}
|
|
|
|
var hideEvent = $__default['default'].Event(EVENT_HIDE);
|
|
$__default['default'](this._element).trigger(hideEvent);
|
|
|
|
if (hideEvent.isDefaultPrevented()) {
|
|
return;
|
|
}
|
|
|
|
this._close();
|
|
};
|
|
|
|
_proto.dispose = function dispose() {
|
|
this._clearTimeout();
|
|
|
|
if (this._element.classList.contains(CLASS_NAME_SHOW)) {
|
|
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
}
|
|
|
|
$__default['default'](this._element).off(EVENT_CLICK_DISMISS);
|
|
$__default['default'].removeData(this._element, DATA_KEY);
|
|
this._element = null;
|
|
this._config = null;
|
|
} // Private
|
|
;
|
|
|
|
_proto._getConfig = function _getConfig(config) {
|
|
config = _extends({}, Default, $__default['default'](this._element).data(), typeof config === 'object' && config ? config : {});
|
|
Util__default['default'].typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
|
return config;
|
|
};
|
|
|
|
_proto._setListeners = function _setListeners() {
|
|
var _this2 = this;
|
|
|
|
$__default['default'](this._element).on(EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, function () {
|
|
return _this2.hide();
|
|
});
|
|
};
|
|
|
|
_proto._close = function _close() {
|
|
var _this3 = this;
|
|
|
|
var complete = function complete() {
|
|
_this3._element.classList.add(CLASS_NAME_HIDE);
|
|
|
|
$__default['default'](_this3._element).trigger(EVENT_HIDDEN);
|
|
};
|
|
|
|
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
|
|
if (this._config.animation) {
|
|
var transitionDuration = Util__default['default'].getTransitionDurationFromElement(this._element);
|
|
$__default['default'](this._element).one(Util__default['default'].TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
|
|
} else {
|
|
complete();
|
|
}
|
|
};
|
|
|
|
_proto._clearTimeout = function _clearTimeout() {
|
|
clearTimeout(this._timeout);
|
|
this._timeout = null;
|
|
} // Static
|
|
;
|
|
|
|
Toast._jQueryInterface = function _jQueryInterface(config) {
|
|
return this.each(function () {
|
|
var $element = $__default['default'](this);
|
|
var data = $element.data(DATA_KEY);
|
|
|
|
var _config = typeof config === 'object' && config;
|
|
|
|
if (!data) {
|
|
data = new Toast(this, _config);
|
|
$element.data(DATA_KEY, data);
|
|
}
|
|
|
|
if (typeof config === 'string') {
|
|
if (typeof data[config] === 'undefined') {
|
|
throw new TypeError("No method named \"" + config + "\"");
|
|
}
|
|
|
|
data[config](this);
|
|
}
|
|
});
|
|
};
|
|
|
|
_createClass(Toast, null, [{
|
|
key: "VERSION",
|
|
get: function get() {
|
|
return VERSION;
|
|
}
|
|
}, {
|
|
key: "DefaultType",
|
|
get: function get() {
|
|
return DefaultType;
|
|
}
|
|
}, {
|
|
key: "Default",
|
|
get: function get() {
|
|
return Default;
|
|
}
|
|
}]);
|
|
|
|
return Toast;
|
|
}();
|
|
/**
|
|
* ------------------------------------------------------------------------
|
|
* jQuery
|
|
* ------------------------------------------------------------------------
|
|
*/
|
|
|
|
|
|
$__default['default'].fn[NAME] = Toast._jQueryInterface;
|
|
$__default['default'].fn[NAME].Constructor = Toast;
|
|
|
|
$__default['default'].fn[NAME].noConflict = function () {
|
|
$__default['default'].fn[NAME] = JQUERY_NO_CONFLICT;
|
|
return Toast._jQueryInterface;
|
|
};
|
|
|
|
return Toast;
|
|
|
|
})));
|
|
//# sourceMappingURL=toast.js.map
|