/* * Name: KEPCO * Part: JavaScript for ui & plug-in * Author : pk.choi */ (function($){ // jQuery.noConfict(); $(document).ready(function() { /* * Part: 갤러리미리보기 썸네일 슬라이드 * Function: * 이전/다음 버튼 클릭시 5개씩 좌우 슬라이드(마지막 썸네일까지 보여지면 더이상 스크롤되지않음) * 썸네일 클릭시 페이지 새로고침 -> 상단 해당 상세 이미지 변경, 클릭했던 썸네일 활성화 * 클릭한 썸네일은 활성화처리(제목태그 비활성화 - span태그가 있는것이 디폴트) * 초기에 페이지에서 전체썸네일수를 변수로 받아 참조한다. */ //테스트용 json data var jsondata = {"data":[ {"a_href":"http://www.naver.com","img_src":"/front/img/temp/sample1.jpg","img_alt":"sample1의 대체텍스트"}, {"a_href":"http://www.nate.com","img_src":"/front/img/temp/sample2.jpg","img_alt":"sample2의 대체텍스트"}, {"a_href":"http://www.daum.net","img_src":"/front/img/temp/sample3.jpg","img_alt":"sample3의 대체텍스트"}, {"a_href":"http://dbcut.com","img_src":"/front/img/temp/sample4.jpg","img_alt":"sample4의 대체텍스트"}, {"a_href":"http://www.nate.com","img_src":"/front/img/temp/sample5.jpg","img_alt":"sample5의 대체텍스트"}, {"a_href":"http://www.daum.net","img_src":"/front/img/temp/sample6.jpg","img_alt":"sample6의 대체텍스트"}, {"a_href":"http://www.naver.com","img_src":"/front/img/temp/sample7.jpg","img_alt":"sample7의 대체텍스트"}, {"a_href":"http://www.daum.net","img_src":"/front/img/temp/sample8.jpg","img_alt":"sample8의 대체텍스트"}, {"a_href":"http://www.naver.com","img_src":"/front/img/temp/sample1.jpg","img_alt":"sample9의 대체텍스트"}, {"a_href":"http://www.nate.com","img_src":"/front/img/temp/sample2.jpg","img_alt":"sample10의 대체텍스트"}, {"a_href":"http://www.daum.net","img_src":"/front/img/temp/sample3.jpg","img_alt":"sample11의 대체텍스트"}, {"a_href":"http://dbcut.com","img_src":"/front/img/temp/sample4.jpg","img_alt":"sample12의 대체텍스트"}, {"a_href":"http://www.nate.com","img_src":"/front/img/temp/sample5.jpg","img_alt":"sample13의 대체텍스트"}, {"a_href":"http://www.daum.net","img_src":"/front/img/temp/sample6.jpg","img_alt":"sample14의 대체텍스트"}, {"a_href":"http://www.naver.com","img_src":"/front/img/temp/sample7.jpg","img_alt":"sample15의 대체텍스트"}, {"a_href":"http://www.daum.net","img_src":"/front/img/temp/sample8.jpg","img_alt":"sample16의 대체텍스트"} ]} // alert(jsondata.data[0].img_src); var $gal_list = $('.gallery_box .gallery_list'); var thumbs_page = 5; //한화면에서 보이는 최대 썸네일갯수 // var total = totalThumbs; //개발단에서 썸네일의 총갯수를 받아온다 // var total = jsondata.data.length; //개발단에서 썸네일의 총갯수를 받아온다 var total = $("#totalCnt").val(); //썸네일의 총갯수 var nCurrentTmbIndex = eval($("#currentThumb").val() - 1); //현재 활성화 썸네일인덱스 ------------------------------ 인덱스가 1부터 시작하면 -1 해준다. //현재페이지 인덱스 var nCurrentPageIndex = Math.floor(nCurrentTmbIndex/thumbs_page); //총페이지수 var nPageLength = Math.ceil(total/thumbs_page); var doms = new Array(nPageLength); doms[nCurrentPageIndex] = $gal_list; var dist = 165; //이동할 간격 var SPEED = 600; var animating = false; var EASING_ANIMATE = "easeInOutCubic"; //현재썸네일 초기 활성화 $gal_list.children().eq(nCurrentTmbIndex%thumbs_page).addClass('on'); //이전버튼 클릭 $('.gallery_perv_box a.ico_prev').bind('click', function () { if(!animating) { animating = true; prevPage(); } return false; }); //다음버튼 클릭 $('.gallery_perv_box a.ico_next').bind('click', function () { if(!animating) { animating = true; nextPage(); } return false; }); //썸네일 롤오버/아웃/클릭 $(this).on('mouseenter', '.gallery_box .gallery_list li a', function (event) { $(this).parent().css({"height":"100%", "background":"#000"}); $(this).find('img').css({"opacity":"0.5"}); }); $(this).on('mouseleave', '.gallery_box .gallery_list li a', function (event) { $(this).parent().css({"background":"none"}); $(this).find('img').css({"opacity":"1"}); }); //이전페이지 function prevPage(){ if(nCurrentPageIndex == 0){ alert('처음 입니다.'); animating = false; return false; }else{ if(nCurrentPageIndex < 0) nCurrentPageIndex = 0; //이전에 보여질 썸네일들이 이전에 생성되지 않았다면 생성한 뒤 스크롤 애니메이션 실행 //생성되었다면 바로 스크롤 애니메이션 실행 if(doms[nCurrentPageIndex-1] == undefined){ $('.gallery_box').prepend('