vendor/assets/javascripts/bootstrap/alerts.js in css-bootstrap-rails-0.0.6 vs vendor/assets/javascripts/bootstrap/alerts.js in css-bootstrap-rails-0.0.7

- old
+ new

@@ -1,7 +1,7 @@ /* ========================================================== - * bootstrap-alerts.js v1.4.0 + * bootstrap-alert.js v2.0.0 * http://twitter.github.com/bootstrap/javascript.html#alerts * ========================================================== * Copyright 2011 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,94 +20,59 @@ !function( $ ){ "use strict" - /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) - * ======================================================= */ - - var transitionEnd - - $(document).ready(function () { - - $.support.transition = (function () { - var thisBody = document.body || document.documentElement - , thisStyle = thisBody.style - , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined - return support - })() - - // set CSS transition event type - if ( $.support.transition ) { - transitionEnd = "TransitionEnd" - if ( $.browser.webkit ) { - transitionEnd = "webkitTransitionEnd" - } else if ( $.browser.mozilla ) { - transitionEnd = "transitionend" - } else if ( $.browser.opera ) { - transitionEnd = "oTransitionEnd" - } - } - - }) - /* ALERT CLASS DEFINITION * ====================== */ - var Alert = function ( content, options ) { - this.settings = $.extend({}, $.fn.alert.defaults, options) - this.$element = $(content) - .delegate(this.settings.selector, 'click', this.close) - } + var dismiss = '[data-dismiss="alert"]' + , Alert = function ( el ) { + $(el).delegate(dismiss, 'click', this.close) + } Alert.prototype = { - close: function (e) { - var $element = $(this).parent('.alert-message') + constructor: Alert + , close: function ( e ) { + var $element = $(this) + + $element = $element.hasClass('alert-message') ? $element : $element.parent() e && e.preventDefault() $element.removeClass('in') - function removeElement () { + function removeElement() { $element.remove() } $.support.transition && $element.hasClass('fade') ? - $element.bind(transitionEnd, removeElement) : + $element.bind($.support.transition.end, removeElement) : removeElement() } } /* ALERT PLUGIN DEFINITION * ======================= */ - $.fn.alert = function ( options ) { - - if ( options === true ) { - return this.data('alert') - } - + $.fn.alert = function ( option ) { return this.each(function () { var $this = $(this) - - if ( typeof options == 'string' ) { - return $this.data('alert')[options]() - } - - $(this).data('alert', new Alert( this, options )) - + , data = $this.data('alert') + if (!data) $this.data('alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) }) } - $.fn.alert.defaults = { - selector: '.close' - } + $.fn.alert.Alert = Alert - $(document).ready(function () { - new Alert($('body'), { - selector: '.alert-message[data-alert] .close' - }) + + /* ALERT DATA-API + * ============== */ + + $(function () { + $('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close) }) -}( window.jQuery || window.ender ); +}( window.jQuery || window.ender ) \ No newline at end of file