mirror of
https://github.com/twbs/bootstrap.git
synced 2024-12-01 13:24:25 +01:00
c2c19a4d2d
Will hopefully revert this reversion and land a fully-working version of UMD in v3.3.0. Revert "some changes from #13801 - add strict mode back and ==" This reverts commit2b302f69ee
. Revert "Fix regression of #10038 introduced by #13772" This reverts commite9d6756a1a
. Revert "MD/CommonJS/Globals #12909" This reverts commit1c6fa9010d
. Revert "address #13811" This reverts commitf347d7d955
. Conflicts: js/carousel.js js/collapse.js js/dropdown.js js/modal.js js/tab.js js/tooltip.js
93 lines
2.2 KiB
JavaScript
93 lines
2.2 KiB
JavaScript
/* ========================================================================
|
|
* Bootstrap: alert.js v3.1.1
|
|
* http://getbootstrap.com/javascript/#alerts
|
|
* ========================================================================
|
|
* Copyright 2011-2014 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.1.1'
|
|
|
|
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.hasClass('alert') ? $this : $this.parent()
|
|
}
|
|
|
|
$parent.trigger(e = $.Event('close.bs.alert'))
|
|
|
|
if (e.isDefaultPrevented()) return
|
|
|
|
$parent.removeClass('in')
|
|
|
|
function removeElement() {
|
|
// detach from parent, fire event then clean up data
|
|
$parent.detach().trigger('closed.bs.alert').remove()
|
|
}
|
|
|
|
$.support.transition && $parent.hasClass('fade') ?
|
|
$parent
|
|
.one('bsTransitionEnd', removeElement)
|
|
.emulateTransitionEnd(150) :
|
|
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);
|