Difference between revisions of "User:Leafygeans/common.js"
Jump to navigation
Jump to search
Leafygeans (talk | contribs) (Created page with "test") |
Leafygeans (talk | contribs) |
||
Line 1: | Line 1: | ||
//customize toolbar |
|||
test |
|||
var customizeToolbar = function() { |
|||
/* Your code goes here */ |
|||
// Adding an art infobox button to the "main" section |
|||
$('#wpTextbox1' ).wikiEditor( 'addToToolbar', { |
|||
section: 'main', |
|||
group: 'insert', |
|||
tools: { |
|||
code: { |
|||
label: 'Art infobox', |
|||
type: 'button', |
|||
icon: '//upload.wikimedia.org/wikipedia/commons/5/5a/Vector_toolbar_insert_picture_gallery_button.png', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{art' + '\n' + '|#artist=' + '\n' + '|series=' + '\n' + '|#source=', |
|||
post: '\n' + '|type=' + '\n' + '}}' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
// Adding artist attribution button for galleries to the "main" section |
|||
$('#wpTextbox1').wikiEditor('addToToolbar', { |
|||
section: 'main', |
|||
group: 'insert', |
|||
tools: { |
|||
artistAttribution: { |
|||
label: 'Artist Attribution', |
|||
type: 'button', |
|||
icon: '//upload.wikimedia.org/wikipedia/commons/1/1b/Button_miss_signature.png', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '| <small><center>by {' + '{a|', |
|||
post: '}}</center></small>' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
// Adding <br/> button to the "main" section |
|||
$('#wpTextbox1').wikiEditor('addToToolbar', { |
|||
section: 'main', |
|||
group: 'insert', |
|||
tools: { |
|||
break: { |
|||
label: 'Break tag', |
|||
type: 'button', |
|||
icon: '//upload.wikimedia.org/wikipedia/commons/1/13/Button_enter.png', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '<' + 'br />', |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
// Adding hidden text button to the "main" section |
|||
$('#wpTextbox1' ).wikiEditor( 'addToToolbar', { |
|||
section: 'main', |
|||
group: 'insert', |
|||
tools: { |
|||
hidden: { |
|||
label: 'Hidden text', |
|||
type: 'button', |
|||
icon: '//upload.wikimedia.org/wikipedia/commons/1/1b/Button_hide_wiki_tag.png', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: "<!--", |
|||
post: "-->" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
// Adding image template button to the "main" section |
|||
$('#wpTextbox1').wikiEditor('addToToolbar', { |
|||
section: 'main', |
|||
group: 'insert', |
|||
tools: { |
|||
image: { |
|||
label: 'Image template', |
|||
type: 'button', |
|||
icon: '//upload.wikimedia.org/wikipedia/commons/d/d8/Vector_toolbar_insert_image_button.png', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{image|', |
|||
post: '|side=|width=|caption}}' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
}; |
|||
/* |
|||
* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar... |
|||
* Don't touch below this line! |
|||
*/ |
|||
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); |
|||
} |
|||
}); |
|||
} |
Revision as of 00:52, 10 February 2023
//customize toolbar var customizeToolbar = function() { /* Your code goes here */ // Adding an art infobox button to the "main" section $('#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'main', group: 'insert', tools: { code: { label: 'Art infobox', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/5/5a/Vector_toolbar_insert_picture_gallery_button.png', action: { type: 'encapsulate', options: { pre: '{' + '{art' + '\n' + '|#artist=' + '\n' + '|series=' + '\n' + '|#source=', post: '\n' + '|type=' + '\n' + '}}' } } } } }); // Adding artist attribution button for galleries to the "main" section $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'main', group: 'insert', tools: { artistAttribution: { label: 'Artist Attribution', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/1/1b/Button_miss_signature.png', action: { type: 'encapsulate', options: { pre: '| <small><center>by {' + '{a|', post: '}}</center></small>' } } } } }); // Adding <br/> button to the "main" section $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'main', group: 'insert', tools: { break: { label: 'Break tag', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/1/13/Button_enter.png', action: { type: 'encapsulate', options: { pre: '<' + 'br />', } } } } }); // Adding hidden text button to the "main" section $('#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'main', group: 'insert', tools: { hidden: { label: 'Hidden text', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/1/1b/Button_hide_wiki_tag.png', action: { type: 'encapsulate', options: { pre: "<!--", post: "-->" } } } } }); // Adding image template button to the "main" section $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'main', group: 'insert', tools: { image: { label: 'Image template', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/d/d8/Vector_toolbar_insert_image_button.png', action: { type: 'encapsulate', options: { pre: '{' + '{image|', post: '|side=|width=|caption}}' } } } } }); }; /* * Check if view is in edit mode and that the required modules are available. Then, customize the toolbar... * Don't touch below this line! */ 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); } }); }