留言增加字数限制
This commit is contained in:
parent
c3cbf87b3d
commit
398e35cf19
|
@ -1,5 +1,42 @@
|
|||
<script>
|
||||
var W3CDOM = document.createElement && document.getElementsByTagName;
|
||||
|
||||
window.onload = setMaxLength;
|
||||
|
||||
function setMaxLength() {
|
||||
if (!W3CDOM) return;
|
||||
var textareas = document.getElementsByTagName('textarea');
|
||||
var counter = document.createElement('div');
|
||||
counter.className = 'counter';
|
||||
for (var i=0;i<textareas.length;i++) {
|
||||
if (textareas[i].getAttribute('maxlength')) {
|
||||
var counterClone = counter.cloneNode(true);
|
||||
counterClone.innerHTML = '<span>0</span>/'+textareas[i].getAttribute('maxlength');
|
||||
textareas[i].parentNode.insertBefore(counterClone,textareas[i].nextSibling);
|
||||
textareas[i].relatedElement = counterClone.getElementsByTagName('span')[0];
|
||||
textareas[i].onkeyup = textareas[i].onchange = checkMaxLength;
|
||||
textareas[i].onkeyup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkMaxLength() {
|
||||
var maxLength = this.getAttribute('maxlength');
|
||||
var currentLength = this.value.length;
|
||||
if (currentLength > maxLength)
|
||||
this.relatedElement.className = 'toomuch';
|
||||
else
|
||||
this.relatedElement.className = '';
|
||||
this.relatedElement.firstChild.nodeValue = currentLength;
|
||||
}
|
||||
|
||||
</script>
|
||||
<%= form_tag({:controller => 'projects', :action => 'project_respond'}) do %>
|
||||
<%= text_area_tag 'project_respond', "", :class => 'noline', :required => true, :style => "resize: none;", :rows => 6, :placeholder => l(:label_projects_feedback_respond_content) %>
|
||||
<%= text_area_tag 'project_respond', "",
|
||||
:class => 'noline', :required => true,
|
||||
:style => "resize: none;", :rows => 6,
|
||||
:placeholder => l(:label_projects_feedback_respond_content),
|
||||
:maxlength => 250 %>
|
||||
|
||||
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %>
|
||||
<%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "bid_btn"%>
|
||||
|
|
|
@ -75,6 +75,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
$(function(){
|
||||
$("a").attr("target", "_blank");
|
||||
});
|
||||
|
||||
function showInfo(id, content) {
|
||||
var text = $('#' + id);
|
||||
if (text.val() == '') {
|
||||
|
@ -90,10 +94,10 @@
|
|||
</style>
|
||||
|
||||
<%= stylesheet_link_tag 'welcome' %>
|
||||
<div class="body_resize">
|
||||
|
||||
<div class="left" style="float: left; height: 445px; width: 50%; margin-left: 30px;">
|
||||
<ul class="welcome-message-list" style="width: 90%; ">
|
||||
|
||||
<div class="left" style="float: left; min-height: 470px; width: 48%;">
|
||||
<ul class="welcome-message-list">
|
||||
<div class="forum-topic" style="height: 25px;">
|
||||
<h3 style="color: rgb(21, 188, 207);margin-left: 8px;"><strong>贴吧动态</strong></h3>
|
||||
|
||||
|
@ -108,7 +112,7 @@
|
|||
<%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url, :class => "gray" , :style => "font-size: 10pt !important;", :target => "_blank" %>
|
||||
</span>
|
||||
<br>
|
||||
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;"><%=time_tag_welcome(topic_last_time topic)%>前</span>
|
||||
<span style="margin-left: 24px; color: rgb(172, 174, 177); white-space: nowrap; font-size: 9pt !important;;"><%= l(:field_updated_on) %><%=time_tag_welcome(topic_last_time topic)%>前</span>
|
||||
<span style="margin-left: 8px; margin-bottom: 0px; color: rgb(172, 174, 177) !important; white-space: nowrap;">
|
||||
由 <%= link_to topic.author ? topic.author : 'Anonymous', user_path(topic.author_id), :style => "font-size: 9pt !important; color: rgb(17, 102, 173);", :target => "_blank" %> 发表
|
||||
</span>
|
||||
|
@ -120,8 +124,8 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="right" style="float: right; margin-right: 10px; height: 445px; width: 45%; ">
|
||||
<ul class="user-welcome-message-list" style="width: 94%; margin-top: 0px;">
|
||||
<div class="right" style="float: right; min-height: 470px; width: 48%; ">
|
||||
<ul class="user-welcome-message-list">
|
||||
<h3 style="margin-left: -5px; color: rgb(21, 188, 207)"><strong>用户动态</strong></h3>
|
||||
<span style="margin-top: -30px;float: right; display: block;"><%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %></span>
|
||||
<div class="user-message-box-list">
|
||||
|
@ -139,7 +143,7 @@
|
|||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
|
||||
<h3 style="margin-left: 5px; color: #e8770d;"><strong>热门项目</strong></h3>
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
<span class="portrait">
|
||||
<%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %>
|
||||
</span>
|
||||
<div class="body">
|
||||
<div class="message-body">
|
||||
<% id = 'project_respond_form_'+ reply.id.to_s %>
|
||||
<p>
|
||||
<span><%= link_to reply.user.name, user_path(reply.user) %>: </span>
|
||||
<span class="message-notes"> <%= reply.notes %></span>
|
||||
</p>
|
||||
<%# ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
<div id='<%= ids %>' class="respond-form">
|
||||
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal.id} %>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
<div>
|
||||
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,45 @@
|
|||
<script>
|
||||
var W3CDOM = document.createElement && document.getElementsByTagName;
|
||||
|
||||
window.onload = setMaxLength;
|
||||
|
||||
function setMaxLength() {
|
||||
if (!W3CDOM) return;
|
||||
var textareas = document.getElementsByTagName('textarea');
|
||||
var counter = document.createElement('div');
|
||||
counter.className = 'counter';
|
||||
for (var i=0;i<textareas.length;i++) {
|
||||
if (textareas[i].getAttribute('maxlength')) {
|
||||
var counterClone = counter.cloneNode(true);
|
||||
counterClone.innerHTML = '<span>0</span>/'+textareas[i].getAttribute('maxlength');
|
||||
textareas[i].parentNode.insertBefore(counterClone,textareas[i].nextSibling);
|
||||
textareas[i].relatedElement = counterClone.getElementsByTagName('span')[0];
|
||||
textareas[i].onkeyup = textareas[i].onchange = checkMaxLength;
|
||||
textareas[i].onkeyup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkMaxLength() {
|
||||
var maxLength = this.getAttribute('maxlength');
|
||||
var currentLength = this.value.length;
|
||||
if (currentLength > maxLength)
|
||||
this.relatedElement.className = 'toomuch';
|
||||
else
|
||||
this.relatedElement.className = '';
|
||||
this.relatedElement.firstChild.nodeValue = currentLength;
|
||||
}
|
||||
|
||||
</script>
|
||||
<%= form_tag({:controller => 'words', :action => 'create_reply'}, :remote => true) do %>
|
||||
<%= text_area_tag 'user_notes', "", :class => 'noline', :style => "resize: none;", :rows => 4, :placeholder => l(:label_projects_feedback_respond_content) %>
|
||||
<%= text_area_tag 'user_notes', "", :class => 'noline',
|
||||
:style => "resize: none;", :rows => 4,
|
||||
:placeholder => l(:label_projects_feedback_respond_content),
|
||||
:maxlength => 250 %>
|
||||
|
||||
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %>
|
||||
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => journal.user.id %>
|
||||
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id %>
|
||||
<%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "enterprise", :style => "margin-top: 1px;"%>
|
||||
<%= submit_tag l(:button_projects_feedback_respond), :name => nil , :class => "enterprise", :style => "float: right; margin-top: 1px; margin-right: 4px;"%>
|
||||
|
||||
<% end %>
|
|
@ -2134,10 +2134,20 @@ ul.messages-for-user-reply li {
|
|||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.body p {
|
||||
.message-body p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-top: 4px;
|
||||
margin-left: 4px;
|
||||
font-size: 9pt;
|
||||
}
|
||||
|
||||
.message-body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-left: 40px;
|
||||
}
|
||||
|
||||
.counter {
|
||||
float: left;
|
||||
}
|
Loading…
Reference in New Issue