diff --git a/app/assets/images/ajax-loader.gif b/app/assets/images/ajax-loader.gif index 0ca7ada9..c97ec6ea 100644 Binary files a/app/assets/images/ajax-loader.gif and b/app/assets/images/ajax-loader.gif differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b1e95736..31046379 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -21,6 +21,6 @@ $(function(){ $('select#tag').selectmenu({style:'popup', width:200}); }); -function updatePage(){ - $.ajax({type: "GET", url: location.href, dataType: "script"}); +function updatePage(data){ + $.ajax({type: "GET", url: location.href, data: data, dataType: "script"}); } diff --git a/app/assets/javascripts/note.js b/app/assets/javascripts/note.js new file mode 100644 index 00000000..71279fc4 --- /dev/null +++ b/app/assets/javascripts/note.js @@ -0,0 +1,65 @@ +var NoteList = { + +first_id: 0, +last_id: 0, +resource_name: null, + +init: + function(resource_name, first_id, last_id) { + this.resource_name = resource_name; + this.first_id = first_id; + this.last_id = last_id; + this.initRefresh(); + this.initLoadMore(); + }, + +getOld: + function() { + $('.loading').show(); + $.ajax({ + type: "GET", + url: location.href, + data: "first_id=" + this.first_id, + complete: function(){ $('.loading').hide()}, + dataType: "script"}); + }, + +append: + function(id, html) { + this.first_id = id; + $("#notes-list").append(html); + this.initLoadMore(); + }, + +prepend: + function(id, html) { + this.last_id = id; + $("#notes-list").prepend(html); + }, + +getNew: + function() { + // refersh notes list + $.ajax({ + type: "GET", + url: location.href, + data: "last_id=" + this.last_id, + dataType: "script"}); + }, + +initRefresh: + function() { + // init timer + var int = setInterval("NoteList.getNew()", 20000); + }, + +initLoadMore: + function() { + $(window).bind('scroll', function(){ + if($(window).scrollTop() == $(document).height() - $(window).height()){ + $(window).unbind('scroll'); + NoteList.getOld(); + } + }); + } +} diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index 4e4bcccc..766138ee 100644 --- a/app/assets/stylesheets/projects.css.scss +++ b/app/assets/stylesheets/projects.css.scss @@ -421,31 +421,6 @@ input.ssh_project_url { list-style:none; margin:0px; padding:0px; - - li { - display:list-item; - padding:8px; - margin:0px; - background: #F7FBFC; - border-top: 1px solid #E2EAEE; - - &:first-child { - border-top: none; - } - &:nth-child(2n+1) { - background: white; - } - p { - margin-bottom: 4px; - font-size: 13px; - color:#111; - } - } - cite { - &.ago { - color:#666; - } - } } .notes_count { @@ -460,14 +435,6 @@ input.ssh_project_url { right: 6px; top: 6px; } -.note_author { - float:left; - width:60px; -} -.note_content { - float:left; - width:650px; -} .issue_notes { .note_content { @@ -556,8 +523,7 @@ input.ssh_project_url { } .commit, -.message, -#notes-list{ +.message{ .author { background: #eaeaea; color: #333; @@ -574,7 +540,7 @@ input.ssh_project_url { font-size:14px; } -.wall_page { +#new_note { #note_note { height:25px; } @@ -719,3 +685,11 @@ table.highlighttable pre{ .project-refs-select { width:200px; } + +body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} +body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;} +body.project-page #notes-list .note img{float: left; margin-right: 10px;} +body.project-page #notes-list .note span.note-title{display: block;} +body.project-page #notes-list .note span.note-title{margin-bottom: 10px} +body.project-page #notes-list .note span.note-author{color: #999; font-weight: normal; font-style: italic;} +body.project-page #notes-list .note span.note-author strong{font-weight: bold; font-style: normal;} diff --git a/app/assets/stylesheets/style.scss b/app/assets/stylesheets/style.scss index 97be566f..29e6058d 100755 --- a/app/assets/stylesheets/style.scss +++ b/app/assets/stylesheets/style.scss @@ -292,7 +292,7 @@ body.login-page{background-color: #f1f1f1; padding-top: 10%} /* General */ #container{background-color: white; overflow: hidden;} -/*#container{margin: auto; width: 980px; border: 1px solid rgba(0,0,0,.22); border-top: 0; box-shadow: 0 0 0px 4px rgba(0,0,0,.04)}*/ +body.collapsed #container{margin: auto; width: 980px; border: 1px solid rgba(0,0,0,.22); border-top: 0; box-shadow: 0 0 0px 4px rgba(0,0,0,.04)} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6d0edace..070def96 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,7 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user! + before_filter :view_style + protect_from_forgery helper_method :abilities, :can? @@ -73,4 +75,12 @@ class ApplicationController < ActionController::Base def require_non_empty_project redirect_to @project unless @project.repo_exists? end + + def view_style + if params[:view_style] == "collapsed" + cookies[:view_style] = "collapsed" + elsif params[:view_style] == "fluid" + cookies[:view_style] = "" + end + end end diff --git a/app/controllers/commits_controller.rb b/app/controllers/commits_controller.rb index 79b97ed7..f6af56f8 100644 --- a/app/controllers/commits_controller.rb +++ b/app/controllers/commits_controller.rb @@ -28,12 +28,15 @@ class CommitsController < ApplicationController def show @commit = project.repo.commits(params[:id]).first - @notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit") + @notes = project.notes.where(:noteable_id => @commit.id, :noteable_type => "Commit").order("created_at DESC").limit(20) @note = @project.notes.new(:noteable_id => @commit.id, :noteable_type => "Commit") - respond_to do |format| - format.html # show.html.erb - format.js + respond_to do |format| + format.html + format.js do + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] + end end end end diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 71c559a1..b6fd85b8 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -35,8 +35,16 @@ class IssuesController < ApplicationController end def show - @notes = @issue.notes.order("created_at ASC") + @notes = @issue.notes.order("created_at DESC").limit(20) @note = @project.notes.new(:noteable => @issue) + + respond_to do |format| + format.html + format.js do + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] + end + end end def create diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index e046add3..067245c4 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,13 +86,15 @@ class ProjectsController < ApplicationController def wall @note = Note.new @notes = @project.common_notes.order("created_at DESC") + @notes = @notes.fresh.limit(20) - @notes = case params[:view] - when "week" then @notes.since((Date.today - 7.days).at_beginning_of_day) - when "all" then @notes.all - when "day" then @notes.since(Date.today.at_beginning_of_day) - else @notes.fresh.limit(10) - end + respond_to do |format| + format.html + format.js do + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id] + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id] + end + end end # diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3aa40c99..70984804 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,6 +4,14 @@ module ApplicationHelper "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(user_email)}?s=40&d=identicon" end + def body_class(default_class = nil) + main = content_for(:body_class).blank? ? + default_class : + content_for(:body_class) + + [main, cookies[:view_style]].join(" ") + end + def commit_name(project, commit) if project.commit.id == commit.id "master" diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml index 7999b94c..b9650145 100644 --- a/app/views/commits/index.html.haml +++ b/app/views/commits/index.html.haml @@ -12,7 +12,7 @@ \/ %a{:href => "#"}= params[:path].split("/").join(" / ") -.right= render "projects/refs" +.right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) } %div{:id => dom_id(@project)} = render "commits" diff --git a/app/views/commits/show.js.haml b/app/views/commits/show.js.haml index 9831bb29..ee31c0b8 100644 --- a/app/views/commits/show.js.haml +++ b/app/views/commits/show.js.haml @@ -1,8 +1 @@ --#:plain - $("#side-commit-preview").remove(); - var side = $("
"); - side.html("#{escape_javascript(render "commits/show")}"); - $("##{dom_id(@project)}").parent().append(side); - $("##{dom_id(@project)}").addClass("span-14"); -:plain - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); += render "notes/load" diff --git a/app/views/issues/show.html.haml b/app/views/issues/show.html.haml index 371a8033..8267a850 100644 --- a/app/views/issues/show.html.haml +++ b/app/views/issues/show.html.haml @@ -1,14 +1,12 @@ %h2 = "Issue ##{@issue.id} - #{html_escape(@issue.title)}" .left.width-65p - -#= simple_format html_escape(@issue.content) .issue_notes= render "notes/notes" + + .loading{ :style => "display:none;"} + %center= image_tag "ajax-loader.gif" .right.width-30p .span-8 - - if @issue.closed - %center.success Closed - - else - %center.error Open %table.round-borders %tr %td Title: @@ -54,4 +52,3 @@ = link_to 'Edit', edit_project_issue_path(@project, @issue), :class => "lbutton positive", :remote => true .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" .clear - diff --git a/app/views/issues/show.js.haml b/app/views/issues/show.js.haml index ae2ff32c..ee31c0b8 100644 --- a/app/views/issues/show.js.haml +++ b/app/views/issues/show.js.haml @@ -1,2 +1 @@ -:plain - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}"); += render "notes/load" diff --git a/app/views/layouts/_head_panel.html.erb b/app/views/layouts/_head_panel.html.erb index a64aa3b5..6db1d389 100644 --- a/app/views/layouts/_head_panel.html.erb +++ b/app/views/layouts/_head_panel.html.erb @@ -1,19 +1,29 @@