0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-01-17 09:52:29 +01:00

Merge branch '3.0.0-wip' of github.com:twitter/bootstrap into 3.0.0-wip

This commit is contained in:
Mark Otto 2013-07-26 20:53:26 -07:00
commit 27a656f72e
11 changed files with 179 additions and 84 deletions

View File

@ -15,13 +15,11 @@
offset: navHeight offset: navHeight
}) })
// Disable certain links in docs $('[href^=#]').click(function (e) {
$('.bs-docs-container [href=#]').click(function (e) {
e.preventDefault() e.preventDefault()
}) })
$(document.body).on('click', '[href^=#]', function (e) { $(document.body).on('click', '.bs-sidenav [href^=#]', function (e) {
var $target = $(this.getAttribute('href')) var $target = $(this.getAttribute('href'))
e.preventDefault() // prevent browser scroll e.preventDefault() // prevent browser scroll

View File

@ -2016,6 +2016,14 @@ input[type="button"].btn-block {
} }
.collapse { .collapse {
display: none;
}
.collapse.in {
display: block;
}
.collapsing {
position: relative; position: relative;
height: 0; height: 0;
overflow: hidden; overflow: hidden;
@ -2023,10 +2031,6 @@ input[type="button"].btn-block {
transition: height 0.35s ease; transition: height 0.35s ease;
} }
.collapse.in {
height: auto;
}
.caret { .caret {
display: inline-block; display: inline-block;
width: 0; width: 0;
@ -2939,6 +2943,7 @@ button.close {
display: none; display: none;
} }
.nav-collapse.collapse { .nav-collapse.collapse {
display: block !important;
height: auto !important; height: auto !important;
overflow: visible !important; overflow: visible !important;
} }

File diff suppressed because one or more lines are too long

80
dist/js/bootstrap.js vendored
View File

@ -53,6 +53,7 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
$(this).one('webkitTransitionEnd', function () { called = true }) $(this).one('webkitTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') } var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') }
setTimeout(callback, duration) setTimeout(callback, duration)
return this
} }
$(function () { $(function () {
@ -532,8 +533,6 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
this.$element.trigger(startEvent) this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
var scroll = $.camelCase(['scroll', dimension].join('-'))
var actives = this.$parent && this.$parent.find('> .accordion-group > .in') var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
if (actives && actives.length) { if (actives && actives.length) {
@ -543,10 +542,32 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
hasData || actives.data('bs.collapse', null) hasData || actives.data('bs.collapse', null)
} }
this.$element[dimension](0) var dimension = this.dimension()
this.transition('addClass', 'shown.bs.collapse')
if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) this.$element
.removeClass('collapse')
.addClass('collapsing')
[dimension](0)
this.transitioning = 1
var complete = function () {
this.$element
.removeClass('collapsing')
.addClass('in')
[dimension]('auto')
this.transitioning = 0
this.$element.trigger('shown.bs.collapse')
}
if (!$.support.transition) return complete.call(this)
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
[dimension](this.$element[0][scrollSize])
} }
Collapse.prototype.hide = function () { Collapse.prototype.hide = function () {
@ -556,42 +577,33 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
this.$element.trigger(startEvent) this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', 'hidden.bs.collapse')
this.$element[dimension](0)
}
Collapse.prototype.reset = function (size) {
var dimension = this.dimension() var dimension = this.dimension()
this.$element this.$element
[dimension](this.$element[dimension]())
[0].offsetHeight
this.$element
.addClass('collapsing')
.removeClass('collapse') .removeClass('collapse')
[dimension](size || 'auto') .removeClass('in')
[0].offsetWidth
this.$element[size != null ? 'addClass' : 'removeClass']('collapse')
return this
}
Collapse.prototype.transition = function (method, completeEvent) {
var that = this
var complete = function () {
if (completeEvent == 'shown.bs.collapse') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
this.transitioning = 1 this.transitioning = 1
this.$element[method]('in') var complete = function () {
this.transitioning = 0
$.support.transition && this.$element.hasClass('collapse') ?
this.$element this.$element
.one($.support.transition.end, complete) .trigger('hidden.bs.collapse')
.emulateTransitionEnd(350) : .removeClass('collapsing')
complete() .addClass('collapse')
}
if (!$.support.transition) return complete.call(this)
this.$element
[dimension](0)
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
} }
Collapse.prototype.toggle = function () { Collapse.prototype.toggle = function () {
@ -1442,6 +1454,8 @@ if (!jQuery) { throw new Error("Bootstrap requires jQuery") }
this.init('popover', element, options) this.init('popover', element, options)
} }
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, { Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
placement: 'right' placement: 'right'
, trigger: 'click' , trigger: 'click'

File diff suppressed because one or more lines are too long

View File

@ -856,10 +856,41 @@ $('#example').tooltip(options)
<h4>.tooltip('destroy')</h4> <h4>.tooltip('destroy')</h4>
<p>Hides and destroys an element's tooltip.</p> <p>Hides and destroys an element's tooltip.</p>
{% highlight js %}$('#element').tooltip('destroy'){% endhighlight %} {% highlight js %}$('#element').tooltip('destroy'){% endhighlight %}
<h3>Events</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 150px;">Event Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>This event fires immediately when the <code>show</code> instance method is called.</td>
</tr>
<tr>
<td>shown</td>
<td>This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete).</td>
</tr>
<tr>
<td>hide</td>
<td>This event is fired immediately when the <code>hide</code> instance method has been called.</td>
</tr>
<tr>
<td>hidden</td>
<td>This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete).</td>
</tr>
</tbody>
</table>
{% highlight js %}
$('#myTooltip').on('hidden.bs.tooltip', function () {
// do something…
})
{% endhighlight %}
</div> </div>
<!-- Popovers <!-- Popovers
================================================== --> ================================================== -->
<div class="bs-docs-section"> <div class="bs-docs-section">
@ -1046,10 +1077,40 @@ $('#example').tooltip(options)
<h4>.popover('destroy')</h4> <h4>.popover('destroy')</h4>
<p>Hides and destroys an element's popover.</p> <p>Hides and destroys an element's popover.</p>
{% highlight js %}$('#element').popover('destroy'){% endhighlight %} {% highlight js %}$('#element').popover('destroy'){% endhighlight %}
<h3>Events</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th style="width: 150px;">Event Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>This event fires immediately when the <code>show</code> instance method is called.</td>
</tr>
<tr>
<td>shown</td>
<td>This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete).</td>
</tr>
<tr>
<td>hide</td>
<td>This event is fired immediately when the <code>hide</code> instance method has been called.</td>
</tr>
<tr>
<td>hidden</td>
<td>This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete).</td>
</tr>
</tbody>
</table>
{% highlight js %}
$('#myPopover').on('hidden.bs.popover', function () {
// do something…
})
{% endhighlight %}
</div> </div>
<!-- Alert <!-- Alert
================================================== --> ================================================== -->
<div class="bs-docs-section"> <div class="bs-docs-section">

View File

@ -48,8 +48,6 @@
this.$element.trigger(startEvent) this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
var scroll = $.camelCase(['scroll', dimension].join('-'))
var actives = this.$parent && this.$parent.find('> .accordion-group > .in') var actives = this.$parent && this.$parent.find('> .accordion-group > .in')
if (actives && actives.length) { if (actives && actives.length) {
@ -59,10 +57,32 @@
hasData || actives.data('bs.collapse', null) hasData || actives.data('bs.collapse', null)
} }
this.$element[dimension](0) var dimension = this.dimension()
this.transition('addClass', 'shown.bs.collapse')
if ($.support.transition) this.$element[dimension](this.$element[0][scroll]) this.$element
.removeClass('collapse')
.addClass('collapsing')
[dimension](0)
this.transitioning = 1
var complete = function () {
this.$element
.removeClass('collapsing')
.addClass('in')
[dimension]('auto')
this.transitioning = 0
this.$element.trigger('shown.bs.collapse')
}
if (!$.support.transition) return complete.call(this)
var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
[dimension](this.$element[0][scrollSize])
} }
Collapse.prototype.hide = function () { Collapse.prototype.hide = function () {
@ -72,42 +92,33 @@
this.$element.trigger(startEvent) this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return if (startEvent.isDefaultPrevented()) return
var dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', 'hidden.bs.collapse')
this.$element[dimension](0)
}
Collapse.prototype.reset = function (size) {
var dimension = this.dimension() var dimension = this.dimension()
this.$element this.$element
[dimension](this.$element[dimension]())
[0].offsetHeight
this.$element
.addClass('collapsing')
.removeClass('collapse') .removeClass('collapse')
[dimension](size || 'auto') .removeClass('in')
[0].offsetWidth
this.$element[size != null ? 'addClass' : 'removeClass']('collapse')
return this
}
Collapse.prototype.transition = function (method, completeEvent) {
var that = this
var complete = function () {
if (completeEvent == 'shown.bs.collapse') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
this.transitioning = 1 this.transitioning = 1
this.$element[method]('in') var complete = function () {
this.transitioning = 0
$.support.transition && this.$element.hasClass('collapse') ?
this.$element this.$element
.one($.support.transition.end, complete) .trigger('hidden.bs.collapse')
.emulateTransitionEnd(350) : .removeClass('collapsing')
complete() .addClass('collapse')
}
if (!$.support.transition) return complete.call(this)
this.$element
[dimension](0)
.one($.support.transition.end, $.proxy(complete, this))
.emulateTransitionEnd(350)
} }
Collapse.prototype.toggle = function () { Collapse.prototype.toggle = function () {

View File

@ -27,6 +27,8 @@
this.init('popover', element, options) this.init('popover', element, options)
} }
if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, { Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
placement: 'right' placement: 'right'
, trigger: 'click' , trigger: 'click'

View File

@ -46,6 +46,7 @@
$(this).one('webkitTransitionEnd', function () { called = true }) $(this).one('webkitTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') } var callback = function () { if (!called) $($el).trigger('webkitTransitionEnd') }
setTimeout(callback, duration) setTimeout(callback, duration)
return this
} }
$(function () { $(function () {

View File

@ -16,12 +16,14 @@
} }
.collapse { .collapse {
display: none;
&.in {
display: block;
}
}
.collapsing {
position: relative; position: relative;
height: 0; height: 0;
overflow: hidden; overflow: hidden;
.transition(height .35s ease); .transition(height .35s ease);
&.in {
height: auto;
}
} }

View File

@ -330,6 +330,7 @@
display: none; display: none;
} }
.nav-collapse.collapse { .nav-collapse.collapse {
display: block !important;
height: auto !important; height: auto !important;
overflow: visible !important; overflow: visible !important;
} }