').prepend(ajax_data));
// $("#navi").empty();
// $("#navi").prepend(get_navi_elm);
$("#container > div#base > article").addClass("ajax");
setTimeout(
function(){
$("#container > div#base > article.leave").remove();
setTimeout(
function(){
$("html").removeClass("moving");
scroll_trigger();
}
, 200);
load_iframe();
// FB.XFBML.parse();
window_resize();
PJAX_loading_remove();
if( scroll != "" ){
var scrollto_val = 0;
$("#container > div#base > article").imagesLoaded().done(function(){
scrollto_val = $("#" + selectorEscape(scroll)).offset().top;
scrollto(scrollto_val);
});
}
}
, 10);
if( data.directory == "root" ){
top_slide_start( $("div#slide_wrapper > div.slide") );
// video_start(startup_video_selector);
// window.FB.XFBML.parse();
}
img_load();
scroll_action_flag = true;
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
function PJAX_ajaxload_loadmore( href, data, option, target ) {
var scroll = data.scroll;
if( typeof ajax_request != "undefined" ){
ajax_request.abort();
}
ajax_request = $.ajax({
url: href,
dataType: "html",
success:
function(data, dataType){
target.children("li.load_more").remove();
var get_elm = $('div.index > ul > *', $('
').prepend(data));
target.append(get_elm);
img_load();
window_resize();
PJAX_loading_remove();
if( ! $("body.modal")[0] && ! $("body.entry")[0] ){
scroll_action_flag = true;
}
var target_index = target.closest(".index");
// thm_random_fade_start( target_index );
},
error:
function(XMLHttpRequest, textStatus, errorThrown){
}
});
}
function scrollto(val){
console.log("scrollto: "+val);
scroll_action_flag = false;
$('html, body').stop().animate({
scrollTop: val
}, 1000, "easeOutQuint",function(){
scroll_action_flag = true;
});
}
function PJAX_pushState( href, title ) {
if ( window.history.pushState ) {
window.history.pushState( title, null, href );
} else {
}
}
window.onpopstate = function(event){
// console.log("onpopstate");
if (event.state) {
} else {
}
var href = location.href;
if ( window.history.pushState ) {
PJAX_pjax( href, "by_onpop", "" );
} else {
var href = "https://value-home.jp/#!/" + href.replace( /^.\//, '' );
window.location = href;
}
}
$(document).on("click", "a.pjax:not(.deactive)", function(){
var href = $(this).attr("href");
if ( window.history.pushState ) {
PJAX_pjax( href, "", "" );
} else {
var href = href.replace( "https://value-home.jp/", "" );
var href = "https://value-home.jp/#!/" + href.replace( /^.\//, '' );
var past_href = location.href;
window.location = href;
}
return false;
});
$(document).on("click", "div.index > ul > li.load_more > a.pjax_load_more", function(){
var href = $(this).attr("href");
var target = $(this).closest("ul");
if ( window.history.pushState ) {
var parent = $(this).parent();
parent.addClass("loading");
parent.append('
loading
');
PJAX_pjax( href, "by_load_more", target );
}
return false;
});
function hashchange(hash) {
if(hash.indexOf( "#/" ) != -1){
hash_arr = hash.split("#/");
hash = hash_arr[1];
PJAX_hash( hash );
}
}
$(window).hashchange( function(){
var hash = location.hash;
hashchange(hash);
})
$(document).on("click", "a.hash", function(){
var href = $(this).attr("href");
var hash = "";
if( href.indexOf( "#/" ) != -1 ){
hash_arr = href.split("#/");
hash = "#/"+hash_arr[1];
// console.log("hash: "+hash);
// console.log("location.hash: "+location.hash);
if( location.hash == hash ){
hashchange(hash);
return false;
}
}
});
$(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_pjax( href, "", "" );
}
}
});
function scroll_trigger() {
if( $("html:not(.moving) .scroll_trigger:not(.action)")[0] ){
$(".scroll_trigger:not(.action)").each(function(i){
var target = $(this);
var position = target.offset().top;
var move_y = +(position - scroll_val);
var in_position = position + window_height/1000;
var window_trigger_position = $(window).scrollTop() + $(window).height() / 2;
if(in_position < window_trigger_position){
target.addClass('action');
if( target.find(".auto_fade")[0] ){
var target_elm = target.find(".auto_fade");
setTimeout(function(){
elm_fade( target_elm, 150 );
},100);
}
if( target.find(".textillate_wrapper")[0] ){
var target_textillate = target.find(".textillate_wrapper");
setTimeout(function(){
textillate( target_textillate, 600 );
},100);
}
if( target.find("iframe.pending")[0] ){
var target_iframe = target.find("iframe.pending");
setTimeout(function(){
target_iframe.removeClass("pending")
target_iframe.attr("src",target_iframe.attr("data-src"));
},100);
}
// if( target.find("video[autoplay]")[0] ){
// var target_video = target.find("video[autoplay]");
// target_video.each(function(i){
// var player = $(this).get(0);
// player.play();
// });
// }
}
});
}
}
function textillate(wrapper,speed) {
if( wrapper.find("span")[0] ){
wrapper.addClass("textillate");
wrapper.find("span").each(function(i){
// $(this).delay(speed*i).queue(function() {
// $(this).addClass("show");
// });
$(this).delay(speed*i).queue(function() {
$(this).textillate({ in: {
effect: 'fadeIn',
delay: 50
} }).dequeue();
});
});
}
}
function elm_fade( targets, delay ){
var target_num = targets.length;
$(targets[0]).addClass("show");
targets.splice(0,1);
if (target_num > 0) {
setTimeout(function(){
elm_fade( targets, delay );
},delay);
} else {
return false;
}
}
function thm_random_fade_start( target_index ){
var target_thms = target_index.find("ul > li.thm:not(.show)");
thm_random_fade( target_thms, 200 );
}
function thm_random_fade( targets, delay ){
var target_num = targets.length;
var random_i = Math.floor(Math.random()*target_num);
$(targets[random_i]).addClass("show");
targets.splice(random_i,1);
if (target_num > 0) {
setTimeout(function(){
thm_random_fade( targets, delay );
},delay);
} else {
return false;
}
}
function scroll_off(){
var scroll_event = 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll';
$(document).on(scroll_event,function(e){e.preventDefault();});
$(document).on('touchmove.noScroll', function(e) {e.preventDefault();});
}
function scroll_on(){
var scroll_event = 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll';
$(document).off(scroll_event);
$(document).off('.noScroll');
}
if( id == "" ){
// scroll_off();
}else{
// scroll_on();
}
var document_height = $(document).height();
var content_height = get_total_height($("#container > div#base > *"));
var entry_height = get_total_height($("#entry > div.inner > *"));
if( $("html.touch_device")[0] ){
if( window.innerHeight > window.innerWidth ){
var window_height = $(window).height();
}else{
var window_height = $(window).height();
}
}else{
var window_height = window.innerHeight ? window.innerHeight: $(window).height();
}
var window_width = $(window).width();
var window_ratio = window_height / window_width;
var scroll_val = $(window).scrollTop();
var scroll_action_flag = true;
if( $("body #container > div#base article.ground")[0] ){
scroll_action_flag = false;
}
if( $("body.modal")[0] ){
scroll_action_flag = false;
}
if( $("body.entry")[0] ){
scroll_action_flag = false;
}
function base_scroll() {
scroll_trigger();
scroll_val = $(window).scrollTop();
// console.log(scroll_val);
// console.log($("#profile-company").offset().top)
// console.log(scroll_val+window_height+"|"+content_height);
if( scroll_val+window_height > content_height - 100 ){
$("html").addClass("scrolled")
$("html").addClass("scrollend")
}else if( scroll_val < Math.round(window_height/100) ){
$("html").removeClass("scrolled")
$("html").removeClass("scrollend")
}else if( scroll_val >= Math.round(window_height/100) && scroll_val+window_height < content_height - 100 ){
$("html").addClass("scrolled")
$("html").removeClass("scrollend")
}else{
$("html").addClass("scrolled")
$("html").addClass("scrollend")
}
if( $("article#spec\\/ > div.inner > div.body > header")[0] ){
if( scroll_val < window_height ){
$("article#spec\\/ > div.inner > div.body > header").css({
"opacity": Math.floor((1-scroll_val/(window_height))*1000)/1000
});
$("article#spec\\/ > div.inner > div.body > header").css({
"transform": "matrix(1, 0, 0, 1, 0, "+ (scroll_val/2) +")"
});
}else{
$("article#spec\\/ > div.inner > div.body > header").css({
"opacity": 0
});
}
}
if( $("div.body.page.spec > header > div.bg > img")[0] ){
if( scroll_val < 1500 ){
$("div.body.page.spec > header > div.bg > img").css({
"transform": "matrix(1, 0, 0, 1, 0, "+ Math.floor(scroll_val/2*100)/100 +")"
});
}
}
if( $("div.body.page.company > header > div.bg > img")[0] ){
if( scroll_val < 1500 ){
$("div.body.page.company > header > div.bg > img").css({
"transform": "matrix(1, 0, 0, 1, 0, "+ Math.floor(scroll_val/2*100)/100 +")"
});
}
}
if( $(".parallax")[0] ){
var window_center_y = window_height/2 + scroll_val;
$(".parallax:visible").each(function(){
var target = $(this);
var wrapper = $(this).closest(".parallax_base");
var speed_adjust = 1;
if( target.attr("data-speed_adjust") != undefined ){
speed_adjust = target.attr("data-speed_adjust");
}
var target_ratio = target.height()/target.width();
var wrapper_ratio = wrapper.height()/wrapper.width();
// console.log(target.attr("src"));
// console.log(target_ratio);
// console.log(wrapper_ratio);
if( target_ratio <= wrapper_ratio ){
target.css({"height": "120%","width": "auto"});
// target.css({"height": "120%","width": "auto"});
}else{
target.css({"height": "auto","width": "100%"});
}
var wrapper_y = wrapper.offset().top;
var wrapper_center_y = wrapper_y + wrapper.height()/2;
var distance = window_center_y - wrapper_center_y;
var parallax_height = wrapper.height();
var img_height = target.height();
var val = img_height-parallax_height;
var move_y = Math.round((val/window_height)*distance)*speed_adjust;
target.css({"transform": "matrix(1, 0, 0, 1, 0, "+ move_y +")"});
});
}
if( scroll_action_flag === true && $("body:not(.modal) #container > div#base article.ground")[0] ){
scroll_action_flag = false;
if( typeof scroll_action_limiter != "undefined" ){
clearTimeout( scroll_action_limiter );
}
scroll_action_limiter = setTimeout(
function(){
$("body #container > div#base article.ground").each(function(){
if( $(this).attr("id") != null ){
var ground_id = $(this).attr("id");
if( typeof category[ground_id] != "undefined" ){
var ground_offset = $("#" + selectorEscape( ground_id )).position().top;
var ground_height = $("#" + selectorEscape( ground_id )).height();
if( scroll_val >= ground_offset && scroll_val <= ground_offset + ground_height ){
// console.log("ground_id::"+ground_id);
// console.log(id);
// console.log(ground_id);
var href = "https://value-home.jp/" + ground_id;
// console.log("do");
PJAX_pjax( href, "by_scroll", "" );
}else if( scroll_val < $("body #container > div#base article.ground").first().position().top ){
if( $("body").attr("data-scroll") != "" ){
var scroll_split = $("body").attr("data-scroll").split('/');
var ground_directory = $("body").attr("data-scroll").replace( scroll_split[scroll_split.length-1], "" );
var href = "https://value-home.jp/" + ground_directory;
// console.log("top::"+href);
// console.log("why");
PJAX_pjax( href, "by_scroll", "" );
}
}
}
}
});
// console.log("true");
scroll_action_flag = true;
}
, 1000);
}
window_action();
}
function entry_scroll() {
scroll_val = $("#entry > div.inner").scrollTop();
if( $("#entry > div.inner > article")[0] ){
scroll_val = $("#entry > div.inner").scrollTop();
// console.log(scroll_val+window_height+"|"+ Number(entry_height - 100));
if( scroll_val+window_height > entry_height - 100 ){
$("html").addClass("scrolled")
$("html").addClass("scrollend")
}else if( scroll_val < Math.round(window_height/100) ){
$("html").removeClass("scrolled")
$("html").removeClass("scrollend")
}else if( scroll_val >= Math.round(window_height/100) && scroll_val+window_height < entry_height - 100 ){
$("html").addClass("scrolled")
$("html").removeClass("scrollend")
}else{
$("html").addClass("scrolled")
$("html").addClass("scrollend")
}
}
window_action();
}
function window_action() {
scroll_val = $(window).scrollTop();
var target_width = window_width;
var slide_margin = Math.floor(scroll_val-window_height)/2;
if( scroll_val < window_height ){
if( $("#slide_wrapper")[0] ){
$("#slide_wrapper").css({
"opacity": Math.floor((1-scroll_val/(window_height))*1000)/1000
});
$("#slide_wrapper").css({
"transform": "matrix(1, 0, 0, 1, 0, "+ (-scroll_val/2) +")"
});
}
}else{
if( $("#slide_wrapper")[0] ){
$("#slide_wrapper").css({
"opacity": 0
});
}
}
if( scroll_val < window_height ){
$("#navi").removeClass("show");
}else if( scroll_val >= window_height ){
$("#navi").addClass("show");
}
if( window_width > 800 ){
$("body").removeClass("m-800");
$("div#menu_toggle").removeClass("show");
if( $("#navi nav").css("display") == "none" ){
$("#navi nav").css({
"display": "block"
});
}
if( scroll_val < window_height && $("body").attr("data-scroll_flag") == "true" ){
$("#wrapper > .scroll_down").fadeIn(200);
$("#return_top").stop().animate({
"bottom": "-50px"
},500);
$("body").attr("data-scroll_flag","false");
}else if( scroll_val >= window_height && $("body").attr("data-scroll_flag") == "false" ){
$("#wrapper > .scroll_down").stop().fadeOut(200);
$("#return_top").stop().animate({
"bottom": "0px"
},500);
$("body").attr("data-scroll_flag","true");
}
}else{
$("body").addClass("m-800");
$("div#menu_toggle").addClass("show");
if( scroll_val < window_height && $("body").attr("data-scroll_flag") == "true" ){
$("#wrapper > .scroll_down").fadeIn(200);
$("#return_top").stop().animate({
"bottom": "-50px"
},500);
$("body").attr("data-scroll_flag","false");
}else if( scroll_val >= window_height && $("body").attr("data-scroll_flag") == "false" ){
$("#wrapper > .scroll_down").stop().fadeOut(200);
$("#return_top").stop().animate({
"bottom": "0px"
},500);
$("body").attr("data-scroll_flag","true");
}
}
}
function window_resize() {
document_height = $(document).height();
content_height = get_total_height($("#container > div#base > *"));
entry_height = get_total_height($("#entry > div.inner > *"));
if( $("html.touch_device")[0] ){
if( window.innerHeight > window.innerWidth ){
window_height = $(window).height();
}else{
window_height = $(window).height();
}
}else{
window_height = window.innerHeight ? window.innerHeight: $(window).height();
}
window_width = $(window).width();
window_ratio = window_height / window_width;
if( window_ratio > 1 ){
$("html").removeClass("horizontal");
$("html").addClass("portrait");
}else{
$("html").removeClass("portrait");
$("html").addClass("horizontal");
}
if( window_ratio < 0.6 ){
$("html").addClass("panorama");
}else{
$("html").removeClass("panorama");
}
if( window_width < 600 ){
$("html").addClass("u_600");
}else{
$("html").removeClass("u_600");
}
if( $("div.scroll_base")[0] ){
$("div.scroll_base").each(function(){
if( $(this).outerWidth() >= $(this).children("div.wrapper").first().outerWidth() ){
$(this).removeClass("scrollable");
}else{
$(this).addClass("scrollable");
}
scroll_base_init($(this));
});
}
if( $("div#slide_wrapper > div.slide")[0] ){
$("div#slide_wrapper > div.slide > div.img > img").each(function(){
$(this).imagesLoaded(function(){
$(this).addClass("loaded");
var img_ratio = $(this).height() / $(this).width();
$(this).parent().removeClass("horizontal vertical");
if( window_ratio < img_ratio ){
$(this).parent().addClass("vertical");
}else{
$(this).parent().addClass("horizontal");
}
});
});
}
iframe_fit_height();
if( $("#entry > div.inner > article")[0] ){
entry_scroll_bind();
entry_scroll();
}else{
base_scroll();
}
window_action();
}
var scroll_flug = true;
$(window).on("scroll.main",function(){
setTimeout(function(){
scroll_flug = true;
}, 10);
if(scroll_flug){
scroll_flug = false;
base_scroll();
}
});
function entry_scroll_bind(){
if( $("#entry > div.inner > article")[0] ){
$("html").removeClass("scrolled");
$("html").removeClass("scrollend");
$("#entry > div.inner").on("scroll.main",function(){
entry_scroll();
// if(scroll_flug){
// scroll_flug = false;
// base_scroll();
// setTimeout(function(){
// scroll_flug = true;
// return scroll_flug;
// }, 50);
// }
});
}
}
$(window).bind("resize", window_resize);
function selectorEscape(val){
return val.replace(/\//g, '\\/');
}
function video_stop(){
$("article#top > div.inner > div.video > ul > li.video_1.part").removeClass("active");
setTimeout(function(){
$("article#top > div.inner > div.video > ul > li.video_1.part > div").empty();
$("article#top > div.inner > div.video > ul > li.video_2.part").removeClass("active");
setTimeout(function(){
$("article#top > div.inner > div.video > ul > li.video_2.part > div").empty();
},1000);
},1000);
}
function video_play(){
if( $("body.root")[0] ){
setTimeout(function(){
$("article#top > div.inner > div.video > ul > li.video_1.part").addClass("active");
create_video( $("article#top > div.inner > div.video > ul > li.video_1.part > div") , "https://value-home.jp/elements/video_01" , "video_01" );
setTimeout(function(){
$("article#top > div.inner > div.video > ul > li.video_2.part").addClass("active");
create_video( $("article#top > div.inner > div.video > ul > li.video_2.part > div") , "https://value-home.jp/elements/video_02" , "video_02" );
setTimeout(function(){
$("article#top > div.inner > div.video > ul > li.part > div > img").fadeIn(1000);
},1000);
},500);
},4000);
}
// if( $("body.root")[0] ){
// setTimeout(function(){
// $("article#top > div.inner > div.video > ul > li.video_1.part").addClass("active");
// create_video( $("article#top > div.inner > div.video > ul > li.video_1.part > div") , "http://test:1111@leafbrand.co.jp/elements/video_01" , "video_01" );
// setTimeout(function(){
// $("article#top > div.inner > div.video > ul > li.video_2.part").addClass("active");
// create_video( $("article#top > div.inner > div.video > ul > li.video_2.part > div") , "http://test:1111@leafbrand.co.jp/elements/video_02" , "video_02" );
// setTimeout(function(){
// $("article#top > div.inner > div.video > ul > li.part > div > img").fadeIn(1000);
// },1000);
// },500);
// },4000);
// }
}
function create_video(target, video_file, target_id) {
if( $("html.touch_device.iOS")[0] ) {
var width = target.outerWidth();
var height = target.outerHeight();
target.append('
');
setTimeout(function(){
target.parent().addClass("play");
var video = document.createElement('video');
video.style.display = 'none';
document.body.appendChild(video);
var canvas = document.getElementById('video_canvas_'+target_id);
$(canvas).css({"display": "block"});
var ctx = canvas.getContext("2d");
var ctime = 0;
var lastTime;
video.addEventListener('canplay',function(){
lastTime = Date.now();
setInterval(function(){
var curTime = Date.now();
var diff = Date.now() - lastTime;
lastTime = curTime;
ctime += diff/1000;
video.currentTime = ctime;
ctx.drawImage(video, 0, 0, width, height);
if(video.duration <= video.currentTime){
ctime = 0;
}
}, 1000/30);
},false);
video.src = video_file +'.mp4?24042821';
video.load();
},1000);
}else{
target.append('
');
setTimeout(function(){
target.parent().addClass("play");
target.find("video").each(function(){
if( ! $(this).hasClass("play") ){
$(this).addClass("play");
$(this).get(0).play();
}
});
},1000);
}
}
function load_iframe(){
$("iframe.preload:not('.loaded')").each(function(){
$(this).load(function(){
$(this).addClass("loaded");
});
});
}
load_iframe();
var start_limit = 2000;
$("html").data("preloaded", 0);
function preload(){
var img = [],
img_arr = $("img.preload"), // ローディング対象の画像を指定
img_arr_lngth = img_arr.size();
var img_arr_lngth_total = img_arr_lngth;
if( img_arr_lngth_total > 0 ){
img_arr.each(function(indx){
img[indx] = new Image();
img[indx].onload = function(){
img_arr_lngth = img_arr_lngth - 1;
var progress = Math.round((1-img_arr_lngth/img_arr_lngth_total)*100);
$("div.progress").stop().animate({"width": progress + "%"},2000);
if( 0 >= img_arr_lngth ){
// img_load();
// window_resize();
$("html").data("preloaded", 1);
$("div.progress").stop().animate({"width": "100%"},1500,"easeOutQuad",function(){
setTimeout(function(){
$("div.progress").addClass("out");
var timer = getPast();
// console.log(timer);
$("#header").addClass("start");
if( timer > start_limit ){
preload_finish();
}else{
setTimeout(function(){
// console.log(getPast());
preload_finish();
},start_limit-timer);
}
},200);
});
}
};
img[indx].src = $(this).attr('src');
});
}else{
$("html").data("preloaded", 1);
$("div#progress").stop().animate({"width": "100%"},1500,"easeOutQuad",function(){
setTimeout(function(){
$("div.progress").addClass("out");
setTimeout(function(){
$("div#preloader").fadeOut(2000, function() {
$(this).remove();
window_resize();
});
},1000);
},200);
});
}
}
function preload_finish(){
window_resize();
if( $("body #container > div#base article.ground")[0] ){
var target = $("#" + selectorEscape($("body").attr("data-scroll")));
if( target[0] ){
var val = target.offset().top;
scrollto(val);
}else{
scroll_action_flag = true;
}
}
$("div#preloader").fadeOut(200, function() {
$(this).remove();
$("html").addClass("start");
if( $("div#slide_wrapper > div.slide")[0] ) {
top_slide_start( $("div#slide_wrapper > div.slide") );
}
// window.FB.XFBML.parse();
});
}
function rnd(n){
return Math.floor(Math.random()*(n+1));
}
function slide_switch(target_wrapper, past_target, next_target) {
var next_id = next_target.attr("id");
target_wrapper.children("ul.dots").find("li").removeClass("active");
var next_dot = target_wrapper.find("."+next_id).addClass("active");
if( past_target != "" ){
past_target.addClass("pending active");
}
img_url = next_target.find("div.img").attr("data-img-url");
next_target.find("div.img > img").imagesLoaded(function(){
if( past_target != "" ){
setTimeout(function(){
past_target.removeClass("pending active");
next_target.addClass("active");
},1500);
}else{
next_target.addClass("active");
}
slide_repeat(target_wrapper);
});
next_target.find("div.img > img").attr("src", img_url);
}
function slide_repeat(target_wrapper) {
var max_num = target_wrapper.find("ul.carousel > li.cell").length;
if( typeof timerId_slide != "undefined" ){
clearTimeout(timerId_slide);
}
timerId_slide = setTimeout(function(){
if( max_num > 1 ){
var past_target = target_wrapper.find("ul.carousel > li.cell.active");
var next_target = "";
if( past_target.next("li")[0] ){
next_target = past_target.next("li");
}else{
next_target = target_wrapper.find("ul.carousel > li.cell").first();
}
slide_switch(target_wrapper, past_target, next_target);
}else{
clearTimeout(timerId_slide);
}
},6000);
}
function slide_start(target_wrapper) {
target_wrapper.addClass("active");
target_wrapper.append('
');
target_wrapper.find("ul.carousel > li.cell").each(function(i){
var set_class = $(this).attr("id");
target_wrapper.children("ul.dots").append('
');
});
var max_num = target_wrapper.find("ul.carousel > li.cell").length;
// var first_target = target_wrapper.find("ul.carousel > li.cell").eq(rnd(max_num-1));
var first_target = target_wrapper.find("ul.carousel > li.cell").eq(0);
var img_url = first_target.find("div.img").attr("data-img-url");
first_target.find("div.img > img").imagesLoaded(function(){
slide_switch(target_wrapper, "", first_target);
slide_repeat(target_wrapper);
});
first_target.find("div.img > img").attr("src", img_url);
target_wrapper.children("ul.dots").find("li").click(function(){
if( !$(this).hasClass("active") ){
var past_target = target_wrapper.find("ul.carousel > li.cell.active");
var next_target = target_wrapper.find("ul.carousel > li.cell#"+$(this).attr("class"));
slide_switch(target_wrapper, past_target, next_target);
}
})
}
$(document).on("click", "article#root > article#top div.slide > ul.carousel > li.cell > a[data-link-to-flag='media']", function(){
return false;
});
function top_slide_start(target_wrapper) {
$("article#root > article#top").addClass("start");
$("html").removeClass("slide_end");
window_resize();
var slide_i = 1;
var max_num = target_wrapper.children("div.img").length;
// target_wrapper.children("div.img").eq(rnd(max_num-1)).addClass("active");
target_wrapper.children("div.img:first-child").addClass("active");
if( typeof timerId_slide != "undefined" ){
clearInterval(timerId_slide);
}
timerId_slide = setInterval(function(){
if( max_num > 1 ){
var past_target = target_wrapper.children("div.img.active");
var next_target = "";
if( past_target.next("div.img")[0] ){
slide_i += 1;
past_target.removeClass("active");
next_target = past_target.next("div.img");
next_target.addClass("active");
if( slide_i == max_num ){
$("article#root > article#top").addClass("slide_last");
setInterval(function(){
$("html").addClass("slide_end");
},5000);
}
}else{
clearInterval(timerId_slide);
// next_target = target_wrapper.children("div.img").first();
}
}else{
clearInterval(timerId_slide);
}
},9000);
setTimeout(
function(){
$("aside.top_info").animate({"opacity":1},4000, "easeOutQuint");
}
, 2000);
}
function video_start(target_video_selector) {
if( $(target_video_selector)[0] ){
var player = $(target_video_selector).get(0);
player.play();
}
}
function get_total_height(elms) {
var total_height = 0;
elms.each(function(i){
var height = $(this).outerHeight(true);
total_height += height;
});
return total_height;
}
function PJAX_hash( hash ) {
if( hash.indexOf( "tag/" ) != -1 ){
hash = decodeURI(hash);
var tag_arr = hash.split("tag/");
var tag = tag_arr[1];
// console.log(".filter.tag_"+tag);
$("a[href^='#/tag/']").removeClass("active");
$("a[href='#/tag/"+tag+"']").addClass("active");
if( tag == "" ){
// console.log("tag: all");
$(".filter").removeClass("hide");
}
if( $(".filter.tag_"+tag)[0] ){
// console.log("tag: "+tag);
$(".filter").addClass("hide");
$(".filter.tag_"+tag).removeClass("hide");
var val = $(".filter.tag_"+tag).first().offset().top - 120;
scrollto(val);
}else{
$(".filter").removeClass("hide");
var val = $("a[href='#/tag/']").first().offset().top - 120;
scrollto(val);
}
}else{
if( $("[data-scrollto='"+hash+"']")[0] ){
var val = $("[data-scrollto='"+hash+"']").first().position().top - 120;
// console.log(val);
scrollto(val);
}
if( $("#"+hash)[0] ){
var val = $("#"+hash).first().position().top - 120;
// console.log(val);
scrollto(val);
}
}
}
function navi_active(href){
if( href == "https://value-home.jp/" || href == "https://value-home.jp/list/" ){
$("div#navi > nav > div.navi > div.input_select > select").each(function(i){
$(this).val("");
$(this).removeClass("active");
});
}else if( $("div#navi > nav > div.navi > div.input_select > select > option[value='"+href+"']")[0] ){
var target = $("div#navi > nav > div.navi > div.input_select > select > option[value='"+href+"']").parent("select");
var id = target.attr("id");
// console.log(id);
// console.log(href);
$("div#navi > nav > div.navi > div.input_select > select").each(function(i){
if( $(this).attr("id") == id ){
$(this).val(href);
$(this).addClass("active");
}else{
$(this).val("");
$(this).removeClass("active");
}
});
}
}
$(document).on("change", "div#navi > nav > div.navi > div.input_select > select", function(e) {
var href = $(this).val();
// console.log(href);
PJAX_pjax( href, "", "" );
return false;
});
var getPast = (function() {
var lastDate = NaN;
return function() {
var now = Date.now();
var past = now - lastDate;
lastDate = now;
return past;
};
})();
window.iframe_fit_height = function () {
$('iframe.iframe_fit_height').each(function(){
var D = $(this).get(0).contentWindow.document;
/*
// console.log(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
);
*/
if( D.body ){
var innerHeight = Math.max(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
);
$(this).removeAttr("height").css('height', innerHeight + 'px');
}
});
}
function img_load(){
$("img.preload:not('.loaded')").each(function(){
$(this).imagesLoaded(function(){
$(this).addClass("loaded");
});
});
}
var watch_target = document.getElementById('base');
var article_id = "";
function watch_reflesh(){
var observer = new MutationObserver(function() {
article_id = $("body #container > div#base > article:not(.leave)").attr("id");
if( article_id == "login/" && $("#login_complete")[0] ){
var href = "https://value-home.jp/accounts/";
PJAX_pjax( href, "", "" );
}
});
observer.observe(watch_target, { childList: true, subtree: true });
}
$("body #header > header > h1 > a > img").imagesLoaded(function(){
if( $("#preloader")[0] ){
$("div#preloader > div.bg").addClass("show");
preload();
getPast();
}
});
$(window).bind('load', function() {
if( $("#preloader")[0] ){
img_load();
watch_reflesh();
}
});
var iframe_contact_url = 'https://value-home.jp/form/form_contact';
var iframe_request_url = 'https://value-home.jp/form/form_request';
// if($("html.pc")[0]){
// iframe_contact_url = 'https://value-home.jp/form/form_contact';
// iframe_request_url = 'https://value-home.jp/form/form_request';
// }
$(document).on("click", "#navi > nav > ul > li.class_contact > a", function(){
$('iframe#form_contact').attr('src',iframe_contact_url);
$("#navi").removeClass("open");
return false;
})
$(document).on("click", "#navi > nav > ul > li.class_request > div", function(){
$('iframe#form_contact').attr('src',iframe_request_url);
$("#navi").removeClass("open");
PJAX_pjax( 'https://value-home.jp/contact' );
})
$(document).on("click", "article#address > dl > dd > a.email", function(){
$('iframe#form_contact').attr('src',iframe_contact_url);
$("#navi").removeClass("open");
return false;
})
});