Commit 3beff9e4 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Fix tooltip title and persist state

parent 10220ef1
...@@ -268,19 +268,33 @@ $ -> ...@@ -268,19 +268,33 @@ $ ->
.on 'click', '.js-nav-pin', (e) -> .on 'click', '.js-nav-pin', (e) ->
e.preventDefault() e.preventDefault()
$pinBtn = $(e.currentTarget)
$page = $ '.page-with-sidebar'
$topNav = $ '.navbar-fixed-top'
$tooltip = $ "##{$pinBtn.attr('aria-describedby')}"
doPinNav = not $page.is('.page-sidebar-pinned')
tooltipText = 'Pin navigation'
$(this).toggleClass 'is-active' $(this).toggleClass 'is-active'
if $.cookie('pin_nav') is 'true' if doPinNav
$.cookie 'pin_nav', 'false', { path: '/' } $page.addClass('page-sidebar-pinned')
$('.page-with-sidebar') $topNav.addClass('header-pinned-nav')
.removeClass('page-sidebar-pinned')
.toggleClass('page-sidebar-collapsed page-sidebar-expanded')
$('.navbar-fixed-top')
.removeClass('header-pinned-nav')
.toggleClass('header-collapsed header-expanded')
$('.pin-nav-btn').attr('data-original-title', 'Pin sidebar').tooltip('fixTitle').tooltip('setContent')
else else
$.cookie 'pin_nav', 'true', { path: '/' } $tooltip.remove() # Remove it immediately when collapsing the sidebar
$('.page-with-sidebar').addClass('page-sidebar-pinned') $page.removeClass('page-sidebar-pinned')
$('.navbar-fixed-top').addClass('header-pinned-nav') .toggleClass('page-sidebar-collapsed page-sidebar-expanded')
$('.pin-nav-btn').attr('data-original-title', 'Unpin sidebar').tooltip('fixTitle').tooltip('setContent') $topNav.removeClass('header-pinned-nav')
.toggleClass('header-collapsed header-expanded')
# Save settings
$.cookie 'pin_nav', doPinNav, { path: '/' }
if $.cookie('pin_nav') is 'true' or doPinNav
tooltipText = 'Unpin navigation'
# Update tooltip text immediately
$tooltip.find('.tooltip-inner').text(tooltipText)
# Persist tooltip title
$pinBtn.attr('title', tooltipText).tooltip('fixTitle')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment