Commit 5a7f3f72 authored by Jacob Thornton's avatar Jacob Thornton

clean up js a tiny bit

parent 8245a708
$(document).ready(function(){ $(document).ready(function(){
// Example dropdown for topbar nav // scroll spy logic
// ================
var activeTarget,
$window = $(window),
position = {},
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) { $("body").bind("click", function(e) {
$("ul.menu-dropdown").hide(); $("ul.menu-dropdown").hide();
$('a.menu').parent("li").removeClass("open").children("ul.menu-dropdown").hide(); $('a.menu').parent("li").removeClass("open").children("ul.menu-dropdown").hide();
...@@ -23,10 +64,16 @@ $(document).ready(function(){ ...@@ -23,10 +64,16 @@ $(document).ready(function(){
return false; return false;
}); });
// table sort example // table sort example
// ==================
$("#sortTableExample").tablesorter( {sortList: [[1,0]]} ); $("#sortTableExample").tablesorter( {sortList: [[1,0]]} );
// add on
// add on logic
// ============
$('.add-on :checkbox').click(function() { $('.add-on :checkbox').click(function() {
if ($(this).attr('checked')) { if ($(this).attr('checked')) {
$(this).parents('.add-on').addClass('active'); $(this).parents('.add-on').addClass('active');
...@@ -35,7 +82,10 @@ $(document).ready(function(){ ...@@ -35,7 +82,10 @@ $(document).ready(function(){
} }
}); });
// Disable certain links in docs // Disable certain links in docs
// =============================
$('ul.tabs a, ul.pills a, .pagination a').click(function(e) { $('ul.tabs a, ul.pills a, .pagination a').click(function(e) {
e.preventDefault(); e.preventDefault();
}); });
...@@ -49,44 +99,9 @@ $(document).ready(function(){ ...@@ -49,44 +99,9 @@ $(document).ready(function(){
}); });
// scroll spyer
var activeTarget,
$window = $(window),
position = {},
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);
// POSITION TWIPSIES // POSITION TWIPSIES
// ================= // =================
$('.twipsies.well a').each(function () { $('.twipsies.well a').each(function () {
var type = this.title var type = this.title
, $anchor = $(this) , $anchor = $(this)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment