[ Index ] |
WordPress Cross Reference |
[Source view] [Print] [Project Stats]
Heartbeat API Note: this API is "experimental" meaning it will likely change a lot in the next few releases based on feedback from 3.6.0. If you intend to use it, please follow the development closely.
File Size: | 742 lines (19 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
initialize() X-Ref |
Set local vars and events, then start return: void |
time() X-Ref |
Return the current time according to the browser return: int |
isLocalFrame( frame ) X-Ref |
Check if the iframe is from the same origin return: bool |
setErrorState( error, status ) X-Ref |
Set error state and fire an event on XHR errors or timeout param: string error The error type passed from the XHR param: int status The HTTP status code passed from jqXHR (200, 404, 500, etc.) return: void |
clearErrorState() X-Ref |
Clear the error state and fire an event return: void |
connect() X-Ref |
Gather the data and connect to the server return: void |
scheduleNextTick() X-Ref |
Schedule the next connection Fires immediately if the connection time is longer than the interval. return: void |
blurred() X-Ref |
No description |
focused() X-Ref |
Set the internal state when the browser window is focused return: void |
setFrameFocusEvents() X-Ref |
Add focus/blur events to all local iframes Used to detect when focus is moved from the main window to an iframe return: void |
removeFrameFocusEvents() X-Ref |
Remove the focus/blur events to all local iframes return: void |
clearFocusTimers() X-Ref |
Clear the reset timers for focus/blur events on the window and iframes return: void |
userIsActive() X-Ref |
Runs when the user becomes active after a period of inactivity return: void |
checkUserActivity() X-Ref |
Check for user activity Runs every 30 sec. Sets 'hasFocus = true' if user is active and the window is in the background. Set 'hasFocus = false' if the user has been inactive (no mouse or keyboard activity) for 5 min. even when the window has focus. return: void |
hasFocus() X-Ref |
Whether the window (or any local iframe in it) has focus, or the user is active return: bool |
hasConnectionError() X-Ref |
Whether there is a connection error return: bool |
connectNow() X-Ref |
Connect asap regardless of 'hasFocus' Will not open two concurrent connections. If a connection is in progress, will connect again immediately after the current connection completes. return: void |
disableSuspend() X-Ref |
Disable suspending Should be used only when Heartbeat is performing critical tasks like autosave, post-locking, etc. Using this on many screens may overload the user's hosting account if several browser windows/tabs are left open for a long time. return: void |
interval( speed, ticks ) X-Ref |
Get/Set the interval When setting to 'fast' or 5, by default interval is 5 sec. for the next 30 ticks (for 2 min and 30 sec). In this case the number of 'ticks' can be passed as second argument. If the window doesn't have focus, the interval slows down to 2 min. param: mixed speed Interval: 'fast' or 5, 15, 30, 60 param: string ticks Used with speed = 'fast' or 5, how many ticks before the interval reverts back return: int Current interval in seconds |
enqueue( handle, data, noOverwrite ) X-Ref |
Enqueue data to send with the next XHR As the data is send asynchronously, this function doesn't return the XHR response. To see the response, use the custom jQuery event 'heartbeat-tick' on the document, example: $(document).on( 'heartbeat-tick.myname', function( event, data, textStatus, jqXHR ) { // code }); If the same 'handle' is used more than once, the data is not overwritten when the third argument is 'true'. Use wp.heartbeat.isQueued('handle') to see if any data is already queued for that handle. $param string handle Unique handle for the data. The handle is used in PHP to receive the data. $param mixed data The data to send. $param bool noOverwrite Whether to overwrite existing data in the queue. $return bool Whether the data was queued or not. |
isQueued( handle ) X-Ref |
Check if data with a particular handle is queued $param string handle The handle for the data $return bool Whether some data is queued with this handle |
dequeue( handle ) X-Ref |
Remove data with a particular handle from the queue $param string handle The handle for the data $return void |
getQueuedItem( handle ) X-Ref |
Get data that was enqueued with a particular handle $param string handle The handle for the data $return mixed The data or undefined |
Generated: Tue Mar 25 01:41:18 2014 | WordPress honlapkészítés: online1.hu |