$(function(){cateSort.init();}); var cateSort = { //apps : null, //lists : null, $cateNavList : null, $cateSortBtn : null, $cMainArticleArea : null, cateSortFixPos : null, $cateNav : null, cateNavNum : null, currentSortCate : "0_0", resetCate : true, scrollandLoding : true, $cArticleArea : null, cArticleAreaPos : null, //------------------------------------------------- // initialize //------------------------------------------------- init : function() { // add Article List cateSort.$cArticleArea = $(".c-article-area"); cateSort._onJsonLoaded(cateSort.currentSortCate); // onEnterFrame Action EnterFrameManager.add(cateSort.onEnterFrame); // start Category sort Nav cateSort._categorySortNav(); // cate sort nav fix cateSort.$cMainArticleArea = $(".c-main-article-area"); cateSort.$cateNav = $(".c-cate-nav"); cateSort.cateSortFixPos = cateSort.$cMainArticleArea.offset().top; }, //------------------------------------------------- // Category sort Nav //------------------------------------------------- _categorySortNav : function() { cateSort.$cateNavList = $(".c-cate-nav-list"); cateSort.$cateSortBtn = $(".cate-sort-btn"); cateSort.$cateNavList.addClass("c-cate-nav-anime"); var currentCateHeight; cateSort.$cateSortBtn.click(function(){ var currentCate = $(this).siblings(".cate-sort-btn"), currentCateCount = currentCate.length + 1; cateSort.cateNavNum = $(this).attr("date-cate"); currentCateHeight = currentCateCount * 36 + 23; // judgment reset category if(cateSort.currentSortCate == $(this).attr("date-sort-cate")){ cateSort.resetCate = true; } else { cateSort.resetCate = false; cateSort.scrollandLoding = false; cateSort.$cArticleArea.empty(); $("html, body").animate({scrollTop: cateSort.cateSortFixPos}, 600, "swing",function(){ cateSort.scrollandLoding = true; }); } cateSort.currentSortCate = $(this).attr("date-sort-cate"); cateSort.$cateSortBtn.removeClass("cate-active"); //$(this).addClass("cate-active"); if (cateSort.currentSortCate.match(/_0/i)) { $(this).addClass("cate-active"); } else { $(currentCate).eq(0).addClass("cate-active"); $(this).addClass("cate-active"); } // list height adjust cateSort.$cateNavList.css("height", "59px"); $(this).parent().parent(cateSort.$cateNavList).css("height", currentCateHeight + "px"); cateSort._onJsonLoaded(cateSort.currentSortCate); }); cateSort.$cateNavList.mouseenter(function(){ var listCount = $(this).find(cateSort.$cateSortBtn).length, listHeight = listCount * 36 + 23; $(this).css("height", listHeight + "px"); }) cateSort.$cateNavList.mouseleave(function(){ cateSort.$cateNavList.css("height", "59px"); cateSort.$cateNavList.eq(cateSort.cateNavNum-1).css("height", currentCateHeight + "px"); }); }, _onJsonLoaded : function(currentCategory) { var jsonURL = '/js/pc/article_data.php?w=&sp=22&c=' + currentCategory, showArticleNum = 12; var cateFlag = function(cate){ switch (cate){ case "PERSON": return 1; break; case "LIFESTYLE": return 2; break; case "UNIVERSITY": return 3; break; case "MONO": return 4; break; case "CREATION": return 5; break; case "EVENT": return 6; break; case "SOCIETY": return 7; break; case "JOB": return 8; break; case "PLACE": return 9; break; } } var addArticleGenerator = function(list){ cateSort.$cArticleArea.append(list); } $.ajax({ url: jsonURL, dataType: 'json', success : function(data){ var articleData = data["article"], articleLen = articleData.length, addArticleLen = $('.c-article-list').length, setAdj = (articleLen) - (addArticleLen), setBeg = (articleLen) - (setAdj), addArticleList = ""; if(showArticleNum > articleLen) { showArticleNum = articleLen; } if(!(articleLen == addArticleLen)){ if(addArticleLen == 0){ // 初期表示 for (var i = 0; i < showArticleNum; i++) { var category = articleData[i].category, cateNum = cateFlag(category); var articleList = [ '