| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
ve.ui.MWFloatingHelpElement = function VeUiMWFloatingHelpElement( config ) { |
| 21 |
|
| 22 |
ve.ui.MWFloatingHelpElement.super.call( this, config ); |
| 23 |
|
| 24 |
this.helpDialog = new ve.ui.MWFloatingHelpDialog( config ); |
| 25 |
this.helpButton = new OO.ui.ButtonWidget( { |
| 26 |
icon: 'help', |
| 27 |
label: config.label, |
| 28 |
title: config.title, |
| 29 |
invisibleLabel: true, |
| 30 |
flags: 'progressive', |
| 31 |
rel: 'help', |
| 32 |
classes: [ 've-ui-mwFloatingHelpElement-toggle' ] |
| 33 |
} ).connect( |
| 34 |
this, { click: 'onClick' } |
| 35 |
); |
| 36 |
|
| 37 |
this.windowManager = new OO.ui.WindowManager(); |
| 38 |
this.windowManager.addWindows( [ this.helpDialog ] ); |
| 39 |
this.windowManager.$element.addClass( 've-ui-mwFloatingHelpElement-windowManager' ); |
| 40 |
|
| 41 |
if ( OO.ui.isMobile() ) { |
| 42 |
$( OO.ui.getTeleportTarget() ).append( this.windowManager.$element ); |
| 43 |
} else { |
| 44 |
this.$element.append( this.windowManager.$element ); |
| 45 |
} |
| 46 |
|
| 47 |
this.$element |
| 48 |
.addClass( 've-ui-mwFloatingHelpElement' ) |
| 49 |
.append( this.helpButton.$element ); |
| 50 |
}; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
OO.inheritClass( ve.ui.MWFloatingHelpElement, OO.ui.Element ); |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
ve.ui.MWFloatingHelpElement.prototype.onClick = function () { |
| 59 |
if ( !this.helpButton.hasFlag( 'primary' ) ) { |
| 60 |
const window = this.windowManager.openWindow( this.helpDialog ); |
| 61 |
|
| 62 |
window.opening.then( this.updateButton.bind( this, true ) ); |
| 63 |
window.closing.then( this.updateButton.bind( this, false ) ); |
| 64 |
} else { |
| 65 |
this.windowManager.closeWindow( this.helpDialog ); |
| 66 |
} |
| 67 |
}; |
| 68 |
|
| 69 |
ve.ui.MWFloatingHelpElement.prototype.updateButton = function ( isOpen ) { |
| 70 |
this.helpButton |
| 71 |
.setIcon( isOpen ? 'expand' : 'help' ) |
| 72 |
.setFlags( { primary: isOpen } ); |
| 73 |
}; |