summaryrefslogtreecommitdiffstats
path: root/js/field.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/field.js')
-rw-r--r--js/field.js81
1 files changed, 70 insertions, 11 deletions
diff --git a/js/field.js b/js/field.js
index 07433b2a5..85aa12ca0 100644
--- a/js/field.js
+++ b/js/field.js
@@ -255,6 +255,8 @@ function showEditableField (e, ContainerInputArray) {
inputs.push(document.getElementById(ContainerInputArray[2]));
} else {
inputs = inputArea.getElementsByTagName('input');
+ if ( inputs.length == 0 )
+ inputs = inputArea.getElementsByTagName('textarea');
}
if ( inputs.length > 0 ) {
// Change the first field's value to ContainerInputArray[2]
@@ -288,7 +290,7 @@ function showEditableField (e, ContainerInputArray) {
*
* 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[0]: the container 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.
@@ -299,7 +301,7 @@ function checkForChangedFieldValues(e, ContainerInputArray ) {
var unhide = false;
if ( el ) {
if ( el.value != ContainerInputArray[3] ||
- ( el.value == "" && el.id != "alias") ) {
+ ( el.value == "" && el.id != "alias" && el.id != "qa_contact" ) ) {
unhide = true;
}
else {
@@ -341,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]);
}
}
@@ -444,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 ) {
@@ -699,7 +707,8 @@ YAHOO.bugzilla.userAutocomplete = {
id : YAHOO.bugzilla.userAutocomplete.counter,
params : [ {
match : [ decodeURIComponent(enteredText) ],
- include_fields : [ "name", "real_name" ]
+ include_fields : [ "name", "real_name" ],
+ include_disabled : 1
} ]
};
var stringified = YAHOO.lang.JSON.stringify(json_object);
@@ -714,9 +723,11 @@ YAHOO.bugzilla.userAutocomplete = {
},
debug_helper : function ( ){
/* used to help debug any errors that might happen */
+ /*
if( typeof(console) !== 'undefined' && console != null && arguments.length > 0 ){
console.log("debug helper info:", arguments);
}
+ */
return true;
},
init_ds : function(){
@@ -792,3 +803,51 @@ YAHOO.bugzilla.keywordAutocomplete = {
});
}
};
+
+/**
+ * Force the browser to honour the selected option when a page is refreshed,
+ * but only if the user hasn't explicitly selected a different option.
+ */
+function initDirtyFieldTracking() {
+ // old IE versions don't provide the information we need to make this fix work
+ // however they aren't affected by this issue, so it's ok to ignore them
+ if (YAHOO.env.ua.ie > 0 && YAHOO.env.ua.ie <= 8) return;
+ var selects = document.getElementById('changeform').getElementsByTagName('select');
+ for (var i = 0, l = selects.length; i < l; i++) {
+ var el = selects[i];
+ var el_dirty = document.getElementById(el.name + '_dirty');
+ if (!el_dirty) continue;
+ if (!el_dirty.value) {
+ var preSelected = bz_preselectedOptions(el);
+ if (!el.multiple) {
+ preSelected.selected = true;
+ } else {
+ el.selectedIndex = -1;
+ for (var j = 0, m = preSelected.length; j < m; j++) {
+ preSelected[j].selected = true;
+ }
+ }
+ }
+ YAHOO.util.Event.on(el, "change", function(e) {
+ var el = e.target || e.srcElement;
+ var preSelected = bz_preselectedOptions(el);
+ var currentSelected = bz_selectedOptions(el);
+ var isDirty = false;
+ if (!el.multiple) {
+ isDirty = preSelected.index != currentSelected.index;
+ } else {
+ if (preSelected.length != currentSelected.length) {
+ isDirty = true;
+ } else {
+ for (var i = 0, l = preSelected.length; i < l; i++) {
+ if (currentSelected[i].index != preSelected[i].index) {
+ isDirty = true;
+ break;
+ }
+ }
+ }
+ }
+ document.getElementById(el.name + '_dirty').value = isDirty ? '1' : '';
+ });
+ }
+}