diff --git a/application/core/packages/limesurvey/survey.css b/application/core/packages/limesurvey/survey.css index 055e5cfe526..1171228344f 100644 --- a/application/core/packages/limesurvey/survey.css +++ b/application/core/packages/limesurvey/survey.css @@ -10,6 +10,13 @@ * Used in answers : bootsrap fix (specific single choice list) */ +/** + * Expression manager relevance system + */ +.ls-hidden {display:none !important;}/* Need important : template can set display:block/table etc ... after */ +.ls-unrelevant{} +.ls-disabled{opacity:0.4;} + /* Some tools */ diff --git a/application/core/packages/limesurvey/survey.js b/application/core/packages/limesurvey/survey.js index 30367019afc..f4f70390d11 100644 --- a/application/core/packages/limesurvey/survey.js +++ b/application/core/packages/limesurvey/survey.js @@ -8,6 +8,114 @@ * Always set an empty LSvar */ var LSvar = LSvar || { }; + +/** + * Action to do when relevance is set to on or off + */ +function triggerEmRelevance(){ + triggerEmRelevanceQuestion(); + triggerEmRelevanceGroup(); + triggerEmRelevanceSubQuestion(); +} + +/* On question */ +function triggerEmRelevanceQuestion(){ + /* Action on this question */ + $("[id^='question']").on('relevance:on',function(event,data) { + if(event.target != this) return; /* @todo : attach only to this. Use http://stackoverflow.com/a/6411507/2239406 solution for now. Don't want to stop propagation. */ + $(this).removeClass("ls-unrelevant ls-hidden"); + }); + $("[id^='question']").on('relevance:off',function(event,data) { + if(event.target != this) return; + $(this).addClass("ls-unrelevant ls-hidden"); + }); + /* In all in one mode : need updating group too */ + $(".allinone [id^='group-']:not(.ls-unrelevant) [id^='question']").on('relevance:on',function(event,data) { + if(event.target != this) return; + $(this).closest("[id^='group-']").removeClass("ls-hidden"); + }); + $(".allinone [id^='group-']:not(.ls-unrelevant) [id^='question']").on('relevance:off',function(event,data) { + if(event.target != this) return; + if($(this).closest("[id^='group-']").find("[id^='question']").length==$(this).closest("[id^='group-']").find("[id^='question'].ls-hidden").length){ + $(this).closest("[id^='group-']").addClass("ls-hidden"); + } + }); +} +function triggerEmRelevanceGroup(){ + $("[id^='group-']").on('relevance:on',function(event,data) { + if(event.target != this) return; + $(this).removeClass("ls-unrelevant ls-hidden"); + }); + $("[id^='group-']").on('relevance:off',function(event,data) { + if(event.target != this) return; + $(this).addClass("ls-unrelevant ls-hidden"); + }); +} +function triggerEmRelevanceSubQuestion(){ + $("[id^='question']").on('relevance:on',"[id^='javatbd']",function(event,data) { + if(event.target != this) return; // not needed now, but after (2016-11-07) + data = $.extend({style:'hidden'}, data); + $(this).removeClass("ls-unrelevant ls-"+data.style); + if(data.style=='disabled'){ + $(event.target).find('input').prop("disabled", false ); + } + if(data.style=='hidden'){ + updateLineClass($(this)); + updateRepeatHeading($(this).closest(".ls-answers")); + } + }); + $("[id^='question']").on('relevance:off',"[id^='javatbd']",function(event,data) { + if(event.target != this) return; // not needed now, but after (2016-11-07) + data = $.extend({style:'hidden'}, data); + $(this).addClass("ls-unrelevant ls-"+data.style); + if(data.style=='disabled'){ + $(event.target).find('input').prop("disabled", true ); + } + if(data.style=='hidden'){ + updateLineClass($(this)); + updateRepeatHeading($(this).closest(".ls-answers")); + } + }); +} +/** + * Update lines class when relevance:(on|off) happen + */ +function updateLineClass(line){ + if($(line).hasClass("ls-odd") || $(line).hasClass("ls-even")){ + $(line).closest(".ls-answers").find(".ls-odd:visible,.ls-even:visible").each(function(index){ // not limited to table + $(this).removeClass('ls-odd ls-even').addClass(((index+1)%2 == 0) ? "ls-odd" : "ls-even"); + }); + } +} +/** + * Update repeat heading + */ +function updateRepeatHeading(answers){ + /* Update only (at start) when all hidden line is done : @todo : do it only once */ + $(function() { + if($(answers).data("repeatHeading") || $(answers).find("tbody").find(".ls-heading").length){ + /* set the data the first time */ + if(!$(answers).data("repeatHeading")){ + var repeatHeading=$(answers).find("tbody:first tr").length;/* first body don't have heading */ + $(answers).data("repeatHeading",repeatHeading) + $(answers).data("repeatHeader",$(answers).find("tbody .ls-heading").filter(":first")[0].outerHTML); + }else{ + var repeatHeading=$(answers).data("repeatHeading"); + } + /* can remove the heading and clone this one of thead */ + var header = $(answers).data("repeatHeader"); + $(answers).find("tbody .ls-heading").remove(); + var lines=$(answers).find('tr:visible'); + var max=$(answers).find('tr:visible').length-1; + $(lines).each(function(index){ + if(index != 0 && index % repeatHeading == 0 && index < max) + { + $(header).insertAfter($(this)); + } + }); + } + }); +} /** * Manage the index */ diff --git a/application/helpers/SurveyRuntimeHelper.php b/application/helpers/SurveyRuntimeHelper.php index 8867a78bc50..6542ec79e1e 100644 --- a/application/helpers/SurveyRuntimeHelper.php +++ b/application/helpers/SurveyRuntimeHelper.php @@ -893,7 +893,7 @@ function run($surveyid,$args) $gnoshow = LimeExpressionManager::GroupIsIrrelevantOrHidden($_gseq); if ($gnoshow && !$previewgrp) { - echo " class='hidden'"; + echo " class='ls-hidden'";/* Unsure for reason : hidden or unrelevant ?*/ } echo ">\n"; echo templatereplace(file_get_contents($sTemplateViewPath."startgroup.pstpl"), array(), $redata); @@ -986,6 +986,7 @@ function run($surveyid,$args) LimeExpressionManager::FinishProcessingGroup($LEMskipReprocessing); echo LimeExpressionManager::GetRelevanceAndTailoringJavaScript(); + Yii::app()->clientScript->registerScript('triggerEmRelevance',"triggerEmRelevance();",CClientScript::POS_END); LimeExpressionManager::FinishProcessingPage(); /** @@ -1172,16 +1173,28 @@ public static function getQuestionReplacement($aQuestionQanda) } // Core value :the classes - $aReplacement['QUESTION_CLASS'] = Question::getQuestionClass($sType); - + $aQuestionClass=array( + Question::getQuestionClass($sType), + ); + /* Add the relevance class */ + if (!$lemQuestionInfo['relevant']) + { + $aQuestionClass[]='ls-unrelevant'; + $aQuestionClass[]='ls-hidden'; + } + if ($lemQuestionInfo['hidden']) + { + $aQuestionClass[]='ls-hidden'; + } //get additional question classes from question attribute $aQuestionAttributes = getQuestionAttributeValues($aQuestionQanda[4]); //add additional classes if(isset($aQuestionAttributes['cssclass'])) { - $aReplacement['QUESTION_CLASS'] .= " ".$aQuestionAttributes['cssclass']; + $aQuestionClass[]=htmlentities($aQuestionAttributes['cssclass']); } + $aReplacement['QUESTION_CLASS'] =implode(" ",$aQuestionClass); $aMandatoryClass = array(); if ($lemQuestionInfo['info']['mandatory'] == 'Y')// $aQuestionQanda[0]['mandatory']=="*" @@ -1203,10 +1216,6 @@ public static function getQuestionReplacement($aQuestionQanda) $aReplacement['QUESTION_MANDATORY']=$aQuestionQanda[0]['mandatory']; // For QUESTION_ESSENTIALS $aHtmlOptions=array(); - if ((!$lemQuestionInfo['relevant']) || ($lemQuestionInfo['hidden']))// && $lemQuestionInfo['info']['type'] == '*')) - { - $aHtmlOptions['style'] = 'display: none;'; - } // Launch the event $event = new PluginEvent('beforeQuestionRender'); @@ -1248,8 +1257,10 @@ public static function getQuestionReplacement($aQuestionQanda) $aReplacement['QUESTION_VALID_MESSAGE'] = $event->get('valid_message'); $aReplacement['QUESTION_FILE_VALID_MESSAGE'] = $event->get('file_valid_message'); $aReplacement['QUESTION_MANDATORY'] = $event->get('mandatory',$aReplacement['QUESTION_MANDATORY']); - // Always add id for QUESTION_ESSENTIALS - $aHtmlOptions['id']="question{$iQid}"; + //Another data for QUESTION_ESSENTIALS + $aHtmlOptions= (array) $event->get('aHtmlOptions'); + unset($aHtmlOptions['class']);// Disallowing update/set class + $aHtmlOptions['id']="question{$iQid}";// Always add id for QUESTION_ESSENTIALS $aReplacement['QUESTION_ESSENTIALS']=CHtml::renderAttributes($aHtmlOptions); return $aReplacement; diff --git a/application/helpers/expressions/em_manager_helper.php b/application/helpers/expressions/em_manager_helper.php index cb2f0dc7d69..b73b6ca1da9 100644 --- a/application/helpers/expressions/em_manager_helper.php +++ b/application/helpers/expressions/em_manager_helper.php @@ -7211,47 +7211,30 @@ static function GetRelevanceAndTailoringJavaScript() // Do all sub-question filtering (e..g array_filter) /** - * $afHide - if true, then use jQuery.show(). If false, then disable/enable the row + * $afHide - if true, then use jQuery.relevanceOn(). If false, then disable/enable the row */ $afHide = (isset($LEM->qattr[$arg['qid']]['array_filter_style']) ? ($LEM->qattr[$arg['qid']]['array_filter_style'] == '0') : true); $inputSelector = (($arg['type'] == 'R') ? '' : ' :input:not(:hidden)'); foreach ($subqParts as $sq) { $rowdividList[$sq['rowdivid']] = $sq['result']; - // make sure to update headings and colors for filtered questions (array filter and individual SQ relevance) - if( ! empty($sq['type'])) { - // js to fix colors - $relParts[] = "updateColors($('#question".$arg['qid']."').find('table.question'));\n"; - // js to fix headings - $repeatheadings = Yii::app()->getConfig("repeatheadings"); - if(isset($LEM->qattr[$arg['qid']]['repeat_headings']) && $LEM->qattr[$arg['qid']]['repeat_headings'] !== "") { - $repeatheadings = $LEM->qattr[$arg['qid']]['repeat_headings']; - } - if($repeatheadings > 0) - { - $relParts[] = "updateHeadings($('#question".$arg['qid']."').find('table.question'), " - .$repeatheadings.");\n"; - } - } - // end //this change is optional....changes to array should prevent "if( )" $relParts[] = " if ( " . (empty($sq['relevancejs'])?'1':$sq['relevancejs']) . " ) {\n"; if ($afHide) { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').show();\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:on');\n"; } else { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').removeAttr('disabled');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:on',{ style : 'disabled' });\n"; } if ($sq['isExclusiveJS'] != '') { $relParts[] = " if ( " . $sq['isExclusiveJS'] . " ) {\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:off',{ style : 'disabled' });\n"; $relParts[] = " }\n"; $relParts[] = " else {\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').removeAttr('disabled');\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . " th.answertext').removeClass('text-muted');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:on',{ style : 'disabled' });\n"; $relParts[] = " }\n"; } $relParts[] = " relChange" . $arg['qid'] . "=true;\n"; @@ -7263,36 +7246,34 @@ static function GetRelevanceAndTailoringJavaScript() if ($sq['irrelevantAndExclusiveJS'] != '') { $relParts[] = " if ( " . $sq['irrelevantAndExclusiveJS'] . " ) {\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . " th.answertext').addClass('text-muted');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:off',{ style : 'disabled' });\n"; $relParts[] = " }\n"; $relParts[] = " else {\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').removeAttr('disabled');\n"; - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . " th.answertext').removeClass('text-muted');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:on',{ style : 'disabled' });\n"; if ($afHide) { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').rtrigger('relevance:off');\n"; } else { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:off',{ style : 'disabled' });\n"; } $relParts[] = " }\n"; } else { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:off',{ style : 'disabled' });\n"; } } else { if ($afHide) { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:off');\n"; } else { - $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n"; + $relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').trigger('relevance:off',{ style : 'disabled' });\n"; } } $relParts[] = " relChange" . $arg['qid'] . "=true;\n"; @@ -7481,14 +7462,14 @@ static function GetRelevanceAndTailoringJavaScript() } if ($arg['hidden']) { - $relParts[] = " // This question should always be hidden\n"; - $relParts[] = " $('#question" . $arg['qid'] . "').hide();\n"; + $relParts[] = " // This question should always be hidden : not relevance, hidden question\n"; + $relParts[] = " $('#question" . $arg['qid'] . "').addClass('hidden');\n"; } else { if (!($relevance == '' || $relevance == '1' || ($arg['result'] == true && $arg['numJsVars']==0))) { // In such cases, PHP will make the question visible by default. By not forcing a re-show(), template.js can hide questions with impunity - $relParts[] = " $('#question" . $arg['qid'] . "').show();\n"; + $relParts[] = " $('#question" . $arg['qid'] . "').trigger('relevance:on');\n"; if ($arg['type'] == 'S') { $relParts[] = " if($('#question" . $arg['qid'] . " div[id^=\"gmap_canvas\"]').length > 0)\n"; @@ -7520,7 +7501,7 @@ static function GetRelevanceAndTailoringJavaScript() if( !($arg['hidden'] && $arg['type']=="*"))// Equation question type don't update visibility of group if hidden ( child of bug #08315). $dynamicQinG[$arg['gseq']][$arg['qid']]=true; $relParts[] = "else {\n"; - $relParts[] = " $('#question" . $arg['qid'] . "').hide();\n"; + $relParts[] = " $('#question" . $arg['qid'] . "').trigger('relevance:off');\n"; $relParts[] = " if ($('#relevance" . $arg['qid'] . "').val()=='1') { relChange" . $arg['qid'] . "=true; }\n"; // only propagate changes if changing from relevant to irrelevant $relParts[] = " $('#relevance" . $arg['qid'] . "').val('0');\n"; $relParts[] = "}\n"; @@ -7622,7 +7603,7 @@ static function GetRelevanceAndTailoringJavaScript() // $jsParts[] = "\n// Process Relevance for Group " . $gr['gid']; // $jsParts[] = ": { " . $gr['eqn'] . " }"; $jsParts[] = "\nif (" . $gr['relevancejs'] . ") {\n"; - $jsParts[] = " $('#group-" . $gr['gseq'] . "').show();\n"; + $jsParts[] = " $('#group-" . $gr['gseq'] . "').trigger('relevance:on');\n"; $jsParts[] = " relChangeG" . $gr['gseq'] . "=true;\n"; $jsParts[] = " $('#relevanceG" . $gr['gseq'] . "').val(1);\n"; @@ -7659,7 +7640,7 @@ static function GetRelevanceAndTailoringJavaScript() } $jsParts[] = "}\nelse {\n"; - $jsParts[] = " $('#group-" . $gr['gseq'] . "').hide();\n"; + $jsParts[] = " $('#group-" . $gr['gseq'] . "').trigger('relevance:off');\n"; $jsParts[] = " if ($('#relevanceG" . $gr['gseq'] . "').val()=='1') { relChangeG" . $gr['gseq'] . "=true; }\n"; $jsParts[] = " $('#relevanceG" . $gr['gseq'] . "').val(0);\n"; $jsParts[] = "}\n"; @@ -7709,11 +7690,11 @@ static function GetRelevanceAndTailoringJavaScript() $relStatusTest = "($('#relevance" . implode("').val()=='1' || $('#relevance", array_keys($dynamicQidsInG)) . "').val()=='1')"; $jsParts[] = "\nif (" . $relStatusTest . ") {\n"; - $jsParts[] = " $('#group-" . $gr['gseq'] . "').show();\n"; + $jsParts[] = " $('#group-" . $gr['gseq'] . "').trigger('relevance:on');\n"; $jsParts[] = " if ($('#relevanceG" . $gr['gseq'] . "').val()=='0') { relChangeG" . $gr['gseq'] . "=true; }\n"; $jsParts[] = " $('#relevanceG" . $gr['gseq'] . "').val(1);\n"; $jsParts[] = "}\nelse {\n"; - $jsParts[] = " $('#group-" . $gr['gseq'] . "').hide();\n"; + $jsParts[] = " $('#group-" . $gr['gseq'] . "').trigger('relevance:off');\n"; $jsParts[] = " if ($('#relevanceG" . $gr['gseq'] . "').val()=='1') { relChangeG" . $gr['gseq'] . "=true; }\n"; $jsParts[] = " $('#relevanceG" . $gr['gseq'] . "').val(0);\n"; $jsParts[] = "}\n"; diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index edfc519860b..589c457ba48 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -696,55 +696,69 @@ function return_timer_script($aQuestionAttributes, $ia, $disable=null) */ function return_display_style($ia, $aQuestionAttributes, $thissurvey, $rowname) { - $htmltbody2 = ''; - $surveyid=$thissurvey['sid']; + /* Disabled actually : no inline style */ + return ""; + //~ $htmltbody2 = ''; + //~ $surveyid=$thissurvey['sid']; + //~ if (isset($_SESSION["survey_{$surveyid}"]['relevanceStatus'][$rowname]) && !$_SESSION["survey_{$surveyid}"]['relevanceStatus'][$rowname]) + //~ { + //~ // If using exclude_all_others, then need to know whether irrelevant rows should be hidden or disabled + //~ if (isset($aQuestionAttributes['exclude_all_others'])) + //~ { + //~ $disableit=false; + //~ foreach(explode(';',trim($aQuestionAttributes['exclude_all_others'])) as $eo) + //~ { + //~ $eorow = $ia[1] . $eo; + //~ if ((!isset($_SESSION["survey_{$surveyid}"]['relevanceStatus'][$eorow]) || $_SESSION["survey_{$surveyid}"]['relevanceStatus'][$eorow]) + //~ && (isset($_SESSION[$eorow]) && $_SESSION[$eorow] == "Y")) + //~ { + //~ $disableit = true; + //~ } + //~ } + //~ if ($disableit) + //~ { + //~ $htmltbody2 .= " disabled='disabled'"; + //~ } + //~ else + //~ { + //~ if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0') + //~ { + //~ $htmltbody2 .= " style='display: none'"; + //~ } + //~ else + //~ { + //~ $htmltbody2 .= " disabled='disabled'"; + //~ } + //~ } + //~ } + //~ else + //~ { + //~ if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0') + //~ { + //~ $htmltbody2 .= " style='display: none'"; + //~ } + //~ else + //~ { + //~ $htmltbody2 .= " disabled='disabled'"; + //~ } + //~ } + //~ } + + //~ return $htmltbody2; +} +/** + * @todo Return the Expression manager class of a subquestion + * @param integer $surveyid : the survey id + * @param string $subquestionName : the target name + * @param array $aQuestionAttributes : the attribute of the question (for array_filter_style actually) + */ +function getExpressionManagerClass($surveyid,$subquestionName,$aQuestionAttributes=null) +{ if (isset($_SESSION["survey_{$surveyid}"]['relevanceStatus'][$rowname]) && !$_SESSION["survey_{$surveyid}"]['relevanceStatus'][$rowname]) { - // If using exclude_all_others, then need to know whether irrelevant rows should be hidden or disabled - if (isset($aQuestionAttributes['exclude_all_others'])) - { - $disableit=false; - foreach(explode(';',trim($aQuestionAttributes['exclude_all_others'])) as $eo) - { - $eorow = $ia[1] . $eo; - if ((!isset($_SESSION["survey_{$surveyid}"]['relevanceStatus'][$eorow]) || $_SESSION["survey_{$surveyid}"]['relevanceStatus'][$eorow]) - && (isset($_SESSION[$eorow]) && $_SESSION[$eorow] == "Y")) - { - $disableit = true; - } - } - if ($disableit) - { - $htmltbody2 .= " disabled='disabled'"; - } - else - { - if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0') - { - $htmltbody2 .= " style='display: none'"; - } - else - { - $htmltbody2 .= " disabled='disabled'"; - } - } - } - else - { - if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0') - { - $htmltbody2 .= " style='display: none'"; - } - else - { - $htmltbody2 .= " disabled='disabled'"; - } - } - } - return $htmltbody2; + } } - /** * @param string $rowname * @param string $valuename diff --git a/scripts/expressions/em_javascript.js b/scripts/expressions/em_javascript.js index 8cd1126ff7e..f3533579595 100644 --- a/scripts/expressions/em_javascript.js +++ b/scripts/expressions/em_javascript.js @@ -18,10 +18,12 @@ * and Contributors (http://phpjs.org/authors) */ -/* Default event to trigger on answer part - * see https://manual.limesurvey.org/Project_ideas_for_GSoC_2015#Expression_Manager_JavaScript_optimizations - * Actually only for list with comment and select in ranking +/** + * Default event to trigger on answer part + * Launch function according to anser-item type + * @todo : checkconditions/fixnum_checkconditions in this function **/ +/* text/number item */ $(document).on("keyup change",".answer-item textarea:not([onkeyup]),.answer-item :text:not([onkeyup])",function(event){ // 'keyup' can be replaced by event.type (but not really needed) // 'text' can be replaced by $(this)[0].type ('textarea' here) (but not really needed) @@ -34,12 +36,14 @@ $(document).on("keyup change",".answer-item textarea:not([onkeyup]),.answer-item checkconditions($(this).val(), $(this).attr('name'), 'text', 'keyup') } }); +/* select/dropdown item */ $(document).on("change",".select-item select:not([onchange]),.dropdown-item select:not([onchange])",function(event){ checkconditions($(this).val(), $(this).attr('name'), 'select-one', 'change') //~ if($.isFunction(window.ExprMgr_process_relevance_and_tailoring )){ //~ ExprMgr_process_relevance_and_tailoring("onchange",$(this).attr("name"),"select-one"); //~ } }); +/* radio/button item */ $(document).on("change",".radio-item :radio:not([onclick]),.button-item :radio:not([onclick])",function(event){ checkconditions($(this).val(), $(this).attr('name'), 'radio', 'click') //~ $('#java'+$(this).attr("name")).val($(this).val()); @@ -47,9 +51,14 @@ $(document).on("change",".radio-item :radio:not([onclick]),.button-item :radio:n //~ ExprMgr_process_relevance_and_tailoring("click",$(this).attr("name"),"radio"); //~ } }); +/* checkbox item */ $(document).on("change",".checkbox-item :checkbox:not([onclick])",function(event){ checkconditions($(this).val(), $(this).attr('name'), 'checkbox', 'click') }); + +/** + * All EM function (see em_core_helper.php) + */ function LEMcount() { // takes variable number of arguments - returns count of those arguments that are not null/empty @@ -3174,29 +3183,3 @@ function time () { return Math.floor(new Date().getTime() / 1000); } -// updates the repeated headings in a dynamic table -function updateHeadings(tab, rep) -{ - tab.find('.repeat').remove(); - var header = tab.find('thead>tr'); - var trs = tab.find('tr:visible'); - trs.each(function(i, tr) - { - // add heading but not for the first and the last rows - if(i != 0 && i % rep == 0 && i != trs.length-1) - { - header.clone().addClass('repeat').addClass('headings').insertAfter(tr); - } - }); -} - -// updates the colors in a dynamic table -function updateColors(tab) -{ - $(tab).find('tr:not(.ls-heading):visible').each(function(i, tr) - { - console.log($(tr)); - // fix line colors - $(tr).removeClass('ls-odd ls-even').addClass(((i+1)%2 == 0) ? "ls-odd" : "ls-even"); - }); -}