jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/307686 )
Change subject: Apply MediaWiki coding conventions for JavaScript
......................................................................
Apply MediaWiki coding conventions for JavaScript
* Add closure.
* Use $foo.find( '...' ) instead of $( '...', $foo ).
* Use $( '<span>' ) instead of $( '<span />' ).
* Remove not necessary public object mw.tocTree.
* Remove not necessary return true.
Change-Id: I99f9a11154b5e49cdb60e0d079f4d86070cc2666
---
M modules/ext.toctree.js
1 file changed, 14 insertions(+), 18 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ext.toctree.js b/modules/ext.toctree.js
index b091e10..097a363 100644
--- a/modules/ext.toctree.js
+++ b/modules/ext.toctree.js
@@ -11,9 +11,9 @@
* @licence GNU General Public Licence 2.0 or later
*/
-mw.tocTree = {
- processClickEvent: function ( event ) {
- var $ul = $( 'ul', $( this ).parent().parent() );
+( function ( mw, $ ) {
+ function processClickEvent( event ) {
+ var $ul = $( this ).parent().parent().find( 'ul' );
$ul.toggle();
if ( $ul.is( ':visible' ) ) {
@@ -25,9 +25,9 @@
.text( '+' )
.attr( 'title', mw.msg( 'showtoc' ) );
}
- },
+ }
- init: function() {
+ function init() {
var $toc = $( '#toc' );
if ( $toc.length > 0 ) {
@@ -36,20 +36,20 @@
}
$toc.attr( 'cellspacing', 0 );
- var $mainUl = $( 'ul:first', $toc );
- var $mainList = $( 'li', $toc );
+ var $mainUl = $toc.find( 'ul:first' );
+ var $mainList = $toc.find( 'li' );
- $mainList.each( function( i ) {
+ $mainList.each( function ( i ) {
if ( $( this ).hasClass( 'toclevel-1' ) ) {
$( this ).css( 'position', 'relative' );
- var $subList = $( 'ul', $( this ) );
+ var $subList = $( this ).find( 'ul' );
if ( $subList.length > 0 ) {
if ( $mainUl.length > 0 ) {
$mainUl.addClass(
'tocUl' );
}
- var $toggleLink = $( '<span />'
).addClass( 'toggleSymbol' );
+ var $toggleLink = $( '<span>'
).addClass( 'toggleSymbol' );
if ( mw.user.options.get(
'toc-expand' ) ) {
$toggleLink
@@ -64,9 +64,9 @@
$subList.hide();
}
- $toggleLink.click(
mw.tocTree.processClickEvent );
+ $toggleLink.click(
processClickEvent );
- var $toggleSpan = $( '<span />'
).addClass( 'toggleNode' );
+ var $toggleSpan = $( '<span>'
).addClass( 'toggleNode' );
$toggleSpan.append( '[',
$toggleLink, ']' );
$( this ).prepend( $toggleSpan
);
@@ -74,11 +74,7 @@
}
} );
}
-
- return true;
}
-};
-jQuery( function( $ ) {
- mw.tocTree.init();
-} );
+ $( init );
+}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/307686
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I99f9a11154b5e49cdb60e0d079f4d86070cc2666
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/TocTree
Gerrit-Branch: master
Gerrit-Owner: Fomafix <[email protected]>
Gerrit-Reviewer: Fomafix <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits