Subversion-Projekte lars-tiefland.shop_ns

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
5 lars 1
function suggest(inputString) {
2
    $('#suchbegriff').keyup(function(event) {
3
        if(event.keyCode != 40 && event.keyCode != 38) {
4
            if($('#suchbegriff').val().length < 1) {
5
                $('#suchbegriffs_liste').hide();
6
            } else {
7
                inputString = $('#suchbegriff').val();
8
                $.post("/autosuggest/autosuggest.php", {queryString: ""+inputString+""}, function(data) {
9
 
10
                    if(data.length > 0) {
11
 
12
                        $('#suggestions').show();
13
                        $('#suggestionsList').html(data);
14
                    }
15
                });
16
            }
17
        }
18
    });
19
}
20
 
21
function fill(thisValue) {
22
    thisValue = decodeURIComponent(thisValue);
23
    $('#suchbegriff').val(thisValue);
24
}
25
 
26
function closeBox() {
27
    $('#suggestions').hide();
28
}
29
 
30
 
31
function jump2List(id) {
32
 
33
    if($('#suchbegriff').val().length > 0) {
34
        $('#suchbegriff').keydown(function(event) {
35
            if(event.keyCode == 40) {
36
                $("#suchbegriffs_liste input:first-child").focus();
37
            }
38
            if(event.keyCode == 38) {
39
                target = "sugg_" + (($('#suchbegriffs_liste').children().length / 2) -1);
40
                $('#'+target).focus();
41
            }
42
        });
43
    }
44
}
45
 
46
function jump(target,id,countList) {
47
    $(id).keydown(function(event) {
48
        cutId = target.substr(5);
49
 
50
        // Enter-Taste
51
        if(event.keyCode == 13) {
52
            fill(this.value);
53
            $('#suchbegriff').focus();
54
        }
55
 
56
        // Pfeiltaste nach unten
57
        if(event.keyCode == 40) {
58
            if(cutId >= countList) {
59
                target = "sugg_" + 0;
60
            }
61
            $('#'+target).focus();
62
        }
63
 
64
        // Pfeiltaste nach oben
65
        if(event.keyCode == 38) {
66
            if(cutId > 1) {
67
                target = "sugg_" + (cutId - 2);
68
                $('#'+target).focus();
69
            }
70
            if(cutId == 1) {
71
                $('#suchbegriff').focus();
72
            }
73
        }
74
    });
75
}
76
 
77
 
78
function cssHover(id) {
79
 
80
    $(id).focus(function(event) {
81
        $(".autocomplete_li").css("background-color","#fff");
82
        $(".autocomplete_li").css("color","#666");
83
        $(id).css("background-color","#666");
84
        $(id).css("color","#fff");
85
    });
86
    $(id).mouseover(function(event) {
87
        $(".autocomplete_li").css("background-color","#fff");
88
        $(".autocomplete_li").css("color","#666");
89
        $(id).css("background-color","#666");
90
        $(id).css("color","#fff");
91
    });
92
}