Commit ca1e3d05796484424057d071b726779537868384

Authored by gitlabhq
1 parent 687290a0

wall login in progress

app/assets/images/ajax-loader.gif

6.66 KB | W: | H:

4.08 KB | W: | H:

  • 2-up
  • Swipe
  • Onion skin
app/assets/javascripts/application.js
... ... @@ -20,6 +20,6 @@ $(function(){
20 20 $('select#tag').selectmenu({style:'popup', width:200});
21 21 });
22 22  
23   -function updatePage(){
24   - $.ajax({type: "GET", url: location.href, dataType: "script"});
  23 +function updatePage(data){
  24 + $.ajax({type: "GET", url: location.href, data: data, dataType: "script"});
25 25 }
... ...
app/assets/javascripts/note.js 0 → 100644
... ... @@ -0,0 +1,65 @@
  1 +var NoteList = {
  2 +
  3 +first_id: 0,
  4 +last_id: 0,
  5 +resource_name: null,
  6 +
  7 +init:
  8 + function(resource_name, first_id, last_id) {
  9 + this.resource_name = resource_name;
  10 + this.first_id = first_id;
  11 + this.last_id = last_id;
  12 + this.initRefresh();
  13 + this.initLoadMore();
  14 + },
  15 +
  16 +getOld:
  17 + function() {
  18 + $('.loading').show();
  19 + $.ajax({
  20 + type: "GET",
  21 + url: location.href,
  22 + data: "first_id=" + this.first_id,
  23 + complete: function(){ $('.loading').hide()},
  24 + dataType: "script"});
  25 + },
  26 +
  27 +append:
  28 + function(id, html) {
  29 + this.first_id = id;
  30 + $("#notes-list").append(html);
  31 + this.initLoadMore();
  32 + },
  33 +
  34 +prepend:
  35 + function(id, html) {
  36 + this.last_id = id;
  37 + $("#notes-list").prepend(html);
  38 + },
  39 +
  40 +getNew:
  41 + function() {
  42 + // refersh notes list
  43 + $.ajax({
  44 + type: "GET",
  45 + url: location.href,
  46 + data: "last_id=" + this.last_id,
  47 + dataType: "script"});
  48 + },
  49 +
  50 +initRefresh:
  51 + function() {
  52 + // init timer
  53 + var int = setInterval("NoteList.getNew()", 20000);
  54 + },
  55 +
  56 +initLoadMore:
  57 + function() {
  58 + $(window).bind('scroll', function(){
  59 + if($(window).scrollTop() == $(document).height() - $(window).height()){
  60 + $(window).unbind('scroll');
  61 + NoteList.getOld();
  62 + }
  63 + });
  64 + }
  65 +}
... ...
app/assets/stylesheets/projects.css.scss
... ... @@ -421,31 +421,6 @@ input.ssh_project_url {
421 421 list-style:none;
422 422 margin:0px;
423 423 padding:0px;
424   -
425   - li {
426   - display:list-item;
427   - padding:8px;
428   - margin:0px;
429   - background: #F7FBFC;
430   - border-top: 1px solid #E2EAEE;
431   -
432   - &:first-child {
433   - border-top: none;
434   - }
435   - &:nth-child(2n+1) {
436   - background: white;
437   - }
438   - p {
439   - margin-bottom: 4px;
440   - font-size: 13px;
441   - color:#111;
442   - }
443   - }
444   - cite {
445   - &.ago {
446   - color:#666;
447   - }
448   - }
449 424 }
450 425  
451 426 .notes_count {
... ... @@ -460,14 +435,6 @@ input.ssh_project_url {
460 435 right: 6px;
461 436 top: 6px;
462 437 }
463   -.note_author {
464   - float:left;
465   - width:60px;
466   -}
467   -.note_content {
468   - float:left;
469   - width:650px;
470   -}
471 438  
472 439 .issue_notes {
473 440 .note_content {
... ... @@ -556,8 +523,7 @@ input.ssh_project_url {
556 523  
557 524 }
558 525 .commit,
559   -.message,
560   -#notes-list{
  526 +.message{
561 527 .author {
562 528 background: #eaeaea;
563 529 color: #333;
... ... @@ -719,3 +685,12 @@ table.highlighttable pre{
719 685 .project-refs-select {
720 686 width:200px;
721 687 }
  688 +
  689 +
  690 +body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;}
  691 +body.project-page #notes-list .note {padding: 10px; border-bottom: 1px solid #eee; overflow: hidden; display: block;}
  692 +body.project-page #notes-list .note img{float: left; margin-right: 10px;}
  693 +body.project-page #notes-list .note span.note-title{display: block;}
  694 +body.project-page #notes-list .note span.note-title{margin-bottom: 10px}
  695 +body.project-page #notes-list .note span.note-author{color: #999; font-weight: normal; font-style: italic;}
  696 +body.project-page #notes-list .note span.note-author strong{font-weight: bold; font-style: normal;}
... ...
app/controllers/projects_controller.rb
... ... @@ -86,13 +86,15 @@ class ProjectsController < ApplicationController
86 86 def wall
87 87 @note = Note.new
88 88 @notes = @project.common_notes.order("created_at DESC")
  89 + @notes = @notes.fresh.limit(20)
89 90  
90   - @notes = case params[:view]
91   - when "week" then @notes.since((Date.today - 7.days).at_beginning_of_day)
92   - when "all" then @notes.all
93   - when "day" then @notes.since(Date.today.at_beginning_of_day)
94   - else @notes.fresh.limit(10)
95   - end
  91 + respond_to do |format|
  92 + format.html
  93 + format.js do
  94 + @notes = @notes.where("id > ?", params[:last_id]) if params[:last_id]
  95 + @notes = @notes.where("id < ?", params[:first_id]) if params[:first_id]
  96 + end
  97 + end
96 98 end
97 99  
98 100 #
... ...
app/views/notes/_notes.html.haml
... ... @@ -20,8 +20,8 @@
20 20 $("#submit_note").removeAttr("disabled");
21 21 })
22 22  
23   -- if ["issues", "projects"].include?(controller.controller_name)
  23 +-#- if ["issues", "projects"].include?(controller.controller_name)
24 24 :javascript
25 25 $(function(){
26   - var int =self.setInterval("updatePage()", 20000);
  26 + var int =self.setInterval("updatePage('ref=#{params[:ref]}')", 20000);
27 27 });
... ...
app/views/notes/_show.html.haml
1   -%li{:id => dom_id(note)}
2   - %div.note_author
3   - = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
4   - %div.note_content.left
  1 +%li{:id => dom_id(note), :class => "note"}
  2 + = image_tag gravatar_icon(note.author.email), :class => "left", :width => 40, :style => "padding-right:5px;"
  3 + %div.note-author
  4 + %strong= note.author_name
  5 + = time_ago_in_words(note.updated_at)
  6 + - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
  7 + = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative"
  8 +
  9 + %div.note-title
5 10 = markdown(note.note)
6 11 - if note.attachment.url
7 12 Attachment:
8 13 = link_to note.attachment_identifier, note.attachment.url, :target => "_blank"
9   - %br
10   - %span.author= note.author.name
11   - %cite.ago
12   - = time_ago_in_words(note.updated_at)
13   - ago
14 14 %br
15   - - if(note.author_id == current_user.id) || can?(current_user, :admin_note, @project)
16   - = link_to 'Remove', [@project, note], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-note right negative"
17 15 .clear
... ...
app/views/notes/create.js.haml
1 1 - if @note.valid?
2 2 :plain
3 3 $("#new_note .errors").remove();
4   - updatePage();
5 4 $('#note_note').val("");
6 5 - else
7 6 :plain
... ...
app/views/projects/wall.html.haml
1 1 %div.wall_page
2 2 - if can? current_user, :write_note, @project
3 3 = render "notes/form"
4   - .right
5   - = form_tag wall_project_path(@project), :method => :get do
6   - .span-2
7   - = radio_button_tag :view, "recent", (params[:view] || "recent") == "recent", :onclick => "this.form.submit()", :id => "recent_view"
8   - = label_tag "recent_view","Recent"
9   - .span-2
10   - = radio_button_tag :view, "day", params[:view] == "day", :onclick => "this.form.submit()", :id => "day_view"
11   - = label_tag "day_view","Today"
12   - .span-2
13   - = radio_button_tag :view, "week", params[:view] == "week", :onclick => "this.form.submit()", :id => "week_view"
14   - = label_tag "week_view","Week"
15   - .span-2
16   - = radio_button_tag :view, "all", params[:view] == "all", :onclick => "this.form.submit()", :id => "all_view"
17   - = label_tag "all_view","All"
18 4 .clear
19   - %br
20 5 %hr
21 6 = render "notes/notes"
22 7  
  8 +.loading{ :style => "display:none;"}
  9 + %center= image_tag "ajax-loader.gif"
  10 +
23 11 :javascript
24 12 $(function(){
25 13 $("#note_note").live("click", function(){
26 14 $(this).css("height", "100px");
27 15 $('.attach_holder').show();
28 16 });
  17 +
  18 + NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id});
29 19 });
... ...
app/views/projects/wall.js.haml
1   -:plain
2   - $("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
  1 +- unless @notes.blank?
  2 +
  3 + - if params[:last_id]
  4 + :plain
  5 + NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
  6 +
  7 + - if params[:first_id]
  8 + :plain
  9 + NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
... ...