2022-12-18 23:31:43 -05:00
|
|
|
$(document).ready( ->
|
|
|
|
|
|
|
|
$('#nav-toggle').on('click', toggleNav)
|
2022-12-22 13:03:08 -05:00
|
|
|
if getCookie('navCollapsed') == 'true'
|
|
|
|
$('body').addClass('collapsed')
|
2023-01-17 02:15:00 -05:00
|
|
|
$('#mobile-nav-toggle').on('click', toggleMobileNav)
|
2022-12-18 23:31:43 -05:00
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
toggleNav = () ->
|
|
|
|
bodyElem = $('body')
|
|
|
|
if bodyElem.hasClass('collapsed')
|
|
|
|
bodyElem.removeClass('collapsed')
|
2022-12-22 13:03:08 -05:00
|
|
|
setCookie('navCollapsed', 'false')
|
2022-12-18 23:31:43 -05:00
|
|
|
else
|
|
|
|
bodyElem.addClass('collapsed')
|
2022-12-22 13:03:08 -05:00
|
|
|
setCookie('navCollapsed', 'true')
|
|
|
|
|
2023-01-17 02:15:00 -05:00
|
|
|
toggleMobileNav = () ->
|
|
|
|
navElem = $('#mobile-nav')
|
|
|
|
if navElem.hasClass('expanded')
|
|
|
|
navElem.removeClass('expanded')
|
|
|
|
else
|
|
|
|
navElem.addClass('expanded')
|
|
|
|
|
2022-12-22 13:03:08 -05:00
|
|
|
getCookie = (cName) ->
|
|
|
|
name = cName + '='
|
|
|
|
cDecoded = decodeURIComponent(document.cookie)
|
|
|
|
#to be careful
|
|
|
|
cArr = cDecoded.split('; ')
|
|
|
|
res = undefined
|
|
|
|
cArr.forEach (val) ->
|
|
|
|
if val.indexOf(name) == 0
|
|
|
|
res = val.substring(name.length)
|
|
|
|
return
|
|
|
|
res
|
|
|
|
|
|
|
|
setCookie = (cName, cValue, expDays = 30) ->
|
|
|
|
date = new Date
|
|
|
|
date.setTime date.getTime() + expDays * 24 * 60 * 60 * 1000
|
|
|
|
expires = 'expires=' + date.toUTCString()
|
|
|
|
document.cookie = cName + '=' + cValue + '; ' + expires + '; path=/'
|
|
|
|
return
|