<commit_before>/*
---

name: NavigationBarItem

description: Provides the navigation bar item that contains the title and
             buttons at the left and right of it.

license: MIT-style license.

authors:
	- <NAME> (<EMAIL>)

requires:
	- BarItem

provides:
	- NavigationBarItem

...
*/

/**
 * Provides the navigation bar item that contains the title and buttons at the
 * left and right of it.
 *
 * @name NavigationBarItem
 * @class NavigationBarItem
 * @extends BarItem
 *
 * @author <NAME> (<EMAIL>)
 * @version 0.1
 */
Moobile.NavigationBarItem = new Class(/** @lends NavigationBarItem.prototype */ {

	Extends: Moobile.BarItem,

	/**
	 * The navigation bar item title.
	 * @type {BarTitle}
	 */
	title: null,

	/**
	 * Set the navigation bar item title.
	 * @param {Mixed} title The title as an instance of BarTitle or as a string.
	 * @return {NavigationBarItem}
	 * @since 0.1
	 */
	setTitle: function(title) {

		if (this.title === title)
			return this;

		this.title.setText(null);
		this.title.hide();

		if (title) {
			if (typeof title == 'string') {
				this.title.setText(title);
				this.title.show();
			} else {
				this.replaceChildView(this.title, title);
				this.title.destroy();
				this.title = title;
			}
		}

		return this;
	},

	/**
	 * Return the navigation bar item title.
	 * @return {BarTitle}
	 * @since 0.1
	 */
	getTitle: function() {
		return this.title;
	},

	/**
	 * @see Entity#willLoad
	 */
	willLoad: function() {

		this.parent();

		var title = this.getRoleElement('title');

		if (title == null) {
			title = new Element('div');
			title.ingest(this.element);
			title.inject(this.element);
		}

		this.defineElementRole(title, 'title');
	},

	/**
	 * @see Entity#didLoad
	 */
	didLoad: function() {

		this.parent();

		var className = this.options.className;
		if (className) {
			this.element.addClass('navigation-' + className);
		}
	},

	/**
	 * @see Entity#destroy
	 */
	destroy: function() {
		this.title = null;
		this.parent();
	},

});

//------------------------------------------------------------------------------
// Child Roles
//------------------------------------------------------------------------------

Moobile.Entity.defineRole('title', Moobile.NavigationBarItem, function(element, name) {

	var instance = Class.instantiate(element.get('title') || Moobile.BarTitle, element, null, name);
	if (instance instanceof Moobile.BarTitle) {
		this.addChild(instance);
		this.title = instance;
	}

	return instance;
});
<commit_msg>Added methods removed from Bar to NavigationBarItem<commit_after>/*
---

name: NavigationBarItem

description: Provides the navigation bar item that contains the title and
             buttons at the left and right of it.

license: MIT-style license.

authors:
	- <NAME> (<EMAIL>)

requires:
	- BarItem

provides:
	- NavigationBarItem

...
*/

/**
 * Provides the navigation bar item that contains the title and buttons at the
 * left and right of it.
 *
 * @name NavigationBarItem
 * @class NavigationBarItem
 * @extends BarItem
 *
 * @author <NAME> (<EMAIL>)
 * @version 0.1
 */
Moobile.NavigationBarItem = new Class(/** @lends NavigationBarItem.prototype */ {

	Extends: Moobile.BarItem,

	/**
	 * The navigation bar item title.
	 * @type {BarTitle}
	 */
	title: null,

	/**
	 * Set the navigation bar item title.
	 * @param {Mixed} title The title as an instance of BarTitle or as a string.
	 * @return {NavigationBarItem}
	 * @since 0.1
	 */
	setTitle: function(title) {

		if (this.title === title)
			return this;

		this.title.setText(null);
		this.title.hide();

		if (title) {
			if (typeof title == 'string') {
				this.title.setText(title);
				this.title.show();
			} else {
				this.replaceChildView(this.title, title);
				this.title.destroy();
				this.title = title;
			}
		}

		return this;
	},

	/**
	 * Return the navigation bar item title.
	 * @return {BarTitle}
	 * @since 0.1
	 */
	getTitle: function() {
		return this.title;
	},

	/**
	 * Add a button at the left of the title.
	 * @see Entity#addChild.
	 */
	addLeftBarButton: function(button) {
		return this.addChild(button, 'top');
	},

	/**
	 * Add a button at the right of the title.
	 * @see Bar#addBarButton.
	 */
	addRightBarButton: function(button) {
		return this.addChild(button, 'bottom');
	},

	/**
	 * Return a bar button from the bar item.
	 * @since 0.1
	 * @see Entity#getChild
	 */
	getBarButton: function(name) {
		return this.getChild(name);
	},

	/**
	 * Remove a bar button from the bar item.
	 * @since 0.1
	 * @see Entity#removeChild
	 */
	removeBarButton: function(item) {
		return this.removeChild(item);
	},

	/**
	 * Remove all bar buttons from the bar item.
	 * @since 0.1
	 * @see Entity#removeChildren
	 */
	removeAllBarButtons: function() {
		return this.removeChildren();
	},

	/**
	 * @see Entity#willLoad
	 */
	willLoad: function() {

		this.parent();

		var title = this.getRoleElement('title');

		if (title == null) {
			title = new Element('div');
			title.ingest(this.element);
			title.inject(this.element);
		}

		this.defineElementRole(title, 'title');
	},

	/**
	 * @see Entity#didLoad
	 */
	didLoad: function() {

		this.parent();

		var className = this.options.className;
		if (className) {
			this.element.addClass('navigation-' + className);
		}
	},

	/**
	 * @see Entity#destroy
	 */
	destroy: function() {
		this.title = null;
		this.parent();
	},

});

//------------------------------------------------------------------------------
// Child Roles
//------------------------------------------------------------------------------

Moobile.Entity.defineRole('title', Moobile.NavigationBarItem, function(element, name) {

	var instance = Class.instantiate(element.get('title') || Moobile.BarTitle, element, null, name);
	if (instance instanceof Moobile.BarTitle) {
		this.addChild(instance);
		this.title = instance;
	}

	return instance;
});

{'fraction_non_alphanumeric': 0.19277313788989262, 'fraction_numerical': 0.0030680074995738877, 'mean_word_length': 2.5413397706698855, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5267689', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1800, 'n_words': 484}