Update bootstrap code

This commit is contained in:
Tom Hughes 2015-03-09 22:30:54 +00:00
parent db66e48847
commit e0c9b2e7fe
3 changed files with 509 additions and 406 deletions

View file

@ -6,8 +6,8 @@ folder 'vendor/assets' do
end end
folder 'bootstrap' do folder 'bootstrap' do
file 'bootstrap.tooltip.js', 'https://raw.githubusercontent.com/twbs/bootstrap/v2.3.2/js/bootstrap-tooltip.js' file 'bootstrap.tooltip.js', 'https://raw.githubusercontent.com/twbs/bootstrap/v3.3.2/js/tooltip.js'
file 'bootstrap.dropdown.js', 'https://raw.githubusercontent.com/twbs/bootstrap/v2.3.2/js/bootstrap-dropdown.js' file 'bootstrap.dropdown.js', 'https://raw.githubusercontent.com/twbs/bootstrap/v3.3.2/js/dropdown.js'
end end
folder 'leaflet' do folder 'leaflet' do

View file

@ -1,155 +1,145 @@
/* ============================================================ /* ========================================================================
* bootstrap-dropdown.js v2.3.2 * Bootstrap: dropdown.js v3.3.2
* http://getbootstrap.com/2.3.2/javascript.html#dropdowns * http://getbootstrap.com/javascript/#dropdowns
* ============================================================ * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2015 Twitter, Inc.
* * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Licensed under the Apache License, Version 2.0 (the "License"); * ======================================================================== */
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============================================================ */
!function ($) { +function ($) {
'use strict';
"use strict"; // jshint ;_; // DROPDOWN CLASS DEFINITION
// =========================
/* DROPDOWN CLASS DEFINITION
* ========================= */
var toggle = '[data-toggle=dropdown]'
, Dropdown = function (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', function () {
$el.parent().removeClass('open')
})
}
Dropdown.prototype = {
constructor: Dropdown
, toggle: function (e) {
var $this = $(this)
, $parent
, isActive
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement) {
// if mobile we we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
}
$parent.toggleClass('open')
}
$this.focus()
return false
}
, keydown: function (e) {
var $this
, $items
, $active
, $parent
, isActive
, index
if (!/(38|40|27)/.test(e.keyCode)) return
$this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).focus()
return $this.click()
}
$items = $('[role=menu] li:not(.divider):visible a', $parent)
if (!$items.length) return
index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items
.eq(index)
.focus()
}
var backdrop = '.dropdown-backdrop'
var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle)
} }
function clearMenus() { Dropdown.VERSION = '3.3.2'
$('.dropdown-backdrop').remove()
Dropdown.prototype.toggle = function (e) {
var $this = $(this)
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
// if mobile we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
}
var relatedTarget = { relatedTarget: this }
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this
.trigger('focus')
.attr('aria-expanded', 'true')
$parent
.toggleClass('open')
.trigger('shown.bs.dropdown', relatedTarget)
}
return false
}
Dropdown.prototype.keydown = function (e) {
if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
var $this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
if ((!isActive && e.which != 27) || (isActive && e.which == 27)) {
if (e.which == 27) $parent.find(toggle).trigger('focus')
return $this.trigger('click')
}
var desc = ' li:not(.divider):visible a'
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
if (!$items.length) return
var index = $items.index(e.target)
if (e.which == 38 && index > 0) index-- // up
if (e.which == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items.eq(index).trigger('focus')
}
function clearMenus(e) {
if (e && e.which === 3) return
$(backdrop).remove()
$(toggle).each(function () { $(toggle).each(function () {
getParent($(this)).removeClass('open') var $this = $(this)
var $parent = getParent($this)
var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this.attr('aria-expanded', 'false')
$parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
}) })
} }
function getParent($this) { function getParent($this) {
var selector = $this.attr('data-target') var selector = $this.attr('data-target')
, $parent
if (!selector) { if (!selector) {
selector = $this.attr('href') selector = $this.attr('href')
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
} }
$parent = selector && $(selector) var $parent = selector && $(selector)
if (!$parent || !$parent.length) $parent = $this.parent() return $parent && $parent.length ? $parent : $this.parent()
return $parent
} }
/* DROPDOWN PLUGIN DEFINITION // DROPDOWN PLUGIN DEFINITION
* ========================== */ // ==========================
var old = $.fn.dropdown function Plugin(option) {
$.fn.dropdown = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('dropdown') var data = $this.data('bs.dropdown')
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
if (typeof option == 'string') data[option].call($this) if (typeof option == 'string') data[option].call($this)
}) })
} }
var old = $.fn.dropdown
$.fn.dropdown = Plugin
$.fn.dropdown.Constructor = Dropdown $.fn.dropdown.Constructor = Dropdown
/* DROPDOWN NO CONFLICT // DROPDOWN NO CONFLICT
* ==================== */ // ====================
$.fn.dropdown.noConflict = function () { $.fn.dropdown.noConflict = function () {
$.fn.dropdown = old $.fn.dropdown = old
@ -157,13 +147,15 @@
} }
/* APPLY TO STANDARD DROPDOWN ELEMENTS // APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */ // ===================================
$(document) $(document)
.on('click.dropdown.data-api', clearMenus) .on('click.bs.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) .on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
.on('keydown.bs.dropdown.data-api', '[role="menu"]', Dropdown.prototype.keydown)
.on('keydown.bs.dropdown.data-api', '[role="listbox"]', Dropdown.prototype.keydown)
}(window.jQuery); }(jQuery);

View file

@ -1,361 +1,472 @@
/* =========================================================== /* ========================================================================
* bootstrap-tooltip.js v2.3.2 * Bootstrap: tooltip.js v3.3.2
* http://getbootstrap.com/2.3.2/javascript.html#tooltips * http://getbootstrap.com/javascript/#tooltip
* Inspired by the original jQuery.tipsy by Jason Frame * Inspired by the original jQuery.tipsy by Jason Frame
* =========================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2015 Twitter, Inc.
* * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Licensed under the Apache License, Version 2.0 (the "License"); * ======================================================================== */
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================== */
!function ($) { +function ($) {
'use strict';
"use strict"; // jshint ;_; // TOOLTIP PUBLIC CLASS DEFINITION
// ===============================
/* TOOLTIP PUBLIC CLASS DEFINITION
* =============================== */
var Tooltip = function (element, options) { var Tooltip = function (element, options) {
this.type =
this.options =
this.enabled =
this.timeout =
this.hoverState =
this.$element = null
this.init('tooltip', element, options) this.init('tooltip', element, options)
} }
Tooltip.prototype = { Tooltip.VERSION = '3.3.2'
constructor: Tooltip Tooltip.TRANSITION_DURATION = 150
, init: function (type, element, options) { Tooltip.DEFAULTS = {
var eventIn animation: true,
, eventOut placement: 'top',
, triggers selector: false,
, trigger template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
, i trigger: 'hover focus',
title: '',
delay: 0,
html: false,
container: false,
viewport: {
selector: 'body',
padding: 0
}
}
this.type = type Tooltip.prototype.init = function (type, element, options) {
this.$element = $(element) this.enabled = true
this.options = this.getOptions(options) this.type = type
this.enabled = true this.$element = $(element)
this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
triggers = this.options.trigger.split(' ') var triggers = this.options.trigger.split(' ')
for (i = triggers.length; i--;) { for (var i = triggers.length; i--;) {
trigger = triggers[i] var trigger = triggers[i]
if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) if (trigger == 'click') {
} else if (trigger != 'manual') { this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' } else if (trigger != 'manual') {
eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this)) var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
} this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
} }
this.options.selector ?
(this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
} }
, getOptions: function (options) { this.options.selector ?
options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options) (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
this.fixTitle()
}
if (options.delay && typeof options.delay == 'number') { Tooltip.prototype.getDefaults = function () {
options.delay = { return Tooltip.DEFAULTS
show: options.delay }
, hide: options.delay
} Tooltip.prototype.getOptions = function (options) {
options = $.extend({}, this.getDefaults(), this.$element.data(), options)
if (options.delay && typeof options.delay == 'number') {
options.delay = {
show: options.delay,
hide: options.delay
} }
return options
} }
, enter: function (e) { return options
var defaults = $.fn[this.type].defaults }
, options = {}
, self
this._options && $.each(this._options, function (key, value) { Tooltip.prototype.getDelegateOptions = function () {
if (defaults[key] != value) options[key] = value var options = {}
}, this) var defaults = this.getDefaults()
self = $(e.currentTarget)[this.type](options).data(this.type) this._options && $.each(this._options, function (key, value) {
if (defaults[key] != value) options[key] = value
})
if (!self.options.delay || !self.options.delay.show) return self.show() return options
}
clearTimeout(this.timeout) Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget).data('bs.' + this.type)
if (self && self.$tip && self.$tip.is(':visible')) {
self.hoverState = 'in' self.hoverState = 'in'
this.timeout = setTimeout(function() { return
if (self.hoverState == 'in') self.show()
}, self.options.delay.show)
} }
, leave: function (e) { if (!self) {
var self = $(e.currentTarget)[this.type](this._options).data(this.type) self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
if (this.timeout) clearTimeout(this.timeout)
if (!self.options.delay || !self.options.delay.hide) return self.hide()
self.hoverState = 'out'
this.timeout = setTimeout(function() {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
} }
, show: function () { clearTimeout(self.timeout)
var $tip
, pos
, actualWidth
, actualHeight
, placement
, tp
, e = $.Event('show')
if (this.hasContent() && this.enabled) { self.hoverState = 'in'
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$tip = this.tip()
this.setContent()
if (this.options.animation) { if (!self.options.delay || !self.options.delay.show) return self.show()
$tip.addClass('fade')
}
placement = typeof this.options.placement == 'function' ? self.timeout = setTimeout(function () {
this.options.placement.call(this, $tip[0], this.$element[0]) : if (self.hoverState == 'in') self.show()
this.options.placement }, self.options.delay.show)
}
$tip Tooltip.prototype.leave = function (obj) {
.detach() var self = obj instanceof this.constructor ?
.css({ top: 0, left: 0, display: 'block' }) obj : $(obj.currentTarget).data('bs.' + this.type)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
pos = this.getPosition() $(obj.currentTarget).data('bs.' + this.type, self)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
switch (placement) {
case 'bottom':
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
break
case 'top':
tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
break
case 'left':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
break
case 'right':
tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
break
}
this.applyPlacement(tp, placement)
this.$element.trigger('shown')
}
} }
, applyPlacement: function(offset, placement){ clearTimeout(self.timeout)
self.hoverState = 'out'
if (!self.options.delay || !self.options.delay.hide) return self.hide()
self.timeout = setTimeout(function () {
if (self.hoverState == 'out') self.hide()
}, self.options.delay.hide)
}
Tooltip.prototype.show = function () {
var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) {
this.$element.trigger(e)
var inDom = $.contains(this.$element[0].ownerDocument.documentElement, this.$element[0])
if (e.isDefaultPrevented() || !inDom) return
var that = this
var $tip = this.tip() var $tip = this.tip()
, width = $tip[0].offsetWidth
, height = $tip[0].offsetHeight var tipId = this.getUID(this.type)
, actualWidth
, actualHeight this.setContent()
, delta $tip.attr('id', tipId)
, replace this.$element.attr('aria-describedby', tipId)
if (this.options.animation) $tip.addClass('fade')
var placement = typeof this.options.placement == 'function' ?
this.options.placement.call(this, $tip[0], this.$element[0]) :
this.options.placement
var autoToken = /\s?auto?\s?/i
var autoPlace = autoToken.test(placement)
if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
$tip $tip
.offset(offset) .detach()
.css({ top: 0, left: 0, display: 'block' })
.addClass(placement) .addClass(placement)
.addClass('in') .data('bs.' + this.type, this)
actualWidth = $tip[0].offsetWidth this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) { var pos = this.getPosition()
offset.top = offset.top + height - actualHeight var actualWidth = $tip[0].offsetWidth
replace = true var actualHeight = $tip[0].offsetHeight
if (autoPlace) {
var orgPlacement = placement
var $container = this.options.container ? $(this.options.container) : this.$element.parent()
var containerDim = this.getPosition($container)
placement = placement == 'bottom' && pos.bottom + actualHeight > containerDim.bottom ? 'top' :
placement == 'top' && pos.top - actualHeight < containerDim.top ? 'bottom' :
placement == 'right' && pos.right + actualWidth > containerDim.width ? 'left' :
placement == 'left' && pos.left - actualWidth < containerDim.left ? 'right' :
placement
$tip
.removeClass(orgPlacement)
.addClass(placement)
} }
if (placement == 'bottom' || placement == 'top') { var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
delta = 0
if (offset.left < 0){ this.applyPlacement(calculatedOffset, placement)
delta = offset.left * -2
offset.left = 0
$tip.offset(offset)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
}
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left') var complete = function () {
} else { var prevHoverState = that.hoverState
this.replaceArrow(actualHeight - height, actualHeight, 'top') that.$element.trigger('shown.bs.' + that.type)
} that.hoverState = null
if (replace) $tip.offset(offset) if (prevHoverState == 'out') that.leave(that)
}
, replaceArrow: function(delta, dimension, position){
this
.arrow()
.css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
, setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
, hide: function () {
var that = this
, $tip = this.tip()
, e = $.Event('hide')
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$tip.removeClass('in')
function removeWithAnimation() {
var timeout = setTimeout(function () {
$tip.off($.support.transition.end).detach()
}, 500)
$tip.one($.support.transition.end, function () {
clearTimeout(timeout)
$tip.detach()
})
} }
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
removeWithAnimation() : $tip
$tip.detach() .one('bsTransitionEnd', complete)
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
this.$element.trigger('hidden') complete()
return this
} }
}
, fixTitle: function () { Tooltip.prototype.applyPlacement = function (offset, placement) {
var $e = this.$element var $tip = this.tip()
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { var width = $tip[0].offsetWidth
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '') var height = $tip[0].offsetHeight
// manually read margins because getBoundingClientRect includes difference
var marginTop = parseInt($tip.css('margin-top'), 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
// $.fn.offset doesn't round pixel values
// so we use setOffset directly with our own function B-0
$.offset.setOffset($tip[0], $.extend({
using: function (props) {
$tip.css({
top: Math.round(props.top),
left: Math.round(props.left)
})
} }
}, offset), 0)
$tip.addClass('in')
// check to see if placing tip in new offset caused the tip to resize itself
var actualWidth = $tip[0].offsetWidth
var actualHeight = $tip[0].offsetHeight
if (placement == 'top' && actualHeight != height) {
offset.top = offset.top + height - actualHeight
} }
, hasContent: function () { var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
return this.getTitle()
if (delta.left) offset.left += delta.left
else offset.top += delta.top
var isVertical = /top|bottom/.test(placement)
var arrowDelta = isVertical ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
var arrowOffsetPosition = isVertical ? 'offsetWidth' : 'offsetHeight'
$tip.offset(offset)
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], isVertical)
}
Tooltip.prototype.replaceArrow = function (delta, dimension, isHorizontal) {
this.arrow()
.css(isHorizontal ? 'left' : 'top', 50 * (1 - delta / dimension) + '%')
.css(isHorizontal ? 'top' : 'left', '')
}
Tooltip.prototype.setContent = function () {
var $tip = this.tip()
var title = this.getTitle()
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
$tip.removeClass('fade in top bottom left right')
}
Tooltip.prototype.hide = function (callback) {
var that = this
var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type)
function complete() {
if (that.hoverState != 'in') $tip.detach()
that.$element
.removeAttr('aria-describedby')
.trigger('hidden.bs.' + that.type)
callback && callback()
} }
, getPosition: function () { this.$element.trigger(e)
var el = this.$element[0]
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : { if (e.isDefaultPrevented()) return
width: el.offsetWidth
, height: el.offsetHeight $tip.removeClass('in')
}, this.$element.offset())
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
complete()
this.hoverState = null
return this
}
Tooltip.prototype.fixTitle = function () {
var $e = this.$element
if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
} }
}
, getTitle: function () { Tooltip.prototype.hasContent = function () {
var title return this.getTitle()
, $e = this.$element }
, o = this.options
title = $e.attr('data-original-title') Tooltip.prototype.getPosition = function ($element) {
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title) $element = $element || this.$element
return title var el = $element[0]
var isBody = el.tagName == 'BODY'
var elRect = el.getBoundingClientRect()
if (elRect.width == null) {
// width and height are missing in IE8, so compute them manually; see https://github.com/twbs/bootstrap/issues/14093
elRect = $.extend({}, elRect, { width: elRect.right - elRect.left, height: elRect.bottom - elRect.top })
} }
var elOffset = isBody ? { top: 0, left: 0 } : $element.offset()
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
var outerDims = isBody ? { width: $(window).width(), height: $(window).height() } : null
, tip: function () { return $.extend({}, elRect, scroll, outerDims, elOffset)
return this.$tip = this.$tip || $(this.options.template) }
}
, arrow: function(){ Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow") 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 } :
, validate: function () { /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
if (!this.$element[0].parentNode) {
this.hide()
this.$element = null
this.options = null
}
}
, enable: function () {
this.enabled = true
}
, disable: function () {
this.enabled = false
}
, toggleEnabled: function () {
this.enabled = !this.enabled
}
, toggle: function (e) {
var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
self.tip().hasClass('in') ? self.hide() : self.show()
}
, destroy: function () {
this.hide().$element.off('.' + this.type).removeData(this.type)
}
} }
Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
var delta = { top: 0, left: 0 }
if (!this.$viewport) return delta
/* TOOLTIP PLUGIN DEFINITION var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
* ========================= */ var viewportDimensions = this.getPosition(this.$viewport)
var old = $.fn.tooltip if (/right|left/.test(placement)) {
var topEdgeOffset = pos.top - viewportPadding - viewportDimensions.scroll
var bottomEdgeOffset = pos.top + viewportPadding - viewportDimensions.scroll + actualHeight
if (topEdgeOffset < viewportDimensions.top) { // top overflow
delta.top = viewportDimensions.top - topEdgeOffset
} else if (bottomEdgeOffset > viewportDimensions.top + viewportDimensions.height) { // bottom overflow
delta.top = viewportDimensions.top + viewportDimensions.height - bottomEdgeOffset
}
} else {
var leftEdgeOffset = pos.left - viewportPadding
var rightEdgeOffset = pos.left + viewportPadding + actualWidth
if (leftEdgeOffset < viewportDimensions.left) { // left overflow
delta.left = viewportDimensions.left - leftEdgeOffset
} else if (rightEdgeOffset > viewportDimensions.width) { // right overflow
delta.left = viewportDimensions.left + viewportDimensions.width - rightEdgeOffset
}
}
$.fn.tooltip = function ( option ) { return delta
}
Tooltip.prototype.getTitle = function () {
var title
var $e = this.$element
var o = this.options
title = $e.attr('data-original-title')
|| (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
return title
}
Tooltip.prototype.getUID = function (prefix) {
do prefix += ~~(Math.random() * 1000000)
while (document.getElementById(prefix))
return prefix
}
Tooltip.prototype.tip = function () {
return (this.$tip = this.$tip || $(this.options.template))
}
Tooltip.prototype.arrow = function () {
return (this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow'))
}
Tooltip.prototype.enable = function () {
this.enabled = true
}
Tooltip.prototype.disable = function () {
this.enabled = false
}
Tooltip.prototype.toggleEnabled = function () {
this.enabled = !this.enabled
}
Tooltip.prototype.toggle = function (e) {
var self = this
if (e) {
self = $(e.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(e.currentTarget, this.getDelegateOptions())
$(e.currentTarget).data('bs.' + this.type, self)
}
}
self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
}
Tooltip.prototype.destroy = function () {
var that = this
clearTimeout(this.timeout)
this.hide(function () {
that.$element.off('.' + that.type).removeData('bs.' + that.type)
})
}
// TOOLTIP PLUGIN DEFINITION
// =========================
function Plugin(option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
, data = $this.data('tooltip') var data = $this.data('bs.tooltip')
, options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
if (!data && option == 'destroy') return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
var old = $.fn.tooltip
$.fn.tooltip = Plugin
$.fn.tooltip.Constructor = Tooltip $.fn.tooltip.Constructor = Tooltip
$.fn.tooltip.defaults = {
animation: true
, placement: 'top'
, selector: false
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
, trigger: 'hover focus'
, title: ''
, delay: 0
, html: false
, container: false
}
// TOOLTIP NO CONFLICT
/* TOOLTIP NO CONFLICT // ===================
* =================== */
$.fn.tooltip.noConflict = function () { $.fn.tooltip.noConflict = function () {
$.fn.tooltip = old $.fn.tooltip = old
return this return this
} }
}(window.jQuery); }(jQuery);