|
@@ -9,5 +9,35 @@ exports.initialize = (config) ->
|
|
|
$mainNavIcon = $mainNav.find('> .icon')
|
|
|
$mainNavList = $mainNav.find('> ul')
|
|
|
|
|
|
+ $tocNav = $('.toc-nav')
|
|
|
+ $tocNavIcon = $tocNav.find('> .icon')
|
|
|
+ $tocNavList = $tocNav.find('> ul')
|
|
|
+
|
|
|
+ $article = $('.container > article')
|
|
|
+
|
|
|
+ hidePopups = (exceptMe) ->
|
|
|
+ $mainNavList.hide() unless $mainNavList is exceptMe
|
|
|
+ $tocNavList.hide() unless $tocNavList is exceptMe
|
|
|
+
|
|
|
+ $('html').on 'click', (e) ->
|
|
|
+ hidePopups()
|
|
|
+
|
|
|
+ # Setup the Main menu
|
|
|
$mainNavIcon.on 'click', (e) ->
|
|
|
+ e.stopPropagation()
|
|
|
+ hidePopups($mainNavList)
|
|
|
$mainNavList.toggle()
|
|
|
+
|
|
|
+ # Setup the TOC menu
|
|
|
+ if $tocNav and $article
|
|
|
+ $article.find('h3').each ->
|
|
|
+ heading = $(@)
|
|
|
+ text = heading.text()
|
|
|
+ headingId = 'TOC-' + text.replace(/[\ \.\?\#\'\"]/g, '-')
|
|
|
+ heading.attr('id', headingId)
|
|
|
+ $tocNavList.append "<li><a href=\"##{headingId}\">#{text}</a></li>"
|
|
|
+
|
|
|
+ $tocNavIcon.on 'click', (e) ->
|
|
|
+ e.stopPropagation()
|
|
|
+ hidePopups($tocNavList)
|
|
|
+ $tocNavList.toggle()
|