Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js |
— | — | @@ -1,190 +1,190 @@ |
2 | 2 | MobileFrontend = function() { |
3 | 3 | |
4 | | -function init() { |
5 | | - document.body.className = "jsEnabled"; |
6 | | - var sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
7 | | - for( var i = 0; i < sectionHeadings.length; i++ ) { |
8 | | - sectionHeadings[i].addEventListener( 'click', function() { |
9 | | - var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
10 | | - if(sectionNumber > -1) { |
11 | | - wm_toggle_section( sectionNumber ); |
12 | | - } |
13 | | - }, false ); |
14 | | - } |
15 | | - var search = document.getElementById( 'search' ); |
16 | | - var clearSearch = document.getElementById( 'clearsearch' ); |
17 | | - var results = document.getElementById( 'results' ); |
18 | | - var languageSelection = document.getElementById( 'languageselection' ); |
| 4 | + function init() { |
| 5 | + document.body.className = "jsEnabled"; |
| 6 | + var sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
| 7 | + for( var i = 0; i < sectionHeadings.length; i++ ) { |
| 8 | + sectionHeadings[i].addEventListener( 'click', function() { |
| 9 | + var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
| 10 | + if(sectionNumber > -1) { |
| 11 | + wm_toggle_section( sectionNumber ); |
| 12 | + } |
| 13 | + }, false ); |
| 14 | + } |
| 15 | + var search = document.getElementById( 'search' ); |
| 16 | + var clearSearch = document.getElementById( 'clearsearch' ); |
| 17 | + var results = document.getElementById( 'results' ); |
| 18 | + var languageSelection = document.getElementById( 'languageselection' ); |
19 | 19 | |
20 | | - var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
| 20 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
21 | 21 | |
22 | | - if ( !zeroRatedBanner ) { |
23 | | - var zeroRatedBanner = document.getElementById( 'zero-rated-banner-red' ); |
24 | | - } |
| 22 | + if ( !zeroRatedBanner ) { |
| 23 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner-red' ); |
| 24 | + } |
25 | 25 | |
26 | | - function initClearSearchLink() { |
27 | | - clearSearch.setAttribute( 'title','Clear' ); |
28 | | - clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
29 | | - search.addEventListener( 'keyup', handleClearSearchLink, false ); |
30 | | - search.addEventListener( 'keydown', handleDefaultText, false ); |
31 | | - } |
| 26 | + function initClearSearchLink() { |
| 27 | + clearSearch.setAttribute( 'title','Clear' ); |
| 28 | + clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
| 29 | + search.addEventListener( 'keyup', handleClearSearchLink, false ); |
| 30 | + search.addEventListener( 'keydown', handleDefaultText, false ); |
| 31 | + } |
32 | 32 | |
33 | | - function navigateToLanguageSelection() { |
34 | | - var url; |
35 | | - if ( languageSelection ) { |
36 | | - url = languageSelection.options[languageSelection.selectedIndex].value; |
37 | | - if ( url ) { |
38 | | - location.href = url; |
| 33 | + function navigateToLanguageSelection() { |
| 34 | + var url; |
| 35 | + if ( languageSelection ) { |
| 36 | + url = languageSelection.options[languageSelection.selectedIndex].value; |
| 37 | + if ( url ) { |
| 38 | + location.href = url; |
| 39 | + } |
39 | 40 | } |
40 | 41 | } |
41 | | - } |
42 | | - document.getElementById( 'languageselection' ).addEventListener( 'change', navigateToLanguageSelection ); |
| 42 | + document.getElementById( 'languageselection' ).addEventListener( 'change', navigateToLanguageSelection ); |
43 | 43 | |
44 | | - function handleDefaultText() { |
45 | | - var pE = document.getElementById( 'placeholder' ); |
46 | | - if ( pE ) { |
47 | | - pE.style.display = 'none'; |
| 44 | + function handleDefaultText() { |
| 45 | + var pE = document.getElementById( 'placeholder' ); |
| 46 | + if ( pE ) { |
| 47 | + pE.style.display = 'none'; |
| 48 | + } |
48 | 49 | } |
49 | | - } |
50 | 50 | |
51 | | - function handleClearSearchLink() { |
52 | | - if ( clearSearch ) { |
53 | | - if ( search.value.length > 0 ) { |
54 | | - clearSearch.style.display = 'block'; |
55 | | - } else { |
56 | | - clearSearch.style.display = 'none'; |
| 51 | + function handleClearSearchLink() { |
| 52 | + if ( clearSearch ) { |
| 53 | + if ( search.value.length > 0 ) { |
| 54 | + clearSearch.style.display = 'block'; |
| 55 | + } else { |
| 56 | + clearSearch.style.display = 'none'; |
| 57 | + } |
57 | 58 | } |
58 | 59 | } |
59 | | - } |
60 | 60 | |
61 | | - function clearSearchBox( event ) { |
62 | | - search.value = ''; |
63 | | - clearSearch.style.display = 'none'; |
64 | | - if ( event ) { |
65 | | - event.preventDefault(); |
| 61 | + function clearSearchBox( event ) { |
| 62 | + search.value = ''; |
| 63 | + clearSearch.style.display = 'none'; |
| 64 | + if ( event ) { |
| 65 | + event.preventDefault(); |
| 66 | + } |
66 | 67 | } |
67 | | - } |
68 | 68 | |
69 | | - function logoClick() { |
70 | | - var n = document.getElementById( 'nav' ).style; |
71 | | - n.display = n.display == 'block' ? 'none' : 'block'; |
72 | | - if (n.display == 'block') { |
73 | | - if ( languageSelection ) { |
74 | | - if ( languageSelection.offsetWidth > 175 ) { |
75 | | - var newWidth = languageSelection.offsetWidth + 30; |
76 | | - n.width = newWidth + 'px'; |
| 69 | + function logoClick() { |
| 70 | + var n = document.getElementById( 'nav' ).style; |
| 71 | + n.display = n.display == 'block' ? 'none' : 'block'; |
| 72 | + if (n.display == 'block') { |
| 73 | + if ( languageSelection ) { |
| 74 | + if ( languageSelection.offsetWidth > 175 ) { |
| 75 | + var newWidth = languageSelection.offsetWidth + 30; |
| 76 | + n.width = newWidth + 'px'; |
| 77 | + } |
77 | 78 | } |
78 | 79 | } |
79 | | - } |
80 | | - }; |
81 | | - initClearSearchLink(); |
82 | | - search.onpaste = function() { |
83 | | - handleDefaultText(); |
84 | | - }; |
85 | | - document.getElementById( 'logo' ).addEventListener( 'click', logoClick ); |
86 | | - var dismissNotification = document.getElementById( 'dismiss-notification' ); |
| 80 | + }; |
| 81 | + initClearSearchLink(); |
| 82 | + search.onpaste = function() { |
| 83 | + handleDefaultText(); |
| 84 | + }; |
| 85 | + document.getElementById( 'logo' ).addEventListener( 'click', logoClick ); |
| 86 | + var dismissNotification = document.getElementById( 'dismiss-notification' ); |
87 | 87 | |
88 | | - if ( dismissNotification ) { |
89 | | - var cookieNameZeroVisibility = 'zeroRatedBannerVisibility'; |
90 | | - var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
91 | | - var zeroRatedBannerVisibility = readCookie( cookieNameZeroVisibility ); |
| 88 | + if ( dismissNotification ) { |
| 89 | + var cookieNameZeroVisibility = 'zeroRatedBannerVisibility'; |
| 90 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
| 91 | + var zeroRatedBannerVisibility = readCookie( cookieNameZeroVisibility ); |
92 | 92 | |
93 | | - if ( zeroRatedBannerVisibility === 'off' ) { |
94 | | - zeroRatedBanner.style.display = 'none'; |
| 93 | + if ( zeroRatedBannerVisibility === 'off' ) { |
| 94 | + zeroRatedBanner.style.display = 'none'; |
| 95 | + } |
| 96 | + |
| 97 | + dismissNotification.onclick = function() { |
| 98 | + if ( zeroRatedBanner ) { |
| 99 | + zeroRatedBanner.style.display = 'none'; |
| 100 | + writeCookie( cookieNameZeroVisibility, 'off', 1 ); |
| 101 | + } |
| 102 | + }; |
95 | 103 | } |
| 104 | + if ( document.location.hash.indexOf( '#' ) == 0 ) { |
| 105 | + wm_reveal_for_hash( document.location.hash ); |
| 106 | + } |
96 | 107 | |
97 | | - dismissNotification.onclick = function() { |
98 | | - if ( zeroRatedBanner ) { |
99 | | - zeroRatedBanner.style.display = 'none'; |
100 | | - writeCookie( cookieNameZeroVisibility, 'off', 1 ); |
| 108 | + for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
| 109 | + a[i].onclick = function() { |
| 110 | + if ( this.hash.indexOf( '#' ) == 0 ) { |
| 111 | + wm_reveal_for_hash( this.hash ); |
| 112 | + } |
101 | 113 | } |
102 | | - }; |
| 114 | + } |
| 115 | + |
| 116 | + // Try to scroll and hide URL bar |
| 117 | + window.scrollTo( 0, 1 ); |
103 | 118 | } |
104 | | - if ( document.location.hash.indexOf( '#' ) == 0 ) { |
105 | | - wm_reveal_for_hash( document.location.hash ); |
106 | | - } |
| 119 | + init(); |
107 | 120 | |
108 | | - for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
109 | | - a[i].onclick = function() { |
110 | | - if ( this.hash.indexOf( '#' ) == 0 ) { |
111 | | - wm_reveal_for_hash( this.hash ); |
| 121 | + function wm_reveal_for_hash( hash ) { |
| 122 | + var targetel = document.getElementById( hash.substr(1) ); |
| 123 | + if ( targetel ) { |
| 124 | + for (var p = targetel.parentNode; p && p.className != 'content_block' && p.className != 'section_heading'; ) { |
| 125 | + p = p.parentNode; |
112 | 126 | } |
| 127 | + if ( p && p.style.display != 'block' ) { |
| 128 | + var section_idx = parseInt( p.id.split( '_' )[1] ); |
| 129 | + wm_toggle_section( section_idx ); |
| 130 | + } |
113 | 131 | } |
114 | 132 | } |
115 | 133 | |
116 | | - // Try to scroll and hide URL bar |
117 | | - window.scrollTo( 0, 1 ); |
118 | | -} |
119 | | -init(); |
120 | | - |
121 | | -function wm_reveal_for_hash( hash ) { |
122 | | - var targetel = document.getElementById( hash.substr(1) ); |
123 | | - if ( targetel ) { |
124 | | - for (var p = targetel.parentNode; p && p.className != 'content_block' && p.className != 'section_heading'; ) { |
125 | | - p = p.parentNode; |
| 134 | + function wm_toggle_section( section_id ) { |
| 135 | + var b = document.getElementById( 'section_' + section_id ), |
| 136 | + bb = b.getElementsByTagName( 'button' ); |
| 137 | + for ( var i = 0; i <= 1; i++ ) { |
| 138 | + var s = bb[i].style; |
| 139 | + s.display = s.display == 'none' || ( i && !s.display ) ? 'inline-block' : 'none'; |
126 | 140 | } |
127 | | - if ( p && p.style.display != 'block' ) { |
128 | | - var section_idx = parseInt( p.id.split( '_' )[1] ); |
129 | | - wm_toggle_section( section_idx ); |
| 141 | + for ( var i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
| 142 | + var e = document.getElementById( d[i] + section_id ); |
| 143 | + |
| 144 | + if ( e ) { |
| 145 | + e.style.display = e.style.display == 'block' ? 'none' : 'block'; |
| 146 | + } |
130 | 147 | } |
131 | 148 | } |
132 | | -} |
133 | 149 | |
134 | | -function wm_toggle_section( section_id ) { |
135 | | - var b = document.getElementById( 'section_' + section_id ), |
136 | | - bb = b.getElementsByTagName( 'button' ); |
137 | | - for ( var i = 0; i <= 1; i++ ) { |
138 | | - var s = bb[i].style; |
139 | | - s.display = s.display == 'none' || ( i && !s.display ) ? 'inline-block' : 'none'; |
140 | | - } |
141 | | - for ( var i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
142 | | - var e = document.getElementById( d[i] + section_id ); |
143 | | - |
144 | | - if ( e ) { |
145 | | - e.style.display = e.style.display == 'block' ? 'none' : 'block'; |
| 150 | + function writeCookie( name, value, days ) { |
| 151 | + if ( days ) { |
| 152 | + var date = new Date(); |
| 153 | + date.setTime( date.getTime() + ( days * 24 * 60 * 60 *1000 ) ); |
| 154 | + var expires = '; expires=' + date.toGMTString(); |
| 155 | + } else { |
| 156 | + var expires = ''; |
146 | 157 | } |
| 158 | + document.cookie = name + '=' + value + expires + '; path=/'; |
147 | 159 | } |
148 | | -} |
149 | 160 | |
150 | | -function writeCookie( name, value, days ) { |
151 | | - if ( days ) { |
152 | | - var date = new Date(); |
153 | | - date.setTime( date.getTime() + ( days * 24 * 60 * 60 *1000 ) ); |
154 | | - var expires = '; expires=' + date.toGMTString(); |
155 | | - } else { |
156 | | - var expires = ''; |
| 161 | + function readCookie( name ) { |
| 162 | + var nameVA = name + '='; |
| 163 | + var ca = document.cookie.split( ';' ); |
| 164 | + for( var i=0; i < ca.length; i++ ) { |
| 165 | + var c = ca[i]; |
| 166 | + while ( c.charAt(0) === ' ' ) { |
| 167 | + c = c.substring( 1, c.length ); |
| 168 | + } |
| 169 | + if ( c.indexOf( nameVA ) == 0 ) { |
| 170 | + return c.substring( nameVA.length, c.length ); |
| 171 | + } |
| 172 | + } |
| 173 | + return null; |
157 | 174 | } |
158 | | - document.cookie = name + '=' + value + expires + '; path=/'; |
159 | | -} |
160 | 175 | |
161 | | -function readCookie( name ) { |
162 | | - var nameVA = name + '='; |
163 | | - var ca = document.cookie.split( ';' ); |
164 | | - for( var i=0; i < ca.length; i++ ) { |
165 | | - var c = ca[i]; |
166 | | - while ( c.charAt(0) === ' ' ) { |
167 | | - c = c.substring( 1, c.length ); |
168 | | - } |
169 | | - if ( c.indexOf( nameVA ) == 0 ) { |
170 | | - return c.substring( nameVA.length, c.length ); |
171 | | - } |
| 176 | + function removeCookie( name ) { |
| 177 | + writeCookie( name, '', -1 ); |
| 178 | + return null; |
172 | 179 | } |
173 | | - return null; |
174 | | -} |
175 | 180 | |
176 | | -function removeCookie( name ) { |
177 | | - writeCookie( name, '', -1 ); |
178 | | - return null; |
179 | | -} |
| 181 | + return { |
| 182 | + readCookie: readCookie, |
| 183 | + writeCookie: writeCookie, |
| 184 | + removeCookie: removeCookie, |
| 185 | + wm_reveal_for_hash: wm_reveal_for_hash, |
| 186 | + wm_toggle_section: wm_toggle_section, |
| 187 | + init: init |
| 188 | + }; |
180 | 189 | |
181 | | -return { |
182 | | - readCookie: readCookie, |
183 | | - writeCookie: writeCookie, |
184 | | - removeCookie: removeCookie, |
185 | | - wm_reveal_for_hash: wm_reveal_for_hash, |
186 | | - wm_toggle_section: wm_toggle_section, |
187 | | - init: init |
188 | | -}; |
189 | | - |
190 | 190 | }(); |
191 | 191 | |
Index: trunk/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -1,179 +1,179 @@ |
2 | 2 | MobileFrontend = function() { |
3 | 3 | |
4 | | -function init() { |
5 | | - document.body.className = "jsEnabled"; |
6 | | - var sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
7 | | - for( var i = 0; i < sectionHeadings.length; i++ ) { |
8 | | - sectionHeadings[i].addEventListener( 'click', function() { |
9 | | - var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
10 | | - if(sectionNumber > -1) { |
11 | | - wm_toggle_section( sectionNumber ); |
12 | | - } |
13 | | - }, false ); |
14 | | - } |
15 | | - var search = document.getElementById( 'search' ); |
16 | | - var clearSearch = document.getElementById( 'clearsearch' ); |
17 | | - var results = document.getElementById( 'results' ); |
18 | | - var languageSelection = document.getElementById( 'languageselection' ); |
| 4 | + function init() { |
| 5 | + document.body.className = "jsEnabled"; |
| 6 | + var sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
| 7 | + for( var i = 0; i < sectionHeadings.length; i++ ) { |
| 8 | + sectionHeadings[i].addEventListener( 'click', function() { |
| 9 | + var sectionNumber = this.id ? this.id.split( '_' )[1] : -1; |
| 10 | + if(sectionNumber > -1) { |
| 11 | + wm_toggle_section( sectionNumber ); |
| 12 | + } |
| 13 | + }, false ); |
| 14 | + } |
| 15 | + var search = document.getElementById( 'search' ); |
| 16 | + var clearSearch = document.getElementById( 'clearsearch' ); |
| 17 | + var results = document.getElementById( 'results' ); |
| 18 | + var languageSelection = document.getElementById( 'languageselection' ); |
19 | 19 | |
20 | | - function initClearSearchLink() { |
21 | | - clearSearch.setAttribute( 'title','Clear' ); |
22 | | - clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
23 | | - search.addEventListener( 'keyup', handleClearSearchLink, false ); |
24 | | - } |
| 20 | + function initClearSearchLink() { |
| 21 | + clearSearch.setAttribute( 'title','Clear' ); |
| 22 | + clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
| 23 | + search.addEventListener( 'keyup', handleClearSearchLink, false ); |
| 24 | + } |
25 | 25 | |
26 | | - function navigateToLanguageSelection() { |
27 | | - var url; |
28 | | - if ( languageSelection ) { |
29 | | - url = languageSelection.options[languageSelection.selectedIndex].value; |
30 | | - if ( url ) { |
31 | | - location.href = url; |
| 26 | + function navigateToLanguageSelection() { |
| 27 | + var url; |
| 28 | + if ( languageSelection ) { |
| 29 | + url = languageSelection.options[languageSelection.selectedIndex].value; |
| 30 | + if ( url ) { |
| 31 | + location.href = url; |
| 32 | + } |
32 | 33 | } |
33 | 34 | } |
34 | | - } |
35 | | - document.getElementById( 'languageselection' ).addEventListener( 'change', navigateToLanguageSelection ); |
| 35 | + document.getElementById( 'languageselection' ).addEventListener( 'change', navigateToLanguageSelection ); |
36 | 36 | |
37 | | - function handleClearSearchLink() { |
38 | | - if ( clearSearch ) { |
39 | | - if ( search.value.length > 0 ) { |
40 | | - clearSearch.style.display = 'block'; |
41 | | - } else { |
42 | | - clearSearch.style.display = 'none'; |
43 | | - if ( results ) { |
44 | | - results.style.display = 'none'; |
| 37 | + function handleClearSearchLink() { |
| 38 | + if ( clearSearch ) { |
| 39 | + if ( search.value.length > 0 ) { |
| 40 | + clearSearch.style.display = 'block'; |
| 41 | + } else { |
| 42 | + clearSearch.style.display = 'none'; |
| 43 | + if ( results ) { |
| 44 | + results.style.display = 'none'; |
| 45 | + } |
45 | 46 | } |
46 | 47 | } |
47 | 48 | } |
48 | | - } |
49 | 49 | |
50 | | - function clearSearchBox( event ) { |
51 | | - search.value = ''; |
52 | | - clearSearch.style.display = 'none'; |
53 | | - if ( results ) { |
54 | | - results.style.display = 'none'; |
| 50 | + function clearSearchBox( event ) { |
| 51 | + search.value = ''; |
| 52 | + clearSearch.style.display = 'none'; |
| 53 | + if ( results ) { |
| 54 | + results.style.display = 'none'; |
| 55 | + } |
| 56 | + if ( event ) { |
| 57 | + event.preventDefault(); |
| 58 | + } |
55 | 59 | } |
56 | | - if ( event ) { |
57 | | - event.preventDefault(); |
58 | | - } |
59 | | - } |
60 | 60 | |
61 | | - function logoClick() { |
62 | | - var n = document.getElementById( 'nav' ).style; |
63 | | - n.display = n.display == 'block' ? 'none' : 'block'; |
64 | | - if (n.display == 'block') { |
65 | | - if ( languageSelection ) { |
66 | | - if ( languageSelection.offsetWidth > 175 ) { |
67 | | - var newWidth = languageSelection.offsetWidth + 30; |
68 | | - n.width = newWidth + 'px'; |
| 61 | + function logoClick() { |
| 62 | + var n = document.getElementById( 'nav' ).style; |
| 63 | + n.display = n.display == 'block' ? 'none' : 'block'; |
| 64 | + if (n.display == 'block') { |
| 65 | + if ( languageSelection ) { |
| 66 | + if ( languageSelection.offsetWidth > 175 ) { |
| 67 | + var newWidth = languageSelection.offsetWidth + 30; |
| 68 | + n.width = newWidth + 'px'; |
| 69 | + } |
69 | 70 | } |
70 | 71 | } |
71 | | - } |
72 | | - }; |
73 | | - initClearSearchLink(); |
74 | | - document.getElementById( 'logo' ).addEventListener( 'click', logoClick ); |
75 | | - var dismissNotification = document.getElementById( 'dismiss-notification' ); |
| 72 | + }; |
| 73 | + initClearSearchLink(); |
| 74 | + document.getElementById( 'logo' ).addEventListener( 'click', logoClick ); |
| 75 | + var dismissNotification = document.getElementById( 'dismiss-notification' ); |
76 | 76 | |
77 | | - if ( dismissNotification ) { |
78 | | - var cookieNameZeroVisibility = 'zeroRatedBannerVisibility'; |
79 | | - var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
80 | | - var zeroRatedBannerVisibility = readCookie( cookieNameZeroVisibility ); |
| 77 | + if ( dismissNotification ) { |
| 78 | + var cookieNameZeroVisibility = 'zeroRatedBannerVisibility'; |
| 79 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
| 80 | + var zeroRatedBannerVisibility = readCookie( cookieNameZeroVisibility ); |
81 | 81 | |
82 | | - if ( zeroRatedBannerVisibility === 'off' ) { |
83 | | - zeroRatedBanner.style.display = 'none'; |
| 82 | + if ( zeroRatedBannerVisibility === 'off' ) { |
| 83 | + zeroRatedBanner.style.display = 'none'; |
| 84 | + } |
| 85 | + |
| 86 | + dismissNotification.onclick = function() { |
| 87 | + if ( zeroRatedBanner ) { |
| 88 | + zeroRatedBanner.style.display = 'none'; |
| 89 | + writeCookie( cookieNameZeroVisibility, 'off', 1 ); |
| 90 | + } |
| 91 | + }; |
84 | 92 | } |
| 93 | + if ( document.location.hash.indexOf( '#' ) == 0 ) { |
| 94 | + wm_reveal_for_hash( document.location.hash ); |
| 95 | + } |
85 | 96 | |
86 | | - dismissNotification.onclick = function() { |
87 | | - if ( zeroRatedBanner ) { |
88 | | - zeroRatedBanner.style.display = 'none'; |
89 | | - writeCookie( cookieNameZeroVisibility, 'off', 1 ); |
| 97 | + for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
| 98 | + a[i].onclick = function() { |
| 99 | + if ( this.hash.indexOf( '#' ) == 0 ) { |
| 100 | + wm_reveal_for_hash( this.hash ); |
| 101 | + } |
90 | 102 | } |
91 | | - }; |
| 103 | + } |
| 104 | + |
| 105 | + // Try to scroll and hide URL bar |
| 106 | + window.scrollTo( 0, 1 ); |
92 | 107 | } |
93 | | - if ( document.location.hash.indexOf( '#' ) == 0 ) { |
94 | | - wm_reveal_for_hash( document.location.hash ); |
95 | | - } |
| 108 | + init(); |
96 | 109 | |
97 | | - for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
98 | | - a[i].onclick = function() { |
99 | | - if ( this.hash.indexOf( '#' ) == 0 ) { |
100 | | - wm_reveal_for_hash( this.hash ); |
| 110 | + function wm_reveal_for_hash( hash ) { |
| 111 | + var targetel = document.getElementById( hash.substr(1) ); |
| 112 | + if ( targetel ) { |
| 113 | + for (var p = targetel.parentNode; p && p.className != 'content_block' && p.className != 'section_heading'; ) { |
| 114 | + p = p.parentNode; |
101 | 115 | } |
| 116 | + if ( p && p.style.display != 'block' ) { |
| 117 | + var section_idx = parseInt( p.id.split( '_' )[1] ); |
| 118 | + wm_toggle_section( section_idx ); |
| 119 | + } |
102 | 120 | } |
103 | 121 | } |
104 | 122 | |
105 | | - // Try to scroll and hide URL bar |
106 | | - window.scrollTo( 0, 1 ); |
107 | | -} |
108 | | -init(); |
109 | | - |
110 | | -function wm_reveal_for_hash( hash ) { |
111 | | - var targetel = document.getElementById( hash.substr(1) ); |
112 | | - if ( targetel ) { |
113 | | - for (var p = targetel.parentNode; p && p.className != 'content_block' && p.className != 'section_heading'; ) { |
114 | | - p = p.parentNode; |
| 123 | + function wm_toggle_section( section_id ) { |
| 124 | + var b = document.getElementById( 'section_' + section_id ), |
| 125 | + bb = b.getElementsByTagName( 'button' ); |
| 126 | + for ( var i = 0; i <= 1; i++ ) { |
| 127 | + var s = bb[i].style; |
| 128 | + s.display = s.display == 'none' || ( i && !s.display ) ? 'inline-block' : 'none'; |
115 | 129 | } |
116 | | - if ( p && p.style.display != 'block' ) { |
117 | | - var section_idx = parseInt( p.id.split( '_' )[1] ); |
118 | | - wm_toggle_section( section_idx ); |
| 130 | + for ( var i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
| 131 | + var e = document.getElementById( d[i] + section_id ); |
| 132 | + |
| 133 | + if ( e ) { |
| 134 | + e.style.display = e.style.display == 'block' ? 'none' : 'block'; |
| 135 | + } |
119 | 136 | } |
120 | 137 | } |
121 | | -} |
122 | 138 | |
123 | | -function wm_toggle_section( section_id ) { |
124 | | - var b = document.getElementById( 'section_' + section_id ), |
125 | | - bb = b.getElementsByTagName( 'button' ); |
126 | | - for ( var i = 0; i <= 1; i++ ) { |
127 | | - var s = bb[i].style; |
128 | | - s.display = s.display == 'none' || ( i && !s.display ) ? 'inline-block' : 'none'; |
129 | | - } |
130 | | - for ( var i = 0, d = ['content_','anchor_']; i<=1; i++ ) { |
131 | | - var e = document.getElementById( d[i] + section_id ); |
132 | | - |
133 | | - if ( e ) { |
134 | | - e.style.display = e.style.display == 'block' ? 'none' : 'block'; |
| 139 | + function writeCookie( name, value, days ) { |
| 140 | + if ( days ) { |
| 141 | + var date = new Date(); |
| 142 | + date.setTime( date.getTime() + ( days * 24 * 60 * 60 *1000 ) ); |
| 143 | + var expires = '; expires=' + date.toGMTString(); |
| 144 | + } else { |
| 145 | + var expires = ''; |
135 | 146 | } |
| 147 | + document.cookie = name + '=' + value + expires + '; path=/'; |
136 | 148 | } |
137 | | -} |
138 | 149 | |
139 | | -function writeCookie( name, value, days ) { |
140 | | - if ( days ) { |
141 | | - var date = new Date(); |
142 | | - date.setTime( date.getTime() + ( days * 24 * 60 * 60 *1000 ) ); |
143 | | - var expires = '; expires=' + date.toGMTString(); |
144 | | - } else { |
145 | | - var expires = ''; |
| 150 | + function readCookie( name ) { |
| 151 | + var nameVA = name + '='; |
| 152 | + var ca = document.cookie.split( ';' ); |
| 153 | + for( var i=0; i < ca.length; i++ ) { |
| 154 | + var c = ca[i]; |
| 155 | + while ( c.charAt(0) === ' ' ) { |
| 156 | + c = c.substring( 1, c.length ); |
| 157 | + } |
| 158 | + if ( c.indexOf( nameVA ) == 0 ) { |
| 159 | + return c.substring( nameVA.length, c.length ); |
| 160 | + } |
| 161 | + } |
| 162 | + return null; |
146 | 163 | } |
147 | | - document.cookie = name + '=' + value + expires + '; path=/'; |
148 | | -} |
149 | 164 | |
150 | | -function readCookie( name ) { |
151 | | - var nameVA = name + '='; |
152 | | - var ca = document.cookie.split( ';' ); |
153 | | - for( var i=0; i < ca.length; i++ ) { |
154 | | - var c = ca[i]; |
155 | | - while ( c.charAt(0) === ' ' ) { |
156 | | - c = c.substring( 1, c.length ); |
157 | | - } |
158 | | - if ( c.indexOf( nameVA ) == 0 ) { |
159 | | - return c.substring( nameVA.length, c.length ); |
160 | | - } |
| 165 | + function removeCookie( name ) { |
| 166 | + writeCookie( name, '', -1 ); |
| 167 | + return null; |
161 | 168 | } |
162 | | - return null; |
163 | | -} |
164 | 169 | |
165 | | -function removeCookie( name ) { |
166 | | - writeCookie( name, '', -1 ); |
167 | | - return null; |
168 | | -} |
| 170 | + return { |
| 171 | + readCookie: readCookie, |
| 172 | + writeCookie: writeCookie, |
| 173 | + removeCookie: removeCookie, |
| 174 | + wm_reveal_for_hash: wm_reveal_for_hash, |
| 175 | + wm_toggle_section: wm_toggle_section, |
| 176 | + init: init |
| 177 | + }; |
169 | 178 | |
170 | | -return { |
171 | | - readCookie: readCookie, |
172 | | - writeCookie: writeCookie, |
173 | | - removeCookie: removeCookie, |
174 | | - wm_reveal_for_hash: wm_reveal_for_hash, |
175 | | - wm_toggle_section: wm_toggle_section, |
176 | | - init: init |
177 | | -}; |
178 | | - |
179 | 179 | }(); |
180 | 180 | |