Renamed files, 1:1 like in BS3.
This commit is contained in:
parent
88cc1cc401
commit
9a77ee67de
8 changed files with 87 additions and 58 deletions
|
@ -56,7 +56,9 @@
|
||||||
var $parent = this.$element.closest('[data-toggle="buttons"]')
|
var $parent = this.$element.closest('[data-toggle="buttons"]')
|
||||||
|
|
||||||
if ($parent.length) {
|
if ($parent.length) {
|
||||||
var $input = this.$element.find('input').prop('checked', !this.$element.hasClass('active'))
|
var $input = this.$element.find('input')
|
||||||
|
.prop('checked', !this.$element.hasClass('active'))
|
||||||
|
.trigger('change')
|
||||||
if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
|
if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +74,7 @@
|
||||||
$.fn.button = function (option) {
|
$.fn.button = function (option) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var $this = $(this)
|
var $this = $(this)
|
||||||
var data = $this.data('button')
|
var data = $this.data('bs.button')
|
||||||
var options = typeof option == 'object' && option
|
var options = typeof option == 'object' && option
|
||||||
|
|
||||||
if (!data) $this.data('bs.button', (data = new Button(this, options)))
|
if (!data) $this.data('bs.button', (data = new Button(this, options)))
|
|
@ -48,7 +48,7 @@
|
||||||
this.$element.trigger(startEvent)
|
this.$element.trigger(startEvent)
|
||||||
if (startEvent.isDefaultPrevented()) return
|
if (startEvent.isDefaultPrevented()) return
|
||||||
|
|
||||||
var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
|
var actives = this.$parent && this.$parent.find('> .panel > .in')
|
||||||
|
|
||||||
if (actives && actives.length) {
|
if (actives && actives.length) {
|
||||||
var hasData = actives.data('bs.collapse')
|
var hasData = actives.data('bs.collapse')
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
var $parent = parent && $(parent)
|
var $parent = parent && $(parent)
|
||||||
|
|
||||||
if (!data || !data.transitioning) {
|
if (!data || !data.transitioning) {
|
||||||
if ($parent) $parent.find('[data-toggle=collapse][data-parent=' + parent + ']').not($this).addClass('collapsed')
|
if ($parent) $parent.find('[data-toggle=collapse][data-parent="' + parent + '"]').not($this).addClass('collapsed')
|
||||||
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
$this[$target.hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
clearMenus()
|
clearMenus()
|
||||||
|
|
||||||
if (!isActive) {
|
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
|
// if mobile we we use a backdrop because click events don't delegate
|
||||||
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
|
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@
|
||||||
$parent
|
$parent
|
||||||
.toggleClass('open')
|
.toggleClass('open')
|
||||||
.trigger('shown.bs.dropdown')
|
.trigger('shown.bs.dropdown')
|
||||||
}
|
|
||||||
|
|
||||||
$this.focus()
|
$this.focus()
|
||||||
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
|
@ -25,11 +25,11 @@
|
||||||
|
|
||||||
var Modal = function (element, options) {
|
var Modal = function (element, options) {
|
||||||
this.options = options
|
this.options = options
|
||||||
this.$element = $(element).on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
|
this.$element = $(element)
|
||||||
this.$backdrop =
|
this.$backdrop =
|
||||||
this.isShown = null
|
this.isShown = null
|
||||||
|
|
||||||
if (this.options.remote) this.$element.find('.modal-body').load(this.options.remote)
|
if (this.options.remote) this.$element.load(this.options.remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.DEFAULTS = {
|
Modal.DEFAULTS = {
|
||||||
|
@ -38,13 +38,13 @@
|
||||||
, show: true
|
, show: true
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.toggle = function () {
|
Modal.prototype.toggle = function (_relatedTarget) {
|
||||||
return this[!this.isShown ? 'show' : 'hide']()
|
return this[!this.isShown ? 'show' : 'hide'](_relatedTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
Modal.prototype.show = function () {
|
Modal.prototype.show = function (_relatedTarget) {
|
||||||
var that = this
|
var that = this
|
||||||
var e = $.Event('show.bs.modal')
|
var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget })
|
||||||
|
|
||||||
this.$element.trigger(e)
|
this.$element.trigger(e)
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@
|
||||||
|
|
||||||
this.escape()
|
this.escape()
|
||||||
|
|
||||||
|
this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
|
||||||
|
|
||||||
this.backdrop(function () {
|
this.backdrop(function () {
|
||||||
var transition = $.support.transition && that.$element.hasClass('fade')
|
var transition = $.support.transition && that.$element.hasClass('fade')
|
||||||
|
|
||||||
|
@ -73,13 +75,15 @@
|
||||||
|
|
||||||
that.enforceFocus()
|
that.enforceFocus()
|
||||||
|
|
||||||
|
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
|
||||||
|
|
||||||
transition ?
|
transition ?
|
||||||
that.$element
|
that.$element.find('.modal-dialog') // wait for modal to slide in
|
||||||
.one($.support.transition.end, function () {
|
.one($.support.transition.end, function () {
|
||||||
that.$element.focus().trigger('shown.bs.modal')
|
that.$element.focus().trigger(e)
|
||||||
})
|
})
|
||||||
.emulateTransitionEnd(300) :
|
.emulateTransitionEnd(300) :
|
||||||
that.$element.focus().trigger('shown.bs.modal')
|
that.$element.focus().trigger(e)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +105,7 @@
|
||||||
this.$element
|
this.$element
|
||||||
.removeClass('in')
|
.removeClass('in')
|
||||||
.attr('aria-hidden', true)
|
.attr('aria-hidden', true)
|
||||||
|
.off('click.dismiss.modal')
|
||||||
|
|
||||||
$.support.transition && this.$element.hasClass('fade') ?
|
$.support.transition && this.$element.hasClass('fade') ?
|
||||||
this.$element
|
this.$element
|
||||||
|
@ -153,7 +158,7 @@
|
||||||
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
||||||
.appendTo(document.body)
|
.appendTo(document.body)
|
||||||
|
|
||||||
this.$element.on('click', $.proxy(function (e) {
|
this.$element.on('click.dismiss.modal', $.proxy(function (e) {
|
||||||
if (e.target !== e.currentTarget) return
|
if (e.target !== e.currentTarget) return
|
||||||
this.options.backdrop == 'static'
|
this.options.backdrop == 'static'
|
||||||
? this.$element[0].focus.call(this.$element[0])
|
? this.$element[0].focus.call(this.$element[0])
|
||||||
|
@ -192,15 +197,15 @@
|
||||||
|
|
||||||
var old = $.fn.modal
|
var old = $.fn.modal
|
||||||
|
|
||||||
$.fn.modal = function (option) {
|
$.fn.modal = function (option, _relatedTarget) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
var $this = $(this)
|
var $this = $(this)
|
||||||
var data = $this.data('bs.modal')
|
var data = $this.data('bs.modal')
|
||||||
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
||||||
|
|
||||||
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
||||||
if (typeof option == 'string') data[option]()
|
if (typeof option == 'string') data[option](_relatedTarget)
|
||||||
else if (options.show) data.show()
|
else if (options.show) data.show(_relatedTarget)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,21 +228,19 @@
|
||||||
var $this = $(this)
|
var $this = $(this)
|
||||||
var href = $this.attr('href')
|
var href = $this.attr('href')
|
||||||
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
|
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
|
||||||
var option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
|
var option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
|
||||||
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
$target
|
$target
|
||||||
.modal(option)
|
.modal(option, this)
|
||||||
.one('hide', function () {
|
.one('hide', function () {
|
||||||
$this.is(':visible') && $this.focus()
|
$this.is(':visible') && $this.focus()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$(function () {
|
$(document)
|
||||||
var $body = $(document.body)
|
.on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
|
||||||
.on('shown.bs.modal', '.modal', function () { $body.addClass('modal-open') })
|
.on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
|
||||||
.on('hidden.bs.modal', '.modal', function () { $body.removeClass('modal-open') })
|
|
||||||
})
|
|
||||||
|
|
||||||
}(window.jQuery);
|
}(window.jQuery);
|
|
@ -58,7 +58,9 @@
|
||||||
|
|
||||||
$tip.removeClass('fade top bottom left right in')
|
$tip.removeClass('fade top bottom left right in')
|
||||||
|
|
||||||
$tip.find('.popover-title:empty').hide()
|
// IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
|
||||||
|
// this manually by checking the contents.
|
||||||
|
if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
Popover.prototype.hasContent = function () {
|
Popover.prototype.hasContent = function () {
|
||||||
|
@ -75,15 +77,15 @@
|
||||||
o.content)
|
o.content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Popover.prototype.arrow = function () {
|
||||||
|
return this.$arrow = this.$arrow || this.tip().find('.arrow')
|
||||||
|
}
|
||||||
|
|
||||||
Popover.prototype.tip = function () {
|
Popover.prototype.tip = function () {
|
||||||
if (!this.$tip) this.$tip = $(this.options.template)
|
if (!this.$tip) this.$tip = $(this.options.template)
|
||||||
return this.$tip
|
return this.$tip
|
||||||
}
|
}
|
||||||
|
|
||||||
Popover.prototype.destroy = function () {
|
|
||||||
this.hide().$element.off('.' + this.type).removeData(this.type)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// POPOVER PLUGIN DEFINITION
|
// POPOVER PLUGIN DEFINITION
|
||||||
// =========================
|
// =========================
|
|
@ -1,6 +1,6 @@
|
||||||
/* ========================================================================
|
/* ========================================================================
|
||||||
* Bootstrap: tooltip.js v3.0.0
|
* Bootstrap: tooltip.js v3.0.0
|
||||||
* http://twbs.github.com/bootstrap/javascript.html#affix
|
* http://twbs.github.com/bootstrap/javascript.html#tooltip
|
||||||
* Inspired by the original jQuery.tipsy by Jason Frame
|
* Inspired by the original jQuery.tipsy by Jason Frame
|
||||||
* ========================================================================
|
* ========================================================================
|
||||||
* Copyright 2012 Twitter, Inc.
|
* Copyright 2012 Twitter, Inc.
|
||||||
|
@ -91,22 +91,27 @@
|
||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.enter = function (obj) {
|
Tooltip.prototype.getDelegateOptions = function () {
|
||||||
var defaults = this.getDefaults()
|
|
||||||
var options = {}
|
var options = {}
|
||||||
|
var defaults = this.getDefaults()
|
||||||
|
|
||||||
this._options && $.each(this._options, function (key, value) {
|
this._options && $.each(this._options, function (key, value) {
|
||||||
if (defaults[key] != value) options[key] = value
|
if (defaults[key] != value) options[key] = value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return options
|
||||||
|
}
|
||||||
|
|
||||||
|
Tooltip.prototype.enter = function (obj) {
|
||||||
var self = obj instanceof this.constructor ?
|
var self = obj instanceof this.constructor ?
|
||||||
obj : $(obj.currentTarget)[this.type](options).data('bs.' + this.type)
|
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
|
||||||
|
|
||||||
clearTimeout(self.timeout)
|
clearTimeout(self.timeout)
|
||||||
|
|
||||||
|
self.hoverState = 'in'
|
||||||
|
|
||||||
if (!self.options.delay || !self.options.delay.show) return self.show()
|
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()
|
if (self.hoverState == 'in') self.show()
|
||||||
}, self.options.delay.show)
|
}, self.options.delay.show)
|
||||||
|
@ -114,13 +119,14 @@
|
||||||
|
|
||||||
Tooltip.prototype.leave = function (obj) {
|
Tooltip.prototype.leave = function (obj) {
|
||||||
var self = obj instanceof this.constructor ?
|
var self = obj instanceof this.constructor ?
|
||||||
obj : $(obj.currentTarget)[this.type](this._options).data('bs.' + this.type)
|
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
|
||||||
|
|
||||||
clearTimeout(self.timeout)
|
clearTimeout(self.timeout)
|
||||||
|
|
||||||
|
self.hoverState = 'out'
|
||||||
|
|
||||||
if (!self.options.delay || !self.options.delay.hide) return self.hide()
|
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()
|
if (self.hoverState == 'out') self.hide()
|
||||||
}, self.options.delay.hide)
|
}, self.options.delay.hide)
|
||||||
|
@ -179,12 +185,9 @@
|
||||||
.addClass(placement)
|
.addClass(placement)
|
||||||
}
|
}
|
||||||
|
|
||||||
var tp = placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
|
||||||
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
|
||||||
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
|
|
||||||
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
|
|
||||||
|
|
||||||
this.applyPlacement(tp, placement)
|
this.applyPlacement(calculatedOffset, placement)
|
||||||
this.$element.trigger('shown.bs.' + this.type)
|
this.$element.trigger('shown.bs.' + this.type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,13 +199,21 @@
|
||||||
var height = $tip[0].offsetHeight
|
var height = $tip[0].offsetHeight
|
||||||
|
|
||||||
// manually read margins because getBoundingClientRect includes difference
|
// manually read margins because getBoundingClientRect includes difference
|
||||||
offset.top = offset.top + parseInt($tip.css('margin-top'), 10)
|
var marginTop = parseInt($tip.css('margin-top'), 10)
|
||||||
offset.left = offset.left + parseInt($tip.css('margin-left'), 10)
|
var marginLeft = parseInt($tip.css('margin-left'), 10)
|
||||||
|
|
||||||
|
// we must check for NaN for ie 8/9
|
||||||
|
if (isNaN(marginTop)) marginTop = 0
|
||||||
|
if (isNaN(marginLeft)) marginLeft = 0
|
||||||
|
|
||||||
|
offset.top = offset.top + marginTop
|
||||||
|
offset.left = offset.left + marginLeft
|
||||||
|
|
||||||
$tip
|
$tip
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.addClass('in')
|
.addClass('in')
|
||||||
|
|
||||||
|
// check to see if placing tip in new offset caused the tip to resize itself
|
||||||
var actualWidth = $tip[0].offsetWidth
|
var actualWidth = $tip[0].offsetWidth
|
||||||
var actualHeight = $tip[0].offsetHeight
|
var actualHeight = $tip[0].offsetHeight
|
||||||
|
|
||||||
|
@ -211,10 +222,10 @@
|
||||||
offset.top = offset.top + height - actualHeight
|
offset.top = offset.top + height - actualHeight
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placement == 'bottom' || placement == 'top') {
|
if (/bottom|top/.test(placement)) {
|
||||||
var delta = 0
|
var delta = 0
|
||||||
|
|
||||||
if (offset.left < 0){
|
if (offset.left < 0) {
|
||||||
delta = offset.left * -2
|
delta = offset.left * -2
|
||||||
offset.left = 0
|
offset.left = 0
|
||||||
|
|
||||||
|
@ -249,6 +260,10 @@
|
||||||
var $tip = this.tip()
|
var $tip = this.tip()
|
||||||
var e = $.Event('hide.bs.' + this.type)
|
var e = $.Event('hide.bs.' + this.type)
|
||||||
|
|
||||||
|
function complete() {
|
||||||
|
if (that.hoverState != 'in') $tip.detach()
|
||||||
|
}
|
||||||
|
|
||||||
this.$element.trigger(e)
|
this.$element.trigger(e)
|
||||||
|
|
||||||
if (e.isDefaultPrevented()) return
|
if (e.isDefaultPrevented()) return
|
||||||
|
@ -257,9 +272,9 @@
|
||||||
|
|
||||||
$.support.transition && this.$tip.hasClass('fade') ?
|
$.support.transition && this.$tip.hasClass('fade') ?
|
||||||
$tip
|
$tip
|
||||||
.one($.support.transition.end, $tip.detach)
|
.one($.support.transition.end, complete)
|
||||||
.emulateTransitionEnd(150) :
|
.emulateTransitionEnd(150) :
|
||||||
$tip.detach()
|
complete()
|
||||||
|
|
||||||
this.$element.trigger('hidden.bs.' + this.type)
|
this.$element.trigger('hidden.bs.' + this.type)
|
||||||
|
|
||||||
|
@ -285,6 +300,13 @@
|
||||||
}, this.$element.offset())
|
}, this.$element.offset())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
|
||||||
|
return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
||||||
|
placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
|
||||||
|
placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
|
||||||
|
/* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
|
||||||
|
}
|
||||||
|
|
||||||
Tooltip.prototype.getTitle = function () {
|
Tooltip.prototype.getTitle = function () {
|
||||||
var title
|
var title
|
||||||
var $e = this.$element
|
var $e = this.$element
|
||||||
|
@ -300,8 +322,8 @@
|
||||||
return this.$tip = this.$tip || $(this.options.template)
|
return this.$tip = this.$tip || $(this.options.template)
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.arrow =function(){
|
Tooltip.prototype.arrow = function () {
|
||||||
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
|
return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.validate = function () {
|
Tooltip.prototype.validate = function () {
|
||||||
|
@ -325,7 +347,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
Tooltip.prototype.toggle = function (e) {
|
Tooltip.prototype.toggle = function (e) {
|
||||||
var self = e ? $(e.currentTarget)[this.type](this._options).data('bs.' + this.type) : this
|
var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
|
||||||
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
|
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue