将内容省略显示的固定字数改为传参

This commit is contained in:
yuanke 2016-05-06 17:59:27 +08:00
parent d32e07bda9
commit 34ea7662b2
5 changed files with 7 additions and 7 deletions

View File

@ -42,7 +42,7 @@
<% else %> <% else %>
<% content = activity.parent.content %> <% content = activity.parent.content %>
<% end %> <% end %>
<p><%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54} %></p> <p><%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54, :maxwordsnum=>100} %></p>
</div> </div>
<div class="ml15 mt10"> <div class="ml15 mt10">
<span class="grayTxt">发帖时间:<%= format_time(activity.created_on) %></span> <span class="grayTxt">发帖时间:<%= format_time(activity.created_on) %></span>

View File

@ -30,7 +30,7 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div class="massages-content ml15"> <div class="massages-content ml15">
<p><%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>activity.description, :maxheight=>54} %></p> <p><%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>activity.description, :maxheight=>54, :maxwordsnum=>100} %></p>
</div> </div>
<div class="ml15 mt10"> <div class="ml15 mt10">
<span class="grayTxt">发布时间:<%= format_time(activity.created_on) %></span> <span class="grayTxt">发布时间:<%= format_time(activity.created_on) %></span>

View File

@ -12,6 +12,6 @@
$("#activity_description_<%= user_activity_id%>").css("max-height", heightType + "px"); $("#activity_description_<%= user_activity_id%>").css("max-height", heightType + "px");
} }
description_showwords_ellipsis(<%=user_activity_id %>); description_showwords_ellipsis(<%=user_activity_id %>,<%= maxwordsnum %>);
}); });
</script> </script>

View File

@ -42,7 +42,7 @@
<% else %> <% else %>
<% content = activity.parent.content %> <% content = activity.parent.content %>
<% end %> <% end %>
<p><%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54 } %></p> <p><%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54, :maxwordsnum=>100} %></p>
</div> </div>
<div class="ml15 mt10"> <div class="ml15 mt10">
<span class="grayTxt">发帖时间:<%= format_time(activity.created_on) %></span> <span class="grayTxt">发帖时间:<%= format_time(activity.created_on) %></span>

View File

@ -1240,7 +1240,7 @@ function expand_reply(container,btnid){
} }
//by yk 列表描述将文字和起来去掉空格多于100就显示省略号 //by yk 列表描述将文字和起来去掉空格多于100就显示省略号
function description_showwords_ellipsis(id){ function description_showwords_ellipsis(id,num){
var str = ""; var str = "";
$("#intro_content_"+id).each(function () { $("#intro_content_"+id).each(function () {
str = str + $(this).text(); str = str + $(this).text();
@ -1249,8 +1249,8 @@ function description_showwords_ellipsis(id){
//去掉空格 //去掉空格
str = str.replace(/\s/gi,''); str = str.replace(/\s/gi,'');
if(str.length > 100){ if(str.length > num){
str = str.substring(0,100)+"..."; str = str.substring(0,num)+"...";
} }
$("#intro_content_"+id).html(str); $("#intro_content_"+id).html(str);