diff --git a/js/bootstrap-alerts.js b/js/bootstrap-alerts.js index 82bcac5246..4498270cb9 100644 --- a/js/bootstrap-alerts.js +++ b/js/bootstrap-alerts.js @@ -53,7 +53,7 @@ var Alert = function ( content, selector ) { this.$element = $(content) - .delegate(selector || '.close', 'click', this.close) + .delegate('[data-alert-dismiss]', 'click', this.close) } Alert.prototype = { @@ -62,6 +62,8 @@ var $element = $(this).parent('.alert-message') e && e.preventDefault() + e && e.stopPropagation() + $element.removeClass('in') function removeElement () { @@ -98,7 +100,7 @@ } $(document).ready(function () { - new Alert($('body'), '.alert-message[data-alert] .close') + new Alert($('body')) }) })( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js index 75320c0f87..6379653c56 100644 --- a/js/bootstrap-dropdown.js +++ b/js/bootstrap-dropdown.js @@ -20,23 +20,14 @@ (function( $ ){ - var d = '.dropdown-toggle' - - function clearMenus() { - $(d).parent('li').removeClass('open') - } - - $(function () { - $('html').bind("click", clearMenus) - $('body').dropdown( '[data-dropdown] .dropdown-toggle' ) - }) + var d = '[data-dropdown]' /* DROPDOWN PLUGIN DEFINITION * ========================== */ - $.fn.dropdown = function ( selector ) { + $.fn.dropdown = function () { return this.each(function () { - $(this).delegate(selector || d, 'click', function (e) { + $(this).delegate(d, 'click', function (e) { var li = $(this).parent('li') , isActive = li.hasClass('open') @@ -47,4 +38,16 @@ }) } + /* APPLY TO STANDARD DROPDOWN ELEMENTS + * =================================== */ + + function clearMenus() { + $(d).parent('li').removeClass('open') + } + + $(function () { + $('html').bind("click", clearMenus) + $('body').dropdown() + }) + })( window.jQuery || window.ender ) \ No newline at end of file diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js index 5c38a7477b..c8d41a50b2 100644 --- a/js/bootstrap-modal.js +++ b/js/bootstrap-modal.js @@ -18,7 +18,7 @@ * ========================================================= */ -(function( $ ){ +!function( $ ){ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) * ======================================================= */ @@ -53,16 +53,12 @@ * ============================= */ var Modal = function ( content, options ) { - this.settings = $.extend({}, $.fn.modal.defaults) + this.settings = $.extend({}, $.fn.modal.defaults, options) this.$element = $(content) - .delegate('.js-dismiss', 'click.modal', $.proxy(this.hide, this)) + .delegate('[data-modal-dismiss]', $.proxy(this.hide, this)) - if ( options ) { - $.extend( this.settings, options ) - - if ( options.show ) { - this.show() - } + if ( this.settings.show ) { + this.show() } return this @@ -81,15 +77,23 @@ escape.call(this) backdrop.call(this, function () { + var transition = $.support.transition && that.$element.hasClass('fade') + that.$element .appendTo(document.body) .show() - setTimeout(function () { - that.$element - .addClass('in') - .trigger('shown') - }, 1) + if (transition) { + that.$element[0].offsetWidth // force reflow + } + + that.$element + .addClass('in') + + transition ? + that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) : + that.$element.trigger('shown') + }) return this @@ -98,6 +102,10 @@ , hide: function (e) { e && e.preventDefault() + if ( !this.isShown ) { + return this + } + var that = this this.isShown = false @@ -132,16 +140,25 @@ var that = this , animate = this.$element.hasClass('fade') ? 'fade' : '' if ( this.isShown && this.settings.backdrop ) { + var doAnimate = $.support.transition && animate + this.$backdrop = $('