H69UNtblNBNpha2dtB1Odn8qYp1Qk5NK2gi7yfceofo9N
/
home
/
ymswebso
/
public_html
/
projects
/
systronics
/
js
/
Nama File / Folder
Size
Action
script.js
51.96KB
Hapus
Edit
Rename
<=Back
"use strict"; (function () { // Global letiables let 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 = true, plugins = { bootstrapTooltip: $('[data-toggle="tooltip"]'), bootstrapModal: $('.modal'), bootstrapTabs: $('.tabs-custom'), customToggle: $('[data-custom-toggle]'), captcha: $('.recaptcha'), copyrightYear: $('.copyright-year'), checkbox: $('input[type="checkbox"]'), lightGallery: $('[data-lightgallery="group"]'), lightGalleryItem: $('[data-lightgallery="item"]'), lightDynamicGalleryItem: $('[data-lightgallery="dynamic"]'), owl: $('.owl-carousel'), selectFilter: $("select"), preloader: $('.preloader'), rdNavbar: $('.rd-navbar'), rdRange: $('.rd-range'), rdMailForm: $('.rd-mailform'), rdInputLabel: $('.form-label'), regula: $('[data-constraints]'), radio: $('input[type="radio"]'), swiper: $('.swiper-container'), search: $('.rd-search'), searchResults: $('.rd-search-results'), wow: $('.wow'), maps: $('.google-map-container'), accordion: $('.accordion'), slick: $('.slick-slider'), stepper: $("input[type='number']"), calendar: $(".rd-calendar"), vide: $( '.vide' ), customWaypoints: $('[data-custom-scroll-to]'), multitoggle: document.querySelectorAll( '[data-multitoggle]' ), counter: document.querySelectorAll('.counter'), countdown: document.querySelectorAll('.countdown') }; /** * @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) { let 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 window $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 link && !/(\#|javascript:void\(0\)|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; } }); } // Counter if (plugins.counter) { for (let i = 0; i < plugins.counter.length; i++) { let node = plugins.counter[i], counter = aCounter({ node: node, duration: node.getAttribute('data-duration') || 1000 }), scrollHandler = (function () { if (Util.inViewport(this) && !this.classList.contains('animated-first')) { this.counter.run(); this.classList.add('animated-first'); } }).bind(node), blurHandler = (function () { this.counter.params.to = parseInt(this.textContent, 10); this.counter.run(); }).bind(node); if (isNoviBuilder) { node.counter.run(); node.addEventListener('blur', blurHandler); } else { scrollHandler(); window.addEventListener('scroll', scrollHandler); } } } }); // Initialize scripts that require a finished document $(function () { isNoviBuilder = window.xMode; /** * Wrapper to eliminate json errors * @param {string} str - JSON string * @returns {object} - parsed or empty object */ function parseJSON ( str ) { try { if ( str ) return JSON.parse( str ); else return {}; } catch ( error ) { console.warn( error ); return {}; } } /** * @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) { let element = swiper.$wrapperEl[0].children[swiper.activeIndex]; swiper.realPrevious = Array.prototype.indexOf.call(element.parentNode.children, element); } /** * @desc Sets slides background images from attribute 'data-slide-bg' * @param {object} swiper - swiper instance */ function setBackgrounds(swiper) { let swipersBg = swiper.el.querySelectorAll('[data-slide-bg]'); for (let i = 0; i < swipersBg.length; i++) { let swiperBg = swipersBg[i]; swiperBg.style.backgroundImage = 'url(' + swiperBg.getAttribute('data-slide-bg') + ')'; } } /** * @desc Animate captions on active slides * @param {object} swiper - swiper instance */ function initCaptionAnimate(swiper) { let animate = function (caption) { return function () { let 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 (let i = 0; i < captions.length; i++) { let caption = captions[i]; caption.classList.remove('animated'); caption.classList.remove(caption.getAttribute('data-caption-animate')); caption.classList.add('not-animated'); } }, finalizeAnimation = function (captions) { for (let i = 0; i < captions.length; i++) { let 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]')); }); } } /** * @desc Create live search results * @param {object} options */ function liveSearch(options, handler) { $('#' + 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++; let 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 (let i = 0; i < elements.length; i++) { let 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) { let $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 (let 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'); let 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 (let i = 0; i < regularConstraintsMessages.length; i++) { let 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) { let results, errors = 0; if (elements.length) { for (let j = 0; j < elements.length; j++) { let $input = $(elements[j]); if ((results = $input.regula('validate')).length) { for (let 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) { let 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 () { let $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 (let i = 0; i < plugins.captcha.length; i++) { let $captcha = $(plugins.captcha[i]), resizeHandler = (function () { let 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) { let 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) { let latitude = results[0].geometry.location.lat(); let longitude = results[0].geometry.location.lng(); callback(new google.maps.LatLng( parseFloat(latitude), parseFloat(longitude) ), marker, map) } }) } } /** * @desc Initialize Google maps */ function initMaps() { let key; for (let 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 + '&' : '') + 'libraries=geometry,places&v=quarterly', function () { let 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); }; let geocoder = new google.maps.Geocoder; for (let i = 0; i < plugins.maps.length; i++) { let zoom = parseInt(plugins.maps[i].getAttribute("data-zoom"), 10) || 11; let styles = plugins.maps[i].hasAttribute('data-styles') ? JSON.parse(plugins.maps[i].getAttribute("data-styles")) : []; let center = plugins.maps[i].getAttribute("data-center") || "New York"; // Initialize map let 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 let markerItems = plugins.maps[i].querySelectorAll(".google-map-markers li"); if (markerItems.length) { let markers = []; for (let j = 0; j < markerItems.length; j++) { let markerElement = markerItems[j]; getLatLngObject(markerElement.getAttribute("data-location"), markerElement, plugins.maps[i], function (location, markerElement, mapElement) { let icon = markerElement.getAttribute("data-icon") || mapElement.getAttribute("data-icon"); let activeIcon = markerElement.getAttribute("data-icon-active") || mapElement.getAttribute("data-icon-active"); let info = markerElement.getAttribute("data-description") || ""; let infoWindow = new google.maps.InfoWindow({ content: info }); markerElement.infoWindow = infoWindow; let markerData = { position: location, map: mapElement.map } if (icon) { markerData.icon = icon; } let 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) { let 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) { let markerIcon; if (markerElement.infoWindow.getContent().length === 0) return; let gMarker, currentMarker = markerElement.gmarker, currentInfoWindow; for (let k = 0; k < markers.length; k++) { 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)) }) } } } }); } // Calendar items function initRowEvents(events) { if (!events.length) { return false; } for (i = 0; i < events.length; i++) { var $event = $(events[i]); $event.on('click', i, function (event) { var $selectedEvent = $(this), hiddenEvents = $selectedEvent.find('.rdc-table_events'), ch = hiddenEvents.outerHeight(), animationDuration = 330, revealOffset = 0, eventRow, openedEvents = $(".rdc-calendar-event-panel"); if ($selectedEvent.hasClass("opened")) { eventRow = $('#calendarEvent' + event.data + ' .event-panel'); eventRow.animate({height: "0"}, animationDuration); setTimeout(function () { eventRow.parent().remove(); }, animationDuration); } else { if (openedEvents.length) { openedEvents.animate({height: "0"}, animationDuration); $('.rdc-table_has-events.opened').removeClass('opened'); setTimeout(function () { openedEvents.remove(); }, animationDuration); revealOffset = animationDuration * 1.2; } setTimeout(function () { $selectedEvent.parent().after("<div class='rdc-calendar-event-panel' id='calendarEvent" + event.data + "'><div class='event-panel'></div></div>"); eventRow = hiddenEvents.clone().appendTo($('#calendarEvent' + event.data + ' .event-panel')); ch = eventRow.outerHeight(); eventRow.parent().css("height", "0"); eventRow.parent().animate({height: ch + "px"}, animationDuration); }, revealOffset); } setTimeout(function () { $selectedEvent.toggleClass("opened"); }, revealOffset); }); } } // Google ReCaptcha if (plugins.captcha.length) { $.getScript("//www.google.com/recaptcha/api.js?onload=onloadCaptchaCallback&render=explicit&hl=en"); } // 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"); } // Bootstrap Tooltips if (plugins.bootstrapTooltip.length) { let tooltipPlacement = plugins.bootstrapTooltip.attr('data-placement'); initBootstrapTooltip(tooltipPlacement); $window.on('resize orientationchange', function () { initBootstrapTooltip(tooltipPlacement); }) } // Bootstrap Modal if (plugins.bootstrapModal.length) { for (let i = 0; i < plugins.bootstrapModal.length; i++) { let modalItem = $(plugins.bootstrapModal[i]); modalItem.on('hidden.bs.modal', $.proxy(function () { let activeModal = $(this), rdVideoInside = activeModal.find('video'), youTubeVideoInside = activeModal.find('iframe'); if (rdVideoInside.length) { rdVideoInside[0].pause(); } if (youTubeVideoInside.length) { let videoUrl = youTubeVideoInside.attr('src'); youTubeVideoInside .attr('src', '') .attr('src', videoUrl); } }, modalItem)) } } // Bootstrap tabs if (plugins.bootstrapTabs.length) { for (let i = 0; i < plugins.bootstrapTabs.length; i++) { let bootstrapTab = $(plugins.bootstrapTabs[i]); //If have slick carousel inside tab - resize slick carousel on click if (bootstrapTab.find('.slick-slider').length) { bootstrapTab.find('.tabs-custom-list > li > a').on('click', $.proxy(function () { let $this = $(this); let setTimeOutTime = isNoviBuilder ? 1500 : 300; setTimeout(function () { $this.find('.tab-content .tab-pane.active .slick-slider').slick('setPosition'); }, setTimeOutTime); }, bootstrapTab)); } let tabs = plugins.bootstrapTabs[i].querySelectorAll('.nav li a'); for (let t = 0; t < tabs.length; t++) { let tab = tabs[t]; if (t === 0) { tab.parentElement.classList.remove('active'); $(tab).tab('show'); } tab.addEventListener('click', function (event) { event.preventDefault(); $(this).tab('show'); }); } } } // 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 (let 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 (let 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 fa fa-angle-up' }); } // RD Navbar if (plugins.rdNavbar.length) { let navbar = plugins.rdNavbar, aliases = { '-': 0, '-sm-': 576, '-md-': 768, '-lg-': 992, '-xl-': 1200, '-xxl-': 1600 }, responsive = {}; for (let alias in aliases) { let link = responsive[aliases[alias]] = {}; if (navbar.attr('data' + alias + 'layout')) link.layout = navbar.attr('data' + alias + 'layout'); if (navbar.attr('data' + alias + 'device-layout')) link.deviceLayout = navbar.attr('data' + alias + 'device-layout'); if (navbar.attr('data' + alias + 'hover-on')) link.focusOnHover = navbar.attr('data' + alias + 'hover-on') === 'true'; if (navbar.attr('data' + alias + 'auto-height')) link.autoHeight = navbar.attr('data' + alias + 'auto-height') === 'true'; if (navbar.attr('data' + alias + 'stick-up-offset')) link.stickUpOffset = navbar.attr('data' + alias + 'stick-up-offset'); if (navbar.attr('data' + alias + 'stick-up')) link.stickUp = navbar.attr('data' + alias + 'stick-up') === 'true'; if (isNoviBuilder) link.stickUp = false; else if (navbar.attr('data' + alias + 'stick-up')) link.stickUp = navbar.attr('data' + alias + 'stick-up') === 'true'; } plugins.rdNavbar.RDNavbar({ anchorNav: !isNoviBuilder, stickUpClone: (plugins.rdNavbar.attr("data-stick-up-clone") && !isNoviBuilder) ? plugins.rdNavbar.attr("data-stick-up-clone") === 'true' : false, responsive: responsive, callbacks: { onStuck: function () { let navbarSearch = this.$element.find('.rd-search input'); if (navbarSearch) { navbarSearch.val('').trigger('propertychange'); } }, onDropdownOver: function () { return !isNoviBuilder; }, onUnstuck: function () { if (this.$clone === null) return; let navbarSearch = this.$clone.find('.rd-search input'); if (navbarSearch) { navbarSearch.val('').trigger('propertychange'); navbarSearch.trigger('blur'); } } } }); } // RD Search if (plugins.search.length || plugins.searchResults) { let handler = "bat/rd-search.php"; let 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>'; let defaultFilter = '*.html'; if (plugins.search.length) { for (let i = 0; i < plugins.search.length; i++) { let 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: {} }; let $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) { let 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, handler), 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) { let regExp = /\?.*s=([^&]+)\&filter=([^&]+)/g; let 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.length) { for (let i = 0; i < plugins.swiper.length; i++) { let node = plugins.swiper[i], params = parseJSON(node.getAttribute('data-swiper')), defaults = { speed: 1000, loop: true, pagination: { el: '.swiper-pagination', clickable: true }, navigation: { nextEl: '.swiper-button-next', prevEl: '.swiper-button-prev' }, autoplay: { delay: 5000 } }, xMode = { autoplay: false, loop: false, simulateTouch: false }; params.on = { init: function () { setBackgrounds(this); setRealPrevious(this); initCaptionAnimate(this); // Real Previous Index must be set recent this.on('slideChangeTransitionEnd', function () { setRealPrevious(this); }); } }; new Swiper( node, Util.merge( isNoviBuilder ? [ defaults, params, xMode ] : [ defaults, params ] ) ); } } // Owl carousel if (plugins.owl.length) { for (let i = 0; i < plugins.owl.length; i++) { let node = plugins.owl[i], params = parseJSON( node.getAttribute( 'data-owl' ) ), defaults = { items: 1, margin: 30, loop: true, mouseDrag: true, stagePadding: 0, nav: false, navText: [], dots: false, autoplay: false, autoplayTimeout: 3000, autoplayHoverPause: true }, xMode = { autoplay: false, loop: false, mouseDrag: false }, generated = { autoplay: node.getAttribute( 'data-autoplay' ) !== 'false', loop: node.getAttribute( 'data-loop' ) !== 'false', mouseDrag: node.getAttribute( 'data-mouse-drag' ) !== 'false', responsive: {} }, aliases = [ '-', '-sm-', '-md-', '-lg-', '-xl-', '-xxl-' ], values = [ 0, 576, 768, 992, 1200, 1600 ], responsive = generated.responsive; for ( let j = 0; j < values.length; j++ ) { responsive[ values[ j ] ] = {}; for ( let k = j; k >= -1; k-- ) { if ( !responsive[ values[ j ] ][ 'items' ] && node.getAttribute( 'data' + aliases[ k ] + 'items' ) ) { responsive[ values[ j ] ][ 'items' ] = k < 0 ? 1 : parseInt( node.getAttribute( 'data' + aliases[ k ] + 'items' ), 10 ); } if ( !responsive[ values[ j ] ][ 'stagePadding' ] && responsive[ values[ j ] ][ 'stagePadding' ] !== 0 && node.getAttribute( 'data' + aliases[ k ] + 'stage-padding' ) ) { responsive[ values[ j ] ][ 'stagePadding' ] = k < 0 ? 0 : parseInt( node.getAttribute( 'data' + aliases[ k ] + 'stage-padding' ), 10 ); } if ( !responsive[ values[ j ] ][ 'margin' ] && responsive[ values[ j ] ][ 'margin' ] !== 0 && node.getAttribute( 'data' + aliases[ k ] + 'margin' ) ) { responsive[ values[ j ] ][ 'margin' ] = k < 0 ? 30 : parseInt( node.getAttribute( 'data' + aliases[ k ] + 'margin' ), 10 ); } } } // Initialize lightgallery items in cloned owl items $(node).on('initialized.owl.carousel', function () { initLightGalleryItem($(node).find('[data-lightgallery="item"]'), 'lightGallery-in-carousel'); }); node.owl = $( node ); $( node ).owlCarousel( Util.merge( isNoviBuilder ? [ defaults, params, generated, xMode ] : [ defaults, params, generated ] ) ); } } // 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); } // RD Mailform if (plugins.rdMailForm.length) { let 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++) { let $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; let 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) { let 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; let 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(); window.dispatchEvent( new Event( 'resize' ) ); } }, success: function (result) { if (isNoviBuilder) return; let 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(); window.dispatchEvent( new Event( 'resize' ) ); } 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 (let i = 0; i < plugins.lightGallery.length; i++) { initLightGallery(plugins.lightGallery[i]); } } // lightGallery item if (plugins.lightGalleryItem.length) { // Filter carousel items let notCarouselItems = []; for (let 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 (let i = 0; i < plugins.lightGalleryItem.length; i++) { initLightGalleryItem(plugins.lightGalleryItem[i]); } } // Dynamic lightGallery if (plugins.lightDynamicGalleryItem.length) { for (let i = 0; i < plugins.lightDynamicGalleryItem.length; i++) { initDynamicLightGallery(plugins.lightDynamicGalleryItem[i]); } } // Custom Toggles if (plugins.customToggle.length) { for (let i = 0; i < plugins.customToggle.length; i++) { let $this = $(plugins.customToggle[i]); $this.on('click', $.proxy(function (event) { event.preventDefault(); let $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'); } }) } } } // Countdown if (plugins.countdown.length) { for (let i = 0; i < plugins.countdown.length; i++) { let node = plugins.countdown[i], countdown = aCountdown({ node: node, from: node.getAttribute('data-from'), to: node.getAttribute('data-to'), count: node.getAttribute('data-count'), tick: 100, }); } } // Accordion if (plugins.accordion.length) { for (let i = 0; i < plugins.accordion.length; i++) { let items = plugins.accordion[i].querySelectorAll( '.accordion-item' ), click = device.ios() ? 'touchstart' : 'click'; for (let i = 0; i < items.length; i++) { console.log( items[i], 'cp1' ); let item = items[i]; let tmpFunction = function ( item ) { let head = items[i].querySelector( '.accordion-head' ), body = items[i].querySelector( '.accordion-body' ); MultiSwitch({ node: head, targets: [ items[i], body ], isolate: plugins.accordion[i].querySelectorAll( '.accordion-head' ), state: items[i].classList.contains( 'active' ), event: click, }); if ( !body.multiSwitchTarget.groups.active.state ) body.style.display = 'none'; body.addEventListener( 'switch:active', function () { let $this = $( this ); if ( this.multiSwitchTarget.groups.active.state ) { $this.stop().slideDown( 300 ); } else { $this.stop().slideUp( 300 ); } }); } } /*items.forEach( function ( items ) { console.log( items ); let head = items.querySelector( '.accordion-head' ), body = items.querySelector( '.accordion-body' ); MultiSwitch({ node: head, targets: [ items, body ], isolate: plugins.accordion[i].querySelectorAll( '.accordion-head' ), state: items.classList.contains( 'active' ), event: click, }); if ( !body.multiSwitchTarget.groups.active.state ) body.style.display = 'none'; body.addEventListener( 'switch:active', function () { let $this = $( this ); if ( this.multiSwitchTarget.groups.active.state ) { $this.stop().slideDown( 300 ); } else { $this.stop().slideUp( 300 ); } }); });*/ } } // Select 2 if ( plugins.selectFilter.length ) { for ( var i = 0; i < plugins.selectFilter.length; i++ ) { var select = $( plugins.selectFilter[ i ] ); select.select2( { dropdownParent: $( '.page' ), theme: select.attr( 'data-theme' ) || 'default', 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 } ); } } /** * RD Range * @description Enables RD Range plugin */ if (plugins.rdRange.length && !isNoviBuilder) { plugins.rdRange.RDRange({}); } /** * Slick carousel * @description Enable Slick carousel plugin */ 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'); initLightGalleryItem($('[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: true, arrows: $slickItem.attr("data-arrows") === "true", swipe: $slickItem.attr("data-swipe") === "true", autoplay: $slickItem.attr("data-autoplay") === "true", vertical: $slickItem.attr("data-vertical") === "true", centerMode: $slickItem.attr("data-center-mode") === "true", centerPadding: $slickItem.attr("data-center-padding") ? $slickItem.attr("data-center-padding") : '0.50', mobileFirst: true, responsive: [ { breakpoint: 0, settings: { slidesToShow: parseInt($slickItem.attr('data-items'), 10) || 1 } }, { breakpoint: 575, settings: { slidesToShow: parseInt($slickItem.attr('data-sm-items'), 10) || 1 } }, { breakpoint: 767, settings: { slidesToShow: parseInt($slickItem.attr('data-md-items'), 10) || 1 } }, { breakpoint: 991, settings: { slidesToShow: parseInt($slickItem.attr('data-lg-items'), 10) || 1 } }, { breakpoint: 1199, settings: { slidesToShow: parseInt($slickItem.attr('data-xl-items'), 10) || 1 } } ] }) .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 * @description Enables Stepper Plugin */ if (plugins.stepper.length) { let steppered = plugins.stepper.stepper({ labels: { up: "", down: "" } }); } /** * RD Calendar * @description Enables RD Calendar plugin */ if (plugins.calendar.length) { var i; for (i = 0; i < plugins.calendar.length; i++) { var calendarItem = $(plugins.calendar[i]); calendarItem.rdCalendar({ days: calendarItem.attr("data-days") ? calendarItem.attr("data-days").split(/\s?,\s?/i) : ['S', 'M', 'T', 'W', 'T', 'F', 'S'], months: calendarItem.attr("data-months") ? calendarItem.attr("data-months").split(/\s?,\s?/i) : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] }); if (calendarItem.data('events-inline') === 'true') { calendarItem.on('rdc.refresh', function () { initRowEvents($('.rdc-table_has-events')); }); initRowEvents($('.rdc-table_has-events')); } } $window.on('resize', function () { var eventToResize = $('.rdc-calendar-event-panel'); if (eventToResize.length) { var eventInnerRow = eventToResize.find('.event-panel'), ch = eventToResize.find('.rdc-table_events').outerHeight(); eventInnerRow.css({ height: ch + 'px' }); } }); } // Multitoggles if(plugins.multitoggle.length) { multitoggles(); } // Vide bg for ( let i = 0; i < plugins.vide.length; i++ ) { let $element = $(plugins.vide[i]), options = $element.data('vide-options'), path = $element.data('vide-bg'); if ( !isMobile ) { $element.vide( path, options ); let videObj = $element.data('vide').getVideoObject(), scrollHandler = (function( $element ) { if ( isScrolledIntoView( $element ) ) this.play(); else this.pause(); }).bind( videObj, $element ); scrollHandler(); if ( isNoviBuilder ) videObj.pause(); else document.addEventListener( 'scroll', scrollHandler ); } else { $element.css({ 'background-image': 'url('+ path +'.jpg)' }); } } /** * Custom Waypoints */ if (plugins.customWaypoints.length && !isNoviBuilder) { var i; for (i = 0; i < plugins.customWaypoints.length; i++) { var $this = $(plugins.customWaypoints[i]); $this.on('click', function (e) { e.preventDefault(); $("body, html").stop().animate({ scrollTop: $("#" + $(this).attr('data-custom-scroll-to')).offset().top }, 1000, function () { $window.trigger("resize"); }); }); } } }); }());
Liking