blob: 235f6b72ba32d6a2e738e38c91e921aab9074672 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
/**
* Investigate Menu Select Widget
*
* @class
*
* @constructor
* @param {Object} [config] Configuration options
*/
var InvestigateMenuSelectWidget = function ( config ) {
// Parent constructor
InvestigateMenuSelectWidget.super.call( this, config );
};
/* Setup */
OO.inheritClass( InvestigateMenuSelectWidget, OO.ui.MenuSelectWidget );
/**
* @inheritdoc
*/
InvestigateMenuSelectWidget.prototype.onDocumentMouseUp = function ( e ) {
if ( !this.selecting ) {
var item = this.findTargetItem( e );
if ( item && item.isSelectable() ) {
this.selecting = item;
}
}
if ( !this.isDisabled() && e.which === OO.ui.MouseButtons.LEFT && this.selecting ) {
this.emit( 'investigate', this.selecting );
}
return InvestigateMenuSelectWidget.super.prototype.onDocumentMouseUp.call( this, e );
};
/**
* @inheritdoc
*/
InvestigateMenuSelectWidget.prototype.onDocumentKeyDown = function ( e ) {
var selected = this.findSelectedItems(),
currentItem = this.findHighlightedItem() || (
Array.isArray( selected ) ? selected[ 0 ] : selected
);
if ( e.keyCode === OO.ui.Keys.ENTER ) {
this.emit( 'investigate', currentItem );
}
return InvestigateMenuSelectWidget.super.prototype.onDocumentKeyDown.call( this, e );
};
module.exports = InvestigateMenuSelectWidget;
|