2010-07-01 03:20:59 +00:00
|
|
|
jQuery(function() {
|
|
|
|
$('body > header span').click(function() {
|
|
|
|
$('#menu').slideToggle('normal');
|
|
|
|
})
|
2010-03-03 20:47:41 +00:00
|
|
|
|
2010-07-01 03:20:59 +00:00
|
|
|
/*** Article Search ***/
|
|
|
|
function reset_search() {
|
|
|
|
console.log("restoring items");
|
|
|
|
$('#articles li').css({height: 'auto', opacity: 1.0});
|
|
|
|
}
|
2010-03-03 20:47:41 +00:00
|
|
|
|
2010-07-06 22:21:38 +00:00
|
|
|
function refresh_search(elem) {
|
2010-07-08 22:23:59 +00:00
|
|
|
var input = $(elem);
|
2010-07-01 03:20:59 +00:00
|
|
|
var value = input.val() || "";
|
2010-03-03 20:47:41 +00:00
|
|
|
|
2010-07-01 03:20:59 +00:00
|
|
|
var q = value.toLowerCase();
|
2010-07-06 22:21:38 +00:00
|
|
|
$('#articles li').each(function(i) {
|
2010-07-01 03:20:59 +00:00
|
|
|
var article = $(this);
|
2010-07-06 22:21:38 +00:00
|
|
|
var style;
|
|
|
|
if(article.text().toLowerCase().indexOf(q) >= 0) {
|
|
|
|
style = {height: 'show', opacity: 1.0}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
style = {height: 'hide', opacity: 0}
|
|
|
|
}
|
|
|
|
if(article.css('opacity') != style.opacity) article.animate(style, {queue: false, duration: 500});
|
|
|
|
});
|
2010-07-01 03:20:59 +00:00
|
|
|
}
|
|
|
|
|
2010-07-06 22:21:38 +00:00
|
|
|
var input = $('#search input');
|
|
|
|
if(input.length > 0) {
|
|
|
|
// Setup incremental search on Articles pages
|
2010-07-10 04:14:25 +00:00
|
|
|
if('onsearch' in input.get(0)) {
|
2010-07-06 22:21:38 +00:00
|
|
|
console.log("Using search event for search");
|
2010-07-07 07:58:40 +00:00
|
|
|
$('#search label').hide();
|
2010-07-08 22:23:59 +00:00
|
|
|
input.bind("search", function() { refresh_search(this) });
|
2010-07-06 22:21:38 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Poll the field for its value while it has focus
|
|
|
|
console.log("Using poll mode for search");
|
|
|
|
|
|
|
|
var last_value;
|
|
|
|
input.focus(function() {
|
|
|
|
last_value = input.val();
|
|
|
|
input.everyTime('500ms', function() {
|
|
|
|
if(input.val() != last_value) {
|
|
|
|
refresh_search(input);
|
|
|
|
last_value = input.val();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}).blur(function() {
|
|
|
|
input.stopTime();
|
|
|
|
});
|
|
|
|
}
|
2010-07-07 07:58:40 +00:00
|
|
|
input.val('');
|
2010-07-06 22:21:38 +00:00
|
|
|
}
|
2010-07-07 07:58:40 +00:00
|
|
|
$('#search').show();
|
2010-07-06 22:21:38 +00:00
|
|
|
});
|
2010-07-01 03:20:59 +00:00
|
|
|
|