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)
No edit summary
ReisuDesign (talk | contribs)
No edit summary
Line 517: Line 517:
         // ------------------------------------------------------------
         // ------------------------------------------------------------


        applyPageMode() {
applyPageMode() {
            $('body')
    $('body')
                .addClass(
        .addClass(
                    'preload-editor-page'
            'preload-editor-page'
                );
        );
 
            /*
    /*
            * Hide the normal MediaWiki page heading.
    * Hide the normal MediaWiki page heading.
            * The editor supplies its own internal headings.
    * The editor supplies its own internal headings.
            */
    */
            $(
    $(
                '#firstHeading, ' +
        '#firstHeading, ' +
                '.firstHeading'
        '.firstHeading, ' +
            ).hide();
        '.mw-body-header'
 
    ).hide();
            /*
            * Remove the normal heading spacing.
    /*
            */
    * Remove the normal heading spacing.
            $(
    */
                '#mw-content-text'
    $(
            ).css({
        '#mw-content-text'
                marginTop: 0
    ).css({
            });
        marginTop: 0
 
    });
            /*
            * Make the editor occupy the remaining viewport
    /*
            * and keep the outer page from scrolling.
    * Make the editor occupy the remaining viewport
            */
    * and keep the outer page from scrolling.
            this.updatePageHeight();
    */
 
    this.updatePageHeight();
            if (!this.pageResizeHandler) {
                this.pageResizeHandler =
    if (!this.pageResizeHandler) {
                    () =>
        this.pageResizeHandler =
                        this.updatePageHeight();
            () =>
 
                this.updatePageHeight();
                window.addEventListener(
                    'resize',
        window.addEventListener(
                    this.pageResizeHandler
            'resize',
                );
            this.pageResizeHandler
            }
        );
        },
    }
},


         updatePageHeight() {
         updatePageHeight() {
Line 3,941: Line 3,942:
         },
         },


        selectVariable(name) {
selectVariable(name) {
            name =
    name =
                String(name || '')
        String(name || '')
                    .trim()
            .trim()
                    .toUpperCase();
            .toUpperCase();
 
            if (!name) {
    if (!name) {
                return;
        return;
            }
    }
 
            const available =
    const available =
                ['PAGE'].concat(
        ['PAGE'].concat(
                    (
            (
                        this.analysis &&
                this.analysis &&
                        this.analysis.variables
                this.analysis.variables
                            ? this.analysis.variables
                    ? this.analysis.variables
                            : []
                    : []
                    ).filter(
            ).filter(
                        variable =>
                variable =>
                            variable !== 'PAGE'
                    variable !== 'PAGE'
                    )
            )
                );
        );
 
            const configuredUnused =
    const configuredUnused =
                this.state.config &&
        this.state.config &&
                this.state.config.fields
        this.state.config.fields
                    ? Object.keys(
            ? Object.keys(
                        this.state.config.fields
                this.state.config.fields
                    )
            )
                        .map(
                .map(
                            variable =>
                    variable =>
                                variable.toUpperCase()
                        variable.toUpperCase()
                        )
                )
                    : [];
            : [];
 
            configuredUnused.forEach(
    configuredUnused.forEach(
                variable => {
        variable => {
                    if (
            if (
                        !available.includes(variable) &&
                !available.includes(variable) &&
                        variable !== 'PAGE'
                variable !== 'PAGE'
                    ) {
            ) {
                        available.push(variable);
                available.push(variable);
                    }
            }
                }
        }
            );
    );
 
            if (!available.includes(name)) {
    if (!available.includes(name)) {
                return;
        return;
            }
    }
 
            this.state.selectedVariable =
    this.state.selectedVariable =
                name;
        name;
 
            this.renderVariablesBySelector();
    this.renderVariablesBySelector();
            this.renderVariableConfigurationBySelector();
    this.renderVariableConfigurationBySelector();
        },
    /*
    * Bring the selected variable configuration back
    * into view, as before.
    */
    const configuration =
        this.root &&
        this.root.find(
            '.preload-editor-variable-configuration'
        );
    if (
        configuration &&
        configuration.length
    ) {
        configuration.get(0).scrollIntoView({
            behavior: 'smooth',
            block: 'start'
        });
    }
},


         renderVariableConfigurationBySelector() {
         renderVariableConfigurationBySelector() {