Add oriantation to Split and demo option
This commit is contained in:
parent
c38ddf3245
commit
55328f3690
3 changed files with 76 additions and 12 deletions
|
|
@ -47,15 +47,20 @@ var Renderer = require("ace/virtual_renderer").VirtualRenderer;
|
|||
var EditSession = require("ace/edit_session").EditSession;
|
||||
|
||||
var Split = function(container, theme, splits) {
|
||||
this.BELOW = 1;
|
||||
this.BESIDE = 0;
|
||||
|
||||
this.$container = container;
|
||||
this.$theme = theme;
|
||||
this.$splits = 0;
|
||||
this.$editorCSS = "";
|
||||
this.$editors = [];
|
||||
this.$oriantation = this.BESIDE;
|
||||
|
||||
this.setSplits(splits || 1);
|
||||
this.$cEditor = this.$editors[0];
|
||||
|
||||
|
||||
this.on("focus", function(editor) {
|
||||
this.$cEditor = editor;
|
||||
}.bind(this));
|
||||
|
|
@ -106,6 +111,10 @@ var Split = function(container, theme, splits) {
|
|||
this.resize();
|
||||
}
|
||||
|
||||
this.getSplits = function() {
|
||||
return this.$splits;
|
||||
}
|
||||
|
||||
this.getEditor = function(idx) {
|
||||
return this.$editors[idx];
|
||||
}
|
||||
|
|
@ -191,17 +200,43 @@ var Split = function(container, theme, splits) {
|
|||
return session;
|
||||
}
|
||||
|
||||
this.getOriantation = function() {
|
||||
return this.$oriantation;
|
||||
}
|
||||
|
||||
this.setOriantation = function(oriantation) {
|
||||
if (this.$oriantation == oriantation) {
|
||||
return;
|
||||
}
|
||||
this.$oriantation = oriantation;
|
||||
this.resize();
|
||||
}
|
||||
|
||||
this.resize = function() {
|
||||
var width = this.$container.clientWidth;
|
||||
var height = this.$container.clientHeight;
|
||||
var editor;
|
||||
var editorWidth = width / this.$splits;
|
||||
for (var i = 0; i < this.$splits; i++) {
|
||||
editor = this.$editors[i];
|
||||
editor.container.style.width = editorWidth + "px";
|
||||
editor.container.style.left = i * editorWidth + "px";
|
||||
editor.container.style.height = height + "px";
|
||||
editor.resize();
|
||||
|
||||
if (this.$oriantation == this.BESIDE) {
|
||||
var editorWidth = width / this.$splits;
|
||||
for (var i = 0; i < this.$splits; i++) {
|
||||
editor = this.$editors[i];
|
||||
editor.container.style.width = editorWidth + "px";
|
||||
editor.container.style.top = "0px";
|
||||
editor.container.style.left = i * editorWidth + "px";
|
||||
editor.container.style.height = height + "px";
|
||||
editor.resize();
|
||||
}
|
||||
} else {
|
||||
var editorHeight = height / this.$splits;
|
||||
for (var i = 0; i < this.$splits; i++) {
|
||||
editor = this.$editors[i];
|
||||
editor.container.style.width = width + "px";
|
||||
editor.container.style.top = i * editorHeight + "px"
|
||||
editor.container.style.left = "0px";
|
||||
editor.container.style.height = editorHeight + "px";
|
||||
editor.resize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue