]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/static/js/default.js
Merge pull request #12 from nyov/nyov/conversion
[xonotic/xonstat.git] / xonstat / static / js / default.js
1 $(function(){
2
3         init_menus();
4         init_checkboxes();
5         init_radiobuttons();
6         init_datatables();
7
8 });
9
10 $.fn.hoverClass = function(c) {
11     return this.each(function(){
12         $(this).hover(
13             function() { $(this).addClass(c);  },
14             function() { $(this).removeClass(c); }
15         );
16     });
17 };
18
19 function init_menus() {
20         $("#menu li").hover(
21         function(){ $("ul", this).fadeIn("fast"); },
22         function() { }
23     );
24     if (document.all) {
25         $("#menu li").hoverClass("sfHover");
26     }
27 }
28 function init_checkboxes() {
29         $(".checkbox").change(function(){
30                 if($(this).is(":checked")){
31                         $(this).next("label").addClass("checkbox-selected");
32                 }else{
33                         $(this).next("label").removeClass("checkbox-selected");
34                 }
35         });
36 }
37 function init_radiobuttons() {
38         $(".radio").change(function(){
39                 if($(this).is(":checked")){
40                         $(".radio-selected:not(:checked)").removeClass("radio-selected");
41                         $(this).next("label").addClass("radio-selected");
42                 }
43         });
44 }
45 function init_datatables() {
46         /* lazy test to see if exists,
47          * setup proper routing in document ready */
48         if ($("#sidebar table").length) {
49                 $("#sidebar table").dataTable({
50                         "bPaginate": false,
51                         "bLengthChange": false,
52                         "bFilter": false,
53                         "bSort": true,
54                         "bInfo": false,
55                         "bAutoWidth": false,
56                         "aaSorting": []
57                 });
58         }
59         if ($("#recent-games").length) {
60                 $("#recent-games").dataTable({
61                         "bPaginate": false,
62                         "bLengthChange": false,
63                         "bFilter": false,
64                         "bSort": true,
65                         "bInfo": false,
66                         "bAutoWidth": false,
67                         "oLanguage": {
68                                 "sSearch": "_INPUT_"
69                         },
70                         "aaSorting": []
71                 });
72         }
73         if ($("table.scoreboard").length) {
74                 $("table.scoreboard").dataTable({
75                         "bPaginate": false,
76                         "bLengthChange": false,
77                         "bFilter": false,
78                         "bSort": true,
79                         "bInfo": false,
80                         "bAutoWidth": false,
81                         "aaSorting": []
82                 });
83         }
84         if ($("table.accuracy").length) {
85                 $("table.accuracy").dataTable({
86                         "bPaginate": false,
87                         "bLengthChange": false,
88                         "bFilter": false,
89                         "bSort": true,
90                         "bInfo": false,
91                         "bAutoWidth": false,
92                         "aaSorting": []
93                 });
94         }
95         if ($(".recent_game_box").length) {
96                 $("").colorbox({width:"80%", height:"80%", iframe:true});
97         }
98         //$("#recent-games_filter input").attr("placeholder","filter names");
99 }