Source: widgets/search/lastsearched.js

define('application/widgets/search/lastsearched', [
    'application/widgets/pointerfocusablebutton',
    'rofl/widgets/label'
], function (
    PointerFocusableButton,
    Label
) {
    'use strict';

    return PointerFocusableButton.extend({

        /**
         * Initialises the button.
         *
         * @param {string} text - The button text.
         * @param {string} [id] - The id. Optional.
         */
        init: function init (text, id) {
            init.base.call(this, id);
            this.addClass('last-searched');

            this._build(text);
        },

        /**
         * Builds the widget.
         *
         * @param {string} text - The text to set.
         * @private
         */
        _build: function (text) {
            this._buildIcon();
            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 || '' });

            this.appendChildWidget(label);
        },

        /**
         * Builds a search icon label.
         *
         * @private
         */
        _buildIcon: function () {
          var icon = new Label({ text: '', classNames: ['icon', 'icon-history-v2'] });

          this.appendChildWidget(icon);
        },

        /**
         * Returns a last-searched button label.
         *
         * @returns {Object} Label.
         * @private
         */
        getLabel: function () {
            return this._label;
        }
    });
});