Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/bootstrap/alert.js')
-rw-r--r--assets/javascripts/bootstrap/alert.js199
1 files changed, 89 insertions, 110 deletions
diff --git a/assets/javascripts/bootstrap/alert.js b/assets/javascripts/bootstrap/alert.js
index b3f9db1..5985401 100644
--- a/assets/javascripts/bootstrap/alert.js
+++ b/assets/javascripts/bootstrap/alert.js
@@ -1,8 +1,6 @@
-'use strict';
+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); } }
-var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
-
-function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
/**
* --------------------------------------------------------------------------
@@ -10,159 +8,140 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* --------------------------------------------------------------------------
*/
-
var Alert = function () {
-
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
-
var NAME = 'alert';
var VERSION = '4.0.0-beta';
var DATA_KEY = 'bs.alert';
- var EVENT_KEY = '.' + DATA_KEY;
+ var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
var JQUERY_NO_CONFLICT = $.fn[NAME];
var TRANSITION_DURATION = 150;
-
var Selector = {
DISMISS: '[data-dismiss="alert"]'
};
-
var Event = {
- CLOSE: 'close' + EVENT_KEY,
- CLOSED: 'closed' + EVENT_KEY,
- CLICK_DATA_API: 'click' + EVENT_KEY + DATA_API_KEY
+ CLOSE: "close" + EVENT_KEY,
+ CLOSED: "closed" + EVENT_KEY,
+ CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
};
-
var ClassName = {
ALERT: 'alert',
FADE: 'fade',
SHOW: 'show'
- };
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
- /**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
- */
+ };
- var Alert = function () {
+ var Alert =
+ /*#__PURE__*/
+ function () {
function Alert(element) {
- _classCallCheck(this, Alert);
-
this._element = element;
- }
+ } // getters
- // getters
- _createClass(Alert, [{
- key: 'close',
+ var _proto = Alert.prototype;
+ // public
+ _proto.close = function close(element) {
+ element = element || this._element;
- // public
+ var rootElement = this._getRootElement(element);
- value: function close(element) {
- element = element || this._element;
+ var customEvent = this._triggerCloseEvent(rootElement);
- var rootElement = this._getRootElement(element);
- var customEvent = this._triggerCloseEvent(rootElement);
+ if (customEvent.isDefaultPrevented()) {
+ return;
+ }
- if (customEvent.isDefaultPrevented()) {
- return;
- }
+ this._removeElement(rootElement);
+ };
+
+ _proto.dispose = function dispose() {
+ $.removeData(this._element, DATA_KEY);
+ this._element = null;
+ }; // private
+
+
+ _proto._getRootElement = function _getRootElement(element) {
+ var selector = Util.getSelectorFromElement(element);
+ var parent = false;
- this._removeElement(rootElement);
+ if (selector) {
+ parent = $(selector)[0];
}
- }, {
- key: 'dispose',
- value: function dispose() {
- $.removeData(this._element, DATA_KEY);
- this._element = null;
+
+ if (!parent) {
+ parent = $(element).closest("." + ClassName.ALERT)[0];
}
- // private
+ return parent;
+ };
- }, {
- key: '_getRootElement',
- value: function _getRootElement(element) {
- var selector = Util.getSelectorFromElement(element);
- var parent = false;
+ _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
+ var closeEvent = $.Event(Event.CLOSE);
+ $(element).trigger(closeEvent);
+ return closeEvent;
+ };
- if (selector) {
- parent = $(selector)[0];
- }
+ _proto._removeElement = function _removeElement(element) {
+ var _this = this;
- if (!parent) {
- parent = $(element).closest('.' + ClassName.ALERT)[0];
- }
+ $(element).removeClass(ClassName.SHOW);
- return parent;
- }
- }, {
- key: '_triggerCloseEvent',
- value: function _triggerCloseEvent(element) {
- var closeEvent = $.Event(Event.CLOSE);
+ if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
+ this._destroyElement(element);
- $(element).trigger(closeEvent);
- return closeEvent;
+ return;
}
- }, {
- key: '_removeElement',
- value: function _removeElement(element) {
- var _this = this;
- $(element).removeClass(ClassName.SHOW);
+ $(element).one(Util.TRANSITION_END, function (event) {
+ return _this._destroyElement(element, event);
+ }).emulateTransitionEnd(TRANSITION_DURATION);
+ };
- if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
- this._destroyElement(element);
- return;
- }
+ _proto._destroyElement = function _destroyElement(element) {
+ $(element).detach().trigger(Event.CLOSED).remove();
+ }; // static
- $(element).one(Util.TRANSITION_END, function (event) {
- return _this._destroyElement(element, event);
- }).emulateTransitionEnd(TRANSITION_DURATION);
- }
- }, {
- key: '_destroyElement',
- value: function _destroyElement(element) {
- $(element).detach().trigger(Event.CLOSED).remove();
- }
- // static
+ Alert._jQueryInterface = function _jQueryInterface(config) {
+ return this.each(function () {
+ var $element = $(this);
+ var data = $element.data(DATA_KEY);
+
+ if (!data) {
+ data = new Alert(this);
+ $element.data(DATA_KEY, data);
+ }
+
+ if (config === 'close') {
+ data[config](this);
+ }
+ });
+ };
- }], [{
- key: '_jQueryInterface',
- value: function _jQueryInterface(config) {
- return this.each(function () {
- var $element = $(this);
- var data = $element.data(DATA_KEY);
+ Alert._handleDismiss = function _handleDismiss(alertInstance) {
+ return function (event) {
+ if (event) {
+ event.preventDefault();
+ }
- if (!data) {
- data = new Alert(this);
- $element.data(DATA_KEY, data);
- }
+ alertInstance.close(this);
+ };
+ };
- if (config === 'close') {
- data[config](this);
- }
- });
- }
- }, {
- key: '_handleDismiss',
- value: function _handleDismiss(alertInstance) {
- return function (event) {
- if (event) {
- event.preventDefault();
- }
-
- alertInstance.close(this);
- };
- }
- }, {
- key: 'VERSION',
+ _createClass(Alert, null, [{
+ key: "VERSION",
get: function get() {
return VERSION;
}
@@ -170,15 +149,14 @@ var Alert = function () {
return Alert;
}();
-
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
- $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
+ $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
/**
* ------------------------------------------------------------------------
* jQuery
@@ -187,6 +165,7 @@ var Alert = function () {
$.fn[NAME] = Alert._jQueryInterface;
$.fn[NAME].Constructor = Alert;
+
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert._jQueryInterface;