~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/custom.js

  • Committer: Martin Albisetti
  • Date: 2008-07-17 04:20:22 UTC
  • mfrom: (128.10.33 loggerhead.search)
  • Revision ID: argentina@gmail.com-20080717042022-x0fw8v2jl5fq8hcr
Merge bzr-search integration

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var global_timeout_id = null;
 
2
var global_search_request = null;
 
3
 
 
4
window.addEvent('domready', function() 
 
5
{
 
6
    var search_box = $('q');
 
7
    search_box.addEvents(
 
8
    {
 
9
        keyup: function()
 
10
        {
 
11
            if($('q').value == '')
 
12
            {
 
13
                $('search_terms').setStyle('display','none');
 
14
            }
 
15
            else
 
16
            {
 
17
                    if (null != global_timeout_id)
 
18
                    {
 
19
                        clearTimeout(global_timeout_id);
 
20
                    }
 
21
                    global_timeout_id = setTimeout('$("q").fireEvent("search",$("q").value)',200);
 
22
            }
 
23
        },
 
24
 
 
25
        search: function(query)
 
26
        {
 
27
            url = global_path + 'search?query=' + query;
 
28
        
 
29
            if ($defined(global_search_request))
 
30
            {
 
31
                global_search_request.cancel();
 
32
            }
 
33
            global_search_request = new Request({'url':url,'method':'get','onComplete':cool_search});
 
34
            global_search_request.send('');
 
35
                var posicion = search_box.getPosition();
 
36
                var size     = search_box.getSize();
 
37
 
 
38
                $('search_terms').setStyle('position','absolute');
 
39
                $('search_terms').setStyle('left',posicion.x);
 
40
                $('search_terms').setStyle('top',posicion.y + size.y);
 
41
                $('search_terms').setStyle('display','block');
 
42
                $('search_terms').set('html','Loading...');
 
43
 
 
44
            new Request({'url':url,'method':'get','onComplete':cool_search}).send('');
 
45
 
 
46
 
 
47
        }
 
48
    });
 
49
});
 
50
 
 
51
function cool_search(response)
 
52
{
 
53
        var posicion = $('q').getPosition();
 
54
        var size     = $('q').getSize();
 
55
        $('search_terms').set('html',response);
 
56
        $('search_terms').setStyle('display','block');
 
57
        $('search_terms').setStyle('position','absolute');
 
58
        $('search_terms').setStyle('left',posicion.x);
 
59
        $('search_terms').setStyle('top',posicion.y + size.y);
 
60
}
 
61
 
 
62
function hide_search()
 
63
{
 
64
    hide_div = setTimeout("$('search_terms').setStyle('display','none')", 300);
 
65
}