1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-25 21:09:06 +02:00

some more js love - update the docs with tabs/pills plugin

This commit is contained in:
Jacob Thornton
2011-09-08 20:21:03 -07:00
parent 346122a0c7
commit 5960711d0f
11 changed files with 143 additions and 120 deletions

View File

@@ -1,96 +1,46 @@
$(document).ready(function(){
// Google code prettify
// ====================
prettyPrint();
// scroll spy logic
// ================
var activeTarget,
position = {},
$window = $(window),
nav = $('body > .topbar li a'),
targets = nav.map(function () {
return $(this).attr('href');
}),
offsets = $.map(targets, function (id) {
return $(id).offset().top;
});
function setButton(id) {
nav.parent("li").removeClass('active');
$(nav[$.inArray(id, targets)]).parent("li").addClass('active');
}
function processScroll(e) {
var scrollTop = $window.scrollTop() + 10, i;
for (i = offsets.length; i--;) {
if (activeTarget != targets[i] && scrollTop >= offsets[i] && (!offsets[i + 1] || scrollTop <= offsets[i + 1])) {
activeTarget = targets[i];
setButton(activeTarget);
}
}
}
nav.click(function () {
processScroll();
});
processScroll();
$window.scroll(processScroll);
// Dropdown example for topbar nav
// ===============================
$("body").bind("click", function (e) {
$('.dropdown-toggle, .menu').parent("li").removeClass("open");
});
$(".dropdown-toggle, .menu").click(function (e) {
var $li = $(this).parent("li").toggleClass('open');
return false;
});
$(".topbar").dropdown() // catch any dropdowns on the page
// table sort example
// ==================
$("#sortTableExample").tablesorter( {sortList: [[1,0]]} );
$("#sortTableExample").tablesorter( { sortList: [[ 1, 0 ]] } )
// add on logic
// ============
$('.add-on :checkbox').click(function() {
$('.add-on :checkbox').click(function () {
if ($(this).attr('checked')) {
$(this).parents('.add-on').addClass('active');
$(this).parents('.add-on').addClass('active')
} else {
$(this).parents('.add-on').removeClass('active');
$(this).parents('.add-on').removeClass('active')
}
});
})
// Disable certain links in docs
// =============================
$('ul.tabs a, ul.pills a, .pagination a, .well .btn, .actions .btn, .alert-message .btn, a.close').click(function(e) {
e.preventDefault();
});
$('ul.tabs a, ul.pills a, .pagination a, .well .btn, .actions .btn, .alert-message .btn, a.close').click(function (e) {
e.preventDefault()
})
// Copy code blocks in docs
$(".copy-code").focus(function() {
$(".copy-code").focus(function () {
var el = this;
// push select to event loop for chrome :{o
setTimeout(function () { $(el).select(); }, 1);
});
// POSITION TWIPSIES
// =================
// POSITION STATIC TWIPSIES
// ========================
$('.twipsies.well a').each(function () {
var type = this.title
@@ -128,7 +78,6 @@ $(document).ready(function(){
}
$twipsy.css(offset[type])
});
});