r74388 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74387‎ | r74388 | r74389 >
Date:20:42, 6 October 2010
Author:tparscal
Status:ok (Comments)
Tags:
Comment:
* Moved search/IE7 specific CSS rule into search.css with a CSS hack, which is now part of mediawiki.legacy.search, reducing the number of requests for IE7 users by 1
* Added mediawiki.specials.search, which will eventually replace mediawiki.legacy.search
* Removed javascript injections in the body which were focusing the search box on load
* Added emulation for HTML5 autofocus attribute on the search page, this may be useful elsewhere and should be considered for use globally
Modified paths:
  • /trunk/phase3/includes/specials/SpecialSearch.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki/mediawiki.specials.search.js (added) (history)
  • /trunk/phase3/skins/common/IE70Fixes.css (deleted) (history)
  • /trunk/phase3/skins/common/search.css (added) (history)

Diff [purge]

Index: trunk/phase3/skins/common/IE70Fixes.css
@@ -1,12 +0,0 @@
2 -/**
3 - * Fixes sister projects box moving down the extract
4 - * of the first result (bug #16886).
5 - * It only happens when the window is small and
6 - * This changes slightly the layout for big screens
7 - * where there was space for the extracts and the
8 - * sister projects and thus it showed like in any
9 - * other browser.
10 - */
11 -.searchresult {
12 - display: inline;
13 -}
Index: trunk/phase3/skins/common/search.css
@@ -0,0 +1,14 @@
 2+/**
 3+ * Fixes sister projects box moving down the extract
 4+ * of the first result (bug #16886).
 5+ * It only happens when the window is small and
 6+ * This changes slightly the layout for big screens
 7+ * where there was space for the extracts and the
 8+ * sister projects and thus it showed like in any
 9+ * other browser.
 10+ *
 11+ * This will only affect IE 7 and lower
 12+ */
 13+html > body .searchresult {
 14+ display: inline;
 15+}
Property changes on: trunk/phase3/skins/common/search.css
___________________________________________________________________
Added: svn:eol-style
116 + native
Index: trunk/phase3/includes/specials/SpecialSearch.php
@@ -221,7 +221,6 @@
222222
223223 $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':';
224224 if( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
225 - $wgOut->addHTML( $this->searchFocus() );
226225 $wgOut->addHTML( $this->formHeader($term, 0, 0));
227226 if( $this->searchAdvanced ) {
228227 $wgOut->addHTML( $this->powerSearchBox( $term ) );
@@ -307,9 +306,6 @@
308307 $this->showCreateLink( $t );
309308 }
310309 $wgOut->addHtml( "</div>" );
311 - if( $num === 0 ) {
312 - $wgOut->addHTML( $this->searchFocus() );
313 - }
314310
315311 if( $num || $this->offset ) {
316312 $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
@@ -367,9 +363,7 @@
368364 $wgOut->setRobotPolicy( 'noindex,nofollow' );
369365 // add javascript specific to special:search
370366 $wgOut->addModules( 'mediawiki.legacy.search' );
371 -
372 - // Bug #16886: Sister projects box moves down the first extract on IE7
373 - $wgOut->addStyle( 'common/IE70Fixes.css', 'screen', 'IE 7' );
 367+ $wgOut->addModules( 'mediawiki.specials.search' );
374368 }
375369
376370 /**
@@ -832,14 +826,6 @@
833827 Xml::hidden( 'fulltext', 'Advanced search' ) .
834828 Xml::closeElement( 'fieldset' );
835829 }
836 -
837 - protected function searchFocus() {
838 - $id = $this->searchAdvanced ? 'powerSearchText' : 'searchText';
839 - return Html::inlineScript(
840 - "hookEvent(\"load\", function() {" .
841 - "document.getElementById('$id').focus();" .
842 - "});" );
843 - }
844830
845831 protected function getSearchProfiles() {
846832 // Builds list of Search Types (profiles)
Index: trunk/phase3/resources/Resources.php
@@ -310,6 +310,9 @@
311311 'mediawiki.specials.preferences' => new ResourceLoaderFileModule( array(
312312 'scripts' => 'resources/mediawiki/mediawiki.specials.preferences.js',
313313 ) ),
 314+ 'mediawiki.specials.search' => new ResourceLoaderFileModule( array(
 315+ 'scripts' => 'resources/mediawiki/mediawiki.specials.search.js',
 316+ ) ),
314317
315318 /* MediaWiki Legacy */
316319
@@ -395,6 +398,7 @@
396399 ) ),
397400 'mediawiki.legacy.search' => new ResourceLoaderFileModule( array(
398401 'scripts' => 'skins/common/search.js',
 402+ 'styles' => 'skins/common/search.css',
399403 'dependencies' => 'mediawiki.legacy.wikibits',
400404 ) ),
401405 'mediawiki.legacy.shared' => new ResourceLoaderFileModule( array(
Index: trunk/phase3/resources/mediawiki/mediawiki.specials.search.js
@@ -0,0 +1,8 @@
 2+/*
 3+ * JavaScript for Specical:Search
 4+ */
 5+
 6+// Emulate HTML5 autofocus behavior in non HTML5 compliant browsers
 7+if ( !( 'autofocus' in document.createElement( 'input' ) ) ) {
 8+ $( 'input[autofocus]' ).focus();
 9+}
Property changes on: trunk/phase3/resources/mediawiki/mediawiki.specials.search.js
___________________________________________________________________
Added: svn:eol-style
110 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r83583Fix r74388: CSS for IE7 and below was put in a selector that only applies it ...catrope12:30, 9 March 2011

Comments

#Comment by TheDJ (talk | contribs)   01:13, 19 February 2011

causes bug 27547

#Comment by Bryan (talk | contribs)   12:35, 26 February 2011
+ * This will only affect IE 7 and lower
+ */
+html > body .searchresult {
+	display: inline;
+}

The child selector was not supported on IE6, right?

#Comment by Trevor Parscal (WMF) (talk | contribs)   18:43, 28 February 2011

That's correct. This is a way to isolate CSS from IE6 without using invalid CSS.

#Comment by TheDJ (talk | contribs)   19:52, 28 February 2011

But wasn't the intent for that CSS to have it apply only to IE6 and IE7 ? Anyway, we need to find some other solution here, because the file results look rather messy atm.

#Comment by Bryan (talk | contribs)   08:59, 1 March 2011

Apologies for being unclear. I was refering to the comment "IE 7 and lower" while the child selector means "IE 7 and higher". So either the use of the child selector is wrong, or the comment is.

#Comment by Catrope (talk | contribs)   22:43, 8 March 2011

Looks like the use of the comment is. Will fix

#Comment by Catrope (talk | contribs)   12:31, 9 March 2011

Fixed in r83583.

Status & tagging log