| 1 |
var ResizingDragBar = require( './ResizingDragBar.js' ); |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
function TwoPaneLayout( config ) { |
| 12 |
|
| 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 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
TwoPaneLayout.prototype.setPane1 = function ( content ) { |
| 33 |
this.setContent( this.$pane1, content ); |
| 34 |
}; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
TwoPaneLayout.prototype.getPane1 = function () { |
| 41 |
return this.$pane1; |
| 42 |
}; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
TwoPaneLayout.prototype.setPane2 = function ( content ) { |
| 51 |
this.setContent( this.$pane2, content ); |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
TwoPaneLayout.prototype.getPane2 = function () { |
| 59 |
return this.$pane2; |
| 60 |
}; |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 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; |