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 ( ) {
2021-03-05 12:52:11 +01:00
// Odjava v Drupalu
jQuery ( '#poslji-odjavo' ) . on ( 'click' , function ( e ) {
console . log ( 'klik odjava' )
e . preventDefault ( ) ;
jQuery ( '[name="odjava"]' ) . submit ( ) ;
setTimeout ( function ( ) {
window . location = '/' ;
} , 500 ) ;
} ) ;
2020-08-14 13:36:36 +02:00
// 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 ( 'fast' ) ;
jQuery ( '#iskanje-form' ) . hide ( 'fast' ) ;
jQuery ( '.burger' ) . css ( 'z-index' , '' ) ;
} ) ;
//Odpremo iskalnik
jQuery ( '#iskanje' ) . on ( 'click' , function ( ) {
jQuery ( '#iskanje-form' ) . show ( 'fast' ) ;
jQuery ( '#iskanje' ) . hide ( 'fast' ) ;
jQuery ( '.burger' ) . css ( 'z-index' , '-99' ) ;
} ) ;
// 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
* /
2021-03-11 14:50:03 +01:00
var drupalLang = 'sl' ;
var drupalButtonName = 'Iskanje po vprašalnikih' ;
if ( location . pathname . split ( "/" ) [ 2 ] == 'en' ) {
drupalLang = 'en' ;
drupalButtonName = 'Search surveys' ;
}
2020-08-14 13:36:36 +02:00
// 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>' ) ;
} ) ;
// 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 ***/
2021-03-11 14:34:12 +01:00
/** gumb svetovanje **/
if ( urlPars [ 3 ] == 'pomoc' || urlPars [ 3 ] == 'iskanje' ) {
jQuery ( '.container h1' ) . append ( '<div class="w-clearfix gumb-svetovanje"><a href="#"><div class="ikona-svetovanje"><i class="fas fa-external-link-alt"></i></div><div class="besedilo">Individualno <br />svetovanje</div></a></div>' ) ;
}
jQuery ( document ) . on ( 'click' , '.gumb-svetovanje' , function ( ) {
jQuery ( '.rexister-modal' ) . hide ( ) ;
jQuery ( '#modal-individualno-svetovanje' ) . show ( ) ;
} ) ;
/** end gumb svetovanje **/
2020-08-14 13:36:36 +02:00
// 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
2021-01-14 16:28:53 +01:00
jQuery ( '#modal-open-1ka' ) . on ( 'click' , function ( ) {
jQuery ( '.rexister-modal' ) . hide ( ) ;
if ( jQuery ( this ) . hasClass ( 'modal-goto-registration' ) ) {
jQuery ( '#modal-registration' ) . show ( ) ;
} else {
jQuery ( '#modal-login' ) . show ( ) ;
}
} ) ;
2021-03-05 11:21:24 +01:00
jQuery ( '#modal-open-login, .odpri-login' ) . on ( 'click' , function ( ) {
2021-03-12 13:03:24 +01:00
document . cookie = "nakup=1;expires=Thu, 01 Jan 1970 00:00:01 GMT" ;
2021-03-05 11:21:24 +01:00
odpriAaiLoginObvestilo ( ) ;
2021-01-14 16:28:53 +01:00
} ) ;
2021-03-05 11:21:24 +01:00
jQuery ( '#modal-open-registration, .brezplacni-nakup-samo-registracija' ) . on ( 'click' , function ( ) {
2021-01-14 16:28:53 +01:00
jQuery ( '.modal-intro-title' ) . hide ( ) ;
jQuery ( '.modal-intro-registration-text' ) . show ( ) ;
jQuery ( '#modal-open-1ka' ) . removeClass ( 'modal-open-login-obrazec' ) . addClass ( 'modal-goto-registration' ) ;
2021-01-14 10:12:53 +01:00
jQuery ( '#modal-info-login' ) . show ( ) ;
} ) ;
jQuery ( '.modal-open-intro-obrazec' ) . on ( 'click' , function ( ) {
jQuery ( '.rexister-modal' ) . hide ( ) ;
jQuery ( '#modal-info-login' ) . show ( ) ;
} ) ;
// Prijava modal
jQuery ( '.modal-open-login-obrazec' ) . on ( 'click' , function ( ) {
jQuery ( '.rexister-modal' ) . hide ( ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '#modal-login' ) . show ( ) ;
} ) ;
//Registracija modal
2021-03-05 11:21:24 +01:00
jQuery ( '.modal-goto-registration, .brezplacni-nakup-samo-registracija-eng' ) . on ( 'click' , function ( ) {
2021-01-14 16:28:53 +01:00
jQuery ( '.rexister-modal' ) . hide ( ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '#modal-registration' ) . show ( ) ;
} ) ;
jQuery ( '.closemodal' ) . on ( 'click' , function ( ) {
jQuery ( '.rexister-modal' ) . hide ( ) ;
jQuery ( '.w-input' ) . val ( '' ) ;
jQuery ( '.w-checkbox-input' ) . prop ( 'checked' , false ) ;
//Odstranimo piskotek za nakup paketa in skrijemo tekst
document . cookie = "nakup=1;expires=Thu, 01 Jan 1970 00:00:01 GMT" ;
jQuery ( '.nakup-prijava' ) . hide ( ) ;
} ) ;
// Č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 ) ;
} ) ;
2020-12-21 11:10:47 +01:00
jQuery ( '.modal-telefonska-pomoc' ) . on ( 'click' , function ( ) {
jQuery ( '#modal-telefonska-pomoc' ) . show ( ) ;
} ) ;
2020-08-14 13:36:36 +02:00
// 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' ) ;
}
2021-07-09 13:34:04 +02:00
if ( jQuery ( '#register-form [name="email"]' ) . val ( ) . length == 0 ||
jQuery ( '#register-form [name="ime"]' ) . val ( ) . length == 0 ||
2021-07-12 00:33:17 +02:00
! jQuery ( '#register-form [name="agree"]' ) . is ( ':checked' )
2021-07-09 13:34:04 +02:00
) {
2020-08-14 13:36:36 +02:00
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 ( '.glavni-naslov' ) . hide ( ) ;
jQuery ( '#register-form-confirm' ) . show ( ) ;
} else {
// Izpišemo napake
if ( response . napaka && response . napaka . length > 0 ) {
jQuery ( '.napaka-registracija' ) . 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' ) ;
}
if ( response . new _username . length > 0 ) {
jQuery ( '#register-form #registracija-vzdevek' ) . val ( response . new _username ) ;
}
//Ponastavi reCaptcho
if ( grecaptcha ) {
grecaptcha . reset ( ) ;
}
}
} ) ;
} ) ;
// 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 ( ) ;
2021-03-05 11:21:24 +01:00
if ( jQuery ( '[name="lang"]' ) . val ( ) == 'sl' ) {
odpriAaiLoginObvestilo ( ) ;
} else {
jQuery ( '#spletna-uporaba-modal' ) . show ( ) ;
}
2020-08-14 13:36:36 +02:00
} ) ;
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
} ) . done ( 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
} ) . done ( 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 ( '#submit-other-login' ) . show ( ) ;
} else {
jQuery ( '#submit-other-login' ) . hide ( ) ;
}
} ) ;
jQuery ( '.prijava-ostale-nazaj' ) . on ( 'click' , function ( ) {
2020-12-01 16:04:07 +01:00
jQuery ( '#modal-other-login' ) . hide ( ) ;
jQuery ( '.rexister-modal' ) . hide ( ) ;
jQuery ( '#modal-login' ) . show ( ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '#modal-other-login h3' ) . show ( ) ;
} ) ;
jQuery ( '.ikona-custom-login' ) . on ( 'click' , function ( ) {
var atribut = jQuery ( this ) . attr ( 'data-login' ) ;
jQuery ( '#submit-other-login' ) . hide ( ) ;
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 ( '#submit-other-login' ) . show ( ) ;
}
if ( atribut == 'aai' ) {
2020-12-01 15:50:56 +01:00
return jQuery ( '#modal-aai-obvestilo' ) . show ( ) ;
2020-08-14 13:36:36 +02:00
}
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 ( ) {
if ( jQuery ( '.nav-container .navulwrap' ) . css ( 'display' ) == 'block' ) {
jQuery ( '.nav-container .navulwrap' ) . hide ( ) ;
jQuery ( this ) . css ( 'border-color' , '#979797' ) ;
jQuery ( '.div-block-13' ) . css ( 'background-color' , '#979797' ) ;
jQuery ( '.logolink' ) . css ( 'z-index' , '' ) ;
jQuery ( '.navwrapinner' ) . css ( 'position' , '' ) ;
} else {
jQuery ( '.nav-container .navulwrap' ) . show ( ) ;
jQuery ( '.nav-ul-2' ) . appendTo ( '.glavni-meni > li.active > a.active' ) . show ( ) ;
jQuery ( this ) . css ( 'border-color' , 'transparent' ) ;
jQuery ( '.div-block-13' ) . css ( 'background-color' , '#979797' ) ;
jQuery ( '.logolink' ) . css ( 'z-index' , '-9' ) ;
jQuery ( '.navwrapinner' ) . css ( 'position' , 'fixed' ) ;
}
// jQuery('ul.nav-ul').show();
// jQuery('ul.nav-ul').prepend('<img src="/d/sites/all/themes/pro1ka/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 ( '.nakup-brez-registracije' ) . on ( 'click' , function ( ) {
var paket = jQuery ( this ) . attr ( 'data-paket' ) ;
var cas = new Date ( ) ;
cas . setMinutes ( cas . getMinutes ( ) + 30 ) ;
document . cookie = "nakup=1; expires=" + cas + ";path=/" ;
document . cookie = "paket=" + paket + "; expires=" + cas + ";path=/" ;
2021-03-12 13:03:24 +01:00
odpriAaiLoginObvestilo ( ) ;
2020-08-14 13:36:36 +02:00
} ) ;
// Naročila
jQuery ( '.racun-na-podjetje' ) . on ( 'click' , function ( ) {
jQuery ( '.podatki-za-podjetje' ) . toggle ( ) ;
2020-11-27 14:20:39 +01:00
prikaziPoljeEracun ( ) ;
2020-08-14 13:36:36 +02:00
if ( jQuery ( '#racun-na-podjetje' ) . is ( ':checked' ) ) {
jQuery ( '.polje-za-podjetje' ) . attr ( 'required' , 'required' ) ;
} else {
jQuery ( '.polje-za-podjetje' ) . removeAttr ( 'required' ) ;
jQuery ( '.polje-za-podjetje' ) . val ( '' ) ;
jQuery ( '#zavezanec-za-ddv' ) . prop ( 'checked' , false ) ;
}
} ) ;
2021-03-18 12:17:04 +01:00
// Tuje bančno nakazilo
jQuery ( '#polje-drzava, [name="payment_method"]' ) . on ( 'change' , function ( ) {
if (
jQuery ( '[name="payment_method"]:checked' ) . val ( ) == 1 &&
jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) != 'Slovenija' &&
jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) != 'Slovenia'
) {
jQuery ( '.tuje-bancno-nakazilo' ) . show ( ) ;
jQuery ( '#tuje-bancno-nakazilo' ) . attr ( 'required' , 'required' ) ;
} else {
jQuery ( '#tuje-bancno-nakazilo' ) . removeAttr ( 'required' ) ;
jQuery ( '.tuje-bancno-nakazilo' ) . hide ( ) ;
}
} ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '#zavezanec-za-ddv, .checkbox-zavezanec-za-ddv, [name="podjetje_drzava"]' ) . on ( 'click' , function ( ) {
posodobiCenoPaketa ( ) ;
} ) ;
2020-09-24 13:24:16 +02:00
// V kolikor gre za e-račun
jQuery ( '[name="podjetje_eracun"]' ) . on ( 'click' , function ( ) {
if ( jQuery ( '[name="podjetje_eracun"]' ) . is ( ':checked' ) ) {
jQuery ( '.p-e-racun' ) . show ( ) ;
} else {
jQuery ( '.p-e-racun' ) . hide ( ) ;
}
} ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '#narocilo-paketa-podatki .naprej' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
jQuery ( '.error-field' ) . removeClass ( 'error-field' ) ;
jQuery ( '.error-color' ) . removeClass ( 'error-color' ) ;
if ( ! jQuery ( '[name="payment_method"]' ) . is ( ":checked" ) ) {
jQuery ( '[name="payment_method"]' ) . siblings ( ) . addClass ( 'error-field' ) ;
}
2020-08-21 13:46:35 +02:00
if ( ! jQuery ( '[name="trajanje"]' ) . is ( ":checked" ) ) {
jQuery ( '[name="trajanje"]' ) . siblings ( ) . addClass ( 'error-field' ) ;
}
2021-07-12 00:33:17 +02:00
1
2021-03-18 12:17:04 +01:00
if ( jQuery ( '#tuje-bancno-nakazilo[required]' ) . is ( ':visible' ) ) {
if ( ! jQuery ( '#tuje-bancno-nakazilo[required]' ) . is ( ':checked' ) ) {
jQuery ( '#tuje-bancno-nakazilo' ) . parent ( ) . addClass ( 'error-field error-color' ) ;
}
}
2021-07-12 00:33:17 +02:00
//Preverjanje polja država
if ( jQuery ( '[name="podjetje_drzava"]' ) . is ( ':visible' ) && ( jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) == '' || jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) == undefined || jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) . length < 2 ) ) {
2021-07-15 23:36:13 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , false ) ;
2021-07-12 00:33:17 +02:00
jQuery ( '[name="podjetje_drzava"]' ) . addClass ( 'error error-field' ) ;
}
2020-08-14 13:36:36 +02:00
// Dodamo opozorilov input polja in tudi sklop obarvamo rdeče
jQuery ( ':input[required]:visible' ) . each ( function ( ) {
if ( jQuery ( this ) . val ( ) == '' ) {
jQuery ( this ) . addClass ( 'error-field' ) ;
}
}
) ;
jQuery ( '.error-field' )
. parents ( '.accordion-toggle' )
. siblings ( '.accordion-head' )
. find ( '.accordion-title' )
. addClass ( 'error-color' ) ;
if ( jQuery ( '.error-field' ) . length > 0 ) {
return '' ;
}
2020-11-27 14:20:39 +01:00
//Pridobi API klic, če gre za davčnega zavezanca
2020-12-01 14:06:35 +01:00
jQuery ( '#predogled-nakupa-1ka .cena-z-ddv-text' ) . show ( ) ;
var skupnaCena = jQuery ( '#narocilo-paketa-podatki .cena-paketa' ) . text ( ) ;
2020-12-01 11:20:20 +01:00
jQuery . post ( '/d/nakupovanje-api/check_ddv' , {
2020-12-01 14:06:35 +01:00
cena : skupnaCena ,
2020-11-27 14:20:39 +01:00
podjetje _drzava : jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) ,
podjetje _davcna : jQuery ( '[name="podjetje_davcna"]' ) . val ( )
} ) . done ( function ( val ) {
val = JSON . parse ( val ) ;
2020-12-01 14:06:35 +01:00
if ( val . success && val . cena ) {
2020-11-27 14:20:39 +01:00
jQuery ( '#predogled-nakupa-1ka .cena-paketa' ) . text ( val . cena ) ;
2020-12-01 14:06:35 +01:00
2020-12-02 13:47:19 +01:00
if ( ! val . ddv ) {
2020-12-01 14:06:35 +01:00
jQuery ( '#predogled-nakupa-1ka .cena-z-ddv-text' ) . hide ( ) ;
}
2020-11-27 14:20:39 +01:00
}
} ) ;
2020-08-14 13:36:36 +02:00
// Pri trajanju je pomembno,da pravilno sklanjamo
var trajanje = jQuery ( '[name="trajanje"]:checked' ) . val ( ) ;
if ( trajanje == 12 ) {
trajanje += ' mesecev' ;
} else if ( trajanje == 3 ) {
trajanje += ' mesece' ;
} else {
trajanje += ' mesec' ;
}
jQuery ( '#forma-trajanje' ) . text ( trajanje ) ;
jQuery ( '#forma-email' ) . text ( jQuery ( '#f-email' ) . val ( ) ) ;
jQuery ( '#forma-ime' ) . text ( jQuery ( '#f-ime' ) . val ( ) ) ;
if ( jQuery ( '#f-telefon' ) . val ( ) . length > 0 ) {
jQuery ( '#forma-telefon' ) . text ( jQuery ( '#f-telefon' ) . val ( ) ) ;
jQuery ( '#col-forma-telefon' ) . show ( ) ;
}
2020-11-27 14:20:39 +01:00
jQuery ( '#forma-d-drzava' ) . text ( jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) ) ;
2020-08-14 13:36:36 +02:00
// Iz forme poberemo pdoatke o podjetju
if ( jQuery ( '#racun-na-podjetje' ) . is ( ':checked' ) ) {
jQuery ( '#forma-p-naziv' ) . text ( jQuery ( '[name="podjetje_ime"]' ) . val ( ) ) ;
jQuery ( '#forma-p-ddv' ) . text ( jQuery ( '[name="podjetje_davcna"]' ) . val ( ) ) ;
jQuery ( '#forma-d-naslov' ) . text ( jQuery ( '[name="podjetje_naslov"]' ) . val ( ) ) ;
jQuery ( '#forma-d-postna-st' ) . text ( jQuery ( '[name="podjetje_postna"]' ) . val ( ) ) ;
jQuery ( '#forma-d-posta-ime' ) . text ( jQuery ( '[name="podjetje_posta"]' ) . val ( ) ) ;
}
var placilo = "" ;
if ( jQuery ( '[name="lang"]' ) . val ( ) == 'sl' ) {
switch ( jQuery ( '[name="payment_method"]:checked' ) . val ( ) ) {
case "2" :
placilo = "Plačilo preko PayPal računa" ;
break ;
case "3" :
placilo = "Plačilo s kreditno kartico" ;
break ;
default :
placilo = "Plačilo po predračunu" ;
}
} else {
switch ( jQuery ( '[name="payment_method"]:checked' ) . val ( ) ) {
case "2" :
placilo = "Payment via PayPal account" ;
break ;
case "3" :
placilo = "Credit card payment" ;
break ;
default :
placilo = "Payment by pro forma invoice" ;
}
}
jQuery ( '#forma-nacin-placila' ) . text ( placilo ) ;
jQuery ( '#nakup-1ka' ) . hide ( ) ;
jQuery ( '#predogled-nakupa-1ka' ) . show ( ) ;
} ) ;
// Vremo se en korak prej pri izbiri naročila
jQuery ( '#nazaj-na-nakup-1ka' ) . on ( 'click' , function ( ) {
jQuery ( '#nakup-1ka' ) . show ( ) ;
jQuery ( '#predogled-nakupa-1ka' ) . hide ( ) ;
} ) ;
// Oddamo naročilo
jQuery ( '#oddaj-narocilo' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
oddajNarociloNaStreznik ( ) ;
} ) ;
jQuery ( '#button-placilo-po-predracunu' ) . on ( 'click' , function ( ) {
jQuery ( '.vrsta-placila' ) . hide ( ) ;
jQuery ( '.obvestila' ) . html ( 'Obdelujem . . .' ) ;
var narocilo = jQuery ( '#izbria-nacina-placila-1ka [name="narocilo_id"]' ) . val ( ) ;
} ) ;
// Uspešno oddan predračun ali plačilo preko spleta
if ( jQuery ( '.narocilo-1ka-pdf' ) . length > 0 ) {
if ( document . cookie . indexOf ( 'pdf=' ) < 1 ) {
return window . location . href = '/' ;
}
var piskotek = ";" + document . cookie ;
if ( piskotek . indexOf ( "; pdf=" ) > 0 ) {
// Pobrišemo vse nastavljene piškotke povezane z nakupom
document . cookie = "pdf=1;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/" ;
document . cookie = "vrsta_placila=0;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/" ;
document . cookie = "brezplacen_preklop=0;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/" ;
}
}
2020-10-29 06:58:42 +01:00
if (
( window . location . pathname . indexOf ( '/narocilo/paypal-cancel' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 ) ||
2020-10-29 07:03:30 +01:00
( window . location . pathname . indexOf ( '/paypal-purchase/cancel' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 )
2020-10-29 06:58:42 +01:00
) {
2020-10-23 15:24:40 +02:00
var parametri = window . location . search . substr ( 1 ) ;
2020-10-06 00:09:00 +02:00
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/cancel_narocilo_paypal' , parametri ) . done ( function ( val ) {
2020-08-14 13:36:36 +02:00
val = JSON . parse ( val ) ;
if ( val . error ) {
return jQuery ( '.procesiram-narocilo' ) . text ( val . error ) ;
}
2020-10-06 00:09:00 +02:00
} ) ;
}
2020-10-29 06:58:42 +01:00
if (
( window . location . href . indexOf ( '/narocilo/paypal?narocilo_id' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 ) ||
2020-10-29 07:03:30 +01:00
( window . location . href . indexOf ( '/paypal-purchase/success?narocilo_id' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 )
2020-10-29 06:58:42 +01:00
) {
2020-10-23 15:24:40 +02:00
var parametri = window . location . search . substr ( 1 ) ;
2020-08-14 13:36:36 +02:00
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/capture_narocilo_paypal' , parametri ) . done ( function ( val ) {
2020-10-06 00:09:00 +02:00
val = JSON . parse ( val ) ;
if ( val . error ) {
return jQuery ( '.procesiram-narocilo' ) . text ( val . error ) ;
2020-08-14 13:36:36 +02:00
}
} ) ;
}
2020-11-16 15:36:11 +01:00
//Stripe plačilo
if (
( window . location . pathname . indexOf ( '/narocilo/stripe-cancel' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 ) ||
( window . location . pathname . indexOf ( '/stripe-purchase/cancel' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 )
) {
var parametri = window . location . search . substr ( 1 ) ;
2020-11-17 12:44:53 +01:00
jQuery . post ( '/d/nakupovanje-api/stripe_checkout_cancel' , parametri ) . done ( function ( val ) {
2020-11-16 15:36:11 +01:00
val = JSON . parse ( val ) ;
if ( val . error ) {
return jQuery ( '.procesiram-narocilo' ) . text ( val . error ) ;
}
} ) ;
}
if (
( window . location . href . indexOf ( '/narocilo/stripe?narocilo_id' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 ) ||
( window . location . href . indexOf ( '/stripe-purchase/success?narocilo_id' ) > - 1 && location . search . split ( 'narocilo_id=' ) . length > 1 )
) {
var parametri = window . location . search . substr ( 1 ) ;
jQuery . post ( '/d/nakupovanje-api/stripe_checkout_success' , parametri ) . done ( function ( val ) {
val = JSON . parse ( val ) ;
if ( val . error ) {
return jQuery ( '.procesiram-narocilo' ) . text ( val . error ) ;
}
} ) ;
}
2020-08-14 13:36:36 +02:00
//Odpiranje funkcionalnosti pri paketih
jQuery ( '.accordion-head' ) . on ( 'click' , function ( ) {
jQuery ( this ) . toggleClass ( 'active' ) ;
jQuery ( this ) . siblings ( ) . toggleClass ( 'active' ) . removeStyle ( ) ;
} ) ;
jQuery ( '.razpri-zapri-vse' ) . on ( 'click' , function ( ) {
jQuery ( this ) . toggleClass ( 'active' ) ;
if ( jQuery ( this ) . hasClass ( 'active' ) ) {
jQuery ( '.accordion-head' ) . addClass ( 'active' ) ;
jQuery ( '.accordion-head' ) . siblings ( ) . addClass ( 'active' ) ;
} else {
jQuery ( '.accordion-head' ) . removeClass ( 'active' ) ;
jQuery ( '.accordion-head' ) . siblings ( ) . removeClass ( 'active' ) ;
}
} ) ;
// PRidobimo pakete
if ( window . location . pathname . indexOf ( 'zasebni-paketi' ) > - 1 || window . location . pathname . indexOf ( 'private-packages' ) > - 1 ) {
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/get_paketi' ) . done ( function ( val ) {
2020-08-14 13:36:36 +02:00
val = JSON . parse ( val ) ;
jQuery ( '[data-price="2"]' ) . text ( val . paketi [ 2 ] . price [ 12 ] . monthly ) ;
jQuery ( '[data-price="3"]' ) . text ( val . paketi [ 3 ] . price [ 12 ] . monthly ) ;
} ) ;
2020-11-05 14:37:55 +01:00
// jQuery.post('/frontend/payments/api.php?action=get_paketi').done(function (val) {
// val = JSON.parse(val);
//
// jQuery('[data-price="2"]').text(val.paketi[2].price[12].monthly);
// jQuery('[data-price="3"]').text(val.paketi[3].price[12].monthly);
// });
2020-08-14 13:36:36 +02:00
}
2020-10-23 14:41:59 +02:00
2020-10-29 07:07:16 +01:00
if ( window . location . pathname . indexOf ( 'izvedi-nakup' ) > - 1 || window . location . pathname . indexOf ( '/purchase/' ) > - 1 ) {
2020-08-14 13:36:36 +02:00
// Če uporabnik ni prijavljen
if ( document . cookie . indexOf ( 'unam=' ) < 1 ) {
return window . location . href = '/' ;
}
2020-08-27 14:35:03 +02:00
//Nastavimo prevzeto plačevanje s karticam
jQuery ( '[name="payment_method"][value="3"]' ) . prop ( 'checked' , true ) ;
2020-08-14 13:36:36 +02:00
posodobiCenoPaketa ( ) ;
2021-05-21 13:04:35 +02:00
// IP lokacija
jQuery . post ( '/d/nakupovanje-api/get_lokacija' ) . done ( function ( val ) {
2021-07-12 00:33:17 +02:00
2021-07-15 23:36:13 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , false ) ;
2021-05-21 13:04:35 +02:00
2021-07-09 13:44:15 +02:00
val = JSON . parse ( val ) ;
2021-05-21 13:04:35 +02:00
2021-07-09 13:44:15 +02:00
if ( val . drzava && val . drzava . length > 1 ) {
2021-07-12 01:53:35 +02:00
if ( val . drzava == 'Slovenia' && jQuery ( '[name="lang"]' ) . val ( ) == 'sl' ) {
val . drzava = "Slovenija" ;
}
2021-07-09 13:34:04 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . val ( val . drzava ) ;
2021-07-15 23:36:13 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , true ) ;
}
} ) ;
// Preverimo, če je že prej opravil nakup
jQuery . post ( '/d/nakupovanje-api/get_lokacija' ) . done ( function ( val ) {
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , false ) ;
val = JSON . parse ( val ) ;
if ( val . drzava && val . drzava . length > 1 ) {
if ( val . drzava == 'Slovenia' && jQuery ( '[name="lang"]' ) . val ( ) == 'sl' ) {
val . drzava = "Slovenija" ;
}
jQuery ( '#nakup-1ka #polje-drzava' ) . val ( val . drzava ) ;
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , true ) ;
2021-07-09 13:34:04 +02:00
}
2021-05-21 13:04:35 +02:00
} ) ;
2020-08-14 13:36:36 +02:00
}
jQuery ( '#nakup-1ka .izbira' ) . on ( 'change' , function ( ) {
posodobiCenoPaketa ( ) ;
} ) ;
2020-09-24 13:24:16 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . on ( 'change' , function ( ) {
2020-11-27 14:20:39 +01:00
prikaziPoljeEracun ( ) ;
2020-09-24 13:24:16 +02:00
} ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '[name="podjetje_davcna"]' ) . keyup ( function ( ) {
2021-07-15 23:36:13 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , true ) ;
2020-08-14 13:36:36 +02:00
var davcna = jQuery ( '[name="podjetje_davcna"]' ) . val ( ) . replace ( /\D/g , '' ) ; // samo številke
2021-05-21 13:04:35 +02:00
if ( davcna . length > 7 ) {
2021-07-15 23:36:13 +02:00
jQuery ( '#nakup-1ka #polje-drzava' ) . attr ( 'readonly' , false ) ;
2020-08-14 13:36:36 +02:00
// $("#obvestilceDavcna").val("Iščemo ime podjetja s to davčno številko ...");
// $.ajax({
// url: "https://www.go-tel.si/tecaji/poizvedba.php",
// type: "post",
// data: {
// davcna:davcna
// },
// headers: {
// "accept": "application/json",
// "Access-Control-Allow-Origin":"*"
// },
// success: function(response) {
// if(response!=undefined) {
// var rez=JSON.parse(response);
// return console.log(rez);
//
// // if(rez!=undefined) {
// // if(rez.naziv) {
// // $("#firma_naziv").val(rez.naziv);
// // $("#firma_naslov").val(rez.naslov);
// // $("#firma_postna").val(rez.posta);
// // $("#firma_posta").val(rez.kraj);
// // }
// // else
// // $("#obvestilceDavcna").html("V bazi ne najdemo podjetja s to davčno številko ... Podatke vnesite ročno.");
// // }
// // else
// // $("#obvestilceDavcna").html("V bazi ne najdemo podjetja s to davčno številko ... Podatke vnesite ročno.");
// }
// },
// error: function() {
// // pocistiPolja();
// }
// });
2021-05-21 13:04:35 +02:00
}
2020-08-14 13:36:36 +02:00
} ) ;
/ *
* Posredujemo podatke za poslovne uporabnike
* /
jQuery ( '#narocilo-poslovni-uporabniki .submit-btn' ) . on ( 'click' , function ( e ) {
e . preventDefault ( ) ;
jQuery ( '.error-field' ) . removeClass ( 'error-field' ) ;
jQuery ( '.error-color' ) . removeClass ( 'error-color' ) ;
if ( ! jQuery ( '[name="vrsta_domene"]' ) . is ( ":checked" ) ) {
jQuery ( '[name="vrsta_domene"]' ) . siblings ( 'span' ) . addClass ( 'error-color' ) ;
}
if ( ! jQuery ( '#strinjanje_s_pogoji' ) . is ( ":checked" ) ) {
jQuery ( '#strinjanje_s_pogoji' ) . siblings ( 'span' ) . addClass ( 'error-color' ) ;
}
// Dodamo opozorilov input polja in tudi sklop obarvamo rdeče
jQuery ( ':input[required]:visible' ) . each ( function ( ) {
if ( jQuery ( this ) . val ( ) == '' ) {
jQuery ( this ) . addClass ( 'error-field' ) ;
}
}
) ;
if ( jQuery ( '.error-field, .error-color' ) . length > 0 ) {
return '' ;
}
//Onemogočimo dvojno pošiljanje
var pocakaj = jQuery ( this ) . attr ( 'data-wait' ) ;
jQuery ( this ) . val ( pocakaj ) . attr ( 'disabled' , 'disabled' ) ;
var podatki = jQuery ( '#narocilo-poslovni-uporabniki' ) . serialize ( ) ;
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/send_poslovni_uporabniki' , podatki ) . done ( function ( val ) {
2020-08-14 13:36:36 +02:00
val = JSON . parse ( val ) ;
if ( val . success ) {
jQuery ( '#narocilo-poslovni-uporabniki' ) . hide ( ) ;
jQuery ( '#nakup-1ka-poslovni-uporabniki .uspesno-oddano-narocilo' ) . show ( ) ;
jQuery ( '.vsebina h1' ) . text ( 'Uspešno oddano naročilo' ) ;
}
} ) ;
2020-11-05 14:37:55 +01:00
// jQuery.post('/frontend/payments/api.php?action=send_poslovni_uporabniki', podatki).done(function (val) {
// val = JSON.parse(val);
//
// if (val.success) {
// jQuery('#narocilo-poslovni-uporabniki').hide();
// jQuery('#nakup-1ka-poslovni-uporabniki .uspesno-oddano-narocilo').show();
// jQuery('.vsebina h1').text('Uspešno oddano naročilo');
// }
// });
2020-08-14 13:36:36 +02:00
} ) ;
jQuery ( window ) . scroll ( function ( ) {
var scroll = jQuery ( '.nav-container' ) . offset ( ) . top ;
if ( scroll > 50 ) {
jQuery ( '.nav-container' ) . addClass ( 'nav-sticky' ) ;
} else {
jQuery ( '.nav-container' ) . removeClass ( 'nav-sticky' ) ;
}
} ) ;
// BREADCRUM ZAMENJAMO ZNAK
jQuery ( '.breadcrumb__separator' ) . text ( '' ) ;
// //Mnenje uporabnikom - dodamo manjkajoč DIV
jQuery ( '.slidearrow-mnenja.w-slider-arrow-right' ) . on ( 'click' , function ( ) {
// var width = jQuery('.w-slider-mask').width();
// var dataWidth = jQuery('.slide-mnenje').attr('data-width') || 0;
//
// var sumWidth = -width + +dataWidth;
// if((jQuery('.slide-mnenje').length/2 - 1)*width == -dataWidth){
// sumWidth = 0;
// }
//
// jQuery('.slide-mnenje').css({ transform: "translateX("+sumWidth+"px)", opacity: 1, transition: "transform 500ms ease 0s" });
// jQuery('.slide-mnenje').attr('data-width', sumWidth);
jQuery . each ( jQuery ( '[data-show]' ) , function ( i , val ) {
var st = jQuery ( this ) . attr ( 'data-show' ) ;
jQuery ( this ) . removeAttr ( 'data-show' ) . hide ( ) ;
st = + st + 1 ;
if ( st > 9 ) {
jQuery ( '.slide-mnenje' ) . eq ( 0 ) . attr ( 'data-show' , 1 ) . show ( ) ;
jQuery ( '.slide-mnenje' ) . eq ( 1 ) . attr ( 'data-show' , 2 ) . show ( ) ;
} else {
jQuery ( '.slide-mnenje' ) . eq ( st ) . attr ( 'data-show' , st + 1 ) . show ( ) ;
}
} ) ;
} ) ;
jQuery ( '.slidearrow-mnenja.w-slider-arrow-left' ) . on ( 'click' , function ( ) {
// var width = jQuery('.w-slider-mask').width();
// var dataWidth = jQuery('.slide-mnenje').attr('data-width') || 0;
//
// var sumWidth = +dataWidth + +width;
// if(dataWidth == 0){
// sumWidth = - (jQuery('.slide-mnenje').length/2 - 1) * width;
// }
//
// jQuery('.slide-mnenje').css({ transform: "translateX("+sumWidth+"px)", opacity: 1, transition: "transform 500ms ease 0s" });
// jQuery('.slide-mnenje').attr('data-width', sumWidth);
jQuery . each ( jQuery ( '[data-show]' ) , function ( i , val ) {
var st = jQuery ( this ) . attr ( 'data-show' ) ;
jQuery ( this ) . removeAttr ( 'data-show' ) . hide ( ) ;
st = + st - 2 ;
if ( st < 1 ) {
jQuery ( '.slide-mnenje' ) . eq ( 8 ) . attr ( 'data-show' , 9 ) . show ( ) ;
jQuery ( '.slide-mnenje' ) . eq ( 9 ) . attr ( 'data-show' , 10 ) . show ( ) ;
} else {
jQuery ( '.slide-mnenje' ) . eq ( st - 1 ) . attr ( 'data-show' , st ) . show ( ) ;
}
} )
} ) ;
// Prikaz novic
if ( jQuery ( '.submitted span' ) . attr ( 'content' ) ) {
var letoNovice = ( new Date ( jQuery ( '.submitted span' ) . attr ( 'content' ) ) ) . getFullYear ( ) ;
jQuery ( '.breadcrumb a[href="/d/en/news"]' ) . text ( 'News' ) ;
jQuery ( '.breadcrumb a[href="/d/en/news/' + letoNovice + '"]' ) . text ( letoNovice ) ;
jQuery ( '.breadcrumb a[href="/d/sl/novice"]' ) . text ( 'Novice' ) ;
jQuery ( '.breadcrumb a[href="/d/sl/novice/' + letoNovice + '"]' ) . text ( letoNovice ) ;
}
2021-03-11 14:34:12 +01:00
2020-08-14 13:36:36 +02:00
} ) ;
}
} ;
} ) ( 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 && domena && 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 ( ) ;
}
} ) ;
function oddajNarociloNaStreznik ( ) {
jQuery ( '.pregled-narocila' ) . hide ( ) ;
2020-11-20 13:59:13 +01:00
jQuery ( '.procesiram-posamezno-narocilo' ) . hide ( ) ;
2020-08-14 13:36:36 +02:00
jQuery ( '.procesiram-narocilo' ) . show ( ) ;
2020-11-20 13:59:13 +01:00
var nacinPlacila = jQuery ( '[name="payment_method"]:checked' ) . val ( ) ;
jQuery ( '.procesiram-narocilo .procesiram-narocilo-' + nacinPlacila ) . show ( ) ;
2020-12-01 13:32:47 +01:00
2020-11-20 13:59:13 +01:00
if ( nacinPlacila == 2 ) {
jQuery ( '.procesiram-narocilo .procesiram-narocilo-ime' ) . text ( 'PayPal' ) ;
} else if ( nacinPlacila == 3 ) {
jQuery ( '.procesiram-narocilo .procesiram-narocilo-ime' ) . text ( 'Stripe' ) ;
}
2020-08-14 13:36:36 +02:00
// V kolikor je omenjeno polje izpolnjeno potem gre za robota in preusmerimo na začetno stran
if ( jQuery ( '[name="narocilo-robotsko-narocilo"]' ) . val ( ) . length > 0 ) {
return window . location = '/' ;
}
var podatki = jQuery ( 'form#narocilo-paketa-podatki' ) . serialize ( ) ;
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/create_narocilo' , podatki ) . done ( function ( val ) {
2020-08-14 13:36:36 +02:00
val = JSON . parse ( val ) ;
if ( val . error ) {
2020-10-29 13:35:13 +01:00
jQuery ( '.procesiram-narocilo' ) . text ( val . error ) . css ( 'color' , 'red' ) ;
return setTimeout ( function ( ) {
jQuery ( '.pregled-narocila' ) . show ( ) ;
2020-11-16 15:36:11 +01:00
jQuery ( '#oddaj-narocilo' ) . show ( ) ;
2020-10-29 13:35:13 +01:00
jQuery ( '.submit-btn.naprej' ) . show ( ) ;
jQuery ( '#nazaj-na-nakup-1ka' ) . show ( ) ;
jQuery ( '.procesiram-narocilo' ) . hide ( ) ;
jQuery ( '.procesiram-narocilo' ) . text ( 'Poteka obdelava' ) . css ( 'color' , 'black' ) ;
} , 3000 ) ;
2020-08-14 13:36:36 +02:00
}
var cas = new Date ( ) ;
cas . setMinutes ( cas . getMinutes ( ) + 30 ) ;
document . cookie = "vrsta_placila=" + jQuery ( '[name="payment_method"]:checked' ) . val ( ) + ";expires=" + cas + ";path=/" ;
2020-10-23 14:41:59 +02:00
if ( val . success ) {
var paymentMethod = jQuery ( '[name="payment_method"]:checked' ) . val ( ) ;
var paymentLang = jQuery ( '#narocilo-paketa-podatki [name="lang"]' ) . val ( ) ;
var urlRedirect = '/' ;
2020-08-14 13:36:36 +02:00
2020-10-23 14:41:59 +02:00
if ( paymentMethod == 1 ) {
document . cookie = "pdf=" + val . payment _link + ";expires=" + cas + ";path=/" ;
2020-08-14 13:36:36 +02:00
2020-10-23 14:41:59 +02:00
// Glede na jezik preusmerimo na slovensko oz. angleško verzijo
var urlRedirect = "/d/narocilo-pregled/predracun/pdf" ;
if ( paymentLang == 'en' ) {
urlRedirect = "/d/en/purchase/payment-details/pdf" ;
}
2020-08-14 13:36:36 +02:00
2020-10-23 14:41:59 +02:00
} else if ( paymentMethod == 2 ) {
2020-08-14 13:36:36 +02:00
2020-12-01 13:32:47 +01:00
// PayPal redirect
2020-12-02 10:49:44 +01:00
return setTimeout ( function ( ) {
window . location = val . paypal _link
2020-12-01 13:32:47 +01:00
} , 1000 ) ;
2020-08-14 13:36:36 +02:00
2020-11-16 15:36:11 +01:00
} else if ( paymentMethod == 3 ) {
2020-12-01 13:32:47 +01:00
2020-11-16 15:36:11 +01:00
// Nastavimo Stripe instanco
2020-11-16 15:56:49 +01:00
var stripe = Stripe ( jQuery ( '#stripe-token' ) . val ( ) ) ;
2020-08-14 13:36:36 +02:00
2020-12-02 10:49:44 +01:00
return setTimeout ( function ( ) {
stripe . redirectToCheckout ( { sessionId : val . session _id } ) ;
2020-12-01 13:32:47 +01:00
} , 1000 ) ;
2020-08-14 13:36:36 +02:00
}
window . location = urlRedirect ;
2020-12-01 13:32:47 +01:00
2020-08-14 13:36:36 +02:00
}
} ) ;
}
function posodobiCenoPaketa ( ) {
var paket = jQuery ( '[name="package_id"]:checked' ) . val ( ) ;
var trajanje = jQuery ( '[name="trajanje"]:checked' ) . val ( ) ;
2020-10-23 14:41:59 +02:00
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/get_paketi' ) . done ( function ( val ) {
2020-08-14 13:36:36 +02:00
val = JSON . parse ( val ) ;
var cenaIzpisGledeNaDDV = '' ;
jQuery ( '.cena-z-ddv-text' ) . show ( ) ;
jQuery ( '.zavezanec-za-ddv' ) . hide ( ) ;
2021-03-18 12:17:04 +01:00
if ( jQuery ( '#zavezanec-za-ddv' ) . is ( ':checked' ) && jQuery ( '#racun-na-podjetje' ) . is ( ':checked' ) &&
jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) != 'Slovenija' &&
jQuery ( '[name="podjetje_drzava"] :selected' ) . val ( ) != 'Slovenia' ) {
2020-08-14 13:36:36 +02:00
cenaIzpisGledeNaDDV = '_without_tax' ;
jQuery ( '.cena-z-ddv-text' ) . hide ( ) ;
jQuery ( '.zavezanec-za-ddv' ) . show ( ) ;
}
2020-08-27 14:35:03 +02:00
if ( val . paketi [ paket ] && trajanje > 0 ) {
jQuery ( '#nakup-1ka .ime-paketa, #predogled-nakupa-1ka .ime-paketa' ) . text ( val . paketi [ paket ] . name ) ;
jQuery ( '#nakup-1ka .cena-paketa, #predogled-nakupa-1ka .cena-paketa' ) . text ( val . paketi [ paket ] . price [ trajanje ] [ 'final' + cenaIzpisGledeNaDDV ] ) ;
}
jQuery ( '#cena-trajanje1m' ) . text ( val . paketi [ paket ] . price [ 1 ] [ 'monthly' + cenaIzpisGledeNaDDV ] ) ;
jQuery ( '#cena-trajanje3m' ) . text ( val . paketi [ paket ] . price [ 3 ] [ 'monthly' + cenaIzpisGledeNaDDV ] ) ;
jQuery ( '#cena-trajanje12m' ) . text ( val . paketi [ paket ] . price [ 12 ] [ 'monthly' + cenaIzpisGledeNaDDV ] ) ;
2020-08-14 13:36:36 +02:00
// Preverimo, če ima kak popust od prej
jQuery ( '.podatki-za-placilo-racuna' ) . show ( ) ;
2020-11-05 14:37:55 +01:00
jQuery . post ( '/d/nakupovanje-api/get_active_subscription' , {
2020-08-14 13:36:36 +02:00
'package_id' : paket ,
'trajanje' : trajanje ,
'email' : jQuery ( '#narocilo-paketa-podatki #f-email' ) . val ( ) ,
} ) . done ( function ( response ) {
response = JSON . parse ( response ) ;
jQuery ( '#nakup-1ka .cena-brez-popusta-sklop, #predogled-nakupa-1ka .cena-brez-popusta-sklop' ) . hide ( ) ;
// V kolikor se cena s popustom razlikuje od privzete cene, potem prikažemo še končno ceno s popustom
if ( response [ 'final' ] !== response [ 'full' ] ) {
jQuery ( '#nakup-1ka .cena-brez-popusta, #predogled-nakupa-1ka .cena-brez-popusta' ) . text ( response [ 'full' + cenaIzpisGledeNaDDV ] ) ;
jQuery ( '#nakup-1ka .cena-brez-popusta-sklop, #predogled-nakupa-1ka .cena-brez-popusta-sklop' ) . show ( ) ;
jQuery ( '#nakup-1ka .cena-paketa, #predogled-nakupa-1ka .cena-paketa' ) . text ( response [ 'final' + cenaIzpisGledeNaDDV ] ) ;
// Če je cena s popustom 0 potem onemogočimo izbiro plačila
if ( response [ 'final' ] == 0 ) {
jQuery ( '.podatki-za-placilo-racuna' ) . hide ( ) ;
jQuery ( '[name="payment_method"][value="1"]' ) . prop ( 'checked' , true ) ;
}
}
} ) ;
} ) ;
}
function lang ( ) {
return jQuery ( '[name="lang"]' ) . val ( ) ;
}
2020-11-27 14:20:39 +01:00
2021-03-05 11:21:24 +01:00
function odpriAaiLoginObvestilo ( ) {
jQuery ( '.modal-intro-title' ) . hide ( ) ;
2021-03-12 13:03:24 +01:00
jQuery ( '.nakup-prijava' ) . hide ( ) ;
2021-03-05 11:21:24 +01:00
jQuery ( '.modal-intro-login-text' ) . show ( ) ;
if ( jQuery ( '[name="lang"]' ) . val ( ) == 'sl' ) {
jQuery ( '#modal-open-1ka' ) . removeClass ( 'modal-goto-registration' ) . addClass ( 'modal-open-login-obrazec' ) ;
jQuery ( '#modal-info-login' ) . show ( ) ;
2021-03-12 13:03:24 +01:00
// V kolikor gre za nakup prikažemo še obvestilo o nakupu
if ( document . cookie . indexOf ( 'nakup=' ) > 0 ) {
jQuery ( '.nakup-prijava' ) . show ( ) ;
}
2021-03-05 11:21:24 +01:00
} else {
2021-08-18 15:25:10 +02:00
if ( document . cookie . indexOf ( 'nakup=' ) > 0 ) {
jQuery ( '.nakup-prijava' ) . show ( ) ;
}
jQuery ( '#modal-login' ) . show ( ) ;
// jQuery('#modal-open-login-obrazec').show();
2021-03-05 11:21:24 +01:00
}
}
2020-11-27 14:20:39 +01:00
/ * *
* Prikažemo polje za Slovenijo v kolikor je uporabnik proračunski uporabnik
* /
function prikaziPoljeEracun ( ) {
if ( jQuery ( '#racun-na-podjetje' ) . is ( ':checked' ) &&
( jQuery ( '#nakup-1ka #polje-drzava' ) . val ( ) == 'Slovenija' || jQuery ( '#nakup-1ka #polje-drzava' ) . val ( ) == 'Slovenia' ) ) {
jQuery ( '#nakup-1ka #polje-podjetje-eracun' ) . show ( ) ;
} else {
jQuery ( '#nakup-1ka #polje-podjetje-eracun' ) . hide ( ) ;
jQuery ( '[name="podjetje_eracun"]' ) . prop ( 'checked' , false ) ;
}
}
2021-03-05 11:21:24 +01:00