Commit ae5faf0f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Ajax branch/tag switch for tree view

parent 97e97743
...@@ -5,13 +5,16 @@ ...@@ -5,13 +5,16 @@
var Tree = { var Tree = {
init: init:
function() { function() {
(new Image).src = "/assets/ajax-loader-facebook.gif"; $('#tree-slider .tree-item-file-name a, .breadcrumb li > a').live("click", function() {
$('#tree-slider .tree-item-file-name a, .breadcrumb a').live("click", function() {
history.pushState({ path: this.path }, '', this.href)
$("#tree-content-holder").hide("slide", { direction: "left" }, 150) $("#tree-content-holder").hide("slide", { direction: "left" }, 150)
}) })
$('.project-refs-form').live({
"ajax:beforeSend": function() {
$("#tree-content-holder").hide("slide", { direction: "left" }, 150);
}
})
$("#tree-slider .tree-item").live('click', function(e){ $("#tree-slider .tree-item").live('click', function(e){
if(e.target.nodeName != "A") { if(e.target.nodeName != "A") {
link = $(this).find(".tree-item-file-name a"); link = $(this).find(".tree-item-file-name a");
...@@ -19,7 +22,7 @@ var Tree = { ...@@ -19,7 +22,7 @@ var Tree = {
} }
}); });
$('#tree-slider td.tree-item-file-name a, .breadcrumb a').live({ $('#tree-slider .tree-item-file-name a, .breadcrumb a, .project-refs-form').live({
"ajax:beforeSend": function() { $('.tree_progress').addClass("loading"); }, "ajax:beforeSend": function() { $('.tree_progress').addClass("loading"); },
"ajax:complete": function() { $('.tree_progress').removeClass("loading"); } "ajax:complete": function() { $('.tree_progress').removeClass("loading"); }
}); });
......
...@@ -9,7 +9,7 @@ $active_bg_color:#79C3E0; ...@@ -9,7 +9,7 @@ $active_bg_color:#79C3E0;
$active_bd_color: #2FA0BB; $active_bd_color: #2FA0BB;
$border_color:#CCC; $border_color:#CCC;
$lite_border_color:#EEE; $lite_border_color:#EEE;
$min_app_width:940px; $min_app_width:980px;
$max_app_width:980px; $max_app_width:980px;
$app_padding:20px; $app_padding:20px;
$bg_color: #FFF; $bg_color: #FFF;
......
...@@ -15,17 +15,6 @@ ...@@ -15,17 +15,6 @@
.handle:hover { .handle:hover {
cursor:move; cursor:move;
} }
.project-refs-form {
span {
background:none !important;
position:static !important;
width:auto !important;
height:auto !important;
}
}
.project-refs-select {
width:200px;
}
/* Project Dashboard Page */ /* Project Dashboard Page */
.news-feed h2 { .news-feed h2 {
...@@ -151,3 +140,54 @@ a.project-update.titled { ...@@ -151,3 +140,54 @@ a.project-update.titled {
height: 70%; height: 70%;
overflow: hidden; overflow: hidden;
} }
/** Branch/tag selector **/
.project-refs-form {
margin:0;
span {
background:none !important;
position:static !important;
width:auto !important;
height:auto !important;
}
}
.project-refs-select {
width:120px;
}
.project-refs-form .chzn-container {
position:relative;
top: -5px;
left: -11px;
.chzn-drop {
margin:7px 0;
border: 1px solid #CCC;
min-width: 300px;
.chzn-results {
max-height:300px;
}
.chzn-search input {
min-width:200px;
}
}
.chzn-single {
background:#ddd;
//border:none;
//box-shadow:none;
div {
background:transparent;
border-left:none;
}
span {
font-weight: normal;
}
}
}
...@@ -105,35 +105,6 @@ body header { ...@@ -105,35 +105,6 @@ body header {
} }
.top_panel_holder .chzn-container {
position:relative;
.chzn-drop {
margin:7px 0;
border: 1px solid #CCC;
min-width: 300px;
.chzn-results {
max-height:300px;
}
}
.chzn-single {
background:transparent;
-moz-border-radius: 4px;
border-radius: 4px;
div {
background:transparent;
border-left:none;
}
span {
font-weight: normal;
}
}
}
.rss-icon { .rss-icon {
margin:0 15px; margin:0 15px;
padding:3px; padding:3px;
......
...@@ -8,13 +8,10 @@ ...@@ -8,13 +8,10 @@
} }
.tree_progress { .tree_progress {
float:left; display:none;
width:16px; margin:20px;
height:16px;
margin:2px 6px;
&.loading { &.loading {
background-position: 0px 0px; display:block;
background: url("ajax-loader-facebook.gif") no-repeat;
} }
} }
......
...@@ -13,13 +13,22 @@ class RefsController < ApplicationController ...@@ -13,13 +13,22 @@ class RefsController < ApplicationController
layout "project" layout "project"
def switch def switch
new_path = if params[:destination] == "tree" respond_to do |format|
tree_project_ref_path(@project, params[:ref]) format.html do
else new_path = if params[:destination] == "tree"
project_commits_path(@project, :ref => params[:ref]) tree_project_ref_path(@project, params[:ref])
end else
project_commits_path(@project, :ref => params[:ref])
end
redirect_to new_path redirect_to new_path
end
format.js do
@ref = params[:ref]
define_tree_vars
render "tree"
end
end
end end
# #
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
= truncate @project.name, :length => 28 = truncate @project.name, :length => 28
.git_url_wrapper .git_url_wrapper
%input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"} %input.git-url.text{:id => "", :name => "", :readonly => "", :type => "text", :value => @project.url_to_repo, :class => "one_click_select"}
- if @project.repo_exists? -#- if @project.repo_exists?
.left{:style => "margin-left:5px;"} .left{:style => "margin-left:5px;"}
= render :partial => "projects/refs", :locals => { :destination => controller.controller_name == "commits" ? "commits" : "tree" } = render :partial => "projects/refs", :locals => { :destination => controller.controller_name == "commits" ? "commits" : "tree" }
= yield :rss_icon = yield :rss_icon
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
- if @project.repo_exists? - if @project.repo_exists?
= link_to "Repository", project_repository_path(@project), :class => repository_tab_class = link_to "Repository", project_repository_path(@project), :class => repository_tab_class
= link_to "Tree", tree_project_ref_path(@project, @ref || @project.root_ref), :class => tree_tab_class = link_to "Tree", tree_project_ref_path(@project), :class => tree_tab_class
= link_to "Commits", project_commits_path(@project, :ref => (@ref || @project.root_ref)), :class => (controller.controller_name == "commits") ? "current" : nil = link_to "Commits", project_commits_path(@project), :class => (controller.controller_name == "commits") ? "current" : nil
= link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil = link_to "Network", graph_project_path(@project), :class => current_page?(:controller => "projects", :action => "graph", :id => @project) ? "current" : nil
= link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do = link_to project_issues_filter_path(@project), :class => (controller.controller_name == "issues") ? "current" : nil do
Issues Issues
......
...@@ -6,38 +6,41 @@ ...@@ -6,38 +6,41 @@
= yield :sidebar_top_block = yield :sidebar_top_block
- else - else
- if can? current_user, :write_project, @project - if can? current_user, :write_project, @project
%h4 Report .alert-message.block-message.info
%ul You have access to create new issue or merge request.
%li %div
= link_to new_project_issue_path(@project), :title => "New Issue", :class => "" do = link_to new_project_issue_path(@project), :title => "New Issue", :class => "btn small" do
New Issue » New Issue »
%li %div
= link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "" do = link_to new_project_merge_request_path(@project), :title => "New Merge Request", :class => "btn small" do
New Merge Request » New Merge Request »
%h4 - if current_user.projects.count > 0
Recent Projects: %div.entry
%ul %h5
- current_user.projects.order("id DESC").limit(5).each do |project| Recent Projects:
%li %ul
= link_to project_path(project) do - current_user.projects.order("id DESC").limit(5).each do |project|
= project.name %li
= link_to project_path(project) do
= project.name
= link_to "More » ", projects_path
%h4 -#%h4
Recent Issues: -#Recent Issues:
%ul -#%ul
- current_user.assigned_issues.order("id DESC").limit(5).each do |issue| -#- current_user.assigned_issues.order("id DESC").limit(5).each do |issue|
%li -#%li
= link_to project_issue_path(issue.project, issue) do -#= link_to project_issue_path(issue.project, issue) do
= truncate issue.title -#= truncate issue.title
%h4 -#%h4
Recent Requests: -#Recent Requests:
%ul -#%ul
- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| -#- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue|
%li -#%li
= link_to project_merge_request_path(issue.project, issue) do -#= link_to project_merge_request_path(issue.project, issue) do
= truncate issue.title -#= truncate issue.title
...@@ -7,29 +7,32 @@ ...@@ -7,29 +7,32 @@
= link_to new_project_path, :class => "btn small" do = link_to new_project_path, :class => "btn small" do
New Project New Project
%h4 - if current_user.projects.count > 0
Recent Projects: %div.entry
%ul %h5
- current_user.projects.order("id DESC").limit(5).each do |project| Recent Projects:
%li %ul
= link_to project_path(project) do - current_user.projects.order("id DESC").limit(5).each do |project|
= project.name %li
= link_to project_path(project) do
= project.name
= link_to "More » ", projects_path
%h4 -#%h5
Recent Issues: -#Your Issues:
%ul -#%ul
- current_user.assigned_issues.order("id DESC").limit(5).each do |issue| -#- current_user.assigned_issues.order("id DESC").limit(5).each do |issue|
%li -#%li
= link_to project_issue_path(issue.project, issue) do -#= link_to project_issue_path(issue.project, issue) do
= truncate issue.title -#= truncate issue.title
%h4 -#%h5
Recent Requests: -#Your Merge Requests:
%ul -#%ul
- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue| -#- current_user.assigned_merge_requests.order("id DESC").limit(5).each do |issue|
%li -#%li
= link_to project_merge_request_path(issue.project, issue) do -#= link_to project_merge_request_path(issue.project, issue) do
= truncate issue.title -#= truncate issue.title
%ul.breadcrumb %ul.breadcrumb
%li
= form_tag switch_project_refs_path(@project), :method => :get, :class => "project-refs-form left", :remote => true do
= select_tag "ref", grouped_options_refs, :onchange => "$(this.form).trigger('submit');", :class => "project-refs-select"
= hidden_field_tag :destination, "tree"
= hidden_field_tag :path, params[:path]
%li %li
= link_to tree_project_ref_path(@project, @ref, :path => nil), :remote => true do = link_to tree_project_ref_path(@project, @ref, :path => nil), :remote => true do
= @project.code = @project.code
- tree.breadcrumbs(6) do |link| - tree.breadcrumbs(6) do |link|
\/ \/
%li= link %li= link
%span.tree_progress
.clear .clear
%div.tree_progress
= image_tag "ajax-loader.gif"
#tree-content-holder #tree-content-holder
- if tree.is_blob? - if tree.is_blob?
= render :partial => "refs/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree } = render :partial => "refs/tree_file", :locals => { :name => tree.name, :content => tree.data, :file => tree }
...@@ -42,12 +49,20 @@ ...@@ -42,12 +49,20 @@
- else - else
= simple_format(content.data) = simple_format(content.data)
- if params[:path]
- history_path = tree_file_project_ref_path(@project, @ref, params[:path])
- else
- history_path = tree_project_ref_path(@project, @ref)
:javascript :javascript
$(function(){ $(function(){
$('select#branch').selectmenu({style:'popup', width:200}); $('select#branch').selectmenu({style:'popup', width:200});
$('select#tag').selectmenu({style:'popup', width:200}); $('select#tag').selectmenu({style:'popup', width:200});
$('.project-refs-select').chosen();
history.pushState({ path: this.path }, '', "#{history_path}")
}); });
- if params[:path] && request.xhr? - if params[:path] && request.xhr?
:javascript :javascript
$(window).unbind('popstate'); $(window).unbind('popstate');
......
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