From 72b93fa8f0c561850871ab9c5697dd9c296321c0 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Sat, 23 May 2015 16:02:41 +0800 Subject: [PATCH] ... --- app/views/boards/_edit.html.erb | 16 +- app/views/boards/_form_project.html.erb | 14 +- app/views/boards/_project_new_topic.html.erb | 6 +- app/views/boards/_project_show.html.erb | 434 +++++++------------ app/views/boards/show.html.erb | 2 +- 5 files changed, 187 insertions(+), 285 deletions(-) diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb index fb5adc1d6..562319e56 100644 --- a/app/views/boards/_edit.html.erb +++ b/app/views/boards/_edit.html.erb @@ -2,37 +2,37 @@ <% if topic.project %> <%#= board_breadcrumb(@message) %> -
+
<% end %> <% elsif topic.course %> <%#= course_board_breadcrumb(@message) %> -
+
    <%= form_for topic, { :as => :message, :url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id}, :html => {:multipart => true, :name=>'message-form', :id => 'message-form' + topic.id.to_s, - :method => :post} + :method => :post,:nhname=>'form'} } do |f| %> <%= render :partial => 'form_course', :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %> - <%= l(:button_submit)%> - <%= l(:button_cancel) %> + <%= l(:button_cancel) %> + <%= l(:button_submit)%> <% end %>
diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index eb9c4e416..5cf20a993 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -18,19 +18,19 @@
  • - <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}",:class=>"talk_input w585", :aa=>'subject' }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}",:class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %> -

    +

  • <% else %>
  • - <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", onkeyup: "regexSubject('#{f.object.id}');",:class=>"talk_input w585", :aa=>'subject' }.merge(extra_option) %> + <%= f.text_field :subject, { size: 60, id: "message_subject#{f.object.id}", :class=>"talk_input w585", :nhname=>'inputsubject' }.merge(extra_option) %> -

    +

  • <% end %>
  • @@ -59,7 +59,7 @@ :width => '89%', :height => 300, :id => "message_content#{f.object.id}", - :aa => 'content', + :nhname => 'textarea', :onkeyup => "regexContent('#{f.object.id}');", :class => 'talk_text fl', :placeholder => "最多3000个汉字(或6000个英文字符)", @@ -74,14 +74,14 @@ :id => "message_content#{f.object.id}", :onkeyup => "regexContent('#{f.object.id}');", :class => 'talk_text fl', - :aa => 'content', + :nhname => 'textarea', :placeholder => "最多3000个汉字(或6000个英文字符)", :maxlength => 5000 %> <% end %>
  • -

    +

  • diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb index 5c8691529..05304e978 100644 --- a/app/views/boards/_project_new_topic.html.erb +++ b/app/views/boards/_project_new_topic.html.erb @@ -1,10 +1,10 @@ -<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form', :name=>'message-form'} do |f| %> +<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},:nhname=>'form', :html => {:multipart => true, :id => 'message-form', :name=>'message-form'} do |f| %> <%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
  • - <%= l(:button_cancel) %> + <%= l(:button_cancel) %> - <%= l(:button_submit)%> + <%= l(:button_submit)%>
  • <% end %> \ No newline at end of file diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 2129c3a9f..0706860f9 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -1,280 +1,182 @@ -
    -

    - <% if User.current.language == "zh"%> - <%= h @board.name %> - <% else %> - <%= l(:project_module_boards) %> +
    +
    +

    + <% if User.current.language == "zh"%> + <%= h @board.name %> + <% else %> + <%= l(:project_module_boards) %> + <% end %> +

    + <% if User.current.logged? %> + <%= l(:label_message_new) %> <% end %> - -

    - <% if User.current.logged? %> - <%= l(:label_message_new) %> +
    +
    + <% if !User.current.logged? %> +
    + <%= l(:label_user_login_project_board) %> + <%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %> +
    <% end %>
    +
    +
    +
      + <%= render :partial => 'project_new_topic' %> +
    +
    +
    - - -<% if !User.current.logged? %> -
    - <%= l(:label_user_login_project_board) %> - <%= link_to l(:label_user_login_new), signin_path, :class => "c_blue ml5" %> -
    -<% end %> - - -
    -
    -
      - <%= render :partial => 'project_new_topic' %> -
    -
    - -

    讨论区共有<%= @topic_count %>个帖子

    -<% if @topics.any? %> - <% @topics.each do |topic| %> - -
    - <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> -
    - <% author = topic.author.to_s + ":" %> - <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %> - -

      <%= h(topic.subject) %>

    - <% if topic.editable_by?(User.current) %> - - <%= l(:button_edit) %> - <% end %> - - <%= link_to( - l(:button_delete), - {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'talk_edit fr', - :style => ' margin-right: 10px;' - ) if topic.destroyable_by?(User.current) %> - - <% if topic.sticky? %> - <%= l(:label_board_sticky)%> - <% end %> -
    - -
    -
    - <%= topic.content.html_safe %> -
    -
    - - -
    +
    + <%= link_to image_tag(url_to_avatar(topic.author), :width=>"42",:height=>"42"), user_path(topic.author),:class =>'talkmain_pic fl' %> +
    + <% author = topic.author.to_s + ":" %> + <%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %> +

      <%= h(topic.subject) %>

    + <% if topic.editable_by?(User.current) %> + <%= l(:button_edit) %> + <% end %> + <%= link_to( + l(:button_delete), + {:controller =>'messages',:action => 'destroy', :id => topic.id, :board_id => topic.board_id, :is_board=>'true'}, + :method => :post, + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'talk_edit fr', + :style => ' margin-right: 10px;' + ) if topic.destroyable_by?(User.current) %> + <% if topic.sticky? %> + <%= l(:label_board_sticky)%> + <% end %> +
    +
    +
    + <%= topic.content.html_safe %> +
    +
    + + <%= link_to_attachments_course topic, :author => false %> + <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> +
    + <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => "about_newtalk#{topic.id}",:class => ' c_dblue fr' %> + <% end %> +
    +
    + +
    +
    -

    - - <%= link_to_attachments_course topic, :author => false %> - - <%= l(:label_activity_time)%>:  <%= format_time topic.created_on %> - -
    - <% if User.current.logged? %> - <%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => "about_newtalk#{topic.id}",:class => ' c_dblue fr' %> - <% end %> -
    - - -
    - - -
    - <% reply = Message.new(:subject => "RE: #{@message.subject}")%> - <% if !topic.locked? && authorize_for('messages', 'reply') %> - -
    - - <% end %> - <% replies_all = topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.id asc").offset(2). - all %> - <% replies_show = topic.children. - includes(:author, :attachments, {:board => :project}). - reorder("#{Message.table_name}.id asc").limit(2). - all %> - <% unless replies_show.empty? %> - <% reply_count = 0 %> -
    -
      - <% replies_show.each do |message| %> - -
    • - <%= link_to image_tag(url_to_avatar(message.author), :width => '34',:height => '34'), user_path(message.author), :class =>'Msg_pic' %> -
      - <%= link_to_user_header message.author,false,:class => 'fl c_orange ' %> -
      -

      <%= textAreailizable message,:content,:attachments => message.attachments %>

      - -
      - <%= format_time(message.created_on) %> - <%= link_to( - - l(:button_delete), - {:controller => 'messages', :action => 'destroy', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete), - :class => ' c_dblue fr' - ) if message.course_destroyable_by?(User.current) %> - <%= link_to( - l(:button_reply), - {:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'}, - :class => ' c_dblue fr', - :style => 'margin-right: 10px;', - :remote => true, - :method => 'get', - :onclick => "$('#reply#{topic.id}').slideToggle(); return false;", - :focus => "about_newtalk#{topic.id}", - :title => l(:button_quote)) if !topic.locked? && authorize_for('messages', 'reply') %> -
      -
      - -
    • - <% end %> -
    -
    - - <%if replies_all.first %> - - <% end %> - <% end %> -
    - +
    + <% reply = Message.new(:subject => "RE: #{@message.subject}")%> + <% if !topic.locked? && authorize_for('messages', 'reply') %> + +
    + <% end %> - <% else %> -

    <%= l(:label_no_data) %>

    - <% end %> -
      - <%= pagination_links_full @topic_pages, @topic_count, :per_page_links => false, :remote => false, :flag => true %> -
    - - -<%# other_formats_links do |f| %> - <%#= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> -<%# end %> +
    -<% html_title @board.name %> - -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %> -<% end %> -
    - + function nh_check_field(params){ + var result=true; + + if($.trim(params.subject.val()) == ""){ + params.subjectmsg.html('主题不能为空'); + params.subjectmsg.css({color:'#ff0000'}); + result=false; + }else{ + params.subjectmsg.html('填写正确'); + params.subjectmsg.css({color:'#008000'}); + } + params.subjectmsg.show(); + + if($.trim(params.content.html()) == ""){ + params.contentmsg.html('内容不能为空'); + params.contentmsg.css({color:'#ff0000'}); + result=false; + }else{ + params.contentmsg.html('填写正确'); + params.contentmsg.css({color:'#008000'}); + } + params.contentmsg.show(); + + return result; + } + function nh_init_board(params){ + params.showbtn.click(function(){//发帖/编辑/回复按钮的click + if(params.textarea.data('init') == undefined){ + var editor = params.kindutil.create(params.textarea, {//初始化编辑器 + resizeType : 1, + allowPreviewEmoticons : false, + allowImageUpload : false, + minWidth:"1px", + width:"565px", + items : [] + }); + params.submitbtn.click(function(){//提交按钮click + var is_checked = nh_check_field({ + subject:params.inputsubject, + subjectmsg:params.subjectmsg, + content:editor, + contentmsg:params.contentmsg, + }); + if(is_checked){ + alert('submit'); + params.textarea.html(editor.html()); +// params.form.submit(); + } + }); + params.cancelbtn.click(function(){//取消按钮click + params.about_talk.toggle();//显示/隐藏编辑区 + params.inputsubject.focus(); + }); + params.textarea.data('init','1') + } + params.cancelbtn.click();//显示/隐藏编辑区 + }); + } + $(function(){ + KindEditor.ready(function(K){ + $("div[nhname='container_board']").each(function(){ + var container = $(this); + nh_init_board({ + kindutil:K, + showbtn:$("a[nhname='showbtn']",container), + about_talk:$("div[nhname='about_talk']",container), + inputsubject:$("input[nhname='inputsubject']",container), + subjectmsg:$("p[nhname='subjectmsg']",container), + textarea:$("textarea[nhname='textarea']",container), + contentmsg:$("p[nhname='contentmsg']",container), + submitbtn:$("a[nhname='submitbtn']",container), + cancelbtn:$("a[nhname='cancelbtn']",container), + form:$("form[nhname='form']",container) + }); + }); + }); + }); + \ No newline at end of file diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index ed49f0adb..7ec7fd0fd 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -61,7 +61,7 @@ function show_newtalk1(id) $(id).toggle(); $(id).focus(); - + }