| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
ve.ui.MWSaveDialogAction = function VeUiMWSaveDialogAction() { |
| 20 |
|
| 21 |
ve.ui.MWSaveDialogAction.super.apply( this, arguments ); |
| 22 |
}; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
OO.inheritClass( ve.ui.MWSaveDialogAction, ve.ui.Action ); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
ve.ui.MWSaveDialogAction.static.name = 'mwSaveDialog'; |
| 31 |
|
| 32 |
ve.ui.MWSaveDialogAction.static.methods = [ 'save', 'review', 'preview' ]; |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
ve.ui.MWSaveDialogAction.prototype.save = function ( checkbox ) { |
| 43 |
ve.init.target.showSaveDialog( null, checkbox ); |
| 44 |
return true; |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
ve.ui.MWSaveDialogAction.prototype.review = function () { |
| 53 |
ve.init.target.showSaveDialog( 'review' ); |
| 54 |
return true; |
| 55 |
}; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
ve.ui.MWSaveDialogAction.prototype.preview = function () { |
| 63 |
ve.init.target.showSaveDialog( 'preview' ); |
| 64 |
return true; |
| 65 |
}; |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
ve.ui.actionFactory.register( ve.ui.MWSaveDialogAction ); |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
ve.ui.MWSaveCommand = function VeUiMwSaveCommand() { |
| 82 |
|
| 83 |
ve.ui.MWSaveCommand.super.apply( this, arguments ); |
| 84 |
}; |
| 85 |
|
| 86 |
OO.inheritClass( ve.ui.MWSaveCommand, ve.ui.Command ); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
ve.ui.MWSaveCommand.prototype.isExecutable = function () { |
| 92 |
|
| 93 |
return ve.ui.MWSaveCommand.super.prototype.isExecutable.apply( this, arguments ) && |
| 94 |
ve.init.target.isSaveable(); |
| 95 |
}; |
| 96 |
|
| 97 |
ve.ui.commandRegistry.register( |
| 98 |
new ve.ui.MWSaveCommand( |
| 99 |
'showSave', 'mwSaveDialog', 'save' |
| 100 |
) |
| 101 |
); |
| 102 |
ve.ui.commandRegistry.register( |
| 103 |
new ve.ui.MWSaveCommand( |
| 104 |
'showChanges', 'mwSaveDialog', 'review' |
| 105 |
) |
| 106 |
); |
| 107 |
if ( mw.libs.ve.isWikitextAvailable ) { |
| 108 |
|
| 109 |
mw.loader.using( 'ext.visualEditor.mwwikitext' ).then( () => { |
| 110 |
ve.ui.wikitextCommandRegistry.register( |
| 111 |
new ve.ui.MWSaveCommand( |
| 112 |
'showPreview', 'mwSaveDialog', 'preview' |
| 113 |
) |
| 114 |
); |
| 115 |
} ); |
| 116 |
} |
| 117 |
ve.ui.commandRegistry.register( |
| 118 |
new ve.ui.MWSaveCommand( |
| 119 |
'saveMinoredit', 'mwSaveDialog', 'save', |
| 120 |
{ args: [ 'wpMinoredit' ] } |
| 121 |
) |
| 122 |
); |
| 123 |
ve.ui.commandRegistry.register( |
| 124 |
new ve.ui.MWSaveCommand( |
| 125 |
'saveWatchthis', 'mwSaveDialog', 'save', |
| 126 |
{ args: [ 'wpWatchthis' ] } |
| 127 |
) |
| 128 |
); |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
( function () { |
| 133 |
const accessKeyPrefix = $.fn.updateTooltipAccessKeys.getAccessKeyPrefix().replace( /-/g, '+' ), |
| 134 |
shortcuts = [ |
| 135 |
{ |
| 136 |
command: 'showSave', |
| 137 |
accessKey: 'accesskey-save', |
| 138 |
label: function () { |
| 139 |
return ve.init.target.getSaveButtonLabel(); |
| 140 |
} |
| 141 |
}, |
| 142 |
{ |
| 143 |
command: 'showChanges', |
| 144 |
accessKey: 'accesskey-diff', |
| 145 |
label: OO.ui.deferMsg( 'visualeditor-savedialog-label-review' ) |
| 146 |
}, |
| 147 |
{ |
| 148 |
command: 'showPreview', |
| 149 |
accessKey: 'accesskey-preview', |
| 150 |
label: OO.ui.deferMsg( 'showpreview' ) |
| 151 |
}, |
| 152 |
{ |
| 153 |
command: 'saveMinoredit', |
| 154 |
accessKey: 'accesskey-minoredit', |
| 155 |
label: OO.ui.deferMsg( 'tooltip-minoredit' ) |
| 156 |
}, |
| 157 |
{ |
| 158 |
command: 'saveWatchthis', |
| 159 |
accessKey: 'accesskey-watch', |
| 160 |
label: OO.ui.deferMsg( 'tooltip-watch' ) |
| 161 |
} |
| 162 |
]; |
| 163 |
|
| 164 |
shortcuts.forEach( ( shortcut ) => { |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
const accessKey = ve.msg( shortcut.accessKey ); |
| 172 |
if ( accessKey !== '-' && accessKey !== '' ) { |
| 173 |
try { |
| 174 |
ve.ui.triggerRegistry.register( |
| 175 |
shortcut.command, new ve.ui.Trigger( accessKeyPrefix + accessKey ) |
| 176 |
); |
| 177 |
} catch ( e ) { |
| 178 |
mw.log.warn( 'Invalid accesskey data? Failed to register ' + accessKeyPrefix + accessKey ); |
| 179 |
return; |
| 180 |
} |
| 181 |
ve.ui.commandHelpRegistry.register( 'other', shortcut.command, { |
| 182 |
trigger: shortcut.command, |
| 183 |
label: shortcut.label |
| 184 |
} ); |
| 185 |
ve.ui.MWCommandHelpDialog.static.commandGroups.other.demote = ve.ui.MWCommandHelpDialog.static.commandGroups.other.demote || []; |
| 186 |
ve.ui.MWCommandHelpDialog.static.commandGroups.other.demote.push( shortcut.command ); |
| 187 |
} |
| 188 |
} ); |
| 189 |
}() ); |