Index: branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/jquery.articleFeedback/jquery.articleFeedback.js |
— | — | @@ -135,6 +135,33 @@ |
136 | 136 | ' |
137 | 137 | }, |
138 | 138 | 'fn': { |
| 139 | + 'trackClick': function( id ) { |
| 140 | + if ( track && typeof $.trackActionWithInfo == 'function' ) { |
| 141 | + $.trackActionWithInfo( prefix( id ), mw.config.get( 'wgTitle' ) + '|' + mw.config.get( 'wgCurRevisionId' ) ); |
| 142 | + } |
| 143 | + }, |
| 144 | + /** |
| 145 | + * Rewrites a URL to one that runs through the ClickTracking API module |
| 146 | + * which registers the event and redirects to the real URL |
| 147 | + * |
| 148 | + * This is a copy of the one out of the clicktracking javascript API |
| 149 | + * we have to do our OWN because there is no "additional" option in that |
| 150 | + * API which we MUST use for the article title |
| 151 | + * |
| 152 | + * @param {string} url URL to redirect to |
| 153 | + * @param {string} id Event identifier |
| 154 | + */ |
| 155 | + 'trackActionURL': function( url, id ) { |
| 156 | + return mw.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( { |
| 157 | + 'action': 'clicktracking', |
| 158 | + 'format' : 'json', |
| 159 | + 'eventid': prefix( id ), |
| 160 | + 'namespacenumber': mw.config.get( 'wgNamespaceNumber' ), |
| 161 | + 'token': $.cookie( 'clicktracking-session' ), |
| 162 | + 'additional': mw.config.get( 'wgTitle' ) + '|' + mw.config.get( 'wgCurRevisionId' ), |
| 163 | + 'redirectto': url |
| 164 | + } ); |
| 165 | + }, |
139 | 166 | 'enableSubmission': function( state ) { |
140 | 167 | var context = this; |
141 | 168 | if ( state ) { |
— | — | @@ -547,9 +574,7 @@ |
548 | 575 | { 'expires': 3, 'path': '/' } |
549 | 576 | ); |
550 | 577 | // Track that a pitch was dismissed |
551 | | - if ( tracked && typeof $.trackAction == 'function' ) { |
552 | | - $.trackAction( prefix( 'pitch-' + key + '-reject' ) ); |
553 | | - } |
| 578 | + $.articleFeedback.fn.trackClick( 'pitch-' + key + '-reject' ); |
554 | 579 | $pitch.fadeOut( 'fast', function() { |
555 | 580 | context.$ui.find( '.articleFeedback-ui' ).show(); |
556 | 581 | } ); |
— | — | @@ -686,14 +711,10 @@ |
687 | 712 | .fadeIn( 'fast' ); |
688 | 713 | context.$ui.find( '.articleFeedback-ui' ).hide(); |
689 | 714 | // Track that a pitch was presented |
690 | | - if ( tracked && typeof $.trackAction == 'function' ) { |
691 | | - $.trackAction( prefix( 'pitch-' + key + '-show' ) ); |
692 | | - } |
| 715 | + $.articleFeedback.fn.trackClick( 'pitch-' + key + '-show' ); |
693 | 716 | } else { |
694 | 717 | // Track that a pitch was not presented |
695 | | - if ( tracked && typeof $.trackAction == 'function' ) { |
696 | | - $.trackAction( prefix( 'pitch-bypass' ) ); |
697 | | - } |
| 718 | + $.articleFeedback.fn.trackClick( 'pitch-' + key + '-bypass' ); |
698 | 719 | // Give user some feedback that a save occured |
699 | 720 | context.$ui.find( '.articleFeedback-success span' ).fadeIn( 'fast' ); |
700 | 721 | context.successTimeout = setTimeout( function() { |
Index: branches/wmf/1.19wmf1/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -26,7 +26,9 @@ |
27 | 27 | * @return Boolean: Whether the pitch is muted |
28 | 28 | */ |
29 | 29 | function isPitchVisible( pitch ) { |
30 | | - return $.cookie( prefix( 'pitches-' + pitch ) ) != 'hide'; |
| 30 | + return true; |
| 31 | + // Disabled per Dario |
| 32 | + //return $.cookie( prefix( 'pitches-' + pitch ) ) != 'hide'; |
31 | 33 | } |
32 | 34 | |
33 | 35 | /** |
— | — | @@ -36,24 +38,10 @@ |
37 | 39 | * @param durration Integer: Number of days to mute the pitch for |
38 | 40 | */ |
39 | 41 | function mutePitch( pitch, duration ) { |
40 | | - $.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration, 'path': '/' } ); |
| 42 | + // Disabled per Dario |
| 43 | + //$.cookie( prefix( 'pitches-' + pitch ), 'hide', { 'expires': duration, 'path': '/' } ); |
41 | 44 | } |
42 | 45 | |
43 | | -function trackClick( id ) { |
44 | | - // Track the click so we can figure out how useful this is |
45 | | - if ( tracked && $.isFunction( $.trackActionWithInfo ) ) { |
46 | | - $.trackActionWithInfo( prefix( id ), mw.config.get( 'wgTitle' ) ); |
47 | | - } |
48 | | -} |
49 | | - |
50 | | -function trackClickURL( url, id ) { |
51 | | - if ( tracked && $.isFunction( $.trackActionURL ) ) { |
52 | | - return $.trackActionURL( url, prefix( id ) ); |
53 | | - } else { |
54 | | - return url; |
55 | | - } |
56 | | -} |
57 | | - |
58 | 46 | /** |
59 | 47 | * Survey object |
60 | 48 | * |
— | — | @@ -94,7 +82,7 @@ |
95 | 83 | 'title': mw.msg( 'articlefeedback-survey-title' ), |
96 | 84 | 'close': function() { |
97 | 85 | // Click tracking |
98 | | - trackClick( 'survey-cancel' ); |
| 86 | + $.articleFeedback.fn.trackClick( 'survey-cancel' ); |
99 | 87 | // Return the survey to default state |
100 | 88 | $dialog.dialog( 'option', 'height', 400 ); |
101 | 89 | $form.show(); |
— | — | @@ -173,7 +161,7 @@ |
174 | 162 | } |
175 | 163 | } ); |
176 | 164 | // Click tracking |
177 | | - trackClick( 'survey-submit-attempt' ); |
| 165 | + $.articleFeedback.fn.trackClick( 'survey-submit-attempt' ); |
178 | 166 | // XXX: Not only are we submitting to a special page instead of an API request, but we are |
179 | 167 | // screen-scraping the result - this is evil and needs to be addressed later |
180 | 168 | $.ajax( { |
— | — | @@ -191,7 +179,7 @@ |
192 | 180 | // Mute for 30 days |
193 | 181 | mutePitch( 'survey', 30 ); |
194 | 182 | // Click tracking |
195 | | - trackClick( 'survey-submit-complete' ); |
| 183 | + $.articleFeedback.fn.trackClick( 'survey-submit-complete' ); |
196 | 184 | }, |
197 | 185 | 'error': function( XMLHttpRequest, textStatus, errorThrown ) { |
198 | 186 | // Take the dialog out of "loading" state |
— | — | @@ -223,7 +211,7 @@ |
224 | 212 | 'action': function() { |
225 | 213 | survey.load(); |
226 | 214 | // Click tracking |
227 | | - trackClick( 'pitch-survey-accept' ); |
| 215 | + $.articleFeedback.fn.trackClick( 'pitch-survey-accept' ); |
228 | 216 | // Hide the pitch immediately |
229 | 217 | return true; |
230 | 218 | }, |
— | — | @@ -243,7 +231,7 @@ |
244 | 232 | mutePitch( 'join', 1 ); |
245 | 233 | // Go to account creation page |
246 | 234 | // Track the click through an API redirect |
247 | | - window.location = trackClickURL( |
| 235 | + window.location = $.articleFeedback.fn.trackActionURL( |
248 | 236 | mw.config.get( 'wgScript' ) + '?' + $.param( { |
249 | 237 | 'title': 'Special:UserLogin', |
250 | 238 | 'type': 'signup', |
— | — | @@ -263,7 +251,7 @@ |
264 | 252 | mutePitch( 'join', 1 ); |
265 | 253 | // Go to login page |
266 | 254 | // Track the click through an API redirect |
267 | | - window.location = trackClickURL( |
| 255 | + window.location = $.articleFeedback.fn.trackActionURL( |
268 | 256 | mw.config.get( 'wgScript' ) + '?' + $.param( { |
269 | 257 | 'title': 'Special:UserLogin', |
270 | 258 | 'returnto': mw.config.get( 'wgPageName' ) |
— | — | @@ -299,7 +287,7 @@ |
300 | 288 | params.clicktrackingevent = prefix( 'pitch-edit-save' ); |
301 | 289 | } |
302 | 290 | // Track the click through an API redirect (automatically bypasses if !tracked) |
303 | | - window.location = trackClickURL( |
| 291 | + window.location = $.articleFeedback.fn.trackActionURL( |
304 | 292 | mw.config.get( 'wgScript' ) + '?' + $.param( params ), 'pitch-edit-accept' |
305 | 293 | ); |
306 | 294 | return false; |
— | — | @@ -333,7 +321,7 @@ |
334 | 322 | .click( function() { |
335 | 323 | // Click tracking |
336 | 324 | // Temporarily disabled per Dario's request --Roan |
337 | | - //trackClick( 'toolbox-link' ); |
| 325 | + //$.articleFeedback.fn.trackClick( 'toolbox-link' ); |
338 | 326 | // Get the image, set the count and an interval. |
339 | 327 | var $box = $( '#mw-articlefeedback' ); |
340 | 328 | var count = 0; |