Commit 465e40d3a663944b5aacf3e53a63158a7812f219
1 parent
4247ccd3
Exists in
master
and in
4 other branches
Extract ref switcher into a partial
Also moves onchange JS to projects.js.coffee
Showing
4 changed files
with
12 additions
and
11 deletions
Show diff stats
app/assets/javascripts/projects.js.coffee
@@ -10,11 +10,15 @@ window.Projects = -> | @@ -10,11 +10,15 @@ window.Projects = -> | ||
10 | $('form #project_default_branch').chosen() | 10 | $('form #project_default_branch').chosen() |
11 | disableButtonIfEmptyField '#project_name', '.project-submit' | 11 | disableButtonIfEmptyField '#project_name', '.project-submit' |
12 | 12 | ||
13 | -# Git clone panel switcher | ||
14 | $ -> | 13 | $ -> |
14 | + # Git clone panel switcher | ||
15 | scope = $ '.project_clone_holder' | 15 | scope = $ '.project_clone_holder' |
16 | if scope.length > 0 | 16 | if scope.length > 0 |
17 | $('a, button', scope).click -> | 17 | $('a, button', scope).click -> |
18 | $('a, button', scope).removeClass 'active' | 18 | $('a, button', scope).removeClass 'active' |
19 | $(@).addClass 'active' | 19 | $(@).addClass 'active' |
20 | $('#project_clone', scope).val $(@).data 'clone' | 20 | $('#project_clone', scope).val $(@).data 'clone' |
21 | + | ||
22 | + # Ref switcher | ||
23 | + $('.project-refs-select').on 'change', -> | ||
24 | + $(@).parents('form').submit() |
app/views/commits/_head.html.haml
1 | %ul.nav.nav-tabs | 1 | %ul.nav.nav-tabs |
2 | - %li | ||
3 | - = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do | ||
4 | - = select_tag "ref", grouped_options_refs, onchange: "$(this.form).trigger('submit');", class: "project-refs-select chosen" | ||
5 | - = hidden_field_tag :destination, "commits" | ||
6 | - | 2 | + %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} |
7 | %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} | 3 | %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} |
8 | = link_to project_commits_path(@project) do | 4 | = link_to project_commits_path(@project) do |
9 | Commits | 5 | Commits |
@@ -20,7 +16,6 @@ | @@ -20,7 +16,6 @@ | ||
20 | Tags | 16 | Tags |
21 | %span.badge= @project.repo.tag_count | 17 | %span.badge= @project.repo.tag_count |
22 | 18 | ||
23 | - | ||
24 | - if current_page?(project_commits_path(@project)) && current_user.private_token | 19 | - if current_page?(project_commits_path(@project)) && current_user.private_token |
25 | %li.right | 20 | %li.right |
26 | %span.rss-icon | 21 | %span.rss-icon |
app/views/refs/_head.html.haml
1 | %ul.nav.nav-tabs | 1 | %ul.nav.nav-tabs |
2 | %li | 2 | %li |
3 | - = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form", remote: true do | ||
4 | - = select_tag "ref", grouped_options_refs, onchange: "$(this.form).trigger('submit');", class: "project-refs-select chosen" | ||
5 | - = hidden_field_tag :destination, "tree" | ||
6 | - = hidden_field_tag :path, params[:path] | 3 | + = render partial: 'shared/ref_switcher', locals: {destination: 'tree', path: params[:path]} |
7 | %li{class: "#{'active' if (controller.controller_name == "refs") }"} | 4 | %li{class: "#{'active' if (controller.controller_name == "refs") }"} |
8 | = link_to tree_project_ref_path(@project, @ref) do | 5 | = link_to tree_project_ref_path(@project, @ref) do |
9 | Source | 6 | Source |
@@ -0,0 +1,5 @@ | @@ -0,0 +1,5 @@ | ||
1 | += form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do | ||
2 | + = select_tag "ref", grouped_options_refs, class: "project-refs-select chosen" | ||
3 | + = hidden_field_tag :destination, destination | ||
4 | + - if respond_to?(:path) | ||
5 | + = hidden_field_tag :path, path |