mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Merge "Create MW targets using a factory"
This commit is contained in:
commit
faed98a7c6
|
@ -139,7 +139,7 @@
|
|||
// Transfer methods
|
||||
ve.init.mw.DesktopArticleTarget.prototype.setupSectionEditLinks = init.setupSectionLinks;
|
||||
|
||||
target = new ve.init.mw.DesktopArticleTarget();
|
||||
target = ve.init.mw.targetFactory.create( 'article' );
|
||||
$( '#content' ).append( target.$element );
|
||||
return target;
|
||||
}, function ( e ) {
|
||||
|
|
|
@ -651,7 +651,7 @@ ve.init.mw.DesktopArticleTarget.prototype.surfaceReady = function () {
|
|||
this.surface.getModel().getDocument().once( 'transact', function () {
|
||||
ve.track( 'mwtiming.behavior.firstTransaction', {
|
||||
duration: ve.now() - surfaceReadyTime,
|
||||
targetName: target.constructor.static.name
|
||||
targetName: target.constructor.static.trackingName
|
||||
} );
|
||||
} );
|
||||
|
||||
|
@ -1451,3 +1451,7 @@ ve.init.mw.DesktopArticleTarget.prototype.switchToWikitextEditor = function ( di
|
|||
ve.init.mw.DesktopArticleTarget.prototype.resetDocumentOpacity = function () {
|
||||
this.getSurface().getView().getDocument().getDocumentNode().$element.css( 'opacity', 1 );
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
||||
ve.init.mw.targetFactory.register( ve.init.mw.DesktopArticleTarget );
|
||||
|
|
|
@ -61,7 +61,7 @@ ve.init.mw.MobileArticleTarget.static.toolbarGroups = [
|
|||
{ include: [ 'done' ] }
|
||||
];
|
||||
|
||||
ve.init.mw.MobileArticleTarget.static.name = 'mobile';
|
||||
ve.init.mw.MobileArticleTarget.static.trackingName = 'mobile';
|
||||
|
||||
// FIXME Some of these users will be on tablets, check for this
|
||||
ve.init.mw.MobileArticleTarget.static.platformType = 'phone';
|
||||
|
@ -224,6 +224,10 @@ ve.init.mw.MobileArticleTarget.prototype.done = function () {
|
|||
this.getSurface().getView().blur();
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
||||
ve.init.mw.targetFactory.register( ve.init.mw.MobileArticleTarget );
|
||||
|
||||
/**
|
||||
* Back tool
|
||||
*/
|
||||
|
|
|
@ -161,13 +161,18 @@ OO.inheritClass( ve.init.mw.ArticleTarget, ve.init.mw.Target );
|
|||
/* Static Properties */
|
||||
|
||||
/**
|
||||
* Name of target class. Used by ArticleTargetEvents to identify which target we are tracking.
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.init.mw.ArticleTarget.static.name = 'article';
|
||||
|
||||
/**
|
||||
* Tracking name of target class. Used by ArticleTargetEvents to identify which target we are tracking.
|
||||
*
|
||||
* @static
|
||||
* @property {string}
|
||||
* @inheritable
|
||||
*/
|
||||
ve.init.mw.ArticleTarget.static.name = 'mwTarget';
|
||||
ve.init.mw.ArticleTarget.static.trackingName = 'mwTarget';
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
@ -1679,7 +1684,7 @@ ve.init.mw.ArticleTarget.prototype.maybeShowWelcomeDialog = function () {
|
|||
) {
|
||||
windowManager.openWindow(
|
||||
'welcome',
|
||||
{ targetName: this.constructor.static.name }
|
||||
{ targetName: this.constructor.static.trackingName }
|
||||
)
|
||||
.then( function ( opened ) {
|
||||
return opened;
|
||||
|
|
|
@ -50,7 +50,7 @@ ve.init.mw.ArticleTargetEvents = function VeInitMwArticleTargetEvents( target )
|
|||
* @param {Object} data Additional data describing the event, encoded as an object
|
||||
*/
|
||||
ve.init.mw.ArticleTargetEvents.prototype.track = function ( topic, data ) {
|
||||
data.targetName = this.target.constructor.static.name;
|
||||
data.targetName = this.target.constructor.static.trackingName;
|
||||
ve.track( 'mwtiming.' + topic, data );
|
||||
|
||||
if ( topic.indexOf( 'performance.system.serializeforcache' ) === 0 ) {
|
||||
|
|
|
@ -34,6 +34,15 @@ OO.inheritClass( ve.init.mw.Target, ve.init.Target );
|
|||
|
||||
/* Static Properties */
|
||||
|
||||
/**
|
||||
* Symbolic name for this target class.
|
||||
*
|
||||
* @static
|
||||
* @property {string}
|
||||
* @inheritable
|
||||
*/
|
||||
ve.init.mw.Target.static.name = null;
|
||||
|
||||
ve.init.mw.Target.static.toolbarGroups = [
|
||||
// History
|
||||
{ include: [ 'undo', 'redo' ] },
|
||||
|
|
|
@ -11,4 +11,6 @@
|
|||
* @class
|
||||
* @singleton
|
||||
*/
|
||||
ve.init.mw = {};
|
||||
ve.init.mw = {
|
||||
targetFactory: new OO.Factory()
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue