RapidApp
view release on metacpan or search on metacpan
share/assets/js/085-AppTree.js view on Meta::CPAN
if(false !== this.expandOnFilter) {
startNode = startNode || this.tree.root;
var animate = this.tree.animate;
this.tree.animate = false;
startNode.expand(true, false, function() {
// call parent after expand
Ext.ux.tree.TreeFilterX.superclass.filter.call(this, value, attr, startNode);
}.createDelegate(this));
this.tree.animate = animate;
}
else {
// call parent
Ext.ux.tree.TreeFilterX.superclass.filter.apply(this, arguments);
}
} // eo function filter
// }}}
// {{{
/**
* Filter by a function. The passed function will be called with each
* node in the tree (or from the startNode). If the function returns true, the node is kept
* otherwise it is filtered. If a node is filtered, its children are also filtered.
* Shows parents of matching nodes.
*
* @param {Function} fn The filter function
* @param {Object} scope (optional) The scope of the function (defaults to the current node)
*/
,filterBy:function(fn, scope, startNode) {
startNode = startNode || this.tree.root;
if(this.autoClear) {
this.clear();
}
var af = this.filtered, rv = this.reverse;
var f = function(n) {
if(n === startNode) {
return true;
}
if(af[n.id]) {
return false;
}
var m = fn.call(scope || n, n);
if(!m || rv) {
af[n.id] = n;
n.ui.hide();
return true;
}
else {
n.ui.show();
var p = n.parentNode;
while(p && p !== this.root) {
p.ui.show();
p = p.parentNode;
}
return true;
}
return true;
};
startNode.cascade(f);
if(this.remove){
for(var id in af) {
if(typeof id != "function") {
var n = af[id];
if(n && n.parentNode) {
n.parentNode.removeChild(n);
}
}
}
}
} // eo function filterBy
// }}}
}); // eo extend
// -----
// Overrides to prevent exceptions when panel is closed while an Ajax load is in-progress
Ext.override(Ext.tree.TreeNode,{
_orig: {
expand: Ext.tree.TreeNode.prototype.expand,
expandChildNodes: Ext.tree.TreeNode.prototype.expandChildNodes,
renderChildren: Ext.tree.TreeNode.prototype.renderChildren,
},
expand : function(){
if(!this.getOwnerTree()) { return; }
return this._orig.expand.apply(this,arguments);
},
expandChildNodes: function() {
if(!this.childNodes) { return; }
return this._orig.expandChildNodes.apply(this,arguments);
},
renderChildren: function() {
if(!this.childNodes) { return; }
return this._orig.renderChildren.apply(this,arguments);
}
});
Ext.override(Ext.tree.AsyncTreeNode,{
loadComplete : function(deep, anim, callback, scope){
this.loading = false;
this.loaded = true;
if(this.ui) { this.ui.afterLoad(this); }
this.fireEvent("load", this);
this.expand(deep, anim, callback, scope);
}
});
// -----
( run in 1.370 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )