提供: defeatedcrow mod wiki
移動先: 案内検索
 
(同じ利用者による、間の4版が非表示)
3行目: 3行目:
  
 
var customizeToolbar = function() {
 
var customizeToolbar = function() {
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
    $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 
         section: 'advanced',
 
         section: 'advanced',
 
         group: 'format',
 
         group: 'format',
 
         tools: {
 
         tools: {
 
             buttonId: {
 
             buttonId: {
                 label: 'Comment',
+
                 label: 'source code',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/format-italic-C.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/code-java.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
 
                     options: {
 
                     options: {
                         pre: '<!-- ',
+
                         pre: '<source lang="java">',
                         peri: 'Insert comment here',
+
                         peri: 'Insert code here',
                         post: ' -->'
+
                         post: '</source>'
 
                     }
 
                     }
 
                 }
 
                 }
27行目: 27行目:
 
         tools: {
 
         tools: {
 
             buttonId: {
 
             buttonId: {
                 label: 'source code',
+
                 label: 'html',
 
                 type: 'button',
 
                 type: 'button',
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/add-code.png',
+
                 icon: '//defeatedcrow.jp/modwiki/extensions/WikiEditor/modules/images/toolbar/code-html.png',
 
                 action: {
 
                 action: {
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
 
                     options: {
 
                     options: {
                         pre: '<source lang="java">',
+
                         pre: '<html>',
                         peri: 'Insert sode here',
+
                         peri: 'Insert html here',
                         post: '<source>'
+
                         post: '</html>'
 
                     }
 
                     }
 
                 }
 
                 }
52行目: 52行目:
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
 
                     options: {
 
                     options: {
                         pre: '<pre style="color: red">',
+
                         pre: '<span style="color: red">',
 
                         peri: 'Insert text',
 
                         peri: 'Insert text',
                         post: '</pre>'
+
                         post: '</span>'
 
                     }
 
                     }
 
                 }
 
                 }
71行目: 71行目:
 
                     type: 'encapsulate',
 
                     type: 'encapsulate',
 
                     options: {
 
                     options: {
                         pre: '<pre style="color: blue">',
+
                         pre: '<span style="color: blue">',
 
                         peri: 'Insert text',
 
                         peri: 'Insert text',
                         post: '</pre>'
+
                         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__',
 
                     }
 
                     }
 
                 }
 
                 }

2016年5月19日 (木) 15:10時点における最新版

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