mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 16:20:52 +00:00
Simplify and fix category popup widget checks
Bug: T86357 Change-Id: I9a85267f6da0077e2167a92f25a8dc41074e6548
This commit is contained in:
parent
9721998763
commit
7888c688b7
|
@ -38,11 +38,6 @@ ve.ui.MWCategoryItemWidget = function VeUiMWCategoryItemWidget( config ) {
|
|||
this.isHidden = config.hidden;
|
||||
this.isMissing = config.missing;
|
||||
|
||||
// Events
|
||||
this.$button.on( {
|
||||
mousedown: this.onMouseDown.bind( this )
|
||||
} );
|
||||
|
||||
// Initialization
|
||||
this.setLabel( config.redirectTo || this.value );
|
||||
if ( config.redirectTo ) {
|
||||
|
@ -65,10 +60,6 @@ OO.mixinClass( ve.ui.MWCategoryItemWidget, OO.ui.mixin.DraggableElement );
|
|||
|
||||
/* Events */
|
||||
|
||||
/**
|
||||
* @event savePopupState
|
||||
*/
|
||||
|
||||
/**
|
||||
* @event togglePopupMenu
|
||||
* @param {ve.ui.MWCategoryItemWidget} item Item to load into popup
|
||||
|
@ -76,26 +67,12 @@ OO.mixinClass( ve.ui.MWCategoryItemWidget, OO.ui.mixin.DraggableElement );
|
|||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* Handle mouse down events.
|
||||
*
|
||||
* @method
|
||||
* @param {jQuery.Event} e Mouse down event
|
||||
* @fires savePopupState on mousedown.
|
||||
*/
|
||||
ve.ui.MWCategoryItemWidget.prototype.onMouseDown = function () {
|
||||
this.emit( 'savePopupState' );
|
||||
|
||||
// Parent method
|
||||
return ve.ui.MWCategoryItemWidget.super.prototype.onMouseDown.apply( this, arguments );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle mouse click events.
|
||||
*
|
||||
* @method
|
||||
* @param {jQuery.Event} e Mouse click event
|
||||
* @fires togglePopupMenu on mousedown.
|
||||
* @fires togglePopupMenu on click.
|
||||
*/
|
||||
ve.ui.MWCategoryItemWidget.prototype.onClick = function () {
|
||||
this.emit( 'togglePopupMenu', this );
|
||||
|
|
|
@ -164,6 +164,7 @@ ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item )
|
|||
ve.ui.MWCategoryPopupWidget.prototype.closePopup = function () {
|
||||
this.toggle( false );
|
||||
this.popupOpen = false;
|
||||
this.category = null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -37,8 +37,6 @@ ve.ui.MWCategoryWidget = function VeUiMWCategoryWidget( config ) {
|
|||
this.categoryRedirects = {};
|
||||
// Title cache - will contain entries even if title is already normalized
|
||||
this.normalizedTitles = {};
|
||||
this.popupState = false;
|
||||
this.savedPopupState = false;
|
||||
this.popup = new ve.ui.MWCategoryPopupWidget();
|
||||
this.input = new ve.ui.MWCategoryInputWidget( this, { $overlay: config.$overlay } );
|
||||
this.forceCapitalization = mw.config.get( 'wgCaseSensitiveNamespaces' ).indexOf( categoryNamespace ) === -1;
|
||||
|
@ -48,8 +46,7 @@ ve.ui.MWCategoryWidget = function VeUiMWCategoryWidget( config ) {
|
|||
this.input.connect( this, { choose: 'onInputChoose' } );
|
||||
this.popup.connect( this, {
|
||||
removeCategory: 'onRemoveCategory',
|
||||
updateSortkey: 'onUpdateSortkey',
|
||||
hide: 'onPopupHide'
|
||||
updateSortkey: 'onUpdateSortkey'
|
||||
} );
|
||||
this.connect( this, {
|
||||
drag: 'onDrag'
|
||||
|
@ -209,20 +206,6 @@ ve.ui.MWCategoryWidget.prototype.clearItems = function () {
|
|||
this.categories = {};
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets popup state when popup is hidden
|
||||
*/
|
||||
ve.ui.MWCategoryWidget.prototype.onPopupHide = function () {
|
||||
this.popupState = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Saves current popup state
|
||||
*/
|
||||
ve.ui.MWCategoryWidget.prototype.onSavePopupState = function () {
|
||||
this.savedPopupState = this.popupState;
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggles popup menu per category item
|
||||
*
|
||||
|
@ -230,7 +213,7 @@ ve.ui.MWCategoryWidget.prototype.onSavePopupState = function () {
|
|||
*/
|
||||
ve.ui.MWCategoryWidget.prototype.onTogglePopupMenu = function ( item ) {
|
||||
// Close open popup.
|
||||
if ( this.savedPopupState === false || item.value !== this.popup.category ) {
|
||||
if ( item.value !== this.popup.category ) {
|
||||
this.popup.openPopup( item );
|
||||
} else {
|
||||
// Handle toggle
|
||||
|
@ -367,7 +350,6 @@ ve.ui.MWCategoryWidget.prototype.addItems = function ( items, index ) {
|
|||
|
||||
categoryItem = new ve.ui.MWCategoryItemWidget( config );
|
||||
categoryItem.connect( widget, {
|
||||
savePopupState: 'onSavePopupState',
|
||||
togglePopupMenu: 'onTogglePopupMenu'
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in a new issue