692 lines
30 KiB
JavaScript
Raw Normal View History

2020-08-14 13:36:36 +02:00
/**
* @file
* A JavaScript file for the theme.
*
* In order for this JavaScript to be loaded on pages, see the instructions in
* the README.txt next to this file.
*/
// JavaScript should be made compatible with libraries other than jQuery by
// wrapping it with an "anonymous closure". See:
// - https://drupal.org/node/1446420
// - http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth
(function ($, Drupal, window, document) {
'use strict';
// To understand behaviors, see https://drupal.org/node/756722#behaviors
Drupal.behaviors.my_custom_behavior = {
attach: function (context, settings) {
var adminMenu = '';
if (jQuery('#admin-menu').length > 0) {
adminMenu = 'fixed-admin';
}
jQuery(document).ready(function () {
// Odpremo drop down menu za uporabnika
jQuery('#submenu-login').on('click', function () {
jQuery('#user-menu').toggle();
});
// JEZIK pustimo samo 3 črke
var jezikText = jQuery('.language-link').text().substring(0,4);
jQuery('.language-link').text(jezikText);
// Iskalnik v navbaru
// Zapremo iskalnik
jQuery(document).on('click', '.search-close', function () {jQuery('#iskanje').show();
jQuery('#iskanje-form').hide();
});
//Odpremo iskalnik
jQuery('#iskanje').on('click', function () {
jQuery('#iskanje-form').show();
jQuery('#iskanje').hide();
});
// Preusmerimo na url za iskanje, ko uporabnik pritisne enter
jQuery('#iskanje-input').on('keyup', function(event){
if (event.keyCode == 13) {
var iskaniNiz = jQuery('#iskanje-input').val();
var action = jQuery('#iskanje-form').attr('data-action');
window.location.href = action + iskaniNiz;
}
});
// if (window.location.pathname.indexOf('/iskanje/') > -1) {
// jQuery('.container-sidenav h1').hide();
// }
// END Iskalnik
/**
* Napredno iskanje
*/
// var drupalLang = 'sl';
// var drupalButtonName = 'Iskanje po vprašalnikih';
// if(location.pathname.split("/")[2] == 'en') {
// drupalLang = 'en';
// drupalButtonName = 'Search surveys';
// }
// Dodamo Gumb za napredno iskanje
if (jQuery('#search-api-page-search-form').length > 0) {
// Če je uporabnik prijavljen dodamo opcijo iskanja po mojih anketah
var piskotek = "; " + document.cookie;
if(piskotek.split("; unam=").length == 2) {
jQuery('#search-api-page-search-form [type="submit"]').after('<div id="prikazi-advance-search" class="povezava"><a href="/admin/survey/index.php?search=' + jQuery('#edit-keys-1').val() + '&lang='+drupalLang+'" id="prikazi-moje-ankete" class="povezava">'+drupalButtonName+'</a></div>');
}
}
jQuery('#edit-keys').bind('keyup', function(){
jQuery('#prikazi-moje-ankete').attr('href', '/admin/survey/index.php?search='+jQuery(this).val()+'&lang='+drupalLang);
});
// Skrijemo napredno iskanje
jQuery(document).on('click', '#prikazi-advance-search', function () {
if(jQuery('.sprites').hasClass('plus')) {
jQuery('.sprites').removeClass('plus').addClass('minus');
} else {
jQuery('.sprites').removeClass('minus').addClass('plus');
}
jQuery('fieldset#edit-advanced').toggle();
});
/*** end napredno iskanje ***/
/**
* Quicktabs
*/
// Quick tabs dodamo ikone
jQuery('#quicktabs-tab-tabs_faq_priporocila_video_slo-0, #quicktabs-tab-tabs_faq_manuals_video_eng-0').addClass('tab-povezava').prepend('<div class="ikona-tab ikona-faq"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" version="1.1" fill="#1e88e5" width="50px" height="50px">' +
'<g id="surface1" fill="#1e88e5">' +
'<path style=" " d="M 22 0 C 19.757813 0 18 1.757813 18 4 L 18 20 C 18 22.242188 19.757813 24 22 24 L 37.625 24 L 45.34375 30.75 C 45.527344 30.910156 45.761719 31 46 31 C 46.140625 31 46.273438 30.96875 46.40625 30.90625 C 46.765625 30.746094 47 30.394531 47 30 L 47 23.875 C 48.742188 23.441406 50 21.898438 50 20 L 50 4 C 50 1.757813 48.242188 0 46 0 Z M 33 6.09375 L 35.09375 6.09375 L 37.5 17.59375 L 35.6875 17.59375 L 35.09375 14.59375 L 32.90625 14.59375 L 32.3125 17.59375 L 30.5 17.59375 Z M 34 8 C 33.898438 8.800781 33.695313 9.894531 33.59375 10.59375 L 33.09375 13.1875 L 35 13.1875 L 34.5 10.59375 C 34.300781 9.894531 34.195313 8.800781 34.09375 8 Z M 4 19 C 1.757813 19 0 20.757813 0 23 L 0 39 C 0 40.894531 1.257813 42.441406 3 42.875 L 3 49 C 3 49.394531 3.234375 49.746094 3.59375 49.90625 C 3.726563 49.96875 3.859375 50 4 50 C 4.238281 50 4.46875 49.910156 4.65625 49.75 L 12.375 43 L 28 43 C 30.242188 43 32 41.242188 32 39 L 32 26 L 22 26 C 18.636719 26 16 23.363281 16 20 L 16 19 Z M 15.59375 25 C 17.992188 25 18.90625 27.585938 18.90625 30.6875 C 18.90625 33.6875 18.195313 35.398438 17.09375 36 L 17.09375 36.09375 C 17.792969 36.394531 18.613281 36.707031 19.3125 36.90625 L 18.6875 38.3125 C 17.789063 37.914063 16.605469 37.304688 15.90625 36.90625 C 15.707031 36.804688 15.507813 36.6875 15.40625 36.6875 C 13.304688 36.6875 12 34.710938 12 30.8125 C 12 27.414063 13.292969 25 15.59375 25 Z M 15.5 26.5 C 14.300781 26.5 13.90625 28.585938 13.90625 30.6875 C 13.90625 33.085938 14.300781 35.09375 15.5 35.09375 C 16.601563 35.09375 17 33.085938 17 30.6875 C 17 28.488281 16.601563 26.5 15.5 26.5 Z " fill="#1e88e5"/>' +
'</g>' +
'</svg></div>');
jQuery('#quicktabs-tab-tabs_faq_priporocila_video_slo-1, #quicktabs-tab-tabs_faq_manuals_video_eng-1').addClass('tab-povezava').prepend('<div class="ikona-tab ikona-prirocniki"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" version="1.1" fill="#1e88e5" width="50px" height="50px">' +
'<g id="surface1" fill="#1e88e5">' +
'<path style=" " d="M 6 2 C 5.449219 2 5 2.449219 5 3 L 5 39 C 5 39.554688 5.449219 40 6 40 C 18.058594 40 22.824219 42.683594 24 43.5 L 24 6.65625 C 21.53125 4.746094 16.21875 2 6 2 Z M 44 2 C 33.78125 2 28.46875 4.746094 26 6.65625 L 26 43.5 C 27.175781 42.683594 31.945313 40 44 40 C 44.554688 40 45 39.554688 45 39 L 45 3 C 45 2.449219 44.554688 2 44 2 Z M 2.84375 8 C 1.273438 8 0 9.273438 0 10.84375 L 0 44.15625 C 0 45.726563 1.273438 47 2.84375 47 L 19.46875 47 C 20.179688 47.980469 21.996094 50 25 50 C 28.003906 50 29.820313 47.980469 30.53125 47 L 47.15625 47 C 48.726563 47 50 45.730469 50 44.15625 L 50 10.84375 C 50 9.273438 48.726563 8 47.15625 8 L 47 8 L 47 39 C 47 40.652344 45.652344 42 44 42 C 32.25 42 27.878906 44.601563 27.125 45.125 L 27 45.25 C 26.304688 45.800781 25.984375 46.6875 25.03125 46.6875 C 24.078125 46.6875 23.917969 45.886719 23.09375 45.3125 L 22.875 45.125 C 22.121094 44.601563 17.757813 42 6 42 C 4.347656 42 3 40.652344 3 39 L 3 8 Z " fill="#1e88e5"/>' +
'</g>' +
'</svg></div>');
jQuery('#quicktabs-tab-tabs_faq_priporocila_video_slo-2, #quicktabs-tab-tabs_faq_manuals_video_eng-2').addClass('tab-povezava').prepend('<div class="ikona-tab ikona-video"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" version="1.1" fill="#1e88e5" width="50px" height="50px">' +
'<g id="surface1" fill="#1e88e5">' +
'<path style=" " d="M 12.8125 5 C 12.261719 5.050781 11.855469 5.542969 11.90625 6.09375 C 11.957031 6.644531 12.449219 7.050781 13 7 L 37 7 C 37.359375 7.003906 37.695313 6.816406 37.878906 6.503906 C 38.058594 6.191406 38.058594 5.808594 37.878906 5.496094 C 37.695313 5.183594 37.359375 4.996094 37 5 L 13 5 C 12.96875 5 12.9375 5 12.90625 5 C 12.875 5 12.84375 5 12.8125 5 Z M 7.8125 9 C 7.261719 9.050781 6.855469 9.542969 6.90625 10.09375 C 6.957031 10.644531 7.449219 11.050781 8 11 L 42 11 C 42.359375 11.003906 42.695313 10.816406 42.878906 10.503906 C 43.058594 10.191406 43.058594 9.808594 42.878906 9.496094 C 42.695313 9.183594 42.359375 8.996094 42 9 L 8 9 C 7.96875 9 7.9375 9 7.90625 9 C 7.875 9 7.84375 9 7.8125 9 Z M 3 13 C 2.445313 13 2 13.449219 2 14 L 2 44 C 2 44.550781 2.445313 45 3 45 L 47 45 C 47.554688 45 48 44.550781 48 44 L 48 14 C 48 13.449219 47.554688 13 47 13 Z M 20.1875 23 L 30.8125 29 L 20.1875 35 Z " fill="#1e88e5"/>' +
'</g>' +
'</svg></div>');
//Dodamo naslove za posamezne tabe
jQuery('[id^=quicktabs-tab-tabs_faq_priporocila_video_slo], [id^=quicktabs-tab-tabs_faq_manuals_video_eng]').each(function(){
var id = jQuery(this).attr('id').slice(14);
var ime = jQuery(this).text();
// Če je v imenu active tab potem to odstranimo v naslovu
var isci = ime.search('(active tab)');
if(isci > 0){
ime = ime.slice(0, (isci-1));
}
jQuery('#quicktabs-tabpage-'+id+' .item-list').prepend('<h3>'+ime+'</h3>');
});
// Quick tabs na angleški strani razširi 2 zavihka na 50%
if (jQuery('#quicktabs-tab-tabs_faq_manuals_video_eng-0').length) {
jQuery('.tabs-1ka ul.quicktabs-tabs > li').each(function () {
jQuery(this).addClass('width-50');
});
}
// Quicktabs odpremo ustreznega glede na izbran url
var urlPars = window.location.pathname.split('/');
if (urlPars[4] == 'prirocniki' || urlPars[4] == 'manuals') {
jQuery('.quicktabs-tabs li').removeClass('active');
jQuery('.quicktabs-tabs li:eq(1)').addClass('active');
jQuery('.quicktabs-tabpage').addClass('quicktabs-hide');
jQuery('.quicktabs-tabpage:eq(1)').removeClass('quicktabs-hide');
}
if (urlPars[4] == 'video') {
jQuery('.quicktabs-tabs li').removeClass('active');
jQuery('.quicktabs-tabs li:eq(2)').addClass('active');
jQuery('.quicktabs-tabpage').addClass('quicktabs-hide');
jQuery('.quicktabs-tabpage:eq(2)').removeClass('quicktabs-hide');
}
/*** end quictabs ***/
// POMOČ
// Skrij moje ankete
if(jQuery('.gumb1kazapri').length > 0) {
jQuery('.menu-630').hide();
jQuery('.menu-489').hide();
jQuery('.menu-952').hide();
}
// Nova 1ka
// Prijava modal
jQuery('#modal-open-login').on('click', function(){
jQuery('#modal-login').show();
});
//Registracija modal
jQuery('#modal-open-registration').on('click', function(){
jQuery('#modal-registration').show();
});
jQuery('.closemodal').on('click', function(){
jQuery('.rexister-modal').hide();
jQuery('.w-input').val('');
jQuery('.w-checkbox-input').prop('checked', false);
});
// Če gr za napako pri loginu
if (window.location.search.indexOf('?a=login') > -1) {
jQuery('#modal-login').show();
jQuery('.w-form-fail').show();
}
jQuery('#gdpr-more').on('click', function(){
jQuery('#gdpr-vec-text').toggle();
});
jQuery('.checkbox-field .checkbox-display').on('click', function(){
var oznacen = true;
if(jQuery(this).siblings('input:checked').length > 0)
oznacen = false;
jQuery(this).siblings('input').prop('checked', oznacen);
});
// Forma za registracijo
jQuery('#registracija-uporabnika .submit-btn').on('click', function( event ) {
jQuery('.error-field').removeClass('error-field');
jQuery('.error').removeClass('error');
// Obravnamo manjkajoča polja
if(jQuery('#register-form [name="email"]').val().length < 2){
jQuery('#register-form [name="email"]').addClass('error error-field');
}
if(jQuery('#register-form [name="ime"]').val().length < 2){
jQuery('#register-form [name="ime"]').addClass('error error-field');
}
if(!jQuery('#register-form [name="agree"]').is(':checked')){
jQuery('#register-form [name="agree"]').addClass('error').siblings('#agreelabel, .checkbox-display').addClass('error');
}
if(jQuery('#register-form [name="email"]').val().length == 0 || jQuery('#register-form [name="ime"]').val().length == 0 || !jQuery('#register-form [name="agree"]').is(':checked')){
return false;
}
event.preventDefault();
var sendVariables = jQuery('#registracija-uporabnika').serialize();
sendVariables += '&ajax=1';
jQuery.post('/frontend/api/api.php?action=register', sendVariables, function(data){
var response = JSON.parse(data);
jQuery('.error-field').removeClass('error-field');
if(response.success && response.success == 1){
jQuery('#reg-confirm-email').text( jQuery('#register-form [name="email"]').val());
jQuery('#reg-confirm-ime').text(jQuery('#register-form [name="ime"]').val());
jQuery('#reg-confirm-geslo').text('****');
jQuery('#reg-confirm-gdpr').text('NE');
if(window.location.href.search('/d/en') > 0) {
if(jQuery('#GdprAgree').is(':checked')){
jQuery('#reg-confirm-gdpr').text('YES');
}else{
jQuery('#reg-confirm-gdpr').text('NO');
}
}else {
if(jQuery('#GdprAgree').is(':checked')){
jQuery('#reg-confirm-gdpr').text('DA');
}
}
if( jQuery('#register-form [name="geslo"]').val().length== 0){
jQuery('#reg-confirm-geslo').text('/');
}
jQuery('#register-form').hide();
jQuery('#register-form-confirm').show();
}else {
//Ponastavi reCaptcho
if(grecaptcha) {
grecaptcha.reset();
}
// Izpišemo napake
if(response.napaka && response.napaka.length > 0){
jQuery('.napaka-registracija').addClass('show');
var napake = '';
jQuery.each(response.napaka, function(key, val){
napake += '<div>'+val+'</div>';
});
jQuery('.napaka-registracija').html(napake);
}
if(response.error_email){
jQuery('#register-form [name="email"]').addClass('error-field');
}
if(response.error_ime){
jQuery('#register-form [name="ime"]').addClass('error-field');
}
if(response.error_geslo){
jQuery('#register-form [name="geslo"]').addClass('error-field');
jQuery('#register-form [name="geslo2"]').addClass('error-field');
}
}
});
});
// Pri potrditvi omogočimo gum nazaj
jQuery('#reg-confirm-back').on('click', function(){
jQuery('#register-form-confirm').hide();
jQuery('#register-form').show();
});
//Pošljemo potrditven email
jQuery('#reg-confirm-next').on('click', function(event){
event.preventDefault();
var sendVariables = jQuery('#registracija-uporabnika').serialize();
sendVariables += '&ajax=1';
jQuery.post('/frontend/api/api.php?action=register_confirm', sendVariables, function(data){
var response = JSON.parse(data);
if(response.success && response.success == 1){
var text = jQuery('#register-form-email-sent').html().replace("SFMAIL", jQuery('#reg-confirm-email').text());
jQuery('#register-form-email-sent').html(text);
jQuery('#reg-confirm-email').text('');
jQuery('#reg-confirm-ime').text('');
jQuery('#reg-confirm-geslo').text('');
jQuery('#reg-confirm-gdpr').text('');
// Počistimo formo
jQuery(':input','#register-form')
.not(':button, :submit')
.val('')
.removeAttr('checked');
jQuery('#register-form-confirm').hide();
jQuery('#register-form-email-sent').show();
}
});
});
// GUmbi na desni front
jQuery('#odpri-prijavo, .odpri-prijavo').on('click', function(){
jQuery('.rexister-modal').hide();
jQuery('#modal-login').show();
});
jQuery(document).on('click', "#odpri-registracijo", function () {
jQuery('.rexister-modal').hide();
jQuery('.w-form-fail').html('').hide();
jQuery('#modal-registration').show();
});
if(window.location.hash == '#neregistriran-uporabnik'){
jQuery('#spletna-uporaba-modal').show();
}
jQuery(document).on('click', '#gumb-spletna-uporaba, .gumb-spletna-uporaba', function(e){
e.preventDefault();
jQuery('#spletna-uporaba-modal').show();
});
jQuery('#gumb-lastna-namestitev').on('click', function(){
jQuery('#lastna-namestitev-modal').show();
});
// Izgubljeno geslo
jQuery('#open-modal-lost-password').on('click', function(){
jQuery('#modal-login').hide();
jQuery('#modal-lost-password').show();
});
jQuery('#submit-lost-password').on('click', function () {
jQuery('.w-form-fail').hide();
var emailObnovitev = jQuery('#obnovitev-gesla').val();
var jezik = jQuery('#modal-lost-password [name="jezik"]').val();
if (emailObnovitev.length == 0 || emailObnovitev.length > 1 && (emailObnovitev.search('@') == -1 || emailObnovitev.indexOf('.') == -1)) {
jQuery('#error-lost-password').show();
return false;
}
// V kolikor je vse ok poljemo POST request, da preverimo v bazi
jQuery.post('/frontend/api/api.php?action=reset_password', {
email: emailObnovitev,
ajax: true,
jezik: jezik
}).success(function (val) {
val = JSON.parse(val);
jQuery('#modal-lost-password .w-form-done').html('').hide();
jQuery('#modal-lost-password .w-form-fail').hide();
if (val.type == 'success') {
jQuery('#modal-lost-password .w-form-done').html('<div>'+val.text+'</div>').show();
// Če je bil email uspešno poslal potem okno zapremo po 5 sekundah
setTimeout(function () {
jQuery("#modal-lost-password").hide();
jQuery('#modal-lost-password .w-form-done').hide();
jQuery("#obnovitev-gesla").val('');
}, 2000);
} else {
// Napaka, če email ne obstaja v bazi
jQuery('#modal-lost-password .w-form-fail').html('<div>'+val.text+'</div>').show();
}
});
});
// AKtivacija izgubljenega gesla
if(window.location.hash == '#aktivacija-gesla'){
jQuery('#modal-lost-password-activate').show();
}
jQuery('#submit-lost-password-activation').on('click', function(){
jQuery('.w-form-fail').hide();
jQuery('.error').removeClass('error');
var email= jQuery('#aktivacija-email').val();
var geslo = jQuery('#aktivacija-geslo').val();
var koda = '';
var jezik = jQuery('#modal-lost-password [name="jezik"]').val();
var results = new RegExp('[\?&]code=([^&#]*)').exec(window.location.href);
if(results[1].length > 10)
koda = results[1];
if (email.length == 0 || geslo.length == 0 || koda.length == 0) {
jQuery('#error-aktivacija-gesla').show();
if(email.length == 0) {
jQuery('#aktivacija-email').addClass('error');
}
if(geslo.length == 0) {
jQuery('#aktivacija-geslo').addClass('error');
}
return false;
}
// V kolikor je vse ok poljemo POST request, da preverimo v bazi
jQuery.post('/frontend/api/api.php?action=reset_password_activate', {
email: email,
pass: geslo,
code: koda,
ajax: true,
lang: jezik
}).success(function (val) {
val = JSON.parse(val);
jQuery('#error-aktivacija-gesla').removeClass('w-form-fail').removeClass('w-form-done').html('').hide();
if (val.type == 'success') {
jQuery('#error-aktivacija-gesla').addClass('w-form-done').html('<div>'+val.text+'</div>').show();
// Če je bil email uspešno poslal potem okno zapremo po 5 sekundah
setTimeout(function () {
window.location.href = val.action;
}, 5000);
} else {
// Napaka, če email ne obstaja v bazi
jQuery('#error-aktivacija-gesla').addClass('w-form-fail').html('<div>'+val.text+'</div>').show();
}
});
});
//Prijava z ostalimi računi
jQuery('#agreelabel, #cutom-login-agree, .checkbox-agree').on('click', function(){
if(jQuery('#cutom-login-agree').is(':checked')){
jQuery('#custom-login-agree-submit').show();
} else{
jQuery('#custom-login-agree-submit').hide();
}
});
jQuery('.ikona-custom-login').on('click', function () {
var atribut = jQuery(this).attr('data-login');
jQuery('.rexister-modal').hide();
jQuery('#modal-other-login h3').hide();
jQuery('#cutom-login-agree').attr('checked', false);
// Če obstaja piškotek, potemgumb naprej prikažemo
if(document.cookie.indexOf('remember-me=') > 0) {
jQuery('#cutom-login-agree').attr('checked', true);
jQuery('#custom-login-agree-submit').show();
}
jQuery('#modal-other-login #login-'+atribut+'-title').show();
jQuery('#submit-other-login').attr('data-redirect', 'url-'+atribut);
jQuery('#modal-other-login').show();
});
jQuery('#modal-other-login #submit-other-login').on('click', function(){
var ikona = jQuery(this).attr('data-redirect');
var url = jQuery('[name="'+ikona+'"]').val();
//Preverimo, če gre za zapomni se me (remember)
if(jQuery('#custom-login-remember-me').attr('checked')){
var date = new Date(new Date().setFullYear(new Date().getFullYear() + 1));
document.cookie='remember-me=1; expires='+ date +'; path=/'
}
document.location.href = url;
});
/**end prijava z ostalimi računi **/
// Če uporabnik ni prijavljen potem moje ankete odprejo možnost za prijavo
if(jQuery('[href*="/admin/survey/index.php?lang="]').length > 0 || jQuery('[data-href*="/admin/survey/index.php?lang="]').length > 0){
// preverimo če obstaja piškot, da je uporabnik prijavljen
if(document.cookie.indexOf('unam=') > 0) {
var dataHref = jQuery('[data-href*="/admin/survey/index.php?lang="]');
if(dataHref.length > 0) {
dataHref.attr('href', dataHref.attr('data-href'));
jQuery('#gumb-spletna-uporaba').attr('href', dataHref.attr('data-href')).attr('id', '');
dataHref.attr('data-href', '');
}
var href= jQuery('[href*="/admin/survey/index.php?lang="]');
if(href.length > 0 && dataHref.length < 1) {
jQuery('#gumb-spletna-uporaba').attr('href', href.attr('href')).attr('id', '');
}
jQuery('[href*="/admin/survey/index.php?lang="]').removeClass('gumb-spletna-uporaba');
} else {
var href = jQuery('[href*="/admin/survey/index.php?lang="]');
if(href.length > 0) {
href.attr('data-href', href.attr('href')).attr('href', '#');
}
jQuery('[data-href*="/admin/survey/index.php?lang="]').addClass('gumb-spletna-uporaba');
}
}
// Meni za mobilnike
jQuery('.burger').on('click', function(){
jQuery('ul.nav-ul').show();
jQuery('ul.nav-ul').prepend('<img src="/d/sites/all/themes/nova1ka/img/ikone/zapri.svg" id="mobile-menu-close">');
if(jQuery('.nav-ul > li.active-trail').length > 0){
jQuery('.nav-ul > li.active-trail').append( jQuery('aside.nav-ul-2 .menu-level-2').html());
jQuery('.nav-ul > li.active-trail > .menu').addClass('nav-ul-2-mobile');
}
});
jQuery(document).on('click', '#mobile-menu-close', function(){
jQuery('ul.nav-ul').hide();
jQuery('.nav-ul-2-mobile').remove();
jQuery(this).remove();
});
});
}
};
})(jQuery, Drupal, this, this.document);
function CheckEmail(text) {
jQuery('#modal-registration .w-form-fail').html('').hide();
jQuery('.w-input').removeClass('error');
var text = text || 'Prosimo, popravite email';
var Email = jQuery('#register-form [name="email"]').val();
if (Email.length > 1 && (Email.search('@') == -1 || Email.indexOf('.') == -1)) {
jQuery('#modal-registration .w-form-fail').html('<div>'+text+'</div>').show();
jQuery('#modal-registration [type="email"]').addClass('error');
return false;
}
return true;
}
function InsertName() {
var Email = jQuery('#register-form [name="email"]').val();
var lokacija = Email.search ('@');
if (Email.search('@') == -1){
lokacija = Email.length;
}
var Ime = Email.substring (0, lokacija);
if (jQuery('#register-form [name="ime"]').val().length <2) {
jQuery('#register-form [name="ime"]').val(Ime);
}
}
function CheckEmailTypo(text) {
var email = jQuery('#register-form [name="email"]').val();
var domains = ['gmail.com', 'hotmail.com', 'guest.arnes.si', 'siol.net'];
var splitEmail = email.split('@');
for (var i = 0; i < domains.length; i++) {
var domain = domains[i];
if(preveriZaTipkarskoNapakoVemailu(splitEmail[1], domain)){
jQuery('#modal-registration .w-form-fail').html('<div>'+text+' <b>@'+domain+'</b>?</div>').show();
return jQuery('#modal-registration [type="email"]').addClass('error');
}
}
return '';
}
function preveriZaTipkarskoNapakoVemailu(uporabnikovaDomena, domena) {
// Domeni se ujemata
if (uporabnikovaDomena.includes(domena))
return false;
//Preverimo če vsebuje dve piki ali vejico
if(new RegExp('(\\.{2})|(\,)').test(uporabnikovaDomena) && uporabnikovaDomena.substring(0,3) == domena.substring(0,3)){
return true;
}
// domeno razbijemo, da preverimo napake za posamezne črke gm|ail
for (var i = 1; i < domena.length; i++) {
var prviDel = domena.substring(0, i);
var preostenekBesede = domena.substring(i);
// preverimo, če so črke napačne
if (new RegExp(prviDel + '.' + preostenekBesede.substring(1)).test(uporabnikovaDomena)) {
return true;
}
// preverimo, če je dodana črka preveč
if (new RegExp(prviDel + '.' + preostenekBesede).test(uporabnikovaDomena)) {
return true;
}
// majkajoča črka
if (preostenekBesede !== 'mail' && new RegExp('('+prviDel+'{0}' + preostenekBesede+')|('+domena+'{0})').test(uporabnikovaDomena)) {
return true;
}
if (domena == 'gmail.com' && new RegExp('gmail.si|gmail.net').test(uporabnikovaDomena) ||
domena == 'guest.arnes.si' && new RegExp('arnes.si').test(uporabnikovaDomena) ||
domena == 'siol.net' && new RegExp('siol.com').test(uporabnikovaDomena)) {
return true;
}
if (domena == 'hotmail.com' && new RegExp('hotmail.si').test(uporabnikovaDomena)) {
return true;
}
// test for switched letters
var switchedLetters = [
domena.substring(0, i - 1),
domena.charAt(i),
domena.charAt(i - 1),
domena.substring(i + 1)
].join('');
if (uporabnikovaDomena.includes(switchedLetters)) {
return true;
}
}
return false;
}
//Fro APP install banner
window.addEventListener('beforeinstallprompt', function(e){
var piskotek = "; " + document.cookie+";";
//if cookies are not accepted, dont show install banner (because install banner covers cookie banner)
if(piskotek.split("; cookie-agreed=2").length != 2) {
e.preventDefault();
}
});