Henning Snater has uploaded a new change for review. https://gerrit.wikimedia.org/r/188039
Change subject: SnakTypeSelector: Updated code documentation ...................................................................... SnakTypeSelector: Updated code documentation Change-Id: I0c5904898e6b3c1340304352e220426380b69356 --- M lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js 1 file changed, 40 insertions(+), 44 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/39/188039/1 diff --git a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js index 2440629..e17787b 100644 --- a/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js +++ b/lib/resources/jquery.wikibase/snakview/snakview.SnakTypeSelector.js @@ -1,54 +1,56 @@ -/** - * @licence GNU GPL v2+ - * @author H. Snater < [email protected] > - * @author Daniel Werner < [email protected] > - */ ( function( mw, $ ) { 'use strict'; var PARENT = $.Widget; /** - * Selector for choosing a Snak type. This will display all Snak types which can be displayed - * by jQuery.snakview (this is the case if there is a jQuery.snakview.variations.Variation - * object registered for a certain type of Snak). - * - * NOTE: Because this is tightly bound to the snakview variations, this can't be considered an - * independent wiki an thus should be considered part of the jQuery.wikibase.snakview rather - * than as a stand alone widget. - * There could also be some sort of generic menu widget. Menu items could be defined via some - * array of plain objects with label/key fields and this widget would be obsolete since all - * available variations could be given to such a widget without much overhead in code. This - * would also allow for an independent snak type selector widget which does not only list - * Snaks which are available as variation objects. - * + * Selector for choosing a `Snak` type offering to select from a list of all `Snak` types which + * a `jQuery.snakview.variations.Variation` is registered for and, thus, can be displayed by a + * `jQuery.wikibase.snakview`. + * Because of being tightly bound to the `jQuery.wikibase.snakview.variations`, the widget is + * considered part of the `jQuery.wikibase.snakview` rather than being a stand-alone widget. + * @see jQuery.wikibase.snakview + * @see jQuery.wikibase.snakview.variations + * @see jQuery.wikibase.snakview.variations.Variation + * @see wikibase.datamodel.Snak + * @class jQuery.wikibase.snakview.SnakTypeSelector + * @extends jQuery.Widget * @since 0.4 + * @licence GNU GPL v2+ + * @author H. Snater < [email protected] > + * @author Daniel Werner < [email protected] > * - * @event change Triggered when the snak type changed. - * (1) {jQuery.Event} + * @constructor + */ + /** + * @event change + * Triggered when the `Snak` type changed. + * @param {jQuery.Event} event */ $.widget( 'wikibase.SnakTypeSelector', PARENT, { /** - * Icon node. - * @type {jQuery} + * @property {jQuery} + * @private */ - $icon: null, + _$icon: null, /** - * The menu's Widget object - * @type Object + * @property {jQuery.ui.menu} + * @private */ _menu: null, /** - * Will hold the function for removing global listeners if there are any. If not, this - * will hold an empty function instead. - * @type Function + * The function for removing global event listeners, if there are any. Empty function if + * no gloabel event listeners are registered. + * @property {Function} + * @private */ _unbindGlobalListenersFn: $.noop, /** * @see jQuery.Widget._create + * @protected */ _create: function() { var self = this, @@ -100,7 +102,7 @@ $( window ).on( 'resize.' + widgetName, degrade ); } ); - this.$icon = $( '<span/>' ) + this._$icon = $( '<span/>' ) .addClass( 'ui-icon ui-icon-snaktypeselector' ) .appendTo( this.element ); @@ -123,7 +125,7 @@ this._menu.destroy(); $menu.remove(); - this.$icon.remove(); + this._$icon.remove(); this.element.removeClass( 'ui-state-default ui-state-hover ' + this.widgetBaseClass ); @@ -135,7 +137,6 @@ /** * @see jQuery.Widget.disable - * @since 0.4 */ disable: function() { this._menu.element.hide(); @@ -146,7 +147,6 @@ /** * @see jQuery.Widget.enable - * @since 0.4 */ enable: function() { this.element.removeClass( 'ui-state-disabled' ); @@ -155,15 +155,14 @@ /** * Returns whether the widget is currently disabled. - * @return 0.4 */ isDisabled: function() { return this.option( 'disabled' ); }, /** - * Returns a DOM structure for the selector's menu where the Snak type can be chosen from. - * @since 0.4 + * Returns a DOM structure for the selector's menu the `Snak` type can be chosen from. + * @private * * @return jQuery */ @@ -191,12 +190,10 @@ }, /** - * Returns the Snak type marked as selected. If the first parameter is set, it is has to - * be a string and is considered the new Snak type. - * @since 0.4 + * Gets the current `Snak` type or sets a new `Snak` type. * * @param {string|null} [snakType] - * @return {string|null|undefined} undefined in case of using this as a setter. + * @return {string|null|undefined} */ snakType: function( snakType ) { if( snakType === undefined ) { @@ -209,8 +206,8 @@ }, /** - * Activates the given snak type while enabling all others. - * @since 0.4 + * Activates a `Snak` type in the menu. + * @private * * @param {string|null} snakType */ @@ -230,14 +227,13 @@ }, /** - * Positions the menu. - * @since 0.4 + * (Re-)aligns the menu. */ repositionMenu: function() { var isRtl = $( 'body' ).hasClass( 'rtl' ); this._menu.element.position( { - of: this.$icon, + of: this._$icon, my: ( isRtl ? 'right' : 'left' ) + ' top', at: ( isRtl ? 'left' : 'right' ) + ' bottom', offset: '0 1', -- To view, visit https://gerrit.wikimedia.org/r/188039 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0c5904898e6b3c1340304352e220426380b69356 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Henning Snater <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
