/** * Add Cite-specific functionality to the WikiEditor toolbar. * Adds a button to insert tags, and adds a help section * about how to use references to WikiEditor's help panel. * * @author Jon Harald Søby */ $( function () { mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { /* Add the button to the toolbar */ $textarea.wikiEditor( 'addToToolbar', { section: 'main', group: 'insert', tools: { reference: { label: mw.message( 'cite-wikieditor-tool-reference' ).escaped(), filters: [ 'body.ns-subject' ], type: 'button', oouiIcon: 'reference', action: { type: 'encapsulate', options: { pre: '', post: '' } } } } } ); /* Add reference help to the Help section */ var parsedRef = function ( number ) { return $( '' ) .addClass( 'reference' ) .append( $( '' ) .attr( 'href', '#' ) .text( mw.message( 'cite-wikieditor-help-content-reference-example-ref-result', mw.language.convertNumber( number ) ).text() ) ); }; $textarea.wikiEditor( 'addToToolbar', { section: 'help', pages: { references: { label: mw.message( 'cite-wikieditor-help-page-references' ).escaped(), layout: 'table', headings: [ { text: mw.message( 'wikieditor-toolbar-help-heading-description' ).escaped() }, { text: mw.message( 'wikieditor-toolbar-help-heading-syntax' ).escaped() }, { text: mw.message( 'wikieditor-toolbar-help-heading-result' ).escaped() } ], rows: [ { description: { html: mw.message( 'cite-wikieditor-help-content-reference-description' ).parse() }, syntax: { html: mw.html.escape( mw.message( 'cite-wikieditor-help-content-reference-example-text1', mw.message( 'cite-wikieditor-help-content-reference-example-ref-normal', mw.message( 'cite-wikieditor-help-content-reference-example-text2', 'https://www.example.org/' ).plain() ).plain() ).plain() ) }, result: { html: mw.message( 'cite-wikieditor-help-content-reference-example-text1', parsedRef( 1 ) ).parse() } }, { description: { html: mw.message( 'cite-wikieditor-help-content-named-reference-description' ).parse() }, syntax: { html: mw.html.escape( mw.message( 'cite-wikieditor-help-content-reference-example-text1', mw.message( 'cite-wikieditor-help-content-reference-example-ref-named', mw.message( 'cite-wikieditor-help-content-reference-example-ref-id' ).plain(), mw.message( 'cite-wikieditor-help-content-reference-example-text3', 'https://www.example.org/' ).plain() ).plain() ).plain() ) }, result: { html: mw.message( 'cite-wikieditor-help-content-reference-example-text1', parsedRef( 2 ) ).parse() } }, { description: { html: mw.message( 'cite-wikieditor-help-content-rereference-description' ).parse() }, syntax: { html: mw.html.escape( mw.message( 'cite-wikieditor-help-content-reference-example-text1', mw.message( 'cite-wikieditor-help-content-reference-example-ref-reuse', mw.message( 'cite-wikieditor-help-content-reference-example-ref-id' ).plain() ).plain() ).plain() ) }, result: { html: mw.message( 'cite-wikieditor-help-content-reference-example-text1', parsedRef( 2 ) ).parse() } }, { description: { html: mw.message( 'cite-wikieditor-help-content-showreferences-description' ).parse() }, syntax: { html: mw.message( 'cite-wikieditor-help-content-reference-example-reflist' ).escaped() }, result: { html: '
    ' + '
  1. ' + mw.message( 'cite_reference_backlink_symbol' ).parse() + ' ' + mw.message( 'cite-wikieditor-help-content-reference-example-text2', window.location.href + '#' ).parse() + '
  2. ' + '
  3. ' + mw.message( 'cite_reference_backlink_symbol' ).parse() + ' ' + mw.message( 'cite-wikieditor-help-content-reference-example-text3', window.location.href + '#' ).parse() + '
' } } ] } } } ); } ); }() );