r113685 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113684‎ | r113685 | r113686 >
Date:23:53, 12 March 2012
Author:jdlrobson
Status:ok
Tags:
Comment:
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 (modified) (history)
  • /trunk/extensions/MobileFrontend/javascripts/toggle.js (modified) (history)
  • /trunk/extensions/MobileFrontend/stylesheets/beta_common.css (modified) (history)
  • /trunk/extensions/MobileFrontend/stylesheets/common.css (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/toggle.js
@@ -26,7 +26,6 @@
2727 label = document.createTextNode( MobileFrontend.message( visible ? 'expand-section' : 'collapse-section' ) );
2828 btn.className = visible ? 'show' : 'hide';
2929 btn.appendChild( label );
30 - btn.style.display = visible ? 'inline-block' : 'none';
3130 return btn;
3231 }
3332 if(!sectionHeadings) {
@@ -73,9 +72,10 @@
7473 function wm_toggle_section( section_id ) {
7574 var b = document.getElementById( 'section_' + section_id ),
7675 bb = b.getElementsByTagName( 'button' ), i, s, e;
77 - for ( i = 0; i <= 1; i++ ) {
78 - s = bb[i].style;
79 - s.display = s.display === 'none' || ( i && !s.display ) ? 'inline-block' : 'none';
 76+ if( u(b).hasClass( 'openSection' ) ) {
 77+ u(b).removeClass( 'openSection' );
 78+ } else {
 79+ u(b).addClass( 'openSection' );
8080 }
8181 for ( i = 0, d = ['content_','anchor_']; i<=1; i++ ) {
8282 e = document.getElementById( d[i] + section_id );
Index: trunk/extensions/MobileFrontend/javascripts/application.js
@@ -36,6 +36,12 @@
3737 return [].slice.call( document.querySelectorAll( el ) );
3838 }
3939 }
 40+
 41+ function hasClass( name ) {
 42+ var classNames = el.className.split( '' );
 43+ return classNames.indexOf( name ) > -1;
 44+ }
 45+
4046 function addClass( name ) {
4147 var className = el.className,
4248 classNames = className.split( ' ' );
@@ -66,6 +72,7 @@
6773 return {
6874 addClass: addClass,
6975 bind: bind,
 76+ hasClass: hasClass,
7077 remove: remove,
7178 removeClass: removeClass
7279 };
Index: trunk/extensions/MobileFrontend/stylesheets/common.css
@@ -332,17 +332,23 @@
333333 margin: 0px;
334334 }
335335
336 -button.show {
 336+button.show,
 337+button.hide { /* for non-js browsers */
337338 display: none;
338339 }
339340
 341+.togglingEnabled button.hide,
 342+.togglingEnabled .openSection button.show {
 343+ display: none;
 344+}
 345+
 346+.togglingEnabled .openSection button.hide,
340347 .togglingEnabled button.show {
341348 display: inline-block;
342349 }
343350
344351 .togglingEnabled .content_block,
345 -.togglingEnabled .section_anchors,
346 -button.section_heading.hide {
 352+.togglingEnabled .section_anchors {
347353 display: none;
348354 }
349355
Index: trunk/extensions/MobileFrontend/stylesheets/beta_common.css
@@ -318,17 +318,23 @@
319319 margin: 0px;
320320 }
321321
322 -button.show {
 322+button.show,
 323+button.hide { /* for non-js browsers */
323324 display: none;
324325 }
325326
 327+.togglingEnabled button.hide,
 328+.togglingEnabled .openSection button.show {
 329+ display: none;
 330+}
 331+
 332+.togglingEnabled .openSection button.hide,
326333 .togglingEnabled button.show {
327334 display: inline-block;
328335 }
329336
330337 .togglingEnabled .content_block,
331 -.togglingEnabled .section_anchors,
332 -button.section_heading.hide {
 338+.togglingEnabled .section_anchors {
333339 display: none;
334340 }
335341

Follow-up revisions

RevisionCommit summaryAuthorDate
r114201MFT r113486, r113488, r113512, r113553, r113640, r113642, r113644, r113645, r...awjrichards22:18, 19 March 2012

Status & tagging log