|
17 | 17 | var translations = {}; |
18 | 18 | var errorChecking = 0; |
19 | 19 | var anyTranslated = false; |
| 20 | + var matrixProcessed = {}; |
20 | 21 |
|
21 | 22 | //document ready change language |
22 | 23 | $( document ).ready(function(){ |
|
530 | 531 | var id; |
531 | 532 | for(id in translations['questions']){ |
532 | 533 | if(translations['questions'][id]['matrix'] != null){ |
| 534 | + if(!(translations['questions'][id]['matrix'] in matrixProcessed) && settings['hide-matrix-questions-without-translation-survey']['value']) { |
| 535 | + $('tr[mtxgrp="'+translations['questions'][id]['matrix']+'"].mtxfld').each(function(){ |
| 536 | + var curMtxQuestionId = $(this).attr('id'); |
| 537 | + curMtxQuestionId = curMtxQuestionId.replace('-tr', ''); |
| 538 | + if(typeof translations['questions'][curMtxQuestionId] == 'undefined') { |
| 539 | + $(this).hide(); |
| 540 | + } else { |
| 541 | + $(this).show(); |
| 542 | + } |
| 543 | + }); |
| 544 | + matrixProcessed[translations['questions'][id]['matrix']] = true; |
| 545 | + } |
533 | 546 | //$('#' + id + '-tr').children('td').eq(1).children('table').children().children().children('td:first').html(translations['questions'][id]['text']); |
534 | 547 | $('#label-' + id).html(translations['questions'][id]['text']); |
535 | | - } |
536 | | - else if(translations['questions'][id]['type'] == 'descriptive'){ |
| 548 | + } else if(translations['questions'][id]['type'] == 'descriptive'){ |
537 | 549 | var tmp = $('#' + id + '-tr').children('td').eq(1).html(); |
538 | 550 | if(tmp != undefined){ |
539 | 551 | $('#' + id + '-tr').children('td').eq(1).html(translations['questions'][id]['text']); |
540 | 552 | //tmp = tmp.split(/<(.+)/); |
541 | 553 | //$('#' + id + '-tr').children('td').eq(1).html(translations['questions'][id]['text'] + ' <' + tmp[1]); |
542 | 554 | } |
543 | | - } |
544 | | - else{ |
| 555 | + } else { |
545 | 556 | $('#label-' + id).html(translations['questions'][id]['text']); |
546 | 557 | } |
547 | 558 | } |
|
552 | 563 | var id2; |
553 | 564 | for(id2 in translations['answers'][id]['text']){ |
554 | 565 | $('[name="' + id + '"] option').each(function(){ |
| 566 | + $(this).show(); |
555 | 567 | if($(this).val() == id2){ |
556 | 568 | $(this).text(translations['answers'][id]['text'][id2]); |
| 569 | + $(this).data('lang', lang); |
| 570 | + } else if(settings['hide-answers-without-translation-survey']['value'] && $(this).val() !== '' && $(this).data('lang') !== lang) { |
| 571 | + $(this).hide(); |
557 | 572 | } |
558 | 573 | }); |
559 | 574 | } |
|
581 | 596 | //translations['answers'][id]['text'][id2]); |
582 | 597 | //$('#' + translations['answers'][id]['matrix'] + '-mtxhdr-tr').children('td').eq(1).children().children().children().children('td').eq(counter).html(translations['answers'][id]['text'][id2]); |
583 | 598 | $('#matrixheader-' + translations['answers'][id]['matrix'] + '-' + id2).html(translations['answers'][id]['text'][id2]); |
| 599 | + // $('#matrixheader-' + translations['answers'][id]['matrix'] + '-' + id2).html('Answer'); |
584 | 600 | counter++; |
585 | 601 | } |
586 | 602 | } |
587 | 603 | else if(translations['answers'][id]['type'] == 'radio' || translations['answers'][id]['type'] == 'yesno' || translations['answers'][id]['type'] == 'truefalse'){ |
588 | 604 | var id2; |
589 | 605 | for(id2 in translations['answers'][id]['text']){ |
590 | 606 | $('[name="' + id + '___radio"]').each(function(){ |
| 607 | + $(this).parent().contents().last().show(); |
| 608 | + $(this).show(); |
591 | 609 | if($(this).val() == id2){ |
592 | | - //$(this).parent().contents().last().replaceWith(' ' + translations['answers'][id]['text'][id2]); |
593 | 610 | $(this).parent().contents().last().html(' ' + translations['answers'][id]['text'][id2]); |
| 611 | + $(this).data('lang', lang); |
| 612 | + } else if(settings['hide-answers-without-translation-survey']['value'] && $(this).data('lang') !== lang) { |
| 613 | + $(this).parent().contents().last().hide(); |
| 614 | + $(this).hide(); |
594 | 615 | } |
595 | 616 | }); |
596 | 617 | } |
597 | 618 | //enhanced radio buttons |
598 | 619 | for(id2 in translations['answers'][id]['text']){ |
599 | 620 | $('.ec').each(function(){ |
600 | 621 | var tmp = $(this).parent().attr('comps').split(','); |
601 | | - if(tmp[0] == id && tmp[2] == id2){ |
602 | | - $(this).html(translations['answers'][id]['text'][id2]); |
| 622 | + $(this).show(); |
| 623 | + if(tmp[0] == id && tmp[2] == id2) { |
| 624 | + $(this).html(' ' + translations['answers'][id]['text'][id2]); |
| 625 | + $(this).data('lang', lang); |
| 626 | + } else if(settings['hide-answers-without-translation-survey']['value'] && $(this).data('lang') !== lang) { |
| 627 | + $(this).hide(); |
603 | 628 | } |
604 | 629 | }); |
605 | 630 | } |
606 | 631 | } |
607 | 632 | else if(translations['answers'][id]['type'] == 'checkbox'){ |
608 | 633 | var id2; |
609 | 634 | for(id2 in translations['answers'][id]['text']){ |
610 | | - $('[name="__chk__' + id + '_RC_' + id2 + '"]').each(function(){ |
611 | | - //$(this).parent().contents().last().replaceWith(' ' + translations['answers'][id]['text'][id2]); |
612 | | - $(this).parent().contents().last().html(' ' + translations['answers'][id]['text'][id2]); |
| 635 | + $('#'+id+'-tr .choicevert').each(function(){ |
| 636 | + $(this).show(); |
| 637 | + if($(this).find('[name="__chk__' + id + '_RC_' + id2 + '"]').length) { |
| 638 | + $(this).contents().last().html(' ' + translations['answers'][id]['text'][id2]); |
| 639 | + $(this).data('lang', lang); |
| 640 | + } else if(settings['hide-answers-without-translation-survey']['value'] && $(this).data('lang') !== lang) { |
| 641 | + $(this).hide(); |
| 642 | + } |
613 | 643 | }); |
614 | 644 | } |
615 | 645 | //enhanced checkboxes |
616 | 646 | for(id2 in translations['answers'][id]['text']){ |
617 | 647 | $('.ec').each(function(){ |
618 | 648 | var tmp = $(this).parent().attr('comps').split(','); |
619 | | - if(tmp[0] == id && tmp[2] == id2){ |
| 649 | + $(this).show(); |
| 650 | + if(tmp[0] == id && tmp[2] == id2) { |
620 | 651 | $(this).html(translations['answers'][id]['text'][id2]); |
| 652 | + $(this).data('lang', lang); |
| 653 | + } else if(settings['hide-answers-without-translation-survey']['value'] && $(this).data('lang') !== lang) { |
| 654 | + $(this).hide(); |
621 | 655 | } |
622 | 656 | }); |
623 | 657 | } |
|
786 | 820 | translations = r; |
787 | 821 | langReady = 1; |
788 | 822 | anyTranslated = true; |
| 823 | + matrixProcessed = {}; |
789 | 824 | } |
790 | 825 | }, |
791 | 826 | error: function(jqXHR, textStatus, errorThrown) { |
|
0 commit comments