From 7bb7a94fbc5c49ae06270057e50edbfc55839967 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 6 Jun 2019 12:58:47 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B02291=20-=20Fix=20blinking=20of=20warning?= =?UTF-8?q?=20image=20on=20mandatory=20HTML=20field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 2 +- js/forms-json-utils.js | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index c8cb4760f..e0a7baac7 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -2103,7 +2103,7 @@ EOF $('#{$iId}_console_form').console_form_handler('alignColumns'); $('#{$iId}_console_form').console_form_handler('option', 'field_set', $('#{$iId}_field_set')); // field_change must be processed to refresh the hidden value at anytime - $('#{$iId}_console_form').bind('value_change', function() { $('#{$iId}').val(JSON.stringify($('#{$iId}_field_set').triggerHandler('get_current_values'))); console.error($('#{$iId}').val()); }); + $('#{$iId}_console_form').bind('value_change', function() { $('#{$iId}').val(JSON.stringify($('#{$iId}_field_set').triggerHandler('get_current_values'))); }); // Initialize the hidden value with current state // update_value is triggered when preparing the wizard helper object for ajax calls $('#{$iId}').bind('update_value', function() { $(this).val(JSON.stringify($('#{$iId}_field_set').triggerHandler('get_current_values'))); }); diff --git a/js/forms-json-utils.js b/js/forms-json-utils.js index add2ace78..60ebf6416 100644 --- a/js/forms-json-utils.js +++ b/js/forms-json-utils.js @@ -200,11 +200,16 @@ function ReportFieldValidationStatus(sFieldId, sFormId, bValid, sExplain) // Let's remember the first input with an error, so that we can put back the focus on it later oFormErrors['input_'+sFormId] = sFieldId; } - // Visual feedback - $('#v_'+sFieldId).html(''); - //Avoid replacing exisiting tooltip for periodically checked element (like CKeditor fields) + + if ($('#v_'+sFieldId+' img').length == 0) + { + $('#v_'+sFieldId).html(''); + } + //Avoid replacing exisiting tooltip for periodically checked element (like CKeditor fields) if($('#v_'+sFieldId).tooltip( "instance" ) === undefined) { + // Visual feedback + $('#v_'+sFieldId).tooltip({ items: 'span', tooltipClass: 'form_field_error', @@ -343,8 +348,13 @@ function ValidateCKEditField(sFieldId, sPattern, bMandatory, sFormId, nullValue, ReportFieldValidationStatus(sFieldId, sFormId, bValid, sExplain); - // We need to check periodically as CKEditor doesn't trigger our events. More details in UIHTMLEditorWidget::Display() @ line 92 - setTimeout(function(){ValidateCKEditField(sFieldId, sPattern, bMandatory, sFormId, nullValue, originalValue);}, 500); + if ($('#'+sFieldId).data('timeout_validate') == undefined) { + // We need to check periodically as CKEditor doesn't trigger our events. More details in UIHTMLEditorWidget::Display() @ line 92 + var iTimeoutValidate = setInterval(function () { + ValidateCKEditField(sFieldId, sPattern, bMandatory, sFormId, nullValue, originalValue); + }, 500); + $('#'+sFieldId).data('timeout_validate', iTimeoutValidate); + } } /*