mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Set sort keys on click-out too
Was previously only set on form submission, but there was no button so you had to press the Enter key Bug: 48555 Change-Id: I256d2b21bc2306959f6d6a0373386054b21dadfe
This commit is contained in:
parent
8039b1c2f8
commit
1be42c8fa6
|
@ -23,6 +23,8 @@ ve.ui.MWCategoryPopupWidget = function VeUiMwCategoryPopupWidget ( config ) {
|
|||
|
||||
// Properties
|
||||
this.category = null;
|
||||
this.origSortkey = null;
|
||||
this.removed = false;
|
||||
this.$title = this.$$( '<label>' );
|
||||
this.$menu = this.$$( '<div>' );
|
||||
this.removeButton = new ve.ui.IconButtonWidget( {
|
||||
|
@ -36,6 +38,7 @@ ve.ui.MWCategoryPopupWidget = function VeUiMwCategoryPopupWidget ( config ) {
|
|||
.append( this.sortKeyLabel.$, this.sortKeyInput.$ );
|
||||
|
||||
// Events
|
||||
this.connect( this, { 'hide': 'onHide' } );
|
||||
this.removeButton.connect( this, { 'click': 'onRemoveCategory' } );
|
||||
this.$sortKeyForm.on( 'submit', ve.bind( this.onSortKeySubmit, this ) );
|
||||
|
||||
|
@ -75,12 +78,12 @@ ve.inheritClass( ve.ui.MWCategoryPopupWidget, ve.ui.PopupWidget );
|
|||
/* Methods */
|
||||
|
||||
ve.ui.MWCategoryPopupWidget.prototype.onRemoveCategory = function () {
|
||||
this.removed = true;
|
||||
this.emit( 'removeCategory', this.category );
|
||||
this.closePopup();
|
||||
};
|
||||
|
||||
ve.ui.MWCategoryPopupWidget.prototype.onSortKeySubmit = function () {
|
||||
this.emit( 'updateSortkey', this.category, this.sortKeyInput.$input.val() );
|
||||
this.closePopup();
|
||||
return false;
|
||||
};
|
||||
|
@ -94,6 +97,7 @@ ve.ui.MWCategoryPopupWidget.prototype.openPopup = function ( item ) {
|
|||
};
|
||||
|
||||
ve.ui.MWCategoryPopupWidget.prototype.loadCategoryIntoPopup = function ( item ) {
|
||||
this.origSortkey = item.sortkey;
|
||||
this.sortKeyInput.$input.val( item.sortKey );
|
||||
};
|
||||
|
||||
|
@ -115,3 +119,10 @@ ve.ui.MWCategoryPopupWidget.prototype.setPopup = function ( item ) {
|
|||
this.$.css( { 'left': left, 'top': top } );
|
||||
this.display( left, top, width, height );
|
||||
};
|
||||
|
||||
ve.ui.MWCategoryPopupWidget.prototype.onHide = function() {
|
||||
var newSortkey = this.sortKeyInput.$input.val();
|
||||
if ( !this.removed && newSortkey !== this.origSortkey ) {
|
||||
this.emit( 'updateSortkey', this.category, this.sortKeyInput.$input.val() );
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue