]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/static/js/default.js
Merge pull request #1 from z/master
[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                 });
57         }
58         if ($("#recent-games").length) {
59                 $("#recent-games").dataTable({
60                         "bPaginate": false,
61                         "bLengthChange": false,
62                         "bFilter": true,
63                         "bSort": true,
64                         "bInfo": false,
65                         "bAutoWidth": false,
66                         "oLanguage": {
67                                 "sSearch": "_INPUT_"
68                         }
69                 });
70         }
71         if ($("table.scoreboard").length) {
72                 $("table.scoreboard").dataTable({
73                         "bPaginate": false,
74                         "bLengthChange": false,
75                         "bFilter": false,
76                         "bSort": true,
77                         "bInfo": false,
78                         "bAutoWidth": false
79                 });
80         }
81         if ($("table.accuracy").length) {
82                 $("table.accuracy").dataTable({
83                         "bPaginate": false,
84                         "bLengthChange": false,
85                         "bFilter": false,
86                         "bSort": true,
87                         "bInfo": false,
88                         "bAutoWidth": false
89                 });
90         }
91         if ($(".recent_game_box").length) {
92                 $("").colorbox({width:"80%", height:"80%", iframe:true});
93         }
94         //$("#recent-games_filter input").attr("placeholder","filter names");
95 }