https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113685

Revision: 113685
Author:   jdlrobson
Date:     2012-03-12 23:53:06 +0000 (Mon, 12 Mar 2012)
Log Message:
-----------
add class openSection to heading when toggling

this allows us to style open headings differently
from closed headings and is preparation for
http://www.mediawiki.org/wiki/File:Mobile_article_expand.png

Modified Paths:
--------------
    trunk/extensions/MobileFrontend/javascripts/application.js
    trunk/extensions/MobileFrontend/javascripts/toggle.js
    trunk/extensions/MobileFrontend/stylesheets/beta_common.css
    trunk/extensions/MobileFrontend/stylesheets/common.css

Modified: trunk/extensions/MobileFrontend/javascripts/application.js
===================================================================
--- trunk/extensions/MobileFrontend/javascripts/application.js  2012-03-12 
23:31:08 UTC (rev 113684)
+++ trunk/extensions/MobileFrontend/javascripts/application.js  2012-03-12 
23:53:06 UTC (rev 113685)
@@ -36,6 +36,12 @@
                                return [].slice.call( 
document.querySelectorAll( el ) );
                        }
                }
+
+               function hasClass( name ) {
+                       var classNames = el.className.split( '' );
+                       return classNames.indexOf( name ) > -1;
+               }
+
                function addClass( name ) {
                        var className = el.className,
                                classNames = className.split( ' ' );
@@ -66,6 +72,7 @@
                return {
                        addClass: addClass,
                        bind: bind,
+                       hasClass: hasClass,
                        remove: remove,
                        removeClass: removeClass
                };

Modified: trunk/extensions/MobileFrontend/javascripts/toggle.js
===================================================================
--- trunk/extensions/MobileFrontend/javascripts/toggle.js       2012-03-12 
23:31:08 UTC (rev 113684)
+++ trunk/extensions/MobileFrontend/javascripts/toggle.js       2012-03-12 
23:53:06 UTC (rev 113685)
@@ -26,7 +26,6 @@
                        label = document.createTextNode( 
MobileFrontend.message( visible ? 'expand-section' : 'collapse-section' ) );
                        btn.className = visible ? 'show' : 'hide';
                        btn.appendChild( label );
-                       btn.style.display = visible ? 'inline-block' : 'none';
                        return btn;
                }
                if(!sectionHeadings) {
@@ -73,9 +72,10 @@
        function wm_toggle_section( section_id ) {
                var b = document.getElementById( 'section_' + section_id ),
                        bb = b.getElementsByTagName( 'button' ), i, s, e;
-               for ( i = 0; i <= 1; i++ ) {
-                       s = bb[i].style;
-                       s.display = s.display === 'none' || ( i && !s.display ) 
? 'inline-block' : 'none';
+               if( u(b).hasClass( 'openSection' ) ) {
+                       u(b).removeClass( 'openSection' );
+               } else {
+                       u(b).addClass( 'openSection' );
                }
                for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
                        e = document.getElementById( d[i] + section_id );

Modified: trunk/extensions/MobileFrontend/stylesheets/beta_common.css
===================================================================
--- trunk/extensions/MobileFrontend/stylesheets/beta_common.css 2012-03-12 
23:31:08 UTC (rev 113684)
+++ trunk/extensions/MobileFrontend/stylesheets/beta_common.css 2012-03-12 
23:53:06 UTC (rev 113685)
@@ -318,17 +318,23 @@
        margin: 0px;
 }
 
-button.show {
+button.show,
+button.hide { /* for non-js browsers */
        display: none;
 }
 
+.togglingEnabled button.hide,
+.togglingEnabled .openSection button.show {
+       display: none;
+}
+
+.togglingEnabled .openSection button.hide,
 .togglingEnabled button.show {
        display: inline-block;
 }
 
 .togglingEnabled .content_block,
-.togglingEnabled .section_anchors,
-button.section_heading.hide {
+.togglingEnabled .section_anchors {
        display: none;
 }
 

Modified: trunk/extensions/MobileFrontend/stylesheets/common.css
===================================================================
--- trunk/extensions/MobileFrontend/stylesheets/common.css      2012-03-12 
23:31:08 UTC (rev 113684)
+++ trunk/extensions/MobileFrontend/stylesheets/common.css      2012-03-12 
23:53:06 UTC (rev 113685)
@@ -332,17 +332,23 @@
        margin: 0px;
 }
 
-button.show {
+button.show,
+button.hide { /* for non-js browsers */
        display: none;
 }
 
+.togglingEnabled button.hide,
+.togglingEnabled .openSection button.show {
+       display: none;
+}
+
+.togglingEnabled .openSection button.hide,
 .togglingEnabled button.show {
        display: inline-block;
 }
 
 .togglingEnabled .content_block,
-.togglingEnabled .section_anchors,
-button.section_heading.hide {
+.togglingEnabled .section_anchors {
        display: none;
 }
 


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

Reply via email to