~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2009-03-10 01:00:45 UTC
  • mto: This revision was merged to the branch mainline in revision 298.
  • Revision ID: mbp@sourcefrog.net-20090310010045-jfewn6fpuk1wngxw
This loggerhead will work with bzr 1.13

Show diffs side-by-side

added added

removed removed

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