http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97556
Revision: 97556
Author: preilly
Date: 2011-09-19 20:58:29 +0000 (Mon, 19 Sep 2011)
Log Message:
-----------
fix for Bug 30985 - Mobile header expanding and menu do not work until page
loads
Modified Paths:
--------------
trunk/extensions/MobileFrontend/javascripts/application.js
trunk/extensions/MobileFrontend/views/layout/application.html.php
Modified: trunk/extensions/MobileFrontend/javascripts/application.js
===================================================================
--- trunk/extensions/MobileFrontend/javascripts/application.js 2011-09-19
20:54:43 UTC (rev 97555)
+++ trunk/extensions/MobileFrontend/javascripts/application.js 2011-09-19
20:58:29 UTC (rev 97556)
@@ -1,79 +1,74 @@
-// Ideally, this would be loaded in the head and activated by a script at the
bottom,
-// I think, rather than attached to an onload...
-window.onload = function() {
-
- var search = document.getElementById( 'search' );
- var clearSearch = document.getElementById( 'clearsearch' );
+var search = document.getElementById( 'search' );
+var clearSearch = document.getElementById( 'clearsearch' );
- initClearSearchLink();
+initClearSearchLink();
- function initClearSearchLink() {
- clearSearch.setAttribute( 'title','Clear' );
- clearSearch.addEventListener( 'mousedown', clearSearchBox, true );
- search.addEventListener( 'keyup', _handleClearSearchLink, false );
- }
+function initClearSearchLink() {
+ clearSearch.setAttribute( 'title','Clear' );
+ clearSearch.addEventListener( 'mousedown', clearSearchBox, true );
+ search.addEventListener( 'keyup', _handleClearSearchLink, false );
+}
- function _handleClearSearchLink() {
- if ( clearSearch ) {
- if ( search.value.length > 0 ) {
- clearSearch.style.display = 'block';
- } else {
- clearSearch.style.display = 'none';
- }
- }
+function _handleClearSearchLink() {
+ if ( clearSearch ) {
+ if ( search.value.length > 0 ) {
+ clearSearch.style.display = 'block';
+ } else {
+ clearSearch.style.display = 'none';
+ }
}
+}
- function clearSearchBox( event ) {
- search.value = '';
- clearSearch.style.display = 'none';
- if ( event ) {
- event.preventDefault();
- }
+function clearSearchBox( event ) {
+ search.value = '';
+ clearSearch.style.display = 'none';
+ if ( event ) {
+ event.preventDefault();
}
+}
- // I don't think this makes sense. Loading this here means that this
button
- // won't function until the page is loaded. It would probably be an
- // improvement to just attach an onclick straight into the html.
- document.getElementById( 'logo' ).onclick = function() {
- var n = document.getElementById( 'nav' ).style;
- n.display = n.display == 'block' ? 'none' : 'block';
- };
+// I don't think this makes sense. Loading this here means that this button
+// won't function until the page is loaded. It would probably be an
+// improvement to just attach an onclick straight into the html.
+document.getElementById( 'logo' ).onclick = function() {
+ var n = document.getElementById( 'nav' ).style;
+ n.display = n.display == 'block' ? 'none' : 'block';
+};
- // Also problematic, not working until the page loads...
- for( var h = document.getElementsByTagName( 'h2' ), i = 0; i <
h.length; i++ ) {
- if ( h[i].className == 'section_heading' ) {
- h[i].onclick = function() {
- var section_idx = parseInt( this.id.replace(
/section_(\d+)/, '$1' ) );
- wm_toggle_section( section_idx );
- }
+// Also problematic, not working until the page loads...
+for( var h = document.getElementsByTagName( 'h2' ), i = 0; i < h.length; i++ )
{
+ if ( h[i].className == 'section_heading' ) {
+ h[i].onclick = function() {
+ var section_idx = parseInt( this.id.replace(
/section_(\d+)/, '$1' ) );
+ wm_toggle_section( section_idx );
}
- };
+ }
+};
- // And this...
- for ( var a = document.getElementsByTagName( 'a' ), i = 0; i <
a.length; i++ ) {
- a[i].onclick = function() {
- if ( this.hash.indexOf( '#' ) == 0 ) {
- wm_reveal_for_hash( this.hash );
- }
+// And this...
+for ( var a = document.getElementsByTagName( 'a' ), i = 0; i < a.length; i++ )
{
+ a[i].onclick = function() {
+ if ( this.hash.indexOf( '#' ) == 0 ) {
+ wm_reveal_for_hash( this.hash );
}
- };
-
- if ( document.location.hash.indexOf( '#' ) == 0 ) {
- wm_reveal_for_hash( document.location.hash );
}
+};
- updateOrientation();
+if ( document.location.hash.indexOf( '#' ) == 0 ) {
+ wm_reveal_for_hash( document.location.hash );
+}
- // Try to scroll and hide URL bar
- window.scrollTo( 0, 1 );
+updateOrientation();
- // This is a global. I don't know why.
- decode = document.getElementById( 'search' );
- decode.value = unescape( decode.value );
- decode = document.getElementsByTagName( 'title' )[0];
- decode.innerHTML = unescape( decode.innerHTML );
-};
+// Try to scroll and hide URL bar
+window.scrollTo( 0, 1 );
+// This is a global. I don't know why.
+decode = document.getElementById( 'search' );
+decode.value = unescape( decode.value );
+decode = document.getElementsByTagName( 'title' )[0];
+decode.innerHTML = unescape( decode.innerHTML );
+
/**
* updateOrientation checks the current orientation, sets the body's class
* attribute to portrait, landscapeLeft, or landscapeRight,
Modified: trunk/extensions/MobileFrontend/views/layout/application.html.php
===================================================================
--- trunk/extensions/MobileFrontend/views/layout/application.html.php
2011-09-19 20:54:43 UTC (rev 97555)
+++ trunk/extensions/MobileFrontend/views/layout/application.html.php
2011-09-19 20:58:29 UTC (rev 97556)
@@ -34,7 +34,6 @@
}
//]]>
</script>
- <script type="text/javascript" language="javascript"
src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/application.js?version=20110912T172820Z"></script>
</head>
<body>
{$searchWebkitHtml}
@@ -43,6 +42,7 @@
{$contentHtml}
</div>
{$footerHtml}
+ <script type="text/javascript" language="javascript"
src="{$wgExtensionAssetsPath}/MobileFrontend/javascripts/application.js?version=20110919T172820Z"></script>
</body>
</html>
EOT;
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs