1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-10 23:54:08 +02:00

update all to new on api + add animation support to tabs

This commit is contained in:
Jacob Thornton
2011-12-20 19:37:41 -08:00
parent 1ef5fa7d6b
commit 0980a33b47
10 changed files with 110 additions and 78 deletions

View File

@@ -9,11 +9,11 @@ We believe you should be able to use all plugins provided by Bootstrap purely th
We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this:
$('body').unbind('.data-api')
$('body').off('.data-api')
To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this:
$('body').unbind('.alert.data-api')
$('body').off('.alert.data-api')
---

View File

@@ -46,7 +46,7 @@
}
$.support.transition && $element.hasClass('fade') ?
$element.bind($.support.transition.end, removeElement) :
$element.on($.support.transition.end, removeElement) :
removeElement()
}

View File

@@ -96,7 +96,7 @@
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
that.$element.unbind($.support.transition.end)
that.$element.off($.support.transition.end)
hideModal.call(that)
}, 500)
@@ -156,11 +156,11 @@
function escape() {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).bind('keyup.dismiss.modal', function ( e ) {
$(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).unbind('keyup.dismiss.modal')
$(document).off('keyup.dismiss.modal')
}
}

View File

@@ -63,8 +63,7 @@
, tip: function() {
if (!this.$tip) {
this.$tip = $('<div class="popover" />')
.html(this.options.template)
this.$tip = $(this.options.template)
}
return this.$tip
}
@@ -90,7 +89,7 @@
$.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, {
placement: 'right'
, content: ''
, template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>'
, template: '<div class="popover"><div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div></div>'
})
}( window.jQuery )

View File

@@ -27,7 +27,7 @@
function ScrollSpy( element ) {
var process = $.proxy(this.process, this)
this.$scrollElement = $(element).bind('scroll.scroll.data-api', process)
this.$scrollElement = $(element).on('scroll.scroll.data-api', process)
this.selector = (this.$scrollElement.attr('data-target')
|| this.$scrollElement.attr('href')
|| '') + ' .nav li > a'

47
js/bootstrap-tab.js vendored
View File

@@ -52,26 +52,45 @@
$href = $(href)
this.activate($this.parent('li'), $ul)
this.activate($href, $href.parent())
$this.trigger({
type: 'shown'
, relatedTarget: previous
this.activate($href, $href.parent(), function () {
$this.trigger({
type: 'shown'
, relatedTarget: previous
})
})
}
, activate: function ( element, container ) {
container
.find('> .active')
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
, activate: function ( element, container, callback) {
var $active = container.find('> .active')
, transition = callback
&& $.support.transition
&& $active.hasClass('fade')
element.addClass('active')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
if ( element.parent('.dropdown-menu') ) {
element.closest('li.dropdown').addClass('active')
element.addClass('active')
if (transition) {
element[0].offsetWidth // reflow for transition
element.addClass('in')
}
if ( element.parent('.dropdown-menu') ) {
element.closest('li.dropdown').addClass('active')
}
callback && callback()
}
transition ?
$active.one($.support.transition.end, next) :
next()
$active.removeClass('in')
}
}

View File

@@ -167,7 +167,7 @@
}
$.support.transition && this.$tip.hasClass('fade') ?
$tip.bind( $.support.transition.end, removeElement) :
$tip.on($.support.transition.end, removeElement) :
removeElement()
}
@@ -196,7 +196,7 @@
}
, tip: function () {
return this.$tip = this.$tip || $('<div class="twipsy" />').html(this.options.template)
return this.$tip = this.$tip || $(this.options.template)
}
, validate: function () {
@@ -256,7 +256,7 @@
, placement: 'above'
, trigger: 'hover'
, title: ''
, template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
, template: '<div class="twipsy"><div class="twipsy-arrow"></div><div class="twipsy-inner"></div></div>'
}
}( window.jQuery )