1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/jappix_ynh.git synced 2024-09-03 19:26:19 +02:00
jappix_ynh/source/js/bubble.js
titoko titoko 96663cd7da add source
2013-11-27 12:56:15 +01:00

59 lines
1.2 KiB
JavaScript
Executable file

/*
Jappix - An open social platform
These are the bubble JS scripts for Jappix
-------------------------------------------------
License: AGPL
Author: Valérian Saliou
Last revision: 11/12/10
*/
// Closes all the opened bubbles
function closeBubbles() {
// Destroy all the elements
$('.bubble.hidable:visible').hide();
$('.bubble.removable').remove();
$('body').off('click');
return false;
}
// Click function when a bubble is opened
function showBubble(selector) {
// Hidable bubbles special things
if($(selector).is('.hidable')) {
// This bubble is yet displayed? So abort!
if($(selector).is(':visible'))
return closeBubbles();
// Close all the bubbles
closeBubbles();
// Show the requested bubble
$(selector).show();
}
// Removable bubbles special things
else {
// This bubble is yet added? So abort!
if(exists(selector))
return closeBubbles();
// Close all the bubbles
closeBubbles();
}
// Creates a new click event to close the bubble
$('body').on('click', function(evt) {
var target = evt.target;
// If this is a click away from a bubble
if(!$(target).parents('.ibubble').size())
closeBubbles();
});
return false;
}