From f11b9e8c795f0828aff102af630fd9b194b80cdd Mon Sep 17 00:00:00 2001 From: Ori Livneh Date: Mon, 17 Jun 2013 17:04:29 -0700 Subject: [PATCH] Address Krinkle's review comments from I51c441d61 See . Change-Id: I14442070c0998d724d67ec41cca813ef5bce2c19 --- modules/ve/init/mw/ve.init.mw.splitTest.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/ve/init/mw/ve.init.mw.splitTest.js b/modules/ve/init/mw/ve.init.mw.splitTest.js index 592c6f0a77..6ff977977f 100644 --- a/modules/ve/init/mw/ve.init.mw.splitTest.js +++ b/modules/ve/init/mw/ve.init.mw.splitTest.js @@ -2,10 +2,6 @@ ( function ( mw, $ ) { 'use strict'; - if ( !mw.config.get( 'wgVisualEditorConfig', {} ).enableEventLogging ) { - return; - } - function log( action ) { var dfd = $.Deferred(); setTimeout( dfd.reject, 1000 ); @@ -25,29 +21,34 @@ return dfd; } + if ( !mw.config.get( 'wgVisualEditorConfig', {} ).enableEventLogging ) { + return; + } + mw.hook( 'postEdit' ).add( function () { log( 'page-save-success' ); } ); - if ( mw.config.get('wgAction') === 'edit' ) { + if ( mw.config.get( 'wgAction' ) === 'edit' ) { log( 'page-edit-impression' ); } // Log clicks on page edit and section edit links $( '#ca-edit a, .mw-editsection a' ).on( 'click', function ( e ) { - var href = this.href, - action = /section=/.test( href ) ? 'section-edit-link-click' : 'edit-link-click'; + var el = this, + action = /section=/.test( el.href ) ? 'section-edit-link-click' : 'edit-link-click'; + log( action ).always( function () { - window.location = href; + window.location = el.href; } ); e.preventDefault(); } ); // Log edit submit $( '#wpSave' ).one( 'click', function ( e ) { - var $save = $( this ); + var el = this; log( 'page-save-attempt' ).always( function () { - $save.trigger( 'click' ); + $( el ).trigger( 'click' ); } ); e.preventDefault(); } );