UNPKG

siesta-lite

Version:

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

176 lines (135 loc) 5.05 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.Project.Browser.UI.TreeFilterField&#39;, { extend : &#39;Ext.form.field.Text&#39;, alias : &#39;widget.treefilter&#39;, filterGroups : false, cls : &#39;filterfield&#39;, store : null, filterField : &#39;text&#39;, hasAndCheck : null, andChecker : null, andCheckerScope : null, triggerLeafCls : &#39;fa-file-o&#39;, triggerGroupCls : &#39;fa-folder-o&#39;, tipText : null, constructor : function (config) { var me = this; Ext.apply(config, { triggers : { clear : { cls : &#39;fa-close&#39;, handler : function () { me.store.clearTreeFilter() me.reset() } }, leafOrGroup : { cls : me.triggerLeafCls, handler : function () { me.setFilterGroups(!me.getFilterGroups()) } } }, listeners : { change : { fn : this.onFilterChange, buffer : 400, scope : this }, specialkey : this.onFilterSpecialKey, scope : this } }) this.callParent(arguments); }, afterRender : function () { this.callParent(arguments) this.tipText &amp;&amp; this.inputEl.set({ title : this.tipText }) if (this.filterGroups) { this.triggerEl.item(1).addCls(this.triggerGroupCls) this.triggerEl.item(1).removeCls(this.triggerLeafCls) } }, onFilterSpecialKey : function (field, e, t) { if (e.keyCode === e.ESC) { this.store.clearTreeFilter() field.reset(); } }, setFilterGroups : function (value) { if (value != this.filterGroups) { this.filterGroups = value if (this.rendered) { var el = this.triggerEl.item(1) if (value) { el.addCls(this.triggerGroupCls) el.removeCls(this.triggerLeafCls) } else { el.removeCls(this.triggerGroupCls) el.addCls(this.triggerLeafCls) } } this.refreshFilter() this.fireEvent(&#39;filter-group-change&#39;, this) } }, getFilterGroups : function () { return this.filterGroups }, refreshFilter : function () { this.onFilterChange(this, this.getValue()) }, onFilterChange : function (field, filterValue) { if (filterValue || this.hasAndCheck &amp;&amp; this.hasAndCheck()) { var filterer = this.store.filterer var fieldName = this.filterField var testFilterRegexps var groupFilterRegexps var filterGroups = this.filterGroups if (filterGroups) { testFilterRegexps = filterer.splitTermByPipe(filterValue) } else { var res = filterer.parseFilterValue(filterValue) testFilterRegexps = res.testFilterRegexps groupFilterRegexps = res.groupFilterRegexps } var andChecker = this.andChecker var andCheckerScope = this.andCheckerScope || this var getTitle = function (node) { return node.get(fieldName) } this.store.filterTreeBy({ filter : function (node) { if (andChecker &amp;&amp; !andChecker.call(andCheckerScope, node)) return false return filterer.checkCommonFilter(node, getTitle, testFilterRegexps, groupFilterRegexps) }, fullMatchingParents : filterGroups }) } else { this.store.clearTreeFilter() } } }) </pre> </body> </html>