Difference between revisions of "User:Leafygeans/common.js"
Jump to navigation
Jump to search
Leafygeans (talk | contribs) |
Leafygeans (talk | contribs) |
||
Line 106: | Line 106: | ||
} |
} |
||
}); |
}); |
||
//Add new references dropdown to the "advanced" section |
|||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { |
|||
section: 'advanced', |
|||
groups: { |
|||
list: { |
|||
tools: { |
|||
references: { |
|||
label: 'references', |
|||
type: 'select', |
|||
list: { |
|||
'book-ref': { |
|||
label: '{' + '{book ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{book ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'wob-ref': { |
|||
label: '{' + '{wob ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{wob ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'ref-plaintext': { |
|||
label: '{' + '{ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{ref|text=', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'epigraph-ref': { |
|||
label: '{' + '{epigraph ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{epigraph ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'au-ref': { |
|||
label: '{' + '{au ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{au ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'msh-ref': { |
|||
label: '{' + '{msh ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{msh ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'tes-ref': { |
|||
label: '{' + '{tes ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{tes ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'file-ref': { |
|||
label: '{' + '{file ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{file ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'map-ref': { |
|||
label: '{' + '{map ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{map ref|', |
|||
post: '}}' |
|||
} |
|||
} |
|||
}, |
|||
'url-ref': { |
|||
label: '{' + '{url ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{url ref|url=', |
|||
post: '|text=|date=|site=}}' |
|||
} |
|||
} |
|||
}, |
|||
'17s-ref': { |
|||
label: '{' + '{17s ref}}', |
|||
action: { |
|||
type: 'encapsulate', |
|||
options: { |
|||
pre: '{' + '{17s ref|topic/news/post', |
|||
post: '|id#|description|date=}}' |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} ); |
|||
}; |
}; |
Revision as of 00:57, 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}}' } } } } }); //Add new references dropdown to the "advanced" section $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', groups: { list: { tools: { references: { label: 'references', type: 'select', list: { 'book-ref': { label: '{' + '{book ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{book ref|', post: '}}' } } }, 'wob-ref': { label: '{' + '{wob ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{wob ref|', post: '}}' } } }, 'ref-plaintext': { label: '{' + '{ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{ref|text=', post: '}}' } } }, 'epigraph-ref': { label: '{' + '{epigraph ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{epigraph ref|', post: '}}' } } }, 'au-ref': { label: '{' + '{au ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{au ref|', post: '}}' } } }, 'msh-ref': { label: '{' + '{msh ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{msh ref|', post: '}}' } } }, 'tes-ref': { label: '{' + '{tes ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{tes ref|', post: '}}' } } }, 'file-ref': { label: '{' + '{file ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{file ref|', post: '}}' } } }, 'map-ref': { label: '{' + '{map ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{map ref|', post: '}}' } } }, 'url-ref': { label: '{' + '{url ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{url ref|url=', post: '|text=|date=|site=}}' } } }, '17s-ref': { label: '{' + '{17s ref}}', action: { type: 'encapsulate', options: { pre: '{' + '{17s ref|topic/news/post', post: '|id#|description|date=}}' } } } } } } } } } ); }; /* * 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); } }); }