Commit ac4529f7 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch '18743-sidebar-pin-tooltip' into 'master'

Resolve "Tooltip for pinning sidebar"

## What does this MR do?
Adds tooltip to show whether sidebar is pinned/unpinned

## What are the relevant issue numbers?
Closes #18743 

## Screenshots (if relevant)
![Screen_Shot_2016-06-17_at_12.14.25_PM](/uploads/162f52084a770012cdc621122acd6c6c/Screen_Shot_2016-06-17_at_12.14.25_PM.png)
![Screen_Shot_2016-06-17_at_12.14.35_PM](/uploads/d9296720aeada972441f48d9a3d2f7f8/Screen_Shot_2016-06-17_at_12.14.35_PM.png)

See merge request !4759
parents f411f83d 3beff9e4
...@@ -145,6 +145,7 @@ v 8.9.0 (unreleased) ...@@ -145,6 +145,7 @@ v 8.9.0 (unreleased)
- ExtractsPath get ref_names from repository cache, if not there access git. - ExtractsPath get ref_names from repository cache, if not there access git.
- Cache user todo counts from TodoService - Cache user todo counts from TodoService
- Ensure Todos counters doesn't count Todos for projects pending delete - Ensure Todos counters doesn't count Todos for projects pending delete
- Add tooltip to pin/unpin navbar
v 8.8.5 v 8.8.5
- Import GitHub repositories respecting the API rate limit !4166 - Import GitHub repositories respecting the API rate limit !4166
......
...@@ -268,17 +268,33 @@ $ -> ...@@ -268,17 +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') else
$tooltip.remove() # Remove it immediately when collapsing the sidebar
$page.removeClass('page-sidebar-pinned')
.toggleClass('page-sidebar-collapsed page-sidebar-expanded') .toggleClass('page-sidebar-collapsed page-sidebar-expanded')
$('.navbar-fixed-top') $topNav.removeClass('header-pinned-nav')
.removeClass('header-pinned-nav')
.toggleClass('header-collapsed header-expanded') .toggleClass('header-collapsed header-expanded')
else
$.cookie 'pin_nav', 'true', { path: '/' } # Save settings
$('.page-with-sidebar').addClass('page-sidebar-pinned') $.cookie 'pin_nav', doPinNav, { path: '/' }
$('.navbar-fixed-top').addClass('header-pinned-nav')
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')
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
= image_tag avatar_icon(current_user, 60), alt: 'Profile', class: 'avatar avatar s36' = image_tag avatar_icon(current_user, 60), alt: 'Profile', class: 'avatar avatar s36'
.username .username
= current_user.username = current_user.username
= link_to '#', class: "nav-header-btn text-center pin-nav-btn #{'is-active' if pinned_nav?} js-nav-pin", title: 'Pin/Unpin navigation' do = link_to '#', class: "nav-header-btn text-center pin-nav-btn has-tooltip #{'is-active' if pinned_nav?} js-nav-pin", title: pinned_nav? ? "Unpin navigation" : "Pin Navigation", data: {placement: 'right', container: 'body'} do
%span.sr-only Toggle navigation pinning %span.sr-only Toggle navigation pinning
= icon('thumb-tack') = icon('thumb-tack')
- if defined?(nav) && nav - if defined?(nav) && nav
......
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