r83056 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83055‎ | r83056 | r83057 >
Date:23:41, 1 March 2011
Author:tparscal
Status:ok
Tags:
Comment:
Added ext.vector.sectionEditLink module which moves the section edit links to be next to the heading text and have a pencil icon. Also implemented bucket testing and click tracking.
Modified paths:
  • /trunk/extensions/Vector/Vector.hooks.php (modified) (history)
  • /trunk/extensions/Vector/Vector.php (modified) (history)
  • /trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.css (added) (history)
  • /trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.js (added) (history)

Diff [purge]

Index: trunk/extensions/Vector/Vector.php
@@ -22,6 +22,7 @@
2323 'editwarning' => array( 'global' => false, 'user' => true ),
2424 'expandablesearch' => array( 'global' => false, 'user' => false ),
2525 'footercleanup' => array( 'global' => false, 'user' => false ),
 26+ 'sectioneditlinks' => array( 'global' => false, 'user' => false ),
2627 'simplesearch' => array( 'global' => false, 'user' => true ),
2728 );
2829
@@ -33,6 +34,12 @@
3435 // Force the new version
3536 $wgCollapsibleNavForceNewVersion = false;
3637
 38+// Enable bucket testing for new version of section edit links
 39+$wgVectorSectionEditLinksBucketTest = false;
 40+// Percentage of users who's use of section edit links will be tracked - half of which will see the
 41+// new section edit links - default 5%
 42+$wgVectorSectionEditLinksLotteryOdds = 5;
 43+
3744 /* Setup */
3845
3946 $wgExtensionCredits['other'][] = array(
@@ -93,6 +100,13 @@
94101 'scripts' => 'ext.vector.footerCleanup.js',
95102 'styles' => 'ext.vector.footerCleanup.css',
96103 ),
 104+ 'ext.vector.sectionEditLinks' => $vectorResourceTemplate + array(
 105+ 'scripts' => 'ext.vector.sectionEditLinks.js',
 106+ 'styles' => 'ext.vector.sectionEditLinks.css',
 107+ 'dependencies' => array(
 108+ 'jquery.cookie',
 109+ ),
 110+ ),
97111 'ext.vector.simpleSearch' => $vectorResourceTemplate + array(
98112 'scripts' => 'ext.vector.simpleSearch.js',
99113 'messages' => array(
Index: trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.css
@@ -0,0 +1,13 @@
 2+span.vector-editLink {
 3+ float: none;
 4+ display: inline-block;
 5+}
 6+span.vector-editLink a {
 7+ padding-left: 18px;
 8+ background-image: url(images/edit-faded.png);
 9+ background-position: left top;
 10+ background-repeat: no-repeat;
 11+}
 12+span.vector-editLink a:hover {
 13+ background-image: url(images/edit.png);
 14+}
Property changes on: trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.css
___________________________________________________________________
Added: svn:mime-type
115 + text/plain
Index: trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.js
@@ -0,0 +1,53 @@
 2+/*
 3+ * Section Edit Links for Vector
 4+ */
 5+( function( $, mw ) {
 6+
 7+if ( mw.config.get( 'wgVectorSectionEditLinksBucketTest', false ) ) {
 8+ var bucket = $.cookie( 'ext.vector.sectionEditLinks-bucket' );
 9+ if ( bucket === null ) {
 10+ // Percentage chance of being tracked
 11+ var odds = Math.min( 100, Math.max( 0,
 12+ Number( mw.config.get( 'wgVectorSectionEditLinksLotteryOdds', 0 ) )
 13+ ) );
 14+ // 0 = not tracked, 1 = tracked with old version, 2 = tracked with new version
 15+ bucket = ( Math.random() * 100 ) < odds ? Number( Math.random() < 0.5 ) + 1 : 0;
 16+ $.cookie( 'ext.vector.sectionEditLinks-bucket', bucket );
 17+ }
 18+}
 19+if ( bucket ) {
 20+ // Transform the targets of section edit links to route through the click tracking API
 21+ $( 'span.editsection a' ).each( function() {
 22+ $(this).attr( 'href', mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( {
 23+ 'action': 'clicktracking',
 24+ 'eventid': 'ext.vector.sectionEditLinks-bucket' + bucket + '-click',
 25+ 'token': $.cookie( 'clicktracking-session' ),
 26+ 'redirectto': $( this ).attr( 'href' )
 27+ } ) );
 28+ } );
 29+ if ( bucket == 2 ) {
 30+ // Move the link over to be next to the heading text and style it with an icon
 31+ $( 'span.mw-headline' ).each( function() {
 32+ $(this)
 33+ .after(
 34+ $( '<span class="editsection vector-editLink"></span>' )
 35+ .append(
 36+ $(this)
 37+ .prev( 'span.editsection' )
 38+ .find( 'a' )
 39+ .each( function() {
 40+ var text = $(this).text();
 41+ $(this).text(
 42+ text.substr( 0, 1 ).toUpperCase() + text.substr( 1 )
 43+ );
 44+ } )
 45+ .detach()
 46+ )
 47+ )
 48+ .prev( 'span.editsection' )
 49+ .remove();
 50+ } );
 51+ }
 52+}
 53+
 54+} )( jQuery, mediaWiki );
Property changes on: trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.js
___________________________________________________________________
Added: svn:mime-type
155 + text/plain
Index: trunk/extensions/Vector/Vector.hooks.php
@@ -52,6 +52,13 @@
5353 'footercleanup' => array(
5454 'modules' => array( 'ext.vector.footerCleanup' ),
5555 ),
 56+ 'sectioneditlinks' => array(
 57+ 'modules' => array( 'ext.vector.sectionEditLinks' ),
 58+ 'configurations' => array(
 59+ 'wgVectorSectionEditLinksBucketTest',
 60+ 'wgVectorSectionEditLinksLotteryOdds',
 61+ ),
 62+ ),
5663 'simplesearch' => array(
5764 'requirements' => array( 'vector-simplesearch' => true, 'disablesuggest' => false ),
5865 'modules' => array( 'ext.vector.simpleSearch' ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r83057Added images for ext.vector.sectionEditLinks module - follow up to r83056tparscal23:52, 1 March 2011
r836001.17wmf1: Merge Vector edit section links module plus required ClickTracking ...catrope18:55, 9 March 2011

Status & tagging log