jenkins-bot has submitted this change and it was merged.
Change subject: Add 'first edit' tour for VE
......................................................................
Add 'first edit' tour for VE
Change-Id: Ifbf41d24175d84c4af2d88ec2c48c111dd306be1
---
M GuidedTour.i18n.php
M GuidedTourHooks.php
A modules/tours/firsteditve.js
3 files changed, 105 insertions(+), 4 deletions(-)
Approvals:
Mattflaschen: Looks good to me, approved
Swalling: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/GuidedTour.i18n.php b/GuidedTour.i18n.php
index 99b410f..be7f5a6 100644
--- a/GuidedTour.i18n.php
+++ b/GuidedTour.i18n.php
@@ -66,6 +66,10 @@
'guidedtour-tour-firstedit-preview-description' => 'Clicking
"{{int:showpreview}}" allows you to check what the page will look like with
your changes. Just don\'t forget to save!',
'guidedtour-tour-firstedit-save-title' => 'You\'re almost done!',
'guidedtour-tour-firstedit-save-description' => 'When you\'re ready,
clicking "{{int:savearticle}}" will make your changes visible for everyone.',
+
+ 'guidedtour-tour-firsteditve-edit-page-description' => 'Click the
"{{int:vector-view-edit}} {{int:visualeditor-beta-appendix}}" button to make
your changes.',
+ 'guidedtour-tour-firsteditve-edit-section-description' => 'There are
"{{int:editsection}} {{int:visualeditor-beta-appendix}}" links for each major
section in an article, so you can focus on just that part.',
+ 'guidedtour-tour-firsteditve-save-description' => 'When you\'re ready,
clicking "{{int:visualeditor-toolbar-savedialog}}" will make your changes
visible for everyone.',
);
/** Message documentation (Message documentation)
@@ -149,6 +153,10 @@
See also:
* {{msg-mw|savearticle}}',
+
+ 'guidedtour-tour-firsteditve-edit-page-description' => 'Description of
the step of the firsteditve tour pointing to the VE edit button',
+ 'guidedtour-tour-firsteditve-edit-section-description' => 'Description
of the step of the firsteditve tour pointing to the VE section edit button',
+ 'guidedtour-tour-firsteditve-save-description' => 'Description of step
of the firsteditve tour explaining how to save in VE',
);
/** Arabic (العربية)
diff --git a/GuidedTourHooks.php b/GuidedTourHooks.php
index 4152177..02eeb44 100644
--- a/GuidedTourHooks.php
+++ b/GuidedTourHooks.php
@@ -203,7 +203,7 @@
*/
public static function onResourceLoaderRegisterModules(
&$resourceLoader ) {
$dir = __DIR__ . DIRECTORY_SEPARATOR;
- $module = array(
+ $firstEditModule = array(
'scripts' => 'firstedit.js',
'localBasePath' => $dir . 'modules/tours',
'remoteExtPath' => 'GuidedTour/modules/tours',
@@ -225,15 +225,37 @@
// Check whether VE is installed to determine which messages to
add.
if ( class_exists( 'VisualEditorHooks' ) ) {
array_push(
- $module['messages'],
+ $firstEditModule['messages'],
'visualeditor-ca-editsource',
'guidedtour-tour-firstedit-edit-page-visualeditor-description',
'visualeditor-ca-editsource-section',
'guidedtour-tour-firstedit-edit-section-visualeditor-description'
);
+
+ $resourceLoader->register(
'ext.guidedTour.tour.firsteditve', array(
+ 'scripts' => 'firsteditve.js',
+ 'localBasePath' => $dir .
'modules/tours',
+ 'remoteExtPath' =>
'GuidedTour/modules/tours',
+ 'dependencies' => array(
+ 'ext.guidedTour',
+ ),
+ 'messages' => array(
+ 'vector-view-edit',
+ 'visualeditor-beta-appendix',
+
'visualeditor-toolbar-savedialog',
+ 'editsection',
+
'guidedtour-tour-firstedit-edit-page-title',
+
'guidedtour-tour-firsteditve-edit-page-description',
+
'guidedtour-tour-firstedit-edit-section-title',
+
'guidedtour-tour-firsteditve-edit-section-description',
+
'guidedtour-tour-firstedit-save-title',
+
'guidedtour-tour-firsteditve-save-description',
+ ),
+ )
+ );
} else {
array_push(
- $module['messages'],
+ $firstEditModule['messages'],
'vector-view-edit',
'guidedtour-tour-firstedit-edit-page-description',
'editsection',
@@ -241,6 +263,6 @@
);
}
- $resourceLoader->register( 'ext.guidedTour.tour.firstedit',
$module );
+ $resourceLoader->register( 'ext.guidedTour.tour.firstedit',
$firstEditModule );
}
}
diff --git a/modules/tours/firsteditve.js b/modules/tours/firsteditve.js
new file mode 100644
index 0000000..0f0a5da
--- /dev/null
+++ b/modules/tours/firsteditve.js
@@ -0,0 +1,71 @@
+// Guided Tour to help users make their first edit.
+// Designed to work on any Wikipedia article, and can work for other sites
with minor message changes.
+
+( function ( window, document, $, mw, gt ) {
+ var hasEditSectionAtLoadTime, editSectionSelector =
'.mw-editsection-visualeditor';
+
+ function shouldShowForPage() {
+ // Excludes pages outside the main namespace and pages with
editing restrictions
+ // Should be 'pages that are not in content namespaces'.
+ // However, the list of content namespaces isn't currently
exposed to JS.
+ return ( mw.config.get( 'wgCanonicalNamespace' ) === '' &&
mw.config.get( 'wgIsProbablyEditable' ) );
+ }
+
+ // If we shouldn't show it, don't initialize the guiders
+ if ( !shouldShowForPage() ) {
+ return;
+ }
+
+ function hasEditSection() {
+ return $( editSectionSelector ).length > 0;
+ }
+
+
+ hasEditSectionAtLoadTime = $( editSectionSelector ).length > 0;
+
+ // Reuses messages from the 'firstedit' tour where it semantically
makes sense
+ gt.defineTour( {
+ name: 'firsteditve',
+ shouldLog: true,
+ showConditionally: 'VisualEditor',
+ steps: [ {
+ titlemsg: 'guidedtour-tour-firstedit-edit-page-title',
+ descriptionmsg:
'guidedtour-tour-firsteditve-edit-page-description',
+ position: 'bottom',
+ attachTo: '#ca-ve-edit',
+ // TODO (mattflaschen, 2013-09-03): After GuidedTour
API enhancements, try to replace
+ // section-related shouldSkip and onclick code with
proceedTo.
+ shouldSkip: gt.isVisualEditorOpen,
+ buttons: [ {
+ namemsg: hasEditSectionAtLoadTime ?
'guidedtour-next-button' : 'guidedtour-okay-button',
+ onclick: function () {
+ if ( hasEditSection() ) {
+ mw.libs.guiders.next();
+ } else {
+ mw.libs.guiders.hideAll();
+ }
+ }
+ } ],
+ allowAutomaticOkay: false
+ }, {
+ titlemsg:
'guidedtour-tour-firstedit-edit-section-title',
+ descriptionmsg:
'guidedtour-tour-firsteditve-edit-section-description',
+ position: 'right',
+ attachTo: editSectionSelector,
+ width: 300,
+ shouldSkip: function () {
+ return gt.isVisualEditorOpen() ||
!hasEditSection();
+ }
+ }, {
+ titlemsg: 'guidedtour-tour-firstedit-save-title',
+ descriptionmsg:
'guidedtour-tour-firsteditve-save-description',
+ attachTo: '.ve-ui-toolbar-saveButton',
+ position: 'left',
+ closeOnClickOutside: false,
+ shouldSkip: function() {
+ return !gt.isEditing();
+ }
+ } ]
+ } );
+
+} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) );
--
To view, visit https://gerrit.wikimedia.org/r/85116
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifbf41d24175d84c4af2d88ec2c48c111dd306be1
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/GuidedTour
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Swalling <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits