foist
[kismet-logviewer.git] / logviewer / static / js / jquery-fluid16.js
1 var fluid = {
2 Ajax : function(){
3         $("#loading").hide();
4         var content = $("#ajax-content").hide();
5         $("#toggle-ajax").bind("click", function(e) {
6         if ( $(this).is(".hidden") ) {
7             $("#ajax-content").empty();
8
9             $("#loading").show();
10             $("#ajax-content").load("/fluid960gs/data/ajax-response.html", function() {
11                 $("#loading").hide();
12                 content.slideDown();
13             });
14         }
15         else {
16             content.slideUp();
17         }
18         if ($(this).hasClass('hidden')){
19             $(this).removeClass('hidden').addClass('visible');
20         }
21         else {
22             $(this).removeClass('visible').addClass('hidden');
23         }
24         e.preventDefault();
25     });
26 },
27 Toggle : function(){
28         var default_hide = {"grid": true };
29         $.each(
30                 ["grid", "paragraphs", "blockquote", "list-items", "section-menu", "tables", "forms", "login-forms", "search", "articles", "accordion"],
31                 function() {
32                         var el = $("#" + (this == 'accordon' ? 'accordion-block' : this) );
33                         if (default_hide[this]) {
34                                 el.hide();
35                                 $("[id='toggle-"+this+"']").addClass("hidden")
36                         }
37                         $("[id='toggle-"+this+"']")
38                         .bind("click", function(e) {
39                                 if ($(this).hasClass('hidden')){
40                                         $(this).removeClass('hidden').addClass('visible');
41                                         el.slideDown();
42                                 } else {
43                                         $(this).removeClass('visible').addClass('hidden');
44                                         el.slideUp();
45                                 }
46                                 e.preventDefault();
47                         });
48                 }
49         );
50 },
51 Kwicks : function(){
52         var animating = false;
53     $("#kwick .kwick")
54         .bind("mouseenter", function(e) {
55             if (animating) return false;
56             animating == true;
57             $("#kwick .kwick").not(this).animate({ "width": 125 }, 200);
58             $(this).animate({ "width": 485 }, 200, function() {
59                 animating = false;
60             });
61         });
62     $("#kwick").bind("mouseleave", function(e) {
63         $(".kwick", this).animate({ "width": 215 }, 200);
64     });
65 },
66 SectionMenu : function(){
67         $("#section-menu")
68         .accordion({
69             "header": "a.menuitem"
70         })
71         .bind("accordionchangestart", function(e, data) {
72             data.newHeader.next().andSelf().addClass("current");
73             data.oldHeader.next().andSelf().removeClass("current");
74         })
75         .find("a.menuitem:first").addClass("current")
76         .next().addClass("current");
77 },
78 Accordion: function(){
79         $("#accordion").accordion({
80         'header': "h3.atStart"
81     }).bind("accordionchangestart", function(e, data) {
82         data.newHeader.css({
83             "font-weight": "bold",
84             "background": "#fff"
85         });
86
87         data.oldHeader.css({
88             "font-weight": "normal",
89             "background": "#eee"
90         });
91     }).find("h3.atStart:first").css({
92         "font-weight": "bold",
93         "background": "#fff"
94     });
95 }
96 }
97 jQuery(function ($) {
98         if($("#accordion").length){fluid.Accordion();}
99         if($("[id$='ajax']").length){fluid.Ajax();}
100         if($("[id^='toggle']").length){fluid.Toggle();}
101         if($("#kwick .kwick").length){fluid.Kwicks();}
102         if($("#section-menu").length){fluid.SectionMenu();}
103 });