"use strict"; var SPEED = 3000; var BOOK_WIDTH = 1000; $(document).ready(function() { for (var i = 0; i < 4; i++) { $(".bookslide .bookall .conceal").clone().removeClass("conceal").addClass("bookone").appendTo(".bookslide .bookall"); } BOOK_WIDTH = $(".bookslide .bookall .bookone:first").outerWidth(true); $(".bookslide .bookall .bookone").each(function(index, element) { var $this = $(this); var offset = $this.offset(); //var width = $this.outerWidth(true); offset.left += index * BOOK_WIDTH; $this.offset(offset); return true; }).mouseenter(function(eventObject ) { $(".bookslide .bookall .bookone").stop(true, false); }).on("mouseleave.marquee", marquee).click(function(eventObject) { $(".res_txt").hide(); var $this = $(this); if ($this.hasClass("book1")) { $(".res_txt.p01").show(); } else if ($this.hasClass("book2")) { $(".res_txt.p02").show(); } else if ($this.hasClass("book3")) { $(".res_txt.p03").show(); } else if ($this.hasClass("book4")) { $(".res_txt.p04").show(); } var $win = $(window); var winWidth = $win.width(); var winHeight = $win.innerHeight(); $(".redmask").slideDown(1000, "easeOutBounce", function() { $(".bookslide .bookall .bookone").stop(true, false).off("mouseleave.marquee"); $(".main, .redtop:not(.redmask)").css("visibility", "hidden"); $("body").css("background", "#db423d"); /*if (winWidth <= 500) { var $layout = $(".redmask"); $(".footer").css("top", $layout.offset().top + $layout.outerHeight()); }*/ }); }).animate({ left: "-=" + BOOK_WIDTH }, SPEED, "linear", marquee_one); $(".redmask .once-more").click(function(eventObject) { $(".main, .redtop:not(.redmask)").css("visibility", "visible"); $("body").css("background", "#fff"); $(".redmask").slideUp(500, "swing", function(eventObject) { marquee(); $(".bookslide .bookall .bookone").on("mouseleave.marquee", marquee); mobile_footer(); }); }); $(".redmask .go-purchase").click(function(eventObject) { var $win = $(window); var winWidth = $win.width(); var winHeight = $win.innerHeight(); $(".purchase").fadeIn(1000, function() { $("body").css("background", "#fff"); $(".main, .redtop:not(.redmask)").hide(); $(".footer").toggle(); adjustFooter(); }); $(".redmask").fadeOut(3000); /*if (winWidth <= 500) { var $three = $(".three_m"); $(".footer").css("top", $three.offset().top + $three.outerHeight()); }*/ }); $(".purchase .once-more").click(function(eventObject) { var $main = $(".main, .redtop:not(.redmask)"); $main.show(); $(".footer").toggle(); $(".purchase").slideUp(500, "swing", function() { mobile_footer(); $main.css("visibility", "visible"); marquee(); }); $(".bookslide .bookall .bookone").on("mouseleave.marquee", marquee); }); $(".popup > .show > span").click(function() { var $this = $(this); if (!$this.hasClass("on")) { var index = $this.index(".popup > .show > span"); $(".popup > .show > span.on, .popup > .show > div.on").removeClass("on"); $this.add(".popup > .show > div:eq(" + index + ")").addClass("on"); } }); $(window).on("resize", function() { if ($(".footer2:visible").length > 0) { adjustFooter(); } }); mobile_footer(); }); function mobile_footer(e) { /*if ($(window).width() <= 500) { var $layout = $(".layout"); $(".footer").css("top", $layout.offset().top + $layout.outerHeight() + 150); }*/ } function marquee_one(e) { var $this = $(this); var offset = $this.offset(); //var width = $this.outerWidth(true); if (offset.left < BOOK_WIDTH * (-1)) { offset.left = $(".bookslide .bookall .bookone:last").offset().left + BOOK_WIDTH; $this.offset(offset).appendTo(".bookslide .bookall"); } $this.animate({ left: "-=" + BOOK_WIDTH }, SPEED, "linear", marquee); } function marquee(e) { $(".bookslide .bookall .bookone").animate({ left: "-=" + BOOK_WIDTH }, SPEED, "linear", marquee_one); } function close_popup(){ $(".popup").fadeOut(300); } function open_popup(){ $(".popup").fadeIn(300); } function adjustFooter() { var $win = $(window); if ($win.width() > 500) { var $footer = $(".footer2") var diff = $win.innerHeight() - $(".purchase").height(); if (diff > 0) { $footer.css("transform", "translateY(" + diff + "px)"); } else { $footer.css("transform", "none"); } } }