讨论区帖子图片可点击

This commit is contained in:
cxt 2015-10-16 09:26:13 +08:00
parent 9a0c9ecc77
commit a16dc09afa
3 changed files with 26 additions and 6 deletions

View File

@ -71,7 +71,9 @@
$(function () {
init_activity_KindEditor_data(<%= topic.id%>, null, "87%");
var description_images=$("div#activity_description_<%= topic.id %>").find("img");
showNormalImage('activity_description_<%= topic.id %>');
//showNormalImage('reply_content_<%#= topic.id %>');
/*var description_images=$("div#activity_description_<%#= topic.id %>").find("img");
if (description_images.length>0) {
for (var i=0; i<description_images.length; i++){
var image=$(description_images[i]);
@ -79,9 +81,9 @@
image.wrap(element);
}
}
$('#activity_description_<%= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
$('#activity_description_<%#= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
var reply_images=$("div#reply_content_<%= topic.id %>").find("img");
var reply_images=$("div#reply_content_<%#= topic.id %>").find("img");
if (reply_images.length>0) {
for (var i=0; i<reply_images.length; i++){
var image=$(reply_images[i]);
@ -89,7 +91,7 @@
image.wrap(element);
}
}
$('#reply_content_<%= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
$('#reply_content_<%#= topic.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});*/
});
</script>
<% if topic %>

View File

@ -25,6 +25,8 @@
}
$(function() {
init_activity_KindEditor_data(<%= @topic.id%>,null,"85%");
/*showNormalImage('activity_description_<%#= topic.id %>');
showNormalImage('reply_content_<%#= topic.id %>');*/
});
</script>
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @topic.id%>').show();" onmouseout="$('#message_setting_<%= @topic.id%>').hide();">
@ -73,7 +75,7 @@
</div>
<div class="postDetailDate mb5"><%= format_time( @topic.created_on)%></div>
<div class="cl"></div>
<div class="memo-content upload_img break_word" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >
<div class="memo-content upload_img break_word" id="message_description_<%= @topic.id %>" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >
<%= @topic.content.html_safe%>
</div>
<div class="cl"></div>
@ -97,6 +99,7 @@
</div>
<div class="" id="reply_div_<%= @topic.id %>">
<% @replies.each_with_index do |reply,i| %>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id%>').hide();">
<div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
@ -109,7 +112,9 @@
<%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
<% end %>
</div>
<div class="homepagePostReplyContent upload_img break_word"><%= reply.content.html_safe%></div>
<div class="homepagePostReplyContent upload_img break_word" id="reply_message_description_<%= reply.id %>">
<%= reply.content.html_safe%>
</div>
<div style="margin-top: -7px; margin-bottom: 5px">
<%= format_time(reply.created_on) %>
<div class="fr" id="reply_edit_menu_<%= reply.id%>" style="display: none">

View File

@ -952,3 +952,16 @@ $(document).ready(function () {
$("pre").addClass("break_word");
}
});
//点击图片即显示大图
function showNormalImage(id) {
var description_images=$('div#'+id).find("img");
if (description_images.length>0) {
for (var i=0; i<description_images.length; i++){
var image=$(description_images[i]);
var element=$("<a></a>").attr("href",image.attr('src'));
image.wrap(element);
}
}
$('#'+id+' a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
}