mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Merge "VE multiSuggest bug fixes."
This commit is contained in:
commit
2c2d7b48dc
|
@ -120,36 +120,15 @@
|
|||
visible = true;
|
||||
$multiSuggest.show();
|
||||
}
|
||||
bindKeyDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Binds a keydown event to override default behavior for enter key.
|
||||
// Binds on open, unbinds on close.
|
||||
function bindKeyDown() {
|
||||
$input.on( 'keydown', function( e ) {
|
||||
var $item;
|
||||
// Enter key.
|
||||
if ( e.which === 13 ) {
|
||||
e.preventDefault();
|
||||
$item = $multiSuggest
|
||||
.find( '.' + options.prefix + '-suggest-item.selected' );
|
||||
if ( $item.length > 0 ) {
|
||||
select.call( this, $item.text() );
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} );
|
||||
}
|
||||
// Closes the dropdown.
|
||||
function close() {
|
||||
if ( visible ) {
|
||||
setTimeout( function() {
|
||||
visible = false;
|
||||
$multiSuggest.hide();
|
||||
$input.unbind( 'keydown' );
|
||||
}, 100 );
|
||||
}
|
||||
}
|
||||
|
@ -186,14 +165,13 @@
|
|||
).append(
|
||||
$( '<div>', options.doc )
|
||||
.prop( 'class', options.prefix + '-suggest-wrap' )
|
||||
);
|
||||
// Add group
|
||||
$multiSuggest
|
||||
.append( $group )
|
||||
// Add a clear break.
|
||||
.append(
|
||||
).append(
|
||||
$( '<div>', options.doc ).css( 'clear', 'both' )
|
||||
);
|
||||
// Add group
|
||||
$multiSuggest.append( $group );
|
||||
|
||||
// Find the group wrapper element.
|
||||
$groupWrap = $group.find( '.' + options.prefix + '-suggest-wrap' );
|
||||
// If no items, add a dummy element to take up space.
|
||||
|
@ -212,7 +190,7 @@
|
|||
.on( 'mousedown', onItemMousedown )
|
||||
.appendTo( $groupWrap );
|
||||
// Select this item by default
|
||||
if ( group.items[i] === $input.val() ) {
|
||||
if ( group.items[i].toLowerCase() === $input.val().toLowerCase() ) {
|
||||
$item.addClass( 'selected' );
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +236,7 @@
|
|||
}, 250 );
|
||||
},
|
||||
// Handle arrow up and down keys.
|
||||
'keyup': function( e ) {
|
||||
'keydown': function( e ) {
|
||||
var $item,
|
||||
$items = $multiSuggest
|
||||
.find( '.' + options.prefix + '-suggest-item' ),
|
||||
|
@ -292,6 +270,20 @@
|
|||
selected = ( selected + $items.length - 1 ) % $items.length;
|
||||
$items.removeClass( 'selected' );
|
||||
$( $items[selected] ).addClass( 'selected' );
|
||||
// Enter key.
|
||||
} else if ( e.which === 13 ) {
|
||||
// Only if the dropdown is open.
|
||||
if ( visible ) {
|
||||
e.preventDefault();
|
||||
$item = $multiSuggest
|
||||
.find( '.' + options.prefix + '-suggest-item.selected' );
|
||||
if ( $item.length > 0 ) {
|
||||
select.call( this, $item.text() );
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
'focus': function(){
|
||||
|
|
|
@ -270,7 +270,7 @@ ve.ui.LinkInspector.prototype.initMultiSuggest = function() {
|
|||
title = new mw.Title( query );
|
||||
modifiedQuery = title.getPrefixedText();
|
||||
// If page doesn't exist, add New Page group.
|
||||
if ( ve.inArray( modifiedQuery, results ) === -1 ) {
|
||||
if ( ve.indexOf( modifiedQuery, results ) === -1 ) {
|
||||
groups['new'] = {
|
||||
label: ve.msg( 'visualeditor-linkinspector-suggest-new-page' ),
|
||||
items: [modifiedQuery],
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
background-image: url(images/gray.png);
|
||||
background-position: 8em top;
|
||||
background-repeat: repeat-y;
|
||||
padding: 0.5em 0;
|
||||
padding: 0.5em 0 0 0;
|
||||
width: 20em;
|
||||
font-size: 1em;
|
||||
z-index: 101;
|
||||
|
@ -123,6 +123,11 @@
|
|||
-moz-box-shadow: 0 .15em .5em 0 rgba(0, 0, 0, 0.2);
|
||||
box-shadow: 0 .15em .5em 0 rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.ve-ui-suggest-container {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.ve-ui-suggest-label {
|
||||
float: left;
|
||||
width: 6.5em;
|
||||
|
|
Loading…
Reference in a new issue