*** empty log message ***
[m17n/m17n-lib-js.git] / xex.js
diff --git a/xex.js b/xex.js
index 556170e..9f2dc42 100644 (file)
--- a/xex.js
+++ b/xex.js
@@ -3116,8 +3116,6 @@ MIM.set_caret = function (target, ic)
     }
 };
 
-MIM.ignore_focus = false;
-
 MIM.update = function (target, ic)
 {
   var text = target.value;
@@ -3130,6 +3128,68 @@ MIM.update = function (target, ic)
   MIM.set_caret (target, ic);
 };
 
+(function () {
+  var style_props = {
+    width: 'width',
+    height: 'height',
+    padingLeft: 'padding-left',
+    paddingRight: 'padding-right',
+    paddingTop: 'padding-top',
+    paddintBottom: 'padding-bottom', 
+    borderLeftStyle: 'border-left-style',
+    borderRightStyle: 'border-right-style',
+    borderTopStyle: 'border-top-style',
+    borderBottomStyle: 'border-bottom-style',
+    borderLeftWidth: 'border-left-width',
+    borderRightWidth: 'border-right-width',
+    borderTopWidth: 'border-top-width',
+    borderBottomWidth: 'border-bottom-width',
+    fontFamily: 'font-family',
+    fontSize: 'font-size',
+    lineHeight: 'line-height',
+    letterSpacing: 'letter-spacing',
+    wordSpacing: 'word-spacing' };
+
+  function copy_style (from, to)
+  {
+    var from_style = getComputedStyle(from,'');
+       
+    for(var name in style_props)
+      to.style[name] = from_style.getPropertyValue (style_props[name]);
+       
+    to.style.left = from.offsetLeft + 'px'; 
+    to.style.top = from.offsetTop + 'px';
+    to.style.width = from.offsetWidth;
+    to.style.height = from.offsetHeight;
+    to.scrollLeft = from.scrollLeft;
+    to.scrollTop = from.scrollTop;
+  }
+
+  MIM.show = function (target, ic)
+  {
+    if (! ic.can_node)
+      {
+       var elm = document.createTextNode ('');
+
+       ic.can_node = document.createElement ('div');
+       ic.can_node.style.visibility="hidden";
+       ic.can_node.style.position = "absolute";
+       ic.can_node.appendChild (elm)
+       elm = document.createElement('span');
+       elm.innerHTML = '.';
+       ic.can_node.appendChild (elm)
+       document.getElementsByTagName ('body')[0].appendChild (ic.can_node);
+      }
+
+    copy_style (target, ic.can_node);
+    ic.can_node.firstChild.value = target.value.substr (0, ic.range[0]);
+    var x = target.offsetLeft + ic.can_node.lastChild.offsetLeft +2;
+    var y = target.offsetTop + ic.can_node.lastChild.offsetTop -2;
+
+    Xex.Log ("x:" + x + "px y:" + y + "px");
+  }
+}) ();
+
 MIM.focus_in = function (event)
 {
   var target = event.target;
@@ -3170,7 +3230,6 @@ MIM.keydown = function (event)
     return;
   if (! (target.type == "text" || target.type == "textarea"))
     return;
-  document.akey = event;
 
   var ic = target.mim_ic;
   if (! ic || ic.im != MIM.current)
@@ -3190,6 +3249,7 @@ MIM.keydown = function (event)
       if (! MIM.get_range (target, ic))
        ic.reset ();
     }
+  MIM.show (target, ic);
   MIM.debug_print (event, ic);
   ic.key = MIM.decode_key_event (event);
   if (ic.key)
@@ -3246,6 +3306,7 @@ MIM.keypress = function (event)
   } finally {
     MIM.debug_print (event, ic);
   }
+
   return;
 };
 
@@ -3267,7 +3328,6 @@ MIM.keypress = function (event)
       sk: { name: 'Slovak' },
       sr: { name: 'Serbian' },
       sv: { name: 'Swedish' },
-      vi: { name: 'Vietnamese' },
       yi: { name: 'Yiddish' } },
     MiddleEast: {
       ar: { name: 'Arabic' },
@@ -3487,7 +3547,6 @@ MIM.keypress = function (event)
            li.appendChild (sub);
            menu.appendChild (li);
          }
-       document.mimmenu = menu;
        lang_category = null;
       }
     menu.style.left = (event.clientX - 10) + "px";