| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
ve.ui.MWEditModeTool = function VeUiMWEditModeTool() { |
| 15 |
}; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
OO.initClass( ve.ui.MWEditModeTool ); |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
ve.ui.MWEditModeTool.prototype.getMode = function () { |
| 27 |
if ( !this.toolbar.getSurface() ) { |
| 28 |
return 'source'; |
| 29 |
} |
| 30 |
return this.toolbar.getSurface().getMode(); |
| 31 |
}; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
ve.ui.MWEditModeTool.prototype.isModeAvailable = function ( mode ) { |
| 37 |
const target = this.toolbar.getTarget(); |
| 38 |
const surface = target.getSurface(); |
| 39 |
const canSwitch = surface && !surface.getModel().isMultiUser(); |
| 40 |
|
| 41 |
|
| 42 |
return canSwitch && ( |
| 43 |
mode === 'source' || target.isModeAvailable( mode ) |
| 44 |
); |
| 45 |
}; |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
ve.ui.MWEditModeVisualTool = function VeUiMWEditModeVisualTool() { |
| 58 |
|
| 59 |
ve.ui.MWEditModeVisualTool.super.apply( this, arguments ); |
| 60 |
|
| 61 |
ve.ui.MWEditModeTool.call( this ); |
| 62 |
}; |
| 63 |
OO.inheritClass( ve.ui.MWEditModeVisualTool, mw.libs.ve.MWEditModeVisualTool ); |
| 64 |
OO.mixinClass( ve.ui.MWEditModeVisualTool, ve.ui.MWEditModeTool ); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
ve.ui.MWEditModeVisualTool.prototype.switch = function () { |
| 69 |
this.toolbar.getTarget().switchToVisualEditor(); |
| 70 |
}; |
| 71 |
ve.ui.toolFactory.register( ve.ui.MWEditModeVisualTool ); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
ve.ui.MWEditModeSourceTool = function VeUiMWEditModeSourceTool() { |
| 84 |
|
| 85 |
ve.ui.MWEditModeSourceTool.super.apply( this, arguments ); |
| 86 |
|
| 87 |
ve.ui.MWEditModeTool.call( this ); |
| 88 |
}; |
| 89 |
OO.inheritClass( ve.ui.MWEditModeSourceTool, mw.libs.ve.MWEditModeSourceTool ); |
| 90 |
OO.mixinClass( ve.ui.MWEditModeSourceTool, ve.ui.MWEditModeTool ); |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
ve.ui.MWEditModeSourceTool.prototype.switch = function () { |
| 95 |
this.toolbar.getTarget().editSource(); |
| 96 |
}; |
| 97 |
ve.ui.toolFactory.register( ve.ui.MWEditModeSourceTool ); |