/**
* js/front.js
*/
$(document).ready(function() {
setTimeout(function () {
$("#visual").addClass("active");
});
$('.btn_up_layer').click(function(){
$("html, body").animate({scrollTop:0}, 'slow');
return false;
});
// 스í¬ë¡¤ì´ ì„¤ì •í•œ ë†’ì´ ì´ìƒ ë‚´ë ¤ê°”ì„ë•Œ 스타ì¼ì¶”가하기
if ($(window).width() > 0) {
$(window).on("scroll",function(ev){
if($(window).scrollTop() > 50 ) {
$('#header').addClass('bg_on');
// $('.c--btn').addClass('active');
$('.btn_up_layer').addClass('active');
}
else{
$('#header').removeClass('bg_on');
// $('.c--btn').removeClass('active');
$('.btn_up_layer').removeClass('active');
}
return false;
});
}
/* tab */
//Default Action
$(".mProduct--cont").hide(); //Hide all content
$("#m-products li:first").addClass("active").show(); //Activate first tab
$(".mProduct--cont:first").show(); //Show first tab content
//On Click Event
$("#m-products li").click(function() {
$("#m-products li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab
$(".mProduct--cont").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active content
return false;
});
}); /* end */
$(function () {
gnb();
classToggle();
fileUpload(); // fileupload
$(this).find('.nice-select').niceSelect(); // selectbox
scrollTopMov();
bodyScrollNone();
subMenuToggle();
accordion();
//checkbox All checked
allChecker('.chk-all');
allChecker('.chk-all1');
allChecker('.chk-all2');
allChecker('.chk-all3');
});
//xscroll
$(window).on('load', function(){
xScroll('.x-scroll');
kScroll('.k-scroll'); // scroll bar true
});
// iscroll outerwidth
function calcWidth(target) {
var $target = $(target);
$target.each(function(){
var child = $(this).children(),
width = 0;
child.each(function(){
width += $(this).outerWidth(true);
});
$(this).css('width', width);
});
}
// iscroll
function xScroll(obj) {
var $obj = $(obj),
tabs = $obj.find('.tabs');
if ( $(obj).length <= 0 ) {
return
} else {
$(window).resize(function(){
calcWidth(tabs);
});
calcWidth(tabs);
new IScroll(obj , {
scrollX : true,
scrollY : false,
mouseWheel : false,
autoCenterScroll : true,
bounce : true
});
}
}
// iscroll
function kScroll(obj) {
var $obj = $(obj),
tabs = $obj.find('.tabs');
if ( $(obj).length <= 0 ) {
return
} else {
$(window).resize(function(){
calcWidth(tabs);
});
calcWidth(tabs);
new IScroll(obj , {
scrollX : true,
scrollY : false,
mouseWheel : false,
autoCenterScroll : true,
bounce : true,
scrollbars: true
});
}
}
// file upload
function fileUpload() {
var obj = $('.inputfile-wrap');
if (obj.length <= 0) return;
var fileTarget = obj.find('input[type=file]');
fileTarget.on('change', function(){
if (window.FileReader) {
var filename = $(this)[0].files[0].name;
} else {
var filename = $(this).val().split('/').pop().split('\\').pop();
}
$(this).siblings('input[type=text]').val(filename);
});
}
// class toggle
function classToggle() {
$('[data-toggle="class-toggle"]').find('button, a').click(function(){
var li = $(this).closest('li');
var lis = li.siblings('li');
var wraps = $(this).closest($('[data-toggle="class-toggle"]'));
var toggleSelf = wraps.data('toggle-self');
var toggleClass = wraps.data('toggle-class');
var className = toggleClass === undefined ? 'active' : toggleClass;
if (toggleSelf){
if (li.hasClass(className)){
li.removeClass(className);
} else {
lis.removeClass(className);
li.addClass(className);
}
} else {
lis.removeClass(className);
li.addClass(className);
}
});
}
// gnb pc nav
function gnb() {
$('#gnb #gnb1_ul').hover(function(){
$('#gnb').addClass('on');
$('.gnb2_ul').css('display','block');
//$('.header_mask').addClass('active');
setTimeout(function(){
$('.gnb2_ul').addClass('on');
},200);
}, function(){
$('#gnb').removeClass('on');
$('.gnb2_ul').css('display','none');
$('.gnb2_ul').removeClass('on');
//$('.header_mask').removeClass('active');
})
// gnb pc nav End
//gnb active
//$("#gnb .gnb1_li").each(function(){
// if ($(this).children("a").text() == $(".location .depth_1").text() ){
//$(this).children("a").css("color","#f03844");
//$(this).children("a").css("border-bottom","1px solid #f03844");
// }
//});
// GNB End
}
// accordion
function accordion() {
var wrap = $('.ui-accordion'),
list = wrap.find('li'),
title = wrap.find('.accord-title'),
toggle = title.find('.btn-toggle');
if(wrap.length <= 0) return;
// ì ‘ê·¼ì„± 대ì‘
list.each(function(){
var $btn = $(this).find('.accord-title .btn-toggle'),
$content = $(this).find('.accord-cont'),
id = $(this).index();
$btn.attr({
'id' : 'accord-toggle' + id,
'aria-controls' : 'accord-cont' + id
});
$content.attr({
'id' : 'accord-cont' + id,
'role' : 'region',
'aria-labelledby' : 'accord-toggle' + id
})
});
toggle.click(function(){
var li = $(this).parent('.accord-title').parent('li'),
cont = $(this).parent('.accord-title').siblings('.accord-cont'),
blind = $(this).find('.blind');
if (li.hasClass('open')) {
$(this).attr('aria-expanded', 'false');
cont.slideUp();
li.removeClass('open');
blind.text('ìƒì„¸ë³´ê¸°');
} else {
$(this).attr('aria-expanded', 'true');
cont.slideDown();
li.addClass('open');
blind.text('닫기');
}
});
}
// tab
function uiTab() {
var tab = '[data-evt="tab"]';
$(document).on('click', tab + ' a', function (e) {
e.preventDefault();
var $this = $(this),
id = $this.attr('href'),
$target = $('[data-id=' + id + ']'),
$siblings = $this.parents('li').siblings('').find('a');
$siblings.each(function () {
var id = $(this).attr('href');
$(this).parents('li').removeClass('active');
$('[data-id=' + id + ']').hide();
});
$this.parents('li').addClass('active');
$target.show();
return false;
});
if ( tab.length <= 0 ) return;
$(tab).find('a').each(function(){
var tg = $(this).attr('href');
$('[data-id="'+tg+'"]').hide();
});
$(tab + ' > li:first-child a').click();
}
// ëª¨ë°”ì¼ ë°”ë”” 스í¬ë¡¤ë°©ì§€ - olibu
function bodyScrollNone() {
var posY;
$(".mOpener").on("click", function(e){
posY = $(window).scrollTop();
$("html, body").addClass("not_scroll");
$(".mMenu").css("display","block");
//$(".cont").css("top",-posY);
});
$(".closer").on("click", function(){
$("html, body").removeClass("not_scroll");
// $(".mMenu").css("display","none");
posY = $(window).scrollTop(posY);
});
$(".mask").on("click", function(){
$("html, body").removeClass("not_scroll");
// $(".mMenu").css("display","none");
posY = $(window).scrollTop(posY);
});
}
// 스í¬ë¡¤ 앵커ì´ë™
function scrollTopMov() {
if (jQuery(window).width() > 1160) {
$('a.ps').click(function(){
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top - 100
}, 500);
return false;
});
}
else{
$('a.ps').click(function(){
$('html, body').animate({
scrollTop: $( $.attr(this, 'href') ).offset().top - 60
}, 500);
return false;
});
}
}
/* Toggle */
function subMenuToggle() {
$('.submenuM').on('click', function(){
$(this).siblings('.submenu_toggle').stop().slideToggle();
})
}
// checkbox all check
function allChecker(input) {
var $input = $(input),
name = $input.attr('name');
$input.on('change', function () {
var $this = $(this);
if ($this.prop("checked")) {
$('input[name=' + name + ']').prop("checked", true);
} else {
$('input[name=' + name + ']').prop("checked", false);
}
});
$('input[name=' + name + ']').each(function () {
var $this = $(this);
$this.on('change', function () {
var total = $('input[name=' + name + ']').length;
var chked = $('input[name=' + name + ']:checked').not($input).length + 1;
if (chked == total) {
$input.prop("checked", true);
} else {
$input.prop("checked", false);
}
});
});
}