Commit 8a23682f authored by gitlabhq's avatar gitlabhq

refactored too

parent ca1e3d05
...@@ -540,7 +540,7 @@ input.ssh_project_url { ...@@ -540,7 +540,7 @@ input.ssh_project_url {
font-size:14px; font-size:14px;
} }
.wall_page { #new_note {
#note_note { #note_note {
height:25px; height:25px;
} }
......
...@@ -28,12 +28,15 @@ class CommitsController < ApplicationController ...@@ -28,12 +28,15 @@ class CommitsController < ApplicationController
def show def show
@commit = project.repo.commits(params[:id]).first @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") @note = @project.notes.new(:noteable_id => @commit.id, :noteable_type => "Commit")
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html
format.js 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 end
end end
...@@ -35,8 +35,16 @@ class IssuesController < ApplicationController ...@@ -35,8 +35,16 @@ class IssuesController < ApplicationController
end end
def show def show
@notes = @issue.notes.order("created_at ASC") @notes = @issue.notes.order("created_at DESC").limit(20)
@note = @project.notes.new(:noteable => @issue) @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 end
def create def create
......
-#:plain = render "notes/load"
$("#side-commit-preview").remove();
var side = $("<div id='side-commit-preview'></div>");
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'))}");
%h2 %h2
= "Issue ##{@issue.id} - #{html_escape(@issue.title)}" = "Issue ##{@issue.id} - #{html_escape(@issue.title)}"
.left.width-65p .left.width-65p
-#= simple_format html_escape(@issue.content)
.issue_notes= render "notes/notes" .issue_notes= render "notes/notes"
.loading{ :style => "display:none;"}
%center= image_tag "ajax-loader.gif"
.right.width-30p .right.width-30p
.span-8 .span-8
- if @issue.closed - if @issue.closed
...@@ -55,3 +57,12 @@ ...@@ -55,3 +57,12 @@
.right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}" .right= link_to 'Destroy', [@project, @issue], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-issue negative", :id => "destroy_issue_#{@issue.id}"
.clear .clear
:javascript
$(function(){
$("#note_note").live("click", function(){
$(this).css("height", "100px");
$('.attach_holder').show();
});
NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id});
});
:plain = render "notes/load"
$("#notes-list").html("#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- unless @notes.blank?
- if params[:last_id]
:plain
NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- if params[:first_id]
:plain
NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- if controller.action_name == "wall" - if can? current_user, :write_note, @project
%ul#notes-list= render "notes/notes_list" = render "notes/form"
.clear
- else %hr
%ul#notes-list= render "notes/notes_list" %ul#notes-list= render "notes/notes_list"
%br
%br
- if can? current_user, :write_note, @project
= render "notes/form"
:javascript :javascript
$('.delete-note').live('ajax:success', function() { $('.delete-note').live('ajax:success', function() {
...@@ -20,8 +16,11 @@ ...@@ -20,8 +16,11 @@
$("#submit_note").removeAttr("disabled"); $("#submit_note").removeAttr("disabled");
}) })
-#- if ["issues", "projects"].include?(controller.controller_name) $(function(){
:javascript $("#note_note").live("click", function(){
$(function(){ $(this).css("height", "100px");
var int =self.setInterval("updatePage('ref=#{params[:ref]}')", 20000); $('.attach_holder').show();
}); });
NoteList.init("wall", #{@notes.last.try(:id) || 0}, #{@notes.first.try(:id) || 0});
});
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
:plain :plain
$("#new_note .errors").remove(); $("#new_note .errors").remove();
$('#note_note').val(""); $('#note_note').val("");
NoteList.prepend(#{@note.id}, "#{escape_javascript(render :partial => "notes/show", :locals => {:note => @note})}");
- else - else
:plain :plain
$("#new_note").replaceWith("#{escape_javascript(render('form'))}"); $("#new_note").replaceWith("#{escape_javascript(render('form'))}");
......
%div.wall_page %div.wall_page
- if can? current_user, :write_note, @project = render "notes/notes"
= render "notes/form"
.clear
%hr
= render "notes/notes"
.loading{ :style => "display:none;"} .loading{ :style => "display:none;"}
%center= image_tag "ajax-loader.gif" %center= image_tag "ajax-loader.gif"
:javascript
$(function(){
$("#note_note").live("click", function(){
$(this).css("height", "100px");
$('.attach_holder').show();
});
NoteList.init("wall", #{@notes.last.id}, #{@notes.first.id});
});
- unless @notes.blank? = render "notes/load"
- if params[:last_id]
:plain
NoteList.prepend(#{@notes.first.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
- if params[:first_id]
:plain
NoteList.append(#{@notes.last.id}, "#{escape_javascript(render(:partial => 'notes/notes_list'))}");
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