Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js |
— | — | @@ -5,10 +5,11 @@ |
6 | 6 | TODO: addEventListener not supported by IE < 9 |
7 | 7 | */ |
8 | 8 | MobileFrontend = (function() { |
| 9 | + var utilities; |
9 | 10 | |
10 | 11 | function init() { |
11 | 12 | var i, search, clearSearch, results, languageSelection, a, heading, |
12 | | - sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
| 13 | + sectionHeadings = utilities( '.section_heading' ); |
13 | 14 | utilities( document.body ).addClass( 'jsEnabled' ); |
14 | 15 | function openSectionHandler() { |
15 | 16 | var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
— | — | @@ -65,7 +66,6 @@ |
66 | 67 | // Try to scroll and hide URL bar |
67 | 68 | window.scrollTo( 0, 1 ); |
68 | 69 | } |
69 | | - init(); |
70 | 70 | |
71 | 71 | function wm_reveal_for_hash( hash ) { |
72 | 72 | var targetel = document.getElementById( hash.substr(1) ), |
— | — | @@ -99,6 +99,12 @@ |
100 | 100 | } |
101 | 101 | |
102 | 102 | function utilities( el ) { |
| 103 | + if( typeof(el) === 'string' ) { |
| 104 | + if( document.querySelectorAll ) { |
| 105 | + return document.querySelectorAll( el ); |
| 106 | + } |
| 107 | + } |
| 108 | + |
103 | 109 | function addClass( name ) { |
104 | 110 | var className = el.className, |
105 | 111 | classNames = className.split( ' ' ); |
— | — | @@ -144,6 +150,7 @@ |
145 | 151 | xmlHttp.send(); |
146 | 152 | }; |
147 | 153 | |
| 154 | + init(); |
148 | 155 | return { |
149 | 156 | wm_reveal_for_hash: wm_reveal_for_hash, |
150 | 157 | wm_toggle_section: wm_toggle_section, |
Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | } |
28 | 28 | function resetViewPort() { |
29 | 29 | if ( navigator.userAgent.match( /iPhone/i ) || navigator.userAgent.match( /iPad/i ) ) { |
30 | | - var viewportmeta = document.querySelector( 'meta[name="viewport"]' ); |
| 30 | + var viewportmeta = utilities( 'meta[name="viewport"]' ); |
31 | 31 | if ( viewportmeta ) { |
32 | 32 | viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0'; |
33 | 33 | u( document.body ).bind( 'gesturestart', function () { |
Index: trunk/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -1,10 +1,11 @@ |
2 | 2 | /*global document, window */ |
3 | 3 | /*jslint sloppy: true, white:true, maxerr: 50, indent: 4, plusplus: true*/ |
4 | 4 | MobileFrontend = (function() { |
| 5 | + var utilities; |
5 | 6 | |
6 | 7 | function init() { |
7 | 8 | var i, results, languageSelection, a, heading, |
8 | | - sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
| 9 | + sectionHeadings = utilities( '.section_heading' ); |
9 | 10 | utilities( document.body ).addClass( 'jsEnabled' ); |
10 | 11 | function openSectionHandler() { |
11 | 12 | var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
— | — | @@ -61,7 +62,6 @@ |
62 | 63 | // Try to scroll and hide URL bar |
63 | 64 | window.scrollTo( 0, 1 ); |
64 | 65 | } |
65 | | - init(); |
66 | 66 | |
67 | 67 | function wm_reveal_for_hash( hash ) { |
68 | 68 | var targetel = document.getElementById( hash.substr(1) ), |
— | — | @@ -94,7 +94,12 @@ |
95 | 95 | } |
96 | 96 | } |
97 | 97 | |
98 | | - function utilities( el ) { |
| 98 | + utilities = function( el ) { |
| 99 | + if( typeof(el) === 'string' ) { |
| 100 | + if( document.querySelectorAll ) { |
| 101 | + return document.querySelectorAll( el ); |
| 102 | + } |
| 103 | + } |
99 | 104 | function addClass( name ) { |
100 | 105 | var className = el.className, |
101 | 106 | classNames = className.split( ' ' ); |
— | — | @@ -140,6 +145,7 @@ |
141 | 146 | xmlHttp.send(); |
142 | 147 | }; |
143 | 148 | |
| 149 | + init(); |
144 | 150 | return { |
145 | 151 | wm_reveal_for_hash: wm_reveal_for_hash, |
146 | 152 | wm_toggle_section: wm_toggle_section, |