r113466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113465‎ | r113466 | r113467 >
Date:14:40, 9 March 2012
Author:jdlrobson
Status:ok
Tags:
Comment:
remove placeholder code in favour of placeholder attribute

for browsers that don't support this attribute it would make
more sense to provide a generic solution if this is in fact
needed

see http://www.quirksmode.org/html5/inputs_mobile.html#t13
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js (modified) (history)
  • /trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php (modified) (history)
  • /trunk/extensions/MobileFrontend/templates/SearchTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.js
@@ -40,7 +40,7 @@
4141 resetViewPort();
4242
4343 search.onfocus = function() {
44 - var pE, pT, pTT, rrd, rrdD,
 44+ var rrd, rrdD,
4545 removeResultsEl;
4646 sb = document.getElementById( 'searchbox' );
4747 sq = document.getElementById( 'sq' );
@@ -51,23 +51,6 @@
5252 if ( !focused ) {
5353 MobileFrontend.utils( document.body ).addClass( 'full-screen-search' );
5454
55 - pE = document.getElementById( 'placeholder' );
56 - if ( !pE ) {
57 - pT = document.createElement( 'span' );
58 - pTT = document.createTextNode(placeholder);
59 - pT.setAttribute( 'id', 'placeholder' );
60 - pT.appendChild(pTT);
61 - sb.insertBefore( pT, sb.firstChild );
62 - }
63 - pE = document.getElementById( 'placeholder' );
64 - if ( pE ) {
65 - pE.style.display = 'block';
66 - }
67 -
68 - if ( pE && search.value !== '' ) {
69 - pE.style.display = 'none';
70 - }
71 -
7255 removeResultsEl = document.getElementById( 'remove-results' );
7356 if ( !removeResultsEl ) {
7457 rrd = document.createElement( 'a' );
@@ -244,13 +227,6 @@
245228 }
246229 }
247230
248 - function handleDefaultText() {
249 - var pE = document.getElementById( 'placeholder' );
250 - if ( pE ) {
251 - pE.style.display = 'none';
252 - }
253 - }
254 -
255231 function initClearSearch() {
256232 var clearSearch = document.getElementById( 'clearsearch' ),
257233 search = document.getElementById( 'search' ),
@@ -278,7 +254,6 @@
279255 }
280256 u( clearSearch ).bind( 'mousedown', clearSearchBox );
281257 u( search ).bind( 'keyup', handleClearSearchLink );
282 - u( search ).bind( 'keydown', handleDefaultText );
283258 u( search ).bind( 'click', onFocusHandler );
284259 }
285260
@@ -288,7 +263,6 @@
289264 document.body.onmousedown = whichElement;
290265 document.body.ontouchstart = whichElement;
291266 results.ontouchstart = whichElement;
292 - search.onpaste = handleDefaultText;
293267 }
294268 init();
295269 initClearSearch();
Index: trunk/extensions/MobileFrontend/templates/ApplicationTemplate.php
@@ -61,7 +61,6 @@
6262 //<![CDATA[
6363 var title = "{$this->data['htmlTitle']}";
6464 var scriptPath = "{$this->data['wgScriptPath']}";
65 - var placeholder = "{$this->data['placeholder']}";
6665 var showText = "{$buttonShowText}";
6766 var hideText = "{$buttonHideText}";
6867 //]]>
Index: trunk/extensions/MobileFrontend/templates/SearchTemplate.php
@@ -14,6 +14,8 @@
1515 $homeButton = $this->data['messages']['mobile-frontend-home-button'];
1616 $randomButton = $this->data['messages']['mobile-frontend-random-button'];
1717 $clearText = htmlentities( $this->data['messages']['mobile-frontend-clear-search'], ENT_QUOTES );
 18+ $searchValue = $this->data['messages']['mobile-frontend-search-submit'];
 19+ $placeholder = htmlentities( $this->data['messages']['mobile-frontend-placeholder'], ENT_QUOTES );
1820
1921 $scriptUrl = wfScript();
2022 $searchBoxDisplayNone = ( $this->data['hideSearchBox'] ) ? ' style="display: none;" ' : '';
@@ -34,7 +36,7 @@
3537 <form action='{$scriptUrl}' class='search_bar' method='get' {$searchBoxDisplayNone}>
3638 <input type="hidden" value="Special:Search" name="title" />
3739 <div id="sq" class="divclearable">
38 - <input type="search" name="search" id="search" size="22" value="{$searchField}" autocorrect="off" autocomplete="off" autocapitalize="off" maxlength="1024" class="search" />
 40+ <input type="search" name="search" id="search" size="22" value="{$searchField}" autocorrect="off" autocomplete="off" autocapitalize="off" maxlength="1024" class="search" placeholder="{$placeholder}" />
3941 <div class="clearlink" id="clearsearch" title="{$clearText}"></div>
4042 </div>
4143 <button id='goButton' class='goButton' type='submit'></button>

Follow-up revisions

RevisionCommit summaryAuthorDate
r114200r113463, r113465, r113466, r113469, r113470, r113471, r113472awjrichards22:16, 19 March 2012

Status & tagging log