<commit_before>/*
---
name: Behavior
description: Auto-instantiates widgets/classes based on parsed, declarative HTML.
requires: [Core/Class.Extras, Core/Element, Core/Selectors, /ART.Window, /Element.Data, Table/Table, /DashSelectors]
provides: [Behavior]
...
*/

(function(){

	this.Behavior = new Class({

		Implements: [Options, Events],

		options: {
			//default error behavior when a filter cannot be applied
			onError: function(){
				if (window.console && console.warn) console.warn.apply(console, arguments);
			}
			//Components that have a Behavior instance (like an ART.Window)
			//call these events to tell filters that need to know that the state
			//has changed:
			// onResize: $empty, //the element's dimensions have changed
			// onShow: $empty, //the element is displayed
			// onHide: $empty //the element is hidden
		},

		initialize: function(options){
			this.setOptions(options);
			this._eventMethods = {};
			var self = this;
			var passEvent = function(method) {
				self._eventMethods[method] = function(name, fn) {
					self[method](name, fn);
					return self._eventMethods;
				};
			};
			['addEvent', 'removeEvent', 'addEvents', 'removeEvents'].each(passEvent);<commit_msg>adding method to pass through any kind of method on an external object to filters<commit_after>/*
---
name: Behavior
description: Auto-instantiates widgets/classes based on parsed, declarative HTML.
requires: [Core/Class.Extras, Core/Element, Core/Selectors, /ART.Window, /Element.Data, Table/Table, /DashSelectors]
provides: [Behavior]
...
*/

(function(){

	this.Behavior = new Class({

		Implements: [Options, Events],

		options: {
			//default error behavior when a filter cannot be applied
			onError: function(){
				if (window.console && console.warn) console.warn.apply(console, arguments);
			}
			//Components that have a Behavior instance (like an ART.Window)
			//call these events to tell filters that need to know that the state
			//has changed:
			// onResize: $empty, //the element's dimensions have changed
			// onShow: $empty, //the element is displayed
			// onHide: $empty //the element is hidden
		},

		initialize: function(options){
			this.setOptions(options);
			this._eventMethods = {};
			this.passMethods(['addEvent', 'removeEvent', 'addEvents', 'removeEvents']);
		},
		
		//pass a method pointer through to a filter
		//by default the methods for add/remove events are passed to the filter
		//pointed to this instance of behavior. you could use this to pass along
		//other methods to your filters. For example, a method to close a popup
		//for filters presented inside popups.
		passMethod: function(method, to){
			var self = this;
			this._passedMethods[method] = function() {
				to[method].apply(to, arguments);
				return self._passedMethods;
			};
		},

		passMethods: function(methods){
			methods.each(function(method){
				this.passMethod(method, this);
			}, this);
{'fraction_non_alphanumeric': 0.12461485792536803, 'fraction_numerical': 0.0, 'mean_word_length': 3.6234177215189876, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3597216', 'n_tokens_mistral': 959, 'n_tokens_neox': 823, 'n_words': 289}