This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Clock
#9
Hi,

Here is a full working sample to auto close widgets based on the back to startpage JS script:

Code:
$(function(){
 
 var SE_Timeout = 15000; // adjust this timer value if needed (15 seconds in miliseconds)
 var eventlist = 'click mousedown mouseout touchend';
 var OpenWidget = 0;
 
 setInterval(function() {
   var WidgetNumber = 0;
   $('.layer-widget').each(function( index, element ) {
     if ( $(this).is(':visible') == true) {
       fields = $(this)[0].id.split(/-/);
       WidgetNumber = Number(fields[1]);
     }      
   });
   if (WidgetNumber > 0 && OpenWidget != WidgetNumber){
     OpenWidget = WidgetNumber;
   }
 }, 1000);      
 
 // Timer function no usage detected
 function No_Usage_Detected(callback, timeout, _this) {
   var timer;
   return function(e) {
       var _that = this;
       if (timer)
           clearTimeout(timer);
       timer = setTimeout(function() {
           callback.call(_this || _that, e);
       }, timeout);
   }
 }

 // Close widget function when timer elapsed
 var SE_CloseWidget = No_Usage_Detected(function(e) {
        $("#widget-" + OpenWidget).addClass("hide");
 }, SE_Timeout);
 
 // Add event listener to document to detect user input
 $(document).on(eventlist, function() {
   SE_CloseWidget();
 });

 // Add event listener to all iframes to detect user input inside iframes
 $('iframe').load(function() {
   var iframe = $('iframe').contents().find('html');
   iframe.on(eventlist, function(event) {
    SE_CloseWidget();
   });
 });
 
});  
BR,

Erwin
Reply


Messages In This Thread
Clock - by paalidar - 19.11.2018, 21:50
RE: Clock - by admin - 20.11.2018, 07:48
RE: Clock - by paalidar - 20.11.2018, 10:50
RE: Clock - by admin - 20.11.2018, 11:24
RE: Clock - by paalidar - 20.11.2018, 11:44
RE: Clock - by admin - 20.11.2018, 11:47
RE: Clock - by paalidar - 20.11.2018, 16:21
RE: Clock - by Daniel - 20.11.2018, 17:17
RE: Clock - by Erwin van der Zwart - 20.11.2018, 21:23

Forum Jump: