Index: trunk/extensions/MobileFrontend/javascripts/beta_application.js |
— | — | @@ -1,59 +1,5 @@ |
2 | | -var search = document.getElementById( 'search' ); |
3 | | -var clearSearch = document.getElementById( 'clearsearch' ); |
4 | | -var results = document.getElementById( 'results' ); |
5 | | -var languageSelection = document.getElementById( 'languageselection' ); |
| 2 | +MobileFrontend = function() { |
6 | 3 | |
7 | | -var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
8 | | - |
9 | | -if ( !zeroRatedBanner ) { |
10 | | - var zeroRatedBanner = document.getElementById( 'zero-rated-banner-red' ); |
11 | | -} |
12 | | - |
13 | | -function initClearSearchLink() { |
14 | | - clearSearch.setAttribute( 'title','Clear' ); |
15 | | - clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
16 | | - search.addEventListener( 'keyup', handleClearSearchLink, false ); |
17 | | - search.addEventListener( 'keydown', handleDefaultText, false ); |
18 | | -} |
19 | | - |
20 | | -function handleDefaultText() { |
21 | | - var pE = document.getElementById( 'placeholder' ); |
22 | | - if ( pE ) { |
23 | | - pE.style.display = 'none'; |
24 | | - } |
25 | | -} |
26 | | - |
27 | | -function handleClearSearchLink() { |
28 | | - if ( clearSearch ) { |
29 | | - if ( search.value.length > 0 ) { |
30 | | - clearSearch.style.display = 'block'; |
31 | | - } else { |
32 | | - clearSearch.style.display = 'none'; |
33 | | - } |
34 | | - } |
35 | | -} |
36 | | - |
37 | | -function clearSearchBox( event ) { |
38 | | - search.value = ''; |
39 | | - clearSearch.style.display = 'none'; |
40 | | - if ( event ) { |
41 | | - event.preventDefault(); |
42 | | - } |
43 | | -} |
44 | | - |
45 | | -function logoClick() { |
46 | | - var n = document.getElementById( 'nav' ).style; |
47 | | - n.display = n.display == 'block' ? 'none' : 'block'; |
48 | | - if (n.display == 'block') { |
49 | | - if ( languageSelection ) { |
50 | | - if ( languageSelection.offsetWidth > 175 ) { |
51 | | - var newWidth = languageSelection.offsetWidth + 30; |
52 | | - n.width = newWidth + 'px'; |
53 | | - } |
54 | | - } |
55 | | - } |
56 | | -}; |
57 | | - |
58 | 4 | function init() { |
59 | 5 | document.body.className = "jsEnabled"; |
60 | 6 | var sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
— | — | @@ -65,7 +11,24 @@ |
66 | 12 | } |
67 | 13 | }, false ); |
68 | 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' ); |
69 | 19 | |
| 20 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner' ); |
| 21 | + |
| 22 | + if ( !zeroRatedBanner ) { |
| 23 | + var zeroRatedBanner = document.getElementById( 'zero-rated-banner-red' ); |
| 24 | + } |
| 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 | + } |
| 32 | + |
70 | 33 | function navigateToLanguageSelection() { |
71 | 34 | var url; |
72 | 35 | if ( languageSelection ) { |
— | — | @@ -77,6 +40,43 @@ |
78 | 41 | } |
79 | 42 | document.getElementById( 'languageselection' ).addEventListener( 'change', navigateToLanguageSelection ); |
80 | 43 | |
| 44 | + function handleDefaultText() { |
| 45 | + var pE = document.getElementById( 'placeholder' ); |
| 46 | + if ( pE ) { |
| 47 | + pE.style.display = 'none'; |
| 48 | + } |
| 49 | + } |
| 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'; |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + |
| 61 | + function clearSearchBox( event ) { |
| 62 | + search.value = ''; |
| 63 | + clearSearch.style.display = 'none'; |
| 64 | + if ( event ) { |
| 65 | + event.preventDefault(); |
| 66 | + } |
| 67 | + } |
| 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'; |
| 77 | + } |
| 78 | + } |
| 79 | + } |
| 80 | + }; |
81 | 81 | initClearSearchLink(); |
82 | 82 | search.onpaste = function() { |
83 | 83 | handleDefaultText(); |
— | — | @@ -176,3 +176,15 @@ |
177 | 177 | writeCookie( name, '', -1 ); |
178 | 178 | return null; |
179 | 179 | } |
| 180 | + |
| 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 | +}(); |
| 191 | + |
Index: trunk/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -1,51 +1,5 @@ |
2 | | -var search = document.getElementById( 'search' ); |
3 | | -var clearSearch = document.getElementById( 'clearsearch' ); |
4 | | -var results = document.getElementById( 'results' ); |
5 | | -var languageSelection = document.getElementById( 'languageselection' ); |
| 2 | +MobileFrontend = function() { |
6 | 3 | |
7 | | -function initClearSearchLink() { |
8 | | - clearSearch.setAttribute( 'title','Clear' ); |
9 | | - clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
10 | | - search.addEventListener( 'keyup', handleClearSearchLink, false ); |
11 | | -} |
12 | | - |
13 | | -function handleClearSearchLink() { |
14 | | - if ( clearSearch ) { |
15 | | - if ( search.value.length > 0 ) { |
16 | | - clearSearch.style.display = 'block'; |
17 | | - } else { |
18 | | - clearSearch.style.display = 'none'; |
19 | | - if ( results ) { |
20 | | - results.style.display = 'none'; |
21 | | - } |
22 | | - } |
23 | | - } |
24 | | -} |
25 | | - |
26 | | -function clearSearchBox( event ) { |
27 | | - search.value = ''; |
28 | | - clearSearch.style.display = 'none'; |
29 | | - if ( results ) { |
30 | | - results.style.display = 'none'; |
31 | | - } |
32 | | - if ( event ) { |
33 | | - event.preventDefault(); |
34 | | - } |
35 | | -} |
36 | | - |
37 | | -function logoClick() { |
38 | | - var n = document.getElementById( 'nav' ).style; |
39 | | - n.display = n.display == 'block' ? 'none' : 'block'; |
40 | | - if (n.display == 'block') { |
41 | | - if ( languageSelection ) { |
42 | | - if ( languageSelection.offsetWidth > 175 ) { |
43 | | - var newWidth = languageSelection.offsetWidth + 30; |
44 | | - n.width = newWidth + 'px'; |
45 | | - } |
46 | | - } |
47 | | - } |
48 | | -}; |
49 | | - |
50 | 4 | function init() { |
51 | 5 | document.body.className = "jsEnabled"; |
52 | 6 | var sectionHeadings = document.getElementsByClassName( 'section_heading' ); |
— | — | @@ -57,7 +11,17 @@ |
58 | 12 | } |
59 | 13 | }, false ); |
60 | 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' ); |
61 | 19 | |
| 20 | + function initClearSearchLink() { |
| 21 | + clearSearch.setAttribute( 'title','Clear' ); |
| 22 | + clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
| 23 | + search.addEventListener( 'keyup', handleClearSearchLink, false ); |
| 24 | + } |
| 25 | + |
62 | 26 | function navigateToLanguageSelection() { |
63 | 27 | var url; |
64 | 28 | if ( languageSelection ) { |
— | — | @@ -69,6 +33,42 @@ |
70 | 34 | } |
71 | 35 | document.getElementById( 'languageselection' ).addEventListener( 'change', navigateToLanguageSelection ); |
72 | 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'; |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 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 | + } |
| 59 | + } |
| 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'; |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + }; |
73 | 73 | initClearSearchLink(); |
74 | 74 | document.getElementById( 'logo' ).addEventListener( 'click', logoClick ); |
75 | 75 | var dismissNotification = document.getElementById( 'dismiss-notification' ); |
— | — | @@ -165,3 +165,15 @@ |
166 | 166 | writeCookie( name, '', -1 ); |
167 | 167 | return null; |
168 | 168 | } |
| 169 | + |
| 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 | +}(); |
| 180 | + |