mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-04 18:58:37 +00:00
94879a98b7
VisualEditor.php: * Make jquery.i18n a dependency of ext.visualEditor.standalone makeStaticLoader.php: * Remove ve.init.platform.addMessages() call with PHP-generated messages * Add fake module for jquery.i18n ** Needed because the module might come from MW core ** Also add special treatment for fallbacks.js and language scripts ve.init.sa.Platform.js: * Remove basic message system, replace with jquery.i18n * Add initialize method that loads messages for current language and fallbacks ve.init.sa.Target.js: * Wait for the platform to initialize before actually doing things * Add .setup() method to allow callers to short-circuit this process ** This is convenient for callers of ve.init.sa.Target in the test suite ve.ce.test.js: * Use existing ve.test.utils function for creating a surface ve.test.utils.js: * Call .setup() on the target so we can get a surface synchronously ve.init.Platform.test.js: * Make these tests async, wait for the platform to initialize * Allow for missing messages to be output either as <foo> (MW) or foo (jquery.i18n) * Get rid of message clearing code, namespace test messages instead Change-Id: Iac7dfd327eadf9b503a61510574d35d748faac92
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
/*!
|
|
* VisualEditor Standalone Initialization Target class.
|
|
*
|
|
* @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Initialization Standalone target.
|
|
*
|
|
* @example
|
|
* new ve.init.sa.Target(
|
|
* $( '<div>' ).appendTo( 'body' ), ve.createDocumentFromHtml( '<p>Hello world.</p>' )
|
|
* );
|
|
*
|
|
* @class
|
|
* @extends ve.init.Target
|
|
*
|
|
* @constructor
|
|
* @param {jQuery} $container Container to render target into
|
|
* @param {ve.dm.Document} doc Document model
|
|
*/
|
|
ve.init.sa.Target = function VeInitSaTarget( $container, doc ) {
|
|
// Parent constructor
|
|
ve.init.Target.call( this, $container );
|
|
|
|
this.document = doc;
|
|
|
|
ve.init.platform.getInitializedPromise().done( ve.bind( this.setup, this ) );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.init.sa.Target, ve.init.Target );
|
|
|
|
/* Methods */
|
|
|
|
ve.init.sa.Target.prototype.setup = function () {
|
|
if ( this.setupDone ) {
|
|
return;
|
|
}
|
|
|
|
// Properties
|
|
this.setupDone = true;
|
|
this.surface = new ve.ui.Surface( this.document );
|
|
this.toolbar = new ve.ui.TargetToolbar( this, this.surface, { 'shadow': true } );
|
|
|
|
// Initialization
|
|
this.toolbar.$element.addClass( 've-init-sa-target-toolbar' );
|
|
this.toolbar.setup( this.constructor.static.toolbarGroups );
|
|
this.toolbar.enableFloatable();
|
|
|
|
this.$element.append( this.toolbar.$element, this.surface.$element );
|
|
|
|
this.toolbar.initialize();
|
|
this.surface.addCommands( this.constructor.static.surfaceCommands );
|
|
this.surface.setPasteRules( this.constructor.static.pasteRules );
|
|
this.surface.initialize();
|
|
};
|