From 0804583f3b19913ad79b5e70268a25fe6ce07408 Mon Sep 17 00:00:00 2001 From: "guy.pyrzak%gmail.com" <> Date: Sat, 1 Mar 2008 11:33:04 +0000 Subject: Bug 418895: Assignee and QA contact fields always become revealed (editable), The patch moves what used to be in one function to hide the qa and assignee into 2 separate calls. It also fixes some typos in the comments and adds my name to the committers list Patch By Guy Pyrzak r=mkanat, a=mkanat --- js/field.js | 96 +++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 18 deletions(-) (limited to 'js') diff --git a/js/field.js b/js/field.js index 4341a1543..04b80fc34 100644 --- a/js/field.js +++ b/js/field.js @@ -15,6 +15,7 @@ * Solved, Inc. All Rights Reserved. * * Contributor(s): Max Kanat-Alexander + * Guy Pyrzak */ /* This library assumes that the needed YUI libraries have been loaded @@ -140,9 +141,21 @@ function updateCalendarFromField(date_field) { 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) ); + 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 )); + YAHOO.util.Event.addListener(window, + 'load', + checkForChangedFieldValues, + new Array(container, + input, + field_id, + original_value + ) + ); } } @@ -178,11 +191,13 @@ function checkForChangedFieldValues(e, ContainerInputArray ) { var el = document.getElementById(ContainerInputArray[2]); var unhide = false; if ( el ) { - if ( el.value != ContainerInputArray[3] || ( el.value == "" && el.id != "alias") ) { + if ( el.value != ContainerInputArray[3] || + ( el.value == "" && el.id != "alias") ) { unhide = true; } else { - var set_default = document.getElementById("set_default_" + ContainerInputArray[2]); + var set_default = document.getElementById("set_default_" + + ContainerInputArray[2]); if ( set_default ) { if(set_default.checked){ unhide = true; @@ -199,34 +214,79 @@ function checkForChangedFieldValues(e, ContainerInputArray ) { 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); + 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); + 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 + ); } function showPeopleOnChange( field_id_list ) { for(var i = 0; i < field_id_list.length; i++) { - YAHOO.util.Event.addListener(field_id_list[i],'change', showEditableField, new Array('bz_qa_contact_edit_container', 'bz_qa_contact_input')); - YAHOO.util.Event.addListener(field_id_list[i],'change', showEditableField, new Array('bz_assignee_edit_container', 'bz_assignee_input')); + YAHOO.util.Event.addListener( field_id_list[i], + 'change', + showEditableField, + new Array('bz_qa_contact_edit_container', + 'bz_qa_contact_input' + ) + ); + YAHOO.util.Event.addListener( field_id_list[i], + 'change', + showEditableField, + new Array('bz_assignee_edit_container', + 'bz_assignee_input' + ) + ); } } function assignToDefaultOnChange(field_id_list) { showPeopleOnChange( field_id_list ); for(var i = 0; i < field_id_list.length; i++) { - YAHOO.util.Event.addListener(field_id_list[i],'change', setDefaultCheckbox, 'set_default_assignee' ); - YAHOO.util.Event.addListener(field_id_list[i],'change', setDefaultCheckbox, 'set_default_qa_contact' ); + YAHOO.util.Event.addListener( field_id_list[i], + 'change', + setDefaultCheckbox, + 'set_default_assignee' + ); + YAHOO.util.Event.addListener( field_id_list[i], + 'change', + setDefaultCheckbox, + 'set_default_qa_contact' + ); } } -function initAssignedQA(){ - YAHOO.util.Event.addListener('set_default_qa_contact','change', boldOnChange, 'set_default_qa_contact'); - YAHOO.util.Event.addListener('set_default_assignee','change', boldOnChange, 'set_default_assignee'); - YAHOO.util.Event.addListener(window, 'load', checkForChangedFieldValues, new Array( 'bz_assignee_edit_container', 'bz_assignee_input', 'set_default_assignee', '' ) ); - YAHOO.util.Event.addListener(window, 'load', checkForChangedFieldValues, new Array( 'bz_qa_contact_edit_container', 'bz_qa_contact_input', 'set_default_qa_contact', '' ) ); - YAHOO.util.Event.addListener(window, 'load', boldOnChange, 'set_default_assignee'); - YAHOO.util.Event.addListener(window, 'load', boldOnChange, 'set_default_qa_contact'); +function initDefaultCheckbox(field_id){ + YAHOO.util.Event.addListener( 'set_default_' + field_id, + 'change', boldOnChange, + 'set_default_' + field_id + ); + YAHOO.util.Event.addListener( window, + 'load', + checkForChangedFieldValues, + new Array( 'bz_' + field_id + '_edit_container', + 'bz_' + field_id + '_input', + 'set_default_' + field_id , + '1' + ) + ); + + YAHOO.util.Event.addListener( window, + 'load', + boldOnChange, + 'set_default_' + field_id + ); } function setDefaultCheckbox(e, field_id ) { -- cgit v1.2.3-24-g4f1b