r106984 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106983‎ | r106984 | r106985 >
Date:21:53, 21 December 2011
Author:foxtrott
Status:deferred
Tags:
Comment:
followup 106871: leave unselected tabs alone for no-script browsers
Modified paths:
  • /trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php (modified) (history)
  • /trunk/extensions/HeaderTabs/skins-jquery/ext.headertabs.core.js (modified) (history)

Diff [purge]

Index: trunk/extensions/HeaderTabs/skins-jquery/ext.headertabs.core.js
@@ -23,9 +23,23 @@
2424
2525 var $tabs = $("#headertabs").tabs();
2626
27 -$tabs.children('div').removeAttr('style');
28 -$tabs.children('ul').children().removeAttr('style');
 27+// delete the rule hiding unselected tabs
 28+var sheets = document.styleSheets;
2929
 30+// Could be somebody else inserted something, so we can not just delete rule 0 of sheet 0
 31+outer:
 32+for (s = 0; s < sheets.length; s++ ) {
 33+ var cursheet = sheets[s];
 34+ var rules = cursheet.cssRules? cursheet.cssRules: cursheet.rules // Yay IE
 35+
 36+ for (r = 0; r < rules.length; r++){
 37+ if(rules[r].selectorText.toLowerCase()==".unselected"){ //find ".unselected" rule
 38+ cursheet.deleteRule?cursheet.deleteRule(r):cursheet.removeRule(r); // Yay IE
 39+ break outer;
 40+ }
 41+ }
 42+}
 43+
3044 /* follow a # anchor to a tab OR a heading */
3145 var curHash = window.location.hash;
3246 if ( curHash.indexOf( "#tab=" ) == 0 ) {
Index: trunk/extensions/HeaderTabs/HeaderTabs_body.jq.php
@@ -229,25 +229,27 @@
230230 if ( $i == 0 ) {
231231 $tabhtml .= ' class="selected" ';
232232 } else { // hide selector of all but first tab
233 - $tabhtml .= ' style="display:none"';
 233+ $tabhtml .= ' class="unselected"';
234234 }
235235 $tabhtml .= '><a href="#' . $tab['tabid'] . '">'.$tab['title'] . "</a></li>\n";
236236 }
237237 $tabhtml .= '</ul>';
238238
239239 foreach ( $tabs as $i => $tab ) {
240 - $tabhtml .= '<div id="' . $tab['tabid'] . '" class="section-'.$tab['section'].'"';
 240+ $tabhtml .= '<div id="' . $tab['tabid'] . '" class="section-'.$tab['section'];
241241
242242 if ( $i != 0 ) { // hide content of all but first tab
243 - $tabhtml .= ' style="display:none"';
 243+ $tabhtml .= ' unselected';
244244 }
245245
246 - $tabhtml .= '><p>' . $tab['tabcontent'] . '</p></div>';
 246+ $tabhtml .= '"><p>' . $tab['tabcontent'] . '</p></div>';
247247 }
248248 $tabhtml .= '</div>';
249249
250250 $text = $above . $tabhtml . $below;
251251
 252+ $parser->getOutput()->addHeadItem(HTML::inlineScript( 'document.styleSheets[0].insertRule?document.styleSheets[0].insertRule(".unselected {display:none;}", 0):document.styleSheets[0].addRule(".unselected", "display:none");' ), true );
 253+
252254 return true;
253255 }
254256

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106871reduce page jumping during loadingfoxtrott21:39, 20 December 2011

Status & tagging log