mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-24 08:14:33 +00:00
Merge "Try to unbreak WikiEditor modules"
This commit is contained in:
commit
4850e6cefa
|
@ -60,11 +60,9 @@ $wgHooks['BeforePageDisplay'][] = 'WikiEditorHooks::onBeforePageDisplay';
|
|||
$wgHooks['EditPage::attemptSave'][] = 'WikiEditorHooks::editPageAttemptSave';
|
||||
$wgHooks['EditPage::attemptSave:after'][] = 'WikiEditorHooks::editPageAttemptSaveAfter';
|
||||
|
||||
$wikiEditorBaseTpl = array(
|
||||
$wikiEditorTpl = array(
|
||||
'localBasePath' => __DIR__ . '/modules',
|
||||
'remoteExtPath' => 'WikiEditor/modules',
|
||||
);
|
||||
$wikiEditorTpl = $wikiEditorBaseTpl + array(
|
||||
'group' => 'ext.wikiEditor',
|
||||
);
|
||||
|
||||
|
@ -364,17 +362,10 @@ $wgResourceModules += array(
|
|||
|
||||
/* WikiEditor Resources */
|
||||
|
||||
'ext.wikiEditor.init' => $wikiEditorBaseTpl + array(
|
||||
// Use wikiEditorBaseTpl so that no group is specified.
|
||||
// The init module is loaded on all pages and would otherwise
|
||||
// require a separate http request.
|
||||
'scripts' => 'ext.wikiEditor.init.js'
|
||||
),
|
||||
'ext.wikiEditor' => $wikiEditorTpl + array(
|
||||
'scripts' => 'ext.wikiEditor.js',
|
||||
'styles' => 'ext.wikiEditor.less',
|
||||
'dependencies' => array(
|
||||
'ext.wikiEditor.init',
|
||||
'jquery.wikiEditor'
|
||||
),
|
||||
),
|
||||
|
|
|
@ -339,15 +339,11 @@
|
|||
"wikieditor-toolbar-help-content-indent-result"
|
||||
]
|
||||
},
|
||||
"ext.wikiEditor.init": {
|
||||
"scripts": "ext.wikiEditor.init.js"
|
||||
},
|
||||
"ext.wikiEditor": {
|
||||
"group": "ext.wikiEditor",
|
||||
"scripts": "ext.wikiEditor.js",
|
||||
"styles": "ext.wikiEditor.less",
|
||||
"dependencies": [
|
||||
"ext.wikiEditor.init",
|
||||
"jquery.wikiEditor"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/*!
|
||||
* WikiEditor extension initialisation
|
||||
* @copyright 2015 Wikimedia Foundation and Alex Monk
|
||||
* @license GPL; see COPYING
|
||||
*/
|
||||
|
||||
( function ( mw, $ ) {
|
||||
mw.wikiEditor = {
|
||||
logEditEvent: function ( action, data ) {
|
||||
if ( mw.loader.getState( 'schema.Edit' ) === null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mw.loader.using( 'schema.Edit' ).done( function () {
|
||||
data = $.extend( {
|
||||
version: 1,
|
||||
action: action,
|
||||
editor: 'wikitext',
|
||||
platform: 'desktop', // FIXME
|
||||
integration: 'page',
|
||||
'page.id': mw.config.get( 'wgArticleId' ),
|
||||
'page.title': mw.config.get( 'wgPageName' ),
|
||||
'page.ns': mw.config.get( 'wgNamespaceNumber' ),
|
||||
'page.revid': mw.config.get( 'wgRevisionId' ),
|
||||
'page.length': -1, // FIXME
|
||||
'user.id': mw.user.getId(),
|
||||
'user.editCount': mw.config.get( 'wgUserEditCount', 0 ),
|
||||
'mediawiki.version': mw.config.get( 'wgVersion' )
|
||||
}, data );
|
||||
|
||||
if ( mw.user.isAnon() ) {
|
||||
data['user.class'] = 'IP';
|
||||
}
|
||||
|
||||
data['action.' + action + '.type'] = data.type;
|
||||
data['action.' + action + '.mechanism'] = data.mechanism;
|
||||
data['action.' + action + '.timing'] = data.timing === undefined ?
|
||||
0 : Math.floor( data.timing );
|
||||
// Remove renamed properties
|
||||
delete data.type;
|
||||
delete data.mechanism;
|
||||
delete data.timing;
|
||||
|
||||
mw.eventLog.logEvent( 'Edit', data );
|
||||
} );
|
||||
}
|
||||
};
|
||||
}( mediaWiki, jQuery ) );
|
|
@ -1,7 +1,80 @@
|
|||
/*
|
||||
* JavaScript for WikiEditor
|
||||
*/
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
// Initialize wikiEditor
|
||||
$( '#wpTextbox1' ).wikiEditor();
|
||||
} );
|
||||
|
||||
( function ( $, mw ) {
|
||||
function logEditEvent( action, data ) {
|
||||
if ( mw.loader.getState( 'schema.Edit' ) === null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
mw.loader.using( 'schema.Edit' ).done( function () {
|
||||
data = $.extend( {
|
||||
version: 1,
|
||||
action: action,
|
||||
editor: 'wikitext',
|
||||
platform: 'desktop', // FIXME
|
||||
integration: 'page',
|
||||
'page.id': mw.config.get( 'wgArticleId' ),
|
||||
'page.title': mw.config.get( 'wgPageName' ),
|
||||
'page.ns': mw.config.get( 'wgNamespaceNumber' ),
|
||||
'page.revid': mw.config.get( 'wgRevisionId' ),
|
||||
'page.length': -1, // FIXME
|
||||
'user.id': mw.user.getId(),
|
||||
'user.editCount': mw.config.get( 'wgUserEditCount', 0 ),
|
||||
'mediawiki.version': mw.config.get( 'wgVersion' )
|
||||
}, data );
|
||||
|
||||
if ( mw.user.isAnon() ) {
|
||||
data['user.class'] = 'IP';
|
||||
}
|
||||
|
||||
data['action.' + action + '.type'] = data.type;
|
||||
data['action.' + action + '.mechanism'] = data.mechanism;
|
||||
data['action.' + action + '.timing'] = data.timing === undefined ?
|
||||
0 : Math.floor( data.timing );
|
||||
// Remove renamed properties
|
||||
delete data.type;
|
||||
delete data.mechanism;
|
||||
delete data.timing;
|
||||
|
||||
mw.eventLog.logEvent( 'Edit', data );
|
||||
} );
|
||||
}
|
||||
|
||||
$( function () {
|
||||
var $textarea = $( '#wpTextbox1' ),
|
||||
editingSessionIdInput = $( '#editingStatsId' ),
|
||||
editingSessionId, submitting, onUnloadFallback;
|
||||
|
||||
// Initialize wikiEditor
|
||||
$textarea.wikiEditor();
|
||||
|
||||
if ( editingSessionIdInput.length ) {
|
||||
editingSessionId = editingSessionIdInput.val();
|
||||
logEditEvent( 'ready', {
|
||||
editingSessionId: editingSessionId
|
||||
} );
|
||||
$textarea.closest( 'form' ).submit( function () {
|
||||
submitting = true;
|
||||
} );
|
||||
onUnloadFallback = window.onunload;
|
||||
window.onunload = function () {
|
||||
var fallbackResult;
|
||||
|
||||
if ( onUnloadFallback ) {
|
||||
fallbackResult = onUnloadFallback();
|
||||
}
|
||||
|
||||
if ( !submitting ) {
|
||||
logEditEvent( 'abort', {
|
||||
editingSessionId: editingSessionId,
|
||||
// TODO: abort.type
|
||||
} );
|
||||
}
|
||||
|
||||
return fallbackResult;
|
||||
};
|
||||
}
|
||||
} );
|
||||
}( jQuery, mediaWiki ) );
|
|
@ -501,9 +501,7 @@ if ( !context || typeof context === 'undefined' ) {
|
|||
*/
|
||||
/* Preserving cursor and focus state, which will get lost due to wrapAll */
|
||||
var hasFocus = context.$textarea.is( ':focus' ),
|
||||
cursorPos = context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } ),
|
||||
editingSessionIdInput = context.$textarea.closest( 'form' ).find( '#editingStatsId' ),
|
||||
editingSessionId;
|
||||
cursorPos = context.$textarea.textSelection( 'getCaretPosition', { startAndEnd: true } );
|
||||
// Encapsulate the textarea with some containers for layout
|
||||
context.$textarea
|
||||
/* Disabling our loading div for now
|
||||
|
@ -551,33 +549,6 @@ if ( !context || typeof context === 'undefined' ) {
|
|||
$( window ).resize( function ( event ) {
|
||||
context.fn.trigger( 'resize', event );
|
||||
} );
|
||||
|
||||
if ( editingSessionIdInput.length ) {
|
||||
editingSessionId = editingSessionIdInput.val();
|
||||
mw.wikiEditor.logEditEvent( 'ready', {
|
||||
editingSessionId: editingSessionId
|
||||
} );
|
||||
context.$textarea.closest( 'form' ).submit( function () {
|
||||
context.submitting = true;
|
||||
} );
|
||||
this.onUnloadFallback = window.onunload;
|
||||
window.onunload = function () {
|
||||
var fallbackResult;
|
||||
|
||||
if ( this.onUnloadFallback ) {
|
||||
fallbackResult = this.onUnloadFallback();
|
||||
}
|
||||
|
||||
if ( !context.submitting ) {
|
||||
mw.wikiEditor.logEditEvent( 'abort', {
|
||||
editingSessionId: editingSessionId,
|
||||
// TODO: abort.type
|
||||
} );
|
||||
}
|
||||
|
||||
return fallbackResult;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/* API Execution */
|
||||
|
|
Loading…
Reference in a new issue