summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNAGOYA, Yoshihiko <nagoya@lepidum.co.jp>2012-10-11 23:39:01 +0900
committerNAGOYA, Yoshihiko <nagoya@lepidum.co.jp>2012-10-12 01:12:15 +0900
commit957a0aa873f2df13483a9b17589c064cc229a80a (patch)
tree90af20d60631cf45dcb6c35e3cde69512f5b042d
parentd7ec050f342a717146f181dac76fc1e2b0cada59 (diff)
downloadetherpad-lite-957a0aa873f2df13483a9b17589c064cc229a80a.zip
fix Pita/etherpad-lite #1032
refact inInternationalComposition
-rw-r--r--src/static/js/ace.js5
-rw-r--r--src/static/js/ace2_inner.js21
-rw-r--r--src/static/js/collab_client.js4
-rw-r--r--src/static/js/pad.js16
4 files changed, 25 insertions, 21 deletions
diff --git a/src/static/js/ace.js b/src/static/js/ace.js
index e50f75c7..83ad9447 100644
--- a/src/static/js/ace.js
+++ b/src/static/js/ace.js
@@ -122,6 +122,11 @@ function Ace2Editor()
return info.ace_getDebugProperty(prop);
};
+ editor.getInInternationalComposition = function()
+ {
+ return info.ace_getInInternationalComposition();
+ };
+
// prepareUserChangeset:
// Returns null if no new changes or ACE not ready. Otherwise, bundles up all user changes
// to the latest base text into a Changeset, which is returned (as a string if encodeAsString).
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index 652a3d25..2e56b950 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -1173,7 +1173,7 @@ function Ace2Inner(){
//if (! top.BEFORE) top.BEFORE = [];
//top.BEFORE.push(magicdom.root.dom.innerHTML);
//if (! isEditable) return; // and don't reschedule
- if (window.parent.parent.inInternationalComposition)
+ if (inInternationalComposition)
{
// don't do idle input incorporation during international input composition
idleWorkTimer.atLeast(500);
@@ -3729,7 +3729,7 @@ function Ace2Inner(){
thisKeyDoesntTriggerNormalize = true;
}
- if ((!specialHandled) && (!thisKeyDoesntTriggerNormalize) && (!window.parent.parent.inInternationalComposition))
+ if ((!specialHandled) && (!thisKeyDoesntTriggerNormalize) && (!inInternationalComposition))
{
if (type != "keyup" || !incorpIfQuick())
{
@@ -4589,9 +4589,24 @@ function Ace2Inner(){
}
}
+
+ var inInternationalComposition = false;
function handleCompositionEvent(evt)
{
- window.parent.parent.handleCompositionEvent(evt);
+ // international input events, fired in FF3, at least; allow e.g. Japanese input
+ if (evt.type == "compositionstart")
+ {
+ inInternationalComposition = true;
+ }
+ else if (evt.type == "compositionend")
+ {
+ inInternationalComposition = false;
+ }
+ }
+
+ editorInfo.ace_getInInternationalComposition = function ()
+ {
+ return inInternationalComposition;
}
function bindTheEventHandlers()
diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js
index b3e17c25..b700fc49 100644
--- a/src/static/js/collab_client.js
+++ b/src/static/js/collab_client.js
@@ -111,7 +111,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
function handleUserChanges()
{
- if (window.parent.parent.inInternationalComposition) return;
+ if (editor.getInInternationalComposition()) return;
if ((!getSocket()) || channelState == "CONNECTING")
{
if (channelState == "CONNECTING" && (((+new Date()) - initialStartConnectTime) > 20000))
@@ -288,7 +288,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad)
var apool = msg.apool;
// When inInternationalComposition, msg pushed msgQueue.
- if (msgQueue.length > 0 || window.parent.parent.inInternationalComposition) {
+ if (msgQueue.length > 0 || editor.getInInternationalComposition()) {
if (msgQueue.length > 0) oldRev = msgQueue[msgQueue.length - 1].newRev;
else oldRev = rev;
diff --git a/src/static/js/pad.js b/src/static/js/pad.js
index 21dea440..89777040 100644
--- a/src/static/js/pad.js
+++ b/src/static/js/pad.js
@@ -51,22 +51,6 @@ var randomString = require('./pad_utils').randomString;
var hooks = require('./pluginfw/hooks');
-window.inInternationalComposition = false;
-var inInternationalComposition = window.inInternationalComposition;
-
-window.handleCompositionEvent = function handleCompositionEvent(evt)
- {
- // international input events, fired in FF3, at least; allow e.g. Japanese input
- if (evt.type == "compositionstart")
- {
- this.inInternationalComposition = true;
- }
- else if (evt.type == "compositionend")
- {
- this.inInternationalComposition = false;
- }
- }
-
function createCookie(name, value, days, path)
{
if (days)