mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Merge "Add GuidedTour survey about user gender"
This commit is contained in:
commit
518dd6247c
|
@ -13,7 +13,8 @@ class VisualEditorHooks {
|
|||
protected static $supportedSkins = array( 'vector', 'apex', 'monobook' );
|
||||
|
||||
public static function onSetup() {
|
||||
global $wgVisualEditorEnableEventLogging, $wgResourceModules;
|
||||
global $wgVisualEditorEnableEventLogging, $wgResourceModules,
|
||||
$wgVisualEditorEnableGenderSurvey;
|
||||
|
||||
if ( $wgVisualEditorEnableEventLogging ) {
|
||||
if ( class_exists( 'ResourceLoaderSchemaModule' ) ) {
|
||||
|
@ -24,6 +25,14 @@ class VisualEditorHooks {
|
|||
'schema' => 'Edit',
|
||||
'revision' => 5570274,
|
||||
);
|
||||
|
||||
if ( $wgVisualEditorEnableGenderSurvey ) {
|
||||
$wgResourceModules['schema.GenderSurvey'] = array(
|
||||
'class' => 'ResourceLoaderSchemaModule',
|
||||
'schema' => 'GenderSurvey',
|
||||
'revision' => '5607845',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
wfWarn( 'VisualEditor is configured to use EventLogging, but the extension is ' .
|
||||
' not available. Disabling wgVisualEditorEnableEventLogging.' );
|
||||
|
@ -85,6 +94,23 @@ class VisualEditorHooks {
|
|||
return true;
|
||||
}
|
||||
|
||||
// Temporary survey in conjuction with split test (bug 49604)
|
||||
// To be removed once no longer needed.
|
||||
// Depends on GuidedTour and EventLogging
|
||||
public static function onBeforeWelcomeCreation( &$welcomeCreationMsg, &$injectHtml ) {
|
||||
global $wgOut, $wgVisualEditorEnableGenderSurvey;
|
||||
|
||||
if ( $wgVisualEditorEnableGenderSurvey ) {
|
||||
$wgOut->addModules( array(
|
||||
'ext.guidedTour.lib',
|
||||
'ext.guidedTour.tour.vegendersurvey',
|
||||
'ext.visualEditor.genderSurvey'
|
||||
) );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function onGetPreferences( $user, &$preferences ) {
|
||||
$preferences['visualeditor-enable'] = array(
|
||||
'type' => 'toggle',
|
||||
|
|
|
@ -152,6 +152,11 @@ $messages['en'] = array(
|
|||
'visualeditor-usernamespacepagelink' => 'Project:User namespace',
|
||||
'visualeditor-viewpage-savewarning' => 'Are you sure you want to go back to view mode without saving first?',
|
||||
'visualeditor-window-title' => 'Inspect',
|
||||
'guidedtour-tour-vegendersurvey-title' => 'Please select your gender',
|
||||
'guidedtour-tour-vegendersurvey-description' => 'By participating in this survey, you consent to the transfer of the information you submit to the Wikimedia Foundation in the United States and elsewhere. The information collected is for internal research purposes only and will not be publicly associated with your account. However, we may share the results of this survey with the public in anonymized or aggregated forms.',
|
||||
'guidedtour-tour-vegendersurvey-male' => 'Male',
|
||||
'guidedtour-tour-vegendersurvey-female' => 'Female',
|
||||
'guidedtour-tour-vegendersurvey-optout' => 'Prefer not to say',
|
||||
);
|
||||
|
||||
/** Message documentation (Message documentation)
|
||||
|
@ -420,6 +425,11 @@ Parameters:
|
|||
{{doc-important|Do not translate "Project"; it is automatically converted to the wiki\'s project namespace.}}',
|
||||
'visualeditor-viewpage-savewarning' => 'Text shown when the user tries to leave the editor without saving their changes',
|
||||
'visualeditor-window-title' => 'Title of an unnamed inspector',
|
||||
'guidedtour-tour-vegendersurvey-title' => 'Title of gender survey guider',
|
||||
'guidedtour-tour-vegendersurvey-description' => 'Description of gender survey guider',
|
||||
'guidedtour-tour-vegendersurvey-male' => 'Button on gender survey for choosing \'male\'',
|
||||
'guidedtour-tour-vegendersurvey-female' => 'Button on gender survey for choosing \'female\'',
|
||||
'guidedtour-tour-vegendersurvey-optout' => 'Button on gender survey for those who prefer not to answer',
|
||||
);
|
||||
|
||||
/** Arabic (العربية)
|
||||
|
|
|
@ -34,7 +34,10 @@ $wgVisualEditorEnableExperimentalCode = false;
|
|||
// * add: Adds #ca-ve-edit.
|
||||
// * replace: Re-creates #ca-edit for VisualEditor and adds #ca-editsource.
|
||||
$wgVisualEditorTabLayout = 'replace';
|
||||
|
||||
// Conduct an optional survey (the user can decline to answer) on the user's gender
|
||||
// upon signup.
|
||||
// Depends on GuidedTour and EventLogging extensions.
|
||||
$wgVisualEditorEnableGenderSurvey = false;
|
||||
/* Setup */
|
||||
|
||||
$wgExtensionCredits['other'][] = array(
|
||||
|
@ -102,6 +105,37 @@ $wgResourceModules += array(
|
|||
've/init/mw/ve.init.mw.splitTest.js',
|
||||
)
|
||||
),
|
||||
|
||||
'ext.guidedTour.tour.vegendersurvey' => $wgVisualEditorResourceTemplate + array(
|
||||
'scripts' => array(
|
||||
've/init/mw/tours/vegendersurvey.js',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'ext.guidedTour.lib',
|
||||
),
|
||||
'messages' => array(
|
||||
'guidedtour-tour-vegendersurvey-title',
|
||||
'guidedtour-tour-vegendersurvey-description',
|
||||
'guidedtour-tour-vegendersurvey-male',
|
||||
'guidedtour-tour-vegendersurvey-female',
|
||||
'guidedtour-tour-vegendersurvey-optout'
|
||||
),
|
||||
),
|
||||
|
||||
'ext.visualEditor.genderSurvey' => $wgVisualEditorResourceTemplate + array(
|
||||
'scripts' => array(
|
||||
've/init/mw/ve.init.mw.genderSurvey.js',
|
||||
),
|
||||
'styles' => array(
|
||||
've/init/mw/ve.init.mw.genderSurvey.css',
|
||||
),
|
||||
'dependencies' => array(
|
||||
'ext.guidedTour.lib',
|
||||
'ext.guidedTour.tour.vegendersurvey',
|
||||
'ext.visualEditor.mediawiki',
|
||||
),
|
||||
),
|
||||
|
||||
// Alias for backwards compat, safe to remove after
|
||||
'ext.visualEditor.editPageInit' => $wgVisualEditorResourceTemplate + array(
|
||||
'dependencies' => array(
|
||||
|
@ -678,7 +712,9 @@ $wgHooks['ResourceLoaderGetConfigVars'][] = 'VisualEditorHooks::onResourceLoader
|
|||
$wgHooks['ResourceLoaderTestModules'][] = 'VisualEditorHooks::onResourceLoaderTestModules';
|
||||
|
||||
// Bug 49604: Running split test in production if $wgVisualEditorEnableSplitTest is true.
|
||||
// This requires that GuidedTour and EventLogging are also enabled on the wiki.
|
||||
$wgHooks['AddNewAccount'][] = 'VisualEditorHooks::onAddNewAccount';
|
||||
$wgHooks['BeforeWelcomeCreation'][] = 'VisualEditorHooks::onBeforeWelcomeCreation';
|
||||
|
||||
$wgExtensionFunctions[] = 'VisualEditorHooks::onSetup';
|
||||
|
||||
|
|
31
modules/ve/init/mw/tours/vegendersurvey.js
Normal file
31
modules/ve/init/mw/tours/vegendersurvey.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*global mw */
|
||||
( function ( $, gt ) {
|
||||
gt.defineTour( {
|
||||
name: 'vegendersurvey',
|
||||
isSinglePage: true,
|
||||
// shouldLog tells GuidedTour to provide additional logging (step impressions, etc.)
|
||||
shouldLog: true,
|
||||
steps: [ {
|
||||
titlemsg: 'guidedtour-tour-vegendersurvey-title',
|
||||
descriptionmsg: 'guidedtour-tour-vegendersurvey-description',
|
||||
allowAutomaticOkay: false,
|
||||
overlay: true,
|
||||
buttons: [ {
|
||||
namemsg: 'guidedtour-tour-vegendersurvey-male',
|
||||
onclick: function () {
|
||||
ve.init.mw.genderSurvey.logAndEndTour( 'male' );
|
||||
}
|
||||
}, {
|
||||
namemsg: 'guidedtour-tour-vegendersurvey-female',
|
||||
onclick: function () {
|
||||
ve.init.mw.genderSurvey.logAndEndTour( 'female' );
|
||||
}
|
||||
}, {
|
||||
namemsg: 'guidedtour-tour-vegendersurvey-optout',
|
||||
onclick: function () {
|
||||
ve.init.mw.genderSurvey.logAndEndTour( 'opt-out' );
|
||||
}
|
||||
} ]
|
||||
} ]
|
||||
} );
|
||||
} ( jQuery, mw.guidedTour ) );
|
3
modules/ve/init/mw/ve.init.mw.genderSurvey.css
Normal file
3
modules/ve/init/mw/ve.init.mw.genderSurvey.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
.mw-guidedtour-tour-vegendersurvey .guider_description {
|
||||
font-size: small;
|
||||
}
|
14
modules/ve/init/mw/ve.init.mw.genderSurvey.js
Normal file
14
modules/ve/init/mw/ve.init.mw.genderSurvey.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*global mw */
|
||||
mw.loader.using( 'schema.GenderSurvey', function () {
|
||||
ve.init.mw.genderSurvey = {
|
||||
logAndEndTour: function ( buttonType ) {
|
||||
mw.eventLog.logEvent( 'GenderSurvey', {
|
||||
userId: mw.config.get( 'wgUserId' ),
|
||||
buttonType: buttonType
|
||||
} );
|
||||
mw.guidedTour.endTour( 'vegendersurvey' );
|
||||
}
|
||||
};
|
||||
|
||||
mw.guidedTour.launchTour( 'vegendersurvey' );
|
||||
} );
|
Loading…
Reference in a new issue