// 포토갤러리 추출 커스터마이징
$(function() {
var tmpno = $(location).attr('pathname').split('/')[1]; tmpno = '';
var dir = $(".section2_1 .listWrapper").data('dir');
var page = $(".section2_1 .listWrapper").data('page');
var elem;
var photoAll = $(".section2_1 .listWrapper .tableArea").html();
var subject = new Array(); // 갤러리 썸네일 제목 배열변수 선언
var content = new Array(); // 갤러리 썸네일 내용 배열변수 선언
var content2 = new Array(); // 갤러리 썸네일 내용 배열변수 선언
var url = new Array(); // 각 썸네일별 링크 저장용 변수
var thumbCount; // 썸네일 개수 (추출개수)
var refHeight; // 높이 동기화를 위한 변수
// 포토갤러리 카테고리 가져오기
function getCategory() {
if($(".section2_1 .tableArea li").length > 0) {
$("#cate-load").attr('src', tmpno + dir + page);
$("#cate-load").load(function() {
var title = [],
cate_no = [],
bo_table = [],
cateHTML;
$(".section2_1 .category").remove();
cateHTML = '
';
var cate = [{'title':'고객사','bo_table':'client'},{'title':'협력사','bo_table':'cowork'}];
//cate = JSON.parse(cate);
//$("#cate-load").contents().find('.board_tab li').each(function(i) {
$.each(cate,function(i,ct) {
//title[i] = $(this).text();
//cate_no[i] = $(this).text();
title[i] = ct['title'];
cate_no[i] = ct['title'];
bo_table[i] = ct['bo_table'];
/*cate_no[i] = $(this).val();*/
cateHTML += '- ' + title[i] + '
';
i++;
});
cateHTML += '
';
$(".section2_1 .dropdown").append(cateHTML);
$(".section2_1 .dropdown .category > li:first").addClass('on');
if($(".section2_1 .tableArea li").length > 0) {
/*$(".category > li:first > a").remove(cate_no[i]);*/
//$(".category").find('li:first').html('전체');
};
$("#cate-load").remove();
});
/*$(function(){
$(".category > li:first > a").addClass("test");
});*/
/*
$("#cate-load").load('/' + tmpno + '/' + dir + '/' + page + '.php' + ' .cate_select select', function() {
var title = [],
cate_no = [],
cateHTML;
$(".section2_1 .category").remove();
cateHTML = '';
$("#cate-load").find('option').each(function(i) {
title[i] = $(this).text();
cate_no[i] = $(this).val();
cateHTML += '- ' + title[i] + '
';
i++;
});
cateHTML += '
';
$(".section2_1 .dropdown").append(cateHTML);
$(".section2_1 .dropdown .category > li:first").addClass('on');
});
*/
/*
$.ajax({
type: 'GET',
url: '/' + tmpno + '/' + dir + '/' + page + '.php',
contentType: 'application/x-www-form-urlencoded;charset=euc-kr',
beforeSend: function(x) {
x.overrideMimeType('application/x-www-form-urlencoded;charset=euc-kr');
},
success: function(data) {
var title = [],
cate_no = [],
cateHTML;
$(".section2_1 .category").remove();
cateHTML = '';
$(data).find('.cate_select option').each(function(i) {
title[i] = $(this).text();
cate_no[i] = $(this).val();
cateHTML += '- ' + title[i] + '
';
i++;
});
cateHTML += '
';
$(".section2_1 .dropdown").append(cateHTML);
$(".section2_1 .dropdown .category > li:first").addClass('on');
},
error:function(xhr,status,error) {
console.log(error);
}
});
*/
}
}
//getCategory();
// 카테고리별 포스팅 추출 함수
function getPhotoPost(cate, bo_table) {
console.log(tmpno);
var loadURL;
// var maxCount = 4; // 카테고리별로 가져올 최대 포스팅 개수
if(cate === null) {
loadURL = tmpno + dir + page;
} else {
//loadURL = tmpno + dir + page + '?&sca=' + cate;
loadURL = tmpno + dir + bo_table;
}
var more_url = tmpno + dir + (bo_table == 'client' ? 'portfolio' : bo_table);
$('.section3_more > a').attr('href', more_url);
$.ajax({
type: 'GET',
url: loadURL,
contentType: '',
beforeSend: function(x) {
x.overrideMimeType('');
},
success: function(data) {
var temp = $(data).find('.'+bo_table+'-list').html();
$(".section2_1 .listWrapper .tableArea").html(temp);
// $(".section2_1 .listWrapper .tableArea > table").each(function() {
// if($(this).index() > maxCount -1) $(this).remove();
// });
galleryAlign();
elem = $(".section2_1 .listWrapper .tableArea li");
elem.find('.gall_name').remove();
elem.css('opacity','0');
elem.animate({'opacity':'1'}, 400, function() {
elem.css({'opacity':''});
});
},
error:function(xhr,status,error) {
console.log(error);
}
})
}
// 카테고리별 포스팅 추출
$(document).on('click', '.section2_1 .category > li' ,function() {
var $cate = $(this).find('a').data('cate');
var $activeText = $(this).find('a').text();
var $bo_table = $(this).find('a').data('bo_table');
// var maxCount = 4; // 카테고리별로 가져올 최대 포스팅 개수
$(".section2_1 .category > li").removeClass('on');
$(this).addClass('on');
if(!$cate) {
$(".section2_1 .listWrapper .tableArea").css('opacity','0');
$(".section2_1 .listWrapper .tableArea").html(photoAll);
// $(".section2_1 .listWrapper .tableArea > table").each(function() {
// if($(this).index() > maxCount) $(this).remove();
// });
$(".section2_1 .listWrapper .tableArea").animate({'opacity':'1'}, 400, function() {
$(".section2_1 .listWrapper .tableArea").css({'opacity':''});
});
galleryInit();
} else {
getPhotoPost($cate, $bo_table);
}
$(".section2_1 .dropdown > a").text($activeText);
});
// 최근 갤러리 드롭다운 이벤트
$(".section2_1 .dropdown").click(function() {
if(!$(this).hasClass('open')) {
$(this).addClass('open');
$(this).find('.category').css('display','block');
} else {
$(this).removeClass('open');
$(this).find('.category').css('display','none');
}
});
// 갤러리 초기세팅
function galleryInit() {
elem = $(".section2_1 .listWrapper .tableArea li");
if(elem.length > 0) {
thumbCount = elem.length;
if($(".hoverBox").length > 0) {
$(".hoverBox").parent('a').remove();
}
for(i=0; i' + subject[i] + '
' + $.trim(content[i]) + '
' + $.trim(content2[i]) + '
');
//$(".section2_1 .listWrapper .tableArea li").eq(i).find('tr').eq(1).css('display','none');
}
}
}
// 카테고리 클릭 후 구조 재정렬
function galleryAlign() {
if($(".bbsnewf5").length > 0) {
thumbCount = $(".section2_1 .listWrapper .tableArea .bbsnewf5").length;
if($(".hoverBox").length > 0) {
$(".hoverBox").parent('a').remove();
}
for(i=0; i' + subject[i] + '
' + $.trim(content[i]) + '
' + $.trim(content2[i]) + '
');
}
// 기존에 보여지는 별도 td 의 제목, 내용은 숨김
$(".infoArea").css('display','none');
}
}
// 테이블 애니메이션
function tableShow() {
if($(".section2_1 .listWrapper").length > 0) {
$(".section2_1 .listWrapper .tableArea li").each(function() {
$(this).addClass('scrollreveal');
});
}
}
galleryInit();
$(".section2_1 .listWrapper .tableArea li").addClass('scrollreveal');
});