Difference between revisions of "MediaWiki:Common.js"

From Eco-Bible 1
Jump to: navigation, search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
The following javascript code was added to MediaWiki:Vector.js in the TNG Wiki with the upgrade to MediaWiki 1.16.2
+
/* Any JavaScript here will be loaded for all users on every page load. */
  
Return to [[Adding Buttons to WikiEditor]]
+
/** Collapsible tables *********************************************************
 +
  *
 +
  *  Description: Allows tables to be collapsed, showing only the header. See
 +
  *              [[Wikipedia:NavFrame]].
 +
  *  Maintainer on Wikipedia: [[User:R. Koot]]
 +
  */
 +
 +
var autoCollapse = 2;
 +
var collapseCaption = "hide";
 +
var expandCaption = "show";
 +
 +
function hasClass( element, className ) {
 +
  var Classes = element.className.split( " " );
 +
  for ( var i = 0; i < Classes.length; i++ ) {
 +
    if ( Classes[i] == className ) {
 +
      return ( true );
 +
    }
 +
  }
 +
  return ( false );
 +
}
 +
 +
function collapseTable( tableIndex )
 +
{
 +
    var Button = document.getElementById( "collapseButton" + tableIndex );
 +
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
 +
 +
    if ( !Table || !Button ) {
 +
        return false;
 +
    }
 +
 +
    var Rows = Table.getElementsByTagName( "tr" );
 +
 +
    if ( Button.firstChild.data == collapseCaption ) {
 +
        for ( var i = 1; i < Rows.length; i++ ) {
 +
            Rows[i].style.display = "none";
 +
        }
 +
        Button.firstChild.data = expandCaption;
 +
    } else {
 +
        for ( var i = 1; i < Rows.length; i++ ) {
 +
            Rows[i].style.display = Rows[0].style.display;
 +
        }
 +
        Button.firstChild.data = collapseCaption;
 +
    }
 +
}
 +
 +
function createCollapseButtons()
 +
{
 +
    var tableIndex = 0;
 +
    var NavigationBoxes = new Object();
 +
    var Tables = document.getElementsByTagName( "table" );
 +
 +
    for ( var i = 0; i < Tables.length; i++ ) {
 +
        if ( hasClass( Tables[i], "collapsible" ) ) {
 +
            NavigationBoxes[ tableIndex ] = Tables[i];
 +
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 +
 +
            var Button    = document.createElement( "span" );
 +
            var ButtonLink = document.createElement( "a" );
 +
            var ButtonText = document.createTextNode( collapseCaption );
 +
 +
            Button.style.styleFloat = "right";
 +
            Button.style.cssFloat = "right";
 +
            Button.style.fontWeight = "normal";
 +
            Button.style.textAlign = "right";
 +
            Button.style.width = "6em";
 +
 +
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
 +
            ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
 +
            ButtonLink.appendChild( ButtonText );
 +
 +
            Button.appendChild( document.createTextNode( "[" ) );
 +
            Button.appendChild( ButtonLink );
 +
            Button.appendChild( document.createTextNode( "]" ) );
 +
 +
            var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
 +
            /* only add button and increment count if there is a header row to work with */
 +
            if (Header) {
 +
                Header.insertBefore( Button, Header.childNodes[0] );
 +
                tableIndex++;
 +
            }
 +
        }
 +
    }
 +
 +
    for ( var i = 0;  i < tableIndex; i++ ) {
 +
        if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
 +
            collapseTable( i );
 +
        }
 +
    }
 +
}
 +
 +
addOnloadHook( createCollapseButtons );
  
<syntaxhighlight lang="javascript" enclose="div">
+
/* EDIT BUTTONS **************************************************************** */
/* Any JavaScript here will be loaded for users using the Vector skin */
+
  
// Check that the toolbar is available
+
var customizeToolbar = function() {
if ( typeof $j !== 'undefined' && typeof $j.fn.wikiEditor !== 'undefined' ) {
+
/* Your code goes here */
    // Execute on load
+
    $j( function() {
+
   
+
        // To add a group to an existing toolbar section:
+
        // Added hdr = Page group on Main toolbar for TNG Wiki
+
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
            'section': 'main',
+
            'groups': {
+
                'hdr': {
+
                    'labelMsg': 'wikieditor-toolbar-group-page' // or 'label': 'Text' when localized label no needed
+
                    }
+
                }
+
            }
+
        );
+
       
+
        // To add a group to an existing toolbar section:
+
        // Added style = Style group on Main toolbar for TNG Wiki
+
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
            'section': 'main',
+
            'groups': {
+
                'style': {
+
                    'labelMsg': 'wikieditor-toolbar-group-style' // or use labelMsg for a localized label, see above
+
                    }
+
                }
+
            }
+
        );
+
       
+
        // To add a group to an existing toolbar section:
+
        // Added code = Code group on Advanced toolbar for TNG Wiki
+
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
            'section': 'advanced',
+
            'groups': {
+
                'code': {
+
                    'labelMsg': 'wikieditor-toolbar-group-code' // or use labelMsg for a localized label, see above
+
                    }
+
                }
+
            }
+
        );
+
       
+
        // To add a button to an existing toolbar group:
+
        // Added Strikethrough button to WikiEditor main toolbar format group:
+
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
            'section': 'main',
+
            'group': 'format',
+
                'tools': {
+
                    'strikethrough': {
+
                        labelMsg: 'wikieditor-toolbar-tool-strike',
+
                        type: 'button',
+
                        icon: 'Button-strike.png',
+
                        action: {
+
                            type: 'encapsulate',
+
                            options: {
+
                                pre: "<s>",
+
                                periMsg: 'wikieditor-toolbar-tool-strike-example',
+
                                post: "</s>"
+
                            }
+
                        }
+
                    }
+
                }
+
            }
+
        );
+
  
        // To add a button to an existing toolbar group:
 
        // Added ZipFile button to WikiEditor main toolbar insert group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'main',
 
            'group': 'insert',
 
                'tools': {
 
                    'zipfile': {
 
                        labelMsg: 'wikieditor-toolbar-tool-zipfile',
 
                        type: 'button',
 
                        icon: 'Button-zipfile.png',
 
                        action: {
 
                            type: 'encapsulate',
 
                            options: {
 
                                preMsg: [ 'wikieditor-toolbar-tool-zipfile-pre', '[[Media:' ],
 
                                periMsg: 'wikieditor-toolbar-tool-zipfile-example',
 
                                post: "]]"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added ZipFile button to WikiEditor main toolbar insert group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'main',
 
            'group': 'insert',
 
                'tools': {
 
                    'image': {
 
                        labelMsg: 'wikieditor-toolbar-tool-imagefile',
 
                        type: 'button',
 
                        icon: 'Button-add-media.png',
 
                        action: {
 
                            type: 'encapsulate',
 
                            options: {
 
                                preMsg: [ 'wikieditor-toolbar-tool-imagefile-pre', '[[Image:' ],
 
                                periMsg: 'wikieditor-toolbar-tool-imagefile-example',
 
                                post: "]]"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
+
$('#wpTextbox1').wikiEditor('addToToolbar', {
        // Added Definition List button to WikiEditor advanced toolbar format group:
+
section: 'advanced',
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
group: 'format',
            'section': 'advanced',
+
tools: {
            'group': 'format',
+
"strikethrough": {
                'tools': {
+
label: 'Strike',
                    'definition': {
+
type: 'button',
                    labelMsg: 'wikieditor-toolbar-tool-definition',
+
icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
                        type: 'button',
+
action: {
                        icon: 'Button-list-definition.png',
+
type: 'encapsulate',
                        action: {
+
options: {
                            type: 'encapsulate',
+
pre: "<s>",
                            options: {
+
post: "</s>"
                                pre: "\n; Definition\n: Item 1\n: Item 2",
+
}
                                post: "\n"
+
}
                            }
+
}
                        }
+
}
                    }
+
});
                }
+
            }
+
        );
+
  
        // To add a button to an existing toolbar group:
+
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        // Added BlockQuote button to TNG main toolbar style group:
+
section: 'advanced',
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
group: 'format',
            'section': 'main',
+
tools: {
            'group': 'style',
+
"hline": {
                'tools': {
+
label: 'Horizontal line',
                    'blockquote': {
+
type: 'button',
                        labelMsg: 'wikieditor-toolbar-tool-blockquote',
+
icon: '//upload.wikimedia.org/wikipedia/commons/a/a4/H-line_icon.png',
                        type: 'button',
+
action: {
                        icon: 'Button-blockquote.png',
+
type: 'encapsulate',
                        action: {
+
options: {
                            type: 'encapsulate',
+
pre: "----",
                            options: {
+
ownline: true
                                pre: "<blockquote>\n",
+
}
                                periMsg: 'wikieditor-toolbar-tool-blockquote-example',
+
}
                                post: "\n</blockquote>"
+
}
                            }
+
}
                        }
+
} );
                    }
+
                }
+
            }
+
        );
+
  
        // To add a button to an existing toolbar group:
+
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        // Added Font Color button to TNG main toolbar style group:
+
section: 'advanced',
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
group: 'format',
            'section': 'main',
+
tools: {
            'group': 'style',
+
"comment": {
                'tools': {
+
label: 'Comment',
                    'fontcolor': {
+
type: 'button',
                        labelMsg: 'wikieditor-toolbar-tool-fontcolor',
+
icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
                        type: 'button',
+
action: {
                        icon: 'Button-font-color.png',
+
type: 'encapsulate',
                        action: {
+
options: {
                        type: 'encapsulate',
+
pre: "<!-- ",
                            options: {
+
post: " -->"
                                pre: "<span style=\"color: ColourName\">",
+
}
                                periMsg: 'wikieditor-toolbar-tool-fontcolor-example',
+
}
                                post: "</span>"
+
}
                            }
+
}
                        }
+
} );
                    }
+
                }
+
            }
+
        );
+
  
        // To add a button to an existing toolbar group:
+
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        // Added RightTOC button to TNG main toolbar hdr group:
+
section: 'advanced',
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
group: 'format',
            'section': 'main',
+
tools: {
            'group': 'hdr',
+
"math": {
                'tools': {
+
label: 'Math',
                'RightTOC': {
+
type: 'button',
                    labelMsg: 'wikieditor-toolbar-tool-rightTOC',
+
icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
                    type: 'button',
+
action: {
                    icon: 'Button-toc.png',
+
type: 'encapsulate',
                    action: {
+
options: {
                        type: 'encapsulate',
+
pre: "<math>",
                        options: {
+
post: "</math>"
                            pre: "{| style=\"margin-right:0.5 em;\" align=\"right\" \n| __TOC__\n",
+
}
                            post: "|}\n"
+
}
                            }
+
}
                        }
+
}
                    }
+
} );
                }
+
            }
+
        );
+
  
        // To add a button to an existing toolbar group:
 
        // Added Language Templage button to TNG main toolbar hdr group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'main',
 
            'group': 'hdr',
 
                'tools': {
 
                'language': {
 
                    labelMsg: 'wikieditor-toolbar-tool-langtemplate',
 
                    type: 'button',
 
                    icon: 'Button-lang-template.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
                            pre: "\n{{Languages",
 
                            periMsg: 'wikieditor-toolbar-tool-langtemplate-example',
 
                            post: "}}\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added Language Templage button to TNG main toolbar hdr group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'main',
 
            'group': 'hdr',
 
                'tools': {
 
                'language': {
 
                    labelMsg: 'wikieditor-toolbar-tool-toggle',
 
                    type: 'button',
 
                    icon: 'Button-Toggle.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
                            preMsg: 'wikieditor-toolbar-tool-toggle-pre',
 
                            periMsg: 'wikieditor-toolbar-tool-toggle-example',
 
                            post: "</toggledisplay>\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added Category button to TNG main toolbar hdr group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'main',
 
            'group': 'hdr',
 
                'tools': {
 
                'category': {
 
                    labelMsg: 'wikieditor-toolbar-tool-category',
 
                    type: 'button',
 
                    icon: 'Button-category.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
                            pre: "\n[[Category:",
 
                            periMsg: 'wikieditor-toolbar-tool-category-example',
 
                            post: "]]\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added Pre-Formatted Text button to TNG advanced toolbar code group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'advanced',
 
            'group': 'code',
 
                'tools': {
 
                'preformat': {
 
                    labelMsg: 'wikieditor-toolbar-tool-preformat',
 
                    type: 'button',
 
                    icon: 'Button-pre.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
                            pre: "\n<pre>\n",
 
                            periMsg: 'wikieditor-toolbar-tool-preformat-example',
 
                            post: "</pre>\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added Code button to TNG advanced toolbar code group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'advanced',
 
            'group': 'code',
 
                'tools': {
 
                'codesnippet': {
 
                    labelMsg: 'wikieditor-toolbar-tool-codesnippet',
 
                    type: 'button',
 
                    icon: 'Button-code.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
                            pre: "\n<code>",
 
                            periMsg: 'wikieditor-toolbar-tool-codesnippet-example',
 
                            post: "</code>\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added Syntax Highlight button to TNG advanced toolbar code group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'advanced',
 
            'group': 'code',
 
                'tools': {
 
                'syntaxhighlight': {
 
                    labelMsg: 'wikieditor-toolbar-tool-highlight',
 
                    type: 'button',
 
                    icon: 'Button-source.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
  
pre: "\n<syntaxhighlight lang=\"html4strict\" line start=\"100\"
 
highlight=\"5\" enclose=\"div\">",
 
                            periMsg: 'wikieditor-toolbar-tool-highlight-example',
 
                            post: "</syntaxhighlight>\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
        // To add a button to an existing toolbar group:
 
        // Added Comment button to TNG advanced toolbar code group:
 
        $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
            'section': 'advanced',
 
            'group': 'code',
 
                'tools': {
 
                'comments': {
 
                    labelMsg: 'wikieditor-toolbar-tool-comments',
 
                    type: 'button',
 
                    icon: 'Button-hide-comment.png',
 
                    action: {
 
                        type: 'encapsulate',
 
                        options: {
 
                            pre: "<!-- ",
 
                            periMsg: 'wikieditor-toolbar-tool-comments-example',
 
                            post: " -->\n"
 
                            }
 
                        }
 
                    }
 
                }
 
            }
 
        );
 
  
    // Terminate onLoad action - Buttons or sections must be added before this line
 
  
    }
 
);
 
  
}
 
  
</syntaxhighlight>
+
};
  
 
+
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
See [http://commons.wikimedia.org/wiki/MediaWiki_edit_toolbar MediaWiki edit toolbar] for extra buttons.
+
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
 
+
mw.loader.using( 'user.options', function () {
Return to [[Adding Buttons to WikiEditor]]
+
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
[[Category:Toolbar Buttons]]
+
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
 +
$.when(
 +
mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
 +
).then( customizeToolbar );
 +
}
 +
} );
 +
}
 +
// Add the customizations to LiquidThreads' edit toolbar, if available
 +
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );

Latest revision as of 20:29, 5 August 2016

/* Any JavaScript here will be loaded for all users on every page load. */

 /** Collapsible tables *********************************************************
  *
  *  Description: Allows tables to be collapsed, showing only the header. See
  *               [[Wikipedia:NavFrame]].
  *  Maintainer on Wikipedia: [[User:R. Koot]]
  */
 
 var autoCollapse = 2;
 var collapseCaption = "hide";
 var expandCaption = "show";
 
 function hasClass( element, className ) {
  var Classes = element.className.split( " " );
  for ( var i = 0; i < Classes.length; i++ ) {
    if ( Classes[i] == className ) {
      return ( true );
    }
  }
  return ( false );
 }
 
 function collapseTable( tableIndex )
 {
     var Button = document.getElementById( "collapseButton" + tableIndex );
     var Table = document.getElementById( "collapsibleTable" + tableIndex );
 
     if ( !Table || !Button ) {
         return false;
     }
 
     var Rows = Table.getElementsByTagName( "tr" ); 
 
     if ( Button.firstChild.data == collapseCaption ) {
         for ( var i = 1; i < Rows.length; i++ ) {
             Rows[i].style.display = "none";
         }
         Button.firstChild.data = expandCaption;
     } else {
         for ( var i = 1; i < Rows.length; i++ ) {
             Rows[i].style.display = Rows[0].style.display;
         }
         Button.firstChild.data = collapseCaption;
     }
 }
 
 function createCollapseButtons()
 {
     var tableIndex = 0;
     var NavigationBoxes = new Object();
     var Tables = document.getElementsByTagName( "table" );
 
     for ( var i = 0; i < Tables.length; i++ ) {
         if ( hasClass( Tables[i], "collapsible" ) ) {
             NavigationBoxes[ tableIndex ] = Tables[i];
             Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
 
             var Button     = document.createElement( "span" );
             var ButtonLink = document.createElement( "a" );
             var ButtonText = document.createTextNode( collapseCaption );
 
             Button.style.styleFloat = "right";
             Button.style.cssFloat = "right";
             Button.style.fontWeight = "normal";
             Button.style.textAlign = "right";
             Button.style.width = "6em";
 
             ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
             ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
             ButtonLink.appendChild( ButtonText );
 
             Button.appendChild( document.createTextNode( "[" ) );
             Button.appendChild( ButtonLink );
             Button.appendChild( document.createTextNode( "]" ) );
 
             var Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
             /* only add button and increment count if there is a header row to work with */
             if (Header) {
                 Header.insertBefore( Button, Header.childNodes[0] );
                 tableIndex++;
             }
         }
     }
 
     for ( var i = 0;  i < tableIndex; i++ ) {
         if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
             collapseTable( i );
         }
     }
 }
 
 addOnloadHook( createCollapseButtons );

/* EDIT BUTTONS **************************************************************** */

var customizeToolbar = function() {
	/* Your code goes here */



$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"strikethrough": {
			label: 'Strike',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<s>",
					post: "</s>"
				}
			}
		}
	}
});

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"hline": {
			label: 'Horizontal line',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/a/a4/H-line_icon.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "----",
					ownline: true
				}
			}
		}
	}
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"comment": {
			label: 'Comment',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<!-- ",
					post: " -->"
				}
			}
		}
	}
} );

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"math": {
			label: 'Math',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/2/2e/Button_math.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<math>",
					post: "</math>"
				}
			}
		}
	}
} );












};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
	mw.loader.using( 'user.options', 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.toolbar' ), $.ready
			).then( customizeToolbar );
		}
	} );
}
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );