From: Trevor Parscal Date: Wed, 6 Oct 2010 20:42:08 +0000 (+0000) Subject: * Moved search/IE7 specific CSS rule into search.css with a CSS hack, which is now... X-Git-Tag: 1.31.0-rc.0~34600 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=8f7d318998e71559337d00aa8dbf04f832d6ded1;p=lhc%2Fweb%2Fwiklou.git * 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 --- diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 86feace1a2..3810fcca9d 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -221,7 +221,6 @@ class SpecialSearch { $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; if( trim( $term ) === '' || $filePrefix === trim( $term ) ) { - $wgOut->addHTML( $this->searchFocus() ); $wgOut->addHTML( $this->formHeader($term, 0, 0)); if( $this->searchAdvanced ) { $wgOut->addHTML( $this->powerSearchBox( $term ) ); @@ -307,9 +306,6 @@ class SpecialSearch { $this->showCreateLink( $t ); } $wgOut->addHtml( "" ); - if( $num === 0 ) { - $wgOut->addHTML( $this->searchFocus() ); - } if( $num || $this->offset ) { $wgOut->addHTML( "

{$prevnext}

\n" ); @@ -367,9 +363,7 @@ class SpecialSearch { $wgOut->setRobotPolicy( 'noindex,nofollow' ); // add javascript specific to special:search $wgOut->addModules( 'mediawiki.legacy.search' ); - - // Bug #16886: Sister projects box moves down the first extract on IE7 - $wgOut->addStyle( 'common/IE70Fixes.css', 'screen', 'IE 7' ); + $wgOut->addModules( 'mediawiki.specials.search' ); } /** @@ -832,14 +826,6 @@ class SpecialSearch { Xml::hidden( 'fulltext', 'Advanced search' ) . Xml::closeElement( 'fieldset' ); } - - protected function searchFocus() { - $id = $this->searchAdvanced ? 'powerSearchText' : 'searchText'; - return Html::inlineScript( - "hookEvent(\"load\", function() {" . - "document.getElementById('$id').focus();" . - "});" ); - } protected function getSearchProfiles() { // Builds list of Search Types (profiles) diff --git a/resources/Resources.php b/resources/Resources.php index 7d36f50584..74a45bc6d9 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -310,6 +310,9 @@ return array( 'mediawiki.specials.preferences' => new ResourceLoaderFileModule( array( 'scripts' => 'resources/mediawiki/mediawiki.specials.preferences.js', ) ), + 'mediawiki.specials.search' => new ResourceLoaderFileModule( array( + 'scripts' => 'resources/mediawiki/mediawiki.specials.search.js', + ) ), /* MediaWiki Legacy */ @@ -395,6 +398,7 @@ return array( ) ), 'mediawiki.legacy.search' => new ResourceLoaderFileModule( array( 'scripts' => 'skins/common/search.js', + 'styles' => 'skins/common/search.css', 'dependencies' => 'mediawiki.legacy.wikibits', ) ), 'mediawiki.legacy.shared' => new ResourceLoaderFileModule( array( diff --git a/resources/mediawiki/mediawiki.specials.search.js b/resources/mediawiki/mediawiki.specials.search.js new file mode 100644 index 0000000000..1b56857b86 --- /dev/null +++ b/resources/mediawiki/mediawiki.specials.search.js @@ -0,0 +1,8 @@ +/* + * JavaScript for Specical:Search + */ + +// Emulate HTML5 autofocus behavior in non HTML5 compliant browsers +if ( !( 'autofocus' in document.createElement( 'input' ) ) ) { + $( 'input[autofocus]' ).focus(); +} diff --git a/skins/common/IE70Fixes.css b/skins/common/IE70Fixes.css deleted file mode 100644 index d9e3ff843c..0000000000 --- a/skins/common/IE70Fixes.css +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Fixes sister projects box moving down the extract - * of the first result (bug #16886). - * It only happens when the window is small and - * This changes slightly the layout for big screens - * where there was space for the extracts and the - * sister projects and thus it showed like in any - * other browser. - */ -.searchresult { - display: inline; -} diff --git a/skins/common/search.css b/skins/common/search.css new file mode 100644 index 0000000000..22c3ca4a5b --- /dev/null +++ b/skins/common/search.css @@ -0,0 +1,14 @@ +/** + * Fixes sister projects box moving down the extract + * of the first result (bug #16886). + * It only happens when the window is small and + * This changes slightly the layout for big screens + * where there was space for the extracts and the + * sister projects and thus it showed like in any + * other browser. + * + * This will only affect IE 7 and lower + */ +html > body .searchresult { + display: inline; +}