MINI MINI MANI MO
(function($){
var lnb = {
wrap : $('.lnb'),
menu : $('.lnb > li'),
cover : $('.lnb_cover'),
speed : 300,
ease : 'easeOutCubic',
cover_h : 37,
mr_top : 15
}
var lnb_reset = function(){
if(lnb.wrap.find('> li.on').length > 0){
lnb.wrap.find('> li.on').removeClass('on');
}
lnb.cover.stop().animate({height:0},{duration:lnb.speed,easing:lnb.ease});
lnb.menu.find('> ul').stop().animate({opacity:0,marginTop:lnb.mr_top},{duration:lnb.speed,easing:lnb.ease,complete:function(){
$(this).hide();
}});
}
lnb.menu.bind('mouseenter',function(){
lnb_reset();
$(this).addClass('on');
if($(this).find('> ul').length > 0){
$(this).find('> ul').show().stop().animate({opacity:1,marginTop:0},{duration:lnb.speed,easing:lnb.ease});
lnb.cover.stop().animate({height:lnb.cover_h},{duration:lnb.speed,easing:lnb.ease});
}
});
lnb.wrap.bind('mouseleave',function(){
lnb_reset();
});
// location
var loc = {
wrap : $('#location > ul'),
menu : $('#location > ul > li'),
speed : 300,
ease : 'easeOutCubic'
}
var loc_set = function(){
loc.menu.each(function(){
if($(this).find('> ul').length > 0){
$(this).addClass('has_ul');
}
});
}
loc.menu.bind('click',function(){
$(this).find('ul').slideDown({duration:loc.speed,easing:loc.ease});
});
loc.menu.bind('mouseleave',function(){
$(this).find('ul').slideUp({duration:loc.speed,easing:loc.ease});
});
loc_set();
// 체크박스 이벤트 관련 테이블
var check_table = $('.check_event_table');
var check_table_evt = function(obj){
checked = obj.prop('checked');
if(checked){
obj.parent().parent().addClass('checked');
}else{
obj.parent().parent().removeClass('checked');
}
}
check_table.find('input:checkbox').bind('click',function(){
check_table_evt($(this));
});
$(window).load(function(){
if(check_table.length > 0){
check_table.find('input:checkbox').each(function(){
check_table_evt($(this));
});
}
});
// 파일 첨부 추가 삭제 기능
var attach = {
btn : $('.file_attach_controll button'),
calculation : 'plus',
num : 1
}
var attach_evt = function(obj,field_id){
attach.num = obj.find('.file_field').length;
if(attach.calculation == 'plus'){
attach.num++;
obj.find('.file_field').eq(0).clone().appendTo(obj).find('input:file').attr('name',field_id+attach.num);
}else{
attach.num--;
if(attach.num <= 0){
attach.num = 1;
alert('파일첨부 항목을 더 이상 삭제할수 없습니다.');
return;
}else{
obj.find('.file_field').eq(-1).remove();
}
}
}
attach.btn.bind('click',function(){
attach.calculation = $(this).attr('class');
connect_id = $(this).parent().attr('data-connect');
attach_evt($('#'+connect_id),connect_id);
return false;
});
// 레이어 팝업 공통 이벤트
var layer = {
btn : $('.layer_call'),
close : $('.commonLayer .close'),
speed : 500
}
var dim_evt = function(obj){
if(obj == 'show'){
dim_html = '<div class="commonDim"></div>';
$('body').append(dim_html);
$('.commonDim').fadeIn(layer.speed);
}else{
$('.commonDim').fadeOut(layer.speed,function(){
$(this).remove();
});
}
}
var layer_evt = function(obj){
dim_evt('show');
obj
.fadeIn(layer.speed)
.css({
'margin-left':'-280px',
'margin-top':-obj.outerHeight()/2+'px'
});
}
layer.btn.bind('click',function(){
layer_id = $(this).attr('data-id');
layer_evt($('#'+layer_id));
return false;
});
layer.close.bind('click',function(){
dim_evt('hide');
$(this).parent().fadeOut(layer.speed);
return false;
});
// input placeholder
var placeholder_set = function(){
$('.placeholder').each(function(){
place_val = $(this).find('input').val();
if(place_val != ''){
$(this).find('input').css('z-index','5')
.find('+label').css('text-indent','-9999px');
}
});
}
placeholder_set();
var placeholder_input = $('.placeholder');
placeholder_input.bind('click',function(){
if($(this).find('input').length > 0){
$(this).find('input').focus().css('z-index','5')
.find('+label').css('text-indent','-9999px');
}else if($(this).find('textarea').length > 0){
$(this).find('textarea').focus().css('z-index','5')
.find('+label').css('text-indent','-9999px');
}
});
placeholder_input.find('input,textarea').bind('focusout',function(){
input_text = $(this).val();
if(input_text == ''){
$(this).css('z-index','-1')
.find('+label').css('text-indent','0');
}else{
}
});
// 공통 탭 이벤트
var commontab = {
tabs : $('.func_tab ul li a')
}
commontab.tabs.bind('click',function(){
wrap_class = $(this).parent().parent().parent().attr('data-class');
wrap_id = $(this).attr('href');
$(this).parent().parent().find('li.active').removeClass('active');
$(this).parent().addClass('active');
$('.'+wrap_class).find('.tabCont').hide();
$(wrap_id).show();
return false;
});
// 상담결과
var qna = {
items : $('.qnaSheet tr.post'),
speed : 300,
ease : 'easeOutCubic'
}
qna.items.find('td').bind('click',function(){
if($(this).find('.ico_typeA').length == 0){
if($(this).parent().find('+tr td .counselCont').is(':hidden')){
//$('.counselCont').slideUp({duration:qna.speed,easing:qna.ease});
$(this).parent().find('+tr td .counselCont').slideDown({duration:qna.speed,easing:qna.ease});
}else{
//$('.counselCont').slideUp({duration:qna.speed,easing:qna.ease});
$(this).parent().find('+tr td .counselCont').slideUp({duration:qna.speed,easing:qna.ease});
}
}
});
// 비주얼 페이드인아웃
// [START] fade in & out (Author: KANG HEE CHANG / http://hckang80.waplez.com)
fadeGallery = function(obj, timer){
var $speed = 500;
var $wrapper = "#" + obj;
var $sel = 0;
var flag = true
$($wrapper).find(".gallery").children("li:gt(0)").hide();
if($($wrapper).find(".control li").length == 0 && $($wrapper).find(".gallery").children("li").length > 1){
for(j = 0; j < $($wrapper).find(".gallery").children("li").length; j++){
$($wrapper).find(".control").append('<li><a href="#">go banner</a></li>\n');
}
};
$($wrapper).find(".control").children("li:first-child").addClass("on");
if($($wrapper).find(".gallery").children("li").length==1){
$($wrapper).find(".links_stop").hide();
$($wrapper).find(".links_play").hide();
return false;
}
//viewItem = 0;
var playAction = function(){
clearInterval(autoPlay);
$($wrapper).find(".control").children("li").eq($sel).addClass("on");
$($wrapper).find(".control").children("li").not($($wrapper).find(".control").children("li").eq($sel)).removeClass("on");
$($wrapper).find(".gallery").children("li").not($($wrapper).find(".gallery").children("li").eq($sel)).css("z-index","0")
$($wrapper).find(".gallery").children("li").eq($sel).css("z-index","1").fadeIn(function(){
$($wrapper).find(".gallery").children("li").not($($wrapper).find(".gallery").children("li").eq($sel)).hide();
flag = true;
});
autoChange();
}
function goNext(){
if(flag == true){
flag = false;
$sel++;
if($sel == $($wrapper).find(".gallery").children("li").size()){
$sel = 0;
}
playAction();
}
return false;
}
$($wrapper).find(".links_next").click(goNext);
function goPrev(){
if(flag == true){
flag = false;
$sel--;
if($sel == -1){
$sel = $($wrapper).find(".gallery").children("li").size() - 1;
}
playAction();
}
return false;
}
$($wrapper).find(".links_prev").click(goPrev);
// 바로가기
function goDirect(){
if(flag == true && !$(this).parent().hasClass("on")){
flag = false;
$sel = $(this).parent().index();
playAction();
}
return false;
}
$($wrapper).find(".control a").click(goDirect);
// 자동실행
var autoPlay;
function autoChange(){
autoPlay = setInterval(goNext, timer);
}
autoChange();
// 영역 오버시 멈춤
$($wrapper).find(".gallery").hover(
function(){
clearInterval(autoPlay);
},
function(){
clearInterval(autoPlay);
autoChange();
}
);
// 컨트롤러
$($wrapper).find(".links_stop").click(function(){
clearInterval(autoPlay);
});
$($wrapper).find(".links_play").click(function(){
clearInterval(autoPlay);
autoChange();
});
}
// [END] fade in & out
})(jQuery);
OHA YOOOO