3 /* ---------------------------------------------- /*
5 /* ---------------------------------------------- */
7 $(window).load(function() {
8 $('.loader').fadeOut();
9 $('.page-loader').delay(350).fadeOut('slow');
12 $(document).ready(function() {
14 /* ---------------------------------------------- /*
15 * Initialization General Scripts for all pages
16 /* ---------------------------------------------- */
18 var homeSection = $('.home-section'),
19 navbar = $('.navbar-custom'),
20 navHeight = navbar.height(),
21 width = Math.max($(window).width(), window.innerWidth),
24 if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
28 buildHomeSection(homeSection);
29 navbarAnimation(navbar, homeSection, navHeight);
31 hoverDropdown(width, mobileTest);
33 $(window).resize(function() {
34 var width = Math.max($(window).width(), window.innerWidth);
35 buildHomeSection(homeSection);
36 hoverDropdown(width, mobileTest);
39 $(window).scroll(function() {
40 effectsHomeSection(homeSection, this);
41 navbarAnimation(navbar, homeSection, navHeight);
44 /* ---------------------------------------------- /*
46 /* ---------------------------------------------- */
48 function buildHomeSection(homeSection) {
49 if (homeSection.length > 0) {
50 if (homeSection.hasClass('home-full-height')) {
51 homeSection.height($(window).height());
53 if ( !homeSection.hasClass('home-slider-plugin') ) {
54 homeSection.height($(window).height() * 0.85);
58 if( $('body.home' ).length>0 && homeSection.length<1 ) {
59 //$('.main').css('margin-top', $('.navbar-custom').outerHeight() );
64 /* ---------------------------------------------- /*
65 * Home section effects
66 /* ---------------------------------------------- */
68 function effectsHomeSection(homeSection, scrollTopp) {
69 if (homeSection.length > 0) {
70 var homeSHeight = homeSection.height();
71 var topScroll = $(document).scrollTop();
72 if ( ( homeSection.hasClass( 'home-parallax' ) ) && ( $( scrollTopp ).scrollTop() <= homeSHeight ) ) {
73 $( '.home-slider-overlay' ).css( 'opacity', ( 0.3 + 0.7 * topScroll / $(window).height() ) );
75 if (homeSection.hasClass('home-fade') && ($(scrollTopp).scrollTop() <= homeSHeight)) {
76 var caption = $('.caption-content');
77 caption.css('opacity', (1 - topScroll/homeSection.height() * 1));
82 /* ---------------------------------------------- /*
84 /* ---------------------------------------------- */
86 if( $('.hero-slider').length > 0 ) {
87 $('.hero-slider').flexslider( {
93 before: function(slider) {
94 $('.hs-caption').fadeOut().animate({top:'-80px'},{queue:false, easing: 'swing', duration: 700});
95 slider.slides.eq(slider.currentSlide).delay(500);
96 slider.slides.eq(slider.animatingTo).delay(500);
99 $('.hs-caption').fadeIn().animate({top:'0'},{queue:false, easing: 'swing', duration: 700});
105 /* ---------------------------------------------- /*
106 * Youtube video background
107 /* ---------------------------------------------- */
110 $('.video-player').mb_YTPlayer();
113 $('#video-play').click(function(event) {
114 event.preventDefault();
115 if ($(this).hasClass('fa-play')) {
116 $('.video-player').playYTP();
118 $('.video-player').pauseYTP();
120 $(this).toggleClass('fa-play fa-pause');
124 $('#video-volume').click(function(event) {
125 event.preventDefault();
126 $('.video-player').toggleVolume();
127 $(this).toggleClass('fa-volume-off fa-volume-up');
131 /* ---------------------------------------------- /*
132 * Transparent navbar animation
133 /* ---------------------------------------------- */
135 function navbarAnimation(navbar, homeSection, navHeight) {
137 var topScroll = $(window).scrollTop();
138 if (navbar.length > 0 && homeSection.length > 0) {
139 if(topScroll >= navHeight) {
140 navbar.removeClass('navbar-transparent');
142 navbar.addClass('navbar-transparent');
145 navbar.removeClass('navbar-transparent');
149 /* ---------------------------------------------- /*
151 /* ---------------------------------------------- */
153 function navbarSubmenu(width) {
155 $('.navbar-custom .navbar-nav > li.menu-item-has-children').on('click mouseover', function() {
156 var MenuLeftOffset = $('.sub-menu', $(this)).offset().left;
157 var Menu1LevelWidth = $('.sub-menu', $(this)).width();
158 if (width - MenuLeftOffset < Menu1LevelWidth * 2) {
159 $(this).children('.sub-menu').addClass('leftauto');
161 $(this).children('.sub-menu').removeClass('leftauto');
163 if ($('.menu-item-has-children', $(this)).length > 0) {
164 var Menu2LevelWidth = $('.sub-menu', $(this)).width();
165 if (width - MenuLeftOffset - Menu1LevelWidth < Menu2LevelWidth) {
166 $(this).children('.sub-menu').addClass('left-side');
168 $(this).children('.sub-menu').removeClass('left-side');
175 /* ---------------------------------------------- /*
176 * Navbar hover dropdown on desctop
177 /* ---------------------------------------------- */
179 function hoverDropdown(width, mobileTest) {
180 if ((width > 767) && (mobileTest !== true)) {
181 $('.navbar-custom .navbar-nav > li, .navbar-custom li.dropdown > ul > li').removeClass('open');
184 $('.navbar-custom .navbar-nav > li, .navbar-custom li > ul > li').hover(function() {
186 setTimeoutConst = setTimeout(function() {
187 $this.addClass('open');
188 $this.find('.dropdown-toggle').addClass('disabled');
192 clearTimeout(setTimeoutConst);
193 $(this).removeClass('open');
194 $(this).find('.dropdown-toggle').removeClass('disabled');
197 $('.navbar-custom .navbar-nav > li, .navbar-custom li > ul > li').unbind('mouseenter mouseleave');
198 $('.navbar-custom [data-toggle=dropdown]').not('.binded').addClass('binded').on('click', function(event) {
199 event.preventDefault();
200 event.stopPropagation();
201 $(this).parent().siblings().removeClass('open');
202 $(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeClass('open');
203 $(this).parent().toggleClass('open');
208 /* ---------------------------------------------- /*
209 * Navbar collapse on click
210 /* ---------------------------------------------- */
212 $(document).on('click','.navbar-collapse.in',function(e) {
213 if( $(e.target).is('a') && $(e.target).attr('class') !== 'dropdown-toggle' && !$('body').hasClass('mega-menu-primary') ) {
214 $(this).collapse('hide');
218 /* ---------------------------------------------- /*
219 * Set sections backgrounds
220 /* ---------------------------------------------- */
222 var module = $('.home-section, .module, .module-small, .side-image');
223 module.each(function() {
224 if ($(this).attr('data-background')) {
225 $(this).css('background-image', 'url(' + $(this).attr('data-background') + ')');
229 /* ---------------------------------------------- /*
230 * Testimonials, Post sliders
231 /* ---------------------------------------------- */
233 if ($('.testimonials-slider').length > 0 ) {
234 $('.testimonials-slider').flexslider( {
240 $('.post-images-slider').flexslider( {
245 /* ---------------------------------------------- /*
247 /* ---------------------------------------------- */
249 $('.owl-carousel').each(function() {
251 // Check items number
253 if ($(this).data('items') > 0) {
254 items = $(this).data('items');
259 // Check pagination true/false
261 if (($(this).data('pagination') > 0) && ($(this).data('pagination') === true)) {
267 // Check navigation true/false
269 if (($(this).data('navigation') > 0) && ($(this).data('navigation') === true)) {
275 // Check rtl true/false
277 if (($(this).data('rtl') > 0) && ($(this).data('rtl') === true)) {
284 $(this).owlCarousel( {
287 autoplayTimeout:5000,
288 autoplayHoverPause:true,
295 responsiveClass:true,
311 /* ---------------------------------------------- /*
312 * Video popup, Gallery
313 /* ---------------------------------------------- */
315 $('.video-pop-up').magnificPopup({
319 $('a.gallery').magnificPopup({
323 navigateByImgClick: true,
328 tError: 'The image could not be loaded.',
332 /* ---------------------------------------------- /*
333 * A jQuery plugin for fluid width video embeds
334 /* ---------------------------------------------- */
338 /* ---------------------------------------------- /*
339 * Open tabs by external link
340 /* ---------------------------------------------- */
342 $('.open-tab').click(function (e) {
343 var pattern = /#.+/gi;
344 var contentID = e.target.toString().match(pattern)[0];
345 $('.nav-tabs a[href="' + contentID + '"]').tab('show');
348 /* ---------------------------------------------- /*
350 /* ---------------------------------------------- */
352 $('.section-scroll').bind('click', function(e) {
353 var anchor = $(this);
354 $('html, body').stop().animate({
355 scrollTop: $(anchor.attr('href')).offset().top - 50
360 /* ---------------------------------------------- /*
362 /* ---------------------------------------------- */
364 $(window).scroll(function() {
365 if ($(this).scrollTop() > 100) {
366 $('.scroll-up').fadeIn();
368 $('.scroll-up').fadeOut();
372 $('a[href="#totop"]').click(function() {
373 $('html, body').animate({ scrollTop: 0 }, 'slow');
377 /* ---------------------------------------------- /*
378 * Dropdown mennu on tablet
379 /* ---------------------------------------------- */
381 var $menuBtnChildren = $('.menu-item-has-children'),
382 submenuOpenClass = 'open',
384 $menuWrap = $('.header-menu-wrap');
385 $menuBtnChildren.click(function(event){
386 if( mobileTest && !$(this).hasClass(submenuOpenClass) && window.innerWidth > 767 ) {
387 $thisParent = $(this).parent('ul').parent('li');
388 if( $thisParent.hasClass(submenuOpenClass) ){
389 $thisParent.find('.'+submenuOpenClass).removeClass(submenuOpenClass);
391 $menuWrap.find('.'+submenuOpenClass).removeClass(submenuOpenClass);
393 $(this).addClass(submenuOpenClass);
394 event.stopPropagation();
399 $('html,body,.main,.navbar-custom,.bottom-page-wrap').click(function(){
400 $menuWrap.find('.'+submenuOpenClass).removeClass(submenuOpenClass);
403 /* Visible arrow on mobile */
404 if( mobileTest === true && $( '.flex-direction-nav' ).length>0 && $( 'ul.slides > li' ).length>1 ) {
405 $('.flex-direction-nav').addClass('visible-arrow');
410 $('#review_form form :input').each(function(index, elem) {
411 var eId = $(elem).attr('id');
413 if (eId && (label = $(elem).parents('form').find('label[for='+eId+']')).length === 1) {
414 $(elem).attr('placeholder', $(label).text());
419 $('#map').click(function(event){
420 $('.shop_isle_pro_map_overlay').css('display','none');
421 event.stopPropagation();
424 $('html').click(function(){
425 $('.shop_isle_pro_map_overlay').css('display','block');
428 if(typeof $('.wr-megamenu-container') !== 'undefined') {
429 $('.wr-megamenu-container').addClass('bg-tr');
433 Android: function() {
434 return navigator.userAgent.match(/Android/i);
436 BlackBerry: function() {
437 return navigator.userAgent.match(/BlackBerry/i);
440 return navigator.userAgent.match(/iPhone|iPad|iPod/i);
443 return navigator.userAgent.match(/Opera Mini/i);
445 Windows: function() {
446 return navigator.userAgent.match(/IEMobile/i);
449 return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
452 if( isMobile.iOS() ) {
453 $( '#ribbon' ).addClass( 'ribbon-ios' );
456 if( isMobile.Windows() && $( '.navbar-cart' ).length > 0 ) {
457 $( '.navbar-header' ).css({
459 'padding-left': '100px',
460 'margin-left': '-100px',