define('application/widgets/detail/iconbutton', [
'application/widgets/pointerfocusablebutton',
'rofl/widgets/label'
], function (
PointerFocusableButton,
Label
) {
'use strict';
return PointerFocusableButton.extend({
/**
* Initialises the button.
*
* @param {string} [id] - The id. Optional.
* @param {string} text - The button text.
* @param {string | array} classname - The icon classname to set.
*/
init: function init (id, text, classname) {
init.base.call(this, id);
this.addClass('icon-button');
if (id === 'back-button') {
this.addClass(id);
}
this._build(text, classname);
},
/**
* Builds the widget.
*
* @param {string} text - The text to set.
* @param {string | array} classname - The icon classname to set.
* @private
*/
_build: function (text, classname) {
var helper = new Label({ text: '', classNames: ['v-align-helper'] });
this.appendChildWidget(helper);
this._buildIcon(classname);
this._buildLabel(text);
},
/**
* Builds the label.
*
* @param {string} text - The text to set.
* @private
*/
_buildLabel: function (text) {
var label = this._label = new Label({ text: text || '', classNames: ['v-align-target'] });
this.appendChildWidget(label);
},
/**
* Builds a search icon label.
*
* @param {string | Array} classname - Icon class.
* @private
*/
_buildIcon: function (classname) {
var icon;
if (!(classname instanceof Array)) {
classname = [classname];
}
classname.push('v-align-target');
icon = this._icon = new Label({ text: '', classNames: classname });
this.appendChildWidget(icon);
}
});
});