1 Thu gọn bài viết và chữ ký 20/4/2012, 8:54 pm
Founder
Admin
Chức năng của code này là thu gọn bài viết dài hơn 500px lại, đồng thời hiện một nút Chi tiết.
Khi click vào nút này thì bài viết sẽ hiển thị toàn bộ và nút bấm cũng mất đi.
Với chữ ký thì code sẽ ẩn phần chữ ký dài hơn 300px, khi rê chuột vào sẽ hiện kích thước thật, và trở lại kích thước thu gọn khi rê chuột ra ngoài.
Demo:
Khi click vào nút này thì bài viết sẽ hiển thị toàn bộ và nút bấm cũng mất đi.
Với chữ ký thì code sẽ ẩn phần chữ ký dài hơn 300px, khi rê chuột vào sẽ hiện kích thước thật, và trở lại kích thước thu gọn khi rê chuột ra ngoài.
Demo:
- Code:
http://www.www.fmvi.tk/t140-thu-gn-bai-vit-va-ch-ky#555
- Title: Thu gọn bài viết và chữ ký
- Placement: In the topics
- Javascript Code: Tuỳ theo phiên bản đang dùng để lấy code thích hợp
- phpBB2:
- Code:
$(function(){$("div.postbody div:not('.cont_code')").each(function(){var $baivietdai=$(this);if($(this).height()>500){$(this).css({'overflow':'hidden','max-height':'300px'});$('<br/><button style="float:right; padding:1px" class="baivietquadai"><img title="Xem bài viết chi tiết" src ="http://i48.servimg.com/u/f48/16/58/89/73/more10.gif" alf="chi tiết"/></button>').insertAfter(this);$('.baivietquadai').click(function(){$baivietdai.css({'overflow':'hidden','max-height':'100%'});$(this).remove()})}});$('div.signature_div').each(function(){if($(this).height()>350){$('div.signature_div img').css('max-width','600px');$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'});$(this).hover(function(){$(this).css({'overflow':'hidden','max-height':'100%','max-width':'100%'})},function(){$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'})})}})});
- phpBB3:
- Code:
$(function(){$("div.content").each(function(){var $baivietdai=$(this);if($(this).height()>500){$(this).css({'overflow':'hidden','max-height':'300px'});$('<br/><button style="float:right; padding:1px" class="baivietquadai"><img title="Xem bài viết chi tiết" src ="http://i48.servimg.com/u/f48/16/58/89/73/more10.gif" alf="chi tiết"/></button>').insertAfter(this);$('.baivietquadai').click(function(){$baivietdai.css({'overflow':'hidden','max-height':'100%'});$(this).remove()})}});$('div.signature_div').each(function(){if($(this).height()>350){$('div.signature_div img').css('max-width','600px');$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'});$(this).hover(function(){$(this).css({'overflow':'hidden','max-height':'100%','max-width':'100%'})},function(){$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'})})}})});
- punBB:
- Code:
$(function(){$("div.entry-content").each(function(){var $baivietdai=$(this);if($(this).height()>500){$(this).css({'overflow':'hidden','max-height':'300px'});$('<br/><button style="float:right; padding:1px" class="baivietquadai"><img title="Xem bài viết chi tiết" src ="http://i48.servimg.com/u/f48/16/58/89/73/more10.gif" alf="chi tiết"/></button>').insertAfter(this);$('.baivietquadai').click(function(){$baivietdai.css({'overflow':'hidden','max-height':'100%'});$(this).remove()})}});$('div.sig-content').each(function(){if($(this).height()>350){$('div.signature_div img').css('max-width','600px');$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'});$(this).hover(function(){$(this).css({'overflow':'hidden','max-height':'100%','max-width':'100%'})},function(){$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'})})}})});
- Invision:
- Code:
$(function(){$("div.post-entry").each(function(){var $baivietdai=$(this);if($(this).height()>500){$(this).css({'overflow':'hidden','max-height':'300px'});$('<br/><button style="float:right; padding:1px" class="baivietquadai"><img title="Xem bài viết chi tiết" src ="http://i48.servimg.com/u/f48/16/58/89/73/more10.gif" alf="chi tiết"/></button>').insertAfter(this);$('.baivietquadai').click(function(){$baivietdai.css({'overflow':'hidden','max-height':'100%'});$(this).remove()})}});$('div.signature_div').each(function(){if($(this).height()>350){$('div.signature_div img').css('max-width','600px');$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'});$(this).hover(function(){$(this).css({'overflow':'hidden','max-height':'100%','max-width':'100%'})},function(){$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'})})}})});
- Tùy chỉnh:
- Code:
$(function(){$(".noidungbaiviet").each(function(){var $baivietdai=$(this);if($(this).height()>500){$(this).css({'overflow':'hidden','max-height':'300px'});$('<br/><button style="float:right; padding:1px" class="baivietquadai"><img title="Xem bài viết chi tiết" src ="http://i48.servimg.com/u/f48/16/58/89/73/more10.gif" alf="chi tiết"/></button>').insertAfter(this);$('.baivietquadai').click(function(){$baivietdai.css({'overflow':'hidden','max-height':'100%'});$(this).remove()})}});$(".noidungchuky").each(function(){if($(this).height()>350){$('.noidungchuky img').css('max-width','600px');$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'});$(this).hover(function(){$(this).css({'overflow':'hidden','max-height':'100%','max-width':'100%'})},function(){$(this).css({'overflow':'hidden','max-height':'250px','max-width':'100%'})})}})});
ACP - Display - Templates - viewtopic_body: - phpBB2: Tìm trong viewtopic_body:
- Code:
{postrow.displayed.MESSAGE}
- Code:
<div class="noidungbaiviet">{postrow.displayed.MESSAGE}</div>
- Code:
{postrow.displayed.SIGNATURE}
- Code:
<div class="noidungchuky">{postrow.displayed.SIGNATURE}</div>
- punBB: Tìm trong viewtopic_body:
- Code:
{postrow.displayed.MESSAGE}
- Code:
<div class="noidungbaiviet">{postrow.displayed.MESSAGE}</div>
- Code:
{postrow.displayed.SIGNATURE_NEW}
- Code:
<div class="noidungchuky">{postrow.displayed.SIGNATURE_NEW}</div>
Viết bởi baivong - FMvi.tk