jenkins-bot has submitted this change and it was merged.

Change subject: Add popup CTA for BetaFeatures
......................................................................


Add popup CTA for BetaFeatures

Change-Id: I1efa8733e86760223add86b1177d428d63bab488
---
M BetaFeatures.i18n.php
M BetaFeatures.php
M BetaFeaturesHooks.php
A js/ext.betaFeatures.popup.js
4 files changed, 75 insertions(+), 0 deletions(-)

Approvals:
  Esanders: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/BetaFeatures.i18n.php b/BetaFeatures.i18n.php
index 763fb99..0210e27 100644
--- a/BetaFeatures.i18n.php
+++ b/BetaFeatures.i18n.php
@@ -41,6 +41,8 @@
        // Test messages
        'betafeatures-test-check-field' => 'blah blah blah', # do not translate 
or duplicate this message to other languages
        'betafeatures-test-feature-field' => 'This is a test feature - it 
should not show up.', # do not translate or duplicate this message to other 
languages
+
+       'betafeatures-tooltip' => 'Introducing Beta Features! This new 
preferences section lets you test and give feedback about new features before 
we launch them as default behavior. Try out something new now!',
 );
 
 /** Message documentation (Message documentation)
@@ -80,6 +82,8 @@
        'betafeatures-test-feature-field' => 'Used as description for the 
checkbox, used to test the extension.
 
 The label for the checkbox is {{msg-mw|Betafeatures-test-check-field}}.',
+
+       'betafeatures-tooltip' => 'A tooltip meant to advertise the existence 
of the BetaFeatures preferences page the first time a user sees it. Only shown 
once, meant to be a call to action.',
 );
 
 /** Arabic (العربية)
diff --git a/BetaFeatures.php b/BetaFeatures.php
index 8b0803e..44eaa17 100644
--- a/BetaFeatures.php
+++ b/BetaFeatures.php
@@ -38,6 +38,7 @@
 $wgHooks['PersonalUrls'][] = 'BetaFeaturesHooks::getBetaFeaturesLink';
 $wgHooks['UnitTestsList'][] = 'BetaFeaturesHooks::getUnitTestsList';
 $wgHooks['LoadExtensionSchemaUpdates'][] = 
'BetaFeaturesHooks::getSchemaUpdates';
+$wgHooks['BeforePageDisplay'][] = 'BetaFeaturesHooks::loadPopupScript';
 
 $wgJobClasses['updateBetaFeaturesUserCounts'] = 
'UpdateBetaFeatureUserCountsJob';
 
@@ -56,6 +57,20 @@
        ),
 ) + $moduleInfo;
 
+$wgResourceModules['ext.betaFeatures.popup'] = array(
+       'scripts' => array(
+               'js/ext.betaFeatures.popup.js',
+       ),
+
+       'dependencies' => array(
+               'jquery.tipsy',
+       ),
+
+       'messages' => array(
+               'betafeatures-tooltip',
+       ),
+) + $moduleInfo;
+
 $wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'BetaFeatures',
diff --git a/BetaFeaturesHooks.php b/BetaFeaturesHooks.php
index a75a7f2..7d2a740 100644
--- a/BetaFeaturesHooks.php
+++ b/BetaFeaturesHooks.php
@@ -149,6 +149,11 @@
 
                wfRunHooks( 'GetBetaFeaturePreferences', array( $user, 
&$betaPrefs ) );
 
+               $prefs['betafeatures-popup-disable'] = array(
+                       'type' => 'api',
+                       'default' => 0,
+               );
+
                $prefs['betafeatures-section-desc'] = array(
                        'class' => 'HTMLTextBlockField',
                        'label' => wfMessage( 'betafeatures-section-desc', 
count( $betaPrefs ), $wgSitename )->text(),
@@ -318,4 +323,17 @@
                        __DIR__ . '/sql/create_counts.sql' );
                return true;
        }
+
+       /**
+        * @param OutputPage &$out
+        * @param Skin &$skin
+        * @return bool
+        */
+       static function loadPopupScript( OutputPage &$out, Skin &$skin ) {
+               if ( !$out->getUser()->getOption( 'betafeatures-popup-disable' 
) ) {
+                       $out->addModules( 'ext.betaFeatures.popup' );
+               }
+
+               return true;
+       }
 }
diff --git a/js/ext.betaFeatures.popup.js b/js/ext.betaFeatures.popup.js
new file mode 100644
index 0000000..98798e9
--- /dev/null
+++ b/js/ext.betaFeatures.popup.js
@@ -0,0 +1,38 @@
+/*
+ * This file is part of the MediaWiki extension BetaFeatures.
+ *
+ * BetaFeatures is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * BetaFeatures is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with BetaFeatures.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+( function ( mw, $ ) {
+       if ( !mw.user.options.get( 'betafeatures-popup-disable' ) ) {
+               $( '#pt-betafeatures a' )
+                       .tipsy()
+                       .prop( 'title', mw.message( 'betafeatures-tooltip' 
).text() )
+                       .tipsy( 'show' );
+
+               new mw.Api().post( {
+                       action: 'tokens',
+                       type: 'options'
+               } ).done( function ( data ) {
+                       if ( data && data.tokens && data.tokens.optionstoken ) {
+                               new mw.Api().post( {
+                                       action: 'options',
+                                       change: 'betafeatures-popup-disable=1',
+                                       token: data.tokens.optionstoken
+                               } );
+                       }
+               } );
+       }
+}( mediaWiki, jQuery ) );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1efa8733e86760223add86b1177d428d63bab488
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Fabriceflorin <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to