Merge "Remove closure in JavaScript files"

This commit is contained in:
jenkins-bot 2023-10-30 20:53:31 +00:00 committed by Gerrit Code Review
commit 0daea7ed38
2 changed files with 119 additions and 124 deletions

View file

@ -7,30 +7,27 @@
* *
* @author Marius Hoch <hoo@online.de> * @author Marius Hoch <hoo@online.de>
*/ */
( function () { mw.hook( 'wikipage.content' ).add( function ( $content ) {
const accessibilityLabelOne = mw.msg( 'cite_references_link_accessibility_label' );
const accessibilityLabelMany = mw.msg( 'cite_references_link_many_accessibility_label' );
mw.hook( 'wikipage.content' ).add( function ( $content ) { $content.find( '.mw-cite-backlink' ).each( function () {
const accessibilityLabelOne = mw.msg( 'cite_references_link_accessibility_label' ); const $links = $( this ).find( 'a' );
const accessibilityLabelMany = mw.msg( 'cite_references_link_many_accessibility_label' );
$content.find( '.mw-cite-backlink' ).each( function () { if ( $links.length > 1 ) {
const $links = $( this ).find( 'a' ); // This citation is used multiple times. Let's only set the accessibility label on the first link, the
// following ones should then be self-explaining. This is needed to make sure this isn't getting
if ( $links.length > 1 ) { // too wordy.
// This citation is used multiple times. Let's only set the accessibility label on the first link, the $links.eq( 0 ).prepend(
// following ones should then be self-explaining. This is needed to make sure this isn't getting $( '<span>' )
// too wordy. .addClass( 'cite-accessibility-label' )
$links.eq( 0 ).prepend( // Also make sure we have at least one space between the accessibility label and the visual one
$( '<span>' ) .text( accessibilityLabelMany + ' ' )
.addClass( 'cite-accessibility-label' ) );
// Also make sure we have at least one space between the accessibility label and the visual one } else {
.text( accessibilityLabelMany + ' ' ) $links
); .attr( 'aria-label', accessibilityLabelOne )
} else { .attr( 'title', accessibilityLabelOne );
$links }
.attr( 'aria-label', accessibilityLabelOne )
.attr( 'title', accessibilityLabelOne );
}
} );
} ); } );
}() ); } );

View file

@ -8,107 +8,105 @@
* @author Jon Harald Søby * @author Jon Harald Søby
*/ */
( function () { mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) { /* Add the <ref></ref> button to the toolbar */
/* Add the <ref></ref> button to the toolbar */ $textarea.wikiEditor( 'addToToolbar', {
$textarea.wikiEditor( 'addToToolbar', { section: 'main',
section: 'main', group: 'insert',
group: 'insert', tools: {
tools: { reference: {
reference: { label: mw.msg( 'cite-wikieditor-tool-reference' ),
label: mw.msg( 'cite-wikieditor-tool-reference' ), filters: [ 'body.ns-subject' ],
filters: [ 'body.ns-subject' ], type: 'button',
type: 'button', oouiIcon: 'reference',
oouiIcon: 'reference', action: {
action: { type: 'encapsulate',
type: 'encapsulate', options: {
options: { pre: '<ref>',
pre: '<ref>', post: '</ref>'
post: '</ref>'
}
} }
} }
} }
} ); }
/* Add reference help to the Help section */
const parsedRef = function ( number ) {
return $( '<sup>' )
.addClass( 'reference' )
.append(
$( '<a>' )
.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.msg( 'cite-wikieditor-help-page-references' ),
layout: 'table',
headings: [
{ text: mw.message( 'wikieditor-toolbar-help-heading-description' ).parse() },
{ text: mw.message( 'wikieditor-toolbar-help-heading-syntax' ).parse() },
{ text: mw.message( 'wikieditor-toolbar-help-heading-result' ).parse() }
],
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: '<ol class="references">' +
'<li><span class="mw-cite-backlink"><a href="#">' +
mw.message( 'cite_reference_backlink_symbol' ).parse() + '</a></span> ' +
mw.message( 'cite-wikieditor-help-content-reference-example-text2', window.location.href + '#' ).parse() +
'</li>' +
'<li><span class="mw-cite-backlink"><a href="#">' +
mw.message( 'cite_reference_backlink_symbol' ).parse() +
'</a></span> ' +
mw.message( 'cite-wikieditor-help-content-reference-example-text3', window.location.href + '#' ).parse() +
'</li></ol>'
}
}
]
}
}
} );
} ); } );
}() );
/* Add reference help to the Help section */
const parsedRef = function ( number ) {
return $( '<sup>' )
.addClass( 'reference' )
.append(
$( '<a>' )
.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.msg( 'cite-wikieditor-help-page-references' ),
layout: 'table',
headings: [
{ text: mw.message( 'wikieditor-toolbar-help-heading-description' ).parse() },
{ text: mw.message( 'wikieditor-toolbar-help-heading-syntax' ).parse() },
{ text: mw.message( 'wikieditor-toolbar-help-heading-result' ).parse() }
],
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: '<ol class="references">' +
'<li><span class="mw-cite-backlink"><a href="#">' +
mw.message( 'cite_reference_backlink_symbol' ).parse() + '</a></span> ' +
mw.message( 'cite-wikieditor-help-content-reference-example-text2', window.location.href + '#' ).parse() +
'</li>' +
'<li><span class="mw-cite-backlink"><a href="#">' +
mw.message( 'cite_reference_backlink_symbol' ).parse() +
'</a></span> ' +
mw.message( 'cite-wikieditor-help-content-reference-example-text3', window.location.href + '#' ).parse() +
'</li></ol>'
}
}
]
}
}
} );
} );