From 8ea5d98b6c5c78871a8c7ca66838a7e20ccc6483 Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 15 Oct 2015 16:17:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA=E5=8C=BA?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=B8=96=E5=AD=90=E3=80=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=B8=96=E5=AD=90=E7=9A=84=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/boards_controller.rb | 1 + app/views/attachments/_form_course.html.erb | 6 +- .../boards/_course_message_edit.html.erb | 16 ++ app/views/boards/_course_new.html.erb | 68 ++++++++- app/views/boards/_course_show.html.erb | 144 +++++++++++------- app/views/boards/show.html.erb | 9 +- app/views/homework_common/index.html.erb | 2 +- app/views/layouts/base_courses.html.erb | 2 +- app/views/messages/_course_show.html.erb | 40 ++--- app/views/messages/edit.html.erb | 67 ++++---- public/javascripts/course.js | 59 +++++++ public/stylesheets/courses.css | 1 + 12 files changed, 282 insertions(+), 133 deletions(-) create mode 100644 app/views/boards/_course_message_edit.html.erb diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 09a0fc342..2ec3cac0d 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -96,6 +96,7 @@ class BoardsController < ApplicationController 'replies' => "#{Message.table_name}.replies_count", 'updated_on' => "COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on)" + @is_new = params[:is_new] @topic_count = @board ? @board.topics.count : 0 if @project @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb index b0ab39b5a..b66632c7f 100644 --- a/app/views/attachments/_form_course.html.erb +++ b/app/views/attachments/_form_course.html.erb @@ -42,7 +42,9 @@ <%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %> -<%= button_tag "#{l(:button_browse)}", :type=>"button", :onclick=>"file#{container.id}.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> +<%#= button_tag "#{l(:button_browse)}", :type=>"button", :onclick=>"file#{container.id}.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %> +<% id ="file#{container.id}"%> +上传附件 <%= file_field_tag 'attachments[dummy][file]', :id => "file#{container.id}", :class => 'file_selector', @@ -63,7 +65,7 @@ <% if container.nil? %> <%= l(:label_no_file_uploaded)%> <% end %> -(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) + <% content_for :header_tags do %> diff --git a/app/views/boards/_course_message_edit.html.erb b/app/views/boards/_course_message_edit.html.erb new file mode 100644 index 000000000..16807afb0 --- /dev/null +++ b/app/views/boards/_course_message_edit.html.erb @@ -0,0 +1,16 @@ + +
+
+
+ 编辑帖子 +
+
+ <%= render :partial => 'boards/course_new', + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic} %> +
\ No newline at end of file diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 61c774a95..9eb7e49ad 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,12 +1,66 @@ -<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> +<%= error_messages_for 'message' %> +
+
+
+
+ +

+
+ +
+ <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %> + +
+
\ No newline at end of file diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 783531027..ef16d0c23 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,79 +1,107 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> +
+
+
+ 课程讨论区 +
+
+ <% if User.current.logged? %> + <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false} %> + <% end %> + <% end %> + <% if topics%> - <% topics.each do |topic| %> - - <% if topic %> - <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> - <% end %> + $('#reply_content_<%= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); + }); + + <% if topic %> + <%= render :partial => 'users/course_message', :locals => {:activity => topic, :user_activity_id => topic.id} %> <% end %> + <% end %> - <% if topics.count == 10 %> -
展开更多<%= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %>
- <% end %> - <% end%> + <% if topics.count == 10 %> +
展开更多<%= link_to "", boards_topic_path(@board, :course_id => @board.course.id ,:page => page), :id => "more_topic_link", :remote => "true", :class => "none" %>
+ <% end %> +<% end%> +
-
+
<%= link_to image_tag(url_to_avatar(@topic.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@topic.author) %>
<% if @topic.author.id == User.current.id%> -
+
<% @replies.each_with_index do |reply,i| %> -
+
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
@@ -111,22 +111,24 @@
<%= reply.content.html_safe%>
- <%= format_date(reply.created_on) %> - <%= link_to( - l(:button_reply), - {:action => 'quote', :id => reply}, - :remote => true, - :method => 'get', - :class => 'fr newsBlue', - :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => reply}, - :method => :post, - :class => 'fr newsGrey mr10', - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if reply.course_destroyable_by?(User.current) %> + <%= format_date(reply.created_on) %> +

diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index d30aee45d..0817594ab 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -1,45 +1,38 @@ -
-

<%= l(:label_course_board) %>

-
+<% if @message.project %> +
+

<%= l(:label_course_board) %>

+
+ - <% if @message.project %> <%#= board_breadcrumb(@message) %> - -
-
    - <%= form_for @message, { :as => :message, - :url => {:action => 'edit'}, - :html => {:multipart => true, - :id => 'message-form', - :method => :post} - } do |f| %> + +
    +
      + <%= form_for @message, {:as => :message, + :url => {:action => 'edit'}, + :html => {:multipart => true, + :id => 'message-form', + :method => :post} + } do |f| %> <%= render :partial => 'form_project', - :locals => {:f => f, :replying => !@message.parent.nil?} %> - <%= l(:button_submit)%> - <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %> -
    -
    - <% end %> + :locals => {:f => f, :replying => !@message.parent.nil?} %> + <%= l(:button_submit) %> + <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %> +
+
+ <% end %> <% elsif @message.course %> - <%#= course_board_breadcrumb(@message) %> -
-
    0 - <%= form_for @message, { - :as => :message, - :url => {:action => 'edit'}, - :html => {:multipart => true, - :id => 'message-form', - :method => :post} - } do |f| %> - <%= render :partial => 'form_course', - :locals => {:f => f, :replying => !@message.parent.nil?} %> - <%= l(:button_submit)%> - <%= link_to l(:button_cancel), board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id)), :class => "blue_btn grey_btn fl c_white" %> + <%= form_for @message, { + :as => :message, + :url => {:action => 'edit'}, + :html => {:multipart => true, + :id => 'message-form', + :method => :post} + } do |f| %> + <%= render :partial => 'boards/course_message_edit', + :locals => {:f => f, :edit_mode => true, :topic => @message} %> - <% end %> -
-
+ <% end %> <% end %> -
diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 3818d447d..3baa11970 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -148,6 +148,65 @@ function submit_edit_course(id) $("#edit_course_"+id).submit(); } } +//课程讨论区 +function regexTopicSubject() { + var name = $("#message_subject").val(); + if(name.length ==0) + { + $("#subjectmsg").text("标题不能为空"); + $("#subjectmsg").css('color','#ff0000'); + $("#message_subject").focus(); + return false; + } + else if(name.length <= 255) + { + $("#subjectmsg").text("填写正确"); + $("#subjectmsg").css('color','#008000'); + return true; + } + else + { + $("#subjectmsg").text("标题超过255个字符"); + $("#subjectmsg").css('color','#ff0000'); + $("#message_subject").focus(); + return false; + } +} + +function regexTopicDescription() +{ + var name = message_content_editor.html(); + if(name.length ==0) + { + $("#message_content_span").text("描述不能为空"); + $("#message_content_span").css('color','#ff0000'); + return false; + } + else if(name.length >=6000){ + $("#message_content_span").text("描述最多3000个汉字(或6000个英文字符)"); + $("#message_content_span").css('color','#ff0000'); + return false; + } + else + { + $("#message_content_span").text("填写正确"); + $("#message_content_span").css('color','#008000'); + return true; + } +} + +function submit_topic() +{ + if(regexTopicSubject() && regexTopicDescription()) + { + message_content_editor.sync(); + $("#message-form").submit(); + } +} + +function reset_topic(){ + +} /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////课程讨论区 diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 2da36a991..d6af2102b 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -904,6 +904,7 @@ a:hover.BlueCirBtn{ background:#269ac9; color:#fff;} .w720{width:721px;} .w709{width: 709px;} .w701{width: 701px;} +.w704{width: 704px;} a.AnnexBtn{ background: url(images/homepage_icon2.png) 0px -343px no-repeat !important; height:20px; display:block; padding-left:20px; color:#888888;} a:hover.AnnexBtn{background: url(images/homepage_icon2.png) -90px -343px no-repeat !important; color:#3598db;} a.FilesBtn{ background: url(../images/homepage_icon2.png) 0px -373px no-repeat; width:70px; height:20px; display:block; padding-left:20px; color:#888888;}