Esanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/98097
Change subject: Update OOJ-UI to include GroupButtonWidget ...................................................................... Update OOJ-UI to include GroupButtonWidget Change-Id: I6099b917aa15a5e25b5ec018b8460962d200889d --- M modules/oojs-ui/oojs-ui.js M modules/oojs-ui/oojs-ui.svg.css 2 files changed, 79 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/97/98097/1 diff --git a/modules/oojs-ui/oojs-ui.js b/modules/oojs-ui/oojs-ui.js index f952bd3..1f7455f 100644 --- a/modules/oojs-ui/oojs-ui.js +++ b/modules/oojs-ui/oojs-ui.js @@ -1,12 +1,12 @@ /*! - * OOJS UI v0.1.0-pre (e5ef1e5b28) + * OOJS UI v0.1.0-pre (e7ceee057a) * https://www.mediawiki.org/wiki/OOJS * * Copyright 2011-2013 OOJS Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: Mon Nov 25 2013 10:40:32 GMT+0000 (GMT) + * Date: Thu Nov 28 2013 13:36:15 GMT+0000 (GMT) */ ( function () { @@ -4033,6 +4033,81 @@ return false; }; /** + * Creates an OO.ui.GroupButtonWidget object. + * + * @class + * @extends OO.ui.Widget + * + * @param {Object} [config] Configuration options + * @cfg {Object} [group] Button group parameters organized by { 'label': returnValue } + * where 'returnValue' is the value returned upon click + */ +OO.ui.GroupButtonWidget = function OoUiGroupButtonWidget( config ) { + var item, + counter = 0; + + // Configuration initialization + config = $.extend( { 'target': '_blank' }, config ); + + // Parent constructor + OO.ui.Widget.call( this, config ); + + // Initialization + this.$element.addClass( 've-ui-groupButtonWidget' ); + + this.value = null; + this.group = config.group; + this.buttons = {}; + // Set up the buttons + for ( item in this.group ) { + this.buttons[item] = new OO.ui.PushButtonWidget( { + 'label': item, + } ); + // bind to master click event + this.buttons[item].on( 'click', OO.ui.bind( this.onClick, this, { 'returnValue': this.group[item] } ) ); + // add button DOM + this.$element.append( this.buttons[item].$element ); + // separate lines if needed + // TODO: separate into lines through CSS instead + if ( ++counter >= 8 ) { + this.$element.append( $( '<br />' ) ); + counter = 0; + } + } + +}; + +/* Inheritance */ + +OO.inheritClass( OO.ui.GroupButtonWidget, OO.ui.Widget ); + +/* Events */ + +/** + * @event click + */ + +/** + * Handle onClick event to any of the buttons in the group + * + * @method + * @param {jQuery.Event} e Mouse click event + * @fires click + */ +OO.ui.GroupButtonWidget.prototype.onClick = function ( config ) { + this.value = config.returnValue; + this.emit( 'click' ); +}; + +/** + * Get the value of the pushed button from the group + * + * @returns {string} value of the selected button from the group + */ +OO.ui.GroupButtonWidget.prototype.getValue = function () { + return this.value; +}; +/** * Creates an OO.ui.IconButtonWidget object. * * @class diff --git a/modules/oojs-ui/oojs-ui.svg.css b/modules/oojs-ui/oojs-ui.svg.css index 3301808..7c82fc8 100644 --- a/modules/oojs-ui/oojs-ui.svg.css +++ b/modules/oojs-ui/oojs-ui.svg.css @@ -1,12 +1,12 @@ /*! - * OOJS UI v0.1.0-pre-svg (e5ef1e5b28) + * OOJS UI v0.1.0-pre-svg (e7ceee057a) * https://www.mediawiki.org/wiki/OOJS * * Copyright 2011-2013 OOJS Team and other contributors. * Released under the MIT license * http://oojs.mit-license.org * - * Date: Mon Nov 25 2013 10:40:32 GMT+0000 (GMT) + * Date: Thu Nov 28 2013 13:36:15 GMT+0000 (GMT) */ /*csslint vendor-prefix:false */ -- To view, visit https://gerrit.wikimedia.org/r/98097 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6099b917aa15a5e25b5ec018b8460962d200889d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits