/* global Modernizr, console */ var Themeoo, ThemeooCache = { $window: jQuery(window), $head: jQuery('#masthead'), $body: jQuery('body') }, $cs_body, $cs_main, $cs_masthead, $cs_window, $cs_document, cs_is_device, cs_is_sticky, cs_is_transparent, cs_is_small, cs_has_admin_bar, cs_is_blank, cs_no_mobile_anim, cs_sticky_height, cs_admin_bar_height, cs_header_height, cs_header_top; ( function( $, window, document ) { Themeoo = { initFormPlaceHolder: function () { if ( ! ( 'placeholder' in document.createElement( 'input' ) ) ) { $('input[placeholder], textarea[placeholder]').each(function () { var placeholder = $(this).attr('placeholder'); if (this.value === '') { this.value = placeholder; } $(this).focus(function () { if (this.value === placeholder) { this.value = ''; } }).blur(function () { if ($.trim(this.value) === '') { this.value = placeholder; } }); }); // Clear default placeholder values on form submit $('form').submit(function () { $(this).find('input[placeholder], textarea[placeholder]').each(function () { if (this.value === $(this).attr('placeholder')) { this.value = ''; } }); }); } }, initTooltip: function () { $('a[data-toggle=tooltip]').tooltip(); }, showBackToTop: function () { var offset = 300, //browser window scroll (in pixels) after which the 'back to top' link opacity is reduced offset_opacity = 1200, //grab the 'back to top' link $back_to_top = $('.cd-top'), $window = $(window); if ($window.scrollTop() > offset) { $back_to_top.addClass('cd-is-visible'); ThemeooCache.$body.addClass('scrolled'); } else { $back_to_top.removeClass('cd-is-visible cd-fade-out'); } if ($window.scrollTop() > offset_opacity) { $back_to_top.addClass('cd-fade-out'); } }, initBackToTop: function () { //smooth scroll to top $('.cd-top').on('click', function (event) { event.preventDefault(); $('body,html').animate({ scrollTop: 0, }, 700); }); }, initTransparentHeader: function () { if (ThemeooCache.$body.hasClass('transparent-header')) { return; } var ht = $('#masthead').height(), firstRow = $('.transparent-header .page-builder .themeoo-row:first-of-type .container:first-of-type, .transparent-header .page-builder .themeoo-row:first-of-type .container-fluid:first-of-type'); firstRow.css('padding-top', ht + 20); }, initMobileMenu: function () { $('#themeoo-mobile-icon').on('click', function (e) { e.preventDefault(); $(this).toggleClass('cs-collapse'); $('#navigation-mobile').slideToggle(500, 'easeInOutExpo'); }); $('#navigation-mobile li:has(ul) > .themeoo-dropdown-plus').on('click', function (e) { e.preventDefault(); $(this).toggleClass('cs-times'); $(this).parent().find('> ul').slideToggle(500, 'easeInOutExpo'); }); $('#navigation-mobile li:has(ul) > a').on('click', function (e) { if ($(this).attr('href') === '#') { e.preventDefault(); var $parent = $(this).parent(); $parent.find('> .themeoo-dropdown-plus').toggleClass('cs-times'); $parent.find('> ul').slideToggle(500, 'easeInOutExpo'); } }); }, staticVariables: function () { $themeoo_body = $('body'); $themeoo_masthead = $('#masthead'); $themeoo_main = $('#main'); $themeoo_window = $(window); $themeoo_document = $(document); themeoo_is_device = (navigator.userAgent.toLowerCase().match(/(android|webos|blackberry|ipod|iphone|ipad|opera mini|iemobile|windows phone|windows mobile)/)) ? true : false; themeoo_is_sticky = (parseInt(themeoo_ajax.sticky)) ? true : false; themeoo_has_admin_bar = ($themeoo_body.hasClass('admin-bar')) ? true : false; themeoo_sticky_height = (parseInt(themeoo_ajax.header)) ? parseInt(themeoo_ajax.header) : 50; themeoo_admin_bar_height = (themeoo_has_admin_bar) ? 32 : 0; themeoo_header_height = ($themeoo_masthead) ? $themeoo_masthead.outerHeight() : 0; themeoo_header_top = ($themeoo_masthead && $themeoo_masthead.offset()) ? $themeoo_masthead.offset().top : 0; }, dynamicVariables: function () { themeoo_is_small = (window.innerWidth < parseInt(themeoo_ajax.viewport)) ? true : false; }, initStickyHeader: function () { if (themeoo_is_sticky && !themeoo_is_device) { var _header_top = (themeoo_has_admin_bar) ? parseInt(themeoo_header_top - themeoo_admin_bar_height) : themeoo_header_top, _header_height, _scroll_top; $themeoo_window.scroll(function () { if (!themeoo_is_small) { _header_height = themeoo_header_height; _scroll_top = $(this).scrollTop(); if (_scroll_top > _header_top) { $themeoo_masthead.trigger('close-modals').addClass('is-sticky'); $themeoo_main.css('padding-top', _header_height); } else { $themeoo_masthead.removeClass('is-sticky'); $themeoo_main.removeAttr('style'); } if (_scroll_top > (_header_height + _header_top)) { $themeoo_masthead.addClass('is-compact'); } else { $themeoo_masthead.removeClass('is-compact'); } } }); } }, initFixSticky: function () { if (themeoo_is_sticky && themeoo_is_small) { $themeoo_masthead.removeClass('is-sticky is-compact'); $themeoo_main.removeAttr('style'); if (themeoo_is_transparent) { $themeoo_body.addClass('is-transparent cs-is-small'); $themeoo_window.scroll(); } } else { $themeoo_body.removeClass('cs-is-small'); } }, initContentProduct: function () { $(document).ready(function () { $(".largeGrid").click(function () { $(this).find('a').addClass('active'); $('.smallGrid a').removeClass('active'); $('.product-item').addClass('large').each(function () { }); setTimeout(function () { $('.info-large').show(); }, 200); setTimeout(function () { $('.view_gallery').trigger("click"); }, 400); return false; }); $(".smallGrid").click(function () { $(this).find('a').addClass('active'); $('.largeGrid a').removeClass('active'); $('div.product-item').removeClass('large'); $(".make3D").removeClass('animate'); $('.info-large').fadeOut("fast"); setTimeout(function () { $('div.flip-back').trigger("click"); }, 400); return false; }); $(".smallGrid").click(function () { $('.product-item').removeClass('large'); return false; }); $('.colors-large a').click(function () { return false; }); $('.product-item').each(function (i, el) { // Flip card to the back side $(el).find('.view_gallery').click(function () { $(el).find('div.carouselNext, div.carouselPrev').removeClass('visible'); $(el).find('.make3D').addClass('flip-10'); setTimeout(function () { $(el).find('.make3D').removeClass('flip-10').addClass('flip90').find('div.shadow').show().fadeTo(80, 1, function () { $(el).find('.product-front, .product-front div.shadow').hide(); }); }, 50); setTimeout(function () { $(el).find('.make3D').removeClass('flip90').addClass('flip190'); $(el).find('.product-back').show().find('div.shadow').show().fadeTo(90, 0); setTimeout(function () { $(el).find('.make3D').removeClass('flip190').addClass('flip180').find('div.shadow').hide(); setTimeout(function () { $(el).find('.make3D').css('transition', '100ms ease-out'); $(el).find('.cx, .cy').addClass('s1'); setTimeout(function () { $(el).find('.cx, .cy').addClass('s2'); }, 100); setTimeout(function () { $(el).find('.cx, .cy').addClass('s3'); }, 200); $(el).find('div.carouselNext, div.carouselPrev').addClass('visible'); }, 100); }, 100); }, 150); }); // Flip card back to the front side $(el).find('.flip-back').click(function () { $(el).find('.make3D').removeClass('flip180').addClass('flip190'); setTimeout(function () { $(el).find('.make3D').removeClass('flip190').addClass('flip90'); $(el).find('.product-back div.shadow').css('opacity', 0).fadeTo(100, 1, function () { $(el).find('.product-back, .product-back div.shadow').hide(); $(el).find('.product-front, .product-front div.shadow').show(); }); }, 50); setTimeout(function () { $(el).find('.make3D').removeClass('flip90').addClass('flip-10'); $(el).find('.product-front div.shadow').show().fadeTo(100, 0); setTimeout(function () { $(el).find('.product-front div.shadow').hide(); $(el).find('.make3D').removeClass('flip-10').css('transition', '100ms ease-out'); $(el).find('.cx, .cy').removeClass('s1 s2 s3'); }, 100); }, 150); }); makeCarousel(el); }); /* ---- Image Gallery Carousel ---- */ function makeCarousel(el) { var carousel = $(el).find('.carousel ul'); var productdiv = $('.product-item'); var carouselSlideWidth = productdiv.outerWidth(); var carouselWidth = 0; var isAnimating = false; var currSlide = 0; $(carousel).attr('rel', currSlide); // building the width of the casousel $(carousel).find('li').each(function () { carouselWidth += carouselSlideWidth; }); $(carousel).css('width', carouselWidth); $('.carousel li').css('width', carouselSlideWidth); $('.carousel').css('width', carouselSlideWidth); $('.arrows-perspective').css('width', carouselSlideWidth); // Load Next Image $(el).find('div.carouselNext').on('click', function () { var currentLeft = Math.abs(parseInt($(carousel).css("left"))); var newLeft = currentLeft + carouselSlideWidth; if (newLeft == carouselWidth || isAnimating === true) { return; } $(carousel).css({ 'left': "-" + newLeft + "px", "transition": "300ms ease-out" }); isAnimating = true; currSlide++; $(carousel).attr('rel', currSlide); setTimeout(function () { isAnimating = false; }, 300); }); // Load Previous Image $(el).find('div.carouselPrev').on('click', function () { var currentLeft = Math.abs(parseInt($(carousel).css("left"))); var newLeft = currentLeft - carouselSlideWidth; if (newLeft < 0 || isAnimating === true) { return; } $(carousel).css({ 'left': "-" + newLeft + "px", "transition": "300ms ease-out" }); isAnimating = true; currSlide--; $(carousel).attr('rel', currSlide); setTimeout(function () { isAnimating = false; }, 300); }); } $('.sizes a span, .categories a span').each(function (i, el) { $(el).append(''); $(el).parent().on('click', function () { if ($(this).hasClass('checked')) { $(el).find('.y').removeClass('animate'); setTimeout(function () { $(el).find('.x').removeClass('animate'); }, 50); $(this).removeClass('checked'); return false; } $(el).find('.x').addClass('animate'); setTimeout(function () { $(el).find('.y').addClass('animate'); }, 100); $(this).addClass('checked'); return false; }); }); //$("body").append('
'); $('.add_to_cart').click(function () { var productCard = $(this).parent(); var position = productCard.offset(); var productImage = $(productCard).find('img').get(0).src; var productName = $(productCard).find('.product_name').get(0).innerHTML; $("body").append(''); var cart = $('div.floating-cart'); productCard.clone().appendTo(cart); $(cart).css({ 'top': position.top + 'px', "left": position.left + 'px' }).fadeIn("slow").addClass('moveToCart'); setTimeout(function () { $("body").addClass("MakeFloatingCart"); }, 800); // setTimeout(function(){ // $('div.floating-cart').remove(); // $("body").removeClass("MakeFloatingCart"); // // // var cartItem = "