From: handa Date: Fri, 12 Mar 2010 13:13:47 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: ALPHA~16 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=948f7eae301c75877ff2d7b6a476ca1d33178b99;p=m17n%2Fm17n-lib-js.git *** empty log message *** --- diff --git a/xex.js b/xex.js index 9f2dc42..4ad5b75 100644 --- a/xex.js +++ b/xex.js @@ -3161,31 +3161,45 @@ MIM.update = function (target, ic) 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) + if (! ic.div_node) { - var elm = document.createTextNode (''); - + ic.target_top = 0; + ic.target_left = 0; + for (var elm = ic.target.offsetParent; elm; elm = elm.offsetParent) + { + ic.target_top += elm.offsetTop; + ic.target_left += elm.offsetLeft; + } + ic.div_node = document.createElement ('div'); + ic.div_node.style.visibility="hidden"; + ic.div_node.style.position = "absolute"; + document.getElementsByTagName ('body')[0].appendChild (ic.div_node); + ic.div_node_first = document.createElement ('span'); + ic.div_node_last = document.createElement('span'); + ic.div_node_last.innerHTML = '.'; 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) + ic.can_node.appendChild (document.createTextNode ('1. abc')); + ic.can_node.appendChild (document.createTextNode ('2. def')); + ic.can_node.style.position = 'absolute'; + ic.can_node.style.display = 'none'; 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; - + copy_style (target, ic.div_node); + ic.div_node.innerHTML = ''; + ic.div_node_first.innerHTML = target.value.substr (0, ic.range[0]); + ic.div_node.appendChild (ic.div_node_first); + ic.div_node.appendChild (ic.div_node_last); + Xex.Log (ic.div_node.firstChild.innerHTML); + var x = ic.target_left + ic.div_node.lastChild.offsetLeft; + var y = ic.target_top + ic.div_node.lastChild.offsetTop - target.scrollTop; + ic.can_node.style.left = x + 'px'; + ic.can_node.style.top = y + 'px'; + ic.can_node.style.display = 'block'; Xex.Log ("x:" + x + "px y:" + y + "px"); } }) ();