/*!
- * OOUI v0.25.3
+ * OOUI v0.26.1
* https://www.mediawiki.org/wiki/OOUI
*
* Copyright 2011–2018 OOUI Team and other contributors.
* Released under the MIT license
* http://oojs.mit-license.org
*
- * Date: 2018-03-07T06:52:35Z
+ * Date: 2018-03-23T23:42:32Z
*/
( function ( OO ) {
*/
OO.ui.OutlineOptionWidget.prototype.setPressed = function ( state ) {
OO.ui.OutlineOptionWidget.parent.prototype.setPressed.call( this, state );
- if ( this.pressed ) {
- this.setFlags( { progressive: true } );
- } else if ( !this.selected ) {
- this.setFlags( { progressive: false } );
- }
return this;
};
*/
OO.ui.OutlineOptionWidget.prototype.setSelected = function ( state ) {
OO.ui.OutlineOptionWidget.parent.prototype.setSelected.call( this, state );
- if ( this.selected ) {
- this.setFlags( { progressive: true } );
- } else {
- this.setFlags( { progressive: false } );
- }
return this;
};
* Item validity has changed
*/
+/**
+ * @event disabled
+ * @param {boolean} isDisabled Item is disabled
+ *
+ * Item disabled state has changed
+ */
+
/* Methods */
/**
* @inheritdoc
+ * @fires disabled
*/
OO.ui.TagItemWidget.prototype.setDisabled = function ( state ) {
// Parent method
if ( this.closeButton ) {
this.closeButton.setDisabled( state );
}
+
+ this.emit( 'disabled', this.isDisabled() );
return this;
};
OO.ui.TagItemWidget.prototype.onKeyDown = function ( e ) {
var movement;
- if ( e.keyCode === OO.ui.Keys.BACKSPACE || e.keyCode === OO.ui.Keys.DELETE ) {
+ if ( !this.isDisabled() && e.keyCode === OO.ui.Keys.BACKSPACE || e.keyCode === OO.ui.Keys.DELETE ) {
this.remove();
return false;
} else if ( e.keyCode === OO.ui.Keys.ENTER ) {
this.aggregate( {
remove: 'itemRemove',
navigate: 'itemNavigate',
- select: 'itemSelect'
+ select: 'itemSelect',
+ disabled: 'itemDisabled'
} );
this.connect( this, {
itemRemove: 'onTagRemove',
itemSelect: 'onTagSelect',
+ itemDisabled: 'onTagDisabled',
itemNavigate: 'onTagNavigate',
change: 'onChangeTags'
} );
// Delete the last item
items = this.getItems();
item = items[ items.length - 1 ];
- this.removeItems( [ item ] );
- // If Ctrl/Cmd was pressed, delete item entirely.
- // Otherwise put it into the text field for editing.
- if ( !withMetaKey ) {
- this.input.setValue( item.getData() );
+
+ if ( !item.isDisabled() ) {
+ this.removeItems( [ item ] );
+ // If Ctrl/Cmd was pressed, delete item entirely.
+ // Otherwise put it into the text field for editing.
+ if ( !withMetaKey ) {
+ this.input.setValue( item.getData() );
+ }
}
return false;
}
};
+/**
+ * Respond to item disabled state change
+ *
+ * @param {OO.ui.TagItemWidget} item Selected item
+ * @param {boolean} isDisabled Item is disabled
+ */
+OO.ui.TagMultiselectWidget.prototype.onTagDisabled = function ( item, isDisabled ) {
+ if ( isDisabled ) {
+ // Move item to start if it is disabled
+ this.addItems( item, 0 );
+ }
+};
/**
* Respond to change event, where items were added, removed, or cleared.
*/
highlightedItem = this.menu.findHighlightedItem(),
item = this.menu.findItemFromData( inputValue );
+ if ( !inputValue ) {
+ return;
+ }
+
// Override the parent method so we add from the menu
// rather than directly from the input