UNPKG

siesta-lite

Version:

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

137 lines (109 loc) 4.34 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 */ Ext.define(&#39;Siesta.Recorder.UI.Editor.Target&#39;, { extend : &#39;Ext.form.field.ComboBox&#39;, alias : &#39;widget.targeteditor&#39;, enableKeyEvents : true, queryMode : &#39;local&#39;, valueField : &#39;type&#39;, displayField : &#39;value&#39;, cls : &#39;siesta-targeteditor&#39;, targetProperty : &#39;target&#39;, store : { proxy : &#39;memory&#39;, fields : [ &#39;type&#39;, &#39;value&#39;, &#39;target&#39; ] }, getTarget : function () { var value = this.getValue(); if (value &amp;&amp; /^!!(.+)/.exec(value)) { var record = this.store.findRecord(&#39;type&#39;, value) // TODO also return &#39;offset&#39;? return record ? record.get(&#39;target&#39;) : null } return value ? { type : &#39;user&#39;, target : value } : null }, setValue : function (value) { // This method is called with an array of a single record if (value instanceof Siesta.Recorder.Target) { if (value.getTarget()) this.callParent([ &#39;!!&#39; + value.getTarget().type ]); else this.callParent([ &#39;&#39; ]) } else this.callParent(arguments) }, getEditorValue : function (record) { return record.data[ this.targetProperty ] }, applyChanges : function (actionRecord) { var value = this.getValue() var match var target = actionRecord.data[ this.targetProperty ] // Typing 100,200 should mean a coordinate if (typeof value === &#39;string&#39; &amp;&amp; value.match(/\d*,\d*/)) { value = value.split(&#39;,&#39;); value[0] = parseInt(value[0], 10); value[1] = parseInt(value[1], 10); } if (value &amp;&amp; !target) { target = actionRecord.data[ this.targetProperty ] = new Siesta.Recorder.Target({ targets : [ { type : &#39;user&#39;, target : value } ] }) } if (target) { if (value &amp;&amp; (match = /^!!(.+)/.exec(value))) target.activeTarget = match[ 1 ] else { target.setUserTarget(value) } // TODO //actionRecord.afterEdit(this.targetProperty) } }, populate : function (target) { var storeData = []; target &amp;&amp; target.targets.forEach(function (target) { var type = target.type value = target.target; if (type === &#39;cq&#39; ) { var splitPos = target.target.indexOf(&#39;-&gt;&#39;); value = splitPos &gt; 0 ? target.target.split(&#39;-&gt;&#39;).splice(1, 0, &#39;&gt;&gt;&#39;).join() : &#39;&gt;&gt;&#39; + target.target } storeData.push({ // we add the &quot;!!&quot; before the type, so that &quot;setValue(value)&quot; can distinguish between the value as // arbitrary string (user input) and value as type name (which should change only the &quot;activeTarget&quot;) type : &#39;!!&#39; + type, value : value, target : target }); }); this.store.loadData(storeData); } }); </pre> </body> </html>