UNPKG

siesta-lite

Version:

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

154 lines (108 loc) 4.51 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 */ Class(&#39;Siesta.Recorder.Target&#39;, { has : { targets : Joose.I.Array, activeTarget : null }, methods : { initialize : function () { if (!this.targets) this.targets = [] var firstTarget = this.targets[ 0 ] if (firstTarget &amp;&amp; !this.activeTarget) this.activeTarget = firstTarget.type }, clear : function () { this.targets = [] }, getTargets : function () { var target = this.getTarget() return target &amp;&amp; target.targets || null }, // returns &quot;query-able&quot; target getTargetAsQueryString : function () { var target = this.getTarget() if (target.type == &#39;xy&#39;) return target.target return (target.type == &#39;cq&#39; ? &#39;&gt;&gt;&#39; : &#39;&#39;) + target.target }, // `getActiveTarget` getTarget : function () { return this.getTargetByType(this.activeTarget) }, clearOffset : function () { this.setOffset(null) }, setOffset : function (value) { var target = this.getTarget() if (target) if (value) target.offset = value else delete target.offset }, getOffset : function () { var target = this.getTarget() if (target) return target.offset }, getTargetByType : function (type) { var targetByType Joose.A.each(this.targets, function (target) { if (target.type == type) { targetByType = target return false } }) return targetByType }, setUserTarget : function (value, offset) { var userTarget = this.getTargetByType(&#39;user&#39;) if (!userTarget) { var target = { type : &#39;user&#39;, target : value } if (offset) target.offset = offset this.targets.unshift(target) } else { userTarget.target = value if (offset) userTarget.offset = offset else delete userTarget.offset } this.activeTarget = &#39;user&#39; }, // some old crap with unclear semantic - need to get rid of it // returns `true` if targeting the coordinates on the screen or &lt;body&gt; (which is the same thing) isTooGeneric : function () { var targets = this.targets if (!targets || targets.length === 0) return true if (targets.length === 1 &amp;&amp; targets[ 0 ].type == &#39;xy&#39;) return true if (targets.length === 2) { var xy = this.getTargetByType(&#39;xy&#39;) var css = this.getTargetByType(&#39;css&#39;) if (xy &amp;&amp; css &amp;&amp; css.target == &#39;body&#39;) return true } return false } } });</pre> </body> </html>