JGonera has uploaded a new change for review.

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


Change subject: [WIP] Add Compact personal bar beta feature
......................................................................

[WIP] Add Compact personal bar beta feature

Change-Id: Ie14423ced7efbd5a2764296bc18bbe84358fc018
---
M VectorBeta.hooks.php
M VectorBeta.i18n.php
M VectorBeta.php
A resources/compactPersonalBar/compactPersonalBar.js
A resources/compactPersonalBar/compactPersonalBar.less
5 files changed, 169 insertions(+), 1 deletion(-)


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

diff --git a/VectorBeta.hooks.php b/VectorBeta.hooks.php
index c65c9c7..9d22687 100644
--- a/VectorBeta.hooks.php
+++ b/VectorBeta.hooks.php
@@ -44,6 +44,17 @@
                        ),
                );
 
+               $prefs['betafeatures-vector-compact-personal-bar'] = array(
+                       'label-message' => 
'vector-beta-feature-compact-personal-bar-message',
+                       'desc-message' => 
'vector-beta-feature-compact-personal-bar-description',
+                       'info-link' => 
'https://www.mediawiki.org/wiki/Compact_Personal_Bar',
+                       'discussion-link' => 
'https://www.mediawiki.org/wiki/Talk:Compact_Personal_Bar',
+                       'screenshot' => '', // XXX
+                       'requirements' => array(
+                               'skins' => array( 'vector' ),
+                       ),
+               );
+
                return true;
        }
 
@@ -67,4 +78,26 @@
                }
                return true;
        }
+
+       /**
+        * Handler for BeforePageDisplay
+        * @param OutputPage $out
+        * @param Skin $skin
+        * @return bool
+        */
+       static function onBeforePageDisplay( &$out, &$skin ) {
+               if (
+                       class_exists( 'BetaFeatures' ) &&
+                       BetaFeatures::isFeatureEnabled( 
$out->getSkin()->getUser(), 'betafeatures-vector-compact-personal-bar' )
+               ) {
+
+                       $out->addModules( array(
+                               'skins.vector.compactPersonalBar',
+                       ) );
+               } elseif ( !class_exists( 'BetaFeatures' ) ) {
+                       wfDebugLog( 'VectorBeta', 'The BetaFeatures extension 
is not installed' );
+               }
+
+               return true;
+       }
 }
diff --git a/VectorBeta.i18n.php b/VectorBeta.i18n.php
index 7076a91..139a9c5 100644
--- a/VectorBeta.i18n.php
+++ b/VectorBeta.i18n.php
@@ -28,6 +28,8 @@
        'vector-beta-feature-typography-message' => 'Typography refresh',
        'vectorbeta-desc' => 'Typography refresh of the Vector skin using 
BetaFeatures',
        'vector-beta-feature-typography-description' => 'Updates typography of 
the Vector skin to improve readability, accessibility and consistency.',
+       'vector-beta-feature-compact-personal-bar-message' => 'Compact personal 
bar',
+       'vector-beta-feature-compact-personal-bar-description' => 'Collapses 
personal bar into a flyout.',
 );
 
 /** Message documentation (Message documentation)
@@ -36,6 +38,8 @@
        'vector-beta-feature-typography-message' => 'Name shown in user 
preferences for Vector typography beta feature experiment.',
        'vectorbeta-desc' => '{{desc|name=Vector 
Beta|url=https://www.mediawiki.org/wiki/Extension:VectorBeta}}',
        'vector-beta-feature-typography-description' => 'Brief explanation of 
Vector typography beta feature experiment which updates/refreshes Vectors 
existing typography for first time since its launch.',
+       'vector-beta-feature-compact-personal-bar-message' => 'Name shown in 
user preferences for Compact personal bar beta feature experiment.',
+       'vector-beta-feature-compact-personal-bar-description' => 'Brief 
explanation of Compact personal bar beta feature experiment.',
 );
 
 /** Asturian (asturianu)
diff --git a/VectorBeta.php b/VectorBeta.php
index 870f615..67c5f4e 100644
--- a/VectorBeta.php
+++ b/VectorBeta.php
@@ -20,7 +20,7 @@
  */
 
 $wgExtensionCredits['other'][] = array(
-       'author' => array( 'Jon Robson', 'Trevor Parscal' ),
+       'author' => array( 'Jon Robson', 'Trevor Parscal', 'Juliusz Gonera' ),
        'descriptionmsg' => 'vectorbeta-desc',
        'name' => 'VectorBeta',
        'path' => __FILE__,
@@ -31,5 +31,21 @@
 
 $wgExtensionMessagesFiles['VectorBeta'] = __DIR__ . '/VectorBeta.i18n.php';
 
+$wgVBResourceBoilerplate = array(
+       'localBasePath' =>  __DIR__,
+       'remoteExtPath' => 'VectorBeta',
+);
+
+$wgResourceModules['skins.vector.compactPersonalBar'] = 
$wgVBResourceBoilerplate + array(
+       'styles' => array(
+               'resources/compactPersonalBar/compactPersonalBar.less',
+       ),
+       'scripts' => array(
+               'resources/compactPersonalBar/compactPersonalBar.js',
+       ),
+       'position' => 'top',
+);
+
 $wgHooks['GetBetaFeaturePreferences'][] = 'VectorBetaHooks::getPreferences';
 $wgHooks['SkinVectorStyleModules'][] = 
'VectorBetaHooks::skinVectorStyleModules';
+$wgHooks['BeforePageDisplay'][] = 'VectorBetaHooks::onBeforePageDisplay';
diff --git a/resources/compactPersonalBar/compactPersonalBar.js 
b/resources/compactPersonalBar/compactPersonalBar.js
new file mode 100644
index 0000000..0e797db
--- /dev/null
+++ b/resources/compactPersonalBar/compactPersonalBar.js
@@ -0,0 +1,43 @@
+// FIXME: this is only for the Compact personal bar beta feature. If this
+// feature is ever merged into the core, this code should not be used anymore.
+// Instead, the Vector skin itself should be modified.
+
+jQuery( function( $ ) {
+       var $bar = $( '#p-personal' ), $barList, $flyoutList;
+
+       function createList( items ) {
+               var $list = $( '<ul>' );
+
+               $( items ).each( function() {
+                       var $el = typeof this.el === 'string' ? $( this.el 
).clone( true, true ) : this.el;
+                       $el.addClass( this.className );
+                       $list.append( $el );
+               } );
+
+               return $list;
+       }
+
+       $flyoutList = createList( [
+               { el: '#pt-userpage' },
+               { el: '#pt-mycontris', className: 'group-start' },
+               // XXX: notifications
+               { el: '#pt-mytalk' },
+               { el: '#pt-watchlist' },
+               // XXX: extensions, plugins
+               // XXX: separator
+               { el: '#pt-preferences', className: 'group-start' },
+               { el: '#pt-betafeatures' },
+               { el: '#pt-logout', className: 'group-start' }
+       ] );
+
+       $barList = createList( [
+               { el: '#pt-uls' },
+               { el: '#pt-notifications' },
+               { el: $( '<li id="pt-flyout">' ).append( $flyoutList ) }
+       ] );
+
+       // remove the old list
+       $bar.find( 'ul' ).remove();
+       // add the new one
+       $bar.append( $barList );
+} );
diff --git a/resources/compactPersonalBar/compactPersonalBar.less 
b/resources/compactPersonalBar/compactPersonalBar.less
new file mode 100644
index 0000000..ae18a81
--- /dev/null
+++ b/resources/compactPersonalBar/compactPersonalBar.less
@@ -0,0 +1,72 @@
+@fadeDuration: .2s;
+@fadeDelay: .1s;
+
+#p-personal {
+       ul {
+               // FIXME: overrides for Vector styles
+               padding: 0;
+       }
+
+       #pt-flyout {
+               // FIXME: overrides for Vector styles
+               margin-top: .1em;
+
+               padding: 0 .2em;
+               border: 1px solid #ccc;
+               border-radius: 3px;
+
+               transition: 0s (@fadeDuration + @fadeDelay);
+
+               &:hover {
+                       border-color: #aaa;
+                       background: #fff;
+
+                       transition: background @fadeDuration @fadeDelay, 
border-color @fadeDuration @fadeDelay;
+               }
+
+               li {
+                       // FIXME: overrides for Vector styles
+                       float: none;
+                       font-size: 1em;
+                       margin: 0;
+                       padding: 0 !important;
+                       background: none;
+
+                       a {
+                               display: block;
+                               padding: .4em .6em;
+                               border-radius: 2px;
+                               color: #000;
+                               text-decoration: none;
+                       }
+               }
+
+               // more widely supported than li:not(:first-child)
+               li:first-child ~ li {
+                       // can't use display: none because it's not animatable
+                       max-height: 0;
+                       visibility: none;
+                       opacity: 0;
+
+                       transition: 0s (@fadeDuration + @fadeDelay);
+
+                       &.group-start {
+                               border-top: 1px solid #eee;
+                       }
+
+                       a:hover {
+                               background: #4c85fb;
+                               color: #fff;
+                       }
+               }
+
+               &:hover li:first-child ~ li {
+                       max-height: 9999px;
+                       visibility: visible;
+                       opacity: 1;
+                       padding: .2em 0 !important;
+
+                       transition: 0s @fadeDelay, opacity @fadeDuration 
@fadeDelay;
+               }
+       }
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie14423ced7efbd5a2764296bc18bbe84358fc018
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VectorBeta
Gerrit-Branch: master
Gerrit-Owner: JGonera <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to