// var mySwiper = new Swiper('#frontpage .swiper-container', { // loop: true, // autoplay:4500, // speed: 1700, // effect: 'fade', // // pagination: '.swiper-pagination', // // nextButton: '.swiper-button-next', // // prevButton: '.swiper-button-prev', // }) jQuery(function(){ var mySwiperAnim = function() { var el1 = document.querySelector('.swiper-wrapper .swiper-slide-active .swiper-img.display-sp'); var el2 = document.querySelector('.swiper-wrapper .swiper-slide-active .swiper-img.display-pc'); var anim = document.querySelectorAll('.is-anim'); for (var i = 0; i < anim.length; i++ ) { anim[i].classList.remove('is-anim'); } el1.classList.add('is-anim'); el2.classList.add('is-anim'); }; // window.addEventListener('DOMContentLoaded', function() { var swiper01 = new Swiper('#frontpage .swiper-container', { autoplay:5500, autoplayDisableOnInteraction: false, noSwiping: true, noSwipingClass: 'swiper-slide', speed: 1700, effect: 'fade', loop: true, onInit: function(i) { mySwiperAnim(); }, onSlideChangeEnd: function(i) { mySwiperAnim(); } }); // }, false); var windowWidth = window.innerWidth; // ブラウザ幅を取得 var countup_flg = 0; // if( 992 > windowWidth){ /* *************************************************************************************** * スマホの処理 *************************************************************************************** */ var stopScroll = function( event ){ // スクロール停止用 for iOS event.preventDefault(); } /* グロナビ */ jQuery('#nav_toggle').click(function(){ // ハンバーガーアイコンがタップされたら var headerHeight = jQuery('.l-header-inner').innerHeight(); jQuery('.l-header').toggleClass('open'); // openクラスを付与しハンバーガーアイコンのアニメーション制御 jQuery('.l-nav-menu').stop().fadeToggle(600); // グロナビを表示制御 if (jQuery('.l-header').hasClass('open')) { // OPEN var url = location.href; if(url == "https://aka-yokohama.com/"){ jQuery('.l-header-full').css('background', 'url(https://aka-yokohama.com/wp-content/themes/aka/img/l-header-inner_bg.jpg)'); // グロナビの背景設定 } jQuery('.l-header-full').css('height', headerHeight); jQuery('.l-nav-menu').css('top', headerHeight); jQuery('.l-header').css({'overflow-y':'hidden','position':'fixed','top':'0','z-index':'99'}); // スクロールを停止する jQuery('.globalNav > ul').css('height','calc(100vh - ' + headerHeight + 'px)'); // window.addEventListener( 'touchmove' , stopScroll , { passive: false } ); // スクロールを停止する for iOS jQuery('.l-wrapper').on('touchmove.scroll', function(event) {event.preventDefault();}); } else { // CLOSE jQuery('.l-header-full').css('background', 'none'); // グロナビの背景削除 jQuery('.l-header').css({'overflow-y':'unset','position':'static','z-index':'0'}); // スクロールの停止を解除 //window.removeEventListener( 'touchmove' , stopScroll, { passive: false } );// スクロールの停止を解除 for iOS jQuery('.l-wrapper').off('touchmove.scroll'); } }); jQuery(window).on('load resize', function(){ var headerHeight = jQuery('.l-header-inner').innerHeight(); // ヘッダーの高さを取得 // jQuery('#subpage .l-nav-menu').css('top', headerHeight - 1 + 'px'); // グロナビ アコーディオンの開始位置を指定 // jQuery('#subpage .l-header-full, #subpage l-header').css('height', headerHeight + 'px'); jQuery('.l-header-full').css('height', headerHeight); var resizeWidth = window.innerWidth; if( 992 <= resizeWidth){ jQuery('.l-header').css({'overflow-y':'unset','position':'relative'}); jQuery('.l-header-full').css('background', 'none'); jQuery('.l-nav-menu').css('top', '-46px'); jQuery('.globalNav > ul').css('height','auto'); } else { jQuery('.l-nav-menu').css('top', '74px'); } }); // } else { /* *************************************************************************************** * PCの処理 *************************************************************************************** */ /* グロナビ hover時に2階層目表示 */ jQuery('.drop').hover(function(){ jQuery(this).find('ul').stop().slideDown(); }, function(){ jQuery(this).find('ul').stop().slideUp(); }); // } jQuery('a[href^="#"]').click(function(event) { var speed = 400; var href= jQuery(this).attr("href"); var target = jQuery(href == "#" || href == "" ? 'html' : href); var position = target.offset().top; jQuery('body,html').animate({scrollTop:position}, speed, 'swing'); return false; }); var startPos = 0, scroll = 0; var userAgent = window.navigator.userAgent.toLowerCase(); jQuery(window).on('scroll load', function(){ if( 992 > windowWidth){ // SP var look = 30; } else { // PC var look = 70; } jQuery('.fadein').each(function(){ var elemPos = jQuery(this).offset().top; var scroll = jQuery(window).scrollTop(); var windowHeight = jQuery(window).height(); if (scroll > elemPos - windowHeight + look){ jQuery(this).addClass('scrollin'); if(jQuery(this).hasClass('c-distributionArea-box')){ countup(); countup_flg = 1; } } }); /////////////////////////////////////////////////////////////////////// totopボタン var jQuerytotopBtn = jQuery('.l-page-top'); // totopボタン var scroll = jQuery(window).scrollTop(); // スクロール量(0から) var scrollPosition = jQuery(window).height() + scroll; // スクロール量(=ブラウザの高さ + スクロール量(0から)) var pageHeight = jQuery('body').innerHeight(); // ページ全体の高さ var footHeight = jQuery('footer').innerHeight(); // footerの高さ(=止めたい位置) var btnHeight= jQuerytotopBtn.innerHeight(); // totopボタンの高さ var footerArea = pageHeight - footHeight; // フッター開始位置(ページの高さ - フッターの高さ) if (scroll <= 150 ){ // スクロール量が150以内なら jQuerytotopBtn.fadeOut(); } else if (footerArea <= scrollPosition) { // スクロール量がフッター開始位置以上になったら jQuerytotopBtn.css({ 'display' : 'block', 'position' : 'absolute', 'bottom': footHeight - btnHeight }); } else { // スクロール量が150~フッター開始位置以内 if (userAgent.indexOf("trident/7.0") > -1) { jQuerytotopBtn.css({ 'display' : 'block', // 'bottom': '20px', 'bottom': '0px', 'position':'fixed' }); } else { if (scroll >= startPos) { jQuerytotopBtn.css({ 'display' : 'none', // 'bottom': '20px', 'bottom': '0px', 'position':'fixed' }); } else { if(jQuery('body').hasClass('price-area') && jQuery('#price-disp').hasClass('open')) { var topBtnP = jQuery('#price-disp').outerHeight(); jQuerytotopBtn.css({ 'display' : 'block', // 'bottom': '20px', 'bottom': topBtnP + 'px', 'position':'fixed', 'opacity':'0.7' }); } else { jQuerytotopBtn.css({ 'display' : 'block', // 'bottom': '20px', 'bottom': '0px', 'position':'fixed', 'opacity':'1' }); } } } } startPos = scroll; }); /////////////////////////////////// 猫アニメーション jQuery('.cat').each(function(index){ var width = jQuery('.c-distributionArea-bg').innerWidth() - 50; var height = jQuery('.c-distributionArea-bg').height() - 40; var left = 50 + Math.floor(Math.random() * width); var top = 40 + Math.floor(Math.random() * height); var index = index+1; jQuery('.cat_'+index).css({left:left+'px',top:top+'px'}); }) cat(); function cat(){ var width = jQuery('.c-distributionArea-bg').innerWidth() - 50; var height = jQuery('.c-distributionArea-bg').height() - 40; jQuery('.cat').each(function(index){ var left = 50 + Math.floor(Math.random() * width); var top = 40 + Math.floor(Math.random() * height); var index = index+1; var muth = 18000 + Math.floor(Math.random() * 30000); jQuery('.cat_'+index).animate({left:left+'px',top:top+'px'}, muth); }) setTimeout(cat,10000) } setInterval(cat,10000); /* トップページ「ポスティング配布目標」カウントアップ*/ function countup() { if (countup_flg == '0') { jQuery('.count').each(function () { jQuery(this).prop('c',0).animate({ c: jQuery(this).text() },{ duration: 1500, easing: 'linear', step: function (now) { jQuery(this).text(Math.ceil(now).toLocaleString()); } }); }); } } if(jQuery('body').hasClass('price-area')) { // if (document.referrer == 'https://aka-yokohama.com/inquiry-estimate/'){ // document.location.reload() // } // jQuery(window).load(function(){ // console.log('7777'); //window.location.reload(); // }); var jQuerypriceList = jQuery('#price-list'), jQuerypriceBtn = jQuery('#priceBtn'), jQuerypaperSize = jQuery('#paper-size'), size = jQuery('#size').val(); // 選択した紙のサイズを取得 //calcFlg = 0; calcPrice(); jQuery('#price_submit').prop('disabled',true); var price_submit_flg = 0; jQuery('.total-btn').on("click", function(){ if (jQuery('#price_submit').prop('disabled') != false){ jQuery('#price_submit').removeClass('cursor-change'); jQuery('#price_submit').addClass('blinking'); // setTimeout("jQuery('#price_submit').removeClass('blinking')", 2800); // setTimeout("jQuery('#price_submit').removeClass('blinking')", 6860); setTimeout("jQuery('#price_submit').removeClass('blinking')", 8850); jQuery('#price_submit').removeClass('transparent'); jQuery('#price_submit').prop('disabled',false); } size = jQuery('#size').val(); calcPrice(); if(!jQuerypriceList.hasClass('open')) { jQuerypriceList.stop().addClass('open'); jQuerypriceList.stop().fadeIn(); getPoint(); jQuery('#price-disp').hide(); } jQuery("html,body").animate({scrollTop:jQuerypriceBtn.offset().top}); }); jQuery('.area-list input, .ctl-select select').on("change", function(){ jQuerypaperSize = jQuery('#paper-size'), size = jQuery('#size').val(); // 選択した紙のサイズを取得 calcPrice(); }); function calcPrice() { // 選択したサイズの単価取得 + お見積り結果の「紙のサイズ」の値を変更 jQuerypaperSize.empty(); if (size == 'A3') { jQuerypaperSize.append('A3(297 × 420mm)'); var price_k = data['A3_k']; price_z = data['A3_z']; price_s = data['A3_s']; } else if (size == 'A4') { jQuerypaperSize.append('A4(210 × 297mm)'); var price_k = data['A4_k']; price_z = data['A4_z']; price_s = data['A4_s']; } else if (size == 'A5') { jQuerypaperSize.append('A5(148 × 210mm)'); var price_k = data['A5_k']; price_z = data['A5_z']; price_s = data['A5_s']; } else if (size == 'B3') { jQuerypaperSize.append('B3(364 × 515mm)'); var price_k = data['B3_k']; price_z = data['B3_z']; price_s = data['B3_s']; } else if (size == 'B4') { jQuerypaperSize.append('B4(257 × 364mm)'); var price_k = data['B4_k']; price_z = data['B4_z']; price_s = data['B4_s']; } else if (size == 'B5') { jQuerypaperSize.append('B5(182 × 257mm)'); var price_k = data['B5_k']; price_z = data['B5_z']; price_s = data['B5_s']; } else { jQuerypaperSize.append('A3(297 × 420mm)'); var price_k = data['A3_k']; price_z = data['A3_z']; price_s = data['A3_s']; } document.getElementById("size").selectedIndex = sessionStorage.getItem('selectNo'); // 各エリアの配布枚数を取得(※チェックされたエリアのみ) var total_z = Number(0), total_k = Number(0), total_s = Number(0); jQuery('.amount_z').each(function() { var result = jQuery(this).prevAll('#starPoint .check_flg').children('input').prop('checked'); if(result) { total_z = total_z + Number(jQuery(this).text()); } }); jQuery('.amount_k').each(function() { var result = jQuery(this).prevAll('#starPoint .check_flg').children('input').prop('checked'); if(result) { total_k = total_k + Number(jQuery(this).text()); } }); jQuery('.amount_s').each(function() { var result = jQuery(this).prevAll('#starPoint .check_flg').children('input').prop('checked'); if(result) { total_s = total_s + Number(jQuery(this).text()); } }); // お見積り結果に料金を表示 var zYen = (total_z * price_z).toLocaleString() + '円', kYen = (total_k * price_k).toLocaleString() + '円', sYen = (total_s * price_s).toLocaleString() + '円', zSheet = total_z.toLocaleString() + '枚', kSheet = total_k.toLocaleString() + '枚', sSheet = total_s.toLocaleString() + '枚'; jQuery('#price-z').html(zYen); jQuery('#price-k').html(kYen); jQuery('#price-s').html(sYen); jQuery('#sum-z, #total-z').html(zSheet); jQuery('#sum-k, #total-k').html(kSheet); jQuery('#sum-s, #total-s').html(sSheet); jQuery('#setEstimate input[name="z_price"]').val(zYen); jQuery('#setEstimate input[name="k_price"]').val(kYen); jQuery('#setEstimate input[name="s_price"]').val(sYen); jQuery('#setEstimate input[name="z_total"]').val(zSheet); jQuery('#setEstimate input[name="k_total"]').val(kSheet); jQuery('#setEstimate input[name="s_total"]').val(sSheet); jQuery('#setEstimate input[name="size"]').val(jQuery('#size').val()); // 選択したエリアを取得 var arrayGroup = ''; jQuery('#starPoint .area-list_table_inner tr').each(function(index) { if (jQuery(this).children('.pt_area').text() !== '地域名') { if(jQuery(this).children('.check_flg').children('input').prop('checked')) { var checkFlg = 1; } else { var checkFlg = 0; } var arrayItem = [ checkFlg, jQuery(this).children('.pt_area').text(), jQuery(this).children('.amount_z').text(), jQuery(this).children('.amount_k').text(), jQuery(this).children('.amount_s').text() ] //arrayGroup.push(arrayItem); arrayGroup += arrayItem + '|'; } }); arrayGroup = arrayGroup.slice(0, -1); jQuery('#setEstimate input[name="selected_town"]').val(arrayGroup); /*** 印刷画面のテーブル作成 ここから ***/ // 選択したエリアのtr以下を取得 var addArea = []; jQuery('#starPoint .check_flg input').each(function() { if(jQuery(this).prop('checked')) { // console.log(jQuery(this).closest('tr').html()); // var test = jQuery(this).closest('tr'); // test.find('.price_checkbox').remove(); // console.log(test.html()); addArea.push('' + jQuery(this).closest('tr').html() + ''); } }); var turnPoint = Math.ceil(jQuery(addArea).length / 2); // 折り返しポイント取得(印刷画面のテーブル作成) jQuery('#printTableInner').remove(); // 読み込みの度、印刷画面のテーブルを削除(印刷画面のテーブル作成) // ソース生成(印刷画面のテーブル作成) var tableSource = ''; tableSource = tableSource.replace(/type="checkbox" value="1"/g, 'type="checkbox" value="1" checked'); jQuery('#printTable').append(tableSource); // 印刷画面用テーブルのソースを設置 jQuery('#printTable').find('.price_checkbox').remove(); jQuery('#printTable').find('.check_flg').append(''); // 初期化 tableSource = ''; addArea = 0; /*** 印刷画面のテーブル作成 ここまで ***/ } var starPoint, endPoint, winH, resultH; function getPoint() { winH = jQuery(window).height(); starPoint = jQuery('#starPoint').offset().top - winH + jQuery('#price-disp').outerHeight(); endPoint = jQuery('.cmn-contact').offset().top - winH + jQuery('#price-disp').outerHeight(); } jQuery(window).on('load resize',function(){ getPoint(); }); jQuery(function() { var priceDisp = jQuery('#price-disp'); priceDisp.hide(); jQuery(window).scroll(function () { if (jQuery(this).scrollTop() > starPoint && endPoint > jQuery(this).scrollTop()) { priceDisp.slideDown(); priceDisp.addClass('open'); calcPrice(); } else { priceDisp.slideUp(); priceDisp.removeClass('open'); } }); }); } var pathname = location.pathname; if ( pathname.match(/area-price/) && 12 < pathname.length) { if (func_flg == 'off') { jQuery('.ctl-wrap').css('justify-content','space-around'); jQuery('.ctl-left,.ctl-center-btn').css('display','none'); jQuery('.area-list').append(jQuery('.ctl-wrap').prop('outerHTML')); } } // 見積ページ プリンター立ち上げ jQuery('#print').click(function(){ jQuery.when( size = jQuery('#size').val(), calcPrice() ) .done(function() { window.print() }) .fail(function() { // エラーがあった時 console.log('print error'); }); }); // グロナビ var baseUrl = location.protocol + '//' + location.hostname +'/'; // var pathname = pathname.replace(/\//g, ''); var pathname = pathname.slice(1).slice(0, -1); if (pathname) { jQuery('.l-nav-menu li a').each(function(){ var nodomain = jQuery(this).attr('href').replace(baseUrl, ''); if (nodomain == pathname) { jQuery(this).closest('li').addClass('active'); } }); } // videoタグの音量調整 jQuery('video').prop('volume',0.3); // 配布エリアと料金 チェックボックスをすべてチェック・すべて解除 var checkBtn = jQuery('.pt_select input'); jQuery('#all').on('click', function() { if (jQuery(this).prop('checked')) { allCheck(checkBtn); calcPrice(); } else { allRemove(checkBtn); calcPrice(); } }); jQuery(checkBtn).on('click', function() { if (jQuery('.pt_select input:not(:checked)').size() == 0) { allCheck('#all'); } else { allRemove('#all'); } }); function allCheck(value) { jQuery(value).prop('checked', true); jQuery('#all_label').text('全ての地域の選択を解除する'); } function allRemove(value) { jQuery(value).prop('checked', false); jQuery('#all_label').text('全ての地域を選択する'); } jQuery('area').hover(function() { // カーソルが当たった時の処理 jQuery(this).css("opacity", ".5"); }, function() { // カーソルが離れた時の処理 jQuery(this).css("opacity", "1"); }); }); jQuery(window).bind("pageshow", function() { jQuery(".area-list input").val(''); jQuery("#another_id").val(''); }); // 見積もりsession var targets = document.querySelectorAll('.price_checkbox'); var checkboxClick = function(){ var self = this; sessionStorage.setItem('input[data-price="' + self.getAttribute('data-price') + '"]', self.checked); }; Array.prototype.forEach.call(targets, function(e){ e.addEventListener('click', checkboxClick) }) var targetsSelect = document.querySelectorAll('#size'); var selectChange = function(){ var setSelectNo = this.selectedIndex; sessionStorage.setItem('selectNo', setSelectNo); var selectChangeNo = sessionStorage.getItem('selectNo'); document.getElementById('size').options[selectChangeNo].selected = true; }; Array.prototype.forEach.call(targetsSelect, function(e){ e.addEventListener('change', selectChange) }) var addSessionStorage = function() { var session = sessionStorage; Object.keys(session).forEach(function(key){ if(key.indexOf('data-price') !== -1 && this[key] === 'true' && document.querySelector(key) !== null) { document.querySelector(key).checked = true; } }, session) } window.addEventListener('load', addSessionStorage); if (!jQuery('body').hasClass('price-area') && !jQuery('body').hasClass('inquiry-estimate')){ sessionStorage.clear(); } else if (jQuery('body').hasClass('thanks')) { sessionStorage.clear(); }