$(function() { category = Array(); category['about_'] = Array(); category['about_'][0] = "ABOUT"; category['about_'][1] = "札幌の注文靴工房・靴作り教室「cagra」について"; category['about_'][2] = "ground"; category['about_'][3] = 0; category['about_'][4] = "about/"; category['about_'][5] = "about_"; category['order_'] = Array(); category['order_'][0] = "ORDER"; category['order_'][1] = "札幌の注文靴工房・靴作り教室「cagra」靴のご注文"; category['order_'][2] = "ground"; category['order_'][3] = 1; category['order_'][4] = "order/"; category['order_'][5] = "order_"; category['school_'] = Array(); category['school_'][0] = "SCHOOL"; category['school_'][1] = "札幌の注文靴工房・靴作り教室「cagra」靴作り教室のご案内"; category['school_'][2] = "ground"; category['school_'][3] = 2; category['school_'][4] = "school/"; category['school_'][5] = "school_"; category['gallery_'] = Array(); category['gallery_'][0] = "GALLERY"; category['gallery_'][1] = "札幌の注文靴工房・靴作り教室「cagra」靴の製作例です"; category['gallery_'][2] = "ground"; category['gallery_'][3] = 3; category['gallery_'][4] = "gallery/"; category['gallery_'][5] = "gallery_"; category['contact_'] = Array(); category['contact_'][0] = "CONTACT"; category['contact_'][1] = "札幌の注文靴工房・靴作り教室「cagra」お問い合わせはこちら"; category['contact_'][2] = "ground"; category['contact_'][3] = 4; category['contact_'][4] = "contact/"; category['contact_'][5] = "contact_"; page_category = Array(); var page_category_count = -1; function htmlEncode(value){ return $('
').text(value).html(); } function htmlDecode(value){ return $('
').html(value).text(); } function img_load_fade(){ $("img.preload:not('.loaded')").imagesLoaded(function(){ $(this).addClass("loaded"); }); } scroll_action_flag = false; root_site_title = "cagra|札幌の注文靴工房・靴作り教室"; history_counter = 0; past_href = location.href; memorize_scrolltop = $(window).scrollTop(); memorize_lastvisit = "root"; memorize_lasturl = location.href; profile_url = "about/"; now_viewing = ""; now_viewing_slsh_to_ub = "".replace( "/", "_" ); memorize_lastindex = ""; $(window).bind('load', function() { if( memorize_lastvisit == "entry" ){ scroll_action_flag = false; $("#entry > article").css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)}); $("div#entry").fadeIn(400); memorize_lastvisit_article_type = ""; }else if( memorize_lastvisit == "index" || memorize_lastvisit == "profile" ){ scroll_action_flag = false; var target_nav = $(".class_" + "".replace( "/", "_" ) + " a"); target_nav.parent("li").removeClass("over"); target_nav.parent("li").addClass("active"); target_nav.closest("li.parent").removeClass("over"); target_nav.closest("li.parent").addClass("p_active"); //article_type(ground・modal)の読み取り var article_type = $( "article#" + now_viewing_slsh_to_ub ).attr("class"); if( article_type.indexOf( "ground" ) != -1 ){ var scrollto = $('#' + now_viewing_slsh_to_ub ).offset().top-0; $('html,body').animate({ scrollTop: scrollto }, 1000, "easeOutQuint", function(){ scroll_action_flag = true; }); }else if( article_type.indexOf( "ground page" ) != -1 ){ var scrollto = $('#' + now_viewing_slsh_to_ub ).offset().top-0; $('html,body').animate({ scrollTop: scrollto }, 1000, "easeOutQuint", function(){ scroll_action_flag = true; }); }else if( article_type.indexOf( "modal" ) != -1 ){ $( "article#" + now_viewing_slsh_to_ub ).css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)}); $( "article#" + now_viewing_slsh_to_ub ).parent().fadeIn( 400,function(){ } ); } memorize_lastvisit_article_type = article_type; }else{ scroll_action_flag = false; setTimeout( function(){ scroll_action_flag = true; } , 1000); memorize_lastvisit_article_type = ""; } }); function PJAX_hrefchange( href, onpop ) { scroll_action_flag = false; if( typeof ajax_request != "undefined" ){ ajax_request.abort(); } if( typeof scroll_action_limiter != "undefined" ){ clearTimeout( scroll_action_limiter ); } if( href && past_href != href ){ past_href = href; var id = href.replace( "https://cagra.net/", "" ); var id = id.replace( "?mode=preview", "" ); now_viewing = id; now_viewing_slsh_to_ub = id.replace( /\//g, "_" ); if (id in category){ var ga_id = category[id][4]; }else{ var ga_id = id; } ajax_request = $.ajax({ url: "https://cagra.net/pjax_readtitle_json.php", data: "id=" + id + "&type=json" + "", dataType: "json", success: function(data, dataType){ if(!onpop){ PJAX_pushState( href, data.title ); } document.title = data.title; }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); if (typeof category[now_viewing_slsh_to_ub] == "undefined") { var arr = id.split("/"); var product_id = arr[arr.length - 1]; var category_filter = id.replace("/" + product_id ,""); if( product_id != "" && category_filter != "" ){ $("body").append("
"); if( memorize_lastvisit == "entry"){ $('html,body').animate({ scrollTop: memorize_scrolltop }, '200', function(){ scroll_action_flag = false; }); }else{ scroll_action_flag = false; memorize_scrolltop = $(window).scrollTop(); } ajax_request = $.ajax({ url: "https://cagra.net/ajax_entry.php", data: "id=" + category_filter + "/" + product_id + "", success: function(data, dataType){ $("div#entry").fadeOut( 400, function(){ $(this).empty().append(data).fadeIn( 400,function(){ $("#entry > article").css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)}); $("div#loading").fadeOut(500, function() { $(this).remove(); }); } ); } ); memorize_lastvisit = "entry"; memorize_lastvisit_article_type = ""; memorize_lasturl = href; memorize_lastindex = category_filter; }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); }else if( product_id != "" ){ $("body").append("
"); ajax_request = $.ajax({ url: "https://cagra.net/ajax_entry.php", data: "id=" + product_id + "", success: function(data, dataType){ $("div#entry").fadeOut( 400, function(){ $(this).empty().append(data).fadeIn( 400,function(){ $("#entry > article").css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)}); $("div#loading").fadeOut(500, function() { $(this).remove(); }); } ); } ); memorize_lastvisit = "entry"; memorize_lastvisit_article_type = ""; memorize_lasturl = href; memorize_scrolltop = 0; memorize_lastindex = ""; }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); } } if( typeof product_id == "undefined" && ( id != "" || id == profile_url ) ){ //article_type(ground・page・modal)の読み取り var article_type = category[now_viewing_slsh_to_ub][2]; if( memorize_lastvisit == "entry" ){ $('html,body').animate({ scrollTop: memorize_scrolltop }, 200); $("div#entry").fadeOut( 400, function(){ $(this).empty(); scroll_action_flag = true; memorize_lastvisit = "index"; memorize_lasturl = href; memorize_scrolltop = 0; memorize_lastindex = id; } ); if( memorize_lastindex != id ){ if( article_type == "ground page" ){ var scrollto = $('#' + now_viewing_slsh_to_ub).offset().top-0; $('html,body').animate({ scrollTop: scrollto }, 1000, "easeOutQuint", function(){ scroll_action_flag = true; }); }else if( article_type == "modal" ){ $( "article#" + id ).css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)}); $( "article#" + id ).parent().fadeIn( 400,function(){ $("div#loading").fadeOut(500, function() { $(this).remove(); }); } ); } memorize_lastvisit = "index"; memorize_lastvisit_article_type = article_type; memorize_lasturl = href; memorize_scrolltop = $(window).scrollTop(); memorize_lastindex = id; } }else{ $( "article.modal" ).parent().fadeOut(400); // if( (article_type == "ground page" && memorize_lastvisit_article_type != "modal") || ( article_type == "ground" && memorize_lastvisit_article_type == "ground page" ) ){ if( (article_type == "ground page" && memorize_lastvisit_article_type != "modal") ){ if( now_viewing_slsh_to_ub != $("#container > article#pagebase > .wrapper > article").attr("id") ){ $("body").append("
"); var first_flag = 0; var past_elm = $("#container > article#pagebase > .wrapper > article"); var past_id = past_elm.attr("id"); var scrollto = $("#container > article#pagebase > .wrapper > article").offset().top; $('html,body').stop().animate({ scrollTop: scrollto }, 800, function(){ if( first_flag == 0 ){ first_flag += 1; $.ajax({ url: "https://cagra.net/ajax_page.php", data: "ajax=true" + "&id=" + id + "", success: function(data, dataType){ var window_width = $(window).width(); $("#container > article#pagebase > .wrapper").append(data); var new_elm = past_elm.next("article"); if(category[past_id][3] > category[now_viewing_slsh_to_ub][3]){ //left elm_x = parseInt(past_elm.css("left")); new_elm.css({ "z-index": 2, "left": elm_x - window_width }); new_elm.stop().animate({ "left": 0 }, 1000, "easeOutQuint"); past_elm.addClass("past_elm"); past_elm.css({ "left": elm_x }); past_elm.stop().animate({ "left": window_width }, 1000, "easeOutQuint", function(){ $(this).remove(); }); }else{ //right elm_x = parseInt(past_elm.css("left")); new_elm.css({ "z-index": 2, "left": elm_x + window_width }); new_elm.stop().animate({ "left": 0 }, 1000, "easeOutQuint"); past_elm.addClass("past_elm"); past_elm.css({ "left": -elm_x }); past_elm.stop().animate({ "left": elm_x - window_width }, 1000, "easeOutQuint", function(){ $(this).remove(); }); } $("div#loading").fadeOut(500, function() { $(this).remove(); }); $(".floatbase a.pjax").attr("href", "https://cagra.net/" + id); scroll_action_flag = true; }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); } }); }else{ var scrollto = $("#container > article#pagebase > .wrapper > article").offset().top; $('html,body').stop().animate({ scrollTop: scrollto }, 800, function(){ scroll_action_flag = true; }); } }else if( article_type == "ground" && memorize_lastvisit_article_type != "modal" ){ var scrollto = $('#' + now_viewing_slsh_to_ub).offset().top+10; $('html,body').stop().animate({ scrollTop: scrollto }, 800, function(){ scroll_action_flag = true; }); }else if( article_type == "modal" ){ $( "article#" + id ).css({"margin-top": $(window).scrollTop()+10 - parseInt($("#container").offset().top)}); $( "article#" + id ).parent().fadeIn( 400,function(){ $("div#loading").fadeOut(500, function() { $(this).remove(); }); } ); } memorize_lastvisit = "index"; memorize_lastvisit_article_type = article_type; memorize_lasturl = href; memorize_scrolltop = $(window).scrollTop(); memorize_lastindex = id; } } if( id == "" ){ $( "article.modal" ).parent().fadeOut( 400,function(){ scroll_action_flag = true; } ); $("div#entry").fadeOut( 400, function(){ $(this).empty(); } ); if( memorize_lastvisit_article_type != "modal" ){ var scrollto = 0; $('html,body').animate({ scrollTop: scrollto }, 1000, "easeOutQuint", function(){ scroll_action_flag = true; }); } memorize_lastvisit = "root"; memorize_lastvisit_article_type = ""; memorize_lasturl = href; memorize_scrolltop = 0; memorize_lastindex = ""; $("#navi nav li").removeClass("active"); $("#navi nav li").removeClass("p_active"); } if( typeof product_id == "undefined" ){ $("#navi nav li").removeClass("active"); $("#navi nav li").removeClass("p_active"); var target_nav = $(".class_" + id.replace( "/", "_" ) + " a"); target_nav.parent("li").removeClass("over"); target_nav.parent("li").addClass("active"); target_nav.closest("li.parent").removeClass("over"); target_nav.closest("li.parent").addClass("p_active"); if( $(".class_" + id.replace( "/", "_" ))[0] ){ if( article_type == "ground page" ){ $("#container > article#pagebase nav li > div.btn").removeClass("active"); var target_tabnav = $(".class_" + id.replace( "/", "_" )); target_tabnav.find("div.btn").addClass("active"); $.each(page_category, function(i) { if( page_category[i]["url"] == id ){ now_page = i; return false; } }); if( now_page != 0 ){ var prev_url = page_category[now_page-1]["url"]; }else{ var prev_url = page_category[page_category_count]["url"]; } if( now_page != page_category_count ){ var next_url = page_category[now_page+1]["url"]; }else{ var next_url = page_category[0]["url"]; } $("a.page_prev").attr("href", "https://cagra.net/" + prev_url) $("a.page_next").attr("href", "https://cagra.net/" + next_url) } } } }else{ if ( href.replace( "https://cagra.net/", "" ) == "" ){ $('html,body').animate({ scrollTop: 0 }, 500); scroll_action_flag = true; } } } function PJAX_pushState( href, title ) { if ( window.history.pushState ) { window.history.pushState( title, null, href ); } else { } } window.onpopstate = function(event){ var onpop = true; if( history_counter != 0 ){ if (event.state) { } else { } var href = location.href; if ( window.history.pushState ) { PJAX_hrefchange( href, onpop ); history_counter++; } else { var href = "https://cagra.net/#!/" + href.replace( /^.\//, '' ); window.location = href; history_counter++; } } history_counter++; } $(document).on("click", "a.pjax", function(){ var href = $(this).attr("href"); if ( window.history.pushState ) { PJAX_hrefchange( href ); history_counter++; } else { var href = href.replace( "https://cagra.net/", "" ); var href = "https://cagra.net/#!/" + href.replace( /^.\//, '' ); var past_href = location.href; if ( href == "https://cagra.net/#!/" && past_href == "https://cagra.net/#!/" ) { $('html,body').animate({ scrollTop: 0 }, 1000); memorize_lastvisit_article_type = ""; } window.location = href; history_counter++; } return false; }); $(window).hashchange( function(){ var hash = location.hash; if( hash.indexOf( "#!/" ) != -1 ){ var href = hash.replace( /^#!\//, '' ); if( href == "" ){ var href = "https://cagra.net/"; } PJAX_hrefchange( href ); } }) $(window).bind('load', function() { var hash = location.hash; if( hash.indexOf( "#!/" ) != -1 ){ var href = hash.replace( /^#!\//, '' ); if ( window.history.pushState ) { window.location = href; }else{ PJAX_hrefchange( href ); } } }); $(window).scroll(function(){ if( scroll_action_flag === true ){ scroll_action_flag = false; if( typeof scroll_action_limiter != "undefined" ){ clearTimeout( scroll_action_limiter ); } scroll_action_limiter = setTimeout( function(){ var menu_list = []; var count_i = 0; $(".ground").each(function(){ if( $(this).attr("id") != null ){ var push_val_id = $(this).attr("id"); var push_val_offset = $("#" + push_val_id).offset().top; var push_val_height = $("#" + push_val_id).height(); menu_list[count_i] = []; menu_list[count_i]["id"] = push_val_id; menu_list[count_i]["offset"] = push_val_offset; menu_list[count_i]["height"] = push_val_height; count_i++; } }); var scroll_val = $(window).scrollTop(); $.each( menu_list, function(i){ if( scroll_val >= menu_list[i]["offset"] && scroll_val <= menu_list[i]["offset"] + menu_list[i]["height"] -200 ){ if( now_viewing != menu_list[i]["id"] ){ var id = menu_list[i]["id"]; var title = category[id][0]; var url = category[id][4]; var slsh_to_ub = category[id][5]; now_viewing = id; past_href = "https://cagra.net/" + url; var page_title = title + " | " + root_site_title; PJAX_pushState( "https://cagra.net/" + url, page_title ); document.title = page_title; $("#navi nav li").removeClass("active"); $("#navi nav li").removeClass("p_active"); var target_nav = $(".class_" + slsh_to_ub + " a"); target_nav.parent("li").removeClass("over"); target_nav.parent("li").addClass("active"); target_nav.closest("li.parent").removeClass("over"); target_nav.closest("li.parent").addClass("p_active"); var ga_id = category[id][4]; } }else if( scroll_val < menu_list[0]["offset"] ){ if( now_viewing != "" ){ var id = ""; now_viewing = id; past_href = "https://cagra.net/"; PJAX_pushState( "https://cagra.net/", root_site_title ); document.title = root_site_title; $("#navi nav li").removeClass("active"); $("#navi nav li").removeClass("p_active"); var ga_id = ""; } } }); scroll_action_flag = true; } , 2000); } }); });