$(function() { category = Array(); category['about'] = Array(); category['about'][0] = "ABOUT"; category['about'][1] = ""; category['art'] = Array(); category['art'][0] = "ART"; category['art'][1] = "藤沢レオのART作品群"; category['art'] = Array(); category['art'][0] = "ART/ALL"; category['art'][1] = ""; category['art/public'] = Array(); category['art/public'][0] = "ART/PUBLIC"; category['art/public'][1] = "藤沢レオのART作品群の中で公共空間に設置された作品"; category['craft'] = Array(); category['craft'][0] = "CRAFT"; category['craft'][1] = "藤沢レオのCRAFT作品群"; category['craft'] = Array(); category['craft'][0] = "CRAFT/ALL"; category['craft'][1] = ""; category['craft/furniture'] = Array(); category['craft/furniture'][0] = "CRAFT/FURNITURE"; category['craft/furniture'][1] = "藤沢レオのCRAFT作品群の中で家具に分類される作品"; category['craft/public'] = Array(); category['craft/public'][0] = "CRAFT/PUBLIC"; category['craft/public'][1] = "藤沢レオのCRAFT作品群の中で公共空間に設置された作品"; category['workshop'] = Array(); category['workshop'][0] = "WORKSHOP"; category['workshop'][1] = "藤沢レオが参加、実施した体験学習/ワークショップ"; category['news'] = Array(); category['news'][0] = "NEWS"; category['news'][1] = "藤沢レオの活動情報"; category['news'] = Array(); category['news'][0] = "NEWS/ALL"; category['news'][1] = ""; category['news/information'] = Array(); category['news/information'][0] = "NEWS/INFORMATION"; category['news/information'][1] = "藤沢レオの活動情報"; category['news/press'] = Array(); category['news/press'][0] = "NEWS/PRESS"; category['news/press'][1] = "藤沢レオが新聞、雑誌等に掲載された情報"; history_counter = 0; past_href = location.href; memorize_scrolltop = $(window).scrollTop(); memorize_lastvisit = "index"; root_url = "http://leofujisawa.com/"; past_entry_id = ""; if( $("div#index > article").length === 0 ){ memorize_past_id = ""; }else{ memorize_past_id = $("div#index > article").attr("class").replace( " ", "/" ); } memorize_lasturl = location.href; profile_url = "about"; $(window).bind('load', function() { var target_nav = $(".class_" + "art".replace( "/", "_" )); target_nav.removeClass("over"); target_nav.addClass("active"); if("art".indexOf( "/" ) != -1){ var id_arr = "art".split('/'); var parent_id = id_arr[0]; var target_nav = $(".class_p_" + parent_id); target_nav.removeClass("over"); target_nav.addClass("active"); $("#header nav li a:not(.class_p_" + parent_id + ")").next("ul").fadeOut(400); $("#header nav li a.class_p_" + parent_id).next("ul").fadeIn(200); var target_thm = $("ul#list li[data-category *= '" + category["art"][0] + "' ]"); if( target_thm[0] && memorize_lastvisit != "entry" ){ var scrollto = target_thm.first().offset().top - $("#header").height() - 50; }else{ var scrollto = 0; } $('html,body').stop().animate({ scrollTop: scrollto }, 1000, "easeOutQuint"); }else{ var target_nav = $(".class_p_" + "art"); target_nav.removeClass("over"); target_nav.addClass("active"); $("#header nav li a:not(.class_p_art)").next("ul").fadeOut(400); $("#header nav li a.class_p_art").next("ul").fadeIn(200); if( memorize_lastvisit != "entry" && "art" != profile_url ){ var scrollto = $("#container").offset().top - 80; $('html,body').stop().animate({ scrollTop: scrollto }, 1000, "easeOutQuint"); } } }); function PJAX_hrefchange( href, onpop ) { if( typeof ajax_request != "undefined" ){ ajax_request.abort(); } if( href && past_href != href ){ past_href = href; var id = href.replace( "http://leofujisawa.com/", "" ); var id = id.replace( "?mode=preview", "" ); if(memorize_past_id.indexOf( "/" ) != -1){ var memorize_past_id_arr = memorize_past_id.split('/'); var parent_past_id = memorize_past_id_arr[0]; }else{ var parent_past_id = memorize_past_id; } ajax_request = $.ajax({ url: "http://leofujisawa.com/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 (id.match(/\d{4}$/)) { var entry_id = id.match(/\d{4}$/); var category_filter = id.replace("/" + entry_id ,""); if( entry_id != "" && category_filter != "" && entry_id != category_filter ){ $("body").append("
"); if( memorize_lastvisit == "entry"){ $('html,body').animate({ scrollTop: memorize_scrolltop }, '200'); }else{ memorize_scrolltop = $(window).scrollTop(); } ajax_request = $.ajax({ url: "http://leofujisawa.com/ajax_entry.php", data: "id=" + category_filter + "/" + entry_id + "", success: function(data, dataType){ $("div#entry").fadeOut( 400, function(){ $("div#entry").css("top", memorize_scrolltop + "px"); $(this).empty().append(data).fadeIn( 400,function(){ $("div#loading").fadeOut(600, function(){ $(this).remove(); } ); } ); } ); memorize_lastvisit = "entry"; memorize_lasturl = href; memorize_past_id = category_filter; }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); }else if( entry_id != "" ){ $("body").append("
"); if( memorize_lastvisit == "entry"){ $('html,body').animate({ scrollTop: memorize_scrolltop }, '200'); }else{ memorize_scrolltop = $(window).scrollTop(); } ajax_request = $.ajax({ url: "http://leofujisawa.com/ajax_entry.php", data: "id=" + entry_id + "", success: function(data, dataType){ $("div#entry").fadeOut( 400, function(){ $("div#entry").css("top", memorize_scrolltop + "px"); $(this).empty().append(data).fadeIn( 400,function(){ $("div#loading").fadeOut(600, function(){ $(this).remove(); } ); } ); } ); memorize_lastvisit = "entry"; memorize_lasturl = href; memorize_past_id = ""; }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); } } if ( id == profile_url ) { $("body").append("
"); ajax_request = $.ajax({ url: "http://leofujisawa.com/ajax_profile.php", data: "id=" + id + "", success: function(data, dataType){ $("div#entry").fadeOut( 400, function(){ $("div#entry").css("top", $(window).scrollTop() + "px"); $(this).empty().append(data).fadeIn( 400,function(){ $("div#loading").fadeOut(600, function(){ $("div#entry a.modal_overlay, div#entry a.close").attr("href", root_url + memorize_past_id); initialize_gmap("http://leofujisawa.com/","ajax"); $(this).remove(); } ); } ); } ); memorize_lastvisit = "profile"; memorize_lasturl = href; memorize_scrolltop = $(window).scrollTop(); }, error: function(XMLHttpRequest, textStatus, errorThrown){ } }); }else if( typeof entry_id == "undefined" && id != "" ){ if( memorize_lastvisit == "entry" || memorize_lastvisit == "profile" ){ $('html,body').animate({ scrollTop: memorize_scrolltop }, 200); $("ul#list").stop().css({ opacity : 1 } ); $("div#entry").stop().animate({ opacity : 0 },200, function(){ $("div#entry").empty().stop().animate({opacity : 1},200); } ); } $("#index a.close").fadeIn(200); if( id != memorize_past_id ){ if( id != parent_past_id ){ if( $("ul#list li[data-category *= '" + category[id][0] + "' ]")[0] ){ var target_thm = $("ul#list li[data-category *= '" + category[id][0] + "' ]"); if( target_thm[0] ){ var scrollto = target_thm.first().offset().top - $("#header").height() - 50; }else{ var scrollto = $(document).height(); } $('html,body').stop().animate({ scrollTop: scrollto }, 1000, "easeOutQuint"); }else{ var scrollto = 0; $('html,body').stop().animate({ scrollTop: scrollto }, 1000, "easeOutQuint"); } } $("li.load_more > a").attr("data-id",id); var next_page = $("li.load_more > a").attr("data-page"); $("li.load_more > a").attr("href","http://leofujisawa.com/"+id+"/"+next_page); thmArr = []; PJAX_thumb_i = 0; $("div#index > article > ul > li.thm").each(function(){ thmArr.push($(this)); PJAX_thumb_i ++; }); for(var i = 0 ; i < PJAX_thumb_i ; i++){ thmArr[i].removeClass("on off"); var get_category = thmArr[i].attr("data-category"); var get_href = thmArr[i].find(".tagswitch").attr("data-href"); var get_inner_html = thmArr[i].find(".tagswitch").html(); if( get_category.indexOf(category[id][0]) != -1 || id.indexOf( "/" ) == -1 ){ thmArr[i].find(".tagswitch").replaceWith(''+get_inner_html+'') thmArr[i].addClass("on"); thmArr[i].stop().delay(10*i).animate({opacity:"1"},200); var ua = navigator.userAgent; var isIE8 = ua.match(/msie [8.]/i); if( isIE8 ){ thmArr[i].find("figure *[class != 'text_wrapper']").animate({"opacity":1},200); } }else{ thmArr[i].find(".tagswitch").replaceWith('
'+get_inner_html+'
') thmArr[i].addClass("off"); thmArr[i].stop().delay(10*i).animate({opacity:"0.1"},200); var ua = navigator.userAgent; var isIE8 = ua.match(/msie [8.]/i); if( isIE8 ){ thmArr[i].find("figure *[class != 'text_wrapper']").animate({"opacity":0.1},200); } } } } memorize_lastvisit = "index"; memorize_lasturl = href; memorize_past_id = id; } if( id == "" ){ $("#index a.close").fadeOut(200); if( memorize_lastvisit == "entry" || memorize_lastvisit == "profile" ){ // if( memorize_scrolltop != 0 ){ // $('html,body').animate({ // scrollTop: memorize_scrolltop // }, 200); // }else{ // var scrollto = $("#container").offset().top - 80; // $('html,body').stop().animate({ // scrollTop: scrollto // }, 1000, "easeOutQuint"); // } $("ul#list").stop().css({ opacity : 1 } ); $("div#entry").stop().animate({ opacity : 0 },200, function(){ $("div#entry").empty().stop().animate({opacity : 1},200); memorize_scrolltop = 0; } ); }else{ $('html,body').animate({ scrollTop: 0 }, 800); $("li.load_more > a").attr("data-id",""); var next_page = $("li.load_more > a").attr("data-page"); $("li.load_more > a").attr("href","http://leofujisawa.com/"+"/"+next_page); thmArr = []; PJAX_thumb_i = 0; $("div#index > article > ul > li.thm").each(function(){ thmArr.push($(this)); PJAX_thumb_i ++; }); for(var i = 0 ; i < PJAX_thumb_i ; i++){ thmArr[i].removeClass("on off"); var get_href = thmArr[i].find(".tagswitch").attr("data-href"); var get_inner_html = thmArr[i].find(".tagswitch").html(); thmArr[i].find(".tagswitch").replaceWith(''+get_inner_html+'') thmArr[i].addClass("on"); thmArr[i].stop().delay(10*i).animate({opacity:"1"},200); var ua = navigator.userAgent; var isIE8 = ua.match(/msie [8.]/i); if( isIE8 ){ thmArr[i].find("figure *[class != 'text_wrapper']").animate({"opacity":1},200); } } } memorize_lastvisit = "root"; memorize_lasturl = href; memorize_past_id = id; } if( typeof entry_id == "undefined" ){ $("#header nav li a").css({ "border-bottom-color" : "" }); $("#header nav li a").removeClass("active"); $("#header nav li a").addClass("over"); var target_nav = $(".class_" + id.replace( "/", "_" )); target_nav.removeClass("over"); target_nav.addClass("active"); if(id.indexOf( "/" ) != -1){ var id_arr = id.split('/'); var parent_id = id_arr[0]; var target_nav = $(".class_p_" + parent_id); target_nav.removeClass("over"); target_nav.addClass("active"); $("#header nav li a:not(.class_p_" + parent_id + ")").next("ul").fadeOut(400); $("#header nav li a.class_p_" + parent_id).next("ul").fadeIn(200); $("ul#list").removeClass(); $("ul#list").addClass(parent_id); }else if( id != "" && id != profile_url ){ if( typeof parent_past_id != "undefined" && id != parent_past_id ){ var scrollto = $("#container").offset().top - 80; $('html,body').stop().animate({ scrollTop: scrollto }, 1000, "easeOutQuint"); $("ul#list").stop().animate({ opacity : 0 },200, function(){ $("ul#list").removeClass(); $("ul#list").addClass(id); setTimeout(function(){ $("ul#list").stop().animate({ opacity : 1 },200 ); },10); } ); }else{ // if( memorize_scrolltop == 0 ){ // var scrollto = $("#container").offset().top - 80; // $('html,body').stop().animate({ // scrollTop: scrollto // }, 1000, "easeOutQuint"); // } $("ul#list").removeClass(); $("ul#list").addClass(id); } var target_nav = $(".class_p_" + id); target_nav.removeClass("over"); target_nav.addClass("active"); $("#header nav li a:not(.class_p_" + id + ")").next("ul").fadeOut(400); $("#header nav li a.class_p_" + id).next("ul").fadeIn(200); memorize_scrolltop = 0; }else if( id == profile_url ){ $("#header nav li a").next("ul").fadeOut(400); $("ul#list").removeClass(); $("ul#list").addClass("art"); }else{ if( typeof parent_past_id != "undefined" && parent_past_id != "art" && parent_past_id != "" ){ $("ul#list").stop().animate({ opacity : 0 },200, function(){ $("ul#list").removeClass(); $("ul#list").addClass("art"); setTimeout(function(){ $("ul#list").stop().animate({ opacity : 1 },200 ); },10); } ); }else{ if( past_entry_id == "" ){ var scrollto = 0; $('html,body').stop().animate({ scrollTop: scrollto }, 1000, "easeOutQuint"); } $("ul#list").removeClass(); $("ul#list").addClass("art"); setTimeout(function(){ $("ul#list").stop().animate({ opacity : 1 },200 ); },10); } var target_nav = $(".class_art"); target_nav.removeClass("over"); target_nav.addClass("active"); var target_nav = $(".class_p_art"); target_nav.removeClass("over"); target_nav.addClass("active"); $("#header nav li a:not(.class_p_art)").next("ul").fadeOut(400); $("#header nav li a.class_p_art").next("ul").fadeIn(200); } }else{ past_entry_id = entry_id; } } } 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 = "http://leofujisawa.com/#!/" + 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( "http://leofujisawa.com/", "" ); var href = "http://leofujisawa.com/#!/" + href.replace( /^.\//, '' ); 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 = "http://leofujisawa.com/"; } } 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 ); } } }); });