2016-10-25 20:44:26 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization CollabTarget class.
|
|
|
|
*
|
|
|
|
* @copyright 2011-2016 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MediaWiki mobile article target.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.init.mw.Target
|
|
|
|
*
|
|
|
|
* @constructor
|
2017-05-20 21:26:42 +00:00
|
|
|
* @param {mw.Title} title Page sub-title
|
|
|
|
* @param {rebaserUrl} string Rebaser server URL
|
2016-10-25 20:44:26 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
2017-05-20 21:26:42 +00:00
|
|
|
ve.init.mw.CollabTarget = function VeInitMwCollabTarget( title, rebaserUrl, config ) {
|
2016-10-25 20:44:26 +00:00
|
|
|
config = config || {};
|
|
|
|
config.toolbarConfig = $.extend( {
|
|
|
|
shadow: true,
|
|
|
|
actions: true,
|
|
|
|
floatable: true
|
|
|
|
}, config.toolbarConfig );
|
|
|
|
|
2017-05-20 21:26:42 +00:00
|
|
|
this.title = title;
|
|
|
|
this.rebaserUrl = rebaserUrl;
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
// Parent constructor
|
|
|
|
ve.init.mw.CollabTarget.super.call( this, config );
|
|
|
|
|
|
|
|
this.$originalContent = $( '<div>' ).addClass( 've-init-mw-desktopArticleTarget-originalContent' );
|
|
|
|
this.$editableContent = $( '#mw-content-text' );
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$element.addClass( 've-init-mw-articleTarget ve-init-mw-desktopArticleTarget ve-init-mw-collabTarget' ).append( this.$originalContent );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.init.mw.CollabTarget, ve.init.mw.Target );
|
|
|
|
|
|
|
|
/* Static Properties */
|
|
|
|
|
|
|
|
ve.init.mw.CollabTarget.static.name = 'collab';
|
|
|
|
|
|
|
|
ve.init.mw.CollabTarget.static.trackingName = 'collab';
|
|
|
|
|
2017-05-23 16:21:16 +00:00
|
|
|
ve.init.mw.CollabTarget.static.actionGroups = [
|
|
|
|
{ include: [ 'authorList' ] }
|
|
|
|
];
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Page modifications after editor load.
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.transformPage = function () {
|
|
|
|
this.$originalContent.append( this.$element.siblings() );
|
|
|
|
};
|
|
|
|
|
2017-05-20 19:22:44 +00:00
|
|
|
/**
|
|
|
|
* Page modifications after editor teardown.
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.restorePage = function () {
|
|
|
|
this.$element.parent().append( this.$originalContent.children() );
|
|
|
|
};
|
|
|
|
|
2017-05-20 21:26:42 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.surfaceReady = function () {
|
|
|
|
// Parent method
|
|
|
|
ve.init.mw.CollabTarget.super.prototype.surfaceReady.apply( this, arguments );
|
|
|
|
|
2017-05-23 16:21:16 +00:00
|
|
|
this.getSurface().getView().focus();
|
2017-05-20 21:26:42 +00:00
|
|
|
};
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.attachToolbar = function () {
|
|
|
|
this.toolbar.$element.addClass( 've-init-mw-desktopArticleTarget-toolbar ve-init-mw-desktopArticleTarget-toolbar-opened' );
|
|
|
|
this.$element.prepend( this.toolbar.$element );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.CollabTarget.prototype.setSurface = function ( surface ) {
|
2017-05-23 16:21:16 +00:00
|
|
|
var synchronizer, surfaceView, toolbar;
|
|
|
|
|
2016-10-25 20:44:26 +00:00
|
|
|
if ( surface !== this.surface ) {
|
|
|
|
this.$editableContent.after( surface.$element );
|
2017-05-23 16:21:16 +00:00
|
|
|
|
|
|
|
surfaceView = surface.getView();
|
|
|
|
toolbar = this.getToolbar();
|
|
|
|
|
|
|
|
synchronizer = new ve.dm.SurfaceSynchronizer(
|
|
|
|
surface.getModel(),
|
|
|
|
this.title.toString(),
|
|
|
|
{ server: this.rebaserUrl }
|
|
|
|
);
|
|
|
|
|
|
|
|
toolbar.initialize();
|
|
|
|
surfaceView.setSynchronizer( synchronizer );
|
2016-10-25 20:44:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parent method
|
|
|
|
ve.init.mw.CollabTarget.super.prototype.setSurface.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.init.mw.targetFactory.register( ve.init.mw.CollabTarget );
|