theme.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /**
  2. * Copyright © 2015 Magento. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. //require([
  6. // 'jquery',
  7. // 'bootstrap/js/bootstrap.min'
  8. //], function ($) {
  9. //});
  10. require([
  11. 'jquery',
  12. 'mage/smart-keyboard-handler',
  13. 'mage/mage',
  14. 'mage/ie-class-fixer',
  15. 'domReady!'
  16. ], function ($, keyboardHandler) {
  17. 'use strict';
  18. $(document).ready(function(){
  19. $('.cart-summary').mage('sticky', {
  20. container: '#maincontent'
  21. });
  22. $('.panel.header .header.links').clone().appendTo('#store\\.links');
  23. });
  24. keyboardHandler.apply();
  25. });
  26. /******************** Init Parallax ***********************/
  27. require([
  28. 'jquery',
  29. 'js/jquery.stellar.min'
  30. ], function ($) {
  31. $(document).ready(function(){
  32. $(window).stellar({
  33. responsive: true,
  34. scrollProperty: 'scroll',
  35. parallaxElements: false,
  36. horizontalScrolling: false,
  37. horizontalOffset: 0,
  38. verticalOffset: 0
  39. });
  40. });
  41. });
  42. require([
  43. 'jquery'
  44. ], function ($) {
  45. (function() {
  46. var ev = new $.Event('classadded'),
  47. orig = $.fn.addClass;
  48. $.fn.addClass = function() {
  49. $(this).trigger(ev, arguments);
  50. return orig.apply(this, arguments);
  51. }
  52. })();
  53. $.fn.extend({
  54. scrollToMe: function(){
  55. if($(this).length){
  56. var top = $(this).offset().top - 100;
  57. $('html,body').animate({scrollTop: top}, 300);
  58. }
  59. },
  60. scrollToJustMe: function(){
  61. if($(this).length){
  62. var top = jQuery(this).offset().top;
  63. $('html,body').animate({scrollTop: top}, 300);
  64. }
  65. }
  66. });
  67. $(document).ready(function(){
  68. var windowScroll_t;
  69. $(window).scroll(function(){
  70. clearTimeout(windowScroll_t);
  71. windowScroll_t = setTimeout(function(){
  72. if(jQuery(this).scrollTop() > 100){
  73. $('#totop').fadeIn();
  74. }else{
  75. $('#totop').fadeOut();
  76. }
  77. }, 500);
  78. });
  79. $('#totop').off("click").on("click",function(){
  80. $('html, body').animate({scrollTop: 0}, 600);
  81. });
  82. if ($('body').hasClass('checkout-cart-index')) {
  83. if ($('#co-shipping-method-form .fieldset.rates').length > 0 && $('#co-shipping-method-form .fieldset.rates :checked').length === 0) {
  84. $('#block-shipping').on('collapsiblecreate', function () {
  85. $('#block-shipping').collapsible('forceActivate');
  86. });
  87. }
  88. }
  89. $(".products-grid .weltpixel-quickview").each(function(){
  90. $(this).appendTo($(this).parent().parent().children(".product-item-photo"));
  91. });
  92. $(".word-rotate").each(function() {
  93. var $this = $(this),
  94. itemsWrapper = $(this).find(".word-rotate-items"),
  95. items = itemsWrapper.find("> span"),
  96. firstItem = items.eq(0),
  97. firstItemClone = firstItem.clone(),
  98. itemHeight = 0,
  99. currentItem = 1,
  100. currentTop = 0;
  101. itemHeight = firstItem.height();
  102. itemsWrapper.append(firstItemClone);
  103. $this
  104. .height(itemHeight)
  105. .addClass("active");
  106. setInterval(function() {
  107. currentTop = (currentItem * itemHeight);
  108. itemsWrapper.animate({
  109. top: -(currentTop) + "px"
  110. }, 300, function() {
  111. currentItem++;
  112. if(currentItem > items.length) {
  113. itemsWrapper.css("top", 0);
  114. currentItem = 1;
  115. }
  116. });
  117. }, 2000);
  118. });
  119. $(".top-links-icon").off("click").on("click", function(e){
  120. if($(this).parent().children("ul.links").hasClass("show")) {
  121. $(this).parent().children("ul.links").removeClass("show");
  122. } else {
  123. $(this).parent().children("ul.links").addClass("show");
  124. }
  125. e.stopPropagation();
  126. });
  127. $(".top-links-icon").parent().click(function(e){
  128. e.stopPropagation();
  129. });
  130. $(".search-toggle-icon").click(function(e){
  131. if($(this).parent().children(".block-search").hasClass("show")) {
  132. $(this).parent().children(".block-search").removeClass("show");
  133. } else {
  134. $(this).parent().children(".block-search").addClass("show");
  135. }
  136. e.stopPropagation();
  137. });
  138. $(".search-toggle-icon").parent().click(function(e){
  139. e.stopPropagation();
  140. });
  141. $("html,body").click(function(){
  142. $(".search-toggle-icon").parent().children(".block-search").removeClass("show");
  143. $(".top-links-icon").parent().children("ul.links").removeClass("show");
  144. });
  145. /********************* Qty Holder **************************/
  146. $(document).on("click", ".qtyplus", function(e) {
  147. // Stop acting like a button
  148. e.preventDefault();
  149. // Get its current value
  150. var currentVal = parseInt($(this).parents('form').find('input[name="qty"]').val());
  151. // If is not undefined
  152. if (!isNaN(currentVal)) {
  153. // Increment
  154. $(this).parents('form').find('input[name="qty"]').val(currentVal + 1);
  155. } else {
  156. // Otherwise put a 0 there
  157. $(this).parents('form').find('input[name="qty"]').val(0);
  158. }
  159. });
  160. // This button will decrement the value till 0
  161. $(document).on("click", ".qtyminus", function(e) {
  162. // Stop acting like a button
  163. e.preventDefault();
  164. // Get the field name
  165. fieldName = $(this).attr('field');
  166. // Get its current value
  167. var currentVal = parseInt($(this).parents('form').find('input[name="qty"]').val());
  168. // If it isn't undefined or its greater than 0
  169. if (!isNaN(currentVal) && currentVal > 0) {
  170. // Decrement one
  171. $(this).parents('form').find('input[name="qty"]').val(currentVal - 1);
  172. } else {
  173. // Otherwise put a 0 there
  174. $(this).parents('form').find('input[name="qty"]').val(0);
  175. }
  176. });
  177. $(".qty-inc").unbind('click').click(function(){
  178. if($(this).parents('.field.qty').find("input.input-text.qty").is(':enabled')){
  179. $(this).parents('.field.qty').find("input.input-text.qty").val((+$(this).parents('.field.qty').find("input.input-text.qty").val() + 1) || 0);
  180. $(this).parents('.field.qty').find("input.input-text.qty").trigger('change');
  181. $(this).focus();
  182. }
  183. });
  184. $(".qty-dec").unbind('click').click(function(){
  185. if($(this).parents('.field.qty').find("input.input-text.qty").is(':enabled')){
  186. $(this).parents('.field.qty').find("input.input-text.qty").val(($(this).parents('.field.qty').find("input.input-text.qty").val() - 1 > 0) ? ($(this).parents('.field.qty').find("input.input-text.qty").val() - 1) : 0);
  187. $(this).parents('.field.qty').find("input.input-text.qty").trigger('change');
  188. $(this).focus();
  189. }
  190. });
  191. /********** Fullscreen Slider ************/
  192. var s_width = $(window).outerWidth();
  193. var s_height = $(window).outerHeight();
  194. var s_ratio = s_width/s_height;
  195. var v_width=320;
  196. var v_height=240;
  197. var v_ratio = v_width/v_height;
  198. $(".full-screen-slider div.item").css("position","relative");
  199. $(".full-screen-slider div.item").css("overflow","hidden");
  200. $(".full-screen-slider div.item").width(s_width);
  201. $(".full-screen-slider div.item").height(s_height);
  202. $(".full-screen-slider div.item > video").css("position","absolute");
  203. $(".full-screen-slider div.item > video").bind("loadedmetadata",function(){
  204. v_width = this.videoWidth;
  205. v_height = this.videoHeight;
  206. v_ratio = v_width/v_height;
  207. if(s_ratio>=v_ratio){
  208. $(this).width(s_width);
  209. $(this).height("");
  210. $(this).css("left","0px");
  211. $(this).css("top",(s_height-s_width/v_width*v_height)/2+"px");
  212. }else{
  213. $(this).width("");
  214. $(this).height(s_height);
  215. $(this).css("left",(s_width-s_height/v_height*v_width)/2+"px");
  216. $(this).css("top","0px");
  217. }
  218. $(this).get(0).play();
  219. });
  220. if($(".page-header").hasClass("type10")) {
  221. if(s_width >= 992){
  222. $(".navigation").addClass("side-megamenu")
  223. } else {
  224. $(".navigation").removeClass("side-megamenu")
  225. }
  226. }
  227. $(window).resize(function(){
  228. s_width = $(window).innerWidth();
  229. s_height = $(window).innerHeight();
  230. s_ratio = s_width/s_height;
  231. $(".full-screen-slider div.item").width(s_width);
  232. $(".full-screen-slider div.item").height(s_height);
  233. $(".full-screen-slider div.item > video").each(function(){
  234. if(s_ratio>=v_ratio){
  235. $(this).width(s_width);
  236. $(this).height("");
  237. $(this).css("left","0px");
  238. $(this).css("top",(s_height-s_width/v_width*v_height)/2+"px");
  239. }else{
  240. $(this).width("");
  241. $(this).height(s_height);
  242. $(this).css("left",(s_width-s_height/v_height*v_width)/2+"px");
  243. $(this).css("top","0px");
  244. }
  245. });
  246. if($(".page-header").hasClass("type10")) {
  247. if(s_width >= 992){
  248. $(".navigation").addClass("side-megamenu")
  249. } else {
  250. $(".navigation").removeClass("side-megamenu")
  251. }
  252. }
  253. });
  254. var breadcrumb_pos_top = 0;
  255. $(window).scroll(function(){
  256. if(!$("body").hasClass("cms-index-index")){
  257. var side_header_height = $(".page-header.type10, .page-header.type22").innerHeight();
  258. var window_height = $(window).height();
  259. if(side_header_height-window_height<$(window).scrollTop()){
  260. if(!$(".page-header.type10, .page-header.type22").hasClass("fixed-bottom"))
  261. $(".page-header.type10, .page-header.type22").addClass("fixed-bottom");
  262. }
  263. if(side_header_height-window_height>=$(window).scrollTop()){
  264. if($(".page-header.type10, .page-header.type22").hasClass("fixed-bottom"))
  265. $(".page-header.type10, .page-header.type22").removeClass("fixed-bottom");
  266. }
  267. }
  268. if($("body.side-header .page-wrapper > .breadcrumbs").length){
  269. if(!$("body.side-header .page-wrapper > .breadcrumbs").hasClass("fixed-position")){
  270. breadcrumb_pos_top = $("body.side-header .page-wrapper > .breadcrumbs").offset().top;
  271. if($("body.side-header .page-wrapper > .breadcrumbs").offset().top<$(window).scrollTop()){
  272. $("body.side-header .page-wrapper > .breadcrumbs").addClass("fixed-position");
  273. }
  274. }else{
  275. if($(window).scrollTop()<=1){
  276. $("body.side-header .page-wrapper > .breadcrumbs").removeClass("fixed-position");
  277. }
  278. }
  279. }
  280. });
  281. });
  282. });
  283. require([
  284. 'jquery',
  285. 'js/jquery.lazyload'
  286. ], function ($) {
  287. $(document).ready(function(){
  288. $("img.porto-lazyload:not(.porto-lazyload-loaded)").lazyload({effect:"fadeIn"});
  289. if ($('.porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').length) {
  290. $('.porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('changed.owl.carousel', function() {
  291. $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
  292. });
  293. $('.porto-lazyload:not(.porto-lazyload-loaded)').closest('.owl-carousel').on('initialized.owl.carousel', function() {
  294. $(this).find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
  295. });
  296. }
  297. window.setTimeout(function(){
  298. $('.sidebar-filterproducts').find('.porto-lazyload:not(.porto-lazyload-loaded)').trigger('appear');
  299. },500);
  300. });
  301. });