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

Revision: 114717
Author:   catrope
Date:     2012-04-04 21:58:49 +0000 (Wed, 04 Apr 2012)
Log Message:
-----------
1.19wmf1: Merge https://gerrit.wikimedia.org/r/#change,4298

Modified Paths:
--------------
    
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
    
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js

Modified: 
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
 2012-04-04 19:11:50 UTC (rev 114716)
+++ 
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js
 2012-04-04 21:58:49 UTC (rev 114717)
@@ -26,7 +26,9 @@
  * @return Boolean: Whether the pitch is muted
  */
 function isPitchVisible( pitch ) {
-       return $.cookie( prefix( 'pitches-' + pitch ) ) != 'hide';
+       return true;
+       // Disabled per Dario
+       //return $.cookie( prefix( 'pitches-' + pitch ) ) != 'hide';
 }
 
 /**
@@ -36,24 +38,10 @@
  * @param durration Integer: Number of days to mute the pitch for
  */
 function mutePitch( pitch, duration ) {
-       $.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration, 
'path': '/' } );
+       // Disabled per Dario
+       //$.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': 
duration, 'path': '/' } );
 }
 
-function trackClick( id ) {
-       // Track the click so we can figure out how useful this is
-       if ( tracked && $.isFunction( $.trackActionWithInfo ) ) {
-               $.trackActionWithInfo( prefix( id ), mw.config.get( 'wgTitle' ) 
);
-       }
-}
-
-function trackClickURL( url, id ) {
-       if ( tracked && $.isFunction( $.trackActionURL ) ) {
-               return $.trackActionURL( url, prefix( id ) );
-       } else {
-               return url;
-       }
-}
-
 /**
  * Survey object
  * 
@@ -94,7 +82,7 @@
                                        'title': mw.msg( 
'articlefeedback-survey-title' ),
                                        'close': function() {
                                                // Click tracking
-                                               trackClick( 'survey-cancel' );
+                                               
$.articleFeedback.fn.trackClick( 'survey-cancel' );
                                                // Return the survey to default 
state
                                                $dialog.dialog( 'option', 
'height', 400 );
                                                $form.show();
@@ -173,7 +161,7 @@
                                        }
                                } );
                // Click tracking
-               trackClick( 'survey-submit-attempt' );
+               $.articleFeedback.fn.trackClick( 'survey-submit-attempt' );
                // XXX: Not only are we submitting to a special page instead of 
an API request, but we are
                // screen-scraping the result - this is evil and needs to be 
addressed later
                $.ajax( {
@@ -191,7 +179,7 @@
                                // Mute for 30 days
                                mutePitch( 'survey', 30 );
                                // Click tracking
-                               trackClick( 'survey-submit-complete' );
+                               $.articleFeedback.fn.trackClick( 
'survey-submit-complete' );
                        },
                        'error': function( XMLHttpRequest, textStatus, 
errorThrown ) {
                                // Take the dialog out of "loading" state
@@ -223,7 +211,7 @@
                        'action': function() {
                                survey.load();
                                // Click tracking
-                               trackClick( 'pitch-survey-accept' );
+                               $.articleFeedback.fn.trackClick( 
'pitch-survey-accept' );
                                // Hide the pitch immediately
                                return true;
                        },
@@ -243,7 +231,7 @@
                                mutePitch( 'join', 1 );
                                // Go to account creation page
                                // Track the click through an API redirect
-                               window.location = trackClickURL(
+                               window.location = 
$.articleFeedback.fn.trackActionURL(
                                        mw.config.get( 'wgScript' ) + '?' + 
$.param( {
                                                'title': 'Special:UserLogin',
                                                'type': 'signup',
@@ -263,7 +251,7 @@
                                mutePitch( 'join', 1 );
                                // Go to login page
                                // Track the click through an API redirect
-                               window.location = trackClickURL(
+                               window.location = 
$.articleFeedback.fn.trackActionURL(
                                        mw.config.get( 'wgScript' ) + '?' + 
$.param( {
                                                'title': 'Special:UserLogin',
                                                'returnto': mw.config.get( 
'wgPageName' )
@@ -299,7 +287,7 @@
                                        params.clicktrackingevent = prefix( 
'pitch-edit-save' );
                                }
                                // Track the click through an API redirect 
(automatically bypasses if !tracked)
-                               window.location = trackClickURL(
+                               window.location = 
$.articleFeedback.fn.trackActionURL(
                                        mw.config.get( 'wgScript' ) + '?' + 
$.param( params ), 'pitch-edit-accept'
                                );
                                return false;
@@ -333,7 +321,7 @@
                .click( function() {
                        // Click tracking
                        // Temporarily disabled per Dario's request --Roan
-                       //trackClick( 'toolbox-link' );
+                       //$.articleFeedback.fn.trackClick( 'toolbox-link' );
                        // Get the image, set the count and an interval.
                        var $box = $( '#mw-articlefeedback' );
                        var count = 0;

Modified: 
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
===================================================================
--- 
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
   2012-04-04 19:11:50 UTC (rev 114716)
+++ 
branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js
   2012-04-04 21:58:49 UTC (rev 114717)
@@ -135,6 +135,33 @@
                '
        },
        'fn': {
+               'trackClick': function( id ) {
+                       if ( track && typeof $.trackActionWithInfo == 
'function' ) {
+                               $.trackActionWithInfo( prefix( id ), 
mw.config.get( 'wgTitle' ) + '|' + mw.config.get( 'wgCurRevisionId' ) );
+                       }
+               },
+               /**
+                * Rewrites a URL to one that runs through the ClickTracking 
API module
+                * which registers the event and redirects to the real URL
+                *
+                * This is a copy of the one out of the clicktracking 
javascript API
+                * we have to do our OWN because there is no "additional" 
option in that
+                * API which we MUST use for the article title
+                *
+                * @param {string} url URL to redirect to
+                * @param {string} id Event identifier
+                */
+               'trackActionURL': function( url, id ) {
+                       return mw.config.get( 'wgScriptPath' ) + '/api.php?' + 
$.param( {
+                               'action': 'clicktracking',
+                               'format' : 'json',
+                               'eventid': prefix( id ),
+                               'namespacenumber': mw.config.get( 
'wgNamespaceNumber' ),
+                               'token': $.cookie( 'clicktracking-session' ),
+                               'additional': mw.config.get( 'wgTitle' ) + '|' 
+ mw.config.get( 'wgCurRevisionId' ),
+                               'redirectto': url
+                       } );
+               },
                'enableSubmission': function( state ) {
                        var context = this;
                        if ( state ) {
@@ -547,9 +574,7 @@
                                                                                
        { 'expires': 3, 'path': '/' }
                                                                                
);
                                                                                
// Track that a pitch was dismissed
-                                                                               
if ( tracked && typeof $.trackAction == 'function' ) {
-                                                                               
        $.trackAction( prefix( 'pitch-' + key + '-reject' ) );
-                                                                               
}
+                                                                               
$.articleFeedback.fn.trackClick( 'pitch-' + key + '-reject' );
                                                                                
$pitch.fadeOut( 'fast', function() {
                                                                                
        context.$ui.find( '.articleFeedback-ui' ).show();
                                                                                
} );
@@ -686,14 +711,10 @@
                                                                        
.fadeIn( 'fast' );
                                                        context.$ui.find( 
'.articleFeedback-ui' ).hide();
                                                        // Track that a pitch 
was presented
-                                                       if ( tracked && typeof 
$.trackAction == 'function' ) {
-                                                               $.trackAction( 
prefix( 'pitch-' + key + '-show' ) );
-                                                       }
+                                                       
$.articleFeedback.fn.trackClick( 'pitch-' + key + '-show' );
                                                } else {
                                                        // Track that a pitch 
was not presented
-                                                       if ( tracked && typeof 
$.trackAction == 'function' ) {
-                                                               $.trackAction( 
prefix( 'pitch-bypass' ) );
-                                                       }
+                                                       
$.articleFeedback.fn.trackClick( 'pitch-' + key + '-bypass' );
                                                        // Give user some 
feedback that a save occured
                                                        context.$ui.find( 
'.articleFeedback-success span' ).fadeIn( 'fast' );
                                                        context.successTimeout 
= setTimeout( function() {


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

Reply via email to