Jump to content
Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
If you make an edit, a temporary account will be created for you.

MediaWiki:Gadget-PreloadEditor.js: Difference between revisions

MediaWiki interface page
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 =
    const root =
                $('#mw-content-text');
        $('#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();
},


            if (!root.length) {
renderShell() {
                return;
    this.root.empty();
            }
 
    /*
            this.root =
    * Preload loader.
                $('<div>')
    */
                    .attr(
    const loader =
                        'id',
        this.createSection(
                        'preload-editor'
            'Preload'
                    )
        );
                    .addClass(
                        'preload-editor'
    const titleInput =
                    );
        this.textInput(
 
            this.state.preloadTitle,
            root.empty().append(
            'Template:Example/Preload'
                this.root
        )
            );
            .attr(
 
                'id',
            this.renderShell();
                'preload-editor-title-input'
        },
            );
 
        renderShell() {
    const loadButton =
            this.root.empty();
        this.createButton(
 
            'Load',
            $('<h1>')
            'preload-editor-button-primary',
                .addClass(
            () =>
                    'preload-editor-title'
                this.loadExisting(
                )
                    titleInput.val()
                .text(
                )
                    'Petit Planet Wiki: Preload Editor'
        );
                )
                .appendTo(this.root);
    const newButton =
 
        this.createButton(
            $('<p>')
            'New',
                .addClass(
            '',
                    'preload-editor-intro'
            () =>
                )
                this.startNew()
                .text(
        );
                    'Create and edit wiki preloads and their configuration from one place.'
                )
    const sampleButton =
                .appendTo(this.root);
        this.createButton(
 
            'Load Sample Page',
            /*
            '',
            * Loader.
            () =>
            */
                this.loadSamplePage()
            const loader =
        );
                this.createSection(
                    'Preload'
    const loadRow =
                );
        $('<div>')
 
            .addClass(
            const titleInput =
                'preload-editor-toolbar'
                this.textInput(
            );
                    this.state.preloadTitle,
                    'Template:Example/Preload'
    loadRow.append(
                )
        titleInput,
                    .attr(
        loadButton,
                        'id',
        newButton,
                        'preload-editor-title-input'
        sampleButton
                    );
    );
 
            const loadButton =
    loader.append(
                this.createButton(
        loadRow
                    'Load',
    );
                    'preload-editor-button-primary',
                    () =>
    this.root.append(
                        this.loadExisting(
        loader
                            titleInput.val()
    );
                        )
                );
    /*
 
    * Status area.
            const newButton =
    */
                this.createButton(
    this.status =
                    'New',
        $('<div>')
                    '',
            .addClass(
                    () =>
                'preload-editor-status'
                        this.startNew()
            );
                );
 
    this.root.append(
            const sampleButton =
        this.status
                this.createButton(
    );
                    'Load Sample Page',
                    '',
    /*
                    () =>
    * Workspace.
                        this.loadSamplePage()
    */
                );
    this.workspace =
 
        $('<div>')
            const loadRow =
            .addClass(
                $('<div>')
                'preload-editor-workspace'
                    .addClass(
            );
                        'preload-editor-toolbar'
                    );
    this.root.append(
 
        this.workspace
            loadRow.append(
    );
                titleInput,
                loadButton,
    /*
                newButton,
    * Initially show instructions.
                sampleButton
    */
            );
    this.renderWelcome();
 
},
            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() {