Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/ui/ve.ui.MWSurface.js

raw symbols SCIP
1 /*!
2 * VisualEditor UserInterface MWSurface class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * @class
9 * @extends ve.ui.Surface
10 *
11 * @constructor
12 * @param {ve.init.Target} target
13 * @param {HTMLDocument|Array|ve.dm.LinearData|ve.dm.Document} dataOrDoc Document data to edit
14 * @param {Object} [config] Configuration options
15 */
16 ve.ui.MWSurface = function VeUiMWSurface() {
17 // Parent constructor
18 ve.ui.MWSurface.super.apply( this, arguments );
19
20 // Events
21 this.getView().getDocument().connect( this, { langChange: 'onDocumentViewLangChange' } );
22
23 // DOM changes
24 this.onDocumentViewLangChange();
25 this.$element.addClass( 've-ui-mwSurface' );
26 // T164790
27 this.getView().$attachedRootNode.addClass( 'mw-parser-output mw-show-empty-elt' );
28 };
29
30 /* Inheritance */
31
32 OO.inheritClass( ve.ui.MWSurface, ve.ui.Surface );
33
34 /* Methods */
35
36 /**
37 * Handle document view langChange events
38 */
39 ve.ui.MWSurface.prototype.onDocumentViewLangChange = function () {
40 // Add appropriately mw-content-ltr or mw-content-rtl class
41 this.getView().$attachedRootNode
42 .removeClass( 'mw-content-ltr mw-content-rtl' )
43 // The following classes are used here:
44 // * mw-content-ltr
45 // * mw-content-rtl
46 .addClass( 'mw-content-' + this.getView().getDocument().getDir() );
47 };