/** * COMMON */ var COMMON = { base_url:'http://www.yk-harekei.jp/', windowS:599, windowM:959, windowL:960, }; /** * COMMON getの取得 */ COMMON.GetQueryString = function(){ var result = {}; if( 1 < window.location.search.length ){ var query = window.location.search.substring(1); var parameters = query.split('&'); for( var i = 0; i < parameters.length; i++ ){ var element = parameters[ i ].split('='); var paramName = decodeURIComponent(element[0]); var paramValue = decodeURIComponent(element[1]); result[ paramName ] = paramValue; } } return result; } /** * COMMON オーバーレイロードスタート */ COMMON.overlayLoadStart = function(){ var h = $(window).height(); $('#overlay-loader-bg ,#overlay-loader').height(h).css("display","block"); } /** * COMMON オーバーレイロードコンプリート */ COMMON.overlayLoadComplete = function(){ $('#overlay-loader-bg ,#overlay-loader').delay(300).fadeOut(100); } /** * userAgent */ COMMON.getUA = (function(){ var ua = navigator.userAgent; if(ua.indexOf('iPhone') > 0 || ua.indexOf('iPod') > 0 || ua.indexOf('Android') > 0 && ua.indexOf('Mobile') > 0){ return 'sp'; }else if(ua.indexOf('iPad') > 0 || ua.indexOf('Android') > 0){ // }else if(ua.indexOf('iPad') > 0){ return 'tab'; }else{ return 'pc'; } })(); /** * 汎用 localstrage * @param {String} app 保存元名 */ COMMON.MyStrage = function(app){ if(typeof localStorage === 'undefind'){ return false; } this.app = app; this.storage = localStorage; this.data = JSON.parse(this.storage[this.app] || '{}'); } COMMON.MyStrage.prototype = { getItem:function(key){ return this.data[key]; }, setItem:function(key,value){ this.data[key] = value; }, //保存 save:function(){ this.storage[this.app] = JSON.stringify(this.data); } } /** * COMMON Slick セット * @return void */ COMMON.setResponsiveSlick = function(pc_num,ipn_num,tablet_num,elem){ 'use strict'; var pc_num = typeof pc_num !== 'undefined' ? pc_num : 9; var ipn_num = typeof ipn_num !== 'undefined' ? ipn_num : 4; var tablet_num = typeof tablet_num !== 'undefined' ? tablet_num : 6; var elem = typeof elem !== 'undefined' ? elem : '.recent_slider'; $(elem).slick({ //dots: true, infinite: false, slidesToShow: pc_num, slidesToScroll: pc_num, responsive: [ { breakpoint: COMMON.windowL, settings: { slidesToShow: pc_num, slidesToScroll: pc_num, infinite: false, } }, { breakpoint: COMMON.windowM, settings: { slidesToShow: tablet_num, slidesToScroll: tablet_num } }, { breakpoint: COMMON.windowS, settings: { slidesToShow: ipn_num, slidesToScroll:ipn_num } } ] }); } /** *-------------------------------------------- * Responsive * * @return string *-------------------------------------------- */ function Responsive(){ 'use strict'; this.windowS = COMMON.windowS; this.windowM = COMMON.windowM; this.windowL = COMMON.windowL; this.window_type = null; this.switch_img = $('.js_switch_img'); this.switch_img_ipn = $('.js_switch_img_ipn'); this.img_sp = 'sp_'; this.img_pc = 'pc_'; this.img_ipn = 'ipn_'; } /** * Responsive 引数の関数を実行 * @return void */ Responsive.prototype.func = function( ipn_init_func, pc_init_func, tab_init_func ){ 'use strict'; var windowWidth = $(window).width(); //alert(windowWidth); //ipn if(windowWidth <= this.windowS && this.window_type != 'ipn'){ if(ipn_init_func !== undefined){ ipn_init_func(); } this.common_ipn_init(); this.window_type = "ipn"; //img_switch this.img_switch(this.img_pc,this.img_sp); this.img_switch_ipn(this.img_pc,this.img_ipn); //tab }else if (windowWidth > this.windowS && windowWidth <= this.windowM && this.window_type != 'tab'){ if(tab_init_func !== undefined){ tab_init_func(); } this.common_tablet_init(); this.common_ipn_init(); this.window_type = "tab"; //img_switch this.img_switch(this.img_pc,this.img_sp); this.img_switch_ipn(this.img_ipn,this.img_pc); //pc }else if(windowWidth > this.windowL && this.window_type != 'pc'){ if(pc_init_func !== undefined){ console.log("common_pc"); pc_init_func(); } this.common_pc_init(); this.window_type = "pc"; //switch img this.img_switch(this.img_sp,this.img_pc); this.img_switch_ipn(this.img_ipn,this.img_pc); } }; /** * common_pc_init * @return void */ Responsive.prototype.common_pc_init = function(){ 'use strict'; //js 読み込み var pc_common_js = document.createElement("script"); //src pc_common_js.src = COMMON.base_url + 'js/pc_common.js'; document.getElementsByTagName("body")[0].appendChild(pc_common_js); } /** * common_ipn_init * @return void */ Responsive.prototype.common_ipn_init = function(){ //js 読み込み $.when( $.getScript('http://www.harenchi.co.jp/js/lib/drawer.js'), $.getScript('http://www.harenchi.co.jp/js/lib/iscroll.js') //$.getScript('https://cdnjs.cloudflare.com/ajax/libs/iScroll/5.1.3/iscroll.min.js') ) .done(function(){ $(document).ready(function() { //drawer $('.body').drawer(); $(".popup-with-form").on("click",function(){ $('.body').drawer('close'); }); }); }) } /** * common_tablet_init * @return void */ Responsive.prototype.common_tablet_init = function(){ 'use strict'; } /** * img_switch * 画像切り替え * @return void */ Responsive.prototype.img_switch = function(elem1,elem2){ $(this.switch_img).each(function(){ var $this = $(this); $this.attr('src', $this.attr('src').replace(elem1,elem2)); }); } Responsive.prototype.img_switch_ipn = function(elem1,elem2){ $(this.switch_img_ipn).each(function(){ var $this = $(this); $this.attr('src', $this.attr('src').replace(elem1,elem2)); }); } $(document).on('touchstart.dropdown.data-api', '.drawer-drop-menu', function(e) { console.log("event"); e.stopPropagation() }); /*----------------------- 共通 ------------------------*/ jQuery(function($){ 'use strict'; var resp = new Responsive(); resp.func(); //over18 function over18Init(){ var over18_strage = new COMMON.MyStrage('over18'); if(!over18_strage.getItem('f')){ $('#over18-modal').modal('show'); $('#over18-modal .btn').on('click',function(){ if($(this).attr('data-over') === '1'){ over18_strage.setItem('f',1); over18_strage.save(); $('#over18-modal').modal('hide'); } else { location.assign("https://www.google.co.jp"); } }) } } //over18Init(); //lazy $('img.lazy').Lazy({ afterLoad: function(element) { //load.gif消す $(element).css('background-image','none'); }, }); /*----------------------- header form ------------------------*/ //サーチsubmit処理 $('.search_btn').on('click',function(event){ search_submit(); }); function search_submit(){ $('.search_form').on('submit', function(e){ e.preventDefault(); var query = $(this).serialize(); location.href = this.action + '?' + (function(){ var arr = []; $.each(query.split('&'), function(i, p){ if(p.split('=')[1]){ arr.push(p); } }); return arr.join('&'); })(); }); } //リサイズ $(window).resize(function($){ resp.func(); //navAreaHeight(); }); function navAreaHeight(){ $('.drawer-nav').height(window.innerHeight); } //shopselect $("#shopselect").change(function(){ $("#selectform").submit(); return false; }); //お気に入り var girls_favorite = Object.create(girlsFavorite); girls_favorite.init(); }); /** *-------------------------------------------- * STATUS * * @return void *-------------------------------------------- */ STATUS = { visEvent: null, } //visEvent STATUS.visEvent = new (function(){ var that = {}, task = []; that._init = function(){ $(window).on('resize.vis scroll.vis', function(e){ that._check(); }); return that; }; that._check = function(){ var _t = $(window).scrollTop(), _h = $(window).height(), _l = task.length; for (var i = _l - 1; i >= 0; i--) { var _pt = task[i].$t.offset().top, _ph = task[i].$t.outerHeight(); if (_t <= _pt + _ph && _pt <= _t + _h) { if (!task[i].s && (_pt <= _t + _h * task[i].p)) { task[i].s = true; task[i].func(true, task[i].$t); if (task[i].one == 1) { that.remove(task[i].$t); }; }; } else { if (task[i].s) { task[i].s = false; task[i].func(false, task[i].$t); }; }; }; }; that.add = function(t, f, p, b){ task.push({ $t: t, func: f, s: false, p: (p ? p : 1), one: (b ? b : 0) }); that._check(); }; that.remove = function(t){ for (var i = 0; i < task.length; i++) { if (task[i].$t == t) { task.splice(i, 1); return; }; }; }; return that._init(); });