r65379 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65378‎ | r65379 | r65380 >
Date:13:30, 21 April 2010
Author:tparscal
Status:ok
Tags:
Comment:
Changed from using click handlers on the links to modifying the href attributes of the links. This fixes the issue seen in bug #23267.
Modified paths:
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js
@@ -1,26 +1,23 @@
2 -(function($) {
3 - if( !wgClickTrackingIsThrottled ) {
4 - // creates 'track action' function to call the clicktracking API and send the ID
5 - $.trackAction = function ( id ) {
6 - $j.post( wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken } );
 2+( function( $ ) {
 3+ if ( !wgClickTrackingIsThrottled ) {
 4+ // Create 'track action' function to call the clicktracking API and send the ID
 5+ $.trackAction = function( id ) {
 6+ $j.post(
 7+ wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken }
 8+ );
79 };
8 -
9 - // Clicktrack the left sidebar links
 10+ // Add click tracking hooks to the sidebar
1011 $j(document).ready( function() {
11 - $( '#p-logo a, #p-navigation a, #p-tb a' ).click( function() {
12 - var id = 'leftnav-' + skin + '-' +
13 - ( $(this).attr( 'id' ) || $(this).parent().attr( 'id' ) );
 12+ $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( function() {
1413 var href = $(this).attr( 'href' );
15 - // Don't attach to javascript: URLs and the like,
16 - // only to local URLs (start with a /), http:// ,
17 - // https:// and same-protocol URLs (start with //)
18 - if ( href[0] == '/' || href.match( /^https?:\/\// ) )
19 - window.location = wgScriptPath +
20 - '/api.php?action=clicktracking&eventid=' +
21 - id + '&token=' + wgTrackingToken +
22 - '&redirectto=' + escape( href );
23 - });
24 - });
 14+ // Only modify local and same-schema URLs
 15+ if ( href[0] == '/' || href.match( /^https?:\/\// ) ) {
 16+ var id = 'leftnav-' + skin + '-' + ( $(this).attr( 'id' ) || $(this).parent().attr( 'id' ) );
 17+ href = wgScriptPath + '/api.php?action=clicktracking' +
 18+ '&eventid=' + id + '&token=' + wgTrackingToken + '&redirectto=' + escape( href );
 19+ $(this).attr( 'href', href );
 20+ }
 21+ } );
 22+ } );
2523 }
26 -
27 -})(jQuery);
 24+} )( jQuery );

Follow-up revisions

RevisionCommit summaryAuthorDate
r65959Merge Vector and UsabilityInitiative fixes from trunk: r64724, r65064, r65379...catrope19:03, 5 May 2010

Status & tagging log