$(function() {
category = Array();
category['profile'] = Array();
category['profile'][0] = "会社概要";
category['profile'][1] = "札信電気實業株式会社の会社概要です。";
category['profile'][2] = "ground";
category['profile'][3] = 0;
category['profile'][4] = "profile";
category['profile'][5] = "profile";
category['history'] = Array();
category['history'][0] = "沿革";
category['history'][1] = "札信電気實業株式会社の沿革です。";
category['history'][2] = "ground";
category['history'][3] = 1;
category['history'][4] = "history";
category['history'][5] = "history";
category['policy'] = Array();
category['policy'][0] = "経営理念";
category['policy'][1] = "札信電気實業株式会社の経営理念です。";
category['policy'][2] = "ground";
category['policy'][3] = 2;
category['policy'][4] = "policy";
category['policy'][5] = "policy";
category['results'] = Array();
category['results'][0] = "工事実績";
category['results'][1] = "札信電気實業株式会社の工事実績です。";
category['results'][2] = "ground";
category['results'][3] = 3;
category['results'][4] = "results";
category['results'][5] = "results";
category['recruit'] = Array();
category['recruit'][0] = "求人情報";
category['recruit'][1] = "札信電気實業株式会社の求人情報です。";
category['recruit'][2] = "ground";
category['recruit'][3] = 4;
category['recruit'][4] = "recruit";
category['recruit'][5] = "recruit";
page_category = Array();
var page_category_count = -1;
function htmlEncode(value){
return $('
').text(value).html();
}
function htmlDecode(value){
return $('').html(value).text();
}
scroll_action_flag = false;
root_site_title = "札信電気實業株式会社";
history_counter = 0;
past_href = location.href;
memorize_scrolltop = $(window).scrollTop();
memorize_lastvisit = "index";
memorize_lasturl = location.href;
profile_url = "profile";
now_viewing = "policy";
now_viewing_slsh_to_ub = "policy".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_" + "policy".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://www.sassin-denki.co.jp/", "" );
var id = id.replace( "?mode=preview", "" );
now_viewing = id;
now_viewing_slsh_to_ub = id.replace( /\//g, "_" );
ajax_request = $.ajax({
url: "https://www.sassin-denki.co.jp/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://www.sassin-denki.co.jp/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://www.sassin-denki.co.jp/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://www.sassin-denki.co.jp/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://www.sassin-denki.co.jp/" + 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 = $('#' + id).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");
$("#navi nav li").addClass("over");
}
if( typeof product_id == "undefined" ){
$("#navi nav li").removeClass("active");
$("#navi nav li").removeClass("p_active");
$("#navi nav li").addClass("over");
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");
$("body").removeClass();
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://www.sassin-denki.co.jp/" + prev_url)
$("a.page_next").attr("href", "https://www.sassin-denki.co.jp/" + next_url)
}
}
}
}else{
if ( href.replace( "https://www.sassin-denki.co.jp/", "" ) == "" ){
$('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://www.sassin-denki.co.jp/#!/" + 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://www.sassin-denki.co.jp/", "" );
var href = "https://www.sassin-denki.co.jp/#!/" + href.replace( /^.\//, '' );
var past_href = location.href;
if ( href == "https://www.sassin-denki.co.jp/#!/" && past_href == "https://www.sassin-denki.co.jp/#!/" ) {
$('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://www.sassin-denki.co.jp/";
}
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"] -50 ){
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://www.sassin-denki.co.jp/" + url;
var page_title = title + " | " + root_site_title;
PJAX_pushState( "https://www.sassin-denki.co.jp/" + url, page_title );
document.title = page_title;
$("#navi nav li").removeClass("active");
$("#navi nav li").removeClass("p_active");
$("#navi nav li").addClass("over");
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");
$("body").removeClass();
}
}else if( scroll_val < menu_list[0]["offset"] ){
if( now_viewing != "" ){
var id = "";
now_viewing = id;
past_href = "https://www.sassin-denki.co.jp/";
PJAX_pushState( "https://www.sassin-denki.co.jp/", root_site_title );
document.title = root_site_title;
$("#navi nav li").removeClass("active");
$("#navi nav li").removeClass("p_active");
$("#navi nav li").addClass("over");
$("body").removeClass();
}
}
});
scroll_action_flag = true;
}
, 2000);
}
});
});