diff --git a/resources/js/ext.uls.actions.menu.item.js b/resources/js/ext.uls.actions.menu.item.js index e06f47bc..999bb2e8 100644 --- a/resources/js/ext.uls.actions.menu.item.js +++ b/resources/js/ext.uls.actions.menu.item.js @@ -1,18 +1,34 @@ ( function () { - var ActionsMenuItem = function ( icon, text, handler ) { + var ActionsMenuItem = function ( icon, text, handler, href ) { this.icon = icon; this.text = text; this.handler = handler; + this.href = href; }; + /** + * @return {OO.ui.ButtonWidget} + */ ActionsMenuItem.prototype.render = function () { - return new OO.ui.ButtonWidget( { + var actionButtonOptions = { framed: false, icon: this.icon, label: this.text, classes: [ 'uls-language-action' ], flags: [ 'progressive' ] - } ); + }; + + if ( this.href ) { + actionButtonOptions.href = this.href; + } + + var actionButton = new OO.ui.ButtonWidget( actionButtonOptions ); + + if ( !this.href ) { + actionButton.$element.one( 'click', this.handler ); + } + + return actionButton; }; module.exports = ActionsMenuItem; diff --git a/resources/js/ext.uls.actions.menu.js b/resources/js/ext.uls.actions.menu.js index 9178734f..347c8778 100644 --- a/resources/js/ext.uls.actions.menu.js +++ b/resources/js/ext.uls.actions.menu.js @@ -7,7 +7,7 @@ this.options = options; this.$template = $( ActionsMenu.template ); this.actionItems = options.actions.map( function ( action ) { - return new ActionsMenuItem( action.icon, action.text, action.handler ); + return new ActionsMenuItem( action.icon, action.text, action.handler, action.href ); } ); this.rendered = false; this.shown = false; @@ -65,14 +65,14 @@ actionItem = new ActionsMenuItem( actionItem.icon, actionItem.text, - actionItem.handler + actionItem.handler, + actionItem.href ); } var actionButton = actionItem.render(); this.$template.find( '.uls-language-action-items' ).prepend( actionButton.$element ); - actionButton.$element.one( 'click', actionItem.handler ); }, i18n: function () {