var __extends = (this && this.__extends) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; /// <reference path="../base/BaseClass.ts" /> /// <reference path="../collection/IListFilter.ts" /> /// <reference path="./tag/ITagDefinition.ts" /> var econda; (function (econda) { var tagmanager; (function (tagmanager) { /** * Decides which tags to apply on document ready. * @class econda.tagmanager.Matcher */ var Matcher = (function (_super) { __extends(Matcher, _super); function Matcher(cfg) { _super.call(this); /** * Tag items have constraint referenced by id. This is the function we use to check if the referenced constraint is true * @cfg {Function} checkConstraintCallback */ this._checkConstraintCallback = null; this._currentEvent = null; if (cfg instanceof Matcher) { return this; } this.initConfig(cfg); } //noinspection JSUnusedGlobalSymbols Matcher.prototype.setCheckConstraintCallback = function (callback) { this._checkConstraintCallback = callback; }; //noinspection JSUnusedGlobalSymbols Matcher.prototype.setCurrentEvent = function (event) { this._currentEvent = event; }; Matcher.prototype.match = function (item) { if (typeof item.filters.length !== 'undefined') { // first level > OR for (var n = 0; n < item.filters.length; n++) { if (typeof item.filters[n].length !== 'undefined' && item.filters[n].length > 0) { // second level > AND var result = true; for (var i = 0; i < item.filters[n].length; i++) { result = result && this._checkConstraintCallback(item.filters[n][i], this._currentEvent); } if (result === true) { return true; } } } } return false; }; return Matcher; }(econda.base.BaseClass)); tagmanager.Matcher = Matcher; })(tagmanager = econda.tagmanager || (econda.tagmanager = {})); })(econda || (econda = {}));