/* theme name:idea - clean & powerful bootstrap theme * author:htmlcoder * author uri:http://www.htmlcoder.me * author e-mail:htmlcoder.me@gmail.com * version:1.0.0 * created:october 2014 * license uri:http://wrapbootstrap.com * file description: initializations of plugins */ (function($){ $(document).ready(function(){ //show dropdown on hover only for desktop devices //----------------------------------------------- var delay=0, settimeoutconst; if (modernizr.mq('only all and (min-width: 768px)') && !modernizr.touch) { $('.main-navigation .navbar-nav>li.dropdown, .main-navigation li.dropdown>ul>li.dropdown').hover( function(){ var $this = $(this); settimeoutconst = settimeout(function(){ $this.addclass('open').slidedown(); $this.find('.dropdown-toggle').addclass('disabled'); }, delay); }, function(){ cleartimeout(settimeoutconst ); $(this).removeclass('open'); $(this).find('.dropdown-toggle').removeclass('disabled'); }); }; $(".class a").hover(function () { $(this).addclass("on").siblings().removeclass("back") $(".guide").hide().eq($(this).index()).show(); }); //show dropdown on click only for mobile devices //----------------------------------------------- if (modernizr.mq('only all and (max-width: 767px)') || modernizr.touch) { $('.main-navigation [data-toggle=dropdown], .header-top [data-toggle=dropdown]').on('click', function(event) { // avoid following the href location when clicking event.preventdefault(); // avoid having the menu to close when clicking event.stoppropagation(); // close all the siblings $(this).parent().siblings().removeclass('open'); // close all the submenus of siblings $(this).parent().siblings().find('[data-toggle=dropdown]').parent().removeclass('open'); // opening the one you clicked on $(this).parent().toggleclass('open'); }); }; //main slider //----------------------------------------------- //revolution slider if ($(".slider-banner-container").length>0) { $(".tp-bannertimer").show(); $('.slider-banner-container .slider-banner').show().revolution({ delay:10000, startwidth:1140, startheight:520, navigationarrows:"solo", navigationstyle: "round", navigationhalign:"center", navigationvalign:"bottom", navigationhoffset:0, navigationvoffset:20, soloarrowlefthalign:"left", soloarrowleftvalign:"center", soloarrowlefthoffset:20, soloarrowleftvoffset:0, soloarrowrighthalign:"right", soloarrowrightvalign:"center", soloarrowrighthoffset:20, soloarrowrightvoffset:0, fullwidth:"on", spinner:"spinner0", stoploop:"off", stopafterloops:-1, stopatslide:-1, onhoverstop: "off", shuffle:"off", autoheight:"off", forcefullwidth:"off", hidethumbsonmobile:"off", hidenavdelayonmobile:1500, hidebulletsonmobile:"off", hidearrowsonmobile:"off", hidethumbsunderresolution:0, hideslideratlimit:0, hidecaptionatlimit:0, hideallcaptionatlilmit:0, startwithslide:0 }); $('.slider-banner-container .slider-banner-2').show().revolution({ delay:10000, startwidth:1140, startheight:520, navigationarrows:"solo", navigationstyle: "preview4", navigationhalign:"center", navigationvalign:"bottom", navigationhoffset:0, navigationvoffset:20, soloarrowlefthalign:"left", soloarrowleftvalign:"center", soloarrowlefthoffset:20, soloarrowleftvoffset:0, soloarrowrighthalign:"right", soloarrowrightvalign:"center", soloarrowrighthoffset:20, soloarrowrightvoffset:0, fullwidth:"on", spinner:"spinner0", stoploop:"off", stopafterloops:-1, stopatslide:-1, onhoverstop: "off", shuffle:"off", autoheight:"off", forcefullwidth:"off", hidethumbsonmobile:"off", hidenavdelayonmobile:1500, hidebulletsonmobile:"off", hidearrowsonmobile:"off", hidethumbsunderresolution:0, hideslideratlimit:0, hidecaptionatlimit:0, hideallcaptionatlilmit:0, startwithslide:0 }); $('.slider-banner-container .slider-banner-3').show().revolution({ delay:10000, startwidth:1140, startheight:520, dottedoverlay: "twoxtwo", parallax:"mouse", parallaxbgfreeze:"on", parallaxlevels:[3,2,1], navigationarrows:"solo", navigationstyle: "preview5", navigationhalign:"center", navigationvalign:"bottom", navigationhoffset:0, navigationvoffset:20, soloarrowlefthalign:"left", soloarrowleftvalign:"center", soloarrowlefthoffset:20, soloarrowleftvoffset:0, soloarrowrighthalign:"right", soloarrowrightvalign:"center", soloarrowrighthoffset:20, soloarrowrightvoffset:0, fullwidth:"on", spinner:"spinner0", stoploop:"off", stopafterloops:-1, stopatslide:-1, onhoverstop: "off", shuffle:"off", autoheight:"off", forcefullwidth:"off", hidethumbsonmobile:"off", hidenavdelayonmobile:1500, hidebulletsonmobile:"off", hidearrowsonmobile:"off", hidethumbsunderresolution:0, hideslideratlimit:0, hidecaptionatlimit:0, hideallcaptionatlilmit:0, startwithslide:0 }); $('.slider-banner-container .slider-banner-fullscreen').show().revolution({ delay:10000, startwidth:1140, startheight:520, fullwidth:"off", fullscreen:"on", fullscreenoffsetcontainer: "", fullscreenoffset: "82px", navigationarrows:"solo", navigationstyle: "preview4", navigationhalign:"center", navigationvalign:"bottom", navigationhoffset:0, navigationvoffset:20, soloarrowlefthalign:"left", soloarrowleftvalign:"center", soloarrowlefthoffset:20, soloarrowleftvoffset:0, soloarrowrighthalign:"right", soloarrowrightvalign:"center", soloarrowrighthoffset:20, soloarrowrightvoffset:0, spinner:"spinner4", stoploop:"off", stopafterloops:-1, stopatslide:-1, onhoverstop: "off", shuffle:"off", hidetimerbar:"on", autoheight:"off", forcefullwidth:"off", hidethumbsonmobile:"off", hidenavdelayonmobile:1500, hidebulletsonmobile:"off", hidearrowsonmobile:"off", hidethumbsunderresolution:0, hideslideratlimit:0, hidecaptionatlimit:0, hideallcaptionatlilmit:0, startwithslide:0 }); }; //owl carousel //----------------------------------------------- if ($('.owl-carousel').length>0) { $(".owl-carousel.carousel").owlcarousel({ items: 4, pagination: false, navigation: true, navigationtext: false }); $(".owl-carousel.carousel-autoplay").owlcarousel({ items: 4, autoplay: 5000, pagination: false, navigation: true, navigationtext: false }); $(".owl-carousel.clients").owlcarousel({ items: 4, autoplay: true, pagination: false, itemsdesktopsmall: [992,5], itemstablet: [768,4], itemsmobile: [479,3] }); $(".owl-carousel.content-slider").owlcarousel({ singleitem: true, autoplay: 5000, navigation: false, navigationtext: false, pagination: false }); $(".owl-carousel.content-slider-with-controls").owlcarousel({ singleitem: true, autoplay: false, navigation: true, navigationtext: false, pagination: true }); $(".owl-carousel.content-slider-with-controls-autoplay").owlcarousel({ singleitem: true, autoplay: 5000, navigation: true, navigationtext: false, pagination: true }); $(".owl-carousel.content-slider-with-controls-bottom").owlcarousel({ singleitem: true, autoplay: false, navigation: true, navigationtext: false, pagination: true }); }; // animations //----------------------------------------------- if (($("[data-animation-effect]").length>0) && !modernizr.touch) { $("[data-animation-effect]").each(function() { var $this = $(this), animationeffect = $this.attr("data-animation-effect"); if(modernizr.mq('only all and (min-width: 768px)') && modernizr.csstransitions) { $this.appear(function() { var delay = ($this.attr("data-effect-delay") ? $this.attr("data-effect-delay") : 1); if(delay > 1) $this.css("effect-delay", delay + "ms"); settimeout(function() { $this.addclass('animated object-visible ' + animationeffect); }, delay); }, {accx: 0, accy: -130}); } else { $this.addclass('object-visible'); } }); }; // stats count to //----------------------------------------------- if ($(".stats [data-to]").length>0) { $(".stats [data-to]").each(function() { var $this = $(this), offset = $this.offset().top; if($(window).scrolltop() > (offset - 800) && !($this.hasclass('counting'))) { $this.addclass('counting'); $this.countto(); }; $(window).scroll(function() { if($(window).scrolltop() > (offset - 800) && !($this.hasclass('counting'))) { $this.addclass('counting'); $this.countto(); } }); }); }; // isotope filters //----------------------------------------------- if ($('.isotope-container').length>0 || $('.masonry-grid').length>0 || $('.masonry-grid-fitrows').length>0) { $(window).load(function() { $('.masonry-grid').isotope({ itemselector: '.masonry-grid-item', layoutmode: 'masonry' }); $('.masonry-grid-fitrows').isotope({ itemselector: '.masonry-grid-item', layoutmode: 'fitrows' }); $('.isotope-container').fadein(); var $container = $('.isotope-container').isotope({ itemselector: '.isotope-item', layoutmode: 'masonry', transitionduration: '0.6s', filter: ".web-design" }); // filter items on button click $('.filters').on( 'click', 'ul.nav li a', function() { var filtervalue = $(this).attr('data-filter'); $(".filters").find("li.active").removeclass("active"); $(this).parent().addclass("active"); $container.isotope({ filter: filtervalue }); return false; }); }); }; //hc-tabs //----------------------------------------------- if ($('.hc-tabs').length>0) { $(window).load(function() { var currenttab = $(".hc-tabs .nav.nav-tabs li.active a").attr("href"), tabsimageanimation = $(".hc-tabs-top").find("[data-tab='" + currenttab + "']").attr("data-tab-animation-effect"); $(".hc-tabs-top").find("[data-tab='" + currenttab + "']").addclass("current-img show " + tabsimageanimation + " animated"); $('.hc-tabs .nav.nav-tabs li a').on('click', function(event) { var currenttab = $(this).attr("href"), tabsimageanimation = $(".hc-tabs-top").find("[data-tab='" + currenttab + "']").attr("data-tab-animation-effect"); $(".current-img").removeclass("current-img show " + tabsimageanimation + " animated"); $(".hc-tabs-top").find("[data-tab='" + currenttab + "']").addclass("current-img show " + tabsimageanimation + " animated"); }); }); } // animated progress bars //----------------------------------------------- if ($("[data-animate-width]").length>0) { $("[data-animate-width]").each(function() { var $this = $(this); $this.appear(function() { $this.animate({ width: $this.attr("data-animate-width") }, 800 ); }, {accx: 0, accy: -100}); }); }; // animated progress bars //----------------------------------------------- if ($(".knob").length>0) { $(".knob").knob(); } // magnific popup //----------------------------------------------- if (($(".popup-img").length > 0) || ($(".popup-iframe").length > 0) || ($(".popup-img-single").length > 0)) { $(".popup-img").magnificpopup({ type:"image", gallery: { enabled: true, } }); $(".popup-img-single").magnificpopup({ type:"image", gallery: { enabled: false, } }); $('.popup-iframe').magnificpopup({ disableon: 700, type: 'iframe', preloader: false, fixedcontentpos: false }); }; // fixed header //----------------------------------------------- var headertopheight = $(".header-top").outerheight(), headerheight = $("header.header.fixed").outerheight(); $(window).scroll(function() { if (($(".header.fixed").length > 0)) { if(($(this).scrolltop() > headertopheight+headerheight) && ($(window).width() > 767)) { $("body").addclass("fixed-header-on"); $(".header.fixed").addclass('animated object-visible fadeindown'); if ($(".banner:not(.header-top)").length>0) { $(".banner").css("margintop", (headerheight)+"px"); } else if ($(".page-intro").length>0) { $(".page-intro").css("margintop", (headerheight)+"px"); } else if ($(".page-top").length>0) { $(".page-top").css("margintop", (headerheight)+"px"); } else { $("section.main-container").css("margintop", (headerheight)+"px"); } } else { $("body").removeclass("fixed-header-on"); $("section.main-container").css("margintop", (0)+"px"); $(".banner").css("margintop", (0)+"px"); $(".page-intro").css("margintop", (0)+"px"); $(".page-top").css("margintop", (0)+"px"); $(".header.fixed").removeclass('animated object-visible fadeindown'); } }; }); // sharrre plugin //----------------------------------------------- if ($('#share').length>0) { $('#share').sharrre({ share: { twitter: true, facebook: true, googleplus: true }, template: '', enablehover: false, enabletracking: true, render: function(api, options){ $(api.element).on('click', '.twitter a', function() { api.openpopup('twitter'); }); $(api.element).on('click', '.facebook a', function() { api.openpopup('facebook'); }); $(api.element).on('click', '.googleplus a', function() { api.openpopup('googleplus'); }); } }); }; // contact forms validation //----------------------------------------------- if($("#contact-form").length>0) { $("#contact-form").validate({ submithandler: function(form) { var submitbutton = $(this.submitbutton); submitbutton.button("loading"); $.ajax({ type: "post", url: "php/contact-form.php", data: { "name": $("#contact-form #name").val(), "email": $("#contact-form #email").val(), "subject": $("#contact-form #subject").val(), "message": $("#contact-form #message").val() }, datatype: "json", success: function (data) { if (data.response == "success") { $("#contactsuccess").removeclass("hidden"); $("#contacterror").addclass("hidden"); // reset form $("#contact-form .form-control") .val("") .blur() .parent() .removeclass("has-success") .removeclass("has-error") .find("label") .removeclass("hide") .parent() .find("span.error") .remove(); if(($("#contactsuccess").position().top - 80) < $(window).scrolltop()){ $("html, body").animate({ scrolltop: $("#contactsuccess").offset().top - 80 }, 300); } } else { $("#contacterror").removeclass("hidden"); $("#contactsuccess").addclass("hidden"); if(($("#contacterror").position().top - 80) < $(window).scrolltop()){ $("html, body").animate({ scrolltop: $("#contacterror").offset().top - 80 }, 300); } } }, complete: function () { submitbutton.button("reset"); } }); }, // debug: true, errorplacement: function(error, element) { error.insertbefore( element ); }, onkeyup: false, onclick: false, rules: { name: { required: true, minlength: 2 }, email: { required: true, email: true }, subject: { required: true }, message: { required: true, minlength: 10 } }, messages: { name: { required: "please specify your name", minlength: "your name must be longer than 2 characters" }, email: { required: "we need your email address to contact you", email: "please enter a valid email address e.g. name@domain.com" }, subject: { required: "please enter a subject" }, message: { required: "please enter a message", minlength: "your message must be longer than 10 characters" } }, errorelement: "span", highlight: function (element) { $(element).parent().removeclass("has-success").addclass("has-error"); $(element).siblings("label").addclass("hide"); }, success: function (element) { $(element).parent().removeclass("has-error").addclass("has-success"); $(element).siblings("label").removeclass("hide"); } }); }; if($("#footer-form").length>0) { $("#footer-form").validate({ submithandler: function(form) { var submitbutton = $(this.submitbutton); submitbutton.button("loading"); $.ajax({ type: "post", url: "php/contact-form.php", data: { "name": $("#footer-form #name2").val(), "email": $("#footer-form #email2").val(), "subject": "message from contact form", "message": $("#footer-form #message2").val() }, datatype: "json", success: function (data) { if (data.response == "success") { $("#contactsuccess2").removeclass("hidden"); $("#contacterror2").addclass("hidden"); // reset form $("#footer-form .form-control") .val("") .blur() .parent() .removeclass("has-success") .removeclass("has-error") .find("label") .removeclass("hide") .parent() .find("span.error") .remove(); if(($("#contactsuccess2").position().top - 80) < $(window).scrolltop()){ $("html, body").animate({ scrolltop: $("#contactsuccess2").offset().top - 80 }, 300); } } else { $("#contacterror2").removeclass("hidden"); $("#contactsuccess2").addclass("hidden"); if(($("#contacterror2").position().top - 80) < $(window).scrolltop()){ $("html, body").animate({ scrolltop: $("#contacterror2").offset().top - 80 }, 300); } } }, complete: function () { submitbutton.button("reset"); } }); }, // debug: true, errorplacement: function(error, element) { error.insertafter( element ); }, onkeyup: false, onclick: false, rules: { name2: { required: true, minlength: 2 }, email2: { required: true, email: true }, message2: { required: true, minlength: 10 } }, messages: { name2: { required: "please specify your name", minlength: "your name must be longer than 2 characters" }, email2: { required: "we need your email address to contact you", email: "please enter a valid email address e.g. name@domain.com" }, message2: { required: "please enter a message", minlength: "your message must be longer than 10 characters" } }, errorelement: "span", highlight: function (element) { $(element).parent().removeclass("has-success").addclass("has-error"); $(element).siblings("label").addclass("hide"); }, success: function (element) { $(element).parent().removeclass("has-error").addclass("has-success"); $(element).siblings("label").removeclass("hide"); } }); }; if($("#sidebar-form").length>0) { $("#sidebar-form").validate({ submithandler: function(form) { var submitbutton = $(this.submitbutton); submitbutton.button("loading"); $.ajax({ type: "post", url: "php/contact-form.php", data: { "name": $("#sidebar-form #name3").val(), "email": $("#sidebar-form #email3").val(), "subject": "message from faq page", "category": $("#sidebar-form #category").val(), "message": $("#sidebar-form #message3").val() }, datatype: "json", success: function (data) { if (data.response == "success") { $("#contactsuccess3").removeclass("hidden"); $("#contacterror3").addclass("hidden"); // reset form $("#sidebar-form .form-control") .val("") .blur() .parent() .removeclass("has-success") .removeclass("has-error") .find("label") .removeclass("hide") .parent() .find("span.error") .remove(); if(($("#contactsuccess3").position().top - 80) < $(window).scrolltop()){ $("html, body").animate({ scrolltop: $("#contactsuccess3").offset().top - 80 }, 300); } } else { $("#contacterror3").removeclass("hidden"); $("#contactsuccess3").addclass("hidden"); if(($("#contacterror3").position().top - 80) < $(window).scrolltop()){ $("html, body").animate({ scrolltop: $("#contacterror3").offset().top - 80 }, 300); } } }, complete: function () { submitbutton.button("reset"); } }); }, // debug: true, errorplacement: function(error, element) { error.insertafter( element ); }, onkeyup: false, onclick: false, rules: { name3: { required: true, minlength: 2 }, email3: { required: true, email: true }, message3: { required: true, minlength: 10 } }, messages: { name3: { required: "please specify your name", minlength: "your name must be longer than 2 characters" }, email3: { required: "we need your email address to contact you", email: "please enter a valid email address e.g. name@domain.com" }, message3: { required: "please enter a message", minlength: "your message must be longer than 10 characters" } }, errorelement: "span", highlight: function (element) { $(element).parent().removeclass("has-success").addclass("has-error"); }, success: function (element) { $(element).parent().removeclass("has-error").addclass("has-success"); } }); }; // affix plugin //----------------------------------------------- if ($("#affix").length>0) { $(window).load(function() { var affixbottom = $(".footer").outerheight(true) + $(".subfooter").outerheight(true) + $(".blogpost footer").outerheight(true), affixtop = $("#affix").offset().top; if ($(".comments").length>0) { affixbottom = affixbottom + $(".comments").outerheight(true); } if ($(".comments-form").length>0) { affixbottom = affixbottom + $(".comments-form").outerheight(true); } if ($(".footer-top").length>0) { affixbottom = affixbottom + $(".footer-top").outerheight(true); } if ($(".header.fixed").length>0) { $("#affix").affix({ offset: { top: affixtop-150, bottom: affixbottom+100 } }); } else { $("#affix").affix({ offset: { top: affixtop-35, bottom: affixbottom+100 } }); } }); } if ($(".affix-menu").length>0) { settimeout(function () { var $sidebar = $('.sidebar') $sidebar.affix({ offset: { top: function () { var offsettop = $sidebar.offset().top return (this.top = offsettop - 65) }, bottom: function () { var affixbottom = $(".footer").outerheight(true) + $(".subfooter").outerheight(true) if ($(".footer-top").length>0) { affixbottom = affixbottom + $(".footer-top").outerheight(true) } return (this.bottom = affixbottom+50) } } }) }, 100) } //smooth scroll //----------------------------------------------- if ($(".smooth-scroll").length>0) { if($(".header.fixed").length>0) { $('.smooth-scroll a[href*=#]:not([href=#]), a[href*=#]:not([href=#]).smooth-scroll').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrolltop: target.offset().top-65 }, 1000); return false; } } }); } else { $('.smooth-scroll a[href*=#]:not([href=#]), a[href*=#]:not([href=#]).smooth-scroll').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrolltop: target.offset().top }, 1000); return false; } } }); } } //scroll spy //----------------------------------------------- if($(".scrollspy").length>0) { $("body").addclass("scroll-spy"); if($(".fixed.header").length>0) { $('body').scrollspy({ target: '.scrollspy', offset: 85 }); } else { $('body').scrollspy({ target: '.scrollspy', offset: 20 }); } } //scroll totop //----------------------------------------------- $(window).scroll(function() { if($(this).scrolltop() != 0) { $(".scrolltotop").fadein(); } else { $(".scrolltotop").fadeout(); } }); $(".scrolltotop").click(function() { $("body,html").animate({scrolltop:0},800); }); //modal //----------------------------------------------- if($(".modal").length>0) { $(".modal").each(function() { $(".modal").prependto( "body" ); }); } // pricing tables popovers //----------------------------------------------- if ($(".pricing-tables").length>0) { $(".plan .pt-popover").popover({ trigger: 'hover' }); }; // parallax section //----------------------------------------------- if (($(".parallax").length>0) && !modernizr.touch ){ $(".parallax").parallax("50%", 0.2, false); }; // remove button //----------------------------------------------- $(".btn-remove").click(function() { $(this).closest(".remove-data").remove(); }); // shipping checkbox //----------------------------------------------- if ($("#shipping-info-check").is(':checked')) { $("#shipping-information").hide(); } $("#shipping-info-check").change(function(){ if ($(this).is(':checked')) { $("#shipping-information").slidetoggle(); } else { $("#shipping-information").slidetoggle(); } }); }); // end document ready })(this.jquery);