mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-18 11:46:01 +00:00
f11b9e8c79
See <https://gerrit.wikimedia.org/r/#/c/69161/1/modules/ve/init/mw/ve.init.mw.splitTest.js>. Change-Id: I14442070c0998d724d67ec41cca813ef5bce2c19
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
/*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;
|
|
}
|
|
|
|
if ( !mw.config.get( 'wgVisualEditorConfig', {} ).enableEventLogging ) {
|
|
return;
|
|
}
|
|
|
|
mw.hook( 'postEdit' ).add( function () {
|
|
log( 'page-save-success' );
|
|
} );
|
|
|
|
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 el = this,
|
|
action = /section=/.test( el.href ) ? 'section-edit-link-click' : 'edit-link-click';
|
|
|
|
log( action ).always( function () {
|
|
window.location = el.href;
|
|
} );
|
|
e.preventDefault();
|
|
} );
|
|
|
|
// Log edit submit
|
|
$( '#wpSave' ).one( 'click', function ( e ) {
|
|
var el = this;
|
|
log( 'page-save-attempt' ).always( function () {
|
|
$( el ).trigger( 'click' );
|
|
} );
|
|
e.preventDefault();
|
|
} );
|
|
|
|
} ( mediaWiki, jQuery ) );
|