$(function() {
var window_height = window.innerHeight ? window.innerHeight: $(window).height();
var window_width = $(window).width();
var window_ratio = Math.floor(window_height/window_width*1000)/1000;
var scroll_val = $(window).scrollTop();
function parallax_action(target) {
var article_id = target.closest("article").attr("id");
scroll_val = $(window).scrollTop();
var offset_top = target.offset().top;
// 開始→ (scroll_val + window_height) > offset_top
// 終了→ scroll_val < (offset_top + target.height())
// パララックス遷移パーセント→ 0%: offset_top - window_height 100%: offset_top + target.height()
// パララックス遷移パーセント式→ (scroll_val - offset_top ) / (offset_top + target.height()) - (offset_top - window_height)
var progress = (scroll_val - offset_top + window_height) / ((offset_top + target.height()) - (offset_top - window_height));
if ( progress*100 >= 0 && progress*100 <= 100 ) {
var parallax_elm = target.children();
var parallax_elm_shift_y = -(target.height() - parallax_elm.height())/2*progress;
parallax_elm.css({"transform": "matrix(1, 0, 0, 1, 0, " + parallax_elm_shift_y + ")"});
}
}
function window_resize() {
window_height = window.innerHeight ? window.innerHeight: $(window).height();
window_width = $(window).width();
window_ratio = Math.floor(window_height/window_width*1000)/1000;
}
$(window).bind("resize", window_resize);
function parallax_refresh() {
var bg_arr = [
'.parallax_base div.bg#movie_bg_1',
'.parallax_base div.bg#movie_bg_2',
'section#concept_1 > div.bg',
'section#concept_3 > div.point_1 > div.bg',
'section#concept_3 > div.point_2 > div.bg',
'section#concept_3 > div.point_4 > div.bg',
'article#salon > header > div.bg',
'article#registration > header > div.bg',
'article#member > header > div.bg'
];
$.each( bg_arr, function(index){
var self = $(bg_arr[index]);
if( self[0] ){
parallax_action(self);
$(window).scroll(function() {
parallax_action(self);
});
}
});
}
function thumbs_fade(scroll_val) {
if( $("div.index[data-flag = 0]")[0] ){
scroll_flag_2 = false;
var target_list = [];
var count_i = 0;
$("div.index[data-flag = 0]").each(function(){
var push_val_offset = $(this).offset().top;
var push_val_height = $(this).height();
target_list[count_i] = [];
target_list[count_i]["this"] = $(this);
target_list[count_i]["offset"] = push_val_offset;
target_list[count_i]["height"] = push_val_height;
count_i++;
});
$.each( target_list, function(target_i){
if( (scroll_val + $(window).height()/10*6) >= target_list[target_i]["offset"] && scroll_val <= target_list[target_i]["offset"] + target_list[target_i]["height"] ){
target_list[target_i]["this"].find("ul > li").each(function (i) {
target_list[target_i]["this"].attr("data-flag",1);
$(this).delay(i * 100).queue(function() {
$(this).addClass("show").dequeue();
});
});
}
});
}
}
category = Array();
category['company'] = Array();
category['company'][0] = "COMPANY";
category['company'][1] = "";
category['company'][2] = "modal";
category['company'][3] = "";
category['company'][4] = "company";
category['company'][5] = "company";
category['movie'] = Array();
category['movie'][0] = "MOVIE";
category['movie'][1] = "";
category['movie'][2] = "ground";
category['movie'][3] = 0;
category['movie'][4] = "movie";
category['movie'][5] = "movie";
category['concept'] = Array();
category['concept'][0] = "CONCEPT";
category['concept'][1] = "";
category['concept'][2] = "ground";
category['concept'][3] = 1;
category['concept'][4] = "concept";
category['concept'][5] = "concept";
category['products'] = Array();
category['products'][0] = "PRODUCTS";
category['products'][1] = "";
category['products'][2] = "ground";
category['products'][3] = 2;
category['products'][4] = "products";
category['products'][5] = "products";
category['thought'] = Array();
category['thought'][0] = "THOUGHT";
category['thought'][1] = "";
category['thought'][2] = "ground";
category['thought'][3] = 3;
category['thought'][4] = "thought";
category['thought'][5] = "thought";
category['salon'] = Array();
category['salon'][0] = "SALON";
category['salon'][1] = "";
category['salon'][2] = "page";
category['salon'][3] = 4;
category['salon'][4] = "salon";
category['salon'][5] = "salon";
category['registration'] = Array();
category['registration'][0] = "パスワード申請フォーム";
category['registration'][1] = "";
category['registration'][2] = "page";
category['registration'][3] = 5;
category['registration'][4] = "registration";
category['registration'][5] = "registration";
category['member'] = Array();
category['member'][0] = "ソニック会員様専用ページ";
category['member'][1] = "";
category['member'][2] = "page";
category['member'][3] = 6;
category['member'][4] = "member";
category['member'][5] = "member";
category['contact'] = Array();
category['contact'][0] = "お問い合わせ";
category['contact'][1] = "";
category['contact'][2] = "modal";
category['contact'][3] = "";
category['contact'][4] = "contact";
category['contact'][5] = "contact";
category['privacy'] = Array();
category['privacy'][0] = "プライバシーポリシー";
category['privacy'][1] = "";
category['privacy'][2] = "modal";
category['privacy'][3] = "";
category['privacy'][4] = "privacy";
category['privacy'][5] = "privacy";
category['law'] = Array();
category['law'][0] = "特定商取引に関する表示";
category['law'][1] = "";
category['law'][2] = "modal";
category['law'][3] = "";
category['law'][4] = "law";
category['law'][5] = "law";
category['quality'] = Array();
category['quality'][0] = "アクアシャルムの秘密 - 活性酸素とH:(エイチコロン)";
category['quality'][1] = "";
category['quality'][2] = "modal";
category['quality'][3] = "";
category['quality'][4] = "quality";
category['quality'][5] = "quality";
page_category = Array();
var page_category_count = -1;
function htmlEncode(value){
return $('
').text(value).html();
}
function htmlDecode(value){
return $('').html(value).text();
}
var scroll_val = $(window).scrollTop();
var scroll_action_flag = false;
var root_site_title = "AQUACHARME - アクアシャルム|水素の力で、知的な肌へご招待。";
var history_counter = 0;
var past_href = location.href;
var memorize_scrolltop = $(window).scrollTop();
var memorize_lastvisit = "entry";
var memorize_lasturl = location.href;
var profile_url = "company";
var now_viewing = "products";
var now_viewing_slsh_to_ub = "products".replace( "/", "_" );
var memorize_lastindex = "";
$(window).bind('load', function() {
parallax_refresh();
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_" + "products".replace( "/", "_" ) + " a");
target_nav.parent("li").removeClass("on");
target_nav.parent("li").addClass("active");
target_nav.closest("li.parent").removeClass("on");
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://aquacharme.com/", "" );
var id = id.replace( "?mode=preview", "" );
now_viewing = id;
now_viewing_slsh_to_ub = id.replace( /\//g, "_" );
ajax_request = $.ajax({
url: "https://aquacharme.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 (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://aquacharme.com/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://aquacharme.com/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://aquacharme.com/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
});
parallax_refresh();
past_elm.stop().animate({
"left": window_width
}, 1000, "easeOutQuint",
function(){
$(this).remove();
scroll_val = $(window).scrollTop();
thumbs_fade(scroll_val);
});
}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
});
parallax_refresh();
past_elm.stop().animate({
"left": elm_x - window_width
}, 1000, "easeOutQuint",
function(){
$(this).remove();
scroll_val = $(window).scrollTop();
thumbs_fade(scroll_val);
});
}
$("div#loading").fadeOut(500, function() {
$(this).remove();
});
$(".floatbase a.pjax").attr("href", "https://aquacharme.com/" + 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("on active");
$("#navi nav li").removeClass("on p_active");
$("#navi nav li").css({"background-color" : ""});
$("#navi nav li").addClass("over");
}
if( typeof product_id == "undefined" ){
$("#navi nav li").removeClass("on active");
$("#navi nav li").removeClass("on p_active");
$("#navi nav li").css({"background-color" : ""});
$("#navi nav li").addClass("over");
var target_nav = $(".class_" + id.replace( "/", "_" ) + " a");
target_nav.parent("li").removeClass("on");
target_nav.parent("li").addClass("active");
target_nav.closest("li.parent").removeClass("on");
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("on 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://aquacharme.com/" + prev_url)
$("a.page_next").attr("href", "https://aquacharme.com/" + next_url)
}
}
}
}else{
if ( href.replace( "https://aquacharme.com/", "" ) == "" ){
$('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://aquacharme.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( "https://aquacharme.com/", "" );
var href = "https://aquacharme.com/#!/" + href.replace( /^.\//, '' );
var past_href = location.href;
if ( href == "https://aquacharme.com/#!/" && past_href == "https://aquacharme.com/#!/" ) {
$('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://aquacharme.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 );
}
}
});
$(window).scroll(function(){
scroll_val = $(window).scrollTop();
thumbs_fade(scroll_val);
if( scroll_action_flag === true && !$("body.page")[0] ){
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++;
}
});
$.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://aquacharme.com/" + url;
var page_title = title + "|" + root_site_title;
PJAX_pushState( "https://aquacharme.com/" + url, page_title );
document.title = page_title;
$("#navi nav li").removeClass("on active");
$("#navi nav li").removeClass("on p_active");
$("#navi nav li").css({"background-color" : ""});
$("#navi nav li").addClass("over");
var target_nav = $(".class_" + slsh_to_ub + " a");
target_nav.parent("li").removeClass("on");
target_nav.parent("li").addClass("active");
target_nav.closest("li.parent").removeClass("on");
target_nav.closest("li.parent").addClass("p_active");
id = url;
}
}else if( scroll_val < menu_list[0]["offset"] ){
if( now_viewing != "" ){
var id = "";
now_viewing = id;
past_href = "https://aquacharme.com/";
PJAX_pushState( "https://aquacharme.com/", root_site_title );
document.title = root_site_title;
$("#navi nav li").removeClass("on active");
$("#navi nav li").removeClass("on p_active");
$("#navi nav li").css({"background-color" : ""});
$("#navi nav li").addClass("over");
}
}
});
scroll_action_flag = true;
}
, 2000);
}
});
});