~automne-team/automne/demo-fr

« back to all changes in this revision

Viewing changes to js/modules/pnews/pnews-demo.js

  • Committer: sebastien
  • Date: 2010-06-10 16:02:31 UTC
  • Revision ID: sebastien.pauchet@ws-interactive.fr-20100610160231-mlw00lg9u07bve8j
Tags: v4_0_2
Initial import of Demo FR for Automne 4.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
$(document).ready(function(){
 
2
        var getSearch = function  () {
 
3
                if ($('#keyword').val() && $('#keyword').val().length < 3) {
 
4
                        return false;
 
5
                }
 
6
                $.ajax({
 
7
                        type:           "GET",
 
8
                        url:            pageURL,
 
9
                        data:           'out=xml&cat=' + $('#cat').val() + '&keyword=' + $('#keyword').val(),
 
10
                        success:        displaySearch
 
11
                });
 
12
                return true;
 
13
        }
 
14
        var getPage = function  (e) {
 
15
                var href = $(e.target).is('a') ? $(e.target).attr("href") : $(e.target).parent('a').attr("href");
 
16
                if (href) {
 
17
                        e.preventDefault();
 
18
                        $.ajax({
 
19
                                type:           "GET",
 
20
                                url:            href,
 
21
                                data:           'out=xml',
 
22
                                success:        displaySearch
 
23
                        });
 
24
                        return false;
 
25
                }
 
26
                return true;
 
27
        }
 
28
        var displaySearch = function  (xmlcontent) {
 
29
                if (xmlcontent.getElementsByTagName('data').length > 0) {
 
30
                        $('#searchresult').html(xmlcontent.getElementsByTagName('data').item(0).firstChild.nodeValue);
 
31
                        if ($('#pages')) {
 
32
                                $('#pages a').click(getPage);
 
33
                        }
 
34
                }
 
35
                return true;
 
36
        }
 
37
        $("#loadingSearch").ajaxStart(function(){
 
38
                $(this).show();
 
39
        });
 
40
        $("#loadingSearch").ajaxStop(function(){
 
41
                $(this).hide();
 
42
        });
 
43
        
 
44
        $('#submitSearch').hide();
 
45
        $('#keyword').keyup(getSearch);
 
46
        $('#cat').change(getSearch);
 
47
        if ($('#pages')) {
 
48
                $('#pages a').click(getPage);
 
49
        }
 
50
});
 
 
b'\\ No newline at end of file'