/*********************************************************************************************************
## Sub Script ##
* º» ½ºÅ©¸³Æ®ÀÇ ÀúÀÛ±ÇÀº (ÁÖ)À¥½º¸®ÆÛºí¸¯¿¡ ÀÖ½À´Ï´Ù.
* º» ½ºÅ©¸³Æ®¸¦ ¹«´ÜÀ¸·Î ÀÌ¿ë(¶Ç´Â µµ¿ë)Çϰųª º¹Á¦ ¶Ç´Â ¼öÁ¤ »ç¿ë½Ã ÀúÀ۱ǹý¿¡ ÀǰŠó¹ú¹ÞÀ» ¼ö ÀÖ½À´Ï´Ù.
* ±¸¸Å ÈÄ¿¡µµ Á¦ 2Â÷ »çÀÌÆ® µî ¶óÀ̼±½º°¡ Àû¿ëµÇÁö ¾Ê´Â »çÀÌÆ®¿¡ ´ëÇÏ¿© »ç¿ëÀº ±ÝÁöµÇ¾î ÀÖ½À´Ï´Ù.
* À§ »çÇ׿¡ ´ëÇÏ¿© À§¹Ý½Ã Àý´ë ÇÕÀÇ´Â ¾ø½À´Ï´Ù !
* date : 2017-03-15
* author : Park Soo Hyun (shpark7502@naver.com)
*********************************************************************************************************/
// ÆĶó¸ÞÅÍ °ª °¡Á®¿À±â
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = decodeURIComponent(window.location.search.substring(1))
, sURLVariables = sPageURL.split('&')
, sParameterName
, i;
for(i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if(sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : sParameterName[1];
}
}
};
// ¼ºêÆäÀÌÁö °øÅë ÇÔ¼ö
$(function() {
var $container = $("#container");
// ¼ºê ºñÁÖ¾ó À̹ÌÁö ÆäÀÌµå º¯¼ö Á¤ÀÇ
var $slides = $("#sub_visual > ul > li");
var $sIndex = 0;
var $stayTime = 4;
var $slideTime = 1.3;
// 1Â÷ µå·Ó´Ù¿î ¸Þ´º ÀÚµ¿ »ý¼º
function majorCreate() {
var $d1url = [];
var $d1title = [];
var $d1html;
var i = 0;
$("#gnb > li")
.each(function() {
$d1url[i] = $(this)
.children('a')
.attr('href');
$d1title[i] = $(this)
.children('a')
.text();
i++;
});
for(n = 0; n < i; n++) {
$d1html = '
' + $d1title[n] + '';
$("#nav .depth1 .mnuList")
.append($d1html);
}
}
majorCreate();
// 2Â÷ µå·Ó´Ù¿î ¸Þ´º ÀÚµ¿ »ý¼º
function minorCreate() {
var $d2url = [];
var $d2title = [];
var $d2html;
var $currIndex = 0;
if($container.data('menu-special')) {
$currIndex = $container.data('menu-special') - 1;
} else {
$currIndex = getUrlParameter('top') - 1;
}
var i = 0;
$("#gnb ul.sub")
.each(function() {
if($(this)
.parent()
.index() == $currIndex) {
for(i = 0; i < $(this)
.children()
.length; i++) {
$d2url[i] = $(this)
.children()
.eq(i)
.find('a')
.attr('href');
$d2title[i] = $(this)
.children()
.eq(i)
.find('a')
.text();
}
}
});
for(n = 0; n < i; n++) {
$d2html = '' + $d2title[n] + '';
$("#nav .depth2 .mnuList")
.append($d2html);
}
}
minorCreate();
// 1Â÷ µå·Ó´Ù¿î ¸Þ´º È°¼ºÈ
function majorActive() {
var currIndex = 0;
if($container.data('menu-special')) {
currIndex = $container.data('menu-special') - 1;
} else {
currIndex = getUrlParameter('top') - 1;
}
var currMenu = $("#nav .depth1 ul.mnuList li")
.eq(currIndex)
.text();
$("#nav .depth1 > a > span")
.text(currMenu);
}
// 2Â÷ µå·Ó´Ù¿î ¸Þ´º È°¼ºÈ
function minorActive() {
var currIndex = 0;
if($container.data('sub-special')) {
currIndex = $container.data('sub-special') - 1;
} else {
currIndex = getUrlParameter('sub') - 1;
}
var currMenu = $("#nav .depth2 ul.mnuList li")
.eq(currIndex)
.text();
$("#nav .depth2 > a > span")
.text(currMenu);
}
// ¼ºê ºñÁÖ¾ó ÅؽºÆ® ÀÚµ¿ µ¿±âÈ
function initTitle() {
var majorTitle = $("#nav .depth1 > a > span")
.text();
var minorTitle = $("#nav .depth2 > a > span")
.text();
$("#sub_visual > .title > .inner > h2")
.text(majorTitle);
$("#sub_visual > .title > .inner > h3")
.text(minorTitle);
}
// µå·Ó¹Ú½º ¸Þ´º Ŭ¸¯ ó¸®
$("#nav .dropdown > a")
.click(function() {
if(!$(this)
.parent('.dropdown')
.hasClass('open')) {
$("#nav .dropdown")
.removeClass('open');
$("#nav .dropdown > ul.mnuList")
.stop(true, false)
.fadeOut(200);
$(this)
.parent('.dropdown')
.addClass('open');
$(this)
.siblings('ul.mnuList')
.stop(true, false)
.fadeIn(200);
} else {
$(this)
.parent('.dropdown')
.removeClass('open');
$(this)
.siblings('ul.mnuList')
.stop(true, false)
.fadeOut(200);
}
});
// ¸ð¹ÙÀÏ µå·Ó¹Ú½º ¸Þ´º Ŭ¸¯ ó¸®
$("#leftBar a.dropdown")
.click(function(e) {
e.preventDefault();
if(!$(this)
.hasClass('open')) {
$(this)
.addClass('open');
$("#lnb")
.stop(true, false)
.slideDown(300);
} else {
$(this)
.removeClass('open');
$("#lnb")
.stop(true, false)
.slideUp(300);
}
});
function activeMobileNav() {
var topIndex = getUrlParameter('top') - 1;
var subIndex = getUrlParameter('sub') - 1;
$(".menuzord-menu > li")
.eq(topIndex)
.addClass('active');
$(".menuzord-menu > li")
.eq(topIndex)
.find('ul')
.css('display', '');
$(".menuzord-menu > li")
.eq(topIndex)
.find('ul')
.children()
.eq(subIndex)
.addClass('active');
}
// µå·Ó¹Ú½º ¸Þ´º µ¿±âÈ
$(window)
.load(function() {
majorActive();
minorActive();
initTitle();
activeMobileNav();
});
});
// Æ÷Åä°¶·¯¸® Ä¿½ºÅ͸¶ÀÌ¡
$(function() {
// °¶·¯¸® È£¹ö¹Ú½º ³ôÀÌ µ¿±âÈ
/*
function syncHeight() {
if($(".bbsnewf5").length > 0) {
refHeight = $(".hoverBox").parents('.bbsnewf5').height();
$(".hoverBox").css('height',refHeight + 'px');
}
}
*/
// °¶·¯¸® È£¹ö¹Ú½º ³ôÀÌ µ¿±âÈ Å¸À̸Ó
/*
if($(".bbsnewf5").length > 0) {
var tmrSync = setInterval(function() { syncHeight() }, 30);
}
*/
// Å×ÀÌºí ¾Ö´Ï¸ÞÀ̼Ç
function tableShow() {
if($(".gallery_inner")
.length > 0) {
$(".gallery_inner > table")
.each(function() {
if(!$(this)
.hasClass('-shown')) {
$(this)
.addClass('-shown');
}
$(this)
.addClass('scrollreveal');
});
}
}
// ´õº¸±â¹öÆ° »ý¼º
/*function createMoreBtn() {
var pageCount = $(".brd_paging").find('a').length;
if($(".gallery_inner").length > 0) {
if(pageCount > 0) {
var btn = '';
$(".board_bottom").before(btn);
}
}
}*/
tableShow();
/*createMoreBtn();*/
// ¸ðµç ¿¤¸®¸ÕÆ® ·Îµå ÈÄ
$(window)
.load(function() {
var loadIndex = 1;
var wrapper;
var moreFlag = false;
var path = $(location)
.attr('pathname');
if($(".gallery_inner")
.length > 0) {
wrapper = $(".gallery_inner");
}
// °ü¸®ÀÚ¹öÆ° »èÁ¦
function adminRemove() {
$(".gallery_inner > table")
.each(function() {
if($(this)
.attr('bordercolor')) {
$(this)
.remove();
}
});
}
// ºó Å×ÀÌºí »èÁ¦
function emptyRemove() {
$(".gallery_inner > table")
.each(function() {
if($(this)
.find('td')
.length < 1) {
$(this)
.remove();
}
});
}
// ¸¶Áö¸· ÆäÀÌÁöÀÎÁö üũ
function isLastPage() {
var currPage = parseInt($(".brd_paging b")
.text());
var pages = $(".brd_paging a");
var maxPage = 0;
pages.each(function() {
var cnt = parseInt($(this)
.text());
if(cnt >= maxPage) maxPage = cnt;
});
if(currPage >= maxPage) {
return true;
} else {
return false;
}
}
// ajax ·Îµå ó¸®
function photoLoadByURL(link) {
var temp;
var paging;
adminRemove();
emptyRemove();
$.ajax({
url: link
, 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) {
temp = $(data)
.find('.gallery_inner')
.html();
paging = $(data)
.find('.brd_paging')
.html();
$(".brd_paging")
.html('');
$(".brd_paging")
.html(paging);
var pageCount = $(".brd_paging")
.find('a')
.length;
if(loadIndex >= pageCount) $("#btnMoreLoad")
.remove();
if(moreFlag === true) {
wrapper.append(temp);
} else {
wrapper.html(temp);
}
tableShow();
wrapper.children()
.css('opacity', '0');
wrapper.children()
.animate({
'opacity': '1'
}, 400, function() {
wrapper.children()
.css({
'opacity': ''
});
});
emptyRemove();
galleryInit();
admBtnReplace();
if(pageCount > 0 && !isLastPage() && $("#btnMoreLoad")
.length < 1) createMoreBtn();
}
, error: function() {
wrapper.html('¿À·ù : Á¤»óÀûÀ¸·Î ·ÎµåµÇÁö ¾Ê¾Ò½À´Ï´Ù.');
}
});
}
// ´õº¸±â ¹öÆ° Ŭ¸¯½Ã
$(document)
.on('click', '#btnMoreLoad', function() {
var pageCount = $(".brd_paging")
.find('a')
.length;
var catePath = $(".board_tab > ul > li.on a")
.attr('href');
if(loadIndex < pageCount) {
loadIndex++;
} else {
loadIndex++;
$("#btnMoreLoad")
.attr('disabled', 'disabled');
}
var url = catePath + '&com_board_page=' + loadIndex;
moreFlag = true;
photoLoadByURL(url);
});
// Ä«Å×°í¸® ÅÇ Å¬¸¯½Ã
$(document)
.on('click', '.board_tab > ul > li > a', function(e) {
var url = $(this)
.attr('href');
moreFlag = false;
loadIndex = 1;
if(!isPC()) {
$(".board_tab > a")
.removeClass('open');
$(".board_tab > a")
.text($(this)
.text());
$(".board_tab > ul")
.css('display', 'none');
}
e.preventDefault();
$(".board_tab > ul > li")
.removeClass('on');
$(this)
.parent()
.addClass('on');
photoLoadByURL(url);
});
emptyRemove();
});
// Ä«Å×°í¸® °ü·Ã º¯¼ö ¼±¾ð
var cate_link = []
, cate_title = []
, currentURL = $(location)
.attr('pathname')
, param = "?&com_board_category_code="
, currentParam = ""
, insertHTML = ""
, idx = 0;
// ¼¿·ºÆ®¹Ú½º ¸µÅ©È
if($("select[name='com_board_category_code']")
.length > 0) {
currentParam = getUrlParameter('com_board_category_code');
$("select[name='com_board_category_code'] > option")
.each(function() {
cate_link[idx] = $(this)
.val();
cate_title[idx] = $(this)
.text();
idx++;
});
insertHTML = '';
$(".cate_select")
.before(insertHTML);
$.each(cate_link, function(m, key) {
if(key == currentParam) {
$(".board_tab > a")
.text(cate_title[m]);
$(".board_tab > ul > li[data-category='" + key + "']")
.addClass('on');
}
});
if(!currentParam) {
$(".board_tab > ul > li:first")
.addClass('on');
}
}
// Ä«Å×°í¸® ¸µÅ© Ŭ¸¯½Ã
$(document)
.on('click', '.board_tab > a', function() {
if(!isPC()) {
if(!$(this)
.hasClass('open')) {
$(this)
.addClass('open');
$(this)
.next('ul')
.css('display', 'block');
} else {
$(this)
.removeClass('open');
$(this)
.next('ul')
.css('display', 'none');
}
}
});
// À©µµ¿ì ¸®»çÀÌ¡ ó¸® (Ä«Å×°í¸® Ç׸ñ enable/disable)
$(window)
.bind('resize', function() {
if(isPC() && $(".board_tab")
.length > 0) {
$(".board_tab > ul")
.css('display', 'block');
} else if(!isPC()) {
if(!$(".board_tab > a")
.hasClass('open')) {
$(".board_tab > ul")
.css('display', 'none');
}
}
});
// °ü¸®ÀÚ Àü¿ë ¹öÆ° replace (ajax ·Îµå½Ã¸¶´Ù È£Ãâ)
function admBtnReplace() {
var $url = window.location.href;
var $readpage = $url.indexOf('read_form');
$("section .container img")
.each(function() {
var $src = $(this)
.attr('src');
// »èÁ¦
if($src.indexOf('btn_sdel.gif') > -1 && $readpage < 0) {
var $opt = $(this)
.attr('onclick');
var $link = "»èÁ¦";
$(this)
.before($link);
$(this)
.remove();
}
// À̵¿
if($src.indexOf('move.gif') > -1 && $readpage < 0) {
var $opt = $(this)
.attr('onclick');
var $link = "À̵¿";
$(this)
.before($link);
$(this)
.remove();
}
// º¹»ç
if($src.indexOf('copy.gif') > -1 && $readpage < 0) {
var $opt = $(this)
.attr('onclick');
var $link = "º¹»ç";
$(this)
.before($link);
$(this)
.remove();
}
// À̵¿ (ºäÆäÀÌÁö)
if($src.indexOf('move.gif') > -1 && $readpage > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default btn-sm');
$(this)
.parent('a')
.html('À̵¿');
$(this)
.remove();
}
// º¹»ç (ºäÆäÀÌÁö)
if($src.indexOf('copy.gif') > -1 && $readpage > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default btn-sm');
$(this)
.parent('a')
.html('º¹»ç');
$(this)
.remove();
}
// ¼öÁ¤ (ºäÆäÀÌÁö)
if($src.indexOf('modify.gif') > -1 && $readpage > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default');
$(this)
.parent('a')
.html('¼öÁ¤');
$(this)
.remove();
}
// »èÁ¦ (ºäÆäÀÌÁö)
if($src.indexOf('delete.gif') > -1 && $readpage > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default');
$(this)
.parent('a')
.html('»èÁ¦');
$(this)
.remove();
}
// ´ä±Û (ºäÆäÀÌÁö)
if($src.indexOf('reply.gif') > -1 && $readpage > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default');
$(this)
.parent('a')
.html('´ä±Û¾²±â');
$(this)
.remove();
}
});
}
// ÀÏ¹Ý ±â´É¹öÆ° replace
function btnReplace() {
$("section .container img")
.each(function() {
var $src = $(this)
.attr('src');
// ±Û¾²±â
if($src.indexOf('write.gif') > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-primary');
$(this)
.parent('a')
.html('±Û¾²±â');
$(this)
.remove();
}
// ÀÌÀü
if($src.indexOf('prev.gif') > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default btn-sm');
$(this)
.parent('a')
.html('ÀÌÀü');
$(this)
.remove();
}
// ¸ñ·Ïº¸±â
if($src.indexOf('list.gif') > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default btn-sm');
$(this)
.parent('a')
.html('¸ñ·Ï');
$(this)
.remove();
}
// ´ÙÀ½
if($src.indexOf('next.gif') > -1) {
$(this)
.parent('a')
.addClass('btn_w btn-default btn-sm');
$(this)
.parent('a')
.html('´ÙÀ½');
$(this)
.remove();
}
// ½ºÆԽŰí
if($src.indexOf('spam.gif') > -1) {
var $opt = $(this)
.attr('onclick');
var $link = '½ºÆԽŰí';
$(this)
.before($link);
$(this)
.remove();
}
});
// °Ë»ö
$("#ext_search input[type=image]")
.before('');
$("#ext_search input[type=image]")
.css('display', 'none');
$(document)
.on('click', '#ext_search input[type=submit]', function() {
$("#ext_search input[type=image]")
.trigger('click');
});
// ´ñ±Û´Þ±â
if($(".board_comment_bgcolor input[type=image]")
.length > 0) {
var $link = '';
$(".board_comment_bgcolor input[type=image]")
.before($link);
$(".board_comment_bgcolor input[type=image]")
.css('display', 'none');
}
$(document)
.on('click', '.board_comment_bgcolor input[type=submit]', function() {
$(".board_comment_bgcolor input[type=image]")
.trigger('click');
});
}
admBtnReplace();
btnReplace();
});