UNPKG

angular-ui-tree-filter

Version:

A module providing an AngularJS filter which can be used with angular-ui-tree to match tree nodes

2 lines 863 B
/*! angular-ui-tree-filter 0.1.1, 01-10-2015 */ !function(a){"use strict";a.module("ui.tree-filter",[]).provider("uiTreeFilterSettings",function(){var a=this;this.addresses=["title"],this.regexFlags="gi",this.descendantCollection="items",this.$get=function(){return{addresses:a.addresses,regexFlags:a.regexFlags,descendantCollection:a.descendantCollection}}}).filter("uiTreeFilter",["uiTreeFilterSettings",function(a){function b(a,b,c){a=a||[];var e=!1;return a.forEach(function(a){e=e||d(a,b,c)}),e}function c(a,b){var d=b.split(".");if(void 0!==a)return d.length<2?a[d[0]]:c(a[d[0]],d.slice(1).join("."))}function d(d,e,f){var g=c(d,f),h="string"==typeof g?!!g.match(new RegExp(e,a.regexFlags)):!1;return h||b(d[a.descendantCollection],e,f)}return function(b,c,e){return e=e||a.addresses,void 0===c||e.reduce(function(a,e){return a||d(b,c,e)},!1)}}])}(angular);