From 0b7ca5cd29d9fae16326eb059caf75dc54876155 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 4 Oct 2012 13:29:07 +0800 Subject: Bug 713796: "Reset Assignee to default" and "Reset QA Contact to default" should only be checked when the assignee/qa-contact is the default --- js/field.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'js') diff --git a/js/field.js b/js/field.js index a17fbbb3a..d42fb0c63 100644 --- a/js/field.js +++ b/js/field.js @@ -343,13 +343,19 @@ function showPeopleOnChange( field_id_list ) { } } -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'); +function assignToDefaultOnChange(field_id_list, default_assignee, default_qa_contact) { + showPeopleOnChange(field_id_list); + for(var i = 0, l = field_id_list.length; i < l; i++) { + YAHOO.util.Event.addListener(field_id_list[i], 'change', function(evt, defaults) { + if (document.getElementById('assigned_to').value == defaults[0]) { + setDefaultCheckbox(evt, 'set_default_assignee'); + } + if (document.getElementById('qa_contact') + && document.getElementById('qa_contact').value == defaults[1]) + { + setDefaultCheckbox(evt, 'set_default_qa_contact'); + } + }, [default_assignee, default_qa_contact]); } } @@ -446,7 +452,7 @@ function setResolutionToDuplicate(e, duplicate_or_move_bug_status) { YAHOO.util.Event.preventDefault(e); } -function setDefaultCheckbox(e, field_id ) { +function setDefaultCheckbox(e, field_id) { var el = document.getElementById(field_id); var elLabel = document.getElementById(field_id + "_label"); if( el && elLabel ) { -- cgit v1.2.3-24-g4f1b