From 46381d01b6e3e1b0143c3fe06224a86b9960d67f Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" <> Date: Mon, 28 Jan 2008 01:21:11 +0000 Subject: Bug 374020: Re-work the bug editing form to be more usable. Patch By Guy Pyrzak r=mkanat, a=mkanat --- js/field.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'js') diff --git a/js/field.js b/js/field.js index ca58329f4..164ce1c31 100644 --- a/js/field.js +++ b/js/field.js @@ -134,3 +134,60 @@ function updateCalendarFromField(date_field) { cal.render(); } } + + +/* Hide input fields and show the text with (edit) next to it */ +function hideEditableField( container, input, action, field_id, original_value ) { + YAHOO.util.Dom.setStyle(container, 'display', 'inline'); + YAHOO.util.Dom.setStyle(input, 'display', 'none'); + YAHOO.util.Event.addListener(action, 'click', showEditableField, new Array(container, input) ); + if(field_id != ""){ + YAHOO.util.Event.addListener(window, 'load', checkForChangedFieldValues, new Array(container, input, field_id, original_value )); + } +} + +/* showEditableField (e, ContainerInputArray) + * Function hides the (edit) link and the text and displays the input + * + * var e: the event + * var ContainerInputArray: An array containing the (edit) and text area and the input being displayed + * var ContainerInputArray[0]: the conainer that will be hidden usually shows the (edit) text + * var ContainerInputArray[1]: the input area and label that will be displayed + * + */ +function showEditableField (e, ContainerInputArray) { + YAHOO.util.Dom.setStyle(ContainerInputArray[0], 'display', 'none'); + YAHOO.util.Dom.setStyle(ContainerInputArray[1], 'display', 'inline'); + YAHOO.util.Event.preventDefault(e); +} + + +/* checkForChangedFieldValues(e, array ) + * Function checks if after the autocomplete by the browser if the values match the originals. + * If they don't match then hide the text and show the input so users don't get confused. + * + * var e: the event + * var ContainerInputArray: An array containing the (edit) and text area and the input being displayed + * var ContainerInputArray[0]: the conainer that will be hidden usually shows the (edit) text + * var ContainerInputArray[1]: the input area and label that will be displayed + * var ContainerInputArray[2]: the field that is on the page, might get changed by browser autocomplete + * var ContainerInputArray[3]: the original value from the page loading. + * + */ +function checkForChangedFieldValues(e, ContainerInputArray ) { + var el = document.getElementById(ContainerInputArray[2]); + if ( el ) { + if ( el.value != ContainerInputArray[3] || ( el.value == "" && el.id != "alias") ) { + YAHOO.util.Dom.setStyle(ContainerInputArray[0], 'display', 'none'); + YAHOO.util.Dom.setStyle(ContainerInputArray[1], 'display', 'inline'); + } + } +} + +function hideAliasAndSummary(short_desc_value, alias_value){ + // check the short desc field + hideEditableField( 'summary_alias_container', 'summary_alias_input', 'editme_action', 'short_desc', short_desc_value); + // check that the alias hasn't changed + bz_alias_check_array = new Array('summary_alias_container', 'summary_alias_input', 'alias', alias_value ) + YAHOO.util.Event.addListener( window, 'load', checkForChangedFieldValues, bz_alias_check_array); +} -- cgit v1.2.3-24-g4f1b