<commit_before>/*
---

name: Component

description:

license: MIT-style license.

authors:
	- <NAME> (<EMAIL>)

requires:
	- Entity

provides:
	- Component

...
*/

Moobile.Component = new Class({

	Extends: Moobile.Entity,

	/**
	 * @private
	 */
	$roles: {},

	/**
	 * @private
	 */
	$styles: {},

	/**
	 * @private
	 */
	_window: null,

	/**
	 * @private
	 */
	_parent: null,

	/**
	 * @private
	 */
	_children: [],

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#element
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	element: null,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#style
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	style: null,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#ready
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	ready: false,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#name
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	name: null,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#options
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	options: {
		className: null,
		styleName: null,
		tagName: 'div'
	},

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#initialization
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	initialize: function(element, options, name) {

		this.element = Element.from(element);
		if (this.element == null) {
			this.element = new Element(this.options.tagName);
		}

		this.name = name || this.element.get('data-name');

		options = options || {};

		for (var option in this.options) {
			var value = this.element.get('data-option-' + option.hyphenate());
			if (value != null) {
				var number = parseFloat(value);
				if (!isNaN(number)) value = number;
				if (options[option] == undefined) {
					options[option] = value;
				}
			}
		}

		this.setOptions(options);

		this.willBuild();
		this.build();
		this.didBuild();

		return this;
	},

	/**
	 * @protected
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	build: function() {

		var className = this.options.className;
		if (className) this.addClass(className);

		var styleName = this.options.styleName
		if (styleName) this.setStyle(styleName);

		this.element.getRoleElements().each(function(element) {

			var role = element.get('data-role');

			var behavior = this.$roles[role];
			if (behavior) {
				behavior.call(this, element);
				return;
			}

			throw new Error('Role ' + name + ' is undefined');

		}, this);
	},

	/**
	 * @overrides
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	addEvent: function(type, fn, internal) {

		if (Moobile.NativeEvents.contains(type)) {
			this.element.addEvent(type, function(e) {
				e.targetElement = this.element;
				this.fireEvent(type, e);<commit_msg>Smallish bugfix<commit_after>/*
---

name: Component

description:

license: MIT-style license.

authors:
	- <NAME> (<EMAIL>)

requires:
	- Entity

provides:
	- Component

...
*/

Moobile.Component = new Class({

	Extends: Moobile.Entity,

	/**
	 * @private
	 */
	$roles: {},

	/**
	 * @private
	 */
	$styles: {},

	/**
	 * @private
	 */
	_window: null,

	/**
	 * @private
	 */
	_parent: null,

	/**
	 * @private
	 */
	_children: [],

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#element
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	element: null,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#style
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	style: null,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#ready
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	ready: false,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#name
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	name: null,

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#options
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	options: {
		className: null,
		styleName: null,
		tagName: 'div'
	},

	/**
	 * @see    http://moobile.net/api/0.1/Component/Component#initialization
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	initialize: function(element, options, name) {

		this.element = Element.from(element);
		if (this.element == null) {
			this.element = new Element(this.options.tagName);
		}

		this.name = name || this.element.get('data-name');

		options = options || {};

		for (var option in this.options) {
			var value = this.element.get('data-option-' + option.hyphenate());
			if (value != null) {
				var number = parseFloat(value);
				if (!isNaN(number)) value = number;
				if (options[option] == undefined) {
					options[option] = value;
				}
			}
		}

		this.setOptions(options);

		this.willBuild();
		this.build();
		this.didBuild();

		return this;
	},

	/**
	 * @protected
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	build: function() {

		var className = this.options.className;
		if (className) this.addClass(className);

		var styleName = this.options.styleName
		if (styleName) this.setStyle(styleName);

		this.element.getRoleElements().each(function(element) {

			var role = element.get('data-role');

			var behavior = this.$roles[role];
			if (behavior) {
				behavior.call(this, element);
				return;
			}

			throw new Error('Role ' + role + ' is undefined');

		}, this);
	},

	/**
	 * @overrides
	 * @author <NAME> (<EMAIL>)
	 * @since  0.1
	 */
	addEvent: function(type, fn, internal) {

		if (Moobile.NativeEvents.contains(type)) {
			this.element.addEvent(type, function(e) {
				e.targetElement = this.element;
				this.fireEvent(type, e);
{'fraction_non_alphanumeric': 0.18937477412359957, 'fraction_numerical': 0.010119262739428984, 'mean_word_length': 2.791095890410959, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '492737', 'n_tokens_mistral': 2280, 'n_tokens_neox': 1969, 'n_words': 384}