2018-09-17 14:24:27 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor MediaWiki Initialization DesktopCollabTarget class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2018-09-17 14:24:27 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2019-02-20 20:23:43 +00:00
|
|
|
/* eslint-disable no-jquery/no-global-selector */
|
2019-01-08 17:00:09 +00:00
|
|
|
|
2018-09-17 14:24:27 +00:00
|
|
|
/**
|
|
|
|
* MediaWiki mobile article target.
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.init.mw.Target
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {mw.Title} title Page sub-title
|
2019-04-16 15:17:29 +00:00
|
|
|
* @param {string} rebaserUrl Rebaser server URL
|
2018-09-17 14:24:27 +00:00
|
|
|
* @param {Object} [config] Configuration options
|
2024-05-27 04:59:02 +00:00
|
|
|
* @param {mw.Title} [config.importTitle] Title to import
|
2018-09-17 14:24:27 +00:00
|
|
|
*/
|
|
|
|
ve.init.mw.DesktopCollabTarget = function VeInitMwDesktopCollabTarget( title, rebaserUrl, config ) {
|
|
|
|
// Parent constructor
|
|
|
|
ve.init.mw.DesktopCollabTarget.super.call( this, title, rebaserUrl, config );
|
|
|
|
|
|
|
|
this.$originalContent = $( '<div>' ).addClass( 've-init-mw-desktopArticleTarget-originalContent' );
|
|
|
|
this.$editableContent = $( '#mw-content-text' );
|
|
|
|
|
|
|
|
// Initialization
|
|
|
|
this.$element.addClass( 've-init-mw-desktopArticleTarget' ).append( this.$originalContent );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.init.mw.DesktopCollabTarget, ve.init.mw.CollabTarget );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Page modifications after editor load.
|
|
|
|
*/
|
|
|
|
ve.init.mw.DesktopCollabTarget.prototype.transformPage = function () {
|
|
|
|
this.$originalContent.append( this.$element.siblings() );
|
2024-05-21 14:22:56 +00:00
|
|
|
let title;
|
2018-09-17 14:24:27 +00:00
|
|
|
if ( ( title = this.getImportTitle() ) ) {
|
2021-11-15 17:03:35 +00:00
|
|
|
// ve.htmlMsg returns `Node[]`
|
|
|
|
// eslint-disable-next-line no-jquery/no-html
|
2018-09-17 14:24:27 +00:00
|
|
|
$( '#contentSub' ).html(
|
|
|
|
ve.htmlMsg(
|
|
|
|
'collabpad-import-subtitle',
|
|
|
|
$( '<a>' ).attr( 'href', title.getUrl() ).text( title.getMainText() )
|
|
|
|
)
|
|
|
|
);
|
|
|
|
ve.targetLinksToNewWindow( $( '#contentSub' )[ 0 ] );
|
|
|
|
} else {
|
|
|
|
$( '#contentSub' ).empty();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Page modifications after editor teardown.
|
|
|
|
*/
|
|
|
|
ve.init.mw.DesktopCollabTarget.prototype.restorePage = function () {
|
|
|
|
this.$element.parent().append( this.$originalContent.children() );
|
|
|
|
$( '#contentSub' ).empty();
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.DesktopCollabTarget.prototype.attachToolbar = function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const toolbar = this.getToolbar();
|
2018-09-17 14:24:27 +00:00
|
|
|
|
|
|
|
// Parent method
|
|
|
|
ve.init.mw.DesktopCollabTarget.super.prototype.attachToolbar.apply( this, arguments );
|
|
|
|
|
|
|
|
toolbar.$element.addClass(
|
2022-01-24 23:35:50 +00:00
|
|
|
've-init-mw-desktopArticleTarget-toolbar ve-init-mw-desktopArticleTarget-toolbar-open'
|
2018-09-17 14:24:27 +00:00
|
|
|
);
|
|
|
|
this.$element.prepend( toolbar.$element );
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.init.mw.DesktopCollabTarget.prototype.setSurface = function ( surface ) {
|
|
|
|
if ( surface !== this.surface ) {
|
|
|
|
this.$editableContent.after( surface.$element );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parent method
|
|
|
|
ve.init.mw.DesktopCollabTarget.super.prototype.setSurface.apply( this, arguments );
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
|
|
|
ve.init.mw.targetFactory.register( ve.init.mw.DesktopCollabTarget );
|