Merge pull request #1477 from ether/fix-opera-double-enter

Fixes #940: opera double enter
This commit is contained in:
Marcel Klehr 2013-02-10 05:10:38 -08:00
commit 6191b01633
2 changed files with 27 additions and 19 deletions

View File

@ -154,16 +154,21 @@ function Ace2Inner(){
var dmesg = noop;
window.dmesg = noop;
var scheduler = parent; // hack for opera required
// Ugly hack for Firefox 18
// get the timeout and interval methods from the parent iframe
// This hack breaks IE8
try{
setTimeout = parent.setTimeout;
clearTimeout = parent.clearTimeout;
setInterval = parent.setInterval;
clearInterval = parent.clearInterval;
}catch(err){
// IE8 can panic here.
// This hack breaks IE8 so be careful
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){
try{
setTimeout = scheduler.setTimeout;
clearTimeout = scheduler.clearTimeout;
setInterval = scheduler.setInterval;
clearInterval = scheduler.clearInterval;
}catch(err){
// IE8 can panic here.
}
}
var textFace = 'monospace';
@ -184,7 +189,7 @@ function Ace2Inner(){
parentDynamicCSS = makeCSSManager("dynamicsyntax", true);
}
var changesetTracker = makeChangesetTracker(rep.apool, {
var changesetTracker = makeChangesetTracker(scheduler, rep.apool, {
withCallbacks: function(operationName, f)
{
inCallStackIfNecessary(operationName, function()
@ -604,7 +609,7 @@ function Ace2Inner(){
doesWrap = newVal;
var dwClass = "doesWrap";
setClassPresence(root, "doesWrap", doesWrap);
setTimeout(function()
scheduler.setTimeout(function()
{
inCallStackIfNecessary("setWraps", function()
{
@ -644,7 +649,7 @@ function Ace2Inner(){
textFace = face;
root.style.fontFamily = textFace;
lineMetricsDiv.style.fontFamily = textFace;
setTimeout(function()
scheduler.setTimeout(function()
{
setUpTrackingCSS();
}, 0);
@ -657,7 +662,7 @@ function Ace2Inner(){
root.style.lineHeight = textLineHeight() + "px";
sideDiv.style.lineHeight = textLineHeight() + "px";
lineMetricsDiv.style.fontSize = textSize + "px";
setTimeout(function()
scheduler.setTimeout(function()
{
setUpTrackingCSS();
}, 0);
@ -1106,7 +1111,7 @@ function Ace2Inner(){
scheduledTime = time;
var delay = time - now();
if (delay < 0) delay = 0;
scheduledTimeout = setTimeout(callback, delay);
scheduledTimeout = scheduler.setTimeout(callback, delay);
}
function callback()
@ -3623,7 +3628,7 @@ function Ace2Inner(){
evt.preventDefault();
doReturnKey();
//scrollSelectionIntoView();
setTimeout(function()
scheduler.setTimeout(function()
{
outerWin.scrollBy(-100, 0);
}, 0);
@ -3709,7 +3714,7 @@ function Ace2Inner(){
var isPageDown = evt.which === 34;
var isPageUp = evt.which === 33;
setTimeout(function(){
scheduler.setTimeout(function(){
var newVisibleLineRange = getVisibleLineRange();
var linesCount = rep.lines.length();
@ -4660,7 +4665,10 @@ function Ace2Inner(){
function bindTheEventHandlers()
{
$(document).on("keydown", handleKeyEvent);
$(document).on("keypress", handleKeyEvent);
// Hack for Opera to stop it firing twice on events
if (/Opera[\/\s](\d+\.\d+)/.test(!navigator.userAgent)){
$(document).on("keypress", handleKeyEvent);
}
$(document).on("keyup", handleKeyEvent);
$(document).on("click", handleClick);
$(root).on("blur", handleBlur);
@ -4766,7 +4774,7 @@ function Ace2Inner(){
});
setTimeout(function()
scheduler.setTimeout(function()
{
parent.readyFunc(); // defined in code that sets up the inner iframe
}, 0);
@ -5214,7 +5222,7 @@ function Ace2Inner(){
documentAttributeManager: documentAttributeManager
});
setTimeout(function()
scheduler.setTimeout(function()
{
parent.readyFunc(); // defined in code that sets up the inner iframe
}, 0);

View File

@ -23,7 +23,7 @@
var AttributePool = require('./AttributePool');
var Changeset = require('./Changeset');
function makeChangesetTracker(apool, aceCallbacksProvider)
function makeChangesetTracker(scheduler, apool, aceCallbacksProvider)
{
// latest official text from server