summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--js/show_bug.js39
-rw-r--r--template/en/default/bug/edit.html.tmpl1
-rw-r--r--template/en/default/bug/field.html.tmpl1
-rw-r--r--template/en/default/bug/show-header.html.tmpl2
-rw-r--r--template/en/default/flag/list.html.tmpl1
5 files changed, 43 insertions, 1 deletions
diff --git a/js/show_bug.js b/js/show_bug.js
new file mode 100644
index 000000000..c762f9e54
--- /dev/null
+++ b/js/show_bug.js
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This Source Code Form is "Incompatible With Secondary Licenses", as
+ * defined by the Mozilla Public License, v. 2.0. */
+
+function getPreSelectedIndex(el) {
+ var options = el.options;
+ for (var i = 0, l = options.length; i < l; i++) {
+ var attributes = options[i].attributes;
+ for (var j = 0, m = attributes.length; j < m; j++) {
+ if (attributes[j].name == 'selected') {
+ return i;
+ }
+ }
+ }
+ return 0;
+}
+
+// Force the browser to honour the selected option when a page is refreshed,
+// but if the user hasn't explicitly selected a different option.
+YAHOO.util.Event.onDOMReady(function() {
+ 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) {
+ if (!el_dirty.value) {
+ el.selectedIndex = getPreSelectedIndex(el);
+ }
+ YAHOO.util.Event.on(el, "change", function(e) {
+ var el = e.target;
+ var preSelectedIndex = getPreSelectedIndex(el);
+ document.getElementById(el.name + '_dirty').value = preSelectedIndex == el.selectedIndex ? '' : '1';
+ });
+ }
+ }
+});
diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl
index aac50b7a4..a2a4300d6 100644
--- a/template/en/default/bug/edit.html.tmpl
+++ b/template/en/default/bug/edit.html.tmpl
@@ -1164,6 +1164,7 @@
<td>
[% IF bug.check_can_change_field(selname, 0, 1)
AND bug.choices.${selname}.size > 1 %]
+ <input type="hidden" id="[% selname %]_dirty">
<select id="[% selname %]" name="[% selname %]">
[% FOREACH x = bug.choices.${selname} %]
[% NEXT IF NOT x.is_active AND x.name != bug.${selname} %]
diff --git a/template/en/default/bug/field.html.tmpl b/template/en/default/bug/field.html.tmpl
index 4ed686248..2447a240e 100644
--- a/template/en/default/bug/field.html.tmpl
+++ b/template/en/default/bug/field.html.tmpl
@@ -97,6 +97,7 @@
</script>
[% CASE [ constants.FIELD_TYPE_SINGLE_SELECT
constants.FIELD_TYPE_MULTI_SELECT ] %]
+ <input type="hidden" id="[% field.name FILTER html %]_dirty">
<select id="[% field.name FILTER html %]"
name="[% field.name FILTER html %]"
[% IF field.type == constants.FIELD_TYPE_MULTI_SELECT %]
diff --git a/template/en/default/bug/show-header.html.tmpl b/template/en/default/bug/show-header.html.tmpl
index b93f3edf1..f71c2a22a 100644
--- a/template/en/default/bug/show-header.html.tmpl
+++ b/template/en/default/bug/show-header.html.tmpl
@@ -35,7 +35,7 @@
[% header = "$terms.Bug&nbsp;$bug.bug_id" %]
[% header_addl_info = "Last modified: $filtered_timestamp" %]
[% yui = ['autocomplete', 'calendar'] %]
-[% javascript_urls = [ "js/util.js", "js/field.js" ] %]
+[% javascript_urls = [ "js/util.js", "js/field.js", "js/show_bug.js" ] %]
[% IF bug.defined %]
[% unfiltered_title = "$terms.Bug $bug.bug_id – $bug.short_desc" %]
[% javascript = BLOCK %]
diff --git a/template/en/default/flag/list.html.tmpl b/template/en/default/flag/list.html.tmpl
index 2f0e1481a..e670515e0 100644
--- a/template/en/default/flag/list.html.tmpl
+++ b/template/en/default/flag/list.html.tmpl
@@ -118,6 +118,7 @@
[%- type.name FILTER html FILTER no_break -%]</label>
</td>
<td>
+ <input type="hidden" id="[% fid FILTER html %]_dirty">
<select id="[% fid FILTER html %]" name="[% fid FILTER html %]"
[% IF !flag && !((type.is_requestable && user.can_request_flag(type)) || user.can_set_flag(type)) %]
disabled="disabled"