mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Add missing documentation for category widgets
Change-Id: Idd01bb8d01363cb2eaf311abae8fa5ecf7b36f0e
This commit is contained in:
parent
8039b1c2f8
commit
9507b7767e
|
@ -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 );
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue