diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-01 11:20:43 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-01 11:20:52 -0500 |
commit | 48ae8ef165a426e5899201789f9b6714ca21e808 (patch) | |
tree | 02b5fce2d0485efa96c0a2b621cd2b9c9e477a88 | |
parent | 8c90b6ecca1ccf21fd30231531208c8b6fdcca10 (diff) | |
download | gitlab-ce-48ae8ef165a426e5899201789f9b6714ca21e808.tar.gz |
Activate tab according URL
-rw-r--r-- | app/assets/javascripts/user_tabs.js.coffee | 26 | ||||
-rw-r--r-- | app/views/users/show.html.haml | 14 |
2 files changed, 23 insertions, 17 deletions
diff --git a/app/assets/javascripts/user_tabs.js.coffee b/app/assets/javascripts/user_tabs.js.coffee index 0b285f6ad80..ebe02274802 100644 --- a/app/assets/javascripts/user_tabs.js.coffee +++ b/app/assets/javascripts/user_tabs.js.coffee @@ -1,7 +1,6 @@ class @UserTabs - actions: ['activity', 'groups', 'contributed', 'personal'], + actions: ['activity', 'groups', 'contributed_projects', 'projects'], defaultAction: 'activity', - tabButtonSelector: '.nav-links a[data-toggle="tab"]' constructor: (@opts = {}) -> # Store the `location` object, allowing for easier stubbing in tests @@ -9,16 +8,20 @@ class @UserTabs @loaded = {} @bindEvents() - @setTabState() + @tabStateInit() - # Set default tab - source = $(".#{@defaultAction}-tab a").attr('href') - @setTab(source, @defaultAction) + action = @opts.action + action = @defaultAction if action == 'show' + + # Set active tab + source = $(".#{action}-tab a").attr('href') + @activateTab(action) + @setTab(source, action) bindEvents: -> - $(document).on 'shown.bs.tab', @tabButtonSelector, @tabShown + $(document).on 'shown.bs.tab', '.nav-links a[data-toggle="tab"]', @tabShown - setTabState: -> + tabStateInit: -> for action in @actions @loaded[action] = false @@ -30,6 +33,9 @@ class @UserTabs @setTab(source, action) @setCurrentAction(action) + activateTab: (action) -> + $(".nav-links .#{action}-tab a").tab('show') + setTab: (source, action) -> return if @loaded[action] is true @@ -39,10 +45,10 @@ class @UserTabs if action is 'groups' @loadTab(source, action) - if action is 'contributed' + if action is 'contributed_projects' @loadTab(source, action) - if action is 'personal' + if action is 'projects' @loadTab(source, action) loadTab: (source, action) -> diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 12cd61f3578..15b1dbd508a 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -70,17 +70,17 @@ = @user.location %ul.nav-links.center - %li.activity-tab.active + %li.activity-tab = link_to user_calendar_activities_path, data: {target: 'div#activity', action: 'activity', toggle: 'tab'} do Activity %li.groups-tab = link_to user_groups_path, data: {target: 'div#groups', action: 'groups', toggle: 'tab'} do Groups - %li.contributed-tab - = link_to user_contributed_projects_path, data: {target: 'div#contributed', action: 'contributed', toggle: 'tab'} do + %li.contributed_projects-tab + = link_to user_contributed_projects_path, data: {target: 'div#contributed_projects', action: 'contributed_projects', toggle: 'tab'} do Contributed projects - %li.personal-tab - = link_to user_projects_path, data: {target: 'div#personal', action: 'personal', toggle: 'tab'} do + %li.projects-tab + = link_to user_projects_path, data: {target: 'div#projects', action: 'projects', toggle: 'tab'} do Personal projects %div{ class: container_class } @@ -99,10 +99,10 @@ #groups.tab-pane - # This tab is always loaded via AJAX - #contributed.tab-pane + #contributed_projects.tab-pane - # This tab is always loaded via AJAX - #personal.tab-pane + #projects.tab-pane - # This tab is always loaded via AJAX .loading-status |