https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112649

Revision: 112649
Author:   kaldari
Date:     2012-02-28 21:47:55 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
fixing confusing module/file name - the existing ext module is a specific 
campaign for tracking sidebar clicks. Also separating throttling logic from 
module outputting logic in case people add some more modules and only want to 
enable some of them.

Modified Paths:
--------------
    trunk/extensions/ClickTracking/ClickTracking.hooks.php
    trunk/extensions/ClickTracking/ClickTracking.php

Added Paths:
-----------
    trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js

Removed Paths:
-------------
    trunk/extensions/ClickTracking/modules/ext.clickTracking.js

Modified: trunk/extensions/ClickTracking/ClickTracking.hooks.php
===================================================================
--- trunk/extensions/ClickTracking/ClickTracking.hooks.php      2012-02-28 
21:43:05 UTC (rev 112648)
+++ trunk/extensions/ClickTracking/ClickTracking.hooks.php      2012-02-28 
21:47:55 UTC (rev 112649)
@@ -71,9 +71,12 @@
        public static function beforePageDisplay( $out, $skin ) {
                global $wgClickTrackSidebar, $wgClickTrackThrottle;
                $out->addModules( 'ext.UserBuckets' );
-
-               if ( $wgClickTrackSidebar && $wgClickTrackThrottle >= 0 && 
rand() % $wgClickTrackThrottle == 0 ) {
-                       $out->addModules( 'ext.clickTracking' );
+               // Throttle ClickTracking if neccessary
+               // 1 out of every $wgClickTrackThrottle users will have 
ClickTracking enabled
+               if ( $wgClickTrackThrottle > 0 && rand() % 
$wgClickTrackThrottle == 0 ) {
+                       if ( $wgClickTrackSidebar ) {
+                               $out->addModules( 'ext.clickTrackingSidebar' );
+                       }
                }
                return true;
        }

Modified: trunk/extensions/ClickTracking/ClickTracking.php
===================================================================
--- trunk/extensions/ClickTracking/ClickTracking.php    2012-02-28 21:43:05 UTC 
(rev 112648)
+++ trunk/extensions/ClickTracking/ClickTracking.php    2012-02-28 21:47:55 UTC 
(rev 112649)
@@ -75,8 +75,8 @@
        'scripts' => 'jquery.clickTracking.js',
        'dependencies' => 'jquery.cookie',
 ) + $ctResourceTemplate;
-$wgResourceModules['ext.clickTracking'] = array(
-       'scripts' => 'ext.clickTracking.js',
+$wgResourceModules['ext.clickTrackingSidebar'] = array(
+       'scripts' => 'ext.clickTrackingSidebar.js',
        'dependencies' => 'jquery.clickTracking',
 ) + $ctResourceTemplate;
 $wgResourceModules['ext.UserBuckets'] = array(

Deleted: trunk/extensions/ClickTracking/modules/ext.clickTracking.js
===================================================================
--- trunk/extensions/ClickTracking/modules/ext.clickTracking.js 2012-02-28 
21:43:05 UTC (rev 112648)
+++ trunk/extensions/ClickTracking/modules/ext.clickTracking.js 2012-02-28 
21:47:55 UTC (rev 112649)
@@ -1,15 +0,0 @@
-/*
- * JavaScript for ClickTracking extension
- */
-
-jQuery( function( $ ) {
-       // Add click tracking hooks to the sidebar
-       $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( 
function() {
-               var $el = $(this), href = $el.attr( 'href' );
-               // Only modify local URLs
-               if ( href.length > 0 && href[0] == '/' && ( href.length == 1 || 
href[1] != '/' ) ) {
-                       var id = 'leftnav-' + skin + '-' + ( $el.attr( 'id' ) 
|| $el.parent().attr( 'id' ) );
-                       $el.attr( 'href', $.trackActionURL( href, id ) );
-               }
-       } );
-} );

Copied: trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js 
(from rev 112647, trunk/extensions/ClickTracking/modules/ext.clickTracking.js)
===================================================================
--- trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js          
                (rev 0)
+++ trunk/extensions/ClickTracking/modules/ext.clickTrackingSidebar.js  
2012-02-28 21:47:55 UTC (rev 112649)
@@ -0,0 +1,15 @@
+/*
+ * JavaScript for sidebar ClickTracking campaign
+ */
+
+jQuery( function( $ ) {
+       // Add click tracking hooks to the sidebar
+       $( '#p-logo a, #p-navigation a, #p-interaction a, #p-tb a' ).each( 
function() {
+               var $el = $(this), href = $el.attr( 'href' );
+               // Only modify local URLs
+               if ( href.length > 0 && href[0] == '/' && ( href.length == 1 || 
href[1] != '/' ) ) {
+                       var id = 'leftnav-' + skin + '-' + ( $el.attr( 'id' ) 
|| $el.parent().attr( 'id' ) );
+                       $el.attr( 'href', $.trackActionURL( href, id ) );
+               }
+       } );
+} );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to