app/assets/javascripts/bootstrap/bootstrap.js in bootstrap-rails-engine-3.0.0.2 vs app/assets/javascripts/bootstrap/bootstrap.js in bootstrap-rails-engine-3.0.0.3
- old
+ new
@@ -47,11 +47,11 @@
}
}
// http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) {
- var called = false, $el = this
+ var called = false, $el = this
$(this).one($.support.transition.end, function () { called = true })
var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
setTimeout(callback, duration)
return this
}
@@ -709,11 +709,11 @@
var isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
- if ('ontouchstart' in document.documentElement) {
+ if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
// if mobile we we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
}
$parent.trigger(e = $.Event('show.bs.dropdown'))
@@ -721,14 +721,14 @@
if (e.isDefaultPrevented()) return
$parent
.toggleClass('open')
.trigger('shown.bs.dropdown')
+
+ $this.focus()
}
- $this.focus()
-
return false
}
Dropdown.prototype.keydown = function (e) {
if (!/(38|40|27)/.test(e.keyCode)) return
@@ -849,11 +849,11 @@
// MODAL CLASS DEFINITION
// ======================
var Modal = function (element, options) {
this.options = options
- this.$element = $(element).on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+ this.$element = $(element)
this.$backdrop =
this.isShown = null
if (this.options.remote) this.$element.load(this.options.remote)
}
@@ -878,10 +878,12 @@
this.isShown = true
this.escape()
+ this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+
this.backdrop(function () {
var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) {
that.$element.appendTo(document.body) // don't move modals dom position
@@ -900,11 +902,11 @@
that.enforceFocus()
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
transition ?
- that.$element
+ that.$element.find('.modal-dialog') // wait for modal to slide in
.one($.support.transition.end, function () {
that.$element.focus().trigger(e)
})
.emulateTransitionEnd(300) :
that.$element.focus().trigger(e)
@@ -1062,11 +1064,11 @@
$this.is(':visible') && $this.focus()
})
})
$(document)
- .on('shown.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
+ .on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
.on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
}(window.jQuery);
/* ========================================================================
@@ -1177,28 +1179,30 @@
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
clearTimeout(self.timeout)
+ self.hoverState = 'in'
+
if (!self.options.delay || !self.options.delay.show) return self.show()
- self.hoverState = 'in'
- self.timeout = setTimeout(function () {
+ self.timeout = setTimeout(function () {
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
}
Tooltip.prototype.leave = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
clearTimeout(self.timeout)
+ self.hoverState = 'out'
+
if (!self.options.delay || !self.options.delay.hide) return self.hide()
- self.hoverState = 'out'
- self.timeout = setTimeout(function () {
+ self.timeout = setTimeout(function () {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
}
Tooltip.prototype.show = function () {
@@ -1327,10 +1331,12 @@
Tooltip.prototype.hide = function () {
var that = this
var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type)
- function complete() { $tip.detach() }
+ function complete() {
+ if (that.hoverState != 'in') $tip.detach()
+ }
this.$element.trigger(e)
if (e.isDefaultPrevented()) return