siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
176 lines (135 loc) • 5.05 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
*/
Ext.define('Siesta.Project.Browser.UI.TreeFilterField', {
extend : 'Ext.form.field.Text',
alias : 'widget.treefilter',
filterGroups : false,
cls : 'filterfield',
store : null,
filterField : 'text',
hasAndCheck : null,
andChecker : null,
andCheckerScope : null,
triggerLeafCls : 'fa-file-o',
triggerGroupCls : 'fa-folder-o',
tipText : null,
constructor : function (config) {
var me = this;
Ext.apply(config, {
triggers : {
clear : {
cls : 'fa-close',
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 && 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('filter-group-change', this)
}
},
getFilterGroups : function () {
return this.filterGroups
},
refreshFilter : function () {
this.onFilterChange(this, this.getValue())
},
onFilterChange : function (field, filterValue) {
if (filterValue || this.hasAndCheck && 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 && !andChecker.call(andCheckerScope, node)) return false
return filterer.checkCommonFilter(node, getTitle, testFilterRegexps, groupFilterRegexps)
},
fullMatchingParents : filterGroups
})
} else {
this.store.clearTreeFilter()
}
}
})
</pre>
</body>
</html>