moemo的创建与编辑公共部分封装;按钮过长隐藏

This commit is contained in:
huang 2016-12-30 15:52:08 +08:00
parent d9b6294883
commit a30ed19b40
5 changed files with 38 additions and 62 deletions

View File

@ -146,6 +146,7 @@ class MemosController < ApplicationController
def edit
@my_topic_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is null").count
@my_replies_count = Memo.where("forum_id = #{@memo.forum_id} and author_id = #{User.current.id} and parent_id is not null").count
@forums = Forum.reorder("topic_count desc,updated_at desc")
@replying = false
respond_to do |format|
format.html {render :layout => 'base_new_forum'}

View File

@ -3,41 +3,36 @@
<% end %>
<div class="wenba-tiwenbox fl mr10 mb10">
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
<div class="wenba-tiwen-con">
<ul >
<li class="mb10">
<input type="text" name="memo[subject]" id="memo_subject" maxlength="50" style="width:708px" onblur="check_memo_name()" onfocus="$('#memo_name_error_tips').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="wenba-tiwen-input" placeholder="请输入标题">
<p class="c_red" style="display: none" id="memo_name_error_tips"></p>
<script>
var textarea1 = document.getElementById('memo_subject');
autoTextarea(textarea1);
</script>
</li>
<li class="mb10">
<%= kindeditor_tag 'memo[content]','', :height => 300, :editor_id => 'memo_content' %>
<!--<textarea placeholder="请输入描述详情" class="wenba-tiwen-textarea"></textarea>-->
</li>
<p class="c_red" style="display: none" id="memo_contents_error_tips"></p>
<li class="clear mb10">
<%= render :partial => 'forums/file_form', :locals => {:container => @memo} %>
<!--<button class="sub_btn fl" name="button" type="button">上传附件</button>-->
<!--<p class="fl ml5 mt3 c_grey">(未选择文件) 您可以上传小于<span class="c_red">50MB</span>的文件</p>-->
</li>
</ul>
<ul class="wenba-tagbox clearfix">
<h3 class="mb5 c_red" id="memo_classify_tips">请选择分类</h3>
<% @forums.each do |forum| %>
<li><a href="javascript:void(0)" class="wenba-tiwen-tag" name="<%= forum.name %>" id="forums_question_<%= forum.id %>" onclick="add_forum('forums_question_<%= forum.id %>')" ><%= forum.name %></a></li>
<% end %>
</ul>
<input type="text" style="display: none" id="forum_name" name="forum_name" value="">
<div class="clear ">
<%= link_to "取消", forum_path(@forum), :class => "btn fr" %>
<a href="javascript:void(0);" class="btn btn-blue fr mr5" onclick="memo_commit();">确定</a>
</div>
</div>
<% end %>
<div class="wenba-tiwen-con">
<ul >
<li class="mb10">
<%= f.text_field :subject, :no_label => true, :id => "memo_subject", :maxlength => "50", :style => "width:708px", :onblur => "check_memo_name();", :onfocus => "$('#memo_name_error_tips').hide();", :onmouseover => "this.style.borderColor='#d9d9d9'", :class => "wenba-tiwen-input", :placeholder => "请输入标题" %>
<p class="c_red" style="display: none" id="memo_name_error_tips"></p>
<script>
var textarea1 = document.getElementById('memo_subject');
autoTextarea(textarea1);
</script>
</li>
<li class="mb10">
<%= f.kindeditor :content, :editor_id => "memo_content", :height => 300, :no_label => true %>
</li>
<p class="c_red" style="display: none" id="memo_contents_error_tips"></p>
<li class="clear mb10">
<%= render :partial => 'forums/file_form', :locals => {:container => @memo} %>
</li>
</ul>
<ul class="wenba-tagbox clearfix">
<h3 class="mb5 c_red" id="memo_classify_tips">请选择分类</h3>
<% @forums.each do |forum| %>
<li class="hidden" style="max-width: 200px;"><a href="javascript:void(0)" class="wenba-tiwen-tag" name="<%= forum.name %>" id="forums_question_<%= forum.id %>" onclick="add_forum('forums_question_<%= forum.id %>')" ><%= forum.name %></a></li>
<% end %>
</ul>
<input type="text" style="display: none" id="forum_name" name="forum_name" value="">
<div class="clear ">
<%= link_to "取消", forum_path(@forum), :class => "btn fr" %>
<a href="javascript:void(0);" class="btn btn-blue fr mr5" onclick="memo_commit();">确定</a>
</div>
</div>
</div>
<script>

View File

@ -44,30 +44,9 @@
<%= @memo.subject %>
</div>
<div class="postRightContainer mr10">
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %>
<div id="error" style="color:red ;display: none">
</div>
<div>
<textarea type="text" id="memo_subject" name="memo[subject]" maxlength="50" class="postDetailInput" placeholder="对应帖子标题" ><%= @memo.subject%></textarea>
<script>
var ta = document.getElementById('memo_subject')
autoTextarea(ta)
</script>
</div>
<div class="mt15">
<%= kindeditor_tag 'memo[content]',@memo.content,:height=>300,:editor_id=>'memo_content'%>
</div>
<div class="mt10">
<!--<a href="javascript:void(0);" class="AnnexBtn fl mt3">对应附件名称</a>-->
<%= render :partial => 'forums/file_form', :locals => {:container => @memo} %>
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit();">确定</a></div>
<div class="fr"><a href="<%= forum_memo_path(@memo.forum,@memo)%>" class="linkGrey2 mr10">取消</a><span class="mr10 fontGrey">或</span></div>
<div class="cl"></div>
</div>
<% end %>
</div>
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %>
<%= render :partial => "memos/form", :locals => {:f => f} %>
<% end %>
<div class="fl">
<%= render :partial => "memos/my_count_message" %>

View File

@ -1,5 +1,6 @@
<div class="banner-big f16 fontGrey3 mb10"><%= link_to "问吧", forums_path, :class => "c_blue" %> > <%= link_to @forum.name, forum_path(@forum), :class => "c_blue" %> > 我要提问</div>
<%= render :partial => "memos/form" %>
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
<%= render :partial => "memos/form", :locals => {:f => f} %>
<% end %>
<%= render :partial => "forums/my_count_message" %>

View File

@ -11,7 +11,7 @@
.wenba-tiwen-con{ width: 100%; }
input.wenba-tiwen-input{ width:705px; height: 30px; line-height: 30px; padding:0 5px;}
textarea.wenba-tiwen-textarea{ padding:5px;width:705px; height: 150px;}
a.wenba-tiwen-tag{background-color: #E4EFF6;border-bottom: 1px solid #B1D3EB; border-right: 1px solid #B1D3EB;-webkit-text-size-adjust: none; color: #3E6D8E; font-size:12px;line-height: 2.4; padding: 5px 10px;text-decoration: none; white-space: nowrap;}
a.wenba-tiwen-tag{background-color: #E4EFF6;border-bottom: 1px solid #B1D3EB; border-right: 1px solid #B1D3EB;-webkit-text-size-adjust: none; color: #3E6D8E; font-size:12px;line-height: 2.4; padding: 5px 10px;text-decoration: none; white-space: nowrap;width: 200px;}
a:hover.wenba-tiwen-tag,a.wenba-tiwen-tag-active{ background: #3b94d6; color: #fff;border-bottom: 1px solid #2e76ab; border-right: 1px solid #2e76ab;}
.wenba-tagbox li{ float: left; margin:0 5px 5px 0;}
.wenba-tagbox h3{ font-weight: normal; color: #333;}