'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 target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top - 80 }, 850); return false; } }); $('.article-nav-collapse-trigger').on('click', function () { $('.article-nav').toggleClass('is-open'); }); $('.scroll-link').on('click', function () { if (win_width() < 1024) { $('.article-nav').removeClass('is-open'); } }); // 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); } }); } }); } (function ($) { // Initial controller variable var controller = void 0; // Controllers for desktop or mobile depending on window size // Desktop if (window.innerWidth >= 1024) { controller = new ScrollMagic.Controller(); initScenes(controller); // Run scenes } // Mobile else { controller = new ScrollMagic.Controller(); } //******************************************** // Init Scenes function initScenes(cntrl) { var parent_container = $('.article-container'), section_container = $('.article-scroll-container'); // Saticky Nav $('.article-nav').each(function () { new ScrollMagic.Scene({ duration: parseInt(parent_container.outerHeight()), triggerElement: $(this)[0], reverse: true, triggerHook: 'onLeave' }).setPin('.article-nav').addTo(controller); }); } initScenes(controller); // Run scenes // RESIZE $(window).resize(function () { // Desktop if (window.innerWidth >= 1024) { // Controller controller.destroy(true); controller = new ScrollMagic.Controller(); initScenes(controller); // Run scenes } // Mobile else { controller.enabled(false); } }); // Change nav class on scroll $(window).scroll(function () { var y = $(this).scrollTop(); $('.scroll-link').each(function (event) { if (y >= $($(this).attr('href')).offset().top - 120) { $('.scroll-link').not(this).parent().removeClass('is-active'); $(this).parent().addClass('is-active'); } }); }); })(jQuery); 'use strict'; //******************************************** // Return Window Width function win_width() { return $(window).width(); } //******************************************** // Return Window Height function win_height() { return $(window).outerHeight(); } $(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 }); /** * Default closing modal */ $('.close-popup').each(function () { $(this).on('click', function () { $(this).parent().hide(); }); }); /** * Match height added to class equal-height */ $('.equal-height').matchHeight(); /** * Animations */ customAnimations(); /** * Grid Accordion */ $('.grid-accordion-title').on('click', function () { $(this).parents('.grid-accordion').toggleClass('is-open').find('.grid-accordion-content').slideToggle('fast'); }); // simluate scroll to article (for share links) var url = window.location.href; var tmp = url.split('?'); if (tmp.length > 1) { var tmpShare = tmp[1].split('&'); var tmpShareFirstKeyValue = tmpShare[0]; var tmpShareFirstValue = tmpShareFirstKeyValue.split('='); var tmpShareFirstValue = tmpShareFirstValue[1]; //console.log(tmpShareFirstValue); //var target = $('#'+tmp[1]); var target = $('#' + tmpShareFirstValue); if (target.length > 0) { $('html,body').animate({ scrollTop: target.offset().top - 80 }, 850); } } }); function hideShowDivFunction() { var x = document.getElementById("thank-you-send"); var y = document.getElementById("subscription-form"); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } if (y.style.display === "none") { y.style.display = "block"; } else { y.style.display = "none"; } } '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(); // }); // console.log("test"); // console.log($('#article-content-zakaj-lin .share_title')); specto_sharer.init({ //ICONS icons_wrapp: ".body-social-shares", //css selector for icons wrapper, or html element pointer //if html is generated by plugin, icon must be single class css selector. Otherwise it can be string or function, which translates to any css selector (!string!) //CONTENT content_wrapp_id: ".body-share", //id of content wrapper - valid only if not present in href atttribute or html is rendered by plugin elm_caption: ".share_caption", //css selector for caption / twitter title elm_title: function elm_title(icn_wrapper, share_type) { if (share_type == 'email') { return '.email .share_title'; } else if (share_type == 'facebook') { return '.fb .share_title'; } else if (share_type == 'twitter') { return '.tw .share_title'; } else if (share_type == 'linkedin') { return '.lin .share_title'; } }, elm_description: function elm_description(icn_wrapper, share_type) { if (share_type == 'email') { return '.email .share_description'; } else if (share_type == 'facebook') { return '.fb .share_description'; } else if (share_type == 'twitter') { return '.tw .share_description'; } else if (share_type == 'linkedin') { return '.lin .share_description'; } }, elm_image: function elm_image(icn_wrapper, share_type) { if (share_type == 'email') { return '.email .share_image'; } else if (share_type == 'facebook') { return '.fb .share_image'; } else if (share_type == 'twitter') { return '.tw .share_image'; } else if (share_type == 'linkedin') { return '.lin .share_image'; } }, elm_url_ref: function elm_url_ref(icn_wrapper, share_type) { if (share_type == 'email') { return '.email .share_url'; } else if (share_type == 'facebook') { return '.fb .share_url'; } else if (share_type == 'twitter') { return '.tw .share_url'; } else if (share_type == 'linkedin') { return '.lin .share_url'; } }, // elm_url_ref_attr: function(icn_wrapper, share_type){ // // // if(share_type == 'facebook'){ // return 'href'; // // // // } // // }, //POPUP //FB settings appId: "123550735015428", //Facebook appId //appId: "289919764980611", //za testno domeno test.p-m.si //appId: "123550735015428", //Facebook appId version: "v2.10", //Facebook app version new_version: true, //Facebook app is new version has_fb: true //has facebook sharer (to async load fb sdk) -> by default is false //debug: true, //write all sharers and their data to console }); }); 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); // $(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(); console.log(getId, product_name); 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; var userAgent = navigator.userAgent || navigator.vendor || window.opera; // 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' || /windows phone/i.test(userAgent) || /android/i.test(userAgent) || /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) 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() { $('.sc-general.sc-newsletter .mod-newsletter button.btn').click(function(event) { $("#nl-response").text(""); event.preventDefault(); if($(".mod-newsletter form").valid()) { var d=new Date(); var datum=""+d.getDate()+"."+(d.getMonth()+1)+"."+d.getFullYear()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds(); var datum2=new Date().toISOString().substr(0, 19); $.post("https://gpw.eglasnik.si/i/submit_contact_v1-1.php", { ml_code: "8Ugpx0fUB0I%3D", sec_code: "qtx5156agh", confirmation: 0, lang: 'SLO', api_mode: 'RESTFUL', contacteml: $('.mod-newsletter form input[name="email"]').val(), sourceuser: datum2 + ";" + window.location, category: "qoAt7Xwpwz0%3D", a01: "", //ip a02: datum, a03: "Prejemanje e-novic - "+$('.mod-newsletter form input[name="personal-newsletter"]').is(":checked"), a04: "Poosebljeno obveščanje - "+$('.mod-newsletter form input[name="personal-newsletter-offer"]').is(":checked") }, function(data) { if (data == 'ok') { ga('send', 'event', 'sucessfully_subscribed_zalovanje_newsletter', 'ajax_call'); hideShowDivFunction(); } else { $("#nl-response").text("Ste že prijavljeni."); } }); } }); $('.mod-newsletter form').validate({ rules: { email: { required: true, email: true }, age: 'required', personal_newsletter: 'required' }, messages: { email: { required: "Obvezno polje.", email: "Elektronska pošta ni v pravilnem formatu!" }, age: 'Za oddajo naročilo na e-novice potrebujete privolitev staršev ali skrbnikov.', personal_newsletter: "Brez vaše privolitve vas ne moremo vključiti med prejemnike e-novic." }, errorPlacement: function(error, element) { if (element.attr("name") == "personal_newsletter") { error.insertAfter('label[for="personal-newsletter"]'); } else if (element.attr("name") == "age") { error.insertAfter('label[for="age"]'); } else { error.insertAfter(element); } } }); });