Commit 968f256a authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

Fix bug with highlight (error) and unhighlight (ok) parameters.

parent 74a34af4
......@@ -19,6 +19,16 @@
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
var get_parent_with_class = function( $element, selected_class ) {
if( $element.parent() == null || $element.parent().is("html") ){
return null ;
} else if( $element.parent().hasClass(selected_class) ){
return $element.parent() ;
} else {
return get_parent_with_class( $element.parent(), selected_class );
}
}
$.validator.setDefaults({
highlight: function (element, errorClass, validClass) {
var $element;
......@@ -27,18 +37,12 @@
} else {
$element = $(element);
}
$element.parent().parent().parent().parent().parent("div.form-group").removeClass(validClass).addClass(errorClass);
$element.parent().parent().parent("div.form-group").removeClass(validClass).addClass(errorClass);
$element.parent().parent("div.form-group").removeClass(validClass).addClass(errorClass);
// if it's a calendar
if ($element.parent("div.input-group").find(".btn").length > 0) {
$element.parent("div.input-group").find(".btn").addClass("btn-danger");
}
// if it's an inputfile
if ($element.parent("div.input-group").parent("div.input-group").find(".btn-group").length > 0) {
$element.parent("div.input-group").parent("div.input-group").find(".btn").addClass("btn-danger");
var $parent = get_parent_with_class($element, "param-field");
if( $parent != null ) {
$parent.removeClass(validClass).addClass(errorClass);
buttons = $parent.find(".btn").addClass("btn-danger");
}
},
unhighlight: function (element, errorClass, validClass) {
var $element;
......@@ -47,16 +51,11 @@
} else {
$element = $(element);
}
$element.parent().parent().parent().parent().parent("div.form-group").removeClass(errorClass).addClass(validClass);
$element.parent().parent().parent("div.form-group").removeClass(errorClass).addClass(validClass);
$element.parent().parent("div.form-group").removeClass(errorClass).addClass(validClass);
// if it's a calendar
if ($element.parent("div.input-group").find(".btn").length > 0) {
$element.parent("div.input-group").find(".btn").removeClass("btn-danger");
}
// if it's an inputfile
if ($element.parent("div.input-group").parent("div.input-group").find(".btn-group").length > 0) {
$element.parent("div.input-group").parent("div.input-group").find(".btn").removeClass("btn-danger");
var $parent = get_parent_with_class($element, "param-field");
if( $parent != null ) {
$parent.removeClass(errorClass).addClass(validClass);
buttons = $parent.find(".btn").removeClass("btn-danger");
}
},
errorPlacement: function(error, element) {
......@@ -663,7 +662,7 @@ jQuery.validator.addMethod("mparam", function(value, element, params) {
' {{each(index, param) workflow.parameters_per_groups[group]}}',
// it the parameter has not already been settled
' {{if Object.keys(parameters).indexOf(param.name) == -1 }}',
' <div class="form-group">',
' <div class="form-group param-field">',
' {{if group != "default" && group.indexOf("exclude-") != 0 && index == 0}}',
' <legend>${param.group}</legend>',
' {{/if}}',
......@@ -673,15 +672,17 @@ jQuery.validator.addMethod("mparam", function(value, element, params) {
' {{if param.type == "MultipleParameters"}}',
' <blockquote style="font-size:14px;">',
' {{each(spindex, sub_param) param.sub_parameters}}',
' {{if sub_param.type == "bool"}}',
' {{html getParameterDisplay(sub_param, parameterTemplate, sub_param.display_name)}}',
' {{else}}',
' <div class="input-group">',
' <span class="input-group-addon">${sub_param.display_name}</span>',
' {{html getParameterDisplay(sub_param, parameterTemplate)}}',
' <div class="param-field">',
' {{if sub_param.type == "bool"}}',
' {{html getParameterDisplay(sub_param, parameterTemplate, sub_param.display_name)}}',
' {{else}}',
' <div class="input-group">',
' <span class="input-group-addon">${sub_param.display_name}</span>',
' {{html getParameterDisplay(sub_param, parameterTemplate)}}',
' </div>',
' {{/if}}',
' <span class="help-block">${sub_param.help}</span> <br />',
' </div>',
' {{/if}}',
' <span class="help-block">${sub_param.help}</span> <br />',
' {{/each}}',
' </blockquote>',
' {{else}}',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment