Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap-rubygem.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/bootstrap.js')
-rw-r--r--assets/javascripts/bootstrap.js136
1 files changed, 69 insertions, 67 deletions
diff --git a/assets/javascripts/bootstrap.js b/assets/javascripts/bootstrap.js
index 5a11cc2..d2f3948 100644
--- a/assets/javascripts/bootstrap.js
+++ b/assets/javascripts/bootstrap.js
@@ -307,10 +307,10 @@ if (typeof jQuery === 'undefined') {
this.$element = $(element)
this.$indicators = this.$element.find('.carousel-indicators')
this.options = options
- this.paused =
- this.sliding =
- this.interval =
- this.$active =
+ this.paused = null
+ this.sliding = null
+ this.interval = null
+ this.$active = null
this.$items = null
this.options.keyboard && this.$element.on('keydown.bs.carousel', $.proxy(this.keydown, this))
@@ -544,7 +544,8 @@ if (typeof jQuery === 'undefined') {
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, Collapse.DEFAULTS, options)
- this.$trigger = $(this.options.trigger).filter('[href="#' + element.id + '"], [data-target="#' + element.id + '"]')
+ this.$trigger = $('[data-toggle="collapse"][href="#' + element.id + '"],' +
+ '[data-toggle="collapse"][data-target="#' + element.id + '"]')
this.transitioning = null
if (this.options.parent) {
@@ -561,8 +562,7 @@ if (typeof jQuery === 'undefined') {
Collapse.TRANSITION_DURATION = 350
Collapse.DEFAULTS = {
- toggle: true,
- trigger: '[data-toggle="collapse"]'
+ toggle: true
}
Collapse.prototype.dimension = function () {
@@ -731,7 +731,7 @@ if (typeof jQuery === 'undefined') {
var $target = getTargetFromTrigger($this)
var data = $target.data('bs.collapse')
- var option = data ? 'toggle' : $.extend({}, $this.data(), { trigger: this })
+ var option = data ? 'toggle' : $this.data()
Plugin.call($target, option)
})
@@ -812,7 +812,7 @@ if (typeof jQuery === 'undefined') {
return $this.trigger('click')
}
- var desc = ' li:not(.divider):visible a'
+ var desc = ' li:not(.disabled):visible a'
var $items = $parent.find('[role="menu"]' + desc + ', [role="listbox"]' + desc)
if (!$items.length) return
@@ -916,12 +916,15 @@ if (typeof jQuery === 'undefined') {
// ======================
var Modal = function (element, options) {
- this.options = options
- this.$body = $(document.body)
- this.$element = $(element)
- this.$backdrop =
- this.isShown = null
- this.scrollbarWidth = 0
+ this.options = options
+ this.$body = $(document.body)
+ this.$element = $(element)
+ this.$dialog = this.$element.find('.modal-dialog')
+ this.$backdrop = null
+ this.isShown = null
+ this.originalBodyPad = null
+ this.scrollbarWidth = 0
+ this.ignoreBackdropClick = false
if (this.options.remote) {
this.$element
@@ -966,6 +969,12 @@ if (typeof jQuery === 'undefined') {
this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this))
+ this.$dialog.on('mousedown.dismiss.bs.modal', function () {
+ that.$element.one('mouseup.dismiss.bs.modal', function (e) {
+ if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true
+ })
+ })
+
this.backdrop(function () {
var transition = $.support.transition && that.$element.hasClass('fade')
@@ -977,7 +986,6 @@ if (typeof jQuery === 'undefined') {
.show()
.scrollTop(0)
- if (that.options.backdrop) that.adjustBackdrop()
that.adjustDialog()
if (transition) {
@@ -993,7 +1001,7 @@ if (typeof jQuery === 'undefined') {
var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget })
transition ?
- that.$element.find('.modal-dialog') // wait for modal to slide in
+ that.$dialog // wait for modal to slide in
.one('bsTransitionEnd', function () {
that.$element.trigger('focus').trigger(e)
})
@@ -1022,6 +1030,9 @@ if (typeof jQuery === 'undefined') {
.removeClass('in')
.attr('aria-hidden', true)
.off('click.dismiss.bs.modal')
+ .off('mouseup.dismiss.bs.modal')
+
+ this.$dialog.off('mousedown.dismiss.bs.modal')
$.support.transition && this.$element.hasClass('fade') ?
this.$element
@@ -1082,13 +1093,18 @@ if (typeof jQuery === 'undefined') {
var doAnimate = $.support.transition && animate
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
- .prependTo(this.$element)
- .on('click.dismiss.bs.modal', $.proxy(function (e) {
- if (e.target !== e.currentTarget) return
- this.options.backdrop == 'static'
- ? this.$element[0].focus.call(this.$element[0])
- : this.hide.call(this)
- }, this))
+ .appendTo(this.$body)
+
+ this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) {
+ if (this.ignoreBackdropClick) {
+ this.ignoreBackdropClick = false
+ return
+ }
+ if (e.target !== e.currentTarget) return
+ this.options.backdrop == 'static'
+ ? this.$element[0].focus()
+ : this.hide()
+ }, this))
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
@@ -1123,16 +1139,9 @@ if (typeof jQuery === 'undefined') {
// these following methods are used to handle overflowing modals
Modal.prototype.handleUpdate = function () {
- if (this.options.backdrop) this.adjustBackdrop()
this.adjustDialog()
}
- Modal.prototype.adjustBackdrop = function () {
- this.$backdrop
- .css('height', 0)
- .css('height', this.$element[0].scrollHeight)
- }
-
Modal.prototype.adjustDialog = function () {
var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight
@@ -1161,11 +1170,12 @@ if (typeof jQuery === 'undefined') {
Modal.prototype.setScrollbar = function () {
var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10)
+ this.originalBodyPad = document.body.style.paddingRight || ''
if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
}
Modal.prototype.resetScrollbar = function () {
- this.$body.css('padding-right', '')
+ this.$body.css('padding-right', this.originalBodyPad)
}
Modal.prototype.measureScrollbar = function () { // thx walsh
@@ -1247,11 +1257,11 @@ if (typeof jQuery === 'undefined') {
// ===============================
var Tooltip = function (element, options) {
- this.type =
- this.options =
- this.enabled =
- this.timeout =
- this.hoverState =
+ this.type = null
+ this.options = null
+ this.enabled = null
+ this.timeout = null
+ this.hoverState = null
this.$element = null
this.init('tooltip', element, options)
@@ -1285,7 +1295,7 @@ if (typeof jQuery === 'undefined') {
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
- throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!');
+ throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')
}
var triggers = this.options.trigger.split(' ')
@@ -1524,7 +1534,7 @@ if (typeof jQuery === 'undefined') {
Tooltip.prototype.hide = function (callback) {
var that = this
- var $tip = this.tip()
+ var $tip = $(this.$tip)
var e = $.Event('hide.bs.' + this.type)
function complete() {
@@ -1541,7 +1551,7 @@ if (typeof jQuery === 'undefined') {
$tip.removeClass('in')
- $.support.transition && this.$tip.hasClass('fade') ?
+ $.support.transition && $tip.hasClass('fade') ?
$tip
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(Tooltip.TRANSITION_DURATION) :
@@ -1685,7 +1695,7 @@ if (typeof jQuery === 'undefined') {
var data = $this.data('bs.tooltip')
var options = typeof option == 'object' && option
- if (!data && option == 'destroy') return
+ if (!data && /destroy|hide/.test(option)) return
if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
if (typeof option == 'string') data[option]()
})
@@ -1784,11 +1794,6 @@ if (typeof jQuery === 'undefined') {
return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
}
- Popover.prototype.tip = function () {
- if (!this.$tip) this.$tip = $(this.options.template)
- return this.$tip
- }
-
// POPOVER PLUGIN DEFINITION
// =========================
@@ -1799,7 +1804,7 @@ if (typeof jQuery === 'undefined') {
var data = $this.data('bs.popover')
var options = typeof option == 'object' && option
- if (!data && option == 'destroy') return
+ if (!data && /destroy|hide/.test(option)) return
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
if (typeof option == 'string') data[option]()
})
@@ -1837,10 +1842,8 @@ if (typeof jQuery === 'undefined') {
// ==========================
function ScrollSpy(element, options) {
- var process = $.proxy(this.process, this)
-
- this.$body = $('body')
- this.$scrollElement = $(element).is('body') ? $(window) : $(element)
+ this.$body = $(document.body)
+ this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
this.selector = (this.options.target || '') + ' .nav li > a'
this.offsets = []
@@ -1848,7 +1851,7 @@ if (typeof jQuery === 'undefined') {
this.activeTarget = null
this.scrollHeight = 0
- this.$scrollElement.on('scroll.bs.scrollspy', process)
+ this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
this.refresh()
this.process()
}
@@ -1864,20 +1867,19 @@ if (typeof jQuery === 'undefined') {
}
ScrollSpy.prototype.refresh = function () {
- var offsetMethod = 'offset'
- var offsetBase = 0
+ var that = this
+ var offsetMethod = 'offset'
+ var offsetBase = 0
+
+ this.offsets = []
+ this.targets = []
+ this.scrollHeight = this.getScrollHeight()
if (!$.isWindow(this.$scrollElement[0])) {
offsetMethod = 'position'
offsetBase = this.$scrollElement.scrollTop()
}
- this.offsets = []
- this.targets = []
- this.scrollHeight = this.getScrollHeight()
-
- var self = this
-
this.$body
.find(this.selector)
.map(function () {
@@ -1892,8 +1894,8 @@ if (typeof jQuery === 'undefined') {
})
.sort(function (a, b) { return a[0] - b[0] })
.each(function () {
- self.offsets.push(this[0])
- self.targets.push(this[1])
+ that.offsets.push(this[0])
+ that.targets.push(this[1])
})
}
@@ -1922,7 +1924,7 @@ if (typeof jQuery === 'undefined') {
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
+ && (offsets[i + 1] === undefined || scrollTop <= offsets[i + 1])
&& this.activate(targets[i])
}
}
@@ -1933,8 +1935,8 @@ if (typeof jQuery === 'undefined') {
this.clear()
var selector = this.selector +
- '[data-target="' + target + '"],' +
- this.selector + '[href="' + target + '"]'
+ '[data-target="' + target + '"],' +
+ this.selector + '[href="' + target + '"]'
var active = $(selector)
.parents('li')
@@ -2174,8 +2176,8 @@ if (typeof jQuery === 'undefined') {
.on('click.bs.affix.data-api', $.proxy(this.checkPositionWithEventLoop, this))
this.$element = $(element)
- this.affixed =
- this.unpin =
+ this.affixed = null
+ this.unpin = null
this.pinnedOffset = null
this.checkPosition()