| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
ve.ui.MWSaveTool = function VeUiMWSaveTool() { |
| 12 |
|
| 13 |
ve.ui.MWSaveTool.super.apply( this, arguments ); |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
this.$link.addClass( 've-ui-toolbar-saveButton' ); |
| 18 |
|
| 19 |
if ( this.toolbar instanceof ve.ui.TargetToolbar ) { |
| 20 |
if ( ve.msg( 'accesskey-save' ) !== '-' && ve.msg( 'accesskey-save' ) !== '' ) { |
| 21 |
|
| 22 |
this.toolbar.target.$saveAccessKeyElements = $( '[accesskey="' + ve.msg( 'accesskey-save' ) + '"]' ).removeAttr( 'accesskey' ); |
| 23 |
this.$link.attr( 'accesskey', ve.msg( 'accesskey-save' ) ); |
| 24 |
} |
| 25 |
|
| 26 |
this.setTitle( this.toolbar.target.getSaveButtonLabel( true ) ); |
| 27 |
this.narrowConfig = { |
| 28 |
title: this.toolbar.target.getSaveButtonLabel( true, true ) |
| 29 |
}; |
| 30 |
} |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
OO.inheritClass( ve.ui.MWSaveTool, ve.ui.Tool ); |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
ve.ui.MWSaveTool.static.name = 'showSave'; |
| 40 |
|
| 41 |
ve.ui.MWSaveTool.static.flags = [ 'primary', 'progressive' ]; |
| 42 |
ve.ui.MWSaveTool.static.displayBothIconAndLabel = true; |
| 43 |
ve.ui.MWSaveTool.static.group = 'save'; |
| 44 |
ve.ui.MWSaveTool.static.fallbackIcon = 'next'; |
| 45 |
ve.ui.MWSaveTool.static.commandName = 'showSave'; |
| 46 |
ve.ui.MWSaveTool.static.autoAddToCatchall = false; |
| 47 |
if ( OO.ui.isMobile() ) { |
| 48 |
|
| 49 |
ve.ui.MWSaveTool.static.icon = 'next'; |
| 50 |
ve.ui.MWSaveTool.static.displayBothIconAndLabel = false; |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
ve.ui.MWSaveTool.prototype.onUpdateState = function () { |
| 59 |
const wasSaveable = !this.isDisabled(), |
| 60 |
isSaveable = this.toolbar instanceof ve.ui.TargetToolbar && |
| 61 |
this.toolbar.target.isSaveable(); |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
if ( wasSaveable !== isSaveable ) { |
| 68 |
this.setDisabled( !isSaveable ); |
| 69 |
mw.hook( 've.toolbarSaveButton.stateChanged' ).fire( !isSaveable ); |
| 70 |
} |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
ve.ui.toolFactory.register( ve.ui.MWSaveTool ); |