var DD = {}; (function($, ns, _w, _d) { 'use strict'; var $w = $(_w), $d = $(_d); ns.id = []; $(readyHandler); function readyHandler() { ns.id = $('#DdId').data('ddid').split('--'); if(ns.id[0] === 'home'){ ddNav('design'); inView($('.dd-card__desc'), true); loadMainVisual(false); }else if(ns.id[0] === 'archives'){ ddNav(); inView($('.dd-card__desc'), true); }else if(ns.id[0] === 'category'){ ddNav(ns.id[1]); inView($('.dd-card__desc'), true); if(ns.id[2] === 'entry'){ inView($('.img, .embed'), false); shareBtn(); } }else if(ns.id[0] === 'tag'){ ddNav(); inView($('.dd-card__desc'), true); }else if(ns.id[0] === 'about-us'){ ddNav(ns.id[0]); loadMainVisual(true); $('.video--youtube').modalVideo(); }else if(ns.id[0] === 'history'){ ddNav(ns.id[0]); inView($('.dd-history__unit'), true); if(ns.id[1] === 'article'){ inView($('.img'), false); ddHistoryNav(ns.id[2]); } } } function ddNav(path) { var $header = $('#DdHeader'); $('#NavSwicthBtn').on('click', function(){ $('#Dd').toggleClass('dd-header__clone-nav--open'); }).after('
' + $header.find('.dd-header__nav').html() + '
'); $d.on('click touchstart', '.dd-header__clone-nav--open', function(e){ if(e.target.className.indexOf('nav--open') != -1 ) $(this).removeClass('dd-header__clone-nav--open'); }); if(path) $header.find('a[href$="' + path + '"]').addClass('is-active'); } function loadMainVisual(branch) { $('#loadingTarget').imagesLoaded( { background: true }, function() { if(branch){ $('#loading').delay(500).fadeOut(1000).parent().addClass('loaded'); }else{ $('#loading').delay(500).fadeOut(1000).parent().addClass('loaded').delay(2000).queue(function() { $(this).addClass('loop-mode').dequeue(); }); var swiperSettings = { mode: 'horizontal', pagination: '.dd-slide__pagination', prevButton: '.dd-slide__prev-btn', nextButton: '.dd-slide__next-btn', speed: 600, autoplay: 10000, spaceBetween: 0, slidesPerView: 1, autoplayDisableOnInteraction: false, resizeReInit: true, paginationClickable: true, loop: true }; swiperSettings = new Swiper('#swiper', swiperSettings); } }); } function inView(selector, difference) { var _i = 0; selector.each(function() { var $this = $(this); $this.one('inview', function(){ if(difference){ setTimeout(function() { $this.addClass('is-active'); _i = 0; }, 250 * _i ); _i++; }else{ $this.addClass('is-active'); } }); }); } function shareBtn() { $('.dd-share__btn').each(function(){ var SHAREURL = encodeURIComponent(_w.location.href), WINDOWNAME = ''; if(this.id === "share--facebook"){ SHAREURL = "https://www.facebook.com/sharer/sharer.php?u=" + SHAREURL; WINDOWNAME = 'FBwindow'; }else if(this.id === "share--twitter"){ SHAREURL = "https://twitter.com/intent/tweet?text=" + encodeURIComponent(_d.title.replace(/ \| /g,'|').split('|')[0]) + "&url=" + SHAREURL; WINDOWNAME = 'tweetwindow'; }else if(this.id === "share--hatenabookmark"){ SHAREURL = "http://b.hatena.ne.jp/entry/" + SHAREURL; WINDOWNAME = 'hatenawindow'; }else if(this.id === "share--pocket"){ SHAREURL = "https://getpocket.com/edit.php?url=" + SHAREURL; WINDOWNAME = 'pocketwindow'; }else if(this.id === "share--gplus"){ SHAREURL = "https://plus.google.com/share?url=" + SHAREURL; WINDOWNAME = 'googlewindow'; } $(this).wrap(''); }); } function ddHistoryNav(path) { if(path) $('#DdHistoryNav').find('a[href$="' + path + '"]').addClass('is-active'); } })(jQuery, DD, this, this.document);