1
0
mirror of https://github.com/php/web-php.git synced 2026-04-23 06:58:14 +02:00
Files
archived-web-php/js/common.js
T
Hannes Magnusson 83301bce52 Merge in new styles from PROTOTYPE_2010
(not includes/used anywhere yet)
2010-12-26 16:11:06 +00:00

61 lines
1.6 KiB
JavaScript

$(document).ready(function() {
// fade in/out mega drop-downs.
$("#headmenu li:has(div.children)").hoverIntent({
interval: 100,
timeout: 200,
over: function(){$(this).find("div.children").fadeIn(250);},
out: function(){$(this).find("div.children").fadeOut(250);}
});
// remove default search text on focus.
$('#headsearch-keywords').focus(function(){
if ($(this).attr("value") == getDefaultSearchText()) {
$(this).attr("value", "");
}
}).blur(function(){
if (!$(this).attr("value")) {
$(this).attr("value", getDefaultSearchText());
}
});
// load the search index and enable auto-complete.
jQuery.getScript("/js/search-index-" + getLanguage() + ".js", function(){
$('#headsearch-keywords').autocomplete(searchIndex, {
matchContains: true,
scrollHeight: 240,
formatItem: function(item) {
return item.name;
}
}).result(
function(event, item){
alert("User selected: " + item['name'] + "\n" +
"Direct user to: " + item['page']);
window.location = '/manual/' + getLanguage() + '/' + item['page'];
}
);
});
});
/**
* Get the default search text to use (e.g. 'Search...').
*/
function getDefaultSearchText()
{
switch (getLanguage()) {
case "en":
return "Search...";
}
}
/**
* Determine what language to present to the user.
*
* @todo make this detect the user's language.
*/
function getLanguage()
{
return "en";
}