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");
}
}) ();