提供: Minecraft Modding Wiki
移動先: 案内検索
1行目: 1行目:
// Check that the toolbar is available
+
jQuery( document ).ready( function ( $ ) {
if ( typeof $ != 'undefined' && typeof $.fn.wikiEditor != 'undefined' ) {
+
$( 'div#edittoolbar' ).wikiEditor();
        // Execute on load
+
 
        $( function() {
+
var customizeToolbar = function() {
        $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
         section: 'advanced',
 
         section: 'advanced',
 
         group: 'format',
 
         group: 'format',
10行目: 10行目:
 
                 label: 'source code',
 
                 label: 'source code',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//mcmodding.jp/modding/extensions/WikiEditor/modules/images/toolbar/code-java.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/code-java.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
29行目: 29行目:
 
                 label: 'html',
 
                 label: 'html',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//mcmodding.jp/modding/extensions/WikiEditor/modules/images/toolbar/code-html.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/code-html.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
48行目: 48行目:
 
                 label: 'red',
 
                 label: 'red',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//mcmodding.jp/modding/extensions/WikiEditor/modules/images/toolbar/color-red.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-red.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
67行目: 67行目:
 
                 label: 'blue',
 
                 label: 'blue',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//mcmodding.jp/modding/extensions/WikiEditor/modules/images/toolbar/color-blue.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-blue.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
86行目: 86行目:
 
                 label: 'del',
 
                 label: 'del',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//mcmodding.jp/modding/extensions/WikiEditor/modules/images/toolbar/delete.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/delete.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
105行目: 105行目:
 
                 label: 'notoc',
 
                 label: 'notoc',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//mcmodding.jp/modding/extensions/WikiEditor/modules/images/toolbar/notoc.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/notoc.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
115行目: 115行目:
 
         }
 
         }
 
     } );
 
     } );
 +
};
  
});
+
/* 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 );
 +
} );

2018年8月20日 (月) 21:08時点における版

jQuery( document ).ready( function ( $ ) {
$( 'div#edittoolbar' ).wikiEditor();

var customizeToolbar = function() {
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'source code',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/code-java.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<source lang="java">',
                        peri: 'Insert code here',
                        post: '</source>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'html',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/code-html.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<html>',
                        peri: 'Insert html here',
                        post: '</html>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'red',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-red.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<span style="color: red">',
                        peri: 'Insert text',
                        post: '</span>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'blue',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/color-blue.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<span style="color: blue">',
                        peri: 'Insert text',
                        post: '</span>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'del',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/delete.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '<s>',
                        peri: 'Insert here',
                        post: '</s>'
                    }
                }
            }
        }
    } );
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        section: 'advanced',
        group: 'format',
        tools: {
            buttonId: {
                label: 'notoc',
                type: 'button',
                icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/notoc.png',
                action: {
                    type: 'encapsulate',
                    options: {
                        pre: '__NOTOC__',
                    }
                }
            }
        }
    } );
};

/* 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 );
} );