]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
clean up js a tiny bit
authorJacob Thornton <jacobthornton@gmail.com>
Sat, 2 Jul 2011 04:37:12 +0000 (21:37 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Sat, 2 Jul 2011 04:37:12 +0000 (21:37 -0700)
docs/assets/js/application.js

index 8f54c996995d96cd594d8fa2af2b7942d555b988..8b29f6c21a113452ede7c5e029462b354736d65c 100644 (file)
@@ -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)