1 /* ========================================================================
2 * Bootstrap: alert.js v3.2.0
3 * http://getbootstrap.com/javascript/#alerts
4 * ========================================================================
5 * Copyright 2011-2014 Twitter, Inc.
6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 * ======================================================================== */
13 // ALERT CLASS DEFINITION
14 // ======================
16 var dismiss = '[data-dismiss="alert"]'
17 var Alert = function (el) {
18 $(el).on('click', dismiss, this.close)
21 Alert.VERSION = '3.2.0'
23 Alert.prototype.close = function (e) {
25 var selector = $this.attr('data-target')
28 selector = $this.attr('href')
29 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
32 var $parent = $(selector)
34 if (e) e.preventDefault()
36 if (!$parent.length) {
37 $parent = $this.hasClass('alert') ? $this : $this.parent()
40 $parent.trigger(e = $.Event('close.bs.alert'))
42 if (e.isDefaultPrevented()) return
44 $parent.removeClass('in')
46 function removeElement() {
47 // detach from parent, fire event then clean up data
48 $parent.detach().trigger('closed.bs.alert').remove()
51 $.support.transition && $parent.hasClass('fade') ?
53 .one('bsTransitionEnd', removeElement)
54 .emulateTransitionEnd(150) :
59 // ALERT PLUGIN DEFINITION
60 // =======================
62 function Plugin(option) {
63 return this.each(function () {
65 var data = $this.data('bs.alert')
67 if (!data) $this.data('bs.alert', (data = new Alert(this)))
68 if (typeof option == 'string') data[option].call($this)
75 $.fn.alert.Constructor = Alert
81 $.fn.alert.noConflict = function () {
90 $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)