UNPKG

siesta-lite

Version:

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

122 lines (91 loc) 3.92 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-CanRecordWindowResize'>/** </span>@class Siesta.Recorder.Role.CanRecordWindowResize A mixin with providing recording for window resize events. */ Role(&#39;Siesta.Recorder.Role.CanRecordWindowResize&#39;, { requires : [ &#39;getWindowSize&#39; ], does : [ Siesta.Recorder.Role.CanSwallowException ], has : { <span id='Siesta-Recorder-Role-CanRecordWindowResize-cfg-recordWindowResize'> /** </span> * @cfg {Boolean} recordWindowResize Set this option to `true` to enable recording of window resize events */ recordWindowResize : true, <span id='Siesta-Recorder-Role-CanRecordWindowResize-cfg-recordInitialWindowSize'> /** </span> * @cfg {Boolean} recordInitialWindowSize Set this option to `true` to record the single `setWindowSize` action * at first launch of the recorder. */ recordInitialWindowSize : false }, override : { initialize : function () { this.SUPERARG(arguments) this.onWindowResize = this.safeBind(this.onWindowResize); }, onStart : function () { this.SUPERARG(arguments) var win = this.window if (this.recordWindowResize) win.addEventListener(&#39;resize&#39;, this.onWindowResize); if (this.recordInitialWindowSize) { // don&#39;t record the size on following start/stop this.recordInitialWindowSize = false var size = this.getWindowSize(this.window) this.addAction({ action : &#39;setWindowSize&#39;, value : [ size.width, size.height ] }) } }, onStop : function () { this.SUPERARG(arguments) var win = this.window if (this.recordWindowResize) win.removeEventListener(&#39;resize&#39;, this.onWindowResize); } }, methods : { onWindowResize : function (nativeEvent) { var size = this.getWindowSize(this.window) var lastAction = this.getLastAction() // note that &quot;target&quot; here is unchanged and can be a document if (lastAction &amp;&amp; lastAction.action == &#39;setWindowSize&#39;) { lastAction.value = [ size.width, size.height ] this.fireEvent(&#39;actionupdate&#39;, lastAction) } else { this.addAction({ action : &#39;setWindowSize&#39;, value : [ size.width, size.height ], sourceEvent : Siesta.Recorder.Event.fromDomEvent(nativeEvent) }) } } } // eof methods });</pre> </body> </html>