Update Heartbeat to use the "page visibility" API and add a setting for minimal interval

Description

Most browsers now support the new ​Page Visibility API. It has the advantage of working across iframes (window focus/blur fires when focusing an iframe).

By adding a setting for "minimal interval", the user will be able to limit the number of AJAX requests. Frequent requests can be a problem on some hosts and cause the user to exceed the allocated server CPU time or other resources.

Change History (3)

Switch Heartbeat from using window.focus/blur to using the page visibility API.

Add a setting for minimal interval. Maximum value is 10 min. Once set at initialization, this cannot be changed.

Extend the setting of interval to support 120 sec. (60 sec, is still the default).

Always suspend after one hour of inactivity. This will also remove the post lock. If the user returns after the post lock has been removed and somebody has taken over the post editing, the user will see the "Taken over..." modal as soon as there is some mouse or keyboard activity.

Use the page visibility API (when available) and document.hasFocus() instead of window.onfocus/onblur. Improves speeding up/slowing down the interval and works for iframes by default.

Add a setting for minimal interval. Maximum value is 10 min. This overrides all other intervals and cannot be changed after setting it at initialization. Can be used to reduce the frequency of requests on hosts that have low limits for used CPU time, etc.

Extend the setting of interval to support 120 sec. (60 sec, is still the default).