am c1828d5a: Merge change 3583 into donut
Merge commit 'c1828d5a492a14a9b15e9106684079049317313e' into eclair * commit 'c1828d5a492a14a9b15e9106684079049317313e': implement browser history for tabbed search results...
This commit is contained in:
@@ -1,99 +1,136 @@
|
|||||||
page.title=Search Results
|
page.title=Search Results
|
||||||
@jd:body
|
@jd:body
|
||||||
|
|
||||||
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
|
||||||
<script src="{@docRoot}assets/jquery-history.js" type="text/javascript"></script>
|
<script src="/assets/jquery-history.js" type="text/javascript"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
google.load('search', '1');
|
var tabIndex = 0;
|
||||||
|
|
||||||
function OnLoad() {
|
google.load('search', '1');
|
||||||
document.getElementById("search_autocomplete").style.color = "#000";
|
|
||||||
|
function OnLoad() {
|
||||||
// create search control
|
document.getElementById("search_autocomplete").style.color = "#000";
|
||||||
searchControl = new google.search.SearchControl();
|
|
||||||
|
// create search control
|
||||||
// use our existing search form and use tabs when multiple searchers are used
|
searchControl = new google.search.SearchControl();
|
||||||
drawOptions = new google.search.DrawOptions();
|
|
||||||
drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
|
// use our existing search form and use tabs when multiple searchers are used
|
||||||
drawOptions.setInput(document.getElementById("search_autocomplete"));
|
drawOptions = new google.search.DrawOptions();
|
||||||
|
drawOptions.setDrawMode(google.search.SearchControl.DRAW_MODE_TABBED);
|
||||||
// configure search result options
|
drawOptions.setInput(document.getElementById("search_autocomplete"));
|
||||||
searchOptions = new google.search.SearcherOptions();
|
|
||||||
searchOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
|
// configure search result options
|
||||||
|
searchOptions = new google.search.SearcherOptions();
|
||||||
// configure each of the searchers, for each tab
|
searchOptions.setExpandMode(GSearchControl.EXPAND_MODE_OPEN);
|
||||||
devSiteSearcher = new google.search.WebSearch();
|
|
||||||
devSiteSearcher.setUserDefinedLabel("All Developers Site");
|
// configure each of the searchers, for each tab
|
||||||
devSiteSearcher.setSiteRestriction("http://developer.android.com/");
|
devSiteSearcher = new google.search.WebSearch();
|
||||||
|
devSiteSearcher.setUserDefinedLabel("All Developers Site");
|
||||||
devGuideSearcher = new google.search.WebSearch();
|
devSiteSearcher.setSiteRestriction("http://developer.android.com/");
|
||||||
devGuideSearcher.setUserDefinedLabel("Dev Guide");
|
|
||||||
devGuideSearcher.setSiteRestriction("http://developer.android.com/guide/");
|
devGuideSearcher = new google.search.WebSearch();
|
||||||
|
devGuideSearcher.setUserDefinedLabel("Dev Guide");
|
||||||
referenceSearcher = new google.search.WebSearch();
|
devGuideSearcher.setSiteRestriction("http://developer.android.com/guide/");
|
||||||
referenceSearcher.setUserDefinedLabel("Reference");
|
|
||||||
referenceSearcher.setSiteRestriction("http://developer.android.com/reference/");
|
referenceSearcher = new google.search.WebSearch();
|
||||||
|
referenceSearcher.setUserDefinedLabel("Reference");
|
||||||
blogSearcher = new google.search.WebSearch();
|
referenceSearcher.setSiteRestriction("http://developer.android.com/reference/");
|
||||||
blogSearcher.setUserDefinedLabel("Blog");
|
|
||||||
blogSearcher.setSiteRestriction("http://android-developers.blogspot.com");
|
blogSearcher = new google.search.WebSearch();
|
||||||
|
blogSearcher.setUserDefinedLabel("Blog");
|
||||||
groupsSearcher = new google.search.WebSearch();
|
blogSearcher.setSiteRestriction("http://android-developers.blogspot.com");
|
||||||
groupsSearcher.setUserDefinedLabel("Developer Groups");
|
|
||||||
groupsSearcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");
|
groupsSearcher = new google.search.WebSearch();
|
||||||
|
groupsSearcher.setUserDefinedLabel("Developer Groups");
|
||||||
sourceSiteSearcher = new google.search.WebSearch();
|
groupsSearcher.setSiteRestriction("001283715400630100512:ggqrtvkztwm");
|
||||||
sourceSiteSearcher.setUserDefinedLabel("Android Source");
|
|
||||||
sourceSiteSearcher.setSiteRestriction("http://source.android.com");
|
sourceSiteSearcher = new google.search.WebSearch();
|
||||||
|
sourceSiteSearcher.setUserDefinedLabel("Android Source");
|
||||||
homeSiteSearcher = new google.search.WebSearch();
|
sourceSiteSearcher.setSiteRestriction("http://source.android.com");
|
||||||
homeSiteSearcher.setUserDefinedLabel("Android Home");
|
|
||||||
homeSiteSearcher.setSiteRestriction("http://www.android.com");
|
homeSiteSearcher = new google.search.WebSearch();
|
||||||
|
homeSiteSearcher.setUserDefinedLabel("Android Home");
|
||||||
// add each searcher to the search control
|
homeSiteSearcher.setSiteRestriction("http://www.android.com");
|
||||||
searchControl.addSearcher(devSiteSearcher, searchOptions);
|
|
||||||
searchControl.addSearcher(devGuideSearcher, searchOptions);
|
// add each searcher to the search control
|
||||||
searchControl.addSearcher(referenceSearcher, searchOptions);
|
searchControl.addSearcher(devSiteSearcher, searchOptions);
|
||||||
searchControl.addSearcher(groupsSearcher, searchOptions);
|
searchControl.addSearcher(devGuideSearcher, searchOptions);
|
||||||
searchControl.addSearcher(sourceSiteSearcher, searchOptions);
|
searchControl.addSearcher(referenceSearcher, searchOptions);
|
||||||
searchControl.addSearcher(blogSearcher, searchOptions);
|
searchControl.addSearcher(groupsSearcher, searchOptions);
|
||||||
|
searchControl.addSearcher(sourceSiteSearcher, searchOptions);
|
||||||
// configure result options
|
searchControl.addSearcher(blogSearcher, searchOptions);
|
||||||
searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
|
|
||||||
searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
|
// configure result options
|
||||||
searchControl.setTimeoutInterval(google.search.SearchControl.TIMEOUT_LONG);
|
searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
|
||||||
searchControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING);
|
searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
|
||||||
|
searchControl.setTimeoutInterval(google.search.SearchControl.TIMEOUT_LONG);
|
||||||
// upon ajax search, refresh the url and search title
|
searchControl.setNoResultsString(google.search.SearchControl.NO_RESULTS_DEFAULT_STRING);
|
||||||
searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
|
|
||||||
$("#searchTitle").html("search results for <em>" + query + "</em>");
|
// upon ajax search, refresh the url and search title
|
||||||
$.history.add('q=' + query); // add the current query to the browser history
|
searchControl.setSearchStartingCallback(this, function(control, searcher, query) {
|
||||||
});
|
// save the tab index from the hash
|
||||||
|
tabIndex = location.hash.split("&t=")[1];
|
||||||
// draw the search results box
|
|
||||||
searchControl.draw(document.getElementById("leftSearchControl"), drawOptions);
|
$("#searchTitle").html("search results for <em>" + query + "</em>");
|
||||||
|
$.history.add('q=' + query + '&t=' + tabIndex);
|
||||||
// execute a search upon page load, from url hash query
|
openTab();
|
||||||
if (location.href.indexOf("#q=") != -1) {
|
});
|
||||||
url = location.href.split("#q=");
|
|
||||||
searchControl.execute(decodeURI(url[1]));
|
// draw the search results box
|
||||||
}
|
searchControl.draw(document.getElementById("leftSearchControl"), drawOptions);
|
||||||
document.getElementById("search_autocomplete").focus();
|
|
||||||
}
|
// get query and execute the search
|
||||||
|
if (location.hash.indexOf("&t=") != -1) {
|
||||||
google.setOnLoadCallback(OnLoad, true);
|
searchControl.execute(decodeURI(getQuery(location.hash)));
|
||||||
|
}
|
||||||
// when an event on the browser history occurs (back, forward, load) perform a search
|
|
||||||
$(window).history(function(e, hash) {
|
document.getElementById("search_autocomplete").focus();
|
||||||
hashParts = hash.split('=');
|
addTabListeners();
|
||||||
searchControl.execute(decodeURI(hashParts[1]));
|
}
|
||||||
$("#searchTitle").html("search results for <em>" + decodeURI(hashParts[1]) + "</em>");
|
// End of OnLoad
|
||||||
});
|
|
||||||
|
|
||||||
// forcefully regain key-up event control (previously jacked by search api)
|
google.setOnLoadCallback(OnLoad, true);
|
||||||
$("#search_autocomplete").keyup(function(event) {
|
|
||||||
return search_changed(event, false, '/');
|
// when an event on the browser history occurs (back, forward, load) perform a search
|
||||||
});
|
$(window).history(function(e, hash) {
|
||||||
|
var query = getQuery(hash);
|
||||||
|
searchControl.execute(query);
|
||||||
|
$("#searchTitle").html("search results for <em>" + decodeURI(query) + "</em>");
|
||||||
|
});
|
||||||
|
|
||||||
|
// forcefully regain key-up event control (previously jacked by search api)
|
||||||
|
$("#search_autocomplete").keyup(function(event) {
|
||||||
|
return search_changed(event, false, '/');
|
||||||
|
});
|
||||||
|
|
||||||
|
// open a tab, specified by its array position
|
||||||
|
function openTab() {
|
||||||
|
tabIndex = location.hash.split("&t=")[1];
|
||||||
|
|
||||||
|
// show the appropriate tab
|
||||||
|
var tabHeaders = $(".gsc-tabHeader");
|
||||||
|
$(tabHeaders[tabIndex]).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add event listeners to each tab so we can track the browser history
|
||||||
|
function addTabListeners() {
|
||||||
|
var tabHeaders = $(".gsc-tabHeader");
|
||||||
|
for (var i = 0; i < tabHeaders.length; i++) {
|
||||||
|
$(tabHeaders[i]).attr("id",i).click(function() {
|
||||||
|
var tabHeaders = $(".gsc-tabHeader");
|
||||||
|
var tabIndex = $(this).attr("id");
|
||||||
|
$.history.add('q=' + getQuery(location.hash) + '&t=' + tabIndex); // update the hash with the new tab
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getQuery(hash) {
|
||||||
|
var hashParts = hash.split('&t=');
|
||||||
|
var queryParts = hashParts[0].split('=');
|
||||||
|
return queryParts[1];
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="mainBodyFixed" style="width:auto; margin:20px">
|
<div id="mainBodyFixed" style="width:auto; margin:20px">
|
||||||
|
|||||||
Reference in New Issue
Block a user