summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-03-16 15:45:51 -0400
committerRobert Speicher <rspeicher@gmail.com>2016-03-17 21:24:17 -0400
commit423e0068407d0589e097ff76bb8301384b39229b (patch)
tree7c8c2aee1b6aabd4ed9cf4adc32bccab46f4399b /app/assets
parentdc396d0fa4b18815b4517c23b0d4e50c23b20db7 (diff)
downloadgitlab-ce-423e0068407d0589e097ff76bb8301384b39229b.tar.gz
Expand the issuable sidebar when coming back from the Changes tabrs-auto-expand-sidebar
Unless the user explicitly requested the collapsed sidebar.
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/merge_request_tabs.js.coffee25
1 files changed, 22 insertions, 3 deletions
diff --git a/app/assets/javascripts/merge_request_tabs.js.coffee b/app/assets/javascripts/merge_request_tabs.js.coffee
index 8322b4c46ad..839e6ec2c08 100644
--- a/app/assets/javascripts/merge_request_tabs.js.coffee
+++ b/app/assets/javascripts/merge_request_tabs.js.coffee
@@ -3,6 +3,8 @@
# Handles persisting and restoring the current tab selection and lazily-loading
# content on the MergeRequests#show page.
#
+#= require jquery.cookie
+#
# ### Example Markup
#
# <ul class="nav-links merge-request-tabs">
@@ -68,11 +70,15 @@ class @MergeRequestTabs
if action == 'commits'
@loadCommits($target.attr('href'))
+ @expandView()
else if action == 'diffs'
@loadDiff($target.attr('href'))
@shrinkView()
else if action == 'builds'
@loadBuilds($target.attr('href'))
+ @expandView()
+ else
+ @expandView()
@setCurrentAction(action)
@@ -189,11 +195,24 @@ class @MergeRequestTabs
$('.container-fluid').removeClass('container-limited')
shrinkView: ->
- $gutterIcon = $('.js-sidebar-toggle i')
+ $gutterIcon = $('.js-sidebar-toggle i:visible')
# Wait until listeners are set
setTimeout( ->
- # Only when sidebar is collapsed
+ # Only when sidebar is expanded
if $gutterIcon.is('.fa-angle-double-right')
- $gutterIcon.closest('a').trigger('click',[true])
+ $gutterIcon.closest('a').trigger('click', [true])
+ , 0)
+
+ # Expand the issuable sidebar unless the user explicitly collapsed it
+ expandView: ->
+ return if $.cookie('collapsed_gutter') == 'true'
+
+ $gutterIcon = $('.js-sidebar-toggle i:visible')
+
+ # Wait until listeners are set
+ setTimeout( ->
+ # Only when sidebar is collapsed
+ if $gutterIcon.is('.fa-angle-double-left')
+ $gutterIcon.closest('a').trigger('click', [true])
, 0)