siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
122 lines (91 loc) • 3.92 kB
HTML
<!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('Siesta.Recorder.Role.CanRecordWindowResize', {
requires : [
'getWindowSize'
],
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('resize', this.onWindowResize);
if (this.recordInitialWindowSize) {
// don't record the size on following start/stop
this.recordInitialWindowSize = false
var size = this.getWindowSize(this.window)
this.addAction({
action : 'setWindowSize',
value : [ size.width, size.height ]
})
}
},
onStop : function () {
this.SUPERARG(arguments)
var win = this.window
if (this.recordWindowResize) win.removeEventListener('resize', this.onWindowResize);
}
},
methods : {
onWindowResize : function (nativeEvent) {
var size = this.getWindowSize(this.window)
var lastAction = this.getLastAction()
// note that "target" here is unchanged and can be a document
if (lastAction && lastAction.action == 'setWindowSize') {
lastAction.value = [ size.width, size.height ]
this.fireEvent('actionupdate', lastAction)
} else {
this.addAction({
action : 'setWindowSize',
value : [ size.width, size.height ],
sourceEvent : Siesta.Recorder.Event.fromDomEvent(nativeEvent)
})
}
}
}
// eof methods
});</pre>
</body>
</html>