From bdbd7a38a86ef2d0593445a54fdca93c8bd7a9ce Mon Sep 17 00:00:00 2001 From: Robert Lord Date: Sun, 22 Jun 2014 02:37:01 -0700 Subject: [PATCH] Update app javascript to pass jslint, fixes #80 --- source/javascripts/app/search.js | 4 ++-- source/javascripts/app/toc.js | 16 ++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/javascripts/app/search.js b/source/javascripts/app/search.js index 1521304..374094a 100644 --- a/source/javascripts/app/search.js +++ b/source/javascripts/app/search.js @@ -4,7 +4,7 @@ var content, darkBox, searchInfo; var highlightOpts = { element: 'span', className: 'search-highlight' }; - var index = new lunr.Index; + var index = new lunr.Index(); index.ref('id'); index.field('title', { boost: 10 }); @@ -92,7 +92,7 @@ // position first element. it wasn't positioned above if len > 1 if (results.length > 1) { var firstRef = results[0].ref; - var secondRef = results[1].ref + var secondRef = results[1].ref; refToHeader(firstRef).insertBefore(refToHeader(secondRef)); } diff --git a/source/javascripts/app/toc.js b/source/javascripts/app/toc.js index 60caf78..8946f87 100644 --- a/source/javascripts/app/toc.js +++ b/source/javascripts/app/toc.js @@ -1,19 +1,12 @@ (function (global) { - var toc; - - global.toc = toc; - - $(toc); - $(animate); - var closeToc = function() { $(".tocify-wrapper").removeClass('open'); $("#nav-button").removeClass('open'); }; - function toc () { - toc = $("#toc").tocify({ + var makeToc = function() { + global.toc = $("#toc").tocify({ selectors: 'h1, h2', extendPage: false, theme: 'none', @@ -37,7 +30,7 @@ $(".page-wrapper").click(closeToc); $(".tocify-item").click(closeToc); - } + }; // Hack to make already open sections to start opened, // instead of displaying an ugly animation @@ -47,5 +40,8 @@ }, 50); } + $(makeToc); + $(animate); + })(window);