Moved to js of BS 3.2.0.

This commit is contained in:
Martin Edenhofer 2014-07-21 00:00:27 +02:00
parent 326c0903f1
commit 29a28d838c
8 changed files with 419 additions and 329 deletions

View file

@ -1,24 +1,14 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: button.js v3.0.3 * Bootstrap: button.js v3.2.0
* http://getbootstrap.com/javascript/#buttons * http://getbootstrap.com/javascript/#buttons
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// BUTTON PUBLIC CLASS DEFINITION // BUTTON PUBLIC CLASS DEFINITION
// ============================== // ==============================
@ -26,8 +16,11 @@
var Button = function (element, options) { var Button = function (element, options) {
this.$element = $(element) this.$element = $(element)
this.options = $.extend({}, Button.DEFAULTS, options) this.options = $.extend({}, Button.DEFAULTS, options)
this.isLoading = false
} }
Button.VERSION = '3.2.0'
Button.DEFAULTS = { Button.DEFAULTS = {
loadingText: 'loading...' loadingText: 'loading...'
} }
@ -40,30 +33,31 @@
state = state + 'Text' state = state + 'Text'
if (!data.resetText) $el.data('resetText', $el[val]()) if (data.resetText == null) $el.data('resetText', $el[val]())
$el[val](data[state] || this.options[state]) $el[val](data[state] == null ? this.options[state] : data[state])
// push to event loop to allow forms to submit // push to event loop to allow forms to submit
setTimeout(function () { setTimeout($.proxy(function () {
state == 'loadingText' ? if (state == 'loadingText') {
$el.addClass(d).attr(d, d) : this.isLoading = true
$el.removeClass(d).removeAttr(d); $el.addClass(d).attr(d, d)
}, 0) } else if (this.isLoading) {
this.isLoading = false
$el.removeClass(d).removeAttr(d)
}
}, this), 0)
} }
Button.prototype.toggle = function () { Button.prototype.toggle = function () {
var $parent = this.$element.closest('[data-toggle="buttons"]')
var changed = true var changed = true
var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent.length) { if ($parent.length) {
var $input = this.$element.find('input') var $input = this.$element.find('input')
if ($input.prop('type') === 'radio') { if ($input.prop('type') == 'radio') {
// see if clicking on current one if ($input.prop('checked') && this.$element.hasClass('active')) changed = false
if ($input.prop('checked') && this.$element.hasClass('active')) else $parent.find('.active').removeClass('active')
changed = false
else
$parent.find('.active').removeClass('active')
} }
if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change') if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
} }
@ -75,9 +69,7 @@
// BUTTON PLUGIN DEFINITION // BUTTON PLUGIN DEFINITION
// ======================== // ========================
var old = $.fn.button function Plugin(option) {
$.fn.button = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs.button') var data = $this.data('bs.button')
@ -90,6 +82,9 @@
}) })
} }
var old = $.fn.button
$.fn.button = Plugin
$.fn.button.Constructor = Button $.fn.button.Constructor = Button
@ -105,11 +100,15 @@
// BUTTON DATA-API // BUTTON DATA-API
// =============== // ===============
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) { $(document)
.on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) {
var $btn = $(e.target) var $btn = $(e.target)
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle') Plugin.call($btn, 'toggle')
e.preventDefault() e.preventDefault()
}) })
.on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) {
$(e.target).closest('.btn').toggleClass('focus', e.type == 'focus')
})
}(jQuery); }(jQuery);

View file

@ -1,24 +1,14 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: collapse.js v3.0.3 * Bootstrap: collapse.js v3.2.0
* http://getbootstrap.com/javascript/#collapse * http://getbootstrap.com/javascript/#collapse
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// COLLAPSE PUBLIC CLASS DEFINITION // COLLAPSE PUBLIC CLASS DEFINITION
// ================================ // ================================
@ -32,6 +22,8 @@
if (this.options.toggle) this.toggle() if (this.options.toggle) this.toggle()
} }
Collapse.VERSION = '3.2.0'
Collapse.DEFAULTS = { Collapse.DEFAULTS = {
toggle: true toggle: true
} }
@ -53,7 +45,7 @@
if (actives && actives.length) { if (actives && actives.length) {
var hasData = actives.data('bs.collapse') var hasData = actives.data('bs.collapse')
if (hasData && hasData.transitioning) return if (hasData && hasData.transitioning) return
actives.collapse('hide') Plugin.call(actives, 'hide')
hasData || actives.data('bs.collapse', null) hasData || actives.data('bs.collapse', null)
} }
@ -61,18 +53,17 @@
this.$element this.$element
.removeClass('collapse') .removeClass('collapse')
.addClass('collapsing') .addClass('collapsing')[dimension](0)
[dimension](0)
this.transitioning = 1 this.transitioning = 1
var complete = function () { var complete = function () {
this.$element this.$element
.removeClass('collapsing') .removeClass('collapsing')
.addClass('in') .addClass('collapse in')[dimension]('')
[dimension]('auto')
this.transitioning = 0 this.transitioning = 0
this.$element.trigger('shown.bs.collapse') this.$element
.trigger('shown.bs.collapse')
} }
if (!$.support.transition) return complete.call(this) if (!$.support.transition) return complete.call(this)
@ -80,9 +71,8 @@
var scrollSize = $.camelCase(['scroll', dimension].join('-')) var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element this.$element
.one($.support.transition.end, $.proxy(complete, this)) .one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(350) .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
[dimension](this.$element[0][scrollSize])
} }
Collapse.prototype.hide = function () { Collapse.prototype.hide = function () {
@ -94,14 +84,11 @@
var dimension = this.dimension() var dimension = this.dimension()
this.$element this.$element[dimension](this.$element[dimension]())[0].offsetHeight
[dimension](this.$element[dimension]())
[0].offsetHeight
this.$element this.$element
.addClass('collapsing') .addClass('collapsing')
.removeClass('collapse') .removeClass('collapse in')
.removeClass('in')
this.transitioning = 1 this.transitioning = 1
@ -117,7 +104,7 @@
this.$element this.$element
[dimension](0) [dimension](0)
.one($.support.transition.end, $.proxy(complete, this)) .one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(350) .emulateTransitionEnd(350)
} }
@ -129,19 +116,21 @@
// COLLAPSE PLUGIN DEFINITION // COLLAPSE PLUGIN DEFINITION
// ========================== // ==========================
var old = $.fn.collapse function Plugin(option) {
$.fn.collapse = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs.collapse') var data = $this.data('bs.collapse')
var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option) var options = $.extend({}, Collapse.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data && options.toggle && option == 'show') option = !option
if (!data) $this.data('bs.collapse', (data = new Collapse(this, options))) if (!data) $this.data('bs.collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
var old = $.fn.collapse
$.fn.collapse = Plugin
$.fn.collapse.Constructor = Collapse $.fn.collapse.Constructor = Collapse
@ -157,11 +146,12 @@
// COLLAPSE DATA-API // COLLAPSE DATA-API
// ================= // =================
$(document).on('click.bs.collapse.data-api', '[data-toggle=collapse]', function (e) { $(document).on('click.bs.collapse.data-api', '[data-toggle="collapse"]', function (e) {
var $this = $(this), href var href
var $this = $(this)
var target = $this.attr('data-target') var target = $this.attr('data-target')
|| e.preventDefault() || e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') // strip for ie7
var $target = $(target) var $target = $(target)
var data = $target.data('bs.collapse') var data = $target.data('bs.collapse')
var option = data ? 'toggle' : $this.data() var option = data ? 'toggle' : $this.data()
@ -169,11 +159,11 @@
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.toggleClass('collapsed', $target.hasClass('in'))
} }
$target.collapse(option) Plugin.call($target, option)
}) })
}(jQuery); }(jQuery);

View file

@ -1,34 +1,26 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: dropdown.js v3.0.3 * Bootstrap: dropdown.js v3.2.0
* http://getbootstrap.com/javascript/#dropdowns * http://getbootstrap.com/javascript/#dropdowns
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// DROPDOWN CLASS DEFINITION // DROPDOWN CLASS DEFINITION
// ========================= // =========================
var backdrop = '.dropdown-backdrop' var backdrop = '.dropdown-backdrop'
var toggle = '[data-toggle=dropdown]' var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) { var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle) $(element).on('click.bs.dropdown', this.toggle)
} }
Dropdown.VERSION = '3.2.0'
Dropdown.prototype.toggle = function (e) { Dropdown.prototype.toggle = function (e) {
var $this = $(this) var $this = $(this)
@ -45,15 +37,16 @@
$('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus) $('<div class="dropdown-backdrop"/>').insertAfter($(this)).on('click', clearMenus)
} }
$parent.trigger(e = $.Event('show.bs.dropdown')) var relatedTarget = { relatedTarget: this }
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$this.trigger('focus')
$parent $parent
.toggleClass('open') .toggleClass('open')
.trigger('shown.bs.dropdown') .trigger('shown.bs.dropdown', relatedTarget)
$this.focus()
} }
return false return false
@ -73,11 +66,12 @@
var isActive = $parent.hasClass('open') var isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) { if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).focus() if (e.which == 27) $parent.find(toggle).trigger('focus')
return $this.click() return $this.trigger('click')
} }
var $items = $('[role=menu] li:not(.divider):visible a', $parent) var desc = ' li:not(.divider):visible a'
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
if (!$items.length) return if (!$items.length) return
@ -85,19 +79,21 @@
if (e.keyCode == 38 && index > 0) index-- // up if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (!~index) index=0 if (!~index) index = 0
$items.eq(index).focus() $items.eq(index).trigger('focus')
} }
function clearMenus() { function clearMenus(e) {
if (e && e.which === 3) return
$(backdrop).remove() $(backdrop).remove()
$(toggle).each(function (e) { $(toggle).each(function () {
var $parent = getParent($(this)) var $parent = getParent($(this))
var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return if (!$parent.hasClass('open')) return
$parent.trigger(e = $.Event('hide.bs.dropdown')) $parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return if (e.isDefaultPrevented()) return
$parent.removeClass('open').trigger('hidden.bs.dropdown') $parent.removeClass('open').trigger('hidden.bs.dropdown', relatedTarget)
}) })
} }
@ -106,7 +102,7 @@
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
} }
var $parent = selector && $(selector) var $parent = selector && $(selector)
@ -118,9 +114,7 @@
// 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)
var data = $this.data('bs.dropdown') var data = $this.data('bs.dropdown')
@ -130,6 +124,9 @@
}) })
} }
var old = $.fn.dropdown
$.fn.dropdown = Plugin
$.fn.dropdown.Constructor = Dropdown $.fn.dropdown.Constructor = Dropdown
@ -148,7 +145,7 @@
$(document) $(document)
.on('click.bs.dropdown.data-api', clearMenus) .on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.bs.dropdown.data-api' , toggle, Dropdown.prototype.toggle) .on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) .on('keydown.bs.dropdown.data-api', toggle + ', [role="menu"], [role="listbox"]', Dropdown.prototype.keydown)
}(jQuery); }(jQuery);

View file

@ -1,45 +1,45 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: modal.js v3.0.3 * Bootstrap: modal.js v3.2.0
* http://getbootstrap.com/javascript/#modals * http://getbootstrap.com/javascript/#modals
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// MODAL CLASS DEFINITION // MODAL CLASS DEFINITION
// ====================== // ======================
var Modal = function (element, options) { var Modal = function (element, options) {
this.options = options this.options = options
this.$body = $(document.body)
this.$element = $(element) this.$element = $(element)
this.$backdrop = this.$backdrop =
this.isShown = null this.isShown = null
this.scrollbarWidth = 0
if (this.options.remote) this.$element.load(this.options.remote) if (this.options.remote) {
this.$element
.find('.modal-content')
.load(this.options.remote, $.proxy(function () {
this.$element.trigger('loaded.bs.modal')
}, this))
}
} }
Modal.VERSION = '3.2.0'
Modal.DEFAULTS = { Modal.DEFAULTS = {
backdrop: true backdrop: true,
, keyboard: true keyboard: true,
, show: true show: true
} }
Modal.prototype.toggle = function (_relatedTarget) { Modal.prototype.toggle = function (_relatedTarget) {
return this[!this.isShown ? 'show' : 'hide'](_relatedTarget) return this.isShown ? this.hide() : this.show(_relatedTarget)
} }
Modal.prototype.show = function (_relatedTarget) { Modal.prototype.show = function (_relatedTarget) {
@ -52,18 +52,24 @@
this.isShown = true this.isShown = true
this.checkScrollbar()
this.$body.addClass('modal-open')
this.setScrollbar()
this.escape() this.escape()
this.$element.on('click.dismiss.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) this.$element.on('click.dismiss.bs.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')
if (!that.$element.parent().length) { if (!that.$element.parent().length) {
that.$element.appendTo(document.body) // don't move modals dom position that.$element.appendTo(that.$body) // don't move modals dom position
} }
that.$element.show() that.$element
.show()
.scrollTop(0)
if (transition) { if (transition) {
that.$element[0].offsetWidth // force reflow that.$element[0].offsetWidth // force reflow
@ -79,11 +85,11 @@
transition ? transition ?
that.$element.find('.modal-dialog') // wait for modal to slide in that.$element.find('.modal-dialog') // wait for modal to slide in
.one($.support.transition.end, function () { .one('bsTransitionEnd', function () {
that.$element.focus().trigger(e) that.$element.trigger('focus').trigger(e)
}) })
.emulateTransitionEnd(300) : .emulateTransitionEnd(300) :
that.$element.focus().trigger(e) that.$element.trigger('focus').trigger(e)
}) })
} }
@ -98,6 +104,9 @@
this.isShown = false this.isShown = false
this.$body.removeClass('modal-open')
this.resetScrollbar()
this.escape() this.escape()
$(document).off('focusin.bs.modal') $(document).off('focusin.bs.modal')
@ -105,11 +114,11 @@
this.$element this.$element
.removeClass('in') .removeClass('in')
.attr('aria-hidden', true) .attr('aria-hidden', true)
.off('click.dismiss.modal') .off('click.dismiss.bs.modal')
$.support.transition && this.$element.hasClass('fade') ? $.support.transition && this.$element.hasClass('fade') ?
this.$element this.$element
.one($.support.transition.end, $.proxy(this.hideModal, this)) .one('bsTransitionEnd', $.proxy(this.hideModal, this))
.emulateTransitionEnd(300) : .emulateTransitionEnd(300) :
this.hideModal() this.hideModal()
} }
@ -119,18 +128,18 @@
.off('focusin.bs.modal') // guard against infinite focus loop .off('focusin.bs.modal') // guard against infinite focus loop
.on('focusin.bs.modal', $.proxy(function (e) { .on('focusin.bs.modal', $.proxy(function (e) {
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) { if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
this.$element.focus() this.$element.trigger('focus')
} }
}, this)) }, this))
} }
Modal.prototype.escape = function () { Modal.prototype.escape = function () {
if (this.isShown && this.options.keyboard) { if (this.isShown && this.options.keyboard) {
this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) { this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
e.which == 27 && this.hide() e.which == 27 && this.hide()
}, this)) }, this))
} else if (!this.isShown) { } else if (!this.isShown) {
this.$element.off('keyup.dismiss.bs.modal') this.$element.off('keydown.dismiss.bs.modal')
} }
} }
@ -138,7 +147,6 @@
var that = this var that = this
this.$element.hide() this.$element.hide()
this.backdrop(function () { this.backdrop(function () {
that.removeBackdrop()
that.$element.trigger('hidden.bs.modal') that.$element.trigger('hidden.bs.modal')
}) })
} }
@ -156,9 +164,9 @@
var doAnimate = $.support.transition && animate var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />') this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
.appendTo(document.body) .appendTo(this.$body)
this.$element.on('click.dismiss.modal', $.proxy(function (e) { this.$element.on('mousedown.dismiss.bs.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])
@ -173,31 +181,56 @@
doAnimate ? doAnimate ?
this.$backdrop this.$backdrop
.one($.support.transition.end, callback) .one('bsTransitionEnd', callback)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
callback() callback()
} else if (!this.isShown && this.$backdrop) { } else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in') this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')? var callbackRemove = function () {
that.removeBackdrop()
callback && callback()
}
$.support.transition && this.$element.hasClass('fade') ?
this.$backdrop this.$backdrop
.one($.support.transition.end, callback) .one('bsTransitionEnd', callbackRemove)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
callback() callbackRemove()
} else if (callback) { } else if (callback) {
callback() callback()
} }
} }
Modal.prototype.checkScrollbar = function () {
if (document.body.clientWidth >= window.innerWidth) return
this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
}
Modal.prototype.setScrollbar = function () {
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
}
Modal.prototype.resetScrollbar = function () {
this.$body.css('padding-right', '')
}
Modal.prototype.measureScrollbar = function () { // thx walsh
var scrollDiv = document.createElement('div')
scrollDiv.className = 'modal-scrollbar-measure'
this.$body.append(scrollDiv)
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
this.$body[0].removeChild(scrollDiv)
return scrollbarWidth
}
// MODAL PLUGIN DEFINITION // MODAL PLUGIN DEFINITION
// ======================= // =======================
var old = $.fn.modal function Plugin(option, _relatedTarget) {
$.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')
@ -209,6 +242,9 @@
}) })
} }
var old = $.fn.modal
$.fn.modal = Plugin
$.fn.modal.Constructor = Modal $.fn.modal.Constructor = Modal
@ -227,20 +263,18 @@
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
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('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
e.preventDefault() if ($this.is('a')) e.preventDefault()
$target $target.one('show.bs.modal', function (showEvent) {
.modal(option, this) if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown
.one('hide', function () { $target.one('hidden.bs.modal', function () {
$this.is(':visible') && $this.focus() $this.is(':visible') && $this.trigger('focus')
}) })
}) })
Plugin.call($target, option, this)
$(document) })
.on('show.bs.modal', '.modal', function () { $(document.body).addClass('modal-open') })
.on('hidden.bs.modal', '.modal', function () { $(document.body).removeClass('modal-open') })
}(jQuery); }(jQuery);

View file

@ -1,24 +1,14 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: popover.js v3.0.3 * Bootstrap: popover.js v3.2.0
* http://getbootstrap.com/javascript/#popovers * http://getbootstrap.com/javascript/#popovers
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// POPOVER PUBLIC CLASS DEFINITION // POPOVER PUBLIC CLASS DEFINITION
// =============================== // ===============================
@ -29,11 +19,13 @@
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js') if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, { Popover.VERSION = '3.2.0'
placement: 'right'
, trigger: 'click' Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
, content: '' placement: 'right',
, template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>' trigger: 'click',
content: '',
template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
}) })
@ -54,7 +46,9 @@
var content = this.getContent() var content = this.getContent()
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title) $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content) $tip.find('.popover-content').empty()[ // we use append for html objects to maintain js events
this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
](content)
$tip.removeClass('fade top bottom left right in') $tip.removeClass('fade top bottom left right in')
@ -78,7 +72,7 @@
} }
Popover.prototype.arrow = function () { Popover.prototype.arrow = function () {
return this.$arrow = this.$arrow || this.tip().find('.arrow') return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
} }
Popover.prototype.tip = function () { Popover.prototype.tip = function () {
@ -90,19 +84,21 @@
// POPOVER PLUGIN DEFINITION // POPOVER PLUGIN DEFINITION
// ========================= // =========================
var old = $.fn.popover function Plugin(option) {
$.fn.popover = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs.popover') var data = $this.data('bs.popover')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data && option == 'destroy') return
if (!data) $this.data('bs.popover', (data = new Popover(this, options))) if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]() if (typeof option == 'string') data[option]()
}) })
} }
var old = $.fn.popover
$.fn.popover = Plugin
$.fn.popover.Constructor = Popover $.fn.popover.Constructor = Popover

View file

@ -1,24 +1,14 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: tab.js v3.0.3 * Bootstrap: tab.js v3.2.0
* http://getbootstrap.com/javascript/#tabs * http://getbootstrap.com/javascript/#tabs
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// TAB CLASS DEFINITION // TAB CLASS DEFINITION
// ==================== // ====================
@ -27,6 +17,8 @@
this.element = $(element) this.element = $(element)
} }
Tab.VERSION = '3.2.0'
Tab.prototype.show = function () { Tab.prototype.show = function () {
var $this = this.element var $this = this.element
var $ul = $this.closest('ul:not(.dropdown-menu)') var $ul = $this.closest('ul:not(.dropdown-menu)')
@ -34,7 +26,7 @@
if (!selector) { if (!selector) {
selector = $this.attr('href') selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
} }
if ($this.parent('li').hasClass('active')) return if ($this.parent('li').hasClass('active')) return
@ -50,11 +42,11 @@
var $target = $(selector) var $target = $(selector)
this.activate($this.parent('li'), $ul) this.activate($this.closest('li'), $ul)
this.activate($target, $target.parent(), function () { this.activate($target, $target.parent(), function () {
$this.trigger({ $this.trigger({
type: 'shown.bs.tab' type: 'shown.bs.tab',
, relatedTarget: previous relatedTarget: previous
}) })
}) })
} }
@ -63,7 +55,7 @@
var $active = container.find('> .active') var $active = container.find('> .active')
var transition = callback var transition = callback
&& $.support.transition && $.support.transition
&& $active.hasClass('fade') && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
function next() { function next() {
$active $active
@ -87,9 +79,9 @@
callback && callback() callback && callback()
} }
transition ? $active.length && transition ?
$active $active
.one($.support.transition.end, next) .one('bsTransitionEnd', next)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
next() next()
@ -100,9 +92,7 @@
// TAB PLUGIN DEFINITION // TAB PLUGIN DEFINITION
// ===================== // =====================
var old = $.fn.tab function Plugin(option) {
$.fn.tab = function ( option ) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs.tab') var data = $this.data('bs.tab')
@ -112,6 +102,9 @@
}) })
} }
var old = $.fn.tab
$.fn.tab = Plugin
$.fn.tab.Constructor = Tab $.fn.tab.Constructor = Tab
@ -129,7 +122,7 @@
$(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) { $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault() e.preventDefault()
$(this).tab('show') Plugin.call($(this), 'show')
}) })
}(jQuery); }(jQuery);

View file

@ -1,25 +1,15 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: tooltip.js v3.0.3 * Bootstrap: tooltip.js v3.2.0
* http://getbootstrap.com/javascript/#tooltip * 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-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// TOOLTIP PUBLIC CLASS DEFINITION // TOOLTIP PUBLIC CLASS DEFINITION
// =============================== // ===============================
@ -35,16 +25,22 @@
this.init('tooltip', element, options) this.init('tooltip', element, options)
} }
Tooltip.VERSION = '3.2.0'
Tooltip.DEFAULTS = { Tooltip.DEFAULTS = {
animation: true animation: true,
, placement: 'top' placement: 'top',
, selector: false selector: false,
, template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>' template: '<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
, trigger: 'hover focus' trigger: 'hover focus',
, title: '' title: '',
, delay: 0 delay: 0,
, html: false html: false,
, container: false container: false,
viewport: {
selector: 'body',
padding: 0
}
} }
Tooltip.prototype.init = function (type, element, options) { Tooltip.prototype.init = function (type, element, options) {
@ -52,6 +48,7 @@
this.type = type this.type = type
this.$element = $(element) this.$element = $(element)
this.options = this.getOptions(options) this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
var triggers = this.options.trigger.split(' ') var triggers = this.options.trigger.split(' ')
@ -61,8 +58,8 @@
if (trigger == 'click') { if (trigger == 'click') {
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this)) this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
} else if (trigger != 'manual') { } else if (trigger != 'manual') {
var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus' var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur' var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, 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.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
@ -83,8 +80,8 @@
if (options.delay && typeof options.delay == 'number') { if (options.delay && typeof options.delay == 'number') {
options.delay = { options.delay = {
show: options.delay show: options.delay,
, hide: options.delay hide: options.delay
} }
} }
@ -104,7 +101,12 @@
Tooltip.prototype.enter = function (obj) { Tooltip.prototype.enter = function (obj) {
var self = obj instanceof this.constructor ? var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) obj : $(obj.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
}
clearTimeout(self.timeout) clearTimeout(self.timeout)
@ -119,7 +121,12 @@
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.getDelegateOptions()).data('bs.' + this.type) obj : $(obj.currentTarget).data('bs.' + this.type)
if (!self) {
self = new this.constructor(obj.currentTarget, this.getDelegateOptions())
$(obj.currentTarget).data('bs.' + this.type, self)
}
clearTimeout(self.timeout) clearTimeout(self.timeout)
@ -133,16 +140,22 @@
} }
Tooltip.prototype.show = function () { Tooltip.prototype.show = function () {
var e = $.Event('show.bs.'+ this.type) var e = $.Event('show.bs.' + this.type)
if (this.hasContent() && this.enabled) { if (this.hasContent() && this.enabled) {
this.$element.trigger(e) this.$element.trigger(e)
if (e.isDefaultPrevented()) return var inDom = $.contains(document.documentElement, this.$element[0])
if (e.isDefaultPrevented() || !inDom) return
var that = this
var $tip = this.tip() var $tip = this.tip()
var tipId = this.getUID(this.type)
this.setContent() this.setContent()
$tip.attr('id', tipId)
this.$element.attr('aria-describedby', tipId)
if (this.options.animation) $tip.addClass('fade') if (this.options.animation) $tip.addClass('fade')
@ -158,6 +171,7 @@
.detach() .detach()
.css({ top: 0, left: 0, display: 'block' }) .css({ top: 0, left: 0, display: 'block' })
.addClass(placement) .addClass(placement)
.data('bs.' + this.type, this)
this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element) this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
@ -166,18 +180,14 @@
var actualHeight = $tip[0].offsetHeight var actualHeight = $tip[0].offsetHeight
if (autoPlace) { if (autoPlace) {
var $parent = this.$element.parent()
var orgPlacement = placement var orgPlacement = placement
var docScroll = document.documentElement.scrollTop || document.body.scrollTop var $parent = this.$element.parent()
var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth() var parentDim = this.getPosition($parent)
var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' : placement = placement == 'bottom' && pos.top + pos.height + actualHeight - parentDim.scroll > parentDim.height ? 'top' :
placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' : placement == 'top' && pos.top - parentDim.scroll - actualHeight < 0 ? 'bottom' :
placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' : placement == 'right' && pos.right + actualWidth > parentDim.width ? 'left' :
placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' : placement == 'left' && pos.left - actualWidth < parentDim.left ? 'right' :
placement placement
$tip $tip
@ -188,12 +198,21 @@
var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight) var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
this.applyPlacement(calculatedOffset, placement) this.applyPlacement(calculatedOffset, placement)
this.$element.trigger('shown.bs.' + this.type)
var complete = function () {
that.$element.trigger('shown.bs.' + that.type)
that.hoverState = null
}
$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) :
complete()
} }
} }
Tooltip.prototype.applyPlacement = function(offset, placement) { Tooltip.prototype.applyPlacement = function (offset, placement) {
var replace
var $tip = this.tip() var $tip = this.tip()
var width = $tip[0].offsetWidth var width = $tip[0].offsetWidth
var height = $tip[0].offsetHeight var height = $tip[0].offsetHeight
@ -209,42 +228,42 @@
offset.top = offset.top + marginTop offset.top = offset.top + marginTop
offset.left = offset.left + marginLeft offset.left = offset.left + marginLeft
$tip // $.fn.offset doesn't round pixel values
.offset(offset) // so we use setOffset directly with our own function B-0
.addClass('in') $.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 // 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
if (placement == 'top' && actualHeight != height) { if (placement == 'top' && actualHeight != height) {
replace = true
offset.top = offset.top + height - actualHeight offset.top = offset.top + height - actualHeight
} }
if (/bottom|top/.test(placement)) { var delta = this.getViewportAdjustedDelta(placement, offset, actualWidth, actualHeight)
var delta = 0
if (offset.left < 0) { if (delta.left) offset.left += delta.left
delta = offset.left * -2 else offset.top += delta.top
offset.left = 0
var arrowDelta = delta.left ? delta.left * 2 - width + actualWidth : delta.top * 2 - height + actualHeight
var arrowPosition = delta.left ? 'left' : 'top'
var arrowOffsetPosition = delta.left ? 'offsetWidth' : 'offsetHeight'
$tip.offset(offset) $tip.offset(offset)
this.replaceArrow(arrowDelta, $tip[0][arrowOffsetPosition], arrowPosition)
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
} }
this.replaceArrow(delta - width + actualWidth, actualWidth, 'left') Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
} else { this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
this.replaceArrow(actualHeight - height, actualHeight, 'top')
}
if (replace) $tip.offset(offset)
}
Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
} }
Tooltip.prototype.setContent = function () { Tooltip.prototype.setContent = function () {
@ -260,8 +279,11 @@
var $tip = this.tip() var $tip = this.tip()
var e = $.Event('hide.bs.' + this.type) var e = $.Event('hide.bs.' + this.type)
this.$element.removeAttr('aria-describedby')
function complete() { function complete() {
if (that.hoverState != 'in') $tip.detach() if (that.hoverState != 'in') $tip.detach()
that.$element.trigger('hidden.bs.' + that.type)
} }
this.$element.trigger(e) this.$element.trigger(e)
@ -272,18 +294,18 @@
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
$tip $tip
.one($.support.transition.end, complete) .one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
complete() complete()
this.$element.trigger('hidden.bs.' + this.type) this.hoverState = null
return this return this
} }
Tooltip.prototype.fixTitle = function () { Tooltip.prototype.fixTitle = function () {
var $e = this.$element var $e = this.$element
if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') { if ($e.attr('title') || typeof ($e.attr('data-original-title')) != 'string') {
$e.attr('data-original-title', $e.attr('title') || '').attr('title', '') $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
} }
} }
@ -292,12 +314,22 @@
return this.getTitle() return this.getTitle()
} }
Tooltip.prototype.getPosition = function () { Tooltip.prototype.getPosition = function ($element) {
var el = this.$element[0] $element = $element || this.$element
return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
width: el.offsetWidth var el = $element[0]
, height: el.offsetHeight var isBody = el.tagName == 'BODY'
}, this.$element.offset()) var isSvg = window.SVGElement && el instanceof window.SVGElement
var elRect = el.getBoundingClientRect ? el.getBoundingClientRect() : null
var elOffset = isBody ? { top: 0, left: 0 } : $element.offset()
var scroll = { scroll: isBody ? document.documentElement.scrollTop || document.body.scrollTop : $element.scrollTop() }
var outerDims = isSvg ? {} : {
width: isBody ? $(window).width() : $element.outerWidth(),
height: isBody ? $(window).height() : $element.outerHeight()
}
return $.extend({}, elRect, scroll, outerDims, elOffset)
} }
Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) { Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
@ -305,6 +337,35 @@
placement == 'top' ? { top: pos.top - actualHeight, 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 == '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 } /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
}
Tooltip.prototype.getViewportAdjustedDelta = function (placement, pos, actualWidth, actualHeight) {
var delta = { top: 0, left: 0 }
if (!this.$viewport) return delta
var viewportPadding = this.options.viewport && this.options.viewport.padding || 0
var viewportDimensions = this.getPosition(this.$viewport)
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
}
}
return delta
} }
Tooltip.prototype.getTitle = function () { Tooltip.prototype.getTitle = function () {
@ -318,12 +379,18 @@
return title return title
} }
Tooltip.prototype.getUID = function (prefix) {
do prefix += ~~(Math.random() * 1000000)
while (document.getElementById(prefix))
return prefix
}
Tooltip.prototype.tip = function () { Tooltip.prototype.tip = function () {
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 () {
@ -347,11 +414,20 @@
} }
Tooltip.prototype.toggle = function (e) { Tooltip.prototype.toggle = function (e) {
var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this 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) self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
} }
Tooltip.prototype.destroy = function () { Tooltip.prototype.destroy = function () {
clearTimeout(this.timeout)
this.hide().$element.off('.' + this.type).removeData('bs.' + this.type) this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
} }
@ -359,19 +435,21 @@
// TOOLTIP PLUGIN DEFINITION // TOOLTIP PLUGIN DEFINITION
// ========================= // =========================
var old = $.fn.tooltip function Plugin(option) {
$.fn.tooltip = function (option) {
return this.each(function () { return this.each(function () {
var $this = $(this) var $this = $(this)
var data = $this.data('bs.tooltip') var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option var options = typeof option == 'object' && option
if (!data && option == 'destroy') return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options))) 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

View file

@ -1,24 +1,14 @@
/* ======================================================================== /* ========================================================================
* Bootstrap: transition.js v3.0.3 * Bootstrap: transition.js v3.2.0
* http://getbootstrap.com/javascript/#transitions * http://getbootstrap.com/javascript/#transitions
* ======================================================================== * ========================================================================
* Copyright 2013 Twitter, Inc. * Copyright 2011-2014 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 ($) { "use strict"; +function ($) {
'use strict';
// CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
// ============================================================ // ============================================================
@ -27,10 +17,10 @@
var el = document.createElement('bootstrap') var el = document.createElement('bootstrap')
var transEndEventNames = { var transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd' WebkitTransition : 'webkitTransitionEnd',
, 'MozTransition' : 'transitionend' MozTransition : 'transitionend',
, 'OTransition' : 'oTransitionEnd otransitionend' OTransition : 'oTransitionEnd otransitionend',
, 'transition' : 'transitionend' transition : 'transitionend'
} }
for (var name in transEndEventNames) { for (var name in transEndEventNames) {
@ -38,12 +28,15 @@
return { end: transEndEventNames[name] } return { end: transEndEventNames[name] }
} }
} }
return false // explicit for ie8 ( ._.)
} }
// http://blog.alexmaccaw.com/css-transitions // http://blog.alexmaccaw.com/css-transitions
$.fn.emulateTransitionEnd = function (duration) { $.fn.emulateTransitionEnd = function (duration) {
var called = false, $el = this var called = false
$(this).one($.support.transition.end, function () { called = true }) var $el = this
$(this).one('bsTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger($.support.transition.end) } var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
setTimeout(callback, duration) setTimeout(callback, duration)
return this return this
@ -51,6 +44,16 @@
$(function () { $(function () {
$.support.transition = transitionEnd() $.support.transition = transitionEnd()
if (!$.support.transition) return
$.event.special.bsTransitionEnd = {
bindType: $.support.transition.end,
delegateType: $.support.transition.end,
handle: function (e) {
if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
}
}
}) })
}(jQuery); }(jQuery);