Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/107523


Change subject: WIP: Add Fixed header experiment to Vector Beta
......................................................................

WIP: Add Fixed header experiment to Vector Beta

Change-Id: I8f34fdbc4857adb8534bc9393749ba2bf5ca37fc
---
M VectorBeta.hooks.php
M VectorBeta.php
A javascripts/header.js
A less/header.less
A less/images/icon-search.png
5 files changed, 144 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VectorBeta 
refs/changes/23/107523/1

diff --git a/VectorBeta.hooks.php b/VectorBeta.hooks.php
index f1805bc..08f494f 100644
--- a/VectorBeta.hooks.php
+++ b/VectorBeta.hooks.php
@@ -44,6 +44,17 @@
                        ),
                );
 
+               $prefs['betafeatures-vector-fixedheader'] = array(
+                       'label-message' => 
'vector-beta-feature-fixedheader-message',
+                       'desc-message' => 
'vector-beta-feature-fixedheader-description',
+                       'info-link' => '',
+                       'discussion-link' => '',
+                       'screenshot' => '',
+                       'requirements' => array(
+                               'skins' => array( 'vector' ),
+                       ),
+               );
+
                return true;
        }
 
@@ -54,17 +65,35 @@
         * @return bool
         */
        static function skinVectorStyleModules( $skin, &$modules ) {
-               if ( class_exists( 'BetaFeatures')
-                       && BetaFeatures::isFeatureEnabled( $skin->getUser(), 
'betafeatures-vector-typography-update' )
-               ) {
-                       $index = array_search( 'skins.vector.styles', $modules 
);
-                       if ( $index !== false ) {
-                               array_splice( $modules, $index, 1 );
-                       }
-                       $modules[] = 'skins.vector.beta';
-               } elseif ( !class_exists( 'BetaFeatures' ) ) {
+               if ( !class_exists( 'BetaFeatures' ) ) {
                        wfDebugLog( 'VectorBeta', 'The BetaFeatures extension 
is not installed' );
+               } else {
+                       $typeEnabled = BetaFeatures::isFeatureEnabled( 
$skin->getUser(), 'betafeatures-vector-typography-update' );
+                       $fixedHeaderEnabled = BetaFeatures::isFeatureEnabled( 
$skin->getUser(), 'betafeatures-vector-fixedheader' );
+                       if (  $typeEnabled || $fixedHeaderEnabled ) {
+                               if ( $typeEnabled ) {
+                                       $index = array_search( 
'skins.vector.styles', $modules );
+                                       if ( $index !== false ) {
+                                               array_splice( $modules, $index, 
1 );
+                                       }
+                                       $modules[] = 'skins.vector.beta';
+                               }
+                               if ( $fixedHeaderEnabled ) {
+                                       $modules[] = 'skins.vector.header.beta';
+                               }
+                       }
                }
+
+               return true;
+       }
+
+       public static function onBeforePageDisplay( &$out, &$sk ) {
+               if ( class_exists( 'BetaFeatures' ) ) {
+                       if ( BetaFeatures::isFeatureEnabled( $out->getUser(), 
'betafeatures-vector-fixedheader' ) ) {
+                               $out->addModules( 'skins.vector.headerjs.beta' 
);
+                       }
+               }
+
                return true;
        }
 }
diff --git a/VectorBeta.php b/VectorBeta.php
index 60ba9c4..db4c6c9 100644
--- a/VectorBeta.php
+++ b/VectorBeta.php
@@ -38,11 +38,29 @@
                'remoteBasePath' => $remoteExtPath,
                'localBasePath' => $localBasePath,
        ),
+
+       'skins.vector.header.beta' => array(
+               'styles' => array(
+                       'less/header.less',
+               ),
+               'remoteBasePath' => $remoteExtPath,
+               'localBasePath' => $localBasePath,
+       ),
+
+       'skins.vector.headerjs.beta' => array(
+               'scripts' => array(
+                       'javascripts/header.js',
+               ),
+               'remoteBasePath' => $remoteExtPath,
+               'localBasePath' => $localBasePath,
+       ),
 ) );
+
 
 $wgAutoloadClasses['VectorBetaHooks'] = __DIR__ . '/VectorBeta.hooks.php';
 
 $wgExtensionMessagesFiles['VectorBeta'] = __DIR__ . '/VectorBeta.i18n.php';
 
 $wgHooks['GetBetaFeaturePreferences'][] = 'VectorBetaHooks::getPreferences';
+$wgHooks['BeforePageDisplay'][] = 'VectorBetaHooks::onBeforePageDisplay';
 $wgHooks['SkinVectorStyleModules'][] = 
'VectorBetaHooks::skinVectorStyleModules';
diff --git a/javascripts/header.js b/javascripts/header.js
new file mode 100644
index 0000000..cff0241
--- /dev/null
+++ b/javascripts/header.js
@@ -0,0 +1,10 @@
+jQuery( function( $ ) {
+       var $body = $( 'body' );
+       $( window ).on( 'scroll', function() {
+               if ( $( this ).scrollTop() > 0 ) {
+                       $body.addClass( 'mw-scrolling' );
+               } else {
+                       $body.removeClass( 'mw-scrolling' );
+               }
+       } );
+} );
diff --git a/less/header.less b/less/header.less
new file mode 100644
index 0000000..10b7533
--- /dev/null
+++ b/less/header.less
@@ -0,0 +1,78 @@
+#p-search {
+       position: fixed;
+       top: 0;
+       left: 11em;
+       margin: 0;
+       width: 100%;
+       background-color: #FFF;
+
+       // FIXME: Reset original vector style. When upstream just remove the 
rule.
+       form {
+               margin: 0;
+       }
+}
+
+// FIXME: Only apply when scrolling started
+.mw-scrolling #p-logo {
+       position: fixed;
+       left: 0;
+       top: 0;
+       height: 2.2em;
+       padding: 0;
+       margin: 0;
+       width: 11em;
+       border-bottom: 1px solid #CCC;
+       background-color: #F6F6F6;
+
+       a {
+               height: 2.2em;
+               width: 11em;
+               background-size: auto 2.2em;
+               background-position: center top;
+       }
+}
+
+div#content {
+       border-left: none;
+}
+
+/*#mw-panel {
+       padding-left: 0;
+
+       .portal {
+               padding-left: 0.5em;
+       }
+}*/
+
+div#simpleSearch {
+       background: none;
+       margin: 0;
+       height: 2.2em;
+       border: none;
+       border-bottom: 1px solid #CCC;
+       width: 100%;
+
+       button#searchButton {
+               background: url(images/icon-search.png) no-repeat 10px center;
+               position: absolute;
+               left: 0;
+               height: 100%;
+               padding: 0;
+               top: 0;
+               width: 50px;
+
+               // FIXME: Kill image tag when upstream to core.
+               img {
+                       display: none;
+               }
+       }
+
+       // FIXME: Doesn't need to be so specific
+       input#searchInput {
+               position: relative;
+               left: 50px;
+               height: 100%;
+               padding: 0;
+               margin: 0;
+       }
+}
\ No newline at end of file
diff --git a/less/images/icon-search.png b/less/images/icon-search.png
new file mode 100644
index 0000000..5e77994
--- /dev/null
+++ b/less/images/icon-search.png
Binary files differ

-- 
To view, visit https://gerrit.wikimedia.org/r/107523
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f34fdbc4857adb8534bc9393749ba2bf5ca37fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VectorBeta
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to