Permalink
Browse files

prettier js

  • Loading branch information...
1 parent a334178 commit 44dd11607213a7a18d701de1e44144fefd039336 @ghiculescu committed Apr 7, 2013
Showing with 5 additions and 10 deletions.
  1. +2 −4 js/nav.js
  2. +3 −6 js/toc.js
View
@@ -1,6 +1,5 @@
$(document).ready(function() {
- var nav = $('ul.nav')
- var active_link = nav.find('li.active'), active_category = active_link.attr('data-category');
+ var nav = $('ul.nav'), active_link = nav.find('li.active'), active_category = active_link.attr('data-category');
// set the headers to hidden, except the active one
nav.find('.nav-header').each(function() {
@@ -15,8 +14,7 @@ $(document).ready(function() {
})
nav.on('click', '.toggle', function() {
- var ele = $(this);
- var header = ele.parents('.nav-header'), cat = header.attr('data-category');
+ var ele = $(this), header = ele.parents('.nav-header'), cat = header.attr('data-category');
if (ele.is('.icon-plus')) {
header.attr('data-hidden', false);
View
@@ -1,17 +1,14 @@
+// https://github.com/ghiculescu/jekyll-table-of-contents
$(document).ready(function() {
- var headers = $('h1, h2, h3, h4, h5, h6').filter(function() {return this.id;});
- var output = $('.toc');
+ var headers = $('h1, h2, h3, h4, h5, h6').filter(function() {return this.id;}), output = $('.toc');
if (!headers.length || headers.length < 3 || !output.length)
return;
var get_level = function(ele) {
return parseInt(ele.nodeName.replace("H", ""), 10);
}
- var level = get_level(headers[0]); // get the initial level
- var this_level;
-
- var html = "<i>Jump to...</i> <ol>";
+ var level = get_level(headers[0]), this_level, html = "<i>Jump to...</i> <ol>";
headers.each(function(_, header) {
this_level = get_level(header);
if (this_level === level) // same level as before; same indenting

0 comments on commit 44dd116

Please sign in to comment.