ui.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. $(function(){
  2. // nav car search
  3. $("#nav .car_search, #nav .nav_list .guide").click(function(){
  4. if(!$(this).hasClass("on")){
  5. //$(this).addClass("on");
  6. $("#nav .car_search, #nav .nav_list .guide").addClass("on");
  7. $("#search_box_wrap").animate({"width":"340px"}, 500);
  8. } else {
  9. $("#search_box_wrap").animate({"width":"0"}, 500, function(){
  10. $("#nav .car_search, #nav .nav_list .guide").removeClass("on");
  11. });
  12. }
  13. return false;
  14. });
  15. $("#search_box .close").click(function(){
  16. $("#search_box_wrap").animate({"width":"0"}, 500, function(){
  17. $("#nav .car_search").removeClass("on");
  18. });
  19. return false;
  20. });
  21. $("#search_box ul > li > span").click(function(){
  22. if(!$(this).parent().hasClass("open")){
  23. $(this).parent().siblings("li").removeClass("open");
  24. $(this).parent().siblings("li").find("ul").hide();
  25. $(this).parent().addClass("open");
  26. $(this).parent().find("ul").show();
  27. } else {
  28. $(this).parent().removeClass("open");
  29. $(this).siblings("ul").hide();
  30. }
  31. });
  32. $("#search_box .option > li").click(function(){
  33. var _text = $(this).text();
  34. $(this).parent().siblings("span").text(_text);
  35. $(this).parent().hide();
  36. $(this).parents().parents().removeClass("open");
  37. if(!$(this).hasClass("select")){
  38. $(this).siblings().removeClass("select");
  39. $(this).addClass("select");
  40. }
  41. });
  42. // car search
  43. $(".search > ul > li > span").click(function(){
  44. if(!$(this).parent().hasClass("open")){
  45. $(this).parent().siblings("li").removeClass("open");
  46. $(this).parent().siblings("li").find("ul").hide();
  47. $(this).parent().addClass("open");
  48. $(this).parent().find("ul").show();
  49. } else {
  50. $(this).parent().removeClass("open");
  51. $(this).siblings("ul").hide();
  52. }
  53. });
  54. $(".search .option > li").click(function(){
  55. var _text = $(this).text();
  56. $(this).parent().siblings("span").text(_text);
  57. $(this).parent().hide();
  58. $(this).parents().parents().removeClass("open");
  59. if(!$(this).hasClass("select")){
  60. $(this).siblings().removeClass("select");
  61. $(this).addClass("select");
  62. }
  63. });
  64. $(document).mouseup(function(e) {
  65. var container = $(".search");
  66. var container_in = $(".search .option");
  67. if (!container.is(e.target) && container.has(e.target).length === 0){
  68. container_in.css("display","none");
  69. container.find("li").removeClass("open");
  70. }
  71. });
  72. // option
  73. $(".option_info > li > span").click(function(){
  74. if(!$(this).hasClass("on")){
  75. $(this).parents(".option_info").find("li > span").removeClass("on");
  76. $(this).parents(".option_info").find("li ul").hide();
  77. $(this).addClass("on");
  78. $(this).siblings().show();
  79. } else {
  80. $(this).removeClass("on");
  81. $(this).siblings().hide();
  82. }
  83. });
  84. // go to top
  85. $("#nav .btn_top").mouseover(function(){
  86. $(this).addClass("on");
  87. });
  88. $("#nav .btn_top").mouseleave(function(){
  89. $(this).removeClass("on");
  90. });
  91. $("#nav .btn_top a").click(function(){
  92. $("html,body").animate({scrollTop:"0"}, 300);
  93. return false;
  94. });
  95. // top visual
  96. var swiper = new Swiper('#visual', {
  97. slidesPerView: 1,
  98. loop: true,
  99. speed: 800,
  100. pagination: {
  101. el: '.swiper-pagination',
  102. clickable: true,
  103. },
  104. autoplay: {
  105. delay: 3000,
  106. disableOnInteraction: false,
  107. },
  108. });
  109. // photo
  110. $(".car_photo li, .showroom_photo li").click(function(){
  111. //var _place = $(".car_photo .placeholder").find("img");
  112. var _place = $(this).parent().parent().siblings(".placeholder");
  113. var _img = _place.find("img");
  114. var _src = $(this).find("img").attr("src");
  115. _img.attr("src", _src);
  116. });
  117. // tab
  118. $(".tab_blue li").click(function(){
  119. var _idx = $(this).index();
  120. $(".tab_cont").hide().eq(_idx).show();
  121. if(!$(this).hasClass("on")){
  122. $(this).parent().find("li").removeClass("on");
  123. $(this).addClass("on");
  124. }
  125. return false;
  126. });
  127. Resize();
  128. $( window ).resize(function() {
  129. Resize();
  130. });
  131. });
  132. // layer popup
  133. function viewPopup(obj){
  134. $("." + obj + "_popup").show();
  135. $("body").append("<div class='dim'></div>");
  136. }
  137. function closePopup(obj){
  138. $("." + obj + "_popup").hide();
  139. $(".dim").remove();
  140. }
  141. // banner
  142. function Resize(){
  143. var w = $("body").width();
  144. if(w > 1900){
  145. $("#left_banner").addClass("wide");
  146. } else {
  147. $("#left_banner").removeClass("wide");
  148. }
  149. $(window).scroll(function(){
  150. var scrollTop = $(window).scrollTop();
  151. if(scrollTop > 540){
  152. $("#left_banner").css({"position":"fixed","top":"20px"});
  153. } else {
  154. $("#left_banner").css({"position":"absolute","top":"560px"});
  155. }
  156. }).scroll();
  157. /*var iScrollPos = 0;
  158. $(window).scroll(function() {
  159. var iCurScrollPos = $(this).scrollTop();
  160. var scrollTop = $(window).scrollTop();
  161. var newPosition = scrollTop + 560;
  162. var bannerOffset = $("#left_banner").offset();
  163. var bannerH = $("#left_banner").height();
  164. if (iCurScrollPos > iScrollPos && bannerOffset.top + bannerH >= $(document).outerHeight() - 370) {
  165. $("#left_banner").css({"top":bannerOffset.top + "px"});
  166. } else if(iCurScrollPos < iScrollPos && newPosition == $(document).height() - bannerOffset.top) {
  167. $("#left_banner").css({"top":newPosition + "px"});
  168. } else {
  169. $("#left_banner").css({"top":newPosition + "px"});
  170. }
  171. iScrollPos = iCurScrollPos;
  172. }).scroll();*/
  173. }