2013-06-17 21:12:21 +00:00
|
|
|
/*global mediaWiki */
|
|
|
|
( function ( mw, $ ) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function log( action ) {
|
|
|
|
var dfd = $.Deferred();
|
|
|
|
setTimeout( dfd.reject, 1000 );
|
|
|
|
mw.loader.using( 'schema.Edit', function () {
|
|
|
|
mw.eventLog.logEvent( 'Edit', {
|
|
|
|
version: 0,
|
|
|
|
action: action,
|
|
|
|
editor: 'wikitext',
|
|
|
|
pageId: mw.config.get( 'wgArticleId' ),
|
|
|
|
pageNs: mw.config.get( 'wgNamespaceNumber' ),
|
|
|
|
pageName: mw.config.get( 'wgPageName' ),
|
|
|
|
pageViewSessionId: mw.user.generateRandomSessionId(),
|
|
|
|
revId: mw.config.get( 'wgCurRevisionId' ),
|
|
|
|
userId: +mw.config.get( 'wgUserId' )
|
|
|
|
} ).always( dfd.resolve );
|
|
|
|
} );
|
|
|
|
return dfd;
|
|
|
|
}
|
|
|
|
|
2013-06-18 00:04:29 +00:00
|
|
|
if ( !mw.config.get( 'wgVisualEditorConfig', {} ).enableEventLogging ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-17 21:12:21 +00:00
|
|
|
mw.hook( 'postEdit' ).add( function () {
|
|
|
|
log( 'page-save-success' );
|
|
|
|
} );
|
|
|
|
|
2013-06-18 00:04:29 +00:00
|
|
|
if ( mw.config.get( 'wgAction' ) === 'edit' ) {
|
2013-06-17 21:12:21 +00:00
|
|
|
log( 'page-edit-impression' );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Log clicks on page edit and section edit links
|
|
|
|
$( '#ca-edit a, .mw-editsection a' ).on( 'click', function ( e ) {
|
2013-06-18 00:04:29 +00:00
|
|
|
var el = this,
|
|
|
|
action = /section=/.test( el.href ) ? 'section-edit-link-click' : 'edit-link-click';
|
|
|
|
|
2013-06-17 21:12:21 +00:00
|
|
|
log( action ).always( function () {
|
2013-06-18 00:04:29 +00:00
|
|
|
window.location = el.href;
|
2013-06-17 21:12:21 +00:00
|
|
|
} );
|
|
|
|
e.preventDefault();
|
|
|
|
} );
|
|
|
|
|
|
|
|
// Log edit submit
|
|
|
|
$( '#wpSave' ).one( 'click', function ( e ) {
|
2013-06-18 00:04:29 +00:00
|
|
|
var el = this;
|
2013-06-17 21:12:21 +00:00
|
|
|
log( 'page-save-attempt' ).always( function () {
|
2013-06-18 00:04:29 +00:00
|
|
|
$( el ).trigger( 'click' );
|
2013-06-17 21:12:21 +00:00
|
|
|
} );
|
|
|
|
e.preventDefault();
|
|
|
|
} );
|
|
|
|
|
|
|
|
} ( mediaWiki, jQuery ) );
|