<commit_before>/**
 * Minimalistic Implement for Minimal.View Class
 * @author <NAME>, <NAME>
 */
define(function(require, exports, module) {

	var _log = __debug('view-core-loader').defineLevel();

	var Loader = new Class({

		options: {
			loader: {
				text: 'Loading...',
				delay: 200
			}
		},

		/**
		 * init loader
		 * @return {void}
		 */
		_initLoader: function() {
			_log.debug('_initLoader');

			this.addEvents({
				getData: this.showLoader.bind(this),
				noData: this.hideLoader.bind(this),
				setList: this.hideLoader.bind(this),
				progress: this.setLoaderText.bind(this)
			});
		},

		/**
		 * Show Loader
		 * @return {void}
		 */
		showLoader: function() {
			_log.debug('showLoader');

			var self = this;
			var opts = this.options.loader;

			this.setStatus(opts.text);
			this._createLoader();

			/*display loader after 200ms*/
			clearTimeout(this.loaderTimeout);
			this.loaderTimeout = setTimeout(function() {
				self.loader.setStyle('display', 'initial');
			}, opts.delay);
		},

		/**
		 * Hide Loader
		 * @return {void}
		 */
		hideLoader: function() {
			_log.debug('hideLoader', this.loader);

			if (!this.loader) {
				return;
			}

			clearTimeout(this.loaderTimeout);
			this.loader.destroy();
			this.loader = undefined;
			this.loaderText = undefined;
		},

		/**
		 * create loader element
		 * @return {void}
		 */
		_createLoader: function() {
			_log.debug('_createLoader', this.element);

			if (!this.element) {
				return;
			}

			var opts = this.options.loader;

			var loader = this.loader = new Element('div', {
				class: 'ui-loader',
				styles: {
					display: 'none'
				}
			}).inject(this.element);

			if (opts.text) {
				this.loaderText = new Element('span', {
					html: opts.text,
					class: 'loader-text'
				}).inject(loader, 'top');
			}

			new Element('div', {
				class: 'loader-bar'
			}).inject(loader, 'bottom');
		},

		/**
		 * set loader text
		 * @return {void}
		 */
		setLoaderText: function(text) {
			if (!this.loaderText) {
				return;
			}

			this.loaderText.set('html', text);
		}

	});

	module.exports = Loader;

});<commit_msg>enhance text options in loader module<commit_after>/**
 * Loader Module
 * @author <NAME>, <NAME>
 */
define(function(require, exports, module) {

	var _log = __debug('view-core-loader').defineLevel();

	var Loader = new Class({

		options: {
			loader: {
				text: {
					default: 'Loading...',
					statusBar: 'Loading ',
				},
				delay: 200
			}
		},

		/**
		 * init loader
		 * @return {void}
		 */
		_initLoader: function() {
			_log.debug('_initLoader');

			this.statusBarText = this.options.loader.text.statusBar;

			this.addEvents({
				getData: this.showLoader.bind(this),
				noData: this.hideLoader.bind(this),
				setList: this.hideLoader.bind(this),
				progress: this.setLoaderText.bind(this)
			});
		},

		/**
		 * Show Loader
		 * @return {void}
		 */
		showLoader: function() {
			_log.debug('showLoader');

			var self = this;
			var opts = this.options.loader;

			this.setStatus(this.statusBarText);

			if (!this.loader) {
				this._createLoader();
			}

			/*display loader after 200ms*/
			clearTimeout(this.loaderTimeout);
			this.loaderTimeout = setTimeout(function() {
				self.loader.setStyle('display', 'initial');
			}, opts.delay);
		},

		/**
		 * Hide Loader
		 * @return {void}
		 */
		hideLoader: function() {
			_log.debug('hideLoader', this.loader);

			if (!this.loader) {
				return;
			}

			clearTimeout(this.loaderTimeout);
			this.loader.destroy();
			this.loader = undefined;
			this.loaderText = undefined;
		},

		/**
		 * create loader element
		 * @return {void}
		 */
		_createLoader: function() {
			_log.debug('_createLoader', this.element);

			if (!this.element) {
				return;
			}

			var opts = this.options.loader;

			var loader = this.loader = new Element('div', {
				class: 'ui-loader',
				styles: {
					display: 'none'
				}
			}).inject(this.element);

			this.loaderText = new Element('span', {
				html: opts.text.default,
				class: 'loader-text'
			}).inject(loader, 'top');

			new Element('div', {
				class: 'loader-bar'
			}).inject(loader, 'bottom');
		},

		/**
		 * set loader text
		 * @return {void}
		 */
		setLoaderText: function(text) {
			//_log.debug('setLoaderText', this.loaderText, text);

			if (this.loaderText) {
				this.loaderText.set('html', text);
			} else if (text) {
				this.setStatus(this.statusBarText + text);
			}
		}

	});

	module.exports = Loader;

});
{'fraction_non_alphanumeric': 0.16882247992863514, 'fraction_numerical': 0.0026761819803746653, 'mean_word_length': 2.76890756302521, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '5408856', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1478, 'n_words': 294}