Index: trunk/extensions/MobileFrontend/MobileFormatter.php |
— | — | @@ -339,14 +339,6 @@ |
340 | 340 | '↑' . $backToTop ) . |
341 | 341 | Html::closeElement( 'div' ); |
342 | 342 | // generate the HTML we are going to inject |
343 | | - $buttons = Html::element( 'button', |
344 | | - array( 'class' => 'section_heading show', |
345 | | - 'section_id' => $this->headings ), |
346 | | - $show ) . |
347 | | - Html::element( 'button', |
348 | | - array( 'class' => 'section_heading hide', |
349 | | - 'section_id' => $this->headings ), |
350 | | - $hide ); |
351 | 343 | if ( $this->expandableSections ) { |
352 | 344 | $base .= Html::openElement( 'h2', |
353 | 345 | array( 'class' => 'section_heading', |
— | — | @@ -356,7 +348,7 @@ |
357 | 349 | array( 'class' => 'section_heading', |
358 | 350 | 'id' => 'section_' . $this->headings ) ); |
359 | 351 | } |
360 | | - $base .= $buttons . |
| 352 | + $base .= |
361 | 353 | Html::rawElement( 'span', |
362 | 354 | array( 'id' => $headlineId ), |
363 | 355 | $matches[2] ) . |
Index: trunk/extensions/MobileFrontend/tests/js/fixtures.js |
— | — | @@ -27,8 +27,6 @@ |
28 | 28 | ' <div id="results">search results here</div>', |
29 | 29 | ' <div id="content">', |
30 | 30 | ' <h2 class="section_heading" id="section_1">', |
31 | | - ' <button class="section_heading show" section_id="1">Show</button>', |
32 | | - ' <button class="section_heading hide" section_id="1" style="display:none">Hide</button>', |
33 | 31 | ' <span id="First_Section">First Section</span>', |
34 | 32 | ' </h2>', |
35 | 33 | ' <div class="content_block" id="content_1" style="display:none">', |
— | — | @@ -41,8 +39,6 @@ |
42 | 40 | ' <a href="#section_1" class="back_to_top">↑Jump back a section</a>', |
43 | 41 | ' </div>', |
44 | 42 | ' <h2 class="section_heading" id="section_2">', |
45 | | - ' <button class="section_heading show" section_id="2">Show</button>', |
46 | | - ' <button class="section_heading hide" section_id="2" style="display:none">Hide</button>', |
47 | 43 | ' <span id="Second_Section">Second Section</span>', |
48 | 44 | ' </h2>', |
49 | 45 | ' <div class="content_block" id="content_2" style="display:none"><p>Text with a <a href="#First_Section">section 1</a> link! and to <a href="#First_Section_2">section 1.2</a></p></div>', |
Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js |
— | — | @@ -7,7 +7,7 @@ |
8 | 8 | MobileFrontend = (function() { |
9 | 9 | |
10 | 10 | function init() { |
11 | | - var i, search, clearSearch, results, languageSelection, a, |
| 11 | + var i, search, clearSearch, results, languageSelection, a, heading, |
12 | 12 | sectionHeadings = document.getElementsByClassName( 'section_heading' ), |
13 | 13 | dismissNotification, cookieNameZeroVisibility, zeroRatedBanner, zeroRatedBannerVisibility; |
14 | 14 | utilities( document.body ).addClass( 'jsEnabled' ); |
— | — | @@ -17,8 +17,20 @@ |
18 | 18 | wm_toggle_section( sectionNumber ); |
19 | 19 | } |
20 | 20 | } |
| 21 | + function createButton( visible ) { |
| 22 | + var btn, label; |
| 23 | + btn = document.createElement( 'button' ); |
| 24 | + label = document.createTextNode( visible ? 'Show' : 'Hide' ); |
| 25 | + btn.className = visible ? 'show' : 'hide'; |
| 26 | + btn.appendChild( label ); |
| 27 | + btn.style.display = visible ? 'inline-block' : 'none'; |
| 28 | + return btn; |
| 29 | + } |
21 | 30 | for( i = 0; i < sectionHeadings.length; i++ ) { |
22 | | - utilities( sectionHeadings[i] ).bind( 'click', openSectionHandler, false ); |
| 31 | + heading = sectionHeadings[i]; |
| 32 | + heading.insertBefore( createButton( true ), heading.firstChild ); |
| 33 | + heading.insertBefore( createButton( false ), heading.firstChild ); |
| 34 | + utilities( heading ).bind( 'click', openSectionHandler, false ); |
23 | 35 | } |
24 | 36 | search = document.getElementById( 'search' ); |
25 | 37 | clearSearch = document.getElementById( 'clearsearch' ); |
Index: trunk/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | MobileFrontend = (function() { |
5 | 5 | |
6 | 6 | function init() { |
7 | | - var i, search, clearSearch, results, languageSelection, a, |
| 7 | + var i, search, clearSearch, results, languageSelection, a, heading, |
8 | 8 | sectionHeadings = document.getElementsByClassName( 'section_heading' ), |
9 | 9 | dismissNotification, cookieNameZeroVisibility, zeroRatedBanner, zeroRatedBannerVisibility; |
10 | 10 | utilities( document.body ).addClass( 'jsEnabled' ); |
— | — | @@ -13,8 +13,20 @@ |
14 | 14 | wm_toggle_section( sectionNumber ); |
15 | 15 | } |
16 | 16 | } |
| 17 | + function createButton( visible ) { |
| 18 | + var btn, label; |
| 19 | + btn = document.createElement( 'button' ); |
| 20 | + label = document.createTextNode( visible ? 'Show' : 'Hide' ); |
| 21 | + btn.className = visible ? 'show' : 'hide'; |
| 22 | + btn.appendChild( label ); |
| 23 | + btn.style.display = visible ? 'inline-block' : 'none'; |
| 24 | + return btn; |
| 25 | + } |
17 | 26 | for( i = 0; i < sectionHeadings.length; i++ ) { |
18 | | - utilities( sectionHeadings[i] ).bind( 'click', openSectionHandler, false ); |
| 27 | + heading = sectionHeadings[i]; |
| 28 | + heading.insertBefore( createButton( true ), heading.firstChild ); |
| 29 | + heading.insertBefore( createButton( false ), heading.firstChild ); |
| 30 | + utilities( heading ).bind( 'click', openSectionHandler, false ); |
19 | 31 | } |
20 | 32 | search = document.getElementById( 'search' ); |
21 | 33 | clearSearch = document.getElementById( 'clearsearch' ); |