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:
authorJan Stevens <jan@playpass.be>2015-08-19 22:34:56 +0300
committerJan Stevens <jan@playpass.be>2015-08-19 22:34:56 +0300
commit7397065e0daf73ac84e0846b0278736163b147a2 (patch)
treee8d2f8d4fabd6c08ffce6e71663289d8aec925b4 /assets/javascripts/bootstrap/alert.js
parent2bab961e660b59462fa05868facb1e7cf298ffe9 (diff)
New assets update for bootstrap 4
Diffstat (limited to 'assets/javascripts/bootstrap/alert.js')
-rw-r--r--assets/javascripts/bootstrap/alert.js276
1 files changed, 187 insertions, 89 deletions
diff --git a/assets/javascripts/bootstrap/alert.js b/assets/javascripts/bootstrap/alert.js
index a7787cb..27f44ed 100644
--- a/assets/javascripts/bootstrap/alert.js
+++ b/assets/javascripts/bootstrap/alert.js
@@ -1,94 +1,192 @@
-/* ========================================================================
- * Bootstrap: alert.js v3.3.5
- * http://getbootstrap.com/javascript/#alerts
- * ========================================================================
- * Copyright 2011-2015 Twitter, Inc.
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
- * ======================================================================== */
-
-
-+function ($) {
- 'use strict';
-
- // ALERT CLASS DEFINITION
- // ======================
-
- var dismiss = '[data-dismiss="alert"]'
- var Alert = function (el) {
- $(el).on('click', dismiss, this.close)
- }
-
- Alert.VERSION = '3.3.5'
-
- Alert.TRANSITION_DURATION = 150
-
- Alert.prototype.close = function (e) {
- var $this = $(this)
- var selector = $this.attr('data-target')
-
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
- }
-
- var $parent = $(selector)
-
- if (e) e.preventDefault()
-
- if (!$parent.length) {
- $parent = $this.closest('.alert')
- }
-
- $parent.trigger(e = $.Event('close.bs.alert'))
+'use strict';
- if (e.isDefaultPrevented()) return
+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; }; })();
- $parent.removeClass('in')
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
- function removeElement() {
- // detach from parent, fire event then clean up data
- $parent.detach().trigger('closed.bs.alert').remove()
+/**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v4.0.0): alert.js
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
+ * --------------------------------------------------------------------------
+ */
+
+var Alert = (function ($) {
+
+ /**
+ * ------------------------------------------------------------------------
+ * Constants
+ * ------------------------------------------------------------------------
+ */
+
+ var NAME = 'alert';
+ var VERSION = '4.0.0';
+ var DATA_KEY = 'bs.alert';
+ 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
+ };
+
+ var ClassName = {
+ ALERT: 'alert',
+ FADE: 'fade',
+ IN: 'in'
+ };
+
+ /**
+ * ------------------------------------------------------------------------
+ * Class Definition
+ * ------------------------------------------------------------------------
+ */
+
+ var Alert = (function () {
+ function Alert(element) {
+ _classCallCheck(this, Alert);
+
+ this._element = element;
}
- $.support.transition && $parent.hasClass('fade') ?
- $parent
- .one('bsTransitionEnd', removeElement)
- .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
- removeElement()
- }
-
-
- // ALERT PLUGIN DEFINITION
- // =======================
-
- function Plugin(option) {
- return this.each(function () {
- var $this = $(this)
- var data = $this.data('bs.alert')
-
- if (!data) $this.data('bs.alert', (data = new Alert(this)))
- if (typeof option == 'string') data[option].call($this)
- })
- }
-
- var old = $.fn.alert
-
- $.fn.alert = Plugin
- $.fn.alert.Constructor = Alert
-
-
- // ALERT NO CONFLICT
- // =================
-
- $.fn.alert.noConflict = function () {
- $.fn.alert = old
- return this
- }
-
-
- // ALERT DATA-API
- // ==============
-
- $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
-
-}(jQuery);
+ /**
+ * ------------------------------------------------------------------------
+ * Data Api implementation
+ * ------------------------------------------------------------------------
+ */
+
+ // getters
+
+ _createClass(Alert, [{
+ key: 'close',
+
+ // public
+
+ value: function close(element) {
+ element = element || this._element;
+
+ var rootElement = this._getRootElement(element);
+ var customEvent = this._triggerCloseEvent(rootElement);
+
+ if (customEvent.isDefaultPrevented()) {
+ return;
+ }
+
+ this._removeElement(rootElement);
+ }
+ }, {
+ key: 'dispose',
+ value: function dispose() {
+ $.removeData(this._element, DATA_KEY);
+ this._element = null;
+ }
+
+ // private
+
+ }, {
+ key: '_getRootElement',
+ value: function _getRootElement(element) {
+ var selector = Util.getSelectorFromElement(element);
+ var parent = false;
+
+ if (selector) {
+ parent = $(selector)[0];
+ }
+
+ if (!parent) {
+ parent = $(element).closest('.' + ClassName.ALERT)[0];
+ }
+
+ return parent;
+ }
+ }, {
+ key: '_triggerCloseEvent',
+ value: function _triggerCloseEvent(element) {
+ var closeEvent = $.Event(Event.CLOSE);
+
+ $(element).trigger(closeEvent);
+ return closeEvent;
+ }
+ }, {
+ key: '_removeElement',
+ value: function _removeElement(element) {
+ $(element).removeClass(ClassName.IN);
+
+ if (!Util.supportsTransitionEnd() || !$(element).hasClass(ClassName.FADE)) {
+ this._destroyElement(element);
+ return;
+ }
+
+ $(element).one(Util.TRANSITION_END, $.proxy(this._destroyElement, this, element)).emulateTransitionEnd(TRANSITION_DURATION);
+ }
+ }, {
+ key: '_destroyElement',
+ value: function _destroyElement(element) {
+ $(element).detach().trigger(Event.CLOSED).remove();
+ }
+
+ // static
+
+ }], [{
+ key: '_jQueryInterface',
+ value: 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: '_handleDismiss',
+ value: function _handleDismiss(alertInstance) {
+ return function (event) {
+ if (event) {
+ event.preventDefault();
+ }
+
+ alertInstance.close(this);
+ };
+ }
+ }, {
+ key: 'VERSION',
+ get: function get() {
+ return VERSION;
+ }
+ }]);
+
+ return Alert;
+ })();
+
+ $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
+
+ /**
+ * ------------------------------------------------------------------------
+ * jQuery
+ * ------------------------------------------------------------------------
+ */
+
+ $.fn[NAME] = Alert._jQueryInterface;
+ $.fn[NAME].Constructor = Alert;
+ $.fn[NAME].noConflict = function () {
+ $.fn[NAME] = JQUERY_NO_CONFLICT;
+ return Alert._jQueryInterface;
+ };
+
+ return Alert;
+})(jQuery);
+//# sourceMappingURL=alert.js.map