1 /* ==========================================================
2 * bootstrap-alert.js v2.0.4
3 * http://twitter.github.com/bootstrap/javascript.html#alerts
4 * ==========================================================
5 * Copyright 2012 Twitter, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ========================================================== */
23 "use strict"; // jshint ;_;
26 /* ALERT CLASS DEFINITION
27 * ====================== */
29 var dismiss = '[data-dismiss="alert"]'
30 , Alert = function (el) {
31 $(el).on('click', dismiss, this.close)
34 Alert.prototype.close = function (e) {
36 , selector = $this.attr('data-target')
40 selector = $this.attr('href')
41 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
46 e && e.preventDefault()
48 $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
50 $parent.trigger(e = $.Event('close'))
52 if (e.isDefaultPrevented()) return
54 $parent.removeClass('in')
56 function removeElement() {
62 $.support.transition && $parent.hasClass('fade') ?
63 $parent.on($.support.transition.end, removeElement) :
68 /* ALERT PLUGIN DEFINITION
69 * ======================= */
71 $.fn.alert = function (option) {
72 return this.each(function () {
74 , data = $this.data('alert')
75 if (!data) $this.data('alert', (data = new Alert(this)))
76 if (typeof option == 'string') data[option].call($this)
80 $.fn.alert.Constructor = Alert
87 $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)