diff --git a/modules/ve/ui/widgets/ve.ui.MWCategoryItemWidget.js b/modules/ve/ui/widgets/ve.ui.MWCategoryItemWidget.js index c8f4d21dee..d3899dc34b 100644 --- a/modules/ve/ui/widgets/ve.ui.MWCategoryItemWidget.js +++ b/modules/ve/ui/widgets/ve.ui.MWCategoryItemWidget.js @@ -14,7 +14,7 @@ * * @constructor * @param {Object} [config] Config options - * @cfg {Object} [metaItem] Meta Item Reference + * @cfg {Object} [item] Category item */ ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) { // Config intialization @@ -68,14 +68,22 @@ ve.inheritClass( ve.ui.MWCategoryItemWidget, ve.ui.Widget ); /* Methods */ /** - * Emits savePopupState on mousedown + * Handle mouse down events. + * + * @method + * @param {jQuery.Event} e Mouse down event + * @emits savePopupState on mousedown. */ ve.ui.MWCategoryItemWidget.prototype.onMouseDown = function () { this.emit( 'savePopupState' ); }; /** - * Emits togglePopupMenu on click + * Handle mouse click events. + * + * @method + * @param {jQuery.Event} e Mouse click event + * @emits togglePopupMenu on mousedown. */ ve.ui.MWCategoryItemWidget.prototype.onClick = function () { this.emit( 'togglePopupMenu', this ); diff --git a/modules/ve/ui/widgets/ve.ui.MWCategoryPopupWidget.js b/modules/ve/ui/widgets/ve.ui.MWCategoryPopupWidget.js index 144e086fff..0a05c348f0 100644 --- a/modules/ve/ui/widgets/ve.ui.MWCategoryPopupWidget.js +++ b/modules/ve/ui/widgets/ve.ui.MWCategoryPopupWidget.js @@ -66,25 +66,47 @@ ve.inheritClass( ve.ui.MWCategoryPopupWidget, ve.ui.PopupWidget ); /** * @event removeCategory + * @param {string} category Category name */ /** * @event updateSortkey + * @param {string} category Category name + * @param {string} sortkey New sortkey */ /* Methods */ +/** + * Handle category remove events. + * + * @method + * @emits removeCategory + */ ve.ui.MWCategoryPopupWidget.prototype.onRemoveCategory = function () { this.emit( 'removeCategory', this.category ); this.closePopup(); }; +/** + * Handle sort key form submit events. + * + * @method + * @param {jQuery.Event} e Form submit event + * @emits updateSortkey + */ ve.ui.MWCategoryPopupWidget.prototype.onSortKeySubmit = function () { this.emit( 'updateSortkey', this.category, this.sortKeyInput.$input.val() ); this.closePopup(); return false; }; +/** + * Open a category item popup. + * + * @method + * @param {ve.ui.MWCategoryItemWidget} item Category item + */ ve.ui.MWCategoryPopupWidget.prototype.openPopup = function ( item ) { this.show(); this.popupOpen = true; @@ -93,19 +115,42 @@ ve.ui.MWCategoryPopupWidget.prototype.openPopup = function ( item ) { this.setPopup( item ); }; +/** + * Load item information into the popup. + * + * @method + * @param {ve.ui.MWCategoryItemWidget} item Category item + */ ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item ) { this.sortKeyInput.$input.val( item.sortKey ); }; +/** + * Close the popup. + * + * @method + */ ve.ui.MWCategoryPopupWidget.prototype.closePopup = function () { this.hide(); this.popupOpen = false; }; +/** + * Set the default sort key. + * + * @method + * @param {string} value Default sort key value + */ ve.ui.MWCategoryPopupWidget.prototype.setDefaultSortKey = function ( value ) { this.sortKeyInput.$input.attr( 'placeholder', value ); }; +/** + * Display the popup next to an item. + * + * @method + * @param {ve.ui.MWCategoryItemWidget} item Category item + */ ve.ui.MWCategoryPopupWidget.prototype.setPopup = function ( item ) { var left = item.$.offset().left + ( item.$.width() - 17 ), top = item.$.offset().top + item.$.height(), diff --git a/modules/ve/ui/widgets/ve.ui.MWCategoryWidget.js b/modules/ve/ui/widgets/ve.ui.MWCategoryWidget.js index b83ca6dee2..781ae88881 100644 --- a/modules/ve/ui/widgets/ve.ui.MWCategoryWidget.js +++ b/modules/ve/ui/widgets/ve.ui.MWCategoryWidget.js @@ -63,12 +63,18 @@ ve.inheritClass( ve.ui.MWCategoryWidget, ve.ui.Widget ); /** * @event newCategory - * @param {Object} item category group item + * @param {Object} item Category item + * @param {string} item.name Fully prefixed category name + * @param {string} item.value Category value (name without prefix) + * @param {Object} item.metaItem Category meta item */ /** * @event updateSortkey - * * @param {Object} item category group item + * @param {Object} item Category item + * @param {string} item.name Fully prefixed category name + * @param {string} item.value Category value (name without prefix) + * @param {Object} item.metaItem Category meta item */ /* Methods */ @@ -103,8 +109,9 @@ ve.ui.MWCategoryWidget.prototype.onLookupMenuItemSelect = function ( item ) { }; /** - * Calls metaItem remove method + * Removes category from model. * + * @method * @param {string} name category name */ ve.ui.MWCategoryWidget.prototype.onRemoveCategory = function ( name ) { @@ -112,8 +119,9 @@ ve.ui.MWCategoryWidget.prototype.onRemoveCategory = function ( name ) { }; /** - * Update sortkey value, emit upsteSortkey event + * Update sortkey value, emit updateSortkey event * + * @method * @param {string} name * @param {string} value */