mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
27 lines
833 B
JavaScript
27 lines
833 B
JavaScript
function Widget(config) {
|
|
this.label = config.label;
|
|
}
|
|
|
|
Widget.prototype = {
|
|
handleClick: function(event) {
|
|
// Every Widget instance is also an EventEmitter instance.
|
|
// We will emit a custom "click" event when a DOM click event
|
|
// is triggered
|
|
this.emit('click', {
|
|
event: event // Pass along the DOM event in case it is helpful to others
|
|
});
|
|
},
|
|
|
|
// Add any other methods here
|
|
setVariant: function(variant) {
|
|
// First remove all of the variant classes (this could be optimized)
|
|
this.$().removeClass('app-button-secondary');
|
|
|
|
// Then add the variant class (unless it is the default 'primary' variant)
|
|
if (variant !== 'primary') {
|
|
this.$().addClass('app-button-' + variant);
|
|
}
|
|
}
|
|
};
|
|
|
|
exports.Widget = Widget; |