var Search; $(document).ready(function () { var _grid = $('.newslist').imagesLoaded(function(){ _grid.masonry({ itemSelector:'.news-item', gutter:0, }); }); //分頁 var pageCode = 0; $(document).on('click','.pagebox .page',function(){ window.location.hash = $(this).attr("send"); }); function Search(){ var _str = ''; var data = []; var id = $('.tagItem[data-select="true"]').data('id'), filter = $('.tagItem[data-select="true"]').data('filter'), cid = $('#CID').val(), sid = $('#SID').val(), pid = $('#PID').val(); if(pageCode) data.push("page="+pageCode); if(id) data.push("id="+id); if(filter) data.push("filter="+filter); if(cid) data.push("cid="+cid); if(sid) data.push("sid="+sid); if(pid) data.push("pid="+pid); _str = data.join("&"); $.ajax({ url:'/include/ajax/ajax_aohuminews-waterwall.php', type:"POST", async:false, data:_str, dataType:'HTML', error:function(d){ alert(d.responseText); }, success:function(d){ $('#newslist').html(d); _grid = $('.newslist').imagesLoaded(function(){ _grid.masonry({ itemSelector:'.news-item', gutter:0, }); }); } }) } // if($('.tagItem[data-select="true"]').length>0){ // Search(); // } //手機版上下頁 $(document).on('click','#prev_page,#next_page',function(){ if($(this).attr("send")>0){ window.location.hash = $(this).attr("send"); $('html, body').animate({scrollTop: parseInt($("#newslist").offset().top)-80}, 500); } }); //分頁下拉選單 $(document).on('change','.page-select',function(){ window.location.hash = $(this).val(); $('html, body').animate({scrollTop: parseInt($("#newslist").offset().top)-80}, 500); }); //分頁錨點 if(parseInt(window.location.hash.replace('#',''))>0){ pageCode = parseInt(window.location.hash.replace('#','')); Search(); } window.onhashchange=function(){ pageCode = parseInt(window.location.hash.replace('#','')); if(pageCode > 0){ Search(); } } });