From 4be50c504b65aa0c87991b36dcd2fa056620ce46 Mon Sep 17 00:00:00 2001 From: Repellent Date: Tue, 18 Oct 2016 20:05:55 +0300 Subject: [PATCH] Upload new file --- whoisonline/js/widget.js | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 whoisonline/js/widget.js diff --git a/whoisonline/js/widget.js b/whoisonline/js/widget.js new file mode 100644 index 0000000..2e3114d --- /dev/null +++ b/whoisonline/js/widget.js @@ -0,0 +1,44 @@ +$(document).ready(function(){ + // This function is executed once the document is loaded + + // Caching the jQuery selectors: + var count = $('.onlineWidget .cnt'); + var panel = $('.onlineWidget .pnl'); + var timeout; + + // Loading the number of users online into the count div: + count.load(aveabspath+'index.php?module=whoisonline&action=online'); + + $('.onlineWidget').hover( + function(){ + // Setting a custom 'open' event on the sliding panel: + + clearTimeout(timeout); + timeout = setTimeout(function(){panel.trigger('open');},500); + }, + function(){ + // Custom 'close' event: + + clearTimeout(timeout); + timeout = setTimeout(function(){panel.trigger('close');},500); + } + ); + + var loaded=false; // A flag which prevents multiple ajax calls to geodata.php; + + // Binding functions to custom events: + + panel.bind('open',function(){ + panel.slideDown(function(){ + if(!loaded) + { + // Loading the countries and the flags once the sliding panel is shown: + panel.load(aveabspath+'index.php?module=whoisonline&action=geodata'); + loaded=true; + } + }); + }).bind('close',function(){ + panel.slideUp(); + }); + +}); \ No newline at end of file