MarkTraceur has uploaded a new change for review.
https://gerrit.wikimedia.org/r/91314
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, 73 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures
refs/changes/14/91314/1
diff --git a/BetaFeatures.i18n.php b/BetaFeatures.i18n.php
index 763fb99..88ec308 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)
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: newchange
Gerrit-Change-Id: I1efa8733e86760223add86b1177d428d63bab488
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BetaFeatures
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits