socialforge/app/views/words/_message.html.erb

79 lines
3.0 KiB
Plaintext
Raw Normal View History

2013-12-28 13:16:22 +08:00
<script>
var W3CDOM = document.createElement && document.getElementsByTagName;
2013-12-25 21:00:40 +08:00
2013-12-28 13:16:22 +08:00
window.onload = setMaxLength;
function setMaxLength() {
if (!W3CDOM) return;
var textareas = document.getElementsByTagName('textarea');
for (var i=0;i<textareas.length;i++) {
var textarea = textareas[i];
setMaxLengthItem(textareas[i]);
}
}
function setMaxLengthItem(textarea){
if (textarea.getAttribute('maxlength')) {
var counter = document.createElement('div');
counter.className = 'counter';
var counterClone = counter.cloneNode(true);
counterClone.innerHTML = '<span>0</span>/'+textarea.getAttribute('maxlength');
textarea.parentNode.insertBefore(counterClone,textarea.nextSibling);
textarea.relatedElement = counterClone.getElementsByTagName('span')[0];
textarea.onkeyup = textarea.onchange = checkMaxLength;
textarea.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>
2014-01-06 21:11:20 +08:00
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
2013-08-01 10:33:49 +08:00
<% if jour.size >0 %>
<% remove_allowed = (User.current.id == jour.first.user_id) %>
2013-12-25 21:00:40 +08:00
<ul class="message-for-user">
<% for journal in jour%>
2013-12-26 19:28:18 +08:00
<li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user">
2013-12-25 15:45:14 +08:00
<span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span>
<span class="body">
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
2013-12-26 15:32:34 +08:00
<p>
2013-12-25 15:45:14 +08:00
<%= textilizable journal.notes%>
2013-12-26 15:32:34 +08:00
</p>
2013-12-25 15:45:14 +08:00
<span class="font_lighter"> <%= l :label_comment_time %>&nbsp; <%= format_time journal.created_on %></span>
<% ids = 'project_respond_form_'+ journal.id.to_s%>
<span>
2014-01-06 21:11:20 +08:00
<% if reply_allow %>
<%= link_to l(:label_projects_feedback_respond),'',
2014-03-13 22:06:49 +08:00
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"}
%>
<% end %>
2013-12-26 20:22:19 +08:00
<% if @user == User.current || User.current.admin? || journal.user.id == User.current.id %>
<%= link_to(l(:label_newfeedback_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user},
2013-12-26 20:22:19 +08:00
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
<% end %>
</span>
2013-12-25 15:45:14 +08:00
</span>
<div style="clear: both;"></div>
2013-12-26 19:28:18 +08:00
<div id='<%= ids %>' class="respond-form">
2014-01-06 21:11:20 +08:00
<% if reply_allow %>
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
2014-01-06 21:11:20 +08:00
<% end %>
</div>
<div style="clear: both;"></div>
<div>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
</div>
</li>
<% end %>
2013-12-25 15:45:14 +08:00
</ul>
2013-08-01 10:33:49 +08:00
<% end %>