position textarea with bottom/right since otherwise firefox 21+ scrolls

editor out of view when textarea.focus is called
This commit is contained in:
nightwing 2013-01-25 18:39:18 +04:00
commit d437b63d19
3 changed files with 18 additions and 17 deletions

View file

@ -98,15 +98,17 @@
resize: none;
outline: none;
overflow: hidden;
font: inherit;
}
.ace_text-input.ace_composition {
background: #fff;
color: #000;
background: #f8f8f8;
color: #111;
z-index: 1000;
opacity: 1;
border: solid lightgray 1px;
margin: -1px
margin: -1px;
padding: 0 1px;
}
.ace_layer {

View file

@ -51,7 +51,7 @@ var TextInput = function(parentNode, host) {
text.autocapitalize = "off";
text.spellcheck = false;
text.style.top = "-2em";
text.style.bottom = "-2em";
parentNode.insertBefore(text, parentNode.firstChild);
var PLACEHOLDER = "\x01\x01";
@ -350,12 +350,10 @@ var TextInput = function(parentNode, host) {
host.onCompositionEnd();
};
var syncComposition = lang.delayedCall(onCompositionUpdate, 50);
event.addListener(text, "compositionstart", onCompositionStart);
if (useragent.isGecko)
event.addListener(text, "text", onCompositionUpdate);
else
event.addListener(text, "keyup", onCompositionUpdate);
event.addListener(text, useragent.isGecko ? "text" : "keyup", function(){syncComposition.schedule()});
event.addListener(text, "compositionend", onCompositionEnd);
this.getElement = function() {

View file

@ -566,28 +566,29 @@ var VirtualRenderer = function(container, theme) {
this.$moveTextAreaToCursor = function() {
if (!this.$keepTextAreaAtCursor)
return;
var config = this.layerConfig;
var posTop = this.$cursorLayer.$pixelPos.top;
var posLeft = this.$cursorLayer.$pixelPos.left;
posTop -= this.layerConfig.offset;
posTop -= config.offset;
if (posTop < 0 || posTop > this.layerConfig.height - this.lineHeight)
if (posTop < 0 || posTop > config.height - this.lineHeight)
return;
var w = this.characterWidth;
if (this.$composition)
w += this.textarea.scrollWidth;
if (this.$composition) {
var val = this.textarea.value.replace(/^\x01+/, "");
w *= this.session.$getStringScreenWidth(val)[0];
}
posLeft -= this.scrollLeft;
if (posLeft > this.$size.scrollerWidth - w)
posLeft = this.$size.scrollerWidth - w;
if (this.showGutter)
posLeft += this.$gutterLayer.gutterWidth;
posLeft -= this.scrollBar.width;
this.textarea.style.height = this.lineHeight + "px";
this.textarea.style.width = w + "px";
this.textarea.style.left = posLeft + "px";
this.textarea.style.top = posTop - 1 + "px";
this.textarea.style.right = this.$size.scrollerWidth - posLeft - w + "px";
this.textarea.style.bottom = this.$size.height - posTop - this.lineHeight + "px";
};
/**