From 8245a7087eac2e0725f2546d7bac9e68de94f58e Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 1 Jul 2011 21:30:12 -0700 Subject: add twipsies... --- docs/assets/js/application.js | 44 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'docs/assets') diff --git a/docs/assets/js/application.js b/docs/assets/js/application.js index 8a74c2eb3..8f54c9969 100644 --- a/docs/assets/js/application.js +++ b/docs/assets/js/application.js @@ -34,7 +34,7 @@ $(document).ready(function(){ $(this).parents('.add-on').removeClass('active'); } }); - + // Disable certain links in docs $('ul.tabs a, ul.pills a, .pagination a').click(function(e) { e.preventDefault(); @@ -84,4 +84,46 @@ $(document).ready(function(){ processScroll(); $window.scroll(processScroll); + + // POSITION TWIPSIES + // ================= + $('.twipsies.well a').each(function () { + var type = this.title + , $anchor = $(this) + , $twipsy = $('.twipsy.' + type) + + , twipsy = { + width: $twipsy.width() + 10 + , height: $twipsy.height() + 10 + } + + , anchor = { + position: $anchor.position() + , width: $anchor.width() + , height: $anchor.height() + } + + , offset = { + above: { + top: anchor.position.top - twipsy.height + , left: anchor.position.left + (anchor.width/2) - (twipsy.width/2) + } + , below: { + top: anchor.position.top + anchor.height + , left: anchor.position.left + (anchor.width/2) - (twipsy.width/2) + } + , left: { + top: anchor.position.top + (anchor.height/2) - (twipsy.height/2) + , left: anchor.position.left - twipsy.width - 5 + } + , right: { + top: anchor.position.top + (anchor.height/2) - (twipsy.height/2) + , left: anchor.position.left + anchor.width + 5 + } + } + + $twipsy.css(offset[type]) + + }); + }); \ No newline at end of file -- cgit v1.2.3 From 5a7f3f72cbc86d79ac6c5967eed39be72bc08561 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 1 Jul 2011 21:37:12 -0700 Subject: clean up js a tiny bit --- docs/assets/js/application.js | 91 +++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 38 deletions(-) (limited to 'docs/assets') diff --git a/docs/assets/js/application.js b/docs/assets/js/application.js index 8f54c9969..8b29f6c21 100644 --- a/docs/assets/js/application.js +++ b/docs/assets/js/application.js @@ -1,6 +1,47 @@ $(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) { $("ul.menu-dropdown").hide(); $('a.menu').parent("li").removeClass("open").children("ul.menu-dropdown").hide(); @@ -23,10 +64,16 @@ $(document).ready(function(){ return false; }); + // table sort example + // ================== + $("#sortTableExample").tablesorter( {sortList: [[1,0]]} ); - // add on + + // add on logic + // ============ + $('.add-on :checkbox').click(function() { if ($(this).attr('checked')) { $(this).parents('.add-on').addClass('active'); @@ -35,7 +82,10 @@ $(document).ready(function(){ } }); + // Disable certain links in docs + // ============================= + $('ul.tabs a, ul.pills a, .pagination a').click(function(e) { e.preventDefault(); }); @@ -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 // ================= + $('.twipsies.well a').each(function () { var type = this.title , $anchor = $(this) -- cgit v1.2.3