64 lines
2.7 KiB
Plaintext
64 lines
2.7 KiB
Plaintext
<script>
|
|
var W3CDOM = document.createElement && document.getElementsByTagName;
|
|
|
|
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>
|
|
<% if jour.size > 0 %>
|
|
<ul class="message-for-user">
|
|
<% for journal in jour%>
|
|
<li id='word_li_<%= journal.id.to_s %>' class="outer-message-for-user">
|
|
<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>
|
|
<span class="font_lighter"><% label = l(:label_contest_requirement) %></span>
|
|
<div> <%= textilizable journal.notes%> </div>
|
|
<span class="font_lighter"><%= l(:label_bids_published) %>
|
|
<%= time_tag(journal.created_on).html_safe %>
|
|
<%= l(:label_bids_published_ago) %>
|
|
</span>
|
|
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
|
<span>
|
|
|
|
<% if journal.user==User.current|| User.current.admin? %>
|
|
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user},
|
|
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
|
|
<% end %>
|
|
</span>
|
|
</span>
|
|
<div style="clear: both;"></div>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
<% end %> |