UNPKG

siesta-lite

Version:

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

211 lines (165 loc) 7.37 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.TargetColumn&#39;, { extend : &#39;Ext.grid.Column&#39;, alias : &#39;widget.targetcolumn&#39;, requires : [ &#39;Siesta.Recorder.UI.Editor.Array&#39;, &#39;Siesta.Recorder.UI.Editor.Target&#39;, &#39;Siesta.Recorder.UI.Editor.DragTarget&#39;, &#39;Siesta.Recorder.UI.Editor.Code&#39; ], header : Siesta.Resource(&#39;Siesta.Recorder.UI.TargetColumn&#39;, &#39;headerText&#39;), dataIndex : &#39;target&#39;, flex : 1, sortable : false, menuDisabled : true, field : {}, tdCls : &#39;eventview-targetcolumn&#39;, // API for highlighting typed target text, supplied by owner/creator highlightTarget : null, renderer : function (value, meta, record) { // we are not interested in the default value which is the &quot;target&quot; field value value = &#39;&#39; var actionName = (record.data.action || &#39;&#39;).toLowerCase() if (record.hasTarget()) { var target = record.getTarget() if (target) { var R = Siesta.Resource(&#39;Siesta.Recorder.UI.TargetColumn&#39;); value = target.target if (target &amp;&amp; target.type == &#39;cq&#39;) value = &#39;&gt;&gt;&#39; + value if (actionName === &#39;drag&#39;) { var toTarget = record.data.toTarget var by = record.data.by if (toTarget &amp;&amp; toTarget.targets.length &amp;&amp; (!toTarget.isTooGeneric() || !by)) value += &#39; &#39; + R.get(&#39;to&#39;) + &#39;: &#39; + toTarget.getTarget().target; else if (by) value += &#39; &#39; + R.get(&#39;by&#39;) + &#39;: [&#39; + by + &#39;]&#39;; } meta.tdCls = &#39;eventview-target-&#39; + target.type if (target.type === &#39;xy&#39;) { meta.tdAttr = &quot;title=&#39;&quot; + R.get(&#39;coordinateTargetWarning&#39;) + &quot;&#39;&quot;; } value = Ext.String.htmlEncode(value); } } else if (actionName == &#39;movecursoralongpath&#39;) { value = Ext.String.htmlEncode(JSON.stringify(record.$action.value)); } else { var value = record.get(&#39;value&#39;); var options = record.data.options; if (value !== null &amp;&amp; value !== undefined &amp;&amp; options) { // Prepend modifier keys to all chars typed value = record.getReadableStringWithModifierKeys(value, options); } } // can be already set above if (!meta.tdAttr) // !IMPORTANT note, that we use double quotes for the value of &quot;title&quot; attribute, so all content inside it should use // single quotes (`getReadableStringWithModifierKeys` does), otherwise the grid&#39;s markup will be broken meta.tdAttr = &#39;title=&quot;&#39; + Ext.util.Format.stripTags(value) + &#39;&quot;&#39;; return value; }, setTargetEditor : function (actionRecord) { var newField = this.getTargetEditor(actionRecord); // Not all actions have target editors if (!newField) { return false; } this.setEditor(newField); }, getTargetEditor : function (record) { var me = this; var action = record.get(&#39;action&#39;); var editor; if (action.match(/^waitFor/)) { if (action === &#39;waitForAnimations&#39;) return null; if (action === &#39;waitForFn&#39;) { editor = new Siesta.Recorder.UI.Editor.Code(); } else { this.dataIndex = &#39;value&#39;; if (action === &#39;waitForMs&#39;) { editor = new Ext.form.field.Number() } else { // Default waitFor editor will just be a text field editor = new Ext.form.field.Text(); } } } else if (action === &#39;drag&#39;) { this.dataIndex = &#39;target&#39;; editor = new Siesta.Recorder.UI.Editor.DragTarget({ onTargetChange : function () { me.onTargetChange.apply(me, arguments); }, listeners : { collapse : function () { me.up(&#39;tablepanel&#39;).editing.cancelEdit() } } }); } else if (action === &#39;fn&#39;) { this.dataIndex = &#39;value&#39;; editor = new Siesta.Recorder.UI.Editor.Code(); } else if (action === &#39;type&#39; || action === &#39;moveCursorBy&#39; || action === &#39;screenshot&#39; || action === &#39;setUrl&#39;) { this.dataIndex = &#39;value&#39;; editor = new Ext.form.field.Text(); }else if (action === &#39;setWindowSize&#39;) { this.dataIndex = &#39;value&#39;; editor = new Siesta.Recorder.UI.Editor.Array(); } else { // Assume it&#39;s a target action this.dataIndex = &#39;target&#39;; editor = new Siesta.Recorder.UI.Editor.Target({ listeners : { select : this.onTargetChange, keyup : this.onTargetChange, focus : this.onTargetChange, buffer : 50, scope : this } }); editor.populate(record.data.target); } // Give editor access to the record editor.record = record; return editor; }, onTargetChange : function (field) { var target = field.getTarget(); if (!target) return; var textTarget = target.target if (target.type == &#39;cq&#39;) textTarget = &#39;&gt;&gt;&#39; + textTarget if (this.highlightTarget) { var result = this.highlightTarget(textTarget, target.offset); if (result.success) { field.clearInvalid() } else { field.markInvalid(result.message); } } } }); </pre> </body> </html>