UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

144 lines (106 loc) 4.55 kB
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>The source code</title> <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="../resources/prettify/prettify.js"></script> <style type="text/css"> .highlight { display: block; background-color: #ddd; } </style> <script type="text/javascript"> function highlight() { document.getElementById(location.hash.replace(/#/, "")).className = "highlight"; } </script> </head> <body onload="prettyPrint(); highlight();"> <pre class="prettyprint lang-js">/* Siesta 5.6.1 Copyright(c) 2009-2022 Bryntum AB https://bryntum.com/contact https://bryntum.com/products/siesta/license */ <span id='Siesta-Recorder-Role-CanRecordMouseMoveOnIdle'>/** </span>@class Siesta.Recorder.Role.CanRecordMouseMoveOnIdle A mixin, providing the feature of recording the &quot;moveCursorTo&quot; action, when mouse is idle at some point for {@link #idleTimeout} time. This feature can be enabled/disabled with the {@link recordMouseMoveOnIdle} config option. */ Role(&#39;Siesta.Recorder.Role.CanRecordMouseMoveOnIdle&#39;, { has : { <span id='Siesta-Recorder-Role-CanRecordMouseMoveOnIdle-cfg-idleTimeout'> /** </span> * @cfg {Boolean} idleTimeout The amount of time for mouse cursor to be idle, after which the * `moveCursorTo` action will be recorded with the target of current cursor position. */ idleTimeout : 3000, <span id='Siesta-Recorder-Role-CanRecordMouseMoveOnIdle-cfg-recordMouseMoveOnIdle'> /** </span> * @cfg {Boolean} recordMouseMoveOnIdle Set this option to `true` to enable recording of `moveCursorTo` * action, when mouse is idle at some point for certain amount of time ({@link #idleTimeout}) */ recordMouseMoveOnIdle : true, idleMouseMoveThrottler : null }, override : { initialize : function () { if (this.recordMouseMoveOnIdle) this.recordMouseMove = true this.SUPERARG(arguments) if (this.recordMouseMoveOnIdle) { this.idleMouseMoveThrottler = new Siesta.Util.Throttler({ func : this.onBodyMouseMoveIdle, scope : this, buffer : this.idleTimeout }) this.resetMouseMoveListener = this.resetMouseMoveListener.bind(this); } }, onDomEvent : function (e) { this.SUPERARG(arguments) // this &quot;reset&quot; will ensure that &quot;onBodyMouseMove&quot; handler will be called after &quot;idleTimeout&quot; // after any other dom event this.resetMouseMoveListener(); }, clear : function () { if (this.recordMouseMoveOnIdle) { this.resetMouseMoveListener() } this.SUPERARG(arguments) }, onStart : function () { this.SUPERARG(arguments) var win = this.window var doc = win.document var body = doc.body if (this.recordMouseMoveOnIdle) { body.addEventListener(&#39;mouseleave&#39;, this.resetMouseMoveListener) } }, onStop : function () { this.SUPERARG(arguments) var win = this.window var doc = win.document var body = doc.body if (this.recordMouseMoveOnIdle) { body.removeEventListener(&#39;mouseleave&#39;, this.resetMouseMoveListener) this.resetMouseMoveListener() } }, processBodyMouseMove : function (e) { this.SUPERARG(arguments) if (this.recordMouseMoveOnIdle) { this.idleMouseMoveThrottler.tick(e) } } }, // eof `override` methods : { resetMouseMoveListener : function () { this.idleMouseMoveThrottler &amp;&amp; this.idleMouseMoveThrottler.cancel() }, onBodyMouseMoveIdle : function (e) { this.addMoveCursorAction(e); } } });</pre> </body> </html>