1
0
Fork 0
forked from wezm/wezm.net
wezm.net/output/js/application.js

48 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

jQuery(function() {
$('body > header span').click(function() {
$('#menu').slideToggle('normal');
})
2010-03-03 20:47:41 +00:00
/*** Article Search ***/
function reset_search() {
$('#articles li').css({height: 'auto', opacity: 1.0});
}
2010-03-03 20:47:41 +00:00
function refresh_search(elem) {
2010-07-08 22:23:59 +00:00
var input = $(elem);
var value = input.val() || "";
2010-03-03 20:47:41 +00:00
var q = value.toLowerCase();
$('#articles li').each(function(i) {
var article = $(this);
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});
});
}
var input = $('#search input');
if(input.length > 0) {
2010-07-12 22:02:36 +00:00
// Poll the field for its value while it has focus
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();
}
});
2010-07-12 22:02:36 +00:00
}).blur(function() {
input.stopTime();
});
input.val('');
}
$('#search').show();
2010-08-04 02:53:43 +00:00
});