Commit 493903a3 authored by Byron Jones's avatar Byron Jones

Bug 686422: Fix custom search's history interaction on HTML4 browsers

r=mkanat, a=mkanat
parent acae816c
......@@ -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.
......
Copyright (c) 2011, Benjamin Arthur Lupton
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
• Neither the name of Benjamin Arthur Lupton nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
History.js (v1.7.1 - October 4 2011)
http://github.com/balupton/history.js
......@@ -74,7 +74,11 @@
TUI_alternates['custom_search_advanced'] = "Show Advanced Features";
TUI_hide_default('custom_search_advanced');
</script>
<script type="text/javascript" src="js/custom-search.js"></script>
<script type="text/javascript" src="[% 'js/custom-search.js' FILTER mtime %]"></script>
<script type="text/javascript" src="[% 'js/history.js/native.history.js' FILTER mtime %]"></script>
<script type="text/javascript">
redirect_html4_browsers();
</script>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment