vendor/assets/javascripts/bootstrap-alert.js in bootstrapped-1.0.1 vs vendor/assets/javascripts/bootstrap-alert.js in bootstrapped-2.0.3
- old
+ new
@@ -1,7 +1,7 @@
/* ==========================================================
- * bootstrap-alert.js v2.0.0
+ * bootstrap-alert.js v2.0.3
* http://twitter.github.com/bootstrap/javascript.html#alerts
* ==========================================================
* Copyright 2012 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,62 +16,61 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
-!function( $ ){
+!function ($) {
- "use strict"
+ "use strict"; // jshint ;_;
+
/* ALERT CLASS DEFINITION
* ====================== */
var dismiss = '[data-dismiss="alert"]'
- , Alert = function ( el ) {
+ , Alert = function (el) {
$(el).on('click', dismiss, this.close)
}
- Alert.prototype = {
+ Alert.prototype.close = function (e) {
+ var $this = $(this)
+ , selector = $this.attr('data-target')
+ , $parent
- constructor: Alert
+ if (!selector) {
+ selector = $this.attr('href')
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
+ }
- , close: function ( e ) {
- var $this = $(this)
- , selector = $this.attr('data-target')
- , $parent
+ $parent = $(selector)
- if (!selector) {
- selector = $this.attr('href')
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
- }
+ e && e.preventDefault()
- $parent = $(selector)
- $parent.trigger('close')
+ $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
- e && e.preventDefault()
+ $parent.trigger(e = $.Event('close'))
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
+ if (e.isDefaultPrevented()) return
- $parent.removeClass('in')
+ $parent.removeClass('in')
- function removeElement() {
- $parent.remove()
- $parent.trigger('closed')
- }
-
- $.support.transition && $parent.hasClass('fade') ?
- $parent.on($.support.transition.end, removeElement) :
- removeElement()
+ function removeElement() {
+ $parent
+ .trigger('closed')
+ .remove()
}
+ $.support.transition && $parent.hasClass('fade') ?
+ $parent.on($.support.transition.end, removeElement) :
+ removeElement()
}
/* ALERT PLUGIN DEFINITION
* ======================= */
- $.fn.alert = function ( option ) {
+ $.fn.alert = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('alert')
if (!data) $this.data('alert', (data = new Alert(this)))
if (typeof option == 'string') data[option].call($this)
@@ -86,6 +85,6 @@
$(function () {
$('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
})
-}( window.jQuery )
+}(window.jQuery);
\ No newline at end of file