Index: trunk/extensions/MobileFrontend/javascripts/application.js |
— | — | @@ -1,79 +1,74 @@ |
2 | | -// Ideally, this would be loaded in the head and activated by a script at the bottom, |
3 | | -// I think, rather than attached to an onload... |
4 | | -window.onload = function() { |
5 | | - |
6 | | - var search = document.getElementById( 'search' ); |
7 | | - var clearSearch = document.getElementById( 'clearsearch' ); |
| 2 | +var search = document.getElementById( 'search' ); |
| 3 | +var clearSearch = document.getElementById( 'clearsearch' ); |
8 | 4 | |
9 | | - initClearSearchLink(); |
| 5 | +initClearSearchLink(); |
10 | 6 | |
11 | | - function initClearSearchLink() { |
12 | | - clearSearch.setAttribute( 'title','Clear' ); |
13 | | - clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
14 | | - search.addEventListener( 'keyup', _handleClearSearchLink, false ); |
15 | | - } |
| 7 | +function initClearSearchLink() { |
| 8 | + clearSearch.setAttribute( 'title','Clear' ); |
| 9 | + clearSearch.addEventListener( 'mousedown', clearSearchBox, true ); |
| 10 | + search.addEventListener( 'keyup', _handleClearSearchLink, false ); |
| 11 | +} |
16 | 12 | |
17 | | - function _handleClearSearchLink() { |
18 | | - if ( clearSearch ) { |
19 | | - if ( search.value.length > 0 ) { |
20 | | - clearSearch.style.display = 'block'; |
21 | | - } else { |
22 | | - clearSearch.style.display = 'none'; |
23 | | - } |
24 | | - } |
| 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 | + } |
25 | 20 | } |
| 21 | +} |
26 | 22 | |
27 | | - function clearSearchBox( event ) { |
28 | | - search.value = ''; |
29 | | - clearSearch.style.display = 'none'; |
30 | | - if ( event ) { |
31 | | - event.preventDefault(); |
32 | | - } |
| 23 | +function clearSearchBox( event ) { |
| 24 | + search.value = ''; |
| 25 | + clearSearch.style.display = 'none'; |
| 26 | + if ( event ) { |
| 27 | + event.preventDefault(); |
33 | 28 | } |
| 29 | +} |
34 | 30 | |
35 | | - // I don't think this makes sense. Loading this here means that this button |
36 | | - // won't function until the page is loaded. It would probably be an |
37 | | - // improvement to just attach an onclick straight into the html. |
38 | | - document.getElementById( 'logo' ).onclick = function() { |
39 | | - var n = document.getElementById( 'nav' ).style; |
40 | | - n.display = n.display == 'block' ? 'none' : 'block'; |
41 | | - }; |
| 31 | +// I don't think this makes sense. Loading this here means that this button |
| 32 | +// won't function until the page is loaded. It would probably be an |
| 33 | +// improvement to just attach an onclick straight into the html. |
| 34 | +document.getElementById( 'logo' ).onclick = function() { |
| 35 | + var n = document.getElementById( 'nav' ).style; |
| 36 | + n.display = n.display == 'block' ? 'none' : 'block'; |
| 37 | +}; |
42 | 38 | |
43 | | - // Also problematic, not working until the page loads... |
44 | | - for( var h = document.getElementsByTagName( 'h2' ), i = 0; i < h.length; i++ ) { |
45 | | - if ( h[i].className == 'section_heading' ) { |
46 | | - h[i].onclick = function() { |
47 | | - var section_idx = parseInt( this.id.replace( /section_(\d+)/, '$1' ) ); |
48 | | - wm_toggle_section( section_idx ); |
49 | | - } |
| 39 | +// Also problematic, not working until the page loads... |
| 40 | +for( var h = document.getElementsByTagName( 'h2' ), i = 0; i < h.length; i++ ) { |
| 41 | + if ( h[i].className == 'section_heading' ) { |
| 42 | + h[i].onclick = function() { |
| 43 | + var section_idx = parseInt( this.id.replace( /section_(\d+)/, '$1' ) ); |
| 44 | + wm_toggle_section( section_idx ); |
50 | 45 | } |
51 | | - }; |
| 46 | + } |
| 47 | +}; |
52 | 48 | |
53 | | - // And this... |
54 | | - for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
55 | | - a[i].onclick = function() { |
56 | | - if ( this.hash.indexOf( '#' ) == 0 ) { |
57 | | - wm_reveal_for_hash( this.hash ); |
58 | | - } |
| 49 | +// And this... |
| 50 | +for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ ) { |
| 51 | + a[i].onclick = function() { |
| 52 | + if ( this.hash.indexOf( '#' ) == 0 ) { |
| 53 | + wm_reveal_for_hash( this.hash ); |
59 | 54 | } |
60 | | - }; |
61 | | - |
62 | | - if ( document.location.hash.indexOf( '#' ) == 0 ) { |
63 | | - wm_reveal_for_hash( document.location.hash ); |
64 | 55 | } |
| 56 | +}; |
65 | 57 | |
66 | | - updateOrientation(); |
| 58 | +if ( document.location.hash.indexOf( '#' ) == 0 ) { |
| 59 | + wm_reveal_for_hash( document.location.hash ); |
| 60 | +} |
67 | 61 | |
68 | | - // Try to scroll and hide URL bar |
69 | | - window.scrollTo( 0, 1 ); |
| 62 | +updateOrientation(); |
70 | 63 | |
71 | | - // This is a global. I don't know why. |
72 | | - decode = document.getElementById( 'search' ); |
73 | | - decode.value = unescape( decode.value ); |
74 | | - decode = document.getElementsByTagName( 'title' )[0]; |
75 | | - decode.innerHTML = unescape( decode.innerHTML ); |
76 | | -}; |
| 64 | +// Try to scroll and hide URL bar |
| 65 | +window.scrollTo( 0, 1 ); |
77 | 66 | |
| 67 | +// This is a global. I don't know why. |
| 68 | +decode = document.getElementById( 'search' ); |
| 69 | +decode.value = unescape( decode.value ); |
| 70 | +decode = document.getElementsByTagName( 'title' )[0]; |
| 71 | +decode.innerHTML = unescape( decode.innerHTML ); |
| 72 | + |
78 | 73 | /** |
79 | 74 | * updateOrientation checks the current orientation, sets the body's class |
80 | 75 | * attribute to portrait, landscapeLeft, or landscapeRight, |
Index: trunk/extensions/MobileFrontend/views/layout/application.html.php |
— | — | @@ -34,7 +34,6 @@ |
35 | 35 | } |
36 | 36 | //]]> |
37 | 37 | </script> |
38 | | - <script type="text/javascript" language="javascript" src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/application.js?version=20110912T172820Z"></script> |
39 | 38 | </head> |
40 | 39 | <body> |
41 | 40 | {$searchWebkitHtml} |
— | — | @@ -43,6 +42,7 @@ |
44 | 43 | {$contentHtml} |
45 | 44 | </div> |
46 | 45 | {$footerHtml} |
| 46 | + <script type="text/javascript" language="javascript" src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/application.js?version=20110919T172820Z"></script> |
47 | 47 | </body> |
48 | 48 | </html> |
49 | 49 | EOT; |