function smoothScroll() { $('a.J_title_nav').click(function() { var speed = 400; var href = $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = target.offset().top - 5; $('body,html').animate({ scrollTop: position }, speed, 'swing'); return false; }); } function txtTrim(trimTag) { $(trimTag).each(function() { var txtW = $(this).outerWidth(); var txtSize = 14; var textLength = $(this).text().length; var _txtLimit = Math.floor(txtW / txtSize); var txtLimit = (_txtLimit) * 2; var textTrim = $(this).text().substr(0, (txtLimit)); var afterTxt = '...'; if (textLength > txtLimit) { $(this).html(textTrim + afterTxt); } }); } //nolSlider02 function nolSlider02(className02) { //slideNum var slideNum = 0; for (var t = 0; t < $(className02).children().length; t++) { slideNum = t; } //slideWidth var windowW = $(window).width(); $(className02).css('min-height', windowW * 0.49); //NEXT PREV var btnArea = $(className02).next('.sliderBtn'); btnArea.children('li').click(function() { var thisArea = $(this).parent(); var thisSlider = thisArea.prev(); var focusSlide = thisSlider.children('.focus'); var totalW = 0; windowW = $(window).width(); if ($(this).hasClass('next')) { if (!thisSlider.children().last().hasClass('focus')) { thisSlider.children('.focus').removeClass('focus').next().addClass('focus'); thisSlider.children().each(function() { var thisW = $(this).outerWidth(); totalW += thisW; if ($(this).hasClass('focus')) { var focusW = $(this).outerWidth(); var transform = -((totalW - focusW) - (windowW - focusW) / 2); thisSlider.css({ 'transform': 'translate3d(' + transform + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); return false; } }); } } if ($(this).hasClass('prev')) { if (!thisSlider.children().first().hasClass('focus')) { thisSlider.children('.focus').removeClass('focus').prev().addClass('focus'); thisSlider.children().each(function() { var thisW = $(this).outerWidth(); totalW += thisW; if ($(this).hasClass('focus')) { var focusW = $(this).outerWidth(); var transform = -((totalW - focusW) - (windowW - focusW) / 2); thisSlider.css({ 'transform': 'translate3d(' + transform + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); return false; } }); } } }); //resize var timer02 = false; $(window).resize(function() { var windowWcheck = $(window).width(); if (windowW !== windowWcheck) { if (timer02 !== false) { clearTimeout(timer02); } timer02 = setTimeout(function() { $(className02).css({ 'transition-duration': '0' }); //slideWidth windowW = $(window).width(); slideW = Math.ceil(windowW * 0.8); $(className02).children().css('width', slideW); $(className02).find('figure').css('min-height', windowW * 0.43); $(className02).css('min-height', windowW * 0.49); //First position $(className02).each(function() { var slideList = $(this).children(); var slildeArrayW = []; for (var i = 0; i < slideList.length; i++) { var slideWidth = slideList.eq(i).outerWidth(); slildeArrayW.push(slideWidth); } //Width var sliderW = 0; for (var j = 0; j < slildeArrayW.length; j++) { sliderW += slildeArrayW[j]; } $(this).css('width', sliderW); //move focusW = $(className02).children('.focus').outerWidth(); currentTotal = 0; slideList.each(function() { currentTotal += $(this).outerWidth(); if ($(this).hasClass('focus')) { return false; } }); moveW = -((currentTotal - focusW) - (windowW - focusW) / 2); $(className02).css({ 'transform': 'translate3d(' + moveW + 'px, 0px, 0px)' }); }); sliderW = slideW * slideNum; //firstLeft firstW = $(className02).children().first().outerWidth(); firstLeft = (windowW - firstW) / 2; //lastLeft lastW = $(className02).children().last().outerWidth(); lastLeft = -(sliderW - lastW - (windowW - lastW) / 2); windowW = windowWcheck; }, 100); } }); } function showLoading(className02) { $(className02).children().css('visibility', 'hidden'); $('.loading').css('display', 'block'); } function nolSlider02Setup(className02, slider02Num) { //slideWidth var windowW = $(window).width(); var slideW = Math.ceil(windowW * 0.8); $(className02).children().css('width', slideW); $(className02).find('figure').css('min-height', windowW * 0.43); $(className02).css('min-height', windowW * 0.49); //First position var slideList = $(className02).children(); var slildeArrayW = []; for (var i = 0; i < slideList.length; i++) { var slideWidth = slideList.eq(i).outerWidth(); slildeArrayW.push(slideWidth); } //Width var sliderW = 0; for (var j = 0; j < slildeArrayW.length; j++) { sliderW += slildeArrayW[j]; } $(className02).css('width', sliderW); //move var focusW = $(className02).children('.focus').outerWidth(); var currentTotal = 0; slideList.each(function() { currentTotal += $(this).outerWidth(); if ($(this).hasClass('focus')) { return false; } }); var moveW = -((currentTotal - focusW) - (windowW - focusW) / 2); $(className02).css({ 'transform': 'translate3d(' + moveW + 'px, 0px, 0px)', 'transition-duration': '0' }); var sliderW = $(className02).outerWidth(); //firstLeft var firstW = $(className02).children().first().outerWidth(); var firstLeft = (windowW - firstW) / 2; //lastLeft var lastW = $(className02).children().last().outerWidth(); var lastLeft = -(sliderW - lastW - (windowW - lastW) / 2); var totalW = 0; var ulLeft = 0; $(className02).on({ 'touchstart': function(e) { $(this).css({ 'transition-duration': '0s' }); $(this).children().removeClass('focus'); this.touchX = event.changedTouches[0].pageX; this.slideX = $(this).position().left; }, 'touchmove': function(e) { e.preventDefault(); this.slideX = this.slideX - (this.touchX - event.changedTouches[0].pageX); $(this).css({ 'transform': 'translate3d(' + this.slideX + 'px, 0px, 0px)', 'transition-duration': '0' }); this.accel = (event.changedTouches[0].pageX - this.touchX) * 5; this.touchX = event.changedTouches[0].pageX; }, 'touchend': function() { var _this = this; sliderW = $(_this).outerWidth(); var slideList = $(_this).children(); _this.slideX += _this.accel * 2; windowW = $(window).width(); // totalW = 0; ulLeft = -_this.slideX; slideList.each(function() { var thisW = $(this).outerWidth(); totalW += thisW; if (totalW - thisW / 2 > ulLeft) { var focusW = $(this).outerWidth(); var tansform = -((totalW - focusW) - (windowW - focusW) / 2); $(_this).css({ 'transform': 'translate3d(' + tansform + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); $(this).addClass('focus'); return false; } }); sliderW = $(className02).outerWidth(); lastW = $(className02).children().last().outerWidth(); lastLeft = -(sliderW - lastW - (windowW - lastW) / 2); _this.accel = 0; // if (_this.slideX > 0) { _this.slideX = 0; $(_this).css({ 'transform': 'translate3d(' + firstLeft + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); $(_this).children().first().addClass('focus'); } if (_this.slideX < lastLeft) { $(_this).css({ 'transform': 'translate3d(' + lastLeft + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); $(_this).children().last().addClass('focus'); } } }); $(className02).children().css('visibility', 'visible'); $('.loading').css('display', 'none'); var image = $(className02).find('figcaption'); image.find('p').each(function() { var txtW = $(this).outerWidth(); var txtSize = 14; var textLength = $(this).text().length; var _txtLimit = Math.floor(txtW / txtSize); var txtLimit = (_txtLimit - 1) * 2; var textTrim = $(this).text().substr(0, (txtLimit)); var afterTxt = '...'; if (textLength > txtLimit) { $(this).html(textTrim + afterTxt); } }); } //nolSlider03 var topArray = []; var posting = 0; function nolSlider03(className03) { topArray = []; //slideNum var slideNum = $(className03).children().length; var slide = $(className03).children(); var windowW = $(window).width(); var slideWidth01 = Math.ceil(windowW * 0.22); var slideWidth02 = Math.ceil(windowW * 0.30); $(className03).children('li').css('width', slideWidth01); $(className03).children('.widWide').css('width', slideWidth02); $(className03).each(function() { var slideList = $(this).children(); var slildeArrayW = []; for (var i = 0; i < slideList.length; i++) { var slideWidth = 0; if (slideList.eq(i).hasClass('widWide')) { slildeArrayW.push(slideWidth02); } else { slildeArrayW.push(slideWidth01); } } //Width var sliderW = 0; for (var j = 0; j < slildeArrayW.length; j++) { sliderW += slildeArrayW[j]; } $(this).css('width', sliderW); }); //move var sliderW = $(className03).outerWidth(); var sliderWHalf = sliderW / 2; //firstLeft var firstLeft = -1; //lastLeft var lastLeft = -(sliderW - windowW); $(className03).css({ 'transform': 'translate3d(-1px, 0px, 0px)', 'transition-duration': '0' }); //focusView function focusView() { var slideWrap = $('#titleNav'); var focusSlide = $(className03).children('.focus'); //alert(focusSlide.data('type')) slideWrap.removeClass(); slideWrap.addClass(focusSlide.data('type')); var leftLine = -$(className03).position().left; var rightLine = leftLine + windowW; var focusLine = 0; if (slide.first().hasClass('focus')) { focusLine = 0; } else { slide.each(function(e) { var thisW = $(this).outerWidth(); if ($(this).next().hasClass('focus')) { return false; } focusLine += thisW; }); } var focusW = focusSlide.outerWidth(); var focusPrevW = focusSlide.prev().outerWidth(); var focusNextW = focusSlide.next().outerWidth(); var focusLine02 = focusLine + focusW + focusPrevW + focusNextW; var centerFit = -(focusLine + focusW - (windowW - focusW) / 2); if (centerFit > 0) { centerFit = 0; } else { if (centerFit < lastLeft) { centerFit = lastLeft; } } if (leftLine > focusLine || rightLine < focusLine02) { $(className03).css({ 'transform': 'translate3d(' + centerFit + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); } } var currentPosition = 0; $(className03).on({ 'touchstart': function() { $(this).css({ 'transition-duration': '0s' }); /* if(currentId){ $(this).removeClass (currentId); } */ this.touchX = event.changedTouches[0].pageX; this.slideX = $(this).position().left; currentPosition = this.slideX; }, 'touchmove': function(e) { e.preventDefault(); this.slideX = this.slideX - (this.touchX - event.changedTouches[0].pageX); $(this).css({ 'transform': 'translate3d(' + this.slideX + 'px, 0px, 0px)', 'transition-duration': '0' }); this.accel = (event.changedTouches[0].pageX - this.touchX) * 5; this.touchX = event.changedTouches[0].pageX; }, 'touchend': function() { var _this = this; var sliderW = $(_this).outerWidth(); var sliderWrapW = $(_this).parent().width(); var maxW = sliderW - sliderWrapW; var slideList = $(_this).children(); var endPosition = $(this).position().left; _this.slideX += _this.accel * 2; $(_this).css({ 'transform': 'translate3d(' + _this.slideX + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); _this.accel = 0; // if (_this.slideX > 0) { _this.slideX = 0; $(_this).css({ 'transform': 'translate3d(' + firstLeft + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); } if (_this.slideX < lastLeft) { $(_this).css({ 'transform': 'translate3d(' + lastLeft + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); } } }); //click var flagClick = false; slide.children().click(function() { slide.removeClass('focus'); $(this).parent('li').addClass('focus'); focusView(); flagClick = true; }); var timer = false; $(window).scroll(function() { if (timer !== false) { clearTimeout(timer); } timer = setTimeout(function() { if (flagClick == true) { flagClick = false; } else { var nowTop = $(window).scrollTop(); var stopNum = 0; var maxNum = topArray.length; for (var j = 0; j < topArray.length; j++) { stopNum = topArray[j]; if (stopNum - 45 > nowTop) { if (j == 0) { slide.removeClass('focus'); slide.eq(0).addClass('focus'); focusView(); return false; } else { slide.removeClass('focus'); slide.eq(j - 1).addClass('focus'); focusView(); return false; } } if (j == maxNum - 1) { slide.removeClass('focus'); slide.eq(j).addClass('focus'); focusView(); return false; } } } }, 200); }); //resize var timer03 = false; $(window).resize(function() { var windowWcheck = $(window).width(); if (windowW !== windowWcheck) { var timer03 = false; if (timer03 !== false) { clearTimeout(timer03); } timer03 = setTimeout(function() { windowW = $(window).width(); slideWidth01 = Math.ceil(windowW * 0.22); slideWidth02 = Math.ceil(windowW * 0.30); $(className03).children('li').css('width', slideWidth01); $(className03).children('.widWide').css('width', slideWidth02); var _sliderW = 0; $(className03).each(function() { var slideList = $(this).children(); var slildeArrayW = []; for (var i = 0; i < slideList.length; i++) { var slideWidth = 0; if (slideList.eq(i).hasClass('widWide')) { slildeArrayW.push(slideWidth02); } else { slildeArrayW.push(slideWidth01); } } //Width var sliderW = 0; for (var j = 0; j < slildeArrayW.length; j++) { sliderW += slildeArrayW[j]; } $(this).css('width', sliderW); _sliderW = sliderW; }); //move sliderWHalf = _sliderW / 2; //firstLeft firstLeft = -1; //lastLeft lastLeft = -(_sliderW - windowW); var thisPosition = $(className03).position().left; if (thisPosition < lastLeft) { $(className03).css({ 'transform': 'translate3d(' + lastLeft + 'px, 0px, 0px)', 'transition-duration': '0.5s' }); } topArray = []; $('.titleAnc').each(function() { var topPoint = $(this).offset().top; topArray.push(topPoint); }); }, 300); } }); $(window).load(function() { if ($('#titleNav').length > 0) { var min_move = $('#main').offset().top; var max_move = $('.titleStop').offset().top; var titleNav = $('#titleNav'); var contents_bottom = max_move - min_move; } $(window).bind("scroll", function() { if ($('#titleNav').length > 0) { var wst = $(window).scrollTop(); if (wst > min_move) { titleNav.css('position', 'fixed'); $('.firstTitle').addClass('focus'); } else if (wst < min_move) { titleNav.animate({ 'top': 0 }, { queue: false }); titleNav.css('position', 'relative'); } } // if ($('#header').parent().attr('id') != 'page_home_index') { // $('#header').css('position', 'fixed'); // $('#content').css('padding-top', '35px'); // } }); //scroll topArray = []; $('.titleAnc').each(function() { var topPoint = $(this).offset().top; topArray.push(topPoint); }); }); } function nolSlider03Setup(className03) { var min_move = $('#main').offset().top; var max_move = $('.titleStop').offset().top; var titleNav = $('#titleNav'); var contents_bottom = max_move - min_move; //scroll topArray = []; $('.titleAnc').each(function() { var topPoint = $(this).offset().top; topArray.push(topPoint); }); } function kxScroll(obj) { $(obj).animate({ marginTop: "-44px" }, 500, function() { $(this).css({ marginTop: "0px" }).find("p:first").appendTo(this); }); } $().ready(function() { if ($('.titleSlider').length > 0) { nolSlider03 ('.titleSlider'); } smoothScroll(); if ($('#tusScroll').length > 0) { setInterval('kxScroll("#tusScroll")', 5000) } //slider if ($('.programSlider').length > 0) { nolSlider02 ('.programSlider'); } $(".nol_textArea input").focus(function(){ $(".nol_querySubmitBt").addClass("nol_btn_on"); }); $(".nol_textArea input").blur(function(){ $(".nol_querySubmitBt").removeClass("nol_btn_on"); }); // pullDown $('#gmenu .pullBtn').on('click', function() { var _id = $(this).attr('id'); $(this).toggleClass('show'); $('#'+_id+'_close').toggleClass('show'); if($(this).hasClass('show')) { $('#sub_'+_id).css({ 'transform':'translate3d(0px, 0px, 0px)', 'transition-duration':'0.5s' }); } else { $('#sub_'+_id).css({ 'transform':'translate3d(0px, -100%, 0px)', 'transition-duration':'0.5s' }); } }); var loadImg = function(url, fn) { var img = new Image(); img.src = url; if (img.complete) { fn.call(img); } else { img.onload = function() { fn.call(img); img.onload = null; }; }; }; $.fn.imgAutoSize = function(padding) { var maxWidth = this.innerWidth() - (padding || 0); return this.find('img').each(function(i, img) { loadImg(this.src, function() { if (this.width > maxWidth) { var height = maxWidth / this.width * this.height, width = maxWidth; img.width = width; img.height = height; }; }); }); }; }); function imgload(e) { var x = navigator, w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; if (typeof e.length !== 'undefined') { for (var a = 0; a < e.length; a++) { e[a].parentNode.style.height = w / 6.4 + 'px'; } } else { e.parentNode.style.height = w / 6.4 + 'px'; } }