'use strict'; function customAnimations() { // Scroll to id in url $(window).load(function () { if (window.location.hash != '') { $("html, body").stop(true, false).animate({ scrollTop: $(window.location.hash).offset().top - 80 }, 1000); history.pushState('', document.title, window.location.pathname); } // Scroll to id on click $('a[href*="#"]:not([href="#"]):not([data-toggle]):not([class*="share-"])').on('click', function (e) { var hrefTarget = $($(this).attr('href')); if (hrefTarget.length > 0) { $('html, body').stop(true, false).animate({ scrollTop: hrefTarget.offset().top - 80 }, 1000); } }); // Count animation numberCounter($(window).scrollTop() + $(window).height()); // Fade and slide animation $(window).scroll(function () { var scrol_position_bottom = $(this).scrollTop() + $(this).height(); $("[data-slidein]").each(function () { if ($(this).hasClass("slidein")) { if ($(this).offset().top <= scrol_position_bottom) $(this).removeClass("slidein"); } else { if ($(this).offset().top > scrol_position_bottom) $(this).addClass("slidein"); } }); //Section fadein effect $("[data-fadein]").each(function () { if ($(this).hasClass("fadein")) { if ($(this).offset().top <= scrol_position_bottom) $(this).removeClass("fadein"); } else { if ($(this).offset().top > scrol_position_bottom) $(this).addClass("fadein"); } }); // Count animation numberCounter(scrol_position_bottom); }); }); } function numberCounter(scrol_position_bottom) { $('.count').each(function () { if ($(this).offset().top + 50 <= scrol_position_bottom) { $(this).removeClass('count'); var endValue = $(this).data('count').toString(); var addPercent = ''; if (~endValue.indexOf("%")) { endValue = endValue.replace("%", ""); addPercent = ' %'; } $(this).prop('Counter', 0).animate({ Counter: $(this).data('count').toString() }, { duration: 2000, easing: 'swing', step: function step(now) { var num = Math.round(now).toString(); if (endValue % 1 != 0) { num = now.toFixed(1).toString(); } if (Number(num) > 999) { num = num.replace(".", ","); while (/(\d+)(\d{3})/.test(num)) { num = num.replace(/(\d+)(\d{3})/, '$1' + '.' + '$2'); } } else if (endValue % 1 != 0) { num = num.replace(".", ","); } $(this).text(num + addPercent); } }); } }); } 'use strict'; $(document).ready(function () { /** * Menu */ mainMenu(); menuHeightFix(); /** * RESIZE WATCH */ $(window).resize(function () { /** * Menu fix */ $('body').removeClass('noscroll'); menuHeightFix(); }); /** * Custom scroll bar */ $(".head-main-menu").mCustomScrollbar({ axis: "y", theme: "minimal-dark", autoExpandScrollbar: true }); /** * Illustration slick */ if ($('.illustrations-slick').length > 0) { illustrationSlider(); } /** * Default closing modal */ $('.close-popup').each(function () { $(this).on('click', function () { $(this).parent().hide(); }); }); /** * Match height added to class equal-height */ $('.equal-height').matchHeight(); /** * Form validatin */ //formValidation(); /** * Animations */ customAnimations(); /** * Youtube videos */ if ($('.yt-player').length > 0) playingVideoFont(); }); 'use strict'; function playingVideoFont() { var tag = document.createElement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstScriptTag = $('script[type="text/javascript"]').get(0); firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); } var player; function onYouTubeIframeAPIReady() { var videoId = $('#js-player').data('youtube-id'); player = new YT.Player('js-player', { height: '390', width: '640', videoId: videoId, controls: 0, modestbranding: 1, rel: 0, showinfo: 0, playerVars: { rel: 0 }, events: { 'onReady': onPlayerReady, 'onStateChange': onPlayerReady } }); } function onPlayerReady(event) { event.target.playVideo(); event.target.mute(); event.target.setLoop(); } 'use strict'; function formValidation() { // Update all inputs on change $('form input[type="email"]').on('change', function () { $('form input[type="email"]').not($(this)).val($(this).val()); }); // Validation $.validator.setDefaults({ ignore: [] // DON'T IGNORE PLUGIN HIDDEN SELECTS, CHECKBOXES AND RADIOS!!! }); $.each($('form'), function () { $(this).validate({ rules: { agreement: { required: true }, email: { required: true, email: true } }, showErrors: function showErrors(errorMap, errorList) { $.each(errorList, function (k, v) { $(v['element']).closest('form').find('input').removeClass('errorMessage'); $(v['element']).addClass('errorMessage'); }); }, submitHandler: function submitHandler(form) { $(form).closest('.container').addClass('thank-you-note'); var getDownload = $(form).attr('data-download-file'); if (getDownload.indexOf('.pdf') > -1) { var donloadHtml = ''; $(form).append(donloadHtml); $(form).find('a.trigger-click').get(0).click(); $(form).find('a.trigger-click').remove(); } else {} // If needed for form which doesn't have pdf download // window.open($(form).attr('action'), '_blank'); // SUBMIT FORM USE ACTION IN inc_subscription.php // form.submit(); } }); }); } 'use strict'; function illustrationSlider() { var illustrationSlick = $('.illustration-slick-slider'); var illustrationPagination = $('.illustrations-legend-pagination'); illustrationSlick.slick({ slidesToShow: 1, slidesToScroll: 1, arrows: false }).on("beforeChange", function (e, slick, currentSlide, nextSlide) { // Pagination illustrationPagination.find('[data-slick-index="' + currentSlide + '"]').removeClass('active'); illustrationPagination.find('[data-slick-index="' + nextSlide + '"]').addClass('active'); }); illustrationPagination.find('[data-slick-index]').on('click', function (e) { e.preventDefault(); var goToSlide = $(this).attr('data-slick-index'); illustrationSlick.slick('slickGoTo', parseInt(goToSlide)); }); var illustrationIcons = $('.illustration-icons'); if (illustrationIcons.length > 0) { illustrationIcons.on('click', function () { var popupId = $(this).attr('data-icon-popup-id'); $('.illustration-icons-popup:not(#icon-popup-' + popupId + ')').hide(); illustrationIcons.not($(this)).removeClass('active'); if ($(this).hasClass('active')) { $(this).removeClass('active'); $(this).parent().find('.icon-popup-' + popupId).hide(); } else { $(this).addClass('active'); $(this).parent().find('.icon-popup-' + popupId).show(); } }); $('.close-popup, .illustrations-slick-slide-wrap > img').on('click', function () { $('.illustration-icons-popup').hide(); illustrationIcons.removeClass('active'); }); } } 'use strict'; function mainMenu() { $(".openmenu").each(function () { $(this).on('click', function () { if ($('.head-menu-wrap, #nav-icon').hasClass('open')) { $('.head-menu-wrap, #nav-icon').stop(true, true).removeClass('open', 500, 'linear'); if ($(window).width() < 920) { $('body').removeClass('noscroll'); } } else { $('.head-menu-wrap, #nav-icon').stop(true, true).addClass('open', 500, 'linear'); if ($(window).width() < 920) { $('body').addClass('noscroll'); $('.head-menu-wrap nav ul li a').on('click', function () { $('.head-menu-wrap, #nav-icon').stop(true, true).removeClass('open', 500, 'linear'); $('body').removeClass('noscroll'); }); } } }); }); } function menuHeightFix() { var docHeight = 0; if ($(window).width() > 1100) { docHeight = $(window).height() - 100; $('.head-main-menu').css('height', docHeight + 'px'); } else if ($(window).width() <= 1100 && $(window).width() > 645) { docHeight = $(window).height() - 150; $('.head-main-menu').css('height', docHeight + 'px'); } else { docHeight = $(window).height() - 120; $('.head-main-menu').css('height', docHeight + 'px'); } } 'use strict'; /** * Start of CUSTOM SOCIAL LINKS */ var pathname; var product_name; var description; var share_image; var share_capt; var share_url; $(document).ready(function () { window.fbAsyncInit = function () { FB.init({ appId: '123550735015428', cookie: true, xfbml: true, version: 'v2.10' }); }; (function (d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) { return; } js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); })(document, 'script', 'facebook-jssdk'); $(window).load(function () { sharer(); }); }); function sharer() { $('.body-share-click-only a.share-mail, .body-share-click-only a.share-lin, .body-share-click-only a.share-tw, .body-share-click-only a.share-fb').each(function () { var clId = $(document).find('.body-share').closest('[id]').attr('id'); if (clId != undefined && clId != '') { $(this).attr('href', '#' + clId); } }); $('.body-share a.share-lin, .body-share-click-only a.share-lin').each(function () { if ($(this).attr("href") != undefined && $(this).attr("href") != '' && $(this).attr("href") != '#') { getIdData($(this).attr("href").indexOf('http://') >= 0 || $(this).attr("href").indexOf('https://') >= 0 ? '#' + $(this).closest('.body-share').closest('[id]').attr('id') : $(this).attr("href")); var encoded = encodeURIComponent(product_name); var encoded2 = encodeURIComponent(description); var encoded3 = encodeURIComponent(share_url); var encoded4 = encodeURIComponent(share_image); $(this).attr("href", "http://www.linkedin.com/shareArticle?mini=true&url=" + encoded3 + "&title=" + encoded + (encoded2 != undefined ? "&summary=" + encoded2 : '') + "&source=" + pathname + window.location.pathname + (encoded4 != undefined ? "&image=" + encoded4 : '')); } }); $('.body-share a.share-mail, .body-share-click-only a.share-mail').each(function () { if ($(this).attr("href") != undefined && $(this).attr("href") != '' && $(this).attr("href") != '#') { getIdData($(this).attr("href").indexOf('mailto:') >= 0 ? '#' + $(this).closest('.body-share').closest('[id]').attr('id') : $(this).attr("href")); $(this).attr("href", "mailto:?subject=" + product_name + "&body=" + description + " - " + encodeURIComponent(share_url)); } }); $('.body-share a.share-tw, .body-share-click-only a.share-tw').each(function () { if ($(this).attr("href") != undefined && $(this).attr("href") != '' && $(this).attr("href") != '#') { getIdData($(this).attr("href").indexOf('http://') >= 0 || $(this).attr("href").indexOf('https://') >= 0 ? '#' + $(this).closest('.body-share').closest('[id]').attr('id') : $(this).attr("href")); var encoded = encodeURIComponent(share_capt + ' - ' + share_url); $(this).attr("href", "https://twitter.com/intent/tweet?text=" + encoded); } }); $('.body-share a.share-fb, .body-share-click-only a.share-fb').each(function () { if ($(this).attr("href") != undefined && $(this).attr("href") != '' && $(this).attr("href") != '#') { $(this).on('click', function (e) { e.preventDefault(); FBShareOp($(this).attr("href").indexOf('http://') >= 0 || $(this).attr("href").indexOf('https://') >= 0 ? '#' + $(this).closest('.body-share').closest('[id]').attr('id') : $(this).attr("href")); }); } }); function FBShareOp(getId) { getIdData(getId); // FB.ui({ // method: 'feed', // display: 'popup', // name: product_name, // link: share_url, // picture: share_image, // caption: share_capt, // description: description // // }); FB.ui({ method: 'share_open_graph', action_type: 'og.shares', action_properties: JSON.stringify({ object: { 'og:url': share_url, 'og:title': product_name, 'og:description': description, 'og:image': share_image } }) }); } clickShareEvent(); } // Function for getting data from class for-sharing function getIdData(getId) { pathname = window.location.protocol + '//' + window.location.host; product_name = $(getId + " .share_title").text(); description = $(getId + " .share_description").text(); share_image = $(getId + " .share_image").attr('src'); if (share_image != undefined && share_image.indexOf(pathname) < 0) share_image = window.location.protocol + '//' + window.location.host + '/' + share_image; share_capt = $(getId + " .share_caption").text(); share_url = $(getId + " .share_link").length ? $(getId + " .share_link").attr('href').match("^#") ? pathname + window.location.pathname + ($(getId + " .share_link").attr('href') != '#' ? $(getId + " .share_link").attr('href') : '') : $(getId + " .share_link").attr('href') : pathname + window.location.pathname + getId; } // Function for popup $(function ($) { $.fn.customerPopup = function (e, intWidth, intHeight, blnResize) { // Prevent default anchor event e.preventDefault(); // Set values for window intWidth = intWidth || '500'; intHeight = intHeight || '400'; var strResize = blnResize ? 'yes' : 'no'; var os = navigator.platform; // Set title and open popup with focus on it var strTitle = typeof this.attr('title') !== 'undefined' ? this.attr('title') : 'Social Share', strParam = 'width=' + intWidth + ',height=' + intHeight + ',resizable=' + strResize; if (os == 'Mac68K' || os == 'MacPPC' || os == 'MacIntel') window.open(this.attr('href'), '_blank');else window.open(this.attr('href'), strTitle, strParam).focus(); }; /* ================================================== */ // $(document).ready(function ($) { // clickShareEvent(); // }); }(jQuery)); function clickShareEvent() { $('.body-share a.share-lin, .body-share-click-only a.share-lin').on("click", function (e) { $(this).customerPopup(e); }); $('.body-share a.share-tw, .body-share-click-only a.share-tw').on("click", function (e) { $(this).customerPopup(e); }); } /** * End of CUSTOM SOCIAL LINKS */ $(document).ready(function() { var urlArr = window.location.pathname.split("/"); var pageName = urlArr[urlArr.length-1]; if (pageName != "pozari" && pageName.length != 0) { $("header nav li." + pageName).addClass("active"); $(".head-menu-wrap .head-main-menu ul." + pageName + " li").first().addClass("mobile-active"); } else { // root $("header nav li").first().addClass("active"); $(".head-menu-wrap .head-main-menu ul.ko-zagori li").first().addClass("mobile-active"); } });