/*!
- * OOUI v0.26.0
+ * OOUI v0.26.4
* 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-21T00:00:53Z
+ * Date: 2018-04-17T22:23:58Z
*/
( function ( OO ) {
e.keyCode === OO.ui.Keys.LEFT ?
movement.left : movement.right
);
+ return false;
}
};
*/
OO.ui.TagMultiselectWidget.prototype.onInputKeyDown = function ( e ) {
var movement, direction,
- withMetaKey = e.metaKey || e.ctrlKey;
+ widget = this,
+ withMetaKey = e.metaKey || e.ctrlKey,
+ isMovementInsideInput = function ( direction ) {
+ var inputRange = widget.input.getRange(),
+ inputValue = widget.hasInput && widget.input.getValue();
+
+ if ( direction === 'forwards' && inputRange.to > inputValue.length - 1 ) {
+ return false;
+ }
+
+ if ( direction === 'backwards' && inputRange.from <= 0 ) {
+ return false;
+ }
+
+ return true;
+ };
if ( !this.isDisabled() ) {
// 'keypress' event is not triggered for Backspace
direction = e.keyCode === OO.ui.Keys.LEFT ?
movement.left : movement.right;
- return this.doInputArrow( e, direction, withMetaKey );
+ if ( !this.hasInput || !isMovementInsideInput( direction ) ) {
+ return this.doInputArrow( e, direction, withMetaKey );
+ }
}
}
};
/**
* Perform an action after the arrow key on the input, select the previous
- * or next item from the input.
- * See #getPreviousItem and #getNextItem
+ * item from the input.
+ * See #getPreviousItem
*
* @param {jQuery.Event} e Event data
* @param {string} direction Direction of the movement; forwards or backwards
OO.ui.TagMultiselectWidget.prototype.doInputArrow = function ( e, direction ) {
if (
this.inputPosition === 'inline' &&
- !this.isEmpty()
+ !this.isEmpty() &&
+ direction === 'backwards'
) {
- if ( direction === 'backwards' ) {
- // Get previous item
- this.getPreviousItem().focus();
- } else {
- // Get next item
- this.getNextItem().focus();
- }
+ // Get previous item
+ this.getPreviousItem().focus();
}
};
* @param {string} direction Direction of movement; 'forwards' or 'backwards'
*/
OO.ui.TagMultiselectWidget.prototype.onTagNavigate = function ( item, direction ) {
+ var firstItem = this.getItems()[ 0 ];
+
if ( direction === 'forwards' ) {
this.getNextItem( item ).focus();
- } else {
+ } else if ( !this.inputPosition === 'inline' || item !== firstItem ) {
+ // If the widget has an inline input, we want to stop at the starting edge
+ // of the tags
this.getPreviousItem( item ).focus();
}
};
defaultConfig.popupInput = defaultInput;
defaultConfig.popup.$content = defaultInput.$element;
+ defaultConfig.popup.padded = true;
this.$element.addClass( 'oo-ui-popupTagMultiselectWidget-defaultPopup' );
}