系统消息-修改

This commit is contained in:
ouyangxuhua 2015-09-11 16:05:02 +08:00
parent 22e2510482
commit 67dcb025aa
2 changed files with 32 additions and 36 deletions

View File

@ -1,5 +1,7 @@
class SystemMessage < ActiveRecord::Base class SystemMessage < ActiveRecord::Base
attr_accessible :content, :id, :user_id attr_accessible :content, :id, :user_id
belongs_to :user belongs_to :user
validates_length_of :content, maximum: 255
validates :content, presence: true
validates_length_of :content, maximum:255
end end

View File

@ -1,53 +1,47 @@
# encoding: utf-8
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<h3 style="float: left"> <h3 style="float: left">
<%=l(:label_system_message)%> <%=l(:label_system_message)%>
</h3><br/> </h3><br/>
<div style="padding-top: 20px; padding-left: 5px;"> <div style="padding-top: 20px; padding-left: 5px;">
<%= form_for(@admin_messages, :html => {:id =>'system_message_form', :multipart => true}) do |f| %> <%= form_for(@admin_messages, :html => {:id =>'system_message-form'}) do |f| %>
<div class="field"> <div class="field">
<%= f.kindeditor :content, :edit_id => 'system_message', <%= f.kindeditor :content,:width=>'87%',:editor_id=>'system_message_editor' %>
:width => '87%', <p id="content_notice_span" class="ml55"></p>
:resizeType => '0',
:no_label => true
%>
</div> </div>
<div> <div>
<p id="content_notice_span" class="ml55"></p> <p id="content_notice_span" class="ml55"></p>
</div> </div>
<div class="actions"> <div class="actions">
<%= f.submit l(:label_submit),:class => "small", :onclick => "system_message.sync;" %> <%= link_to l(:label_submit), "javascript:void(0)",:class => "small", :onclick => "system_message_editor.sync();submit_message();" %>
</div> </div>
<% end %> <% end %>
</div> </div>
<script> <script>
function system_message_length() function system_message_length() {
{ var obj = system_message_editor.html();
var obj = $("#system_message").value; if (obj.length == 0) {
if (obj.length == 0) { $("#content_notice_span").text("内容不能为空");
$("#content_notice_span").text("内容不能为空"); $("#content_notice_span").css('color', '#ff0000');
$("#content_notice_span").css('color', '#ff0000'); $("#content_notice_span").focus();
$("#content_notice_span").focus(); return false;
return false;
}
else if (obj.length > 255) {
$("#content_notice_span").text("内容过长超过255个字符");
$("#content_notice_span").css('color', '#ff0000');
$("#content_notice_span").focus();
return false;
}
else {
$("#content_notice_span").text("填写正确");
$("#content_notice_span").css('color', '#008000');
return true;
}
}
function submit_message()
{
if (system_message_length())
{
$("#system_message_form").submit();
}
} }
else if (obj.length > 255) {
$("#content_notice_span").text("内容过长超过255个字符");
$("#content_notice_span").css('color', '#ff0000');
$("#content_notice_span").focus();
return false;
}
else {
$("#content_notice_span").text("填写正确");
$("#content_notice_span").css('color', '#008000');
return true;
}
}
function submit_message() {
if (system_message_length()) {
$("#system_message-form").submit();
}
}
</script> </script>