Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/192858

Change subject: Don't use random ids for toggleable sections
......................................................................

Don't use random ids for toggleable sections

Bug: T90737
Change-Id: I8c95487681193fd78df303ff7abd66ea086b2664
---
M javascripts/modules/toc/init.js
M javascripts/modules/toggling/init.js
2 files changed, 10 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/58/192858/1

diff --git a/javascripts/modules/toc/init.js b/javascripts/modules/toc/init.js
index 738e8e1..fdd42ef 100644
--- a/javascripts/modules/toc/init.js
+++ b/javascripts/modules/toc/init.js
@@ -32,7 +32,7 @@
                                // prevent to float text right of toc
                                this.$( '.toc-mobile' ).after( '<div 
style="clear:both;"></div>' );
                        }
-                       toggle.enable( toc.$el );
+                       toggle.enable( toc.$el, 'toc-' );
                }
        }
 
diff --git a/javascripts/modules/toggling/init.js 
b/javascripts/modules/toggling/init.js
index 286612d..26fbd01 100644
--- a/javascripts/modules/toggling/init.js
+++ b/javascripts/modules/toggling/init.js
@@ -190,9 +190,10 @@
         *
         * @method
         * @param {jQuery.object} $container to apply toggling to
+        * @param {String} $prefix a prefix to use for the id.
         * @ignore
         */
-       function enable( $container ) {
+       function enable( $container, prefix ) {
                var tagName, expandSections, indicator,
                        $firstHeading,
                        collapseSectionsByDefault = mw.config.get( 
'wgMFCollapseSectionsByDefault' );
@@ -209,9 +210,9 @@
                expandSections = !collapseSectionsByDefault ||
                        ( context.isAlphaGroupMember() && settings.get( 
'expandSections', true ) === 'true' );
 
-               $container.find( tagName ).each( function () {
+               $container.find( tagName ).each( function ( i ) {
                        var $heading = $( this ),
-                               id = 'collapsible-block-' + 
Math.random().toString();
+                               id = prefix + 'collapsible-block-' + i;
                        // Be sure there is a div wrapping the section content.
                        // Otherwise, collapsible sections for this page is not 
enabled.
                        if ( $heading.next().is( 'div' ) ) {
@@ -303,12 +304,13 @@
         *
         * @method
         * @param {jQuery.Object} $container to enable toggling on
+        * @param {String} $prefix a prefix to use for the id.
         * @ignore
         */
-       function init( $container ) {
+       function init( $container, prefix ) {
                // distinguish headings in content from other headings
-               $( '#content' ).find( '> h1,> h2,> h3,> h4,> h5,> h6' 
).addClass( 'section-heading' );
-               enable( $container );
+               $container.find( '> h1,> h2,> h3,> h4,> h5,> h6' ).addClass( 
'section-heading' );
+               enable( $container, prefix );
        }
 
        // avoid this running on Watchlist
@@ -318,7 +320,7 @@
                mw.config.get( 'wgAction' ) === 'view'
        ) {
                if ( mw.config.get( 'wgMFPageSections' ) ) {
-                       init();
+                       init( $( '#content' ), 'content-' );
                }
        }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/192858
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8c95487681193fd78df303ff7abd66ea086b2664
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to