Merge "Create MW targets using a factory"

This commit is contained in:
jenkins-bot 2016-04-21 22:25:37 +00:00 committed by Gerrit Code Review
commit faed98a7c6
7 changed files with 32 additions and 8 deletions

View file

@ -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 ) {

View file

@ -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 );

View file

@ -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
*/

View file

@ -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;

View file

@ -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 ) {

View file

@ -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' ] },

View file

@ -11,4 +11,6 @@
* @class
* @singleton
*/
ve.init.mw = {};
ve.init.mw = {
targetFactory: new OO.Factory()
};