|
|
| (3 mellomversjonar av den same brukaren er ikkje viste) |
| Line 1: |
Line 1: |
| /**
| |
| * Description: Modify parts of the toolbar to better suit this projects needs
| |
| * Maintainer:
| |
| */
| |
| function(mw, $, undefined) {
| |
| //if ( $.fn.wikiEditor !== undefined ) {
| |
|
| |
|
| // customization for the beta toolbar
| |
| var customizeBetaToolbar = function () {
| |
|
| |
| // Execute on load
| |
| $( function() {
| |
|
| |
| // just to get rid of some errors
| |
| function label(msg, txt, before, after) {
| |
| var str = '';
| |
| if (before === undefined ? true : before) str += "{" + "{";
| |
| str += msg;
| |
| if (after === undefined ? true : after) str += "}" + "}";
| |
| if (txt) str += " – " + txt;
| |
| return str;
| |
| }
| |
| // just to get rid of some errors
| |
| function pre(msg, txt, before) {
| |
| var str = '';
| |
| if (before === undefined ? true : before) str += "{" + "{";
| |
| str += msg;
| |
| if (txt) str += txt;
| |
| return str;
| |
| }
| |
| // just to get rid of some errors
| |
| function peri(msg, txt, before, after) {
| |
| var str = '';
| |
| if (before === undefined ? true : before) str += "{" + "{";
| |
| str += msg;
| |
| if (txt) str += txt;
| |
| if (after === undefined ? true : after) str += "}" + "}";
| |
| return str;
| |
| }
| |
|
| |
| // get timestamp for templates
| |
| var now = new Date();
| |
| var timestamp = now.getUTCFullYear() + '-' + (now.getUTCMonth()<9 ? '0' : '') + (now.getUTCMonth()+1) + '-' + (now.getUTCDate()<9 ? '0' : '') + now.getUTCDate();
| |
|
| |
| // add quote signs to the format group in the main section
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'main',
| |
| 'group': 'format',
| |
| 'tools': {
| |
| 'quote': {
| |
| label: 'Anførselstegn',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/a/ac/Norwegian_quote_sign.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "«",
| |
| //peri: "«»",
| |
| post: "»"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| // add quote signs to the format group in the main section
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'main',
| |
| 'group': 'format',
| |
| 'tools': {
| |
| 'link': {
| |
| label: 'Lenkeparenteser',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/b/ba/Norwegian_link_sign.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "[[",
| |
| //peri: "[[]]",
| |
| post: "]]"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| // add quote signs to the format group in the main section
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'main',
| |
| 'group': 'format',
| |
| 'tools': {
| |
| 'link': {
| |
| label: 'Malparenteser',
| |
| type: 'button',
| |
| icon: '//upload.wikimedia.org/wikipedia/commons/4/4a/Norwegian_template_sign.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "{{",
| |
| //peri: "{{}}",
| |
| post: "}}"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| // add an article mark menu in the advanced section
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'advanced',
| |
| groups: {
| |
| 'heading': {
| |
| tools: {
| |
| 'heading': {
| |
| label: 'Vedlikehold',
| |
| type: 'select',
| |
| list: {
| |
| 'template-neutral' : {
| |
| label: label('Nøytralitet', 'artikkelen gir ikke en nøytral fremstilling'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Nøytralitet', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-verifiable' : {
| |
| label: label('Verifiserbar', 'artikkelen er ikke verifiserbar'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Verifiserbar', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-research' : {
| |
| label: label('Forskning', 'artikkelen inneholder originalforskning'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Forskning', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-accuracy' : {
| |
| label: label('Nøyaktighet', 'artikkelen har ikke en nøyaktig fremstilling'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Nøyaktighet', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-spelling' : {
| |
| label: label('Språkvask', 'artikkelens språk trenger en gjennomgang'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Språkvask', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-format' : {
| |
| label: label('Formatering', 'artikkelen trenger wikifisering'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Formatering', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-workinprogress' : {
| |
| label: label('Arbeid pågår', 'artikkelen er under arbeid'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('Arbeid pågår', '|ts=' + timestamp + '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| // add a template menu in the advanced sectionined' ) {
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'advanced',
| |
| groups: {
| |
| 'heading': {
| |
| tools: {
| |
| 'heading': {
| |
| label: 'Maler',
| |
| type: 'select',
| |
| list: {
| |
| 'template-columns' : {
| |
| label: label('kolonner', 'etterfølgende liste fordeles over flere kolonner'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('kolonner', '|'),
| |
| //peri: peri('columns'),
| |
| post: '}}',
| |
| ownline: true
| |
| }
| |
| }
| |
| },
| |
| 'template-sorted-columns' : {
| |
| label: label('sorterte kolonner', 'etterfølgende liste fordeles over flere sorterbare kolonner'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('sorterte kolonner', '|tittel='),
| |
| //peri: peri('columns'),
| |
| post: '}}',
| |
| ownline: true
| |
| }
| |
| }
| |
| },
| |
| 'template-nowrap' : {
| |
| label: label('nowrap', 'hindre linjeskift i tekst og tall'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('nowrap', '|'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-formatnum' : {
| |
| label: label('formatnum', 'tall med mellomrom og desimalkomma'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('formatnum', ':'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| },
| |
| 'template-defaultsort' : {
| |
| label: label('DEFAULTSORT', 'sortering på etternavn og lignende'),
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: pre('DEFAULTSORT', ':'),
| |
| post: '}}',
| |
| ownline: false
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
|
| |
| // add a titles menu in the advanced section
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'advanced',
| |
| groups: {
| |
| 'heading': {
| |
| tools: {
| |
| 'heading': {
| |
| label: 'Titler',
| |
| type: 'select',
| |
| list: {
| |
| 'titles-see-also' : {
| |
| label: '== Se også == – interne lenker til andre prosjekter',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '== Se også ==',
| |
| ownline: true
| |
| }
| |
| }
| |
| },
| |
| 'titles-references' : {
| |
| label: '== Referanser == – oppgitte referanser i teksten',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "== Referanser ==\n<references>\n",
| |
| post: "\n</references>",
| |
| ownline: true
| |
| }
| |
| }
| |
| },
| |
| 'titles-literature' : {
| |
| label: '== Litteratur == – oppgitt litteratur',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '== Litteratur ==',
| |
| ownline: true
| |
| }
| |
| }
| |
| },
| |
| 'titles-links' : {
| |
| label: '== Eksterne lenker == – lenker til nettsteder',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: '== Eksterne lenker ==',
| |
| ownline: true
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| });
| |
| };
| |
| /* Check if we are in edit mode and the required modules are available and then customize the toolbar */
| |
| if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 ) {
| |
| mw.loader.using( 'user.options', function () {
| |
| if ( mw.user.options.get('usebetatoolbar') ) {
| |
| mw.loader.using( 'ext.wikiEditor.toolbar', function () {
| |
| $(customizeBetaToolbar);
| |
| });
| |
| }
| |
| //else {
| |
| // $(customizeOrigToolbar);
| |
| // }
| |
| });
| |
| }
| |
|
| |
| }(mediaWiki, jQuery);
| |