summaryrefslogtreecommitdiffstats
path: root/js/custom-search.js
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2011-11-29 19:38:42 +0100
committerByron Jones <bjones@mozilla.com>2011-11-29 19:38:42 +0100
commit493903a3f7c2d0e573f57319d6afa840f4051c0c (patch)
tree4dbe3fef6d798668fa7e7786a70e3aa116460990 /js/custom-search.js
parentacae816ceccc6cd6bdbc6c73e973d1bcd502db9b (diff)
downloadbugzilla-493903a3f7c2d0e573f57319d6afa840f4051c0c.tar.gz
bugzilla-493903a3f7c2d0e573f57319d6afa840f4051c0c.tar.xz
Bug 686422: Fix custom search's history interaction on HTML4 browsers
r=mkanat, a=mkanat
Diffstat (limited to 'js/custom-search.js')
-rw-r--r--js/custom-search.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/js/custom-search.js b/js/custom-search.js
index 394e0eb32..0ee7d2488 100644
--- a/js/custom-search.js
+++ b/js/custom-search.js
@@ -140,14 +140,29 @@ function custom_search_close_paren() {
// using the query string, which query.cgi can read to re-create the page
// exactly as the user had it before.
function fix_query_string(form_member) {
- if (!(window.history && window.history.replaceState))
+ // window.History comes from history.js.
+ // It falls back to the normal window.history object for HTML5 browsers.
+ if (!(window.History && window.History.replaceState))
return;
var form = YAHOO.util.Dom.getAncestorByTagName(form_member, 'form');
var query = YAHOO.util.Connect.setForm(form);
- window.history.replaceState(null, document.title, '?' + query);
+ window.History.replaceState(null, document.title, '?' + query);
}
+// Browsers that do not support HTML5's history.replaceState gain an emulated
+// version via history.js, with the full query_string in the location's hash.
+// We rewrite the URL to include the hash and redirect to the new location,
+// which causes custom search fields to work.
+function redirect_html4_browsers() {
+ var hash = document.location.hash;
+ if (hash == '') return;
+ hash = hash.substring(1);
+ if (hash.substring(0, 10) != 'query.cgi?') return;
+ var url = document.location + "";
+ url = url.substring(0, url.indexOf('query.cgi#')) + hash;
+ document.location = url;
+}
function _cs_fix_ids(parent, preserve_values) {
// Update the label of the checkbox.