List & Grid Post Display
Membuat tampilan artikel berbentuk daftar atau grid berdasarkan tombol perintah dengan jQuery Masonry sebagai pembangun grid dan bantuan JavaScript Cookie sebagai pengingat sesi:
HTML
<nav id="view">
<a href="#" class="grid">Grid</a>
<a href="#" class="list">List</a>
</nav>
<div id="main">
<article> ... </article>
<article> ... </article>
<article> ... </article>
<article> ... </article>
</div>
CSS
#view {
display:block;
width:95%;
margin:10px auto;
}
#view a {
display:inline-block;
background-color:darkblue;
padding:2px 7px;
text-decoration:none;
color:white;
}
#view a.active {background-color:darkred}
#main {
width:98%;
margin:10px auto;
}
article {
display:block;
background-color:black;
font:normal 11px Arial,Sans-Serif;
color:white;
padding:10px 15px;
margin:0 10px 10px;
}
/* Grid mode */
article.grid {
float:left;
width:100px;
}
jQuery
(function() {
var $container = $('#main'),
$article = $container.find('article'),
$gridNav = $('#view .grid'),
$listNav = $('#view .list');
// Functions...
function gridMode() {
$article.addClass('grid');
$gridNav.addClass('active');
$listNav.removeClass('active');
$container.masonry({
itemSelector: ".grid",
isAnimated: true,
isFitWidth: true
});
createCookie('grid', null, 7000);
return false;
}
function listMode() {
$article.removeClass('grid');
$gridNav.removeClass('active');
$listNav.addClass('active');
$container.masonry("destroy");
eraseCookie('grid');
return false;
}
// Initialize...
// If the `grid` cookie reads
if (readCookie('grid')) {
gridMode();
eraseCookie('grid');
} else {
listMode();
}
// By user...
$listNav.click(listMode);
$gridNav.click(gridMode);
})();
Eksternal
Labels: Blogger, JavaScript, jQuery, Lanjutan, Potongan
20 Comments:
ehh keknya ini cocok untuk arsips
.
ehh klo masang gituan untuk post... itu pke rss atau tidak?
By abang ichal, at Wednesday, August 29, 2012 at 1:08:00 PM GMT+7
Tergantung kreativitas. Mengingat dalam kerangka kolom artikel Blogger umumnya terdiri dari kode ini...
<div id="main">
<div class="post hentry"> ... </div>
<div class="post hentry"> ... </div>
<div class="post hentry"> ... </div>
</div>
Jadi kodenya harus dimodifikasi agar bisa diterapkan pada template:
var $container = $('#main'),
$article = $container.find('.post');
.post.grid {
float:left;
width:200px;
}
By Taufik Nurrohman, at Wednesday, August 29, 2012 at 4:56:00 PM GMT+7
wah sangat bergunanih..
makasih mas.. :-bd
By Unknown, at Thursday, August 30, 2012 at 7:25:00 AM GMT+7
MAs, kalo yang gridnya muncul gambar gimana caranya ??
By Arif Rahman, at Saturday, September 1, 2012 at 10:35:00 AM GMT+7
Pelajari ini: http://jsfiddle.net/tovic/7PaAY/8/embedded/result,resources,js,html,css/
By Taufik Nurrohman, at Saturday, September 1, 2012 at 6:02:00 PM GMT+7
ini yang saya cari mas, ketemu disini.. thanks mas taufik.. salam kenal
By Son Goku, at Saturday, September 15, 2012 at 2:52:00 PM GMT+7
wah dicari-cari mutar di google malah ada didekat sini...
thanks mas taufik...
By Anonymous, at Monday, October 1, 2012 at 12:04:00 AM GMT+7
maaf mas untuk implementasinya di blogger gimana ya??
satu lagi nih mas, tapi maaf keluar jari pembahasan, kalo mau bikin postnya cuma tampil gambarnya aja tanpa snippet gitu gimana mas?? :-)
By Unknown, at Sunday, December 2, 2012 at 5:04:00 AM GMT+7
mas gimana tutorial detail nya hehe maklum mas Masih baru didunia bloging :p
By Aji Abdul Sajid, at Sunday, January 27, 2013 at 5:59:00 PM GMT+7
⇒ http://www.google.com/search?q=membuat+list+%26+grid+post+display+pada+blogspot
By Taufik Nurrohman, at Sunday, January 27, 2013 at 6:31:00 PM GMT+7
Mas saya mau tanya dong.
kalau tampilan defaultnya itu yang list, bukan grid bisa gak ?
Mohon jawabannya ya
By Fajri Alhadi, at Wednesday, October 9, 2013 at 5:16:00 PM GMT+7
Mas tampilan blog aku kan list, bisa gak diubah jadi grid.
By Arbi, at Sunday, October 20, 2013 at 6:13:00 PM GMT+7
gmana kalo list seperti yang ada pada blog [url=http://manga.wardhanime.net/]AW Manga[/url]? bagaimana kalo yang begitu?
By Anonymous, at Saturday, November 2, 2013 at 10:29:00 PM GMT+7
kok post ditemplate saya ketindis ya pas klik menu grid
By Unknown, at Thursday, April 24, 2014 at 7:58:00 PM GMT+7
Kalau tidak ada screenshot bagaimana Saya bisa tahu masalahnya?
By Taufik Nurrohman, at Saturday, April 26, 2014 at 7:05:00 AM GMT+7
nyimak dulu kang taufik. terima kasih :)
By Kang Rian, at Wednesday, June 11, 2014 at 5:13:00 PM GMT+7
saya coba dulu pak, terima kasih ..
By Kang Rian, at Friday, June 13, 2014 at 3:42:00 PM GMT+7
mas, cara merubah default tampilan grid menjadi list mode gimana ya?
By Dika Ramadanu, at Thursday, July 2, 2015 at 11:08:00 AM GMT+7
Coba ini: https://jsfiddle.net/tovic/7PaAY/30
By Taufik Nurrohman, at Saturday, July 11, 2015 at 12:13:00 PM GMT+7
Eh, pertanyaanmu kebalik ya?
By Taufik Nurrohman, at Saturday, July 11, 2015 at 12:14:00 PM GMT+7
Post a Comment
<< Home