aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-04-08 20:51:56 -0700
committerMark Otto <[email protected]>2014-04-08 20:51:56 -0700
commit11a835f56662f8a93e2f8d27038c683d901a5a72 (patch)
treee731f33d712272472b82c7c6b5de660735a78217 /js
parentb57396944a39b21571848728b6ad479cd50537cd (diff)
parent9863344e9a7ef47379c8308baa5647a07d332799 (diff)
downloadbootstrap-11a835f56662f8a93e2f8d27038c683d901a5a72.tar.xz
bootstrap-11a835f56662f8a93e2f8d27038c683d901a5a72.zip
Merge branch 'master' into equal-height-experiment
Diffstat (limited to 'js')
-rw-r--r--js/carousel.js8
-rw-r--r--js/collapse.js13
-rw-r--r--js/modal.js23
-rw-r--r--js/tests/unit/dropdown.js8
-rw-r--r--js/tests/unit/modal.js10
5 files changed, 31 insertions, 31 deletions
diff --git a/js/carousel.js b/js/carousel.js
index 6d6fa0aee..9f063aec0 100644
--- a/js/carousel.js
+++ b/js/carousel.js
@@ -59,7 +59,7 @@
if (pos > (this.$items.length - 1) || pos < 0) return
- if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) })
+ if (this.sliding) return this.$element.one('slid.bs.carousel', function () { that.to(pos) }) // yes, "slid". not a typo. past tense of "to slide".
if (activeIndex == pos) return this.pause().cycle()
return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
@@ -113,7 +113,7 @@
if (this.$indicators.length) {
this.$indicators.find('.active').removeClass('active')
- this.$element.one('slid.bs.carousel', function () {
+ this.$element.one('slid.bs.carousel', function () { // yes, "slid". not a typo. past tense of "to slide".
var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
$nextIndicator && $nextIndicator.addClass('active')
})
@@ -129,14 +129,14 @@
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
that.sliding = false
- setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0)
+ setTimeout(function () { that.$element.trigger('slid.bs.carousel') }, 0) // yes, "slid". not a typo. past tense of "to slide".
})
.emulateTransitionEnd($active.css('transition-duration').slice(0, -1) * 1000)
} else {
$active.removeClass('active')
$next.addClass('active')
this.sliding = false
- this.$element.trigger('slid.bs.carousel')
+ this.$element.trigger('slid.bs.carousel') // yes, "slid". not a typo. past tense of "to slide".
}
isCycling && this.cycle()
diff --git a/js/collapse.js b/js/collapse.js
index 59e27f13d..6f2205b6f 100644
--- a/js/collapse.js
+++ b/js/collapse.js
@@ -51,8 +51,7 @@
this.$element
.removeClass('collapse')
- .addClass('collapsing')
- [dimension](0)
+ .addClass('collapsing')[dimension](0)
this.transitioning = 1
@@ -60,8 +59,7 @@
if (e && e.target != this.$element[0]) return
this.$element
.removeClass('collapsing')
- .addClass('collapse in')
- [dimension]('auto')
+ .addClass('collapse in')[dimension]('auto')
this.transitioning = 0
this.$element.trigger('shown.bs.collapse')
}
@@ -72,8 +70,7 @@
this.$element
.one($.support.transition.end, $.proxy(complete, this))
- .emulateTransitionEnd(350)
- [dimension](this.$element[0][scrollSize])
+ .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
}
Collapse.prototype.hide = function () {
@@ -85,9 +82,7 @@
var dimension = this.dimension()
- this.$element
- [dimension](this.$element[dimension]())
- [0].offsetHeight
+ this.$element[dimension](this.$element[dimension]())[0].offsetHeight
this.$element
.addClass('collapsing')
diff --git a/js/modal.js b/js/modal.js
index ec358696f..a55363728 100644
--- a/js/modal.js
+++ b/js/modal.js
@@ -14,11 +14,12 @@
// ======================
var Modal = function (element, options) {
- this.options = options
- this.$body = $(document.body)
- this.$element = $(element)
- this.$backdrop =
- this.isShown = null
+ this.options = options
+ this.$body = $(document.body)
+ this.$element = $(element)
+ this.$backdrop =
+ this.isShown = null
+ this.scrollbarWidth = 0
if (this.options.remote) {
this.$element
@@ -49,6 +50,7 @@
this.isShown = true
+ this.checkScrollbar()
this.$body.addClass('modal-open')
this.setScrollbar()
@@ -195,11 +197,14 @@
}
}
+ Modal.prototype.checkScrollbar = function () {
+ if (document.body.clientWidth >= window.innerWidth) return
+ this.scrollbarWidth = this.scrollbarWidth || this.measureScrollbar()
+ }
+
Modal.prototype.setScrollbar = function () {
- if (document.body.clientHeight <= window.innerHeight) return
- var scrollbarWidth = this.measureScrollbar()
- var bodyPad = parseInt(this.$body.css('padding-right') || 0)
- if (scrollbarWidth) this.$body.css('padding-right', bodyPad + scrollbarWidth)
+ var bodyPad = parseInt(this.$body.css('padding-right') || 0)
+ if (this.scrollbarWidth) this.$body.css('padding-right', bodyPad + this.scrollbarWidth)
}
Modal.prototype.resetScrollbar = function () {
diff --git a/js/tests/unit/dropdown.js b/js/tests/unit/dropdown.js
index 8597426cd..2d2e7c51d 100644
--- a/js/tests/unit/dropdown.js
+++ b/js/tests/unit/dropdown.js
@@ -169,10 +169,10 @@ $(function () {
dropdown
.parent('.dropdown')
- .bind('show.bs.dropdown', function () {
+ .on('show.bs.dropdown', function () {
ok(true, 'show was called')
})
- .bind('hide.bs.dropdown', function () {
+ .on('hide.bs.dropdown', function () {
ok(true, 'hide was called')
start()
})
@@ -203,10 +203,10 @@ $(function () {
dropdown
.parent('.dropdown')
- .bind('shown.bs.dropdown', function () {
+ .on('shown.bs.dropdown', function () {
ok(true, 'show was called')
})
- .bind('hidden.bs.dropdown', function () {
+ .on('hidden.bs.dropdown', function () {
ok(true, 'hide was called')
start()
})
diff --git a/js/tests/unit/modal.js b/js/tests/unit/modal.js
index b026d18c4..34912c2e9 100644
--- a/js/tests/unit/modal.js
+++ b/js/tests/unit/modal.js
@@ -140,13 +140,13 @@ $(function () {
$.support.transition = false
var div = $('<div id="modal-test"><div class="contents"></div></div>')
div
- .bind('shown.bs.modal', function () {
+ .on('shown.bs.modal', function () {
ok($('#modal-test').length, 'modal insterted into dom')
$('.contents').click()
ok($('#modal-test').is(':visible'), 'modal visible')
$('#modal-test').click()
})
- .bind('hidden.bs.modal', function () {
+ .on('hidden.bs.modal', function () {
ok(!$('#modal-test').is(':visible'), 'modal hidden')
div.remove()
start()
@@ -162,11 +162,11 @@ $(function () {
var div = $('<div id="modal-test"><div class="contents"></div></div>')
div
- .bind('shown.bs.modal', function () {
+ .on('shown.bs.modal', function () {
triggered = 0
$('#modal-test').click()
})
- .bind('hide.bs.modal', function () {
+ .on('hide.bs.modal', function () {
triggered += 1
ok(triggered === 1, 'modal hide triggered once')
start()
@@ -179,7 +179,7 @@ $(function () {
$.support.transition = false
var div = $('<div id="modal-test"><div class="contents"><div id="close" data-dismiss="modal"></div></div></div>')
div
- .bind('shown.bs.modal', function () {
+ .on('shown.bs.modal', function () {
$('#close').click()
ok(!$('#modal-test').is(':visible'), 'modal hidden')
})