123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701 |
- "use strict";
- (function () {
- // Global variables
- var userAgent = navigator.userAgent.toLowerCase(),
- initialDate = new Date(),
- $document = $(document),
- $window = $(window),
- $html = $("html"),
- $body = $("body"),
- isDesktop = $html.hasClass("desktop"),
- isIE = userAgent.indexOf("msie") !== -1 ? parseInt(userAgent.split("msie")[1], 10) : userAgent.indexOf("trident") !== -1 ? 11 : userAgent.indexOf("edge") !== -1 ? 12 : false,
- isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
- windowReady = false,
- isNoviBuilder = false,
- livedemo = false,
- plugins = {
- bootstrapTooltip: $( '[data-toggle="tooltip"]' ),
- bootstrapTabs: $( '.tabs-custom' ),
- customToggle: $( '[data-custom-toggle]' ),
- counter: $( '.counter' ),
- countDown: $( '[data-circle-countdown]' ),
- captcha: $( '.recaptcha' ),
- campaignMonitor: $( '.campaign-mailform' ),
- copyrightYear: $( '.copyright-year' ),
- checkbox: $( 'input[type="checkbox"]' ),
- isotope: $( '.isotope-wrap' ),
- lightGallery: $( '[data-lightgallery="group"]' ),
- lightGalleryItem: $( '[data-lightgallery="item"]' ),
- lightDynamicGalleryItem: $( '[data-lightgallery="dynamic"]' ),
- maps: $( '.google-map-container' ),
- materialParallax: $( '.parallax-container' ),
- mailchimp: $( '.mailchimp-mailform' ),
- multitoggle: document.querySelectorAll( '[data-multitoggle]' ),
- owl: $( '.owl-carousel' ),
- progressLinear: $( '.progress-linear' ),
- preloader: $( '.preloader' ),
- rdNavbar: $( '.rd-navbar' ),
- rdMailForm: $( '.rd-mailform' ),
- rdInputLabel: $( '.form-label' ),
- regula: $( '[data-constraints]' ),
- radio: $( 'input[type="radio"]' ),
- rdRange: $( '.rd-range' ),
- radioPanel: $( '.radio-panel .radio-inline' ),
- swiper: document.querySelectorAll( '.swiper-container' ),
- selectFilter: $( 'select' ),
- slick: $( '.slick-slider' ),
- stepper: $( 'input[type="number"]' ),
- search: $( '.rd-search' ),
- searchResults: $( '.rd-search-results' ),
- wow: $( '.wow' )
- };
- /**
- * @desc Check the element was been scrolled into the view
- * @param {object} elem - jQuery object
- * @return {boolean}
- */
- function isScrolledIntoView ( elem ) {
- if ( isNoviBuilder ) return true;
- return elem.offset().top + elem.outerHeight() >= $window.scrollTop() && elem.offset().top <= $window.scrollTop() + $window.height();
- }
- /**
- * @desc Calls a function when element has been scrolled into the view
- * @param {object} element - jQuery object
- * @param {function} func - init function
- */
- function lazyInit( element, func ) {
- var scrollHandler = function () {
- if ( ( !element.hasClass( 'lazy-loaded' ) && ( isScrolledIntoView( element ) ) ) ) {
- func.call( element );
- element.addClass( 'lazy-loaded' );
- }
- };
- scrollHandler();
- $window.on( 'scroll', scrollHandler );
- }
- // Initialize scripts that require a loaded page
- $window.on('load', function () {
- // Page loader & Page transition
- if (plugins.preloader.length && !isNoviBuilder) {
- pageTransition({
- target: document.querySelector( '.page' ),
- delay: 0,
- duration: 500,
- classIn: 'fadeIn',
- classOut: 'fadeOut',
- classActive: 'animated',
- conditions: function (event, link) {
- return !/(\#|callto:|tel:|mailto:|:\/\/)/.test(link) && !event.currentTarget.hasAttribute('data-lightgallery');
- },
- onTransitionStart: function ( options ) {
- setTimeout( function () {
- plugins.preloader.removeClass('loaded');
- }, options.duration * .75 );
- },
- onReady: function () {
- plugins.preloader.addClass('loaded');
- windowReady = true;
- }
- });
- }
- // jQuery Count To
- if ( plugins.counter.length ) {
- for ( var i = 0; i < plugins.counter.length; i++ ) {
- var
- counter = $(plugins.counter[i]),
- initCount = function () {
- var counter = $(this);
- if ( !counter.hasClass( "animated-first" ) && isScrolledIntoView( counter ) ) {
- counter.countTo({
- refreshInterval: 40,
- speed: counter.attr("data-speed") || 1000,
- from: 0,
- to: parseInt( counter.text(), 10 )
- });
- counter.addClass('animated-first');
- }
- };
- $.proxy( initCount, counter )();
- $window.on( "scroll", $.proxy( initCount, counter ) );
- }
- }
- // Progress bar
- if ( plugins.progressLinear.length ) {
- for ( var i = 0; i < plugins.progressLinear.length; i++) {
- var
- bar = $(plugins.progressLinear[i]),
- initProgress = function() {
- var
- bar = $(this),
- end = parseInt($(this).find('.progress-value').text(), 10);
- if ( !bar.hasClass( "animated-first" ) && isScrolledIntoView( bar ) ) {
- bar.find('.progress-bar-linear').css({width: end + '%'});
- bar.find('.progress-value').countTo({
- refreshInterval: 40,
- from: 0,
- to: end,
- speed: 1000
- });
- bar.addClass('animated-first');
- }
- };
- $.proxy( initProgress, bar )();
- $window.on( "scroll", $.proxy( initProgress, bar ) );
- }
- }
- // SVG Countdown
- if( plugins.countDown.length ) {
- svgCountDown({
- tickInterval: 100,
- counterSelector: '.countdown-counter'
- });
- }
- // Isotope
- if ( plugins.isotope.length ) {
- for ( var i = 0; i < plugins.isotope.length; i++ ) {
- var
- wrap = plugins.isotope[ i ],
- filterHandler = function ( event ) {
- event.preventDefault();
- for ( var n = 0; n < this.isoGroup.filters.length; n++ ) this.isoGroup.filters[ n ].classList.remove( 'active' );
- this.classList.add( 'active' );
- this.isoGroup.isotope.arrange( { filter: this.getAttribute( "data-isotope-filter" ) !== '*' ? '[data-filter*="' + this.getAttribute( "data-isotope-filter" ) + '"]' : '*' } );
- },
- resizeHandler = function () {
- this.isoGroup.isotope.layout();
- };
- wrap.isoGroup = {};
- wrap.isoGroup.filters = wrap.querySelectorAll( '[data-isotope-filter]' );
- wrap.isoGroup.node = wrap.querySelector( '.isotope' );
- wrap.isoGroup.layout = wrap.isoGroup.node.getAttribute( 'data-isotope-layout' ) ? wrap.isoGroup.node.getAttribute( 'data-isotope-layout' ) : 'masonry';
- wrap.isoGroup.isotope = new Isotope( wrap.isoGroup.node, {
- itemSelector: '.isotope-item',
- layoutMode: wrap.isoGroup.layout,
- filter: '*',
- masonry: {
- columnWidth: '.col-1'
- }
- } );
- $('.isotope-filters-toggle').on('click', function(){
- $('.isotope-filters-list').toggleClass('active');
- });
- for ( var n = 0; n < wrap.isoGroup.filters.length; n++ ) {
- var filter = wrap.isoGroup.filters[ n ];
- filter.isoGroup = wrap.isoGroup;
- filter.addEventListener( 'click', filterHandler );
- }
- window.addEventListener( 'resize', resizeHandler.bind( wrap ) );
- }
- }
- // Material Parallax
- if ( plugins.materialParallax.length ) {
- if ( !isNoviBuilder && !isIE && !isMobile) {
- plugins.materialParallax.parallax();
- } else {
- for ( var i = 0; i < plugins.materialParallax.length; i++ ) {
- var $parallax = $(plugins.materialParallax[i]);
- $parallax.addClass( 'parallax-disabled' );
- $parallax.css({ "background-image": 'url('+ $parallax.data("parallax-img") +')' });
- }
- }
- }
- });
- // Initialize scripts that require a finished document
- $(function () {
- isNoviBuilder = window.xMode;
- /**
- * @desc Initialize owl carousel plugin
- * @param {object} c - carousel jQuery object
- */
- function initOwlCarousel(c) {
- var aliaces = ["-", "-sm-", "-md-", "-lg-", "-xl-", "-xxl-"],
- values = [0, 576, 768, 992, 1200, 1600],
- responsive = {};
- for (var j = 0; j < values.length; j++) {
- responsive[values[j]] = {};
- for (var k = j; k >= -1; k--) {
- if (!responsive[values[j]]["items"] && c.attr("data" + aliaces[k] + "items")) {
- responsive[values[j]]["items"] = k < 0 ? 1 : parseInt(c.attr("data" + aliaces[k] + "items"), 10);
- }
- if (!responsive[values[j]]["stagePadding"] && responsive[values[j]]["stagePadding"] !== 0 && c.attr("data" + aliaces[k] + "stage-padding")) {
- responsive[values[j]]["stagePadding"] = k < 0 ? 0 : parseInt(c.attr("data" + aliaces[k] + "stage-padding"), 10);
- }
- if (!responsive[values[j]]["margin"] && responsive[values[j]]["margin"] !== 0 && c.attr("data" + aliaces[k] + "margin")) {
- responsive[values[j]]["margin"] = k < 0 ? 30 : parseInt(c.attr("data" + aliaces[k] + "margin"), 10);
- }
- }
- }
- // Enable custom pagination
- if (c.attr('data-dots-custom')) {
- c.on("initialized.owl.carousel", function (event) {
- var carousel = $(event.currentTarget),
- customPag = $(carousel.attr("data-dots-custom")),
- active = 0;
- if (carousel.attr('data-active')) {
- active = parseInt(carousel.attr('data-active'), 10);
- }
- carousel.trigger('to.owl.carousel', [active, 300, true]);
- customPag.find("[data-owl-item='" + active + "']").addClass("active");
- customPag.find("[data-owl-item]").on('click', function (e) {
- e.preventDefault();
- carousel.trigger('to.owl.carousel', [parseInt(this.getAttribute("data-owl-item"), 10), 300, true]);
- });
- carousel.on("translate.owl.carousel", function (event) {
- customPag.find(".active").removeClass("active");
- customPag.find("[data-owl-item='" + event.item.index + "']").addClass("active")
- });
- });
- }
- c.on("initialized.owl.carousel", function () {
- initLightGalleryItem(c.find('[data-lightgallery="item"]'), 'lightGallery-in-carousel');
- });
- c.owlCarousel({
- autoplay: isNoviBuilder ? false : c.attr("data-autoplay") === "true",
- loop: isNoviBuilder ? false : c.attr("data-loop") !== "false",
- items: 1,
- center: c.attr("data-center") === "true",
- dotsContainer: c.attr("data-pagination-class") || false,
- navContainer: c.attr("data-navigation-class") || false,
- mouseDrag: isNoviBuilder ? false : c.attr("data-mouse-drag") !== "false",
- nav: c.attr("data-nav") === "true",
- dots: c.attr("data-dots") === "true",
- dotsEach: c.attr("data-dots-each") ? parseInt(c.attr("data-dots-each"), 10) : false,
- animateIn: c.attr('data-animation-in') ? c.attr('data-animation-in') : false,
- animateOut: c.attr('data-animation-out') ? c.attr('data-animation-out') : false,
- responsive: responsive,
- smartSpeed: c.attr('data-smart-speed') ? c.attr('data-smart-speed') : 250,
- navText: c.attr("data-nav-text") ? $.parseJSON( c.attr("data-nav-text") ) : [],
- navClass: c.attr("data-nav-class") ? $.parseJSON( c.attr("data-nav-class") ) : ['owl-prev', 'owl-next']
- });
- }
- /**
- * @desc Create live search results
- * @param {object} options
- */
- function liveSearch(options) {
- $('#' + options.live).removeClass('cleared').html();
- options.current++;
- options.spin.addClass('loading');
- $.get(handler, {
- s: decodeURI(options.term),
- liveSearch: options.live,
- dataType: "html",
- liveCount: options.liveCount,
- filter: options.filter,
- template: options.template
- }, function (data) {
- options.processed++;
- var live = $('#' + options.live);
- if ((options.processed === options.current) && !live.hasClass('cleared')) {
- live.find('> #search-results').removeClass('active');
- live.html(data);
- setTimeout(function () {
- live.find('> #search-results').addClass('active');
- }, 50);
- }
- options.spin.parents('.rd-search').find('.input-group-addon').removeClass('loading');
- })
- }
- /**
- * @desc Attach form validation to elements
- * @param {object} elements - jQuery object
- */
- function attachFormValidator(elements) {
- // Custom validator - phone number
- regula.custom({
- name: 'PhoneNumber',
- defaultMessage: 'Invalid phone number format',
- validator: function() {
- if ( this.value === '' ) return true;
- else return /^(\+\d)?[0-9\-\(\) ]{5,}$/i.test( this.value );
- }
- });
- for (var i = 0; i < elements.length; i++) {
- var o = $(elements[i]), v;
- o.addClass("form-control-has-validation").after("<span class='form-validation'></span>");
- v = o.parent().find(".form-validation");
- if (v.is(":last-child")) o.addClass("form-control-last-child");
- }
- elements.on('input change propertychange blur', function (e) {
- var $this = $(this), results;
- if (e.type !== "blur") if (!$this.parent().hasClass("has-error")) return;
- if ($this.parents('.rd-mailform').hasClass('success')) return;
- if (( results = $this.regula('validate') ).length) {
- for (i = 0; i < results.length; i++) {
- $this.siblings(".form-validation").text(results[i].message).parent().addClass("has-error");
- }
- } else {
- $this.siblings(".form-validation").text("").parent().removeClass("has-error")
- }
- }).regula('bind');
- var regularConstraintsMessages = [
- {
- type: regula.Constraint.Required,
- newMessage: "The text field is required."
- },
- {
- type: regula.Constraint.Email,
- newMessage: "The email is not a valid email."
- },
- {
- type: regula.Constraint.Numeric,
- newMessage: "Only numbers are required"
- },
- {
- type: regula.Constraint.Selected,
- newMessage: "Please choose an option."
- }
- ];
- for (var i = 0; i < regularConstraintsMessages.length; i++) {
- var regularConstraint = regularConstraintsMessages[i];
- regula.override({
- constraintType: regularConstraint.type,
- defaultMessage: regularConstraint.newMessage
- });
- }
- }
- /**
- * @desc Check if all elements pass validation
- * @param {object} elements - object of items for validation
- * @param {object} captcha - captcha object for validation
- * @return {boolean}
- */
- function isValidated(elements, captcha) {
- var results, errors = 0;
- if (elements.length) {
- for (var j = 0; j < elements.length; j++) {
- var $input = $(elements[j]);
- if ((results = $input.regula('validate')).length) {
- for (k = 0; k < results.length; k++) {
- errors++;
- $input.siblings(".form-validation").text(results[k].message).parent().addClass("has-error");
- }
- } else {
- $input.siblings(".form-validation").text("").parent().removeClass("has-error")
- }
- }
- if (captcha) {
- if (captcha.length) {
- return validateReCaptcha(captcha) && errors === 0
- }
- }
- return errors === 0;
- }
- return true;
- }
- /**
- * @desc Validate google reCaptcha
- * @param {object} captcha - captcha object for validation
- * @return {boolean}
- */
- function validateReCaptcha(captcha) {
- var captchaToken = captcha.find('.g-recaptcha-response').val();
- if (captchaToken.length === 0) {
- captcha
- .siblings('.form-validation')
- .html('Please, prove that you are not robot.')
- .addClass('active');
- captcha
- .closest('.form-wrap')
- .addClass('has-error');
- captcha.on('propertychange', function () {
- var $this = $(this),
- captchaToken = $this.find('.g-recaptcha-response').val();
- if (captchaToken.length > 0) {
- $this
- .closest('.form-wrap')
- .removeClass('has-error');
- $this
- .siblings('.form-validation')
- .removeClass('active')
- .html('');
- $this.off('propertychange');
- }
- });
- return false;
- }
- return true;
- }
- /**
- * @desc Initialize Google reCaptcha
- */
- window.onloadCaptchaCallback = function () {
- for (var i = 0; i < plugins.captcha.length; i++) {
- var
- $captcha = $(plugins.captcha[i]),
- resizeHandler = (function() {
- var
- frame = this.querySelector( 'iframe' ),
- inner = this.firstElementChild,
- inner2 = inner.firstElementChild,
- containerRect = null,
- frameRect = null,
- scale = null;
- inner2.style.transform = '';
- inner.style.height = 'auto';
- inner.style.width = 'auto';
- containerRect = this.getBoundingClientRect();
- frameRect = frame.getBoundingClientRect();
- scale = containerRect.width/frameRect.width;
- if ( scale < 1 ) {
- inner2.style.transform = 'scale('+ scale +')';
- inner.style.height = ( frameRect.height * scale ) + 'px';
- inner.style.width = ( frameRect.width * scale ) + 'px';
- }
- }).bind( plugins.captcha[i] );
- grecaptcha.render(
- $captcha.attr('id'),
- {
- sitekey: $captcha.attr('data-sitekey'),
- size: $captcha.attr('data-size') ? $captcha.attr('data-size') : 'normal',
- theme: $captcha.attr('data-theme') ? $captcha.attr('data-theme') : 'light',
- callback: function () {
- $('.recaptcha').trigger('propertychange');
- }
- }
- );
- $captcha.after("<span class='form-validation'></span>");
- if ( plugins.captcha[i].hasAttribute( 'data-auto-size' ) ) {
- resizeHandler();
- window.addEventListener( 'resize', resizeHandler );
- }
- }
- };
- /**
- * @desc Initialize Bootstrap tooltip with required placement
- * @param {string} tooltipPlacement
- */
- function initBootstrapTooltip(tooltipPlacement) {
- plugins.bootstrapTooltip.tooltip('dispose');
- if (window.innerWidth < 576) {
- plugins.bootstrapTooltip.tooltip({placement: 'bottom'});
- } else {
- plugins.bootstrapTooltip.tooltip({placement: tooltipPlacement});
- }
- }
- /**
- * @desc Initialize the gallery with set of images
- * @param {object} itemsToInit - jQuery object
- * @param {string} addClass - additional gallery class
- */
- function initLightGallery(itemsToInit, addClass) {
- if (!isNoviBuilder) {
- $(itemsToInit).lightGallery({
- thumbnail: $(itemsToInit).attr("data-lg-thumbnail") !== "false",
- selector: "[data-lightgallery='item']",
- autoplay: $(itemsToInit).attr("data-lg-autoplay") === "true",
- pause: parseInt($(itemsToInit).attr("data-lg-autoplay-delay")) || 5000,
- addClass: addClass,
- mode: $(itemsToInit).attr("data-lg-animation") || "lg-slide",
- loop: $(itemsToInit).attr("data-lg-loop") !== "false"
- });
- }
- }
- /**
- * @desc Initialize the gallery with dynamic addition of images
- * @param {object} itemsToInit - jQuery object
- * @param {string} addClass - additional gallery class
- */
- function initDynamicLightGallery(itemsToInit, addClass) {
- if (!isNoviBuilder) {
- $(itemsToInit).on("click", function () {
- $(itemsToInit).lightGallery({
- thumbnail: $(itemsToInit).attr("data-lg-thumbnail") !== "false",
- selector: "[data-lightgallery='item']",
- autoplay: $(itemsToInit).attr("data-lg-autoplay") === "true",
- pause: parseInt($(itemsToInit).attr("data-lg-autoplay-delay")) || 5000,
- addClass: addClass,
- mode: $(itemsToInit).attr("data-lg-animation") || "lg-slide",
- loop: $(itemsToInit).attr("data-lg-loop") !== "false",
- dynamic: true,
- dynamicEl: JSON.parse($(itemsToInit).attr("data-lg-dynamic-elements")) || []
- });
- });
- }
- }
- /**
- * @desc Initialize the gallery with one image
- * @param {object} itemToInit - jQuery object
- * @param {string} addClass - additional gallery class
- */
- function initLightGalleryItem(itemToInit, addClass) {
- if (!isNoviBuilder) {
- $(itemToInit).lightGallery({
- selector: "this",
- addClass: addClass,
- counter: false,
- youtubePlayerParams: {
- modestbranding: 1,
- showinfo: 0,
- rel: 0,
- controls: 0
- },
- vimeoPlayerParams: {
- byline: 0,
- portrait: 0
- }
- });
- }
- }
- /**
- * @desc Google map function for getting latitude and longitude
- */
- function getLatLngObject(str, marker, map, callback) {
- var coordinates = {};
- try {
- coordinates = JSON.parse(str);
- callback(new google.maps.LatLng(
- coordinates.lat,
- coordinates.lng
- ), marker, map)
- } catch (e) {
- map.geocoder.geocode({'address': str}, function (results, status) {
- if (status === google.maps.GeocoderStatus.OK) {
- var latitude = results[0].geometry.location.lat();
- var longitude = results[0].geometry.location.lng();
- callback(new google.maps.LatLng(
- parseFloat(latitude),
- parseFloat(longitude)
- ), marker, map)
- }
- })
- }
- }
- /**
- * @desc Initialize Google maps
- */
- function initMaps() {
- var key;
- for ( var i = 0; i < plugins.maps.length; i++ ) {
- if ( plugins.maps[i].hasAttribute( "data-key" ) ) {
- key = plugins.maps[i].getAttribute( "data-key" );
- break;
- }
- }
- $.getScript('//maps.google.com/maps/api/js?'+ ( key ? 'key='+ key + '&' : '' ) +'sensor=false&libraries=geometry,places&v=quarterly', function () {
- var head = document.getElementsByTagName('head')[0],
- insertBefore = head.insertBefore;
- head.insertBefore = function (newElement, referenceElement) {
- if (newElement.href && newElement.href.indexOf('//fonts.googleapis.com/css?family=Roboto') !== -1 || newElement.innerHTML.indexOf('gm-style') !== -1) {
- return;
- }
- insertBefore.call(head, newElement, referenceElement);
- };
- var geocoder = new google.maps.Geocoder;
- for (var i = 0; i < plugins.maps.length; i++) {
- var zoom = parseInt(plugins.maps[i].getAttribute("data-zoom"), 10) || 11;
- var styles = plugins.maps[i].hasAttribute('data-styles') ? JSON.parse(plugins.maps[i].getAttribute("data-styles")) : [];
- var center = plugins.maps[i].getAttribute("data-center") || "New York";
- // Initialize map
- var map = new google.maps.Map(plugins.maps[i].querySelectorAll(".google-map")[0], {
- zoom: zoom,
- styles: styles,
- scrollwheel: false,
- center: {lat: 0, lng: 0}
- });
- // Add map object to map node
- plugins.maps[i].map = map;
- plugins.maps[i].geocoder = geocoder;
- plugins.maps[i].keySupported = true;
- plugins.maps[i].google = google;
- // Get Center coordinates from attribute
- getLatLngObject(center, null, plugins.maps[i], function (location, markerElement, mapElement) {
- mapElement.map.setCenter(location);
- });
- // Add markers from google-map-markers array
- var markerItems = plugins.maps[i].querySelectorAll(".google-map-markers li");
- if (markerItems.length){
- var markers = [];
- for (var j = 0; j < markerItems.length; j++){
- var markerElement = markerItems[j];
- getLatLngObject(markerElement.getAttribute("data-location"), markerElement, plugins.maps[i], function(location, markerElement, mapElement){
- var icon = markerElement.getAttribute("data-icon") || mapElement.getAttribute("data-icon");
- var activeIcon = markerElement.getAttribute("data-icon-active") || mapElement.getAttribute("data-icon-active");
- var info = markerElement.getAttribute("data-description") || "";
- var infoWindow = new google.maps.InfoWindow({
- content: info
- });
- markerElement.infoWindow = infoWindow;
- var markerData = {
- position: location,
- map: mapElement.map
- }
- if (icon){
- markerData.icon = icon;
- }
- var marker = new google.maps.Marker(markerData);
- markerElement.gmarker = marker;
- markers.push({markerElement: markerElement, infoWindow: infoWindow});
- marker.isActive = false;
- // Handle infoWindow close click
- google.maps.event.addListener(infoWindow,'closeclick',(function(markerElement, mapElement){
- var markerIcon = null;
- markerElement.gmarker.isActive = false;
- markerIcon = markerElement.getAttribute("data-icon") || mapElement.getAttribute("data-icon");
- markerElement.gmarker.setIcon(markerIcon);
- }).bind(this, markerElement, mapElement));
- // Set marker active on Click and open infoWindow
- google.maps.event.addListener(marker, 'click', (function(markerElement, mapElement) {
- if (markerElement.infoWindow.getContent().length === 0) return;
- var gMarker, currentMarker = markerElement.gmarker, currentInfoWindow;
- for (var k =0; k < markers.length; k++){
- var markerIcon;
- if (markers[k].markerElement === markerElement){
- currentInfoWindow = markers[k].infoWindow;
- }
- gMarker = markers[k].markerElement.gmarker;
- if (gMarker.isActive && markers[k].markerElement !== markerElement){
- gMarker.isActive = false;
- markerIcon = markers[k].markerElement.getAttribute("data-icon") || mapElement.getAttribute("data-icon")
- gMarker.setIcon(markerIcon);
- markers[k].infoWindow.close();
- }
- }
- currentMarker.isActive = !currentMarker.isActive;
- if (currentMarker.isActive) {
- if (markerIcon = markerElement.getAttribute("data-icon-active") || mapElement.getAttribute("data-icon-active")){
- currentMarker.setIcon(markerIcon);
- }
- currentInfoWindow.open(map, marker);
- }else{
- if (markerIcon = markerElement.getAttribute("data-icon") || mapElement.getAttribute("data-icon")){
- currentMarker.setIcon(markerIcon);
- }
- currentInfoWindow.close();
- }
- }).bind(this, markerElement, mapElement))
- })
- }
- }
- }
- });
- }
- /**
- * @desc Sets the actual previous index based on the position of the slide in the markup. Should be the most recent action.
- * @param {object} swiper - swiper instance
- */
- function setRealPrevious( swiper ) {
- var element = swiper.$wrapperEl[0].children[ swiper.activeIndex ];
- swiper.realPrevious = Array.prototype.indexOf.call( element.parentNode.children, element );
- }
- function initSwiper(sliderMarkup) {
- var
- autoplayAttr = sliderMarkup.getAttribute('data-autoplay') || 5000,
- slides = sliderMarkup.querySelectorAll('.swiper-slide'),
- swiper,
- options = {
- loop: sliderMarkup.getAttribute('data-loop') === 'true' || false,
- effect: sliderMarkup.getAttribute('data-effect') || 'slide',
- direction: sliderMarkup.getAttribute('data-direction') || 'horizontal',
- speed: sliderMarkup.getAttribute('data-speed') ? Number(sliderMarkup.getAttribute('data-speed')) : 600,
- simulateTouch: sliderMarkup.getAttribute('data-simulate-touch') === 'true' && !isNoviBuilder || false,
- slidesPerView: sliderMarkup.getAttribute('data-slides') || 1,
- spaceBetween: Number(sliderMarkup.getAttribute('data-margin')) || 0
- };
- if (Number(autoplayAttr)) {
- options.autoplay = {
- delay: Number(autoplayAttr),
- stopOnLastSlide: false,
- disableOnInteraction: true,
- reverseDirection: false,
- };
- }
- if (sliderMarkup.getAttribute('data-keyboard') === 'true') {
- options.keyboard = {
- enabled: sliderMarkup.getAttribute('data-keyboard') === 'true',
- onlyInViewport: true
- };
- }
- if (sliderMarkup.getAttribute('data-mousewheel') === 'true') {
- options.mousewheel = {
- sensitivity: 1
- };
- }
- if (sliderMarkup.querySelector('.swiper-button-next, .swiper-button-prev')) {
- options.navigation = {
- nextEl: '.swiper-button-next',
- prevEl: '.swiper-button-prev'
- };
- }
- if (sliderMarkup.querySelector('.swiper-pagination')) {
- options.pagination = {
- el: '.swiper-pagination',
- type: 'bullets',
- clickable: true
- };
- }
- if (sliderMarkup.querySelector('.swiper-scrollbar')) {
- options.scrollbar = {
- el: '.swiper-scrollbar',
- hide: false
- };
- }
- for (var s = 0; s < slides.length; s++) {
- var
- slide = slides[s],
- url = slide.getAttribute('data-slide-bg');
- if (url) slide.style.backgroundImage = 'url(' + url + ')';
- }
- options.on = {
- init: function () {
- setRealPrevious(this);
- initCaptionAnimate(this);
- // Real Previous Index must be set recent
- this.on('slideChangeTransitionEnd', function () {
- setRealPrevious(this);
- });
- }
- };
- swiper = new Swiper(sliderMarkup, options);
- return swiper;
- }
- /**
- * @desc Animate captions on active slides
- * @param {object} swiper - swiper instance
- */
- function initCaptionAnimate( swiper ) {
- var
- animate = function ( caption ) {
- return function() {
- var duration;
- if ( duration = caption.getAttribute( 'data-caption-duration' ) ) caption.style.animationDuration = duration +'ms';
- caption.classList.remove( 'not-animated' );
- caption.classList.add( caption.getAttribute( 'data-caption-animate' ) );
- caption.classList.add( 'animated' );
- };
- },
- initializeAnimation = function ( captions ) {
- for ( var i = 0; i < captions.length; i++ ) {
- var caption = captions[i];
- caption.classList.remove( 'animated' );
- caption.classList.remove( caption.getAttribute( 'data-caption-animate' ) );
- caption.classList.add( 'not-animated' );
- }
- },
- finalizeAnimation = function ( captions ) {
- for ( var i = 0; i < captions.length; i++ ) {
- var caption = captions[i];
- if ( caption.getAttribute( 'data-caption-delay' ) ) {
- setTimeout( animate( caption ), Number( caption.getAttribute( 'data-caption-delay' ) ) );
- } else {
- animate( caption )();
- }
- }
- };
- // Caption parameters
- swiper.params.caption = {
- animationEvent: 'slideChangeTransitionEnd'
- };
- initializeAnimation( swiper.$wrapperEl[0].querySelectorAll( '[data-caption-animate]' ) );
- finalizeAnimation( swiper.$wrapperEl[0].children[ swiper.activeIndex ].querySelectorAll( '[data-caption-animate]' ) );
- if ( swiper.params.caption.animationEvent === 'slideChangeTransitionEnd' ) {
- swiper.on( swiper.params.caption.animationEvent, function() {
- initializeAnimation( swiper.$wrapperEl[0].children[ swiper.previousIndex ].querySelectorAll( '[data-caption-animate]' ) );
- finalizeAnimation( swiper.$wrapperEl[0].children[ swiper.activeIndex ].querySelectorAll( '[data-caption-animate]' ) );
- });
- } else {
- swiper.on( 'slideChangeTransitionEnd', function() {
- initializeAnimation( swiper.$wrapperEl[0].children[ swiper.previousIndex ].querySelectorAll( '[data-caption-animate]' ) );
- });
- swiper.on( swiper.params.caption.animationEvent, function() {
- finalizeAnimation( swiper.$wrapperEl[0].children[ swiper.activeIndex ].querySelectorAll( '[data-caption-animate]' ) );
- });
- }
- }
- // Additional class on html if mac os.
- if (navigator.platform.match(/(Mac)/i)) {
- $html.addClass("mac-os");
- }
- // Adds some loosing functionality to IE browsers (IE Polyfills)
- if (isIE) {
- if (isIE === 12) $html.addClass("ie-edge");
- if (isIE === 11) $html.addClass("ie-11");
- if (isIE < 10) $html.addClass("lt-ie-10");
- if (isIE < 11) $html.addClass("ie-10");
- }
- // Google ReCaptcha
- if (plugins.captcha.length) {
- $.getScript("//www.google.com/recaptcha/api.js?onload=onloadCaptchaCallback&render=explicit&hl=en");
- }
- // Bootstrap Tooltips
- if (plugins.bootstrapTooltip.length) {
- var tooltipPlacement = plugins.bootstrapTooltip.attr('data-placement');
- initBootstrapTooltip(tooltipPlacement);
- $window.on('resize orientationchange', function () {
- initBootstrapTooltip(tooltipPlacement);
- })
- }
- // Bootstrap tabs
- if (plugins.bootstrapTabs.length) {
- for (var i = 0; i < plugins.bootstrapTabs.length; i++) {
- var bootstrapTabsItem = $(plugins.bootstrapTabs[i]);
- //If have slick carousel inside tab - resize slick carousel on click
- if (bootstrapTabsItem.find('.slick-slider').length) {
- bootstrapTabsItem.find('.tabs-custom-list > li > a').on('click', $.proxy(function () {
- var $this = $(this);
- var setTimeOutTime = isNoviBuilder ? 1500 : 300;
- setTimeout(function () {
- $this.find('.tab-content .tab-pane.active .slick-slider').slick('setPosition');
- }, setTimeOutTime);
- }, bootstrapTabsItem));
- }
- }
- }
- // Copyright Year (Evaluates correct copyright year)
- if (plugins.copyrightYear.length) {
- plugins.copyrightYear.text(initialDate.getFullYear());
- }
- // Google maps
- if( plugins.maps.length ) {
- lazyInit( plugins.maps, initMaps );
- }
- // Add custom styling options for input[type="radio"]
- if (plugins.radio.length) {
- for (var i = 0; i < plugins.radio.length; i++) {
- $(plugins.radio[i]).addClass("radio-custom").after("<span class='radio-custom-dummy'></span>")
- }
- }
- // Add custom styling options for input[type="checkbox"]
- if (plugins.checkbox.length) {
- for (var i = 0; i < plugins.checkbox.length; i++) {
- $(plugins.checkbox[i]).addClass("checkbox-custom").after("<span class='checkbox-custom-dummy'></span>")
- }
- }
- // UI To Top
- if (isDesktop && !isNoviBuilder) {
- $().UItoTop({
- easingType: 'easeOutQuad',
- containerClass: 'ui-to-top mdi mdi-arrow-up'
- });
- }
- // RD Navbar
- if (plugins.rdNavbar.length) {
- var aliaces, i, j, len, value, values, responsiveNavbar;
- aliaces = ["-", "-sm-", "-md-", "-lg-", "-xl-", "-xxl-"];
- values = [0, 576, 768, 992, 1200, 1600];
- responsiveNavbar = {};
- for (i = j = 0, len = values.length; j < len; i = ++j) {
- value = values[i];
- if (!responsiveNavbar[values[i]]) {
- responsiveNavbar[values[i]] = {};
- }
- if (plugins.rdNavbar.attr('data' + aliaces[i] + 'layout')) {
- responsiveNavbar[values[i]].layout = plugins.rdNavbar.attr('data' + aliaces[i] + 'layout');
- }
- if (plugins.rdNavbar.attr('data' + aliaces[i] + 'device-layout')) {
- responsiveNavbar[values[i]]['deviceLayout'] = plugins.rdNavbar.attr('data' + aliaces[i] + 'device-layout');
- }
- if (plugins.rdNavbar.attr('data' + aliaces[i] + 'hover-on')) {
- responsiveNavbar[values[i]]['focusOnHover'] = plugins.rdNavbar.attr('data' + aliaces[i] + 'hover-on') === 'true';
- }
- if (plugins.rdNavbar.attr('data' + aliaces[i] + 'auto-height')) {
- responsiveNavbar[values[i]]['autoHeight'] = plugins.rdNavbar.attr('data' + aliaces[i] + 'auto-height') === 'true';
- }
- if (isNoviBuilder) {
- responsiveNavbar[values[i]]['stickUp'] = false;
- } else if (plugins.rdNavbar.attr('data' + aliaces[i] + 'stick-up')) {
- responsiveNavbar[values[i]]['stickUp'] = plugins.rdNavbar.attr('data' + aliaces[i] + 'stick-up') === 'true';
- }
- if (plugins.rdNavbar.attr('data' + aliaces[i] + 'stick-up-offset')) {
- responsiveNavbar[values[i]]['stickUpOffset'] = plugins.rdNavbar.attr('data' + aliaces[i] + 'stick-up-offset');
- }
- }
- plugins.rdNavbar.RDNavbar({
- anchorNav: !isNoviBuilder,
- stickUpClone: (plugins.rdNavbar.attr("data-stick-up-clone") && !isNoviBuilder) ? plugins.rdNavbar.attr("data-stick-up-clone") === 'true' : false,
- responsive: responsiveNavbar,
- callbacks: {
- onStuck: function () {
- var navbarSearch = this.$element.find('.rd-search input');
- if (navbarSearch) {
- navbarSearch.val('').trigger('propertychange');
- }
- },
- onDropdownOver: function () {
- return !isNoviBuilder;
- },
- onUnstuck: function () {
- if (this.$clone === null)
- return;
- var navbarSearch = this.$clone.find('.rd-search input');
- if (navbarSearch) {
- navbarSearch.val('').trigger('propertychange');
- navbarSearch.trigger('blur');
- }
- }
- }
- });
- if (plugins.rdNavbar.attr("data-body-class")) {
- document.body.className += ' ' + plugins.rdNavbar.attr("data-body-class");
- }
- }
- // Owl carousel
- if (plugins.owl.length) {
- for (var i = 0; i < plugins.owl.length; i++) {
- var c = $(plugins.owl[i]);
- plugins.owl[i].owl = c;
- initOwlCarousel(c);
- }
- // Owl bug with webkit scrollbar
- if ( !isIE || isIE >= 12 ) {
- setTimeout( function() {
- window.dispatchEvent( new Event('resize') );
- }, 500)
- }
- }
- // RD Search
- if (plugins.search.length || plugins.searchResults) {
- var handler = "bat/rd-search.php";
- var defaultTemplate = '<h5 class="search-title"><a target="_top" href="#{href}" class="search-link">#{title}</a></h5>' +
- '<p>...#{token}...</p>' +
- '<p class="match"><em>Terms matched: #{count} - URL: #{href}</em></p>';
- var defaultFilter = '*.html';
- if (plugins.search.length) {
- for (var i = 0; i < plugins.search.length; i++) {
- var searchItem = $(plugins.search[i]),
- options = {
- element: searchItem,
- filter: (searchItem.attr('data-search-filter')) ? searchItem.attr('data-search-filter') : defaultFilter,
- template: (searchItem.attr('data-search-template')) ? searchItem.attr('data-search-template') : defaultTemplate,
- live: (searchItem.attr('data-search-live')) ? searchItem.attr('data-search-live') : false,
- liveCount: (searchItem.attr('data-search-live-count')) ? parseInt(searchItem.attr('data-search-live'), 10) : 4,
- current: 0, processed: 0, timer: {}
- };
- var $toggle = $('.rd-navbar-search-toggle');
- if ($toggle.length) {
- $toggle.on('click', (function (searchItem) {
- return function () {
- if (!($(this).hasClass('active'))) {
- searchItem.find('input').val('').trigger('propertychange');
- }
- }
- })(searchItem));
- }
- if (options.live) {
- var clearHandler = false;
- searchItem.find('input').on("input propertychange", $.proxy(function () {
- this.term = this.element.find('input').val().trim();
- this.spin = this.element.find('.input-group-addon');
- clearTimeout(this.timer);
- if (this.term.length > 2) {
- this.timer = setTimeout(liveSearch(this), 200);
- if (clearHandler === false) {
- clearHandler = true;
- $body.on("click", function (e) {
- if ($(e.toElement).parents('.rd-search').length === 0) {
- $('#rd-search-results-live').addClass('cleared').html('');
- }
- })
- }
- } else if (this.term.length === 0) {
- $('#' + this.live).addClass('cleared').html('');
- }
- }, options, this));
- }
- searchItem.submit($.proxy(function () {
- $('<input />').attr('type', 'hidden')
- .attr('name', "filter")
- .attr('value', this.filter)
- .appendTo(this.element);
- return true;
- }, options, this))
- }
- }
- if (plugins.searchResults.length) {
- var regExp = /\?.*s=([^&]+)\&filter=([^&]+)/g;
- var match = regExp.exec(location.search);
- if (match !== null) {
- $.get(handler, {
- s: decodeURI(match[1]),
- dataType: "html",
- filter: match[2],
- template: defaultTemplate,
- live: ''
- }, function (data) {
- plugins.searchResults.html(data);
- })
- }
- }
- }
- // Swiper
- if (plugins.swiper) {
- for (var i = 0; i < plugins.swiper.length; i++) {
- plugins.swiper[i].swiper = initSwiper(plugins.swiper[i]);
- }
- var dynamicSwipers = $('.swiper-slider-custom');
- if(dynamicSwipers.length) {
- $window.on('resize orientationchange', function () {
- for (var i = 0; i < dynamicSwipers.length; i++) {
- if(window.innerWidth < 576 && dynamicSwipers[i].swiper.params.direction === 'vertical') {
- dynamicSwipers[i].setAttribute('data-direction', 'horizontal');
- dynamicSwipers[i].swiper.destroy();
- initSwiper(dynamicSwipers[i]);
- } else if (window.innerWidth >= 576 && dynamicSwipers[i].swiper.params.direction === 'horizontal') {
- dynamicSwipers[i].setAttribute('data-direction', 'vertical');
- dynamicSwipers[i].swiper.destroy();
- initSwiper(dynamicSwipers[i]);
- }
- }
- });
- }
- }
- // WOW
- if ($html.hasClass("wow-animation") && plugins.wow.length && !isNoviBuilder && isDesktop) {
- new WOW().init();
- }
- // RD Input Label
- if (plugins.rdInputLabel.length) {
- plugins.rdInputLabel.RDInputLabel();
- }
- // Regula
- if (plugins.regula.length) {
- attachFormValidator(plugins.regula);
- }
- // MailChimp Ajax subscription
- if (plugins.mailchimp.length) {
- for (i = 0; i < plugins.mailchimp.length; i++) {
- var $mailchimpItem = $(plugins.mailchimp[i]),
- $email = $mailchimpItem.find('input[type="email"]');
- // Required by MailChimp
- $mailchimpItem.attr('novalidate', 'true');
- $email.attr('name', 'EMAIL');
- $mailchimpItem.on('submit', $.proxy( function ( $email, event ) {
- event.preventDefault();
- var $this = this;
- var data = {},
- url = $this.attr('action').replace('/post?', '/post-json?').concat('&c=?'),
- dataArray = $this.serializeArray(),
- $output = $("#" + $this.attr("data-form-output"));
- for (i = 0; i < dataArray.length; i++) {
- data[dataArray[i].name] = dataArray[i].value;
- }
- $.ajax({
- data: data,
- url: url,
- dataType: 'jsonp',
- error: function (resp, text) {
- $output.html('Server error: ' + text);
- setTimeout(function () {
- $output.removeClass("active");
- }, 4000);
- },
- success: function (resp) {
- $output.html(resp.msg).addClass('active');
- $email[0].value = '';
- var $label = $('[for="'+ $email.attr( 'id' ) +'"]');
- if ( $label.length ) $label.removeClass( 'focus not-empty' );
- setTimeout(function () {
- $output.removeClass("active");
- }, 6000);
- },
- beforeSend: function (data) {
- var isNoviBuilder = window.xMode;
- var isValidated = (function () {
- var results, errors = 0;
- var elements = $this.find('[data-constraints]');
- var captcha = null;
- if (elements.length) {
- for (var j = 0; j < elements.length; j++) {
- var $input = $(elements[j]);
- if ((results = $input.regula('validate')).length) {
- for (var k = 0; k < results.length; k++) {
- errors++;
- $input.siblings(".form-validation").text(results[k].message).parent().addClass("has-error");
- }
- } else {
- $input.siblings(".form-validation").text("").parent().removeClass("has-error")
- }
- }
- if (captcha) {
- if (captcha.length) {
- return validateReCaptcha(captcha) && errors === 0
- }
- }
- return errors === 0;
- }
- return true;
- })();
- // Stop request if builder or inputs are invalide
- if (isNoviBuilder || !isValidated)
- return false;
- $output.html('Submitting...').addClass('active');
- }
- });
- return false;
- }, $mailchimpItem, $email ));
- }
- }
- // Campaign Monitor ajax subscription
- if (plugins.campaignMonitor.length) {
- for (i = 0; i < plugins.campaignMonitor.length; i++) {
- var $campaignItem = $(plugins.campaignMonitor[i]);
- $campaignItem.on('submit', $.proxy(function (e) {
- var data = {},
- url = this.attr('action'),
- dataArray = this.serializeArray(),
- $output = $("#" + plugins.campaignMonitor.attr("data-form-output")),
- $this = $(this);
- for (i = 0; i < dataArray.length; i++) {
- data[dataArray[i].name] = dataArray[i].value;
- }
- $.ajax({
- data: data,
- url: url,
- dataType: 'jsonp',
- error: function (resp, text) {
- $output.html('Server error: ' + text);
- setTimeout(function () {
- $output.removeClass("active");
- }, 4000);
- },
- success: function (resp) {
- $output.html(resp.Message).addClass('active');
- setTimeout(function () {
- $output.removeClass("active");
- }, 6000);
- },
- beforeSend: function (data) {
- // Stop request if builder or inputs are invalide
- if (isNoviBuilder || !isValidated($this.find('[data-constraints]')))
- return false;
- $output.html('Submitting...').addClass('active');
- }
- });
- // Clear inputs after submit
- var inputs = $this[0].getElementsByTagName('input');
- for (var i = 0; i < inputs.length; i++) {
- inputs[i].value = '';
- var label = document.querySelector( '[for="'+ inputs[i].getAttribute( 'id' ) +'"]' );
- if( label ) label.classList.remove( 'focus', 'not-empty' );
- }
- return false;
- }, $campaignItem));
- }
- }
- // RD Mailform
- if (plugins.rdMailForm.length) {
- var i, j, k,
- msg = {
- 'MF000': 'Successfully sent!',
- 'MF001': 'Recipients are not set!',
- 'MF002': 'Form will not work locally!',
- 'MF003': 'Please, define email field in your form!',
- 'MF004': 'Please, define type of your form!',
- 'MF254': 'Something went wrong with PHPMailer!',
- 'MF255': 'Aw, snap! Something went wrong.'
- };
- for (i = 0; i < plugins.rdMailForm.length; i++) {
- var $form = $(plugins.rdMailForm[i]),
- formHasCaptcha = false;
- $form.attr('novalidate', 'novalidate').ajaxForm({
- data: {
- "form-type": $form.attr("data-form-type") || "contact",
- "counter": i
- },
- beforeSubmit: function (arr, $form, options) {
- if (isNoviBuilder)
- return;
- var form = $(plugins.rdMailForm[this.extraData.counter]),
- inputs = form.find("[data-constraints]"),
- output = $("#" + form.attr("data-form-output")),
- captcha = form.find('.recaptcha'),
- captchaFlag = true;
- output.removeClass("active error success");
- if (isValidated(inputs, captcha)) {
- // veify reCaptcha
- if (captcha.length) {
- var captchaToken = captcha.find('.g-recaptcha-response').val(),
- captchaMsg = {
- 'CPT001': 'Please, setup you "site key" and "secret key" of reCaptcha',
- 'CPT002': 'Something wrong with google reCaptcha'
- };
- formHasCaptcha = true;
- $.ajax({
- method: "POST",
- url: "bat/reCaptcha.php",
- data: {'g-recaptcha-response': captchaToken},
- async: false
- })
- .done(function (responceCode) {
- if (responceCode !== 'CPT000') {
- if (output.hasClass("snackbars")) {
- output.html('<p><span class="icon text-middle mdi mdi-check icon-xxs"></span><span>' + captchaMsg[responceCode] + '</span></p>')
- setTimeout(function () {
- output.removeClass("active");
- }, 3500);
- captchaFlag = false;
- } else {
- output.html(captchaMsg[responceCode]);
- }
- output.addClass("active");
- }
- });
- }
- if (!captchaFlag) {
- return false;
- }
- form.addClass('form-in-process');
- if (output.hasClass("snackbars")) {
- output.html('<p><span class="icon text-middle fa fa-circle-o-notch fa-spin icon-xxs"></span><span>Sending</span></p>');
- output.addClass("active");
- }
- } else {
- return false;
- }
- },
- error: function (result) {
- if (isNoviBuilder)
- return;
- var output = $("#" + $(plugins.rdMailForm[this.extraData.counter]).attr("data-form-output")),
- form = $(plugins.rdMailForm[this.extraData.counter]);
- output.text(msg[result]);
- form.removeClass('form-in-process');
- if (formHasCaptcha) {
- grecaptcha.reset();
- }
- },
- success: function (result) {
- if (isNoviBuilder)
- return;
- var form = $(plugins.rdMailForm[this.extraData.counter]),
- output = $("#" + form.attr("data-form-output")),
- select = form.find('select');
- form
- .addClass('success')
- .removeClass('form-in-process');
- if (formHasCaptcha) {
- grecaptcha.reset();
- }
- result = result.length === 5 ? result : 'MF255';
- output.text(msg[result]);
- if (result === "MF000") {
- if (output.hasClass("snackbars")) {
- output.html('<p><span class="icon text-middle mdi mdi-check icon-xxs"></span><span>' + msg[result] + '</span></p>');
- } else {
- output.addClass("active success");
- }
- } else {
- if (output.hasClass("snackbars")) {
- output.html(' <p class="snackbars-left"><span class="icon icon-xxs mdi mdi-alert-outline text-middle"></span><span>' + msg[result] + '</span></p>');
- } else {
- output.addClass("active error");
- }
- }
- form.clearForm();
- if (select.length) {
- select.select2("val", "");
- }
- form.find('input, textarea').trigger('blur');
- setTimeout(function () {
- output.removeClass("active error success");
- form.removeClass('success');
- }, 3500);
- }
- });
- }
- }
- // lightGallery
- if (plugins.lightGallery.length) {
- for (var i = 0; i < plugins.lightGallery.length; i++) {
- initLightGallery(plugins.lightGallery[i]);
- }
- }
- // lightGallery item
- if (plugins.lightGalleryItem.length) {
- // Filter carousel items
- var notCarouselItems = [];
- for (var z = 0; z < plugins.lightGalleryItem.length; z++) {
- if (!$(plugins.lightGalleryItem[z]).parents('.owl-carousel').length &&
- !$(plugins.lightGalleryItem[z]).parents('.swiper-slider').length &&
- !$(plugins.lightGalleryItem[z]).parents('.slick-slider').length) {
- notCarouselItems.push(plugins.lightGalleryItem[z]);
- }
- }
- plugins.lightGalleryItem = notCarouselItems;
- for (var i = 0; i < plugins.lightGalleryItem.length; i++) {
- initLightGalleryItem(plugins.lightGalleryItem[i]);
- }
- }
- // Dynamic lightGallery
- if (plugins.lightDynamicGalleryItem.length) {
- for (var i = 0; i < plugins.lightDynamicGalleryItem.length; i++) {
- initDynamicLightGallery(plugins.lightDynamicGalleryItem[i]);
- }
- }
- // Custom Toggles
- if (plugins.customToggle.length) {
- for (var i = 0; i < plugins.customToggle.length; i++) {
- var $this = $(plugins.customToggle[i]);
- $this.on('click', $.proxy(function (event) {
- event.preventDefault();
- var $ctx = $(this);
- $($ctx.attr('data-custom-toggle')).add(this).toggleClass('active');
- }, $this));
- if ($this.attr("data-custom-toggle-hide-on-blur") === "true") {
- $body.on("click", $this, function (e) {
- if (e.target !== e.data[0]
- && $(e.data.attr('data-custom-toggle')).find($(e.target)).length
- && e.data.find($(e.target)).length === 0) {
- $(e.data.attr('data-custom-toggle')).add(e.data[0]).removeClass('active');
- }
- })
- }
- if ($this.attr("data-custom-toggle-disable-on-blur") === "true") {
- $body.on("click", $this, function (e) {
- if (e.target !== e.data[0] && $(e.data.attr('data-custom-toggle')).find($(e.target)).length === 0 && e.data.find($(e.target)).length === 0) {
- $(e.data.attr('data-custom-toggle')).add(e.data[0]).removeClass('active');
- }
- })
- }
- }
- }
- //RD Range
- if (plugins.rdRange.length && !isNoviBuilder) {
- plugins.rdRange.RDRange({
- callbacks: {
- onChange: function() {
- var $inputs = $('.rd-range-input-value-1, .rd-range-input-value-2');
- for(var z = 0; z < $inputs.length; z++) {
- if(isDesktop) {
- $inputs[z].style.width = ($inputs[z].value.length + 1) * 1.15 + 'ch';
- }
- }
- },
- }
- });
- }
- // Select 2
- if ( plugins.selectFilter.length ) {
- for ( var i = 0; i < plugins.selectFilter.length; i++ ) {
- var select = $( plugins.selectFilter[ i ] );
- select.select2( {
- dropdownParent: select.parent(),
- placeholder: select.attr( 'data-placeholder' ) || null,
- minimumResultsForSearch: select.attr( 'data-minimum-results-search' ) || Infinity,
- containerCssClass: select.attr( 'data-container-class' ) || null,
- dropdownCssClass: select.attr( 'data-dropdown-class' ) || null
- } );
- }
- }
- // Slick carousel
- if (plugins.slick.length) {
- for (var i = 0; i < plugins.slick.length; i++) {
- var $slickItem = $(plugins.slick[i]);
- $slickItem.on('init', function (slick) {
- initLightGallery($('[data-lightgallery="group-slick"]'), 'lightGallery-in-carousel');
- initLightGallery($('[data-lightgallery="item-slick"]'), 'lightGallery-in-carousel');
- });
- $slickItem.slick({
- slidesToScroll: parseInt($slickItem.attr('data-slide-to-scroll'), 10) || 1,
- asNavFor: $slickItem.attr('data-for') || false,
- dots: $slickItem.attr("data-dots") === "true",
- infinite: isNoviBuilder ? false : $slickItem.attr("data-loop") === "true",
- focusOnSelect: $slickItem.attr('data-focus-select') || true,
- arrows: $slickItem.attr("data-arrows") === "true",
- swipe: $slickItem.attr("data-swipe") === "true",
- autoplay: $slickItem.attr("data-autoplay") === "true",
- centerMode: $slickItem.attr("data-center-mode") === "true",
- fade: $slickItem.attr("data-slide-effect") === "true",
- centerPadding: $slickItem.attr("data-center-padding") ? $slickItem.attr("data-center-padding") : '0.50',
- mobileFirst: true,
- appendArrows: $slickItem.attr("data-arrows-class") || $slickItem,
- nextArrow: '<button type="button" class="slick-next"></button>',
- prevArrow: '<button type="button" class="slick-prev"></button>',
- responsive: [
- {
- breakpoint: 0,
- settings: {
- slidesToShow: parseInt($slickItem.attr('data-items'), 10) || 1,
- vertical: $slickItem.attr('data-vertical') === 'true' || false
- }
- },
- {
- breakpoint: 575,
- settings: {
- slidesToShow: parseInt($slickItem.attr('data-sm-items'), 10) || 1,
- vertical: $slickItem.attr('data-sm-vertical') === 'true' || false
- }
- },
- {
- breakpoint: 767,
- settings: {
- slidesToShow: parseInt($slickItem.attr('data-md-items'), 10) || 1,
- vertical: $slickItem.attr('data-md-vertical') === 'true' || false
- }
- },
- {
- breakpoint: 991,
- settings: {
- slidesToShow: parseInt($slickItem.attr('data-lg-items'), 10) || 1,
- vertical: $slickItem.attr('data-lg-vertical') === 'true' || false
- }
- },
- {
- breakpoint: 1199,
- settings: {
- slidesToShow: parseInt($slickItem.attr('data-xl-items'), 10) || 1,
- vertical: $slickItem.attr('data-xl-vertical') === 'true' || false
- }
- },
- {
- breakpoint: 1599,
- settings: {
- slidesToShow: parseInt($slickItem.attr('data-xxl-items'), 10) || 1,
- vertical: $slickItem.attr('data-xxl-vertical') === 'true' || false
- }
- }
- ]
- })
- .on('afterChange', function (event, slick, currentSlide, nextSlide) {
- var $this = $(this),
- childCarousel = $this.attr('data-child');
- if (childCarousel) {
- $(childCarousel + ' .slick-slide').removeClass('slick-current');
- $(childCarousel + ' .slick-slide').eq(currentSlide).addClass('slick-current');
- }
- });
- }
- }
- // Stepper
- if (plugins.stepper.length) {
- plugins.stepper.stepper({
- labels: {
- up: "",
- down: ""
- }
- });
- }
- // Radio Panel
- if (plugins.radioPanel) {
- for (var i = 0; i < plugins.radioPanel.length; i++) {
- var $element = $(plugins.radioPanel[i]);
- $element.on('click', function () {
- plugins.radioPanel.removeClass('active');
- $(this).addClass('active');
- })
- }
- }
- // Multitoggles
- if(plugins.multitoggle.length) {
- multitoggles();
- }
- });
- }());
|