* Moved search/IE7 specific CSS rule into search.css with a CSS hack, which is now...
authorTrevor Parscal <tparscal@users.mediawiki.org>
Wed, 6 Oct 2010 20:42:08 +0000 (20:42 +0000)
committerTrevor Parscal <tparscal@users.mediawiki.org>
Wed, 6 Oct 2010 20:42:08 +0000 (20:42 +0000)
* 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

includes/specials/SpecialSearch.php
resources/Resources.php
resources/mediawiki/mediawiki.specials.search.js [new file with mode: 0644]
skins/common/IE70Fixes.css [deleted file]
skins/common/search.css [new file with mode: 0644]

index 86feace..3810fcc 100644 (file)
@@ -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( "</div>" );
-               if( $num === 0 ) {
-                       $wgOut->addHTML( $this->searchFocus() );
-               }
 
                if( $num || $this->offset ) {
                        $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\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)
index 7d36f50..74a45bc 100644 (file)
@@ -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 (file)
index 0000000..1b56857
--- /dev/null
@@ -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 (file)
index d9e3ff8..0000000
+++ /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 (file)
index 0000000..22c3ca4
--- /dev/null
@@ -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;
+}