r105028 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105027‎ | r105028 | r105029 >
Date:23:55, 2 December 2011
Author:rsterbin
Status:deferred
Tags:
Comment:
Updates to feedback links:
* Added link option B
* Turned off all links for display option 0
* Added link bucketing, with option B = 100% (unless the display option is
0 or 5, in which case the bucket is 0 -- no links)
* Made the toolbox link exist only for display option 5, and not pop up an
overlay
- ArticleFeedbackv5.i18n.php:
- New message 'articlefeedbackv5-titlebar-linktext'
- Changed message 'articlefeedbackv5-toolbox-linktext' back to "Rate
this Page", since only display option 5 will be using it
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js:
- New methods inDebug() and getBucketId()
- Added both of those, and prefix(), to the plugin's public-facing methods
- modules/ext.articleFeedbackv5/ext.articleFeedbackv5.css:
- Removed old rules for surveys
- modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js:
- Rearranged so that the div gets built first, then the link bucketing
is done, then each of the links gets added to the page if it's allowed
- Changed all references to the articleFeedbackv5 object to calls to
the plugin, so that only public-facing methods are being used
- ArticleFeedbackv5.php:
- Added $wgArticleFeedbackv5LinkBuckets
- ArticleFeedbackv5.hooks.php:
- Updated to send $wgArticleFeedbackv5LinkBuckets to the modules

Bug fix: In some browsers, the bucket config was being read as an array rather
than an object, causing the bucketing to fail. This is fixed by using names
for the buckets that aren't numbers (e.g. display bucket '2' becomes 'two').
- ArticleFeedbackv5.php:
- Renamed the buckets in $wgArticleFeedbackv5DisplayBuckets
- modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js:
- Updated $.articleFeedbackv5.selectBucket() to convert named buckets
to numbered ones
Modified paths:
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.css (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js (modified) (history)
  • /trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.i18n.php
@@ -127,8 +127,10 @@
128128 'articlefeedbackv5-transparency-terms-linktext' => 'terms',
129129 'articlefeedbackv5-transparency-terms-url' => 'Project:Privacy_policy', // TODO: Confirm correct link
130130 'articlefeedbackv5-section-linktext' => 'feedback',
131 - 'articlefeedbackv5-toolbox-linktext' => 'Feedback',
 131+ 'articlefeedbackv5-titlebar-linktext' => 'Feedback',
 132+ 'articlefeedbackv5-toolbox-linktext' => 'Rate this page',
132133
 134+
133135 /* --- copied from AFTv4 and possibly not used --- */
134136 /* ArticleFeedback survey */
135137 'articlefeedbackv5-survey-question-origin' => 'What page were you on when you started this survey?',
@@ -285,6 +287,7 @@
286288 'articlefeedbackv5-transparency-terms-url' => 'The URL for the terms (can be translated; defaults to Project:Privacy_policy; Do not translate "Project:")',
287289 'articlefeedbackv5-section-linktext' => 'When a link to pop up the feedback tool appears on the article section headers, next to [edit], this will be the text inside the brackets immediately following (e.g. "[edit] [feedback]").',
288290 'articlefeedbackv5-toolbox-linktext' => 'When a link to pop up the feedback tool appears at the bottom of the toolbox area in the sidebar, this will be the link text.',
 291+ 'articlefeedbackv5-toolbox-linktext' => 'When a link to pop up the feedback tool appears just below the title bar to the far right, this will be the link text.',
289292
290293 /* --- copied from AFTv4 and possibly not used --- */
291294 /* ArticleFeedback survey */
Index: trunk/extensions/ArticleFeedbackv5/modules/jquery.articleFeedbackv5/jquery.articleFeedbackv5.js
@@ -1906,10 +1906,12 @@
19071907 } else if ( cookieval in knownBuckets ) {
19081908 $.articleFeedbackv5.bucketId = cookieval;
19091909 } else {
1910 - $.articleFeedbackv5.bucketId = mw.user.bucket(
 1910+ var bucketName = mw.user.bucket(
19111911 'ext.articleFeedbackv5-display',
19121912 mw.config.get( 'wgArticleFeedbackv5DisplayBuckets' )
19131913 );
 1914+ var nameMap = { zero: '0', one: '1', two: '2', three: '3', four: '4', five: '5' };
 1915+ $.articleFeedbackv5.bucketId = nameMap[bucketName];
19141916 }
19151917 // Drop in a cookie to keep track of their display bucket;
19161918 // use the config to determine how long to hold onto it.
@@ -2329,6 +2331,30 @@
23302332 };
23312333
23322334 // }}}
 2335+ // {{{ inDebug
 2336+
 2337+ /**
 2338+ * Returns whether the plugin is in debug mode
 2339+ *
 2340+ * @return int whether the plugin is in debug mode
 2341+ */
 2342+ $.articleFeedbackv5.inDebug = function () {
 2343+ return $.articleFeedbackv5.debug;
 2344+ };
 2345+
 2346+ // }}}
 2347+ // {{{ getBucketId
 2348+
 2349+ /**
 2350+ * Gets the bucket ID
 2351+ *
 2352+ * @return int the bucket ID
 2353+ */
 2354+ $.articleFeedbackv5.getBucketId = function () {
 2355+ return $.articleFeedbackv5.bucketId;
 2356+ };
 2357+
 2358+ // }}}
23332359 // {{{ openAsModal
23342360
23352361 /**
@@ -2396,6 +2422,12 @@
23972423 $.articleFeedbackv5.init( $( this ), opts );
23982424 } else if ( 'setLinkId' === opts ) {
23992425 $.articleFeedbackv5.setLinkId( arg );
 2426+ } else if ( 'getBucketId' === opts ) {
 2427+ return $.articleFeedbackv5.getBucketId();
 2428+ } else if ( 'inDebug' === opts ) {
 2429+ return $.articleFeedbackv5.inDebug();
 2430+ } else if ( 'prefix' === opts ) {
 2431+ return $.articleFeedbackv5.prefix( arg );
24002432 } else if ( 'openAsModal' === opts ) {
24012433 $.articleFeedbackv5.openAsModal( arg );
24022434 } else if ( 'closeAsModal' === opts ) {
Index: trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.css
@@ -1,16 +1,18 @@
2 -/*
3 - * Styles for Article Feedback Extension
4 - */
5 -#articleFeedback-dialog {
6 - padding: 2em;
7 - padding-top: 1em;
8 -}
 2+/** Styles for feedback links **/
93
10 -.articleFeedback-survey-disclaimer {
11 - font-weight: normal; /* Override bold */
12 - font-style: italic;
 4+#articleFeedbackv5-titlebarlink {
 5+ float: right;
 6+ font-size: 85%;
 7+ font-weight: bold;
 8+ line-height: 1.5em;
 9+ margin: 5px 0;
 10+ padding: 0;
 11+ position: absolute;
 12+ right: 0;
 13+ text-align: right;
 14+ text-indent: 0;
 15+ text-transform: none;
 16+ top: 0;
 17+ white-space: nowrap;
1318 }
1419
15 -.articleFeedback-survey-disclaimer a {
16 - color: #0645AD; /* Override blackish color set by JUI */
17 -}
Index: trunk/extensions/ArticleFeedbackv5/modules/ext.articleFeedbackv5/ext.articleFeedbackv5.js
@@ -3,6 +3,19 @@
44 */
55 ( function( $ ) {
66
 7+/* Load at the bottom of the article */
 8+var $aftDiv = $( '<div id="mw-articlefeedbackv5"></div>' ).articleFeedbackv5();
 9+
 10+// Put on bottom of article before #catlinks (if it exists)
 11+// Except in legacy skins, which have #catlinks above the article but inside content-div.
 12+var legacyskins = [ 'standard', 'cologneblue', 'nostalgia' ];
 13+if ( $( '#catlinks' ).length && $.inArray( mw.config.get( 'skin' ), legacyskins ) < 0 ) {
 14+ $aftDiv.insertBefore( '#catlinks' );
 15+} else {
 16+ // CologneBlue, Nostalgia, ...
 17+ mw.util.$content.append( $aftDiv );
 18+}
 19+
720 /* Setup for feedback links */
821
922 // Only track users who have been assigned to the tracking group
@@ -13,10 +26,13 @@
1427 // Info about each of the links
1528 var linkInfo = {
1629 '1': {
17 - clickTracking: $.articleFeedbackv5.prefix( 'section-link' )
 30+ clickTracking: $aftDiv.articleFeedbackv5( 'prefix', 'section-link' )
1831 },
 32+ '2': {
 33+ clickTracking: $aftDiv.articleFeedbackv5( 'prefix', 'titlebar-link' )
 34+ },
1935 '4': {
20 - clickTracking: $.articleFeedbackv5.prefix( 'toolbox-link' )
 36+ clickTracking: $aftDiv.articleFeedbackv5( 'prefix', 'toolbox-link' )
2137 }
2238 };
2339
@@ -26,47 +42,81 @@
2743 if ( useClickTracking && $.isFunction( $.trackActionWithInfo ) ) {
2844 $.trackActionWithInfo( linkInfo[ $link.data( 'linkId' ) ].clickTracking, mw.config.get( 'wgTitle' ) );
2945 }
30 - // Set the link id
31 - $( '#mw-articlefeedbackv5' ).articleFeedbackv5( 'openAsModal', $link );
32 -}
 46+ // Open as modal
 47+ $aftDiv.articleFeedbackv5( 'openAsModal', $link );
 48+};
3349
34 -/* Load at the bottom of the article */
35 -var $aftDiv = $( '<div id="mw-articlefeedbackv5"></div>' ).articleFeedbackv5();
 50+// Bucketing
 51+var linkBucket = function () {
 52+ // Find out which link bucket they go in:
 53+ // 1. Display buckets 0 or 5? Always zero.
 54+ // 2. Requested in query string (debug only)
 55+ // 3. Random bucketing
 56+ var displayBucket = $aftDiv.articleFeedbackv5( 'getBucketId' );
 57+ if ( '5' == displayBucket || '0' == displayBucket ) {
 58+ console.log( '5 or 0');
 59+ return '0';
 60+ }
 61+ var knownBuckets = { '0': true, '1': true, '2': true };
 62+ var requested = mw.util.getParamValue( 'aft_link' );
 63+ if ( $aftDiv.articleFeedbackv5( 'inDebug' ) && requested in knownBuckets ) {
 64+ console.log( 'requested ' + requested );
 65+ return requested;
 66+ } else {
 67+ console.log( 'bucketing' );
 68+ console.log( mw.config.get( 'wgArticleFeedbackv5LinkBuckets' ) );
 69+ console.log( mw.config.get( 'wgArticleFeedbackv5DisplayBuckets' ) );
 70+ var bucketName = mw.user.bucket( 'ext.articleFeedbackv5-links',
 71+ mw.config.get( 'wgArticleFeedbackv5LinkBuckets' )
 72+ );
 73+ var nameMap = { '-': 0, 'A': 1, 'B': 2 };
 74+ return nameMap[bucketName];
3675
37 -// Put on bottom of article before #catlinks (if it exists)
38 -// Except in legacy skins, which have #catlinks above the article but inside content-div.
39 -var legacyskins = [ 'standard', 'cologneblue', 'nostalgia' ];
40 -if ( $( '#catlinks' ).length && $.inArray( mw.config.get( 'skin' ), legacyskins ) < 0 ) {
41 - $aftDiv.insertBefore( '#catlinks' );
42 -} else {
43 - // CologneBlue, Nostalgia, ...
44 - mw.util.$content.append( $aftDiv );
 76+ }
 77+}();
 78+if ( $aftDiv.articleFeedbackv5( 'inDebug' ) ) {
 79+ console.log( 'Using link option #' + linkBucket );
4580 }
4681
4782 /* Add section links */
48 -$( 'span.editsection' ).append(
49 - '&nbsp;[' +
50 - '<a href="#mw-articlefeedbackv5" class="articleFeedbackv5-sectionlink">' +
51 - mw.msg( 'articlefeedbackv5-section-linktext' ) + '</a>' +
52 - ']'
53 -);
54 -$( 'span.editsection a.articleFeedbackv5-sectionlink' )
55 - .data( 'linkId', 1 )
56 - .click( function ( e ) {
57 - e.preventDefault();
58 - clickFeedbackLink( $( e.target ) );
59 - } );
 83+if ( '1' == linkBucket ) {
 84+ $( 'span.editsection' ).append(
 85+ '&nbsp;[' +
 86+ '<a href="#mw-articlefeedbackv5" class="articleFeedbackv5-sectionlink">' +
 87+ mw.msg( 'articlefeedbackv5-section-linktext' ) + '</a>' +
 88+ ']'
 89+ );
 90+ $( 'span.editsection a.articleFeedbackv5-sectionlink' )
 91+ .data( 'linkId', 1 )
 92+ .click( function ( e ) {
 93+ e.preventDefault();
 94+ clickFeedbackLink( $( e.target ) );
 95+ } );
 96+}
6097
61 -/* Add toolbox link */
62 -var $aftLink4 = $( '<li id="t-articlefeedbackv5"><a href="#mw-articlefeedbackv5"></a></li>' )
63 - .find( 'a' )
64 - .data( 'linkId', 4 )
65 - .text( mw.msg( 'articlefeedbackv5-toolbox-linktext' ) )
 98+/* Add titlebar link */
 99+if ( '2' == linkBucket ) {
 100+ $( '<a href="#mw-articleFeedbackv5" id="articleFeedbackv5-titlebarlink" />' )
 101+ .data( 'linkId', 2 )
 102+ .text( mw.msg( 'articlefeedbackv5-titlebar-linktext' ) )
66103 .click( function ( e ) {
67104 e.preventDefault();
68105 clickFeedbackLink( $( e.target ) );
69106 } )
70 - .end();
71 -$( '#p-tb' ).find( 'ul' ).append( $aftLink4 );
 107+ .insertBefore( $aftDiv );
 108+}
72109
 110+/* Add toolbox link */
 111+if ( '5' == $aftDiv.articleFeedbackv5( 'getBucketId' ) ) {
 112+ var $aftLink4 = $( '<li id="t-articlefeedbackv5"><a href="#mw-articlefeedbackv5"></a></li>' )
 113+ .find( 'a' )
 114+ .text( mw.msg( 'articlefeedbackv5-toolbox-linktext' ) )
 115+ .click( function ( e ) {
 116+ // Just set the link ID -- this should act just like AFTv4
 117+ $aftDiv.articleFeedbackv5( 'setLinkId', 4 );
 118+ } )
 119+ .end();
 120+ $( '#p-tb' ).find( 'ul' ).append( $aftLink4 );
 121+}
 122+
73123 } )( jQuery );
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.php
@@ -63,12 +63,12 @@
6464 // the new odds are applied to everyone, not just people who have yet to be
6565 // placed in a bucket.
6666 'buckets' => array(
67 - '0' => 17,
68 - '1' => 17,
69 - '2' => 17,
70 - '3' => 17,
71 - '4' => 16,
72 - '5' => 16,
 67+ 'zero' => 17,
 68+ 'one' => 17,
 69+ 'two' => 17,
 70+ 'three' => 17,
 71+ 'four' => 16,
 72+ 'five' => 16,
7373 ),
7474 // This version number is added to all tracking event names, so that
7575 // changes in the software don't corrupt the data being collected. Bump
@@ -82,7 +82,7 @@
8383 'tracked' => true
8484 );
8585
86 -// Bucket settings for tracking users
 86+// Bucket settings for click tracking on feedback links
8787 $wgArticleFeedbackv5Tracking = array(
8888 // Not all users need to be tracked, but we do want to track some users over time - these
8989 // buckets are used when deciding to track someone or not, placing them in one of two buckets:
@@ -97,13 +97,13 @@
9898 // This version number is added to all tracking event names, so that changes in the software
9999 // don't corrupt the data being collected. Bump this when you want to start a new "experiment".
100100 'version' => 0,
101 - // Let user's be tracked for a month, and then rebucket them, allowing some churn
 101+ // Let users be tracked for a month, and then rebucket them, allowing some churn
102102 'expires' => 30,
103103 // Track the event of users being bucketed - so we can be sure the odds worked out right
104104 'tracked' => true
105105 );
106106
107 -// Bucket settings for extra options in the UI
 107+// Bucket settings for extra expertise checkboxes in the Option 5 feedback form
108108 $wgArticleFeedbackv5Options = array(
109109 'buckets' => array(
110110 'show' => 100,
@@ -114,6 +114,31 @@
115115 'tracked' => true
116116 );
117117
 118+// Bucket settings for links to the feedback form
 119+$wgArticleFeedbackv5LinkBuckets = array(
 120+ // Users can fall into one of several buckets for links. These are:
 121+ // 0: No link; user must scroll to the bottom of the page
 122+ // 1: Section bars
 123+ // 2: Title bar
 124+ // 3: Vertical button
 125+ 'buckets' => array(
 126+ '-' => 0,
 127+ 'A' => 0,
 128+ 'B' => 100,
 129+ 'C' => 0,
 130+ ),
 131+ // This version number is added to all tracking event names, so that
 132+ // changes in the software don't corrupt the data being collected. Bump
 133+ // this when you want to start a new "experiment".
 134+ 'version' => 0,
 135+ // Let users be tracked for a month, and then rebucket them, allowing some
 136+ // churn.
 137+ 'expires' => 30,
 138+ // Track the event of users being bucketed - so we can be sure the odds
 139+ // worked out right.
 140+ 'tracked' => true
 141+);
 142+
118143 /**
119144 * The full URL for a discussion page about the Article Feedback Dashboard
120145 *
Index: trunk/extensions/ArticleFeedbackv5/ArticleFeedbackv5.hooks.php
@@ -20,6 +20,7 @@
2121 'styles' => 'ext.articleFeedbackv5/ext.articleFeedbackv5.css',
2222 'messages' => array(
2323 'articlefeedbackv5-section-linktext',
 24+ 'articlefeedbackv5-titlebar-linktext',
2425 'articlefeedbackv5-toolbox-linktext',
2526 ),
2627 'dependencies' => array(
@@ -216,6 +217,7 @@
217218 $wgArticleFeedbackv5DisplayBuckets,
218219 $wgArticleFeedbackv5Tracking,
219220 $wgArticleFeedbackv5Options,
 221+ $wgArticleFeedbackv5LinkBuckets,
220222 $wgArticleFeedbackv5Namespaces,
221223 $wgArticleFeedbackv5LearnToEdit;
222224 $vars['wgArticleFeedbackv5SMaxage'] = $wgArticleFeedbackv5SMaxage;
@@ -228,6 +230,7 @@
229231 $vars['wgArticleFeedbackv5DisplayBuckets'] = $wgArticleFeedbackv5DisplayBuckets;
230232 $vars['wgArticleFeedbackv5Tracking'] = $wgArticleFeedbackv5Tracking;
231233 $vars['wgArticleFeedbackv5Options'] = $wgArticleFeedbackv5Options;
 234+ $vars['wgArticleFeedbackv5LinkBuckets'] = $wgArticleFeedbackv5LinkBuckets;
232235 $vars['wgArticleFeedbackv5Namespaces'] = $wgArticleFeedbackv5Namespaces;
233236 $vars['wgArticleFeedbackv5LearnToEdit'] = $wgArticleFeedbackv5LearnToEdit;
234237 $vars['wgArticleFeedbackv5WhatsThisPage'] = wfMsgForContent( 'articlefeedbackv5-bucket5-form-panel-explanation-link' );

Status & tagging log