Commit ae5faf0fd32160dd46a7e94e230d241de8ec4e38
1 parent
97e97743
Exists in
master
and in
4 other branches
Ajax branch/tag switch for tree view
Showing
11 changed files
with
151 additions
and
110 deletions
Show diff stats
app/assets/javascripts/tree.js
| ... | ... | @@ -5,13 +5,16 @@ |
| 5 | 5 | var Tree = { |
| 6 | 6 | init: |
| 7 | 7 | function() { |
| 8 | - (new Image).src = "/assets/ajax-loader-facebook.gif"; | |
| 9 | - | |
| 10 | - $('#tree-slider .tree-item-file-name a, .breadcrumb a').live("click", function() { | |
| 11 | - history.pushState({ path: this.path }, '', this.href) | |
| 8 | + $('#tree-slider .tree-item-file-name a, .breadcrumb li > a').live("click", function() { | |
| 12 | 9 | $("#tree-content-holder").hide("slide", { direction: "left" }, 150) |
| 13 | 10 | }) |
| 14 | 11 | |
| 12 | + $('.project-refs-form').live({ | |
| 13 | + "ajax:beforeSend": function() { | |
| 14 | + $("#tree-content-holder").hide("slide", { direction: "left" }, 150); | |
| 15 | + } | |
| 16 | + }) | |
| 17 | + | |
| 15 | 18 | $("#tree-slider .tree-item").live('click', function(e){ |
| 16 | 19 | if(e.target.nodeName != "A") { |
| 17 | 20 | link = $(this).find(".tree-item-file-name a"); |
| ... | ... | @@ -19,7 +22,7 @@ var Tree = { |
| 19 | 22 | } |
| 20 | 23 | }); |
| 21 | 24 | |
| 22 | - $('#tree-slider td.tree-item-file-name a, .breadcrumb a').live({ | |
| 25 | + $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live({ | |
| 23 | 26 | "ajax:beforeSend": function() { $('.tree_progress').addClass("loading"); }, |
| 24 | 27 | "ajax:complete": function() { $('.tree_progress').removeClass("loading"); } |
| 25 | 28 | }); | ... | ... |
app/assets/stylesheets/common.scss
app/assets/stylesheets/projects.css.scss
| ... | ... | @@ -15,17 +15,6 @@ |
| 15 | 15 | .handle:hover { |
| 16 | 16 | cursor:move; |
| 17 | 17 | } |
| 18 | -.project-refs-form { | |
| 19 | - span { | |
| 20 | - background:none !important; | |
| 21 | - position:static !important; | |
| 22 | - width:auto !important; | |
| 23 | - height:auto !important; | |
| 24 | - } | |
| 25 | -} | |
| 26 | -.project-refs-select { | |
| 27 | - width:200px; | |
| 28 | -} | |
| 29 | 18 | |
| 30 | 19 | /* Project Dashboard Page */ |
| 31 | 20 | .news-feed h2 { |
| ... | ... | @@ -151,3 +140,54 @@ a.project-update.titled { |
| 151 | 140 | height: 70%; |
| 152 | 141 | overflow: hidden; |
| 153 | 142 | } |
| 143 | + | |
| 144 | + | |
| 145 | +/** Branch/tag selector **/ | |
| 146 | +.project-refs-form { | |
| 147 | + margin:0; | |
| 148 | + span { | |
| 149 | + background:none !important; | |
| 150 | + position:static !important; | |
| 151 | + width:auto !important; | |
| 152 | + height:auto !important; | |
| 153 | + } | |
| 154 | +} | |
| 155 | +.project-refs-select { | |
| 156 | + width:120px; | |
| 157 | +} | |
| 158 | + | |
| 159 | +.project-refs-form .chzn-container { | |
| 160 | + position:relative; | |
| 161 | + top: -5px; | |
| 162 | + left: -11px; | |
| 163 | + | |
| 164 | + .chzn-drop { | |
| 165 | + margin:7px 0; | |
| 166 | + border: 1px solid #CCC; | |
| 167 | + min-width: 300px; | |
| 168 | + | |
| 169 | + .chzn-results { | |
| 170 | + max-height:300px; | |
| 171 | + } | |
| 172 | + | |
| 173 | + .chzn-search input { | |
| 174 | + min-width:200px; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + .chzn-single { | |
| 179 | + background:#ddd; | |
| 180 | + //border:none; | |
| 181 | + //box-shadow:none; | |
| 182 | + | |
| 183 | + div { | |
| 184 | + background:transparent; | |
| 185 | + border-left:none; | |
| 186 | + } | |
| 187 | + | |
| 188 | + span { | |
| 189 | + font-weight: normal; | |
| 190 | + } | |
| 191 | + } | |
| 192 | +} | |
| 193 | + | ... | ... |
app/assets/stylesheets/top_panel.scss
| ... | ... | @@ -105,35 +105,6 @@ body header { |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | |
| 108 | -.top_panel_holder .chzn-container { | |
| 109 | - position:relative; | |
| 110 | - | |
| 111 | - .chzn-drop { | |
| 112 | - margin:7px 0; | |
| 113 | - border: 1px solid #CCC; | |
| 114 | - min-width: 300px; | |
| 115 | - | |
| 116 | - .chzn-results { | |
| 117 | - max-height:300px; | |
| 118 | - } | |
| 119 | - } | |
| 120 | - | |
| 121 | - .chzn-single { | |
| 122 | - background:transparent; | |
| 123 | - -moz-border-radius: 4px; | |
| 124 | - border-radius: 4px; | |
| 125 | - | |
| 126 | - div { | |
| 127 | - background:transparent; | |
| 128 | - border-left:none; | |
| 129 | - } | |
| 130 | - | |
| 131 | - span { | |
| 132 | - font-weight: normal; | |
| 133 | - } | |
| 134 | - } | |
| 135 | -} | |
| 136 | - | |
| 137 | 108 | .rss-icon { |
| 138 | 109 | margin:0 15px; |
| 139 | 110 | padding:3px; | ... | ... |
app/assets/stylesheets/tree.scss
| ... | ... | @@ -8,13 +8,10 @@ |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | 10 | .tree_progress { |
| 11 | - float:left; | |
| 12 | - width:16px; | |
| 13 | - height:16px; | |
| 14 | - margin:2px 6px; | |
| 11 | + display:none; | |
| 12 | + margin:20px; | |
| 15 | 13 | &.loading { |
| 16 | - background-position: 0px 0px; | |
| 17 | - background: url("ajax-loader-facebook.gif") no-repeat; | |
| 14 | + display:block; | |
| 18 | 15 | } |
| 19 | 16 | } |
| 20 | 17 | ... | ... |
app/controllers/refs_controller.rb
| ... | ... | @@ -13,13 +13,22 @@ class RefsController < ApplicationController |
| 13 | 13 | layout "project" |
| 14 | 14 | |
| 15 | 15 | def switch |
| 16 | - new_path = if params[:destination] == "tree" | |
| 17 | - tree_project_ref_path(@project, params[:ref]) | |
| 18 | - else | |
| 19 | - project_commits_path(@project, :ref => params[:ref]) | |
| 20 | - end | |
| 16 | + respond_to do |format| | |
| 17 | + format.html do | |
| 18 | + new_path = if params[:destination] == "tree" | |
| 19 | + tree_project_ref_path(@project, params[:ref]) | |
| 20 | + else | |
| 21 | + project_commits_path(@project, :ref => params[:ref]) | |
| 22 | + end | |
| 21 | 23 | |
| 22 | - redirect_to new_path | |
| 24 | + redirect_to new_path | |
| 25 | + end | |
| 26 | + format.js do | |
| 27 | + @ref = params[:ref] | |
| 28 | + define_tree_vars | |
| 29 | + render "tree" | |
| 30 | + end | |
| 31 | + end | |
| 23 | 32 | end |
| 24 | 33 | |
| 25 | 34 | # | ... | ... |
app/views/layouts/_head_panel.html.haml
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | = truncate @project.name, :length => 28 |
| 12 | 12 | .git_url_wrapper |
| 13 | 13 | %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"} |
| 14 | - - if @project.repo_exists? | |
| 14 | + -#- if @project.repo_exists? | |
| 15 | 15 | .left{:style => "margin-left:5px;"} |
| 16 | 16 | = render :partial => "projects/refs", :locals => { :destination => controller.controller_name == "commits" ? "commits" : "tree" } |
| 17 | 17 | = yield :rss_icon | ... | ... |
app/views/layouts/_project_side.html.haml
| ... | ... | @@ -6,8 +6,8 @@ |
| 6 | 6 | |
| 7 | 7 | - if @project.repo_exists? |
| 8 | 8 | = link_to "Repository", project_repository_path(@project), :class => repository_tab_class |
| 9 | - = link_to "Tree", tree_project_ref_path(@project, @ref || @project.root_ref), :class => tree_tab_class | |
| 10 | - = link_to "Commits", project_commits_path(@project, :ref => (@ref || @project.root_ref)), :class => (controller.controller_name == "commits") ? "current" : nil | |
| 9 | + = link_to "Tree", tree_project_ref_path(@project), :class => tree_tab_class | |
| 10 | + = link_to "Commits", project_commits_path(@project), :class => (controller.controller_name == "commits") ? "current" : nil | |
| 11 | 11 | = link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil |
| 12 | 12 | = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do |
| 13 | 13 | Issues | ... | ... |
app/views/layouts/_project_side_right.html.haml
| ... | ... | @@ -6,38 +6,41 @@ |
| 6 | 6 | = yield :sidebar_top_block |
| 7 | 7 | - else |
| 8 | 8 | - if can? current_user, :write_project, @project |
| 9 | - %h4 Report | |
| 10 | - %ul | |
| 11 | - %li | |
| 12 | - = link_to new_project_issue_path(@project), :title => "New Issue", :class => "" do | |
| 9 | + .alert-message.block-message.info | |
| 10 | + You have access to create new issue or merge request. | |
| 11 | + %div | |
| 12 | + = link_to new_project_issue_path(@project), :title => "New Issue", :class => "btn small" do | |
| 13 | 13 | New Issue » |
| 14 | - %li | |
| 15 | - = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "" do | |
| 14 | + %div | |
| 15 | + = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "btn small" do | |
| 16 | 16 | New Merge Request » |
| 17 | 17 | |
| 18 | - %h4 | |
| 19 | - Recent Projects: | |
| 20 | - %ul | |
| 21 | - - current_user.projects.order("id DESC").limit(5).each do |project| | |
| 22 | - %li | |
| 23 | - = link_to project_path(project) do | |
| 24 | - = project.name | |
| 18 | + - if current_user.projects.count > 0 | |
| 19 | + %div.entry | |
| 20 | + %h5 | |
| 21 | + Recent Projects: | |
| 22 | + %ul | |
| 23 | + - current_user.projects.order("id DESC").limit(5).each do |project| | |
| 24 | + %li | |
| 25 | + = link_to project_path(project) do | |
| 26 | + = project.name | |
| 27 | + = link_to "More » ", projects_path | |
| 25 | 28 | |
| 26 | - %h4 | |
| 27 | - Recent Issues: | |
| 28 | - %ul | |
| 29 | - - current_user.assigned_issues.order("id DESC").limit(5).each do |issue| | |
| 30 | - %li | |
| 31 | - = link_to project_issue_path(issue.project, issue) do | |
| 32 | - = truncate issue.title | |
| 29 | + -#%h4 | |
| 30 | + -#Recent Issues: | |
| 31 | + -#%ul | |
| 32 | + -#- current_user.assigned_issues.order("id DESC").limit(5).each do |issue| | |
| 33 | + -#%li | |
| 34 | + -#= link_to project_issue_path(issue.project, issue) do | |
| 35 | + -#= truncate issue.title | |
| 33 | 36 | |
| 34 | 37 | |
| 35 | - %h4 | |
| 36 | - Recent Requests: | |
| 37 | - %ul | |
| 38 | - - current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| | |
| 39 | - %li | |
| 40 | - = link_to project_merge_request_path(issue.project, issue) do | |
| 41 | - = truncate issue.title | |
| 38 | + -#%h4 | |
| 39 | + -#Recent Requests: | |
| 40 | + -#%ul | |
| 41 | + -#- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| | |
| 42 | + -#%li | |
| 43 | + -#= link_to project_merge_request_path(issue.project, issue) do | |
| 44 | + -#= truncate issue.title | |
| 42 | 45 | |
| 43 | 46 | ... | ... |
app/views/layouts/_projects_side.html.haml
| ... | ... | @@ -7,29 +7,32 @@ |
| 7 | 7 | = link_to new_project_path, :class => "btn small" do |
| 8 | 8 | New Project |
| 9 | 9 | |
| 10 | - %h4 | |
| 11 | - Recent Projects: | |
| 12 | - %ul | |
| 13 | - - current_user.projects.order("id DESC").limit(5).each do |project| | |
| 14 | - %li | |
| 15 | - = link_to project_path(project) do | |
| 16 | - = project.name | |
| 10 | + - if current_user.projects.count > 0 | |
| 11 | + %div.entry | |
| 12 | + %h5 | |
| 13 | + Recent Projects: | |
| 14 | + %ul | |
| 15 | + - current_user.projects.order("id DESC").limit(5).each do |project| | |
| 16 | + %li | |
| 17 | + = link_to project_path(project) do | |
| 18 | + = project.name | |
| 19 | + = link_to "More » ", projects_path | |
| 17 | 20 | |
| 18 | - %h4 | |
| 19 | - Recent Issues: | |
| 20 | - %ul | |
| 21 | - - current_user.assigned_issues.order("id DESC").limit(5).each do |issue| | |
| 22 | - %li | |
| 23 | - = link_to project_issue_path(issue.project, issue) do | |
| 24 | - = truncate issue.title | |
| 21 | + -#%h5 | |
| 22 | + -#Your Issues: | |
| 23 | + -#%ul | |
| 24 | + -#- current_user.assigned_issues.order("id DESC").limit(5).each do |issue| | |
| 25 | + -#%li | |
| 26 | + -#= link_to project_issue_path(issue.project, issue) do | |
| 27 | + -#= truncate issue.title | |
| 25 | 28 | |
| 26 | 29 | |
| 27 | - %h4 | |
| 28 | - Recent Requests: | |
| 29 | - %ul | |
| 30 | - - current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| | |
| 31 | - %li | |
| 32 | - = link_to project_merge_request_path(issue.project, issue) do | |
| 33 | - = truncate issue.title | |
| 30 | + -#%h5 | |
| 31 | + -#Your Merge Requests: | |
| 32 | + -#%ul | |
| 33 | + -#- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| | |
| 34 | + -#%li | |
| 35 | + -#= link_to project_merge_request_path(issue.project, issue) do | |
| 36 | + -#= truncate issue.title | |
| 34 | 37 | |
| 35 | 38 | ... | ... |
app/views/refs/_tree.html.haml
| 1 | 1 | %ul.breadcrumb |
| 2 | 2 | %li |
| 3 | + = form_tag switch_project_refs_path(@project), :method => :get, :class => "project-refs-form left", :remote => true do | |
| 4 | + = select_tag "ref", grouped_options_refs, :onchange => "$(this.form).trigger('submit');", :class => "project-refs-select" | |
| 5 | + = hidden_field_tag :destination, "tree" | |
| 6 | + = hidden_field_tag :path, params[:path] | |
| 7 | + | |
| 8 | + %li | |
| 3 | 9 | = link_to tree_project_ref_path(@project, @ref, :path => nil), :remote => true do |
| 4 | 10 | = @project.code |
| 5 | 11 | - tree.breadcrumbs(6) do |link| |
| 6 | 12 | \/ |
| 7 | 13 | %li= link |
| 8 | - %span.tree_progress | |
| 9 | 14 | .clear |
| 15 | +%div.tree_progress | |
| 16 | + = image_tag "ajax-loader.gif" | |
| 10 | 17 | #tree-content-holder |
| 11 | 18 | - if tree.is_blob? |
| 12 | 19 | = render :partial => "refs/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree } |
| ... | ... | @@ -42,12 +49,20 @@ |
| 42 | 49 | - else |
| 43 | 50 | = simple_format(content.data) |
| 44 | 51 | |
| 52 | +- if params[:path] | |
| 53 | + - history_path = tree_file_project_ref_path(@project, @ref, params[:path]) | |
| 54 | +- else | |
| 55 | + - history_path = tree_project_ref_path(@project, @ref) | |
| 45 | 56 | :javascript |
| 46 | 57 | $(function(){ |
| 47 | 58 | $('select#branch').selectmenu({style:'popup', width:200}); |
| 48 | 59 | $('select#tag').selectmenu({style:'popup', width:200}); |
| 60 | + $('.project-refs-select').chosen(); | |
| 61 | + | |
| 62 | + history.pushState({ path: this.path }, '', "#{history_path}") | |
| 49 | 63 | }); |
| 50 | 64 | |
| 65 | + | |
| 51 | 66 | - if params[:path] && request.xhr? |
| 52 | 67 | :javascript |
| 53 | 68 | $(window).unbind('popstate'); | ... | ... |