define('application/widgets/infoblock', [
'application/widgets/pointerselectablebutton',
'rofl/widgets/label'
], function (
Button,
Label
) {
'use strict';
return Button.extend({
/**
* Initialises the button.
*
* @param {Object} config - The config objects.
*/
init: function init (config) {
var id = config.id || 'infoblock',
position = config.position || null;
init.base.call(this, id);
this.addClass('info-block-basic');
if (position) {
this.addClass('info-block-' + position);
}
this.setDisabled(true);
this._build(config);
},
/**
* Builds the info block.
*
* @param {Object} config - The config for text and icon.
*/
_build: function (config) {
this._buildIcon(config.classname);
this._buildLabel(config.text);
},
/**
* Builds a search icon label.
*
* @param {string | Array} classname - Icon class.
* @private
*/
_buildIcon: function (classname) {
var icon = new Label({ classNames: classname, enableHTML: true, text: '' });
this.appendChildWidget(icon);
},
/**
* Builds the widget.
*
* @param {string} text - The text to set.
* @private
*/
_buildLabel: function (text) {
var label = this._label = new Label({ text: text || '', classNames: ['text'] });
this.appendChildWidget(label);
},
/**
* Shows the widget.
*
* @param {Object} opts - The options.
*/
show: function show (opts) {
if (!this.isVisible()) {
show.base.call(this, opts);
}
},
/**
* Hides the widget.
*
* @param {Object} opts - The options.
*/
hide: function hide (opts) {
if (this.isVisible()) {
hide.base.call(this, opts);
}
}
});
});