http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97871
Revision: 97871
Author: preilly
Date: 2011-09-23 00:24:48 +0000 (Fri, 23 Sep 2011)
Log Message:
-----------
mft 96528 to 95268
Modified Paths:
--------------
branches/wmf/1.17wmf1/extensions/MobileFrontend/javascripts/application.js
Modified:
branches/wmf/1.17wmf1/extensions/MobileFrontend/javascripts/application.js
===================================================================
--- branches/wmf/1.17wmf1/extensions/MobileFrontend/javascripts/application.js
2011-09-23 00:16:28 UTC (rev 97870)
+++ branches/wmf/1.17wmf1/extensions/MobileFrontend/javascripts/application.js
2011-09-23 00:24:48 UTC (rev 97871)
@@ -1,5 +1,34 @@
-// 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
+var search = document.getElementById( 'search' );
+var clearSearch = document.getElementById( 'clearsearch' );
+
+initClearSearchLink();
+
+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 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;
@@ -35,7 +64,7 @@
window.scrollTo( 0, 1 );
// This is a global. I don't know why.
-decode = document.getElementById( 'searchField' );
+decode = document.getElementById( 'search' );
decode.value = unescape( decode.value );
decode = document.getElementsByTagName( 'title' )[0];
decode.innerHTML = unescape( decode.innerHTML );
@@ -83,4 +112,4 @@
var s = document.getElementById( d[i] + section_id ).style;
s.display = s.display == 'block' ? 'none' : 'block';
}
-}
+}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs