// JavaScript Document /*--------------------------------------event on each Breakpoints*/ $(window).on('load resize', function(){ if(window.matchMedia('(max-width: 480px)').matches){ $('.rwdImg').each(function() { $(this).attr('src', $(this).data('img')); }); $('body').removeClass('bodyPc').addClass('bodySp'); } else if(window.matchMedia('(min-width: 481px)').matches){ $('.rwdImg').each(function() { $(this).attr('src', $(this).data('img').replace('_sp', '_pc')); }); $('body').removeClass('bodySp').addClass('bodyPc'); } }); /*--------------------------------------Smart RollOver*/ function smartRollover() { if(document.getElementsByTagName) { var images = document.getElementsByTagName("img"); for(var i=0; i < images.length; i++) { if(images[i].getAttribute("src").match("_off.")) { images[i].onmouseover = function() { this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on.")); } images[i].onmouseout = function() { this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off.")); } } } } } if(window.addEventListener) { window.addEventListener("load", smartRollover, false); } else if(window.attachEvent) { window.attachEvent("onload", smartRollover); } $(function(){ /*--------------------------------------smooth scroll*/ $('a[href^="#"]').click( function(){ var speed = 800; var href= $(this).attr("href"); var target = $(href == "#" || href == "" ? 'html' : href); var position = $('body.bodyPc')[0] ? target.offset().top : (target.offset().top - $('header').height()); $("html,body").animate({scrollTop:position}, speed, "easeOutExpo"); return false; }); }); // Smooth scroll with paging /* $(function(){ //assigning click events var anchors = document.querySelectorAll('main a'), href =''; $.each(anchors,function(i,e){ href = $(this).attr('href'); //validation for href property if(typeof href !== 'undefined' && href.indexOf('?') === -1 && href.match(/#[A-Za-z]+.*?/) && $(href.match(/#[A-Za-z]+.*?/)[0]).length === 0){ console.log('ok'); $(e).on('click.scroll', function(ev) { ev.preventDefault(); var ref = $(ev.currentTarget).attr('href'); //change location with hash string param location.href = ref.slice(0,ref.lastIndexOf('#')) + '?pagepos=' + $(ev.currentTarget).attr('href').match(/#([A-Za-z]+.*?)/)[1]; }); } }); //getting param on onload event if(/pagepos=(.*?)(&|$)/.test(location.href)){ $(window).on('load.scroll', function(){ $('html,body').delay(100).animate({ scrollTop: $('body.bodyPc')[0] ? $('#' + location.search.match(/pagepos=(.*?)(&|$)/)[1]).offset().top : $('#' + location.search.match(/pagepos=(.*?)(&|$)/)[1]).offset().top - $('header').height() },800,'easeOutExpo'); }); } }); */ // Header $(function(){ var header = $('header'), menu = header.find('.menu'), menuText = menu.find('span'), menuContent = header.find('.menu-wrapper'), //menuContentAnchor = menuContent.find('a'), overlay = header.find('#menu-overlay'), closeBtn = menuContent.find('.close'), layout = matchMedia('(max-width: 480px)').matches ? 'sp' : 'pc' var forceClose = function(){ menuContent.animate({ bottom: 0 }, 400, 'easeOutQuart'); menu.removeClass('open'); menuText.text('MENU'); overlay.hide(); } menu.on('click', function(e) { e.preventDefault(); var menuHeight = menuContent.outerHeight(); if(!menu.hasClass('open')){ menuContent.animate({ bottom: -menuHeight }, 400, 'easeOutQuart'); menu.addClass('open'); overlay.show(); menuText.text('close'); } else { forceClose(); } }); //menuContentAnchor.on('click', forceClose); closeBtn.on('click', forceClose); overlay.on('click', forceClose); // Current Nav function curNav(){ if(window.matchMedia('(min-width: 481px)').matches){ var nav = $('header .menu-global > li:visible').add('header .menu-group-sub li:visible'), urlReg = new RegExp(document.URL.replace(/https?:\/\/.*?\//,'/').replace(/index\.html?/,'').replace(/(\/.*?\/).*/,'')), dir1 = RegExp.$1; if(dir1 !== ''){ nav.each(function(i){ if($('>a',this).attr('href').match(dir1)){ //restore 1st directory $('>a',this).addClass('active'); } }); } } }; curNav(); $(window).on('resize.h', function(){ if(matchMedia('(max-width: 480px)').matches && layout === 'pc'){ layout = 'sp'; forceClose(); } else if(matchMedia('(min-width: 481px)').matches && layout === 'sp'){ layout = 'pc'; forceClose(); curNav(); } }); }); // Tab $(function(){ function Tab(el){ this.nav = el.find('.tabs-menu-container > div'); this.content = el.find('.tabs-content'); this.el = el; this.margin = 20; this.init(); }; Tab.isTabIndexEnabled = /tabIndex=(.*?)(&|$)/.test(location.href); Tab.prototype.init = function(){ try{ var activeTab = this.nav.find('.active'); this.switchTab = $.proxy(this.switchTab,this); if (activeTab.length !== 2 || (activeTab[0].getAttribute('data-rel') !== activeTab[1].getAttribute('data-rel')) || this.nav.length / 2 !== this.content.length){ throw 'Initialization Error'; } else{ this.el.on('click','.tabs-menu-container a',this.switchTab); this.switchTab(); } }catch(e){ this.content.eq(0).html('
' + e + '
').show(); } }; Tab.prototype.switchTab = function(ev){ var _this = this, attr = ev ? ev.currentTarget.getAttribute('data-rel') : Tab.isTabIndexEnabled ? 'tab-' + location.search.match(/tabIndex=(.*?)(&|$)/)[1] : this.nav.find('.active')[0].getAttribute('data-rel'); $('>a',this.nav).removeClass('active'); this.content.each(function(i,e){ if(e.getAttribute('data-rel') === attr){ _this.nav.parent().find('[data-rel="' + attr + '"]').addClass('active'); $(e).show(); } else{ $(e).hide(); } }); // Scroll if((Tab.isTabIndexEnabled || typeof ev !== 'undefined') && ($(window).scrollTop() + this.margin > this.el.offset().top || $(window).scrollTop() + this.margin < this.el.offset().top)){ if(Tab.isTabIndexEnabled && !Tab.firstInit){ $(window).on('load.tab',function(){ _this.scroll(); Tab.firstInit = true; }); } else{ this.scroll(); } } }; Tab.prototype.scroll = function(){ $('html,body').animate({ scrollTop: $('body.bodyPc')[0] ? this.el.offset().top - this.margin : this.el.offset().top - $('header').height() - this.margin },400,'easeOutExpo'); }; //Initialize if($('.tabs-container').length >= 1){ $('.tabs-container').each(function(){ this.tab = new Tab($(this)); }); } }); /* * jquery-match-height 0.7.0 by @liabru * http://brm.io/jquery-match-height/ * License MIT */ !function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=-1,o=-1,i=function(t){return parseFloat(t)||0},a=function(e){var o=1,a=t(e),n=null,r=[];return a.each(function(){var e=t(this),a=e.offset().top-i(e.css("margin-top")),s=r.length>0?r[r.length-1]:null;null===s?r.push(e):Math.floor(Math.abs(n-a))<=o?r[r.length-1]=s.add(e):r.push(e),n=a}),r},n=function(e){var o={ byRow:!0,property:"height",target:null,remove:!1};return"object"==typeof e?t.extend(o,e):("boolean"==typeof e?o.byRow=e:"remove"===e&&(o.remove=!0),o)},r=t.fn.matchHeight=function(e){var o=n(e);if(o.remove){var i=this;return this.css(o.property,""),t.each(r._groups,function(t,e){e.elements=e.elements.not(i)}),this}return this.length<=1&&!o.target?this:(r._groups.push({elements:this,options:o}),r._apply(this,o),this)};r.version="0.7.0",r._groups=[],r._throttle=80,r._maintainScroll=!1,r._beforeUpdate=null, r._afterUpdate=null,r._rows=a,r._parse=i,r._parseOptions=n,r._apply=function(e,o){var s=n(o),h=t(e),l=[h],c=t(window).scrollTop(),p=t("html").outerHeight(!0),d=h.parents().filter(":hidden");return d.each(function(){var e=t(this);e.data("style-cache",e.attr("style"))}),d.css("display","block"),s.byRow&&!s.target&&(h.each(function(){var e=t(this),o=e.css("display");"inline-block"!==o&&"flex"!==o&&"inline-flex"!==o&&(o="block"),e.data("style-cache",e.attr("style")),e.css({display:o,"padding-top":"0", "padding-bottom":"0","margin-top":"0","margin-bottom":"0","border-top-width":"0","border-bottom-width":"0",height:"100px",overflow:"hidden"})}),l=a(h),h.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||"")})),t.each(l,function(e,o){var a=t(o),n=0;if(s.target)n=s.target.outerHeight(!1);else{if(s.byRow&&a.length<=1)return void a.css(s.property,"");a.each(function(){var e=t(this),o=e.attr("style"),i=e.css("display");"inline-block"!==i&&"flex"!==i&&"inline-flex"!==i&&(i="block");var a={ display:i};a[s.property]="",e.css(a),e.outerHeight(!1)>n&&(n=e.outerHeight(!1)),o?e.attr("style",o):e.css("display","")})}a.each(function(){var e=t(this),o=0;s.target&&e.is(s.target)||("border-box"!==e.css("box-sizing")&&(o+=i(e.css("border-top-width"))+i(e.css("border-bottom-width")),o+=i(e.css("padding-top"))+i(e.css("padding-bottom"))),e.css(s.property,n-o+"px"))})}),d.each(function(){var e=t(this);e.attr("style",e.data("style-cache")||null)}),r._maintainScroll&&t(window).scrollTop(c/p*t("html").outerHeight(!0)), this},r._applyDataApi=function(){var e={};t("[data-match-height], [data-mh]").each(function(){var o=t(this),i=o.attr("data-mh")||o.attr("data-match-height");i in e?e[i]=e[i].add(o):e[i]=o}),t.each(e,function(){this.matchHeight(!0)})};var s=function(e){r._beforeUpdate&&r._beforeUpdate(e,r._groups),t.each(r._groups,function(){r._apply(this.elements,this.options)}),r._afterUpdate&&r._afterUpdate(e,r._groups)};r._update=function(i,a){if(a&&"resize"===a.type){var n=t(window).width();if(n===e)return;e=n; }i?-1===o&&(o=setTimeout(function(){s(a),o=-1},r._throttle)):s(a)},t(r._applyDataApi),t(window).bind("load",function(t){r._update(!1,t)}),t(window).bind("resize orientationchange",function(t){r._update(!0,t)})}); // matchHeight $(function() { $('.list-menu-1 .name').matchHeight(); $('.list-menu-1 .cat > div > div').matchHeight({byRow: false}); $('.list-menu-2 .txt').matchHeight(); $('.list-menu-2 .cat > div > div').matchHeight({byRow: false}); $('.list-menu-3 .txt').matchHeight(); $('.list-menu-3 .name').matchHeight(); $('.btn-box-list > li > a').matchHeight(); if(window.matchMedia('(max-width: 480px)').matches){ $('.list-articles .desc .ttl,.list-articles .desc .txt,.list-campaign .desc .ttl,.list-campaign .desc .cat > div > div').matchHeight({remove:true}); } else if(window.matchMedia('(min-width: 481px)').matches){ $('.list-articles .desc .ttl,.list-campaign .desc .ttl').matchHeight(); $('.list-articles .desc .txt,.list-campaign .desc .cat > div > div').matchHeight({byRow: false}); } $(window).on('resize.mh', function(){ if(window.matchMedia('(max-width: 480px)').matches){ $('.list-articles .desc .ttl,.list-articles .desc .txt,.list-campaign .desc .ttl,.list-campaign .desc .cat > div > div').matchHeight({remove:true}); } else if(window.matchMedia('(min-width: 481px)').matches){ $('.list-articles .desc .ttl,.list-campaign .desc .ttl').matchHeight(); $('.list-articles .desc .txt,.list-campaign .desc .cat > div > div').matchHeight({byRow: false}); } }); }); /*========= Set SNS =========*/ /* share URL */ var targetURL = window.location.href; /* tweet text */ var enc_title = encodeURIComponent($('title').html()); $('a#ft_tw,a#title_tw').attr('href','https://twitter.com/share?text=' + enc_title + '&url=' + targetURL); $('a#ft_fb,a#title_fb').attr('href','https://www.facebook.com/share.php?u=' + targetURL); /*========= Set SNS =========*/ /*========= Set Print =========*/ $('.page-print').on('click',function(){ window.print(); return false; }); /*========= Set Print =========*/ //EOF