]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/bubble.js
Merge pull request #48 from Leberwurscht/master
[friendica-addons.git] / jappixmini / jappix / js / bubble.js
1 /*
2
3 Jappix - An open social platform
4 These are the bubble JS scripts for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Author: Vanaryon
10 Last revision: 11/12/10
11
12 */
13
14 // Closes all the opened bubbles
15 function closeBubbles() {
16         // Destroy all the elements
17         $('.bubble.hidable:visible').hide();
18         $('.bubble.removable').remove();
19         $('body').die('click');
20         
21         return false;
22 }
23
24 // Click function when a bubble is opened
25 function showBubble(selector) {
26         // Hidable bubbles special things
27         if($(selector).is('.hidable')) {
28                 // This bubble is yet displayed? So abort!
29                 if($(selector).is(':visible'))
30                         return closeBubbles();
31                 
32                 // Close all the bubbles
33                 closeBubbles();
34                 
35                 // Show the requested bubble
36                 $(selector).show();
37         }
38         
39         // Removable bubbles special things
40         else {
41                 // This bubble is yet added? So abort!
42                 if(exists(selector))
43                         return closeBubbles();
44                 
45                 // Close all the bubbles
46                 closeBubbles();
47         }
48         
49         // Creates a new click event to close the bubble
50         $('body').live('click', function(evt) {
51                 var target = evt.target;
52                 
53                 // If this is a click away from a bubble
54                 if(!$(target).parents('.ibubble').size())
55                         closeBubbles();
56         });
57         
58         return false;
59 }