$(function() { smartRollover(); opacityRollover(); externalLink(); smoothScroll(); smoothScroll2(); pulldownSet(); }); /* violation ============================================================================================================ */ function violation() { $('.violation button').click(function(){ $(this).parent().html('

送信しました。

'); return false; }); } /* smartRollover ============================================================================================================ */ function smartRollover() { var imgCount = 0; var images_pre = new Array(); $('img[src*="_off."],input[src*="_off."]').each (function(){ images_pre[imgCount] = new Image(); images_pre[imgCount].src = $(this).attr("src").replace("_off.", "_on."); $(this).hover( function () { $(this).attr("src", $(this).attr("src").replace("_off.", "_on.")); }, function () { $(this).attr("src", $(this).attr("src").replace("_on.", "_off.")); } ); imgCount ++; }); } /* opacityRollover ============================================================================================================ */ function opacityRollover() { $('img[src*="_op."],input[src*="_op."]').hover( function () { $(this).css('opacity', 0.7); }, function () { $(this).css('opacity', 1); } ); } /* externalLink ============================================================================================================ */ function externalLink() { var notBlank = new Array(""); var n = ""; for (var i = 0; i < notBlank.length; i ++) if(notBlank[i]) n += ":not([href*='" + notBlank[i] + "'])"; if(document.domain) n += ":not([href*='" + document.domain + "'])"; $("a[rel='external'], a[href$='.pdf']").attr("target", "_blank"); $("a[href^=http]"+n).attr("target", "_blank"); if(!location.href.match(/^http/)){ $("a[href$='/']").not("a[href^='http']").each( function(){ $(this).attr('href', $(this).attr('href') + 'index.html'); }); $("a[href*='/#']").not("a[href^='http'],a[href$='.html']").each( function(){ var n = $(this).attr('href').lastIndexOf("/#") + 1; $(this).attr('href', $(this).attr('href').substring(0, n) + 'index.html' + $(this).attr('href').substring(n)); }); } } /* smoothScroll ============================================================================================================ */ function smoothScroll() { $('a[href^="#"], a[href^="' + location.pathname + '#"]').each (function(){ var hash = this.hash; if(hash.length > 1 && !this['rel']){ $(this).click(function() { goScroll(hash); return false; }) } }); } function goScroll(hash) { var hdheight = 1000; var target = $(hash).offset().top-hdheight; $(($.browser.safari) ? 'body' : 'html') // $(/safari/i.test(window.navigator.userAgent) ? 'body' : 'html') .animate({scrollTop: target >= 15 ? target - 15 : target}, 600, 'swing', function(){$(this).unbind("mousewheel DOMMouseScroll");}) .bind("mousewheel DOMMouseScroll",function(){ $(this).queue([]).stop(); $(this).unbind("mousewheel DOMMouseScroll"); }) } /* smoothScroll2 (別ページからのリンク) ============================================================================================================ */ function smoothScroll2() { var windowWidth = $(window).width(); var windowSm = 640; if (windowWidth <= windowSm) { //横幅640px以下のとき(つまりスマホ時)に行う処理を書く $(window).on('load', function() { var url = $(location).attr('href'); if(url.indexOf("?id=") != -1){ var id = url.split("?id="); var $target = $('#' + id[id.length - 1]); if($target.length){ var pos = $target.offset().top-51; $("html, body").animate({scrollTop:pos}, 500); } } }); } else { //横幅640px超のとき(タブレット、PC)に行う処理を書く $(window).on('load', function() { var url = $(location).attr('href'); if(url.indexOf("?id=") != -1){ var id = url.split("?id="); var $target = $('#' + id[id.length - 1]); if($target.length){ var pos = $target.offset().top-70; $("html, body").animate({scrollTop:pos}, 500); } } }); } } /* pulldownSet ============================================================================================================ */ function pulldownSet() { var t; var h = $('#NaviWrap > div > ul > li:eq(2)'); var hi = $('ul', h); setPull(h); function setPull(ele) { ele.hover( function(){ clearTimeout(t); if(hi.queue().length < 1) hi.slideDown(300); }, function(){ t = setTimeout(function() { hi.slideUp(300); }, 500); } ); } } /* pay.php ============================================================================================================ */ $(function() { $('.pricing .selectable .box-plan').on('click', function() { var planElm = $(this).closest('.box-plan'); $('.box-plan', $(this).closest('.plans')).removeClass('active'); planElm.addClass('active'); $('input[name=money]', planElm).prop('checked', true); $('input[name=price]', planElm).prop('checked', true); $('input[name=option]', planElm).prop('checked', true); $('input[name=rebill_param_id]', planElm).prop('checked', true); $('input[name=plan]', planElm).prop('checked', true); }); }); /* validation ============================================================================================================ */ $(function() { var input = $('input[type=email]').get(0); if (!input) return; input.addEventListener('invalid', function(e) { if(input.validity.valueMissing){ e.target.setCustomValidity("メールアドレスを入力してください。"); } else if(!input.validity.valid) { e.target.setCustomValidity("メールアドレスの形式が正しくありません。"); } }, false); }); /* imagePopup ============================================================================================================ */ $(window).on('load', function() { addPopupHandler($('img.popup')); $('.image-popup-overlay').on('click', function() { $('.popup-image', this).attr('src', ''); $(this).hide(); }); }) function addPopupHandler(img) { $(img).on('click', function() { var outer = $('.image-popup-overlay'), src = $(this).attr('popup-src'); src = src || $(this).attr('src'); $('.popup-image', outer).attr('src', src); $('.popup-image', outer).attr('imgId', $(img).attr('imgId')); outer.fadeIn().fadeIn(); }); }