diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2024-05-27 13:08:29 +0200 |
commit | 75160b12821f7f4299cce7f0b69c83c1502ae071 (patch) | |
tree | 27e25e4ccaef45f0c58b22831164050d1af1d4db /main/survey/js/script.js | |
parent | prvi-commit (diff) | |
download | 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.gz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.bz2 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.lz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.xz 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.tar.zst 1ka-75160b12821f7f4299cce7f0b69c83c1502ae071.zip |
Diffstat (limited to 'main/survey/js/script.js')
-rw-r--r-- | main/survey/js/script.js | 238 |
1 files changed, 143 insertions, 95 deletions
diff --git a/main/survey/js/script.js b/main/survey/js/script.js index dc30154..9f44af3 100644 --- a/main/survey/js/script.js +++ b/main/survey/js/script.js @@ -1011,90 +1011,103 @@ function dynamicMultigridFixAllArrows(spremenljivka){ // Razpiranje mobilnih tabel
function mobileMultigridExpandable(){
-
+
+ // Na zacetku skrijemo vedno vse razen prvega
+ $(".grid_mobile.mobile_expanding.radio:not(.double)").find("div.grid_mobile_variables:visible:not(:first)").hide("fast", function(){
+ mobileMultigridExpandableArrow(this, 0);
+ });
+
+
// Pri kliku na naslov podvprasanja razpremo/zapremo podvprasanje
- $(".grid_mobile_title").click(function(){
+ $(".grid_mobile.mobile_expanding .grid_mobile_title").click(function(){
// Double gridi imajo zaenkrat to izklopljeno
if(!$(this).parent().parent().hasClass("double")){
+ let grid_mobile_variables_element = $(this).parent().find(".grid_mobile_variables");
+ let show = 1;
+
+ if($(grid_mobile_variables_element).is(':visible')){
+ show = 0;
+ }
+
// Dobimo pripadajoc div z vsemi vrednostmi
- $(this).parent().find(".grid_mobile_variables").toggle("fast", function(){
- mobileMultigridExpandableArrow(this);
+ $(this).parent().find(".grid_mobile_variables").toggle(300, function(){
+ mobileMultigridExpandableArrow(this, show);
});
}
});
- // Posebna obravnava radio tabel (avtomatsko razpiranje in pomikanje)
- mobileMultigridExpandableRadio();
-}
-// Razpiranje mobilnih tabel pri radio tabelah
-function mobileMultigridExpandableRadio(){
-
- // Na zacetku skrijemo vedno vse razen prvega
- $(".grid_mobile.radio:not(.double)").find("div.grid_mobile_variables:not(:first)").hide(function(){
- mobileMultigridExpandableArrow(this);
- });
-
- // Obrnemo puscico za razpiranje
- $(".grid_mobile.radio:not(.double)").find("div.grid_mobile_variables:not(:first)").parent().find(".mobile_expanding_arrow").toggleClass("arrow_down").toggleClass("arrow_up");
-
- // Pokazemo div z rezultatom
- $(".grid_mobile.radio:not(.double)").find("div.grid_mobile_variables:not(:first)").parent().find(".grid_mobile_result").show();
-
+
// Pri kliku na radio zapremo in razpremo naslednji segment
$("input[type=\"radio\"]").click(function(){
// Ce gre za radio znotraj tabele
- if($(this).closest(".grid_mobile_variables").length > 0 && !$(this).closest(".grid_mobile_variables").parent().parent().hasClass("double")){
+ if($(this).closest(".grid_mobile.mobile_expanding .grid_mobile_variables").length > 0 && !$(this).closest(".grid_mobile_variables").parent().parent().hasClass("double")){
- var podvprasanje_current = $(this).closest(".grid_mobile_variables");
- var podvprasanje_next = $(podvprasanje_current).parent().next().find(".grid_mobile_variables");
+ // Posebna obravnava radio tabel (avtomatsko razpiranje in pomikanje)
+ mobileMultigridExpandableRadio(this);
+ }
+ });
+}
+// Razpiranje mobilnih tabel pri radio tabelah
+function mobileMultigridExpandableRadio(el){
- // Zapremo trenutno podvprasanje
- $(podvprasanje_current).hide("fast", function(){
- mobileMultigridExpandableArrow(this);
- });
+ let podvprasanje_current = $(el).closest(".grid_mobile_variables");
+ let podvprasanje_next = $(podvprasanje_current).parent().nextAll(".grid_mobile_question:visible:first").find(".grid_mobile_variables");
+
+ // Dodamo delay, da lahko konca prejsnja animacija (nastavljanje okvirja na oznacen radio), drugace se izvede istocasno in "pobliskne"
+ setTimeout(function(){
+
+ // Zapremo trenutno podvprasanje
+ mobileMultigridExpandableArrow(podvprasanje_current, 0);
+ $(podvprasanje_current).hide(300, function(){
// Razpremo naslednje vprasanje ce obstaja
- $(podvprasanje_next).show("fast", function(){
- mobileMultigridExpandableArrow(this);
+ mobileMultigridExpandableArrow(podvprasanje_next, 1);
+ $(podvprasanje_next).show(300, function(){
});
+ });
- // Zascrollamo do naslednjega podvprasanja
- $("html, body").animate({
- scrollTop: $(podvprasanje_current).offset().top
- }, 300, "swing");
- }
- });
+ // Zascrollamo do naslednjega podvprasanja
+ $("html, body").animate({
+ scrollTop: $(podvprasanje_current).offset().top - 50
+ }, 300, "swing");
+
+ }, 100);
}
-// Razpiranje mobilnih tabel - zamenjava puscice
-function mobileMultigridExpandableArrow(el){
-
- var arrow = $(el).parent().find(".mobile_expanding_arrow");
- $(arrow).toggleClass("arrow_down").toggleClass("arrow_up");
- mobileMultigridExpandableData(arrow);
-}
-// Prikazemo/skrijemo text odgovora pod naslovom
-function mobileMultigridExpandableData(arrow){
-
- var result = $(arrow).parent().parent().find(".grid_mobile_result");
+// Razpiranje mobilnih tabel - zamenjava puscice in prikaz rezultata
+function mobileMultigridExpandableArrow(el, show){
- // Dobimo text oznacenega radia in ga zapisemo v result div
- var text = $(arrow).parent().parent().find("input[type=radio]:checked").parent().parent().find(".grid_mobile_variable_title").text();
- $(result).text(text);
+ // Element puscice
+ let arrow = $(el).parent().find(".mobile_expanding_arrow");
- // Glede na puscico prikazemo oz. skrijemo result div
- if($(arrow).hasClass("arrow_down")){
- $(result).show('fast');
- }
- else{
- $(result).hide('fast');
- }
-
+ // Element (div pod naslovom) s trenutno oznacenim textom
+ let result = $(arrow).parent().parent().find(".grid_mobile_result");
+
+ // Dobimo text oznacenega radia in ga zapisemo v result div
+ let text = $(arrow).parent().parent().find("input[type=radio]:checked").parent().parent().find(".grid_mobile_variable_title").text();
+
+ // Razpremo
+ if(show == 1){
+ // Obrnemo puscico
+ $(arrow).removeClass("arrow_down").addClass("arrow_up");
+
+ // Skrijemo text
+ $(result).hide('fast');
+ }
+ // Skrcimo
+ else{
+ // Obrnemo puscico
+ $(arrow).removeClass("arrow_up").addClass("arrow_down");
+
+ // Prikazemo text
+ $(result).text(text).show('fast');
+ }
}
+
// Razpiranje vprasanj v bloku - init
function questionsExpandable(){
@@ -1211,16 +1224,19 @@ function questionExpandableData(spremenljivka){ function continue_later (site_url, lang_id) {
- if ( $('#continue_later').length ) {
-
+ if ( $('#continue_later').length ) {
$('#continue_later').remove();
-
- } else {
- $.post(site_url+'main/survey/ajax.php?a=continue_later&language='+lang_id, {anketa: srv_meta_anketa_id, url: window.location.href}, function (data) {
-
+ }
+ else {
+
+ var url = window.location.href;
+
+ if( $('#panel_url').length )
+ url = $('#panel_url').val();
+
+ $.post(site_url+'main/survey/ajax.php?a=continue_later&language='+lang_id, {anketa: srv_meta_anketa_id, url: url}, function (data) {
$('#continue_later').remove();
$('#container h1').after( data );
-
});
}
}
@@ -1231,17 +1247,22 @@ function continue_later_send (site_url, lang_id) { email = $('#email').val();
$.post(site_url+'main/survey/ajax.php?a=continue_later_send&language='+lang_id, {anketa: srv_meta_anketa_id, url:url, email:email}, function (data) {
-
$('#continue_later').remove();
-
});
+}
+
+function return_edit_send (site_url, lang_id) {
+ url = $('#url').val();
+ email = $('#email').val();
+
+ $.post(site_url+'main/survey/ajax.php?a=return_edit_send&language='+lang_id, {anketa: srv_meta_anketa_id, url:url, email:email}, function (data) {
+ $('#return_edit_email').text(data);
+ });
}
function preview_popup_close () {
- $('#preview-holder, #preview_switch').fadeOut('medium');
-
$('#preview-window').addClass('closed');
$('.preview_icon_open').show();
@@ -1252,8 +1273,6 @@ function preview_popup_close () { function preview_popup_open () {
- $('#preview-holder, #preview_switch').fadeIn('medium');
-
$('#preview-window').removeClass('closed');
$('.preview_icon_open').hide();
@@ -1324,26 +1343,6 @@ function init_comments_save () { }();
}
-// respondent se strinja z uporabo piskotkov
-function cookie_ok () {
-
- $.post(srv_site_url+'main/survey/ajax.php?a=cookie_ok', {anketa: srv_meta_anketa_id}, function (data) {
- window.location.reload();
- });
-
- return false;
-}
-
-function cookie_check() {
-
- if ( $('#cookie_alert').css('display') == 'block' ) {
- alert(lang['srv_cookie_continue_alert']);
- return false;
- }
-
- $('#container form').submit();
-}
-
function privacy_check() {
if ( $('#privacy_box').length ) {
@@ -1757,6 +1756,27 @@ function hide_gdpr_about(){ $('#popup').removeClass('gdpr_about');
}
+
+// popup "pogoji uporabe" pri modulu email dostop (mju)
+function show_email_access_terms() {
+
+ $('#popup').addClass('email_access_terms');
+
+ $('#popup').load(srv_site_url+'main/survey/ajax.php?a=show_email_access_terms', {anketa: srv_meta_anketa_id}, function(){
+ $('#fade').fadeTo('fast', 0.5, function(){
+ $('#popup').fadeIn("fast");
+ });
+ });
+}
+function hide_email_access_terms(){
+
+ $('#fade').fadeOut();
+ $('#popup').hide();
+
+ $('#popup').removeClass('email_access_terms');
+}
+
+
/**
* Show notification, that respondent has reached maximum number of chars
* @param {type} input - input or textarea
@@ -1776,7 +1796,11 @@ function handleMaxTextParam(input, sid){ * @returns {undefined}
*/
function charCounter(field){
- document.getElementById(field.id+'_counter').innerHTML = field.value.length;
+
+ var char_counter = field.value.length;
+ char_counter = (char_counter == 0) ? '' : char_counter;
+
+ $('#'+field.id+'_counter').html(char_counter);
}
/**
@@ -1785,7 +1809,11 @@ function charCounter(field){ * @returns {undefined}
*/
function set_charCounter(field_id){
- document.getElementById(field_id+'_counter').innerHTML = document.getElementById(field_id).value.length;
+
+ var char_counter = $('#'+field_id).val().length;
+ char_counter = (char_counter == 0) ? '' : char_counter;
+
+ $('#'+field_id+'_counter').html(char_counter);
}
@@ -1883,11 +1911,13 @@ function gridRepeatHeader(repeat_every, spr_id){ // Za tabelo najprej pobrisemo vse ponovljene vrstice ce so ze prisotne
$(table).find('tbody tr.repeat_header').remove();
+ var count_rows = $(table).find("tbody tr:visible").size();
+
// Loopamo cez vidne vrstice in vstavimo header vsakih "repeat_every" vrstic
$(table).find("tbody tr:visible").each(function(index) {
// Insetamo naslovno vrstico na pravo mesto
- if((index+1) % repeat_every == 0){
+ if((index+1) % repeat_every == 0 && count_rows > (index+1)){
$(this).after(table_header);
}
});
@@ -1914,7 +1944,7 @@ function checkUpload(upload, id){ // File extensions allowed
- let extAllowed = ["jpeg", "jpg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx"];
+ let extAllowed = ["jpeg", "jpg", "png", "gif", "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "zip", "rar", "rdata", "rds", "rmd", "qmd"];
// Get file ext
let fileNameFull = upload.files[0].name;
@@ -1969,3 +1999,21 @@ function disableSubsequentAnswers(){ });
}
+
+// Preverimo, ce je vnesel mail za posiljanje url-ja za nadaljevanje kasneje in je pozabil klikniti "poslji"
+function continueLaterCheckEmail(alert_text, callback) {
+
+ let close_survey = true;
+
+ if($('#return_edit_email').find('input#email').length && $('#return_edit_email').find('input#email').val() != ''){
+
+ if (!confirm(alert_text)){
+ close_survey = false;
+ }
+ }
+
+ // Zapremo anketo, ker itak ni vnesel maila
+ if (close_survey) {
+ callback();
+ }
+}
\ No newline at end of file |