MediaWiki:Gadget-PreloadEditor.js: Difference between revisions
MediaWiki interface page
More actions
ReisuDesign (talk | contribs) Created page with "(function (mw, $) { 'use strict'; const PreloadEditor = { version: '0.1.0', state: { preloadTitle: '', preloadSource: '', preloadContent: '', config: null, variables: [], conditions: [], mode: 'idle', dirty: false }, defaults: { preload: '<includeonly>\n' + '<!-- preload here -->\n' +..." |
ReisuDesign (talk | contribs) No edit summary |
||
| Line 746: | Line 746: | ||
init() { | init() { | ||
const root = | |||
$('#mw-content-text'); | |||
if (!root.length) { | |||
return; | |||
} | |||
/* | |||
* Keep the wiki page itself intact. | |||
* The editor gets its own mount point. | |||
*/ | |||
this.root = | |||
$('<div>') | |||
.attr( | |||
'id', | |||
'preload-editor' | |||
) | |||
.addClass( | |||
'preload-editor' | |||
); | |||
root.append( | |||
this.root | |||
); | |||
this.renderShell(); | |||
}, | |||
renderShell() { | |||
this.root.empty(); | |||
/* | |||
* Preload loader. | |||
*/ | |||
const loader = | |||
this.createSection( | |||
'Preload' | |||
); | |||
const titleInput = | |||
this.textInput( | |||
this.state.preloadTitle, | |||
'Template:Example/Preload' | |||
) | |||
.attr( | |||
'id', | |||
'preload-editor-title-input' | |||
); | |||
const loadButton = | |||
this.createButton( | |||
'Load', | |||
'preload-editor-button-primary', | |||
() => | |||
this.loadExisting( | |||
titleInput.val() | |||
) | |||
); | |||
const newButton = | |||
this.createButton( | |||
'New', | |||
'', | |||
() => | |||
this.startNew() | |||
); | |||
const sampleButton = | |||
this.createButton( | |||
'Load Sample Page', | |||
'', | |||
() => | |||
this.loadSamplePage() | |||
); | |||
const loadRow = | |||
$('<div>') | |||
.addClass( | |||
'preload-editor-toolbar' | |||
); | |||
loadRow.append( | |||
titleInput, | |||
loadButton, | |||
newButton, | |||
sampleButton | |||
); | |||
loader.append( | |||
loadRow | |||
); | |||
this.root.append( | |||
loader | |||
); | |||
/* | |||
* Status area. | |||
*/ | |||
this.status = | |||
$('<div>') | |||
.addClass( | |||
'preload-editor-status' | |||
); | |||
this.root.append( | |||
this.status | |||
); | |||
/* | |||
* Workspace. | |||
*/ | |||
this.workspace = | |||
$('<div>') | |||
.addClass( | |||
'preload-editor-workspace' | |||
); | |||
this.root.append( | |||
this.workspace | |||
); | |||
/* | |||
* Initially show instructions. | |||
*/ | |||
this.renderWelcome(); | |||
}, | |||
renderWelcome() { | renderWelcome() { | ||