Difference between revisions of "MediaWiki:Common.js"

From Ephemeral Film Wiki
Jump to navigation Jump to search
Line 198: Line 198:
                         'b': { text: 'The templates in the "Insert" tab provide a list of fields that the wiki can process into the appropriate html. Fill out the fields according to the documentation in the this "Parameters" tab. All fields are optional.' }},
                         'b': { text: 'The templates in the "Insert" tab provide a list of fields that the wiki can process into the appropriate html. Fill out the fields according to the documentation in the this "Parameters" tab. All fields are optional.' }},
{'a': { text: 'title' },'b': { text: 'title' }},
{'a': { text: 'title' },'b': { text: 'title' }},
{'a': { text: 'oclc' },'b': { text: 'hello {{plural:world}}' }},
{'a': { text: 'oclc' },'b': { html: 'hello {{plural:world}}' }},
{'a': { text: 'heldby' },'b': { parse: 'hello {{!}}' }},
{'a': { text: 'heldby' },'b': { plain: 'hello {{!}}' }},
{'a': { text: 'form' },'b': { parse: 'format' }},
{'a': { text: 'form' },'b': { escaped: 'format' }},
{'a': { text: 'year' },'b': { text: 'what year' }},
{'a': { text: 'lang' },'b': { text: 'Thai or English' }}


                     ]
                     ]

Revision as of 20:08, 30 November 2021

/* Any JavaScript here will be loaded for all users on every page load. */
var customizeToolbar = function () {
    /*
    *
    * jrtools toolbar
    *
    */
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'sections': {
                'jrtools': {
                    //'type': 'booklet', // Can be 'booklet' or 'toolbar'
                    'type': 'toolbar',
                    'label': 'JR Tools'
                    // or 'labelMsg': 'section-jrtools-label' for a localized label
                }
            }
        } );
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'jrtools',
            'groups': {
                'inserts': {
                    'label': '' 
                }
            }
        } );
        // strike butt
        $('#wpTextbox1').wikiEditor('addToToolbar', {
            section: 'jrtools',
            group: 'inserts',
            tools: {
                "strikethrough": {
                    label: 'Strike',
                    oouiIcon: 'strikethrough',
                    type: 'button',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: "<s>",
                            post: "</s>"
                        }
                    }
                }
            }
        });
        // def butt
        $('#wpTextbox1').wikiEditor('addToToolbar', {
            section: 'jrtools',
            group: 'inserts',
            tools: {
                "defini": {
                    label: 'Definition',
                    oouiIcon: 'highlight',
                    type: 'button',
                    action: {
                        type: 'encapsulate',
                        options: {
                            pre: ";",
                            post: ":"
                        }
                    }
                }
            }
        });
        // dropdown
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            section: 'jrtools',
            group: 'inserts',
            groups: {
                list: {
                    tools: {
                        templates: {
                            label: 'EV Tags',
                            type: 'select',
                            list: {
                                'a-button': {
                                    label: 'EV Tag Example',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{#ev:youtube|id=38j1vMy94TY|urlArgs=start=1653&end=1658&rel=0}}'
                                        }
                                    }
                                },
                                'b-button': {
                                    label: 'EV YouTube',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{#ev:youtube|id=|urlArgs=start=}}'
                                        }
                                    }
                                },
                                'c-button': {
                                    label: 'EV ArchiveOrg',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{#ev:archiveorg|id=}}'
                                        }
                                    }
                                },
                                'd-button': {
                                    label: 'EV Indiana',
                                    action: {
                                        type: 'encapsulate',
                                        options: {
                                            pre: '{{#ev:Insimple|id=xw42nc085}}'
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } );
    /*
    *
    * tpl booklet
    *
    */
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'sections': {
            'filmtpl': {
                'type': 'booklet',
                'label': 'Tpl'
            }
        }
    } );
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'filmtpl',
            'pages': {
                'one': {
                    'layout': 'characters',
                    'label': 'Insert Template Buttons',
                    'characters': [ 
                            {
                            'label':'Tpl Save and Edit',       
                            'action': { 
                                type: 'replace',
                                options: {
                                    pre: '{{',
post:'subst:Filmjr/keys}}',
ownline: true
                                }
                            }                     
                        },{
                            'label':'Tpl Print',       
                            'action': { 
                                type: 'replace',
                                options: {
                                    pre: '{{',
peri: 'Filmjr \r\n|title= \r\n|embid= \r\n|embsv= \r\n|oclc= \r\n|form= \r\n|year= \r\n|up= \r\n|next= \r\n|prev= \r\n|step= \r\n|lang=English \r\n|heldby= \r\n|desc=\r\n',
post:'}}',
ownline: true
                                }
                            }                     
                        }
                    ]
                }
            }
        } );
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'filmtpl',
            'pages': {
                'ex': {
                    'layout': 'table',
                    'label': 'Button Usage',
                    'headings': [
                        { text: 'Label' },
                        { text: 'Notes' }
                    ],
                    'rows': [
                        {
                            'inpu': { text: 'Tpl Save and Edit' },
                            'outpu': { text: 'This will insert a reference to the template markup that will populate after you save. To use, edit the page, save it, and then edit it again. This option is always up to date.' }
                        },
                        {
                            'inpu': { text: 'Tpl Print' },
                            'outpu': { text: 'Easier, but may not be up to date and contain all the parameters.' }
                        }
                    ]
                }
            }
        } );
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'filmtpl',
            'pages': {
                'par': {
                    'layout': 'table',
                    'label': 'Parameters',
                    'headings': [
                        { text: 'Param' },
                        { text: 'Usage' }
                    ],
                    'rows': [
                        {'a': { text: 'About' },
                        'b': { text: 'The templates in the "Insert" tab provide a list of fields that the wiki can process into the appropriate html. Fill out the fields according to the documentation in the this "Parameters" tab. All fields are optional.' }},
{'a': { text: 'title' },'b': { text: 'title' }},
{'a': { text: 'oclc' },'b': { html: 'hello {{plural:world}}' }},
{'a': { text: 'heldby' },'b': { plain: 'hello {{!}}' }},
{'a': { text: 'form' },'b': { escaped: 'format' }},
{'a': { text: 'year' },'b': { text: 'what year' }},
{'a': { text: 'lang' },'b': { text: 'Thai or English' }}

                    ]
                }
            }
        } );
    /*
    *
    * fa booklet
    *
    */
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'sections': {
            'fontaw': {
                'type': 'booklet',
                'label': 'Icons'
            }
        }
    } );
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'fontaw',
            'pages': {
                'one': {
                    'layout': 'characters',
                    'label': 'Films Icons',
                    'characters': [ 
                        '{{#fas:film}}','{{#far:file-video}}','{{#fas:file-video}}','{{#fas:video}}',
                        '{{#fas:tv}}','{{#fas:upload}}','{{#fas:glasses}}','{{#fas:play}}',
                        '{{#fas:stopwatch}}','{{#fas:eye}}','{{#fas:check}}',{
                            'label':'EFW Logo',       
                            'action': { 
                                type: 'encapsulate',
                                options: {
                                    pre: '[[File:EphLogoTrans.png|400px]]'
                                }
                            }                     
                        }
                    ]
                }
            }
        } );
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'fontaw',
            'pages': {
                'two': {
                    'layout': 'characters',
                    'label': 'Brand Icons',
                    'characters': [ 
                        '{{#fab:github}}','{{#fab:soundcloud}}','{{#fab:patreon}}','{{#fab:markdown}}',
                        '{{#fab:twitch}}','{{#fab:twitter}}','{{#fab:wikipedia-w}}','{{#fab:vimeo}}', 
                        '{{#fab:youtube}}','{{#fab:youtube-square}}','{{#fab:creative-commons}}', 
                        '{{#fab:creative-commons-nd}}','{{#fab:creative-commons-zero}}'
                    ]
                }
            }
        } );

        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
            'section': 'fontaw',
            'pages': {
                'ex': {
                    'layout': 'table',
                    'label': 'Examples',
                    'headings': [
                        { text: 'input' },
                        { text: 'output' }
                    ],
                    'rows': [
                        {
                            'inpu': { text: '{{#fas:eye}}' },
                            'outpu': { html: '<svg style="max-width:18px;" class="svg-inline--fa fa-eye fa-w-18" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="eye" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512" data-fa-i2svg=""><path fill="currentColor" d="M572.52 241.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400a144 144 0 1 1 144-144 143.93 143.93 0 0 1-144 144zm0-240a95.31 95.31 0 0 0-25.31 3.79 47.85 47.85 0 0 1-66.9 66.9A95.78 95.78 0 1 0 288 160z"></path></svg>' }
                        },
                        {
                            'inpu': { text: '{{#fas:film}}' },
                            'outpu': { html: '<svg style="max-width:18px;" class="svg-inline--fa fa-film fa-w-16" aria-hidden="true" focusable="false" data-prefix="fas" data-icon="film" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" data-fa-i2svg=""><path fill="currentColor" d="M488 64h-8v20c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12V64H96v20c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12V64h-8C10.7 64 0 74.7 0 88v336c0 13.3 10.7 24 24 24h8v-20c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v20h320v-20c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v20h8c13.3 0 24-10.7 24-24V88c0-13.3-10.7-24-24-24zM96 372c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12H44c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm272 208c0 6.6-5.4 12-12 12H156c-6.6 0-12-5.4-12-12v-96c0-6.6 5.4-12 12-12h200c6.6 0 12 5.4 12 12v96zm0-168c0 6.6-5.4 12-12 12H156c-6.6 0-12-5.4-12-12v-96c0-6.6 5.4-12 12-12h200c6.6 0 12 5.4 12 12v96zm112 152c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40zm0-96c0 6.6-5.4 12-12 12h-40c-6.6 0-12-5.4-12-12v-40c0-6.6 5.4-12 12-12h40c6.6 0 12 5.4 12 12v40z"></path></svg>' }
                        },
                        {
                            'inpu': { text: 'EFW Logo' },
                            'outpu': { html: '<img src="http://ephemeralfilm.info/images/thumb/5/5a/EphLogoTrans.png/85px-EphLogoTrans.png">' }
                        }
                    ]
                }
            }
        } );
    };
        
        /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
        if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
            mw.loader.using( 'user.options' ).then( function () {
                // This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
                if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
                    $.when(
                        mw.loader.using( 'ext.wikiEditor' ), $.ready
                    ).then( customizeToolbar );
                }
            } );
        }