提供: Minecraft Modding Wiki
Defeatedcrow (トーク | 投稿記録) (ページの作成:「// Check that the toolbar is available if ( typeof $j !== 'undefined' && typeof $j.fn.wikiEditor !== 'undefined' ) { // Execute on load $j( function() { $…」) |
Defeatedcrow (トーク | 投稿記録) |
||
1行目: | 1行目: | ||
// Check that the toolbar is available | // Check that the toolbar is available | ||
− | + | var customizeToolbar = function () { | |
− | + | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | |
− | |||
− | |||
section: 'advanced', | section: 'advanced', | ||
group: 'format', | group: 'format', | ||
20行目: | 18行目: | ||
} | } | ||
} | } | ||
− | + | }); | |
− | + | ||
− | + | // To add a booklet section: | |
− | |||
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
'sections': { | 'sections': { | ||
31行目: | 28行目: | ||
} | } | ||
} | } | ||
− | } ); | + | }); |
− | + | ||
− | + | // To add a page to an existing booklet section | |
$j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
'section': 'info', | 'section': 'info', | ||
66行目: | 63行目: | ||
}); | }); | ||
− | + | }; | |
+ | |||
+ | /* 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' ).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 ); | ||
+ | } | ||
+ | } ); | ||
} | } |
2018年8月19日 (日) 16:19時点における版
// Check that the toolbar is available var customizeToolbar = function () { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'format', tools: { "math": { label: 'Java', type: 'button', icon: '//modwiki/extensions/WikiEditor/modules/images/toolbar/add-code.png', action: { type: 'encapsulate', options: { pre: "<syntaxhighlight>", post: "</source>" } } } } }); // To add a booklet section: $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'sections': { 'info': { 'type': 'booklet', 'label': 'Info' } } }); // To add a page to an existing booklet section $j( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'info', 'pages': { 'colors': { 'layout': 'table', 'label': 'Colors', 'headings': [ { text: 'Name' }, // or use textMsg for localization, see also above { text: 'Temperature' }, { text: 'Swatch' } ], 'rows': [ { 'name': { text: 'Red' }, 'temp': { text: 'Warm' }, 'swatch': { html: '<div style="width:10px;height:10px;background-color:red;">' } }, { 'name': { text: 'Blue' }, 'temp': { text: 'Cold' }, 'swatch': { html: '<div style="width:10px;height:10px;background-color:blue;">' } }, { 'name': { text: 'Silver' }, 'temp': { text: 'Neutral' }, 'swatch': { html: '<div style="width:10px;height:10px;background-color:silver;">' } } ] } } }); }; /* 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' ).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 ); } } ); }