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>
*/
( 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 ) {
const accessibilityLabelOne = mw.msg( 'cite_references_link_accessibility_label' );
const accessibilityLabelMany = mw.msg( 'cite_references_link_many_accessibility_label' );
$content.find( '.mw-cite-backlink' ).each( function () {
const $links = $( this ).find( 'a' );
$content.find( '.mw-cite-backlink' ).each( function () {
const $links = $( this ).find( 'a' );
if ( $links.length > 1 ) {
// 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
// too wordy.
$links.eq( 0 ).prepend(
$( '<span>' )
.addClass( 'cite-accessibility-label' )
// Also make sure we have at least one space between the accessibility label and the visual one
.text( accessibilityLabelMany + ' ' )
);
} else {
$links
.attr( 'aria-label', accessibilityLabelOne )
.attr( 'title', accessibilityLabelOne );
}
} );
if ( $links.length > 1 ) {
// 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
// too wordy.
$links.eq( 0 ).prepend(
$( '<span>' )
.addClass( 'cite-accessibility-label' )
// Also make sure we have at least one space between the accessibility label and the visual one
.text( accessibilityLabelMany + ' ' )
);
} else {
$links
.attr( 'aria-label', accessibilityLabelOne )
.attr( 'title', accessibilityLabelOne );
}
} );
}() );
} );

View file

@ -8,107 +8,105 @@
* @author Jon Harald Søby
*/
( function () {
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
/* Add the <ref></ref> button to the toolbar */
$textarea.wikiEditor( 'addToToolbar', {
section: 'main',
group: 'insert',
tools: {
reference: {
label: mw.msg( 'cite-wikieditor-tool-reference' ),
filters: [ 'body.ns-subject' ],
type: 'button',
oouiIcon: 'reference',
action: {
type: 'encapsulate',
options: {
pre: '<ref>',
post: '</ref>'
}
mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
/* Add the <ref></ref> button to the toolbar */
$textarea.wikiEditor( 'addToToolbar', {
section: 'main',
group: 'insert',
tools: {
reference: {
label: mw.msg( 'cite-wikieditor-tool-reference' ),
filters: [ 'body.ns-subject' ],
type: 'button',
oouiIcon: 'reference',
action: {
type: 'encapsulate',
options: {
pre: '<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>'
}
}
]
}
}
} );
} );