Debian Codegraph @

extensions/WikiEditor/modules/realtimepreview/TwoPaneLayout.js

raw symbols SCIP
1 var ResizingDragBar = require( './ResizingDragBar.js' );
2
3 /**
4 * This is a layout with two resizable panes.
5 *
6 * @class
7 * @constructor
8 * @extends OO.ui.Layout
9 * @param {Object} [config] Configuration options
10 */
11 function TwoPaneLayout( config ) {
12 // Configuration initialization
13 config = config || {};
14 TwoPaneLayout.super.call( this, config );
15
16 this.$pane1 = $( '<div>' ).addClass( 'ext-WikiEditor-twopanes-pane1' );
17 var middleDragBar = new ResizingDragBar( { isEW: true } );
18 this.$pane2 = $( '<div>' ).addClass( 'ext-WikiEditor-twopanes-pane2' );
19
20 this.$element.addClass( 'ext-WikiEditor-twopanes-TwoPaneLayout' );
21 this.$element.append( this.$pane1, middleDragBar.$element, this.$pane2 );
22 }
23
24 OO.inheritClass( TwoPaneLayout, OO.ui.Layout );
25
26 /**
27 * Set pane 1 content.
28 *
29 * @public
30 * @param {jQuery|string|Function|OO.ui.HtmlSnippet} content
31 */
32 TwoPaneLayout.prototype.setPane1 = function ( content ) {
33 this.setContent( this.$pane1, content );
34 };
35
36 /**
37 * @public
38 * @return {jQuery}
39 */
40 TwoPaneLayout.prototype.getPane1 = function () {
41 return this.$pane1;
42 };
43
44 /**
45 * Set pane 2 content.
46 *
47 * @public
48 * @param {jQuery|string|Function|OO.ui.HtmlSnippet} content
49 */
50 TwoPaneLayout.prototype.setPane2 = function ( content ) {
51 this.setContent( this.$pane2, content );
52 };
53
54 /**
55 * @public
56 * @return {jQuery}
57 */
58 TwoPaneLayout.prototype.getPane2 = function () {
59 return this.$pane2;
60 };
61
62 /**
63 * @private
64 * @param {jQuery} $container The container to set the content in.
65 * @param {jQuery|string|Function|OO.ui.HtmlSnippet} content The content to set.
66 */
67 TwoPaneLayout.prototype.setContent = function ( $container, content ) {
68 if ( typeof content === 'string' ) {
69 $container.text( content );
70 } else if ( content instanceof OO.ui.HtmlSnippet ) {
71 $container.html( content.toString() );
72 } else if ( content instanceof $ ) {
73 $container.empty().append( content );
74 } else {
75 $container.empty();
76 }
77 };
78
79 module.exports = TwoPaneLayout;