For the latest updates, send a blank email to our SUBSCRIPTION ADDRESS
HEADLINES | CLASSIFIED | SPORTS | FORUM | BUSINESS | ENTERTAINMENT
Vol. 1, Issue 9
The News Organ of Liberty City
Thursday October 18th, 2001
Seplogo.gif
" Yesterday's News Today "

MediaWiki:Common.js: Difference between revisions

From Liberty Tree
Jump to navigationJump to search
(Replaced content with "window.onload=function(){ const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]'); const currentTheme = localStorage.getItem('theme'); if (cur...")
Tag: Replaced
(Undo revision 589 by Lazlow (talk))
 
Line 1: Line 1:
window.onload=function(){
var customizeToolbar = function() {
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
   
const currentTheme = localStorage.getItem('theme');
    /* TRANSLATE GROUP */
 
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
if (currentTheme) {
        'section': 'main',
    document.documentElement.setAttribute('data-theme', currentTheme);
        'groups': {
 
            'translate': {
     if (currentTheme === 'dark') {
                'label': 'Translate' // or use labelMsg for a localized label, see above
         toggleSwitch.checked = true;
            }
    }
        }
}
    } );
 
    /* TRANSLATE GROUP END */
function switchTheme(e) {
   
     if (e.target.checked) {
    /* LANGUAGES BUTTON */
         document.documentElement.setAttribute('data-theme', 'dark');
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        localStorage.setItem('theme', 'dark');
        section: 'main',
     }
        group: 'translate',
     else {        document.documentElement.setAttribute('data-theme', 'light');
        tools: {
          localStorage.setItem('theme', 'light');
            "languages": {
    }   
                label: 'Languages',
}
                type: 'button',
 
                icon: '//xat.wiki/w/images/2/29/Button_languages.png',
toggleSwitch.addEventListener('change', switchTheme, false);
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<languages/>",
                        post: ""
                    }
                }
            }
        }
    });
    /* LANGUAGES BUTTON END */
   
    /* TRANSLATE BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "translate": {
                label: 'Translate',
                type: 'button',
                icon: '//xat.wiki/w/images/5/5c/Button_translate.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<translate>",
                        post: "</translate>"
                    }
                }
            }
        }
    });
    /* TRANSLATE BUTTON END */
   
    /* TRANS TEMPLATE BUTTON */
     $('#wpTextbox1').wikiEditor('addToToolbar', {
         section: 'main',
        group: 'translate',
        tools: {
            "tt": {
                label: 'Translatable template',
                type: 'button',
                icon: '//xat.wiki/w/images/f/f6/Button_tt.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "{{ {{tt|trans/",
                        post: "}} }}"
                    }
                }
            }
        }
    });
    /* TRANS TEMPLATE BUTTON END */
   
    /* TVAR BUTTON */
     $('#wpTextbox1').wikiEditor('addToToolbar', {
         section: 'main',
        group: 'translate',
        tools: {
            "tvar": {
                label: 'Variable',
                type: 'button',
                icon: '//xat.wiki/w/images/e/e4/Button_tvar.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<tvar|1>",
                        post: "</>"
                    }
                }
            }
        }
    });
    /* TVAR BUTTON END */
   
    /* MYLANGUAGE BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "tvar": {
                label: 'MyLanguage',
                type: 'button',
                icon: '//xat.wiki/w/images/8/84/Button_ml.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "[[<tvar|1>Special:MyLanguage/</>|",
                        post: "]]"
                    }
                }
            }
        }
    });
     /* MYLANGUAGE BUTTON END */
   
    /* REMOVED BUTTONS */
    /* REMOVED BUTTONS END */
   
};
      
/* TOOLBAR CONFIG */
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
/* 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 );
}
} );
}
}

Latest revision as of 20:04, 4 February 2025

var customizeToolbar = function() {
    
    /* TRANSLATE GROUP */
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'main',
        'groups': {
            'translate': {
                'label': 'Translate' // or use labelMsg for a localized label, see above
            }
        }
    } );
    /* TRANSLATE GROUP END */
    
    /* LANGUAGES BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "languages": {
                label: 'Languages',
                type: 'button',
                icon: '//xat.wiki/w/images/2/29/Button_languages.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<languages/>",
                        post: ""
                    }
                }
            }
        }
    });
    /* LANGUAGES BUTTON END */
    
    /* TRANSLATE BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "translate": {
                label: 'Translate',
                type: 'button',
                icon: '//xat.wiki/w/images/5/5c/Button_translate.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<translate>",
                        post: "</translate>"
                    }
                }
            }
        }
    });
    /* TRANSLATE BUTTON END */
    
    /* TRANS TEMPLATE BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "tt": {
                label: 'Translatable template',
                type: 'button',
                icon: '//xat.wiki/w/images/f/f6/Button_tt.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "{{ {{tt|trans/",
                        post: "}} }}"
                    }
                }
            }
        }
    });
    /* TRANS TEMPLATE BUTTON END */
    
    /* TVAR BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "tvar": {
                label: 'Variable',
                type: 'button',
                icon: '//xat.wiki/w/images/e/e4/Button_tvar.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "<tvar|1>",
                        post: "</>"
                    }
                }
            }
        }
    });
    /* TVAR BUTTON END */
    
    /* MYLANGUAGE BUTTON */
    $('#wpTextbox1').wikiEditor('addToToolbar', {
        section: 'main',
        group: 'translate',
        tools: {
            "tvar": {
                label: 'MyLanguage',
                type: 'button',
                icon: '//xat.wiki/w/images/8/84/Button_ml.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: "[[<tvar|1>Special:MyLanguage/</>|",
                        post: "]]"
                    }
                }
            }
        }
    });
    /* MYLANGUAGE BUTTON END */
    
    /* REMOVED BUTTONS */
    /* REMOVED BUTTONS END */
    
};
    
/* TOOLBAR CONFIG */
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
/* 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 );
		}
	} );
}