+(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;
+ }
+
+ MIM.show = function (ic)
+ {
+ if (! ic.candidates)
+ return;
+ var target = ic.target;
+ if (! ic.div_node)
+ {
+ 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');
+ copy_style (target, ic.div_node);
+ 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.div_node.appendChild (ic.div_node_first);
+ ic.div_node.appendChild (ic.div_node_last);
+ ic.can_node = document.createElement ('table');
+ ic.can_node.style.position = 'absolute';
+ ic.can_node.style.display = 'none';
+ ic.can_node.style.backgroundColor = "white";
+ ic.can_node.style.border = "1px solid black";
+ document.getElementsByTagName ('body')[0].appendChild (ic.can_node);
+ }
+
+ if (ic.changed & MIM.ChangedStatus.CandidateList)
+ {
+ while (ic.can_node.childNodes.length > 0)
+ ic.can_node.removeChild (ic.can_node.firstChild);
+ var tr = document.createElement ('tr');
+ var group = ic.candidates.CurrentGroup ();
+ var td = document.createElement ('td');
+ td.innerHTML = group[0][1] + '/' + group[0][0];
+ td.style.color = 'white';
+ td.style.backgroundColor = 'black';
+ tr.appendChild (td);
+ for (var i = 1; i < group.length; i++)
+ {
+ var td = document.createElement ('td');
+ td.noWrap = true;
+ td.innerHTML = (i < 10 ? i : i == 10 ? '0' : String.fromCharCode (0x60 + (i - 10))) + '.' + group[i];
+ if (i == group[0][2] + 1)
+ td.style.backgroundColor = 'lightblue';
+ tr.appendChild (td);
+ }
+ ic.can_node.appendChild (tr);
+ ic.div_node_first.innerHTML = target.value.substr (0, ic.range[0]);
+ var x = ic.target_left + ic.div_node.lastChild.offsetLeft;
+ var y = (ic.target_top + ic.div_node.lastChild.offsetTop
+ + ic.div_node.lastChild.offsetHeight - target.scrollTop + 10);
+ ic.can_node.style.left = x + 'px';
+ ic.can_node.style.top = y + 'px';
+ }
+ else
+ {
+ var td = ic.can_node.firstElement ().firstElement ().nextElement ();
+ var col = ic.candidates.CurrentCol ();
+ for (var i = 0; td; td = td.nextElement ())
+ td.style.backgroundColor = (i++ == col ? 'lightblue' : 'white');
+ }
+ ic.can_node.style.display = 'block';
+ }
+
+ MIM.hide = function (ic)
+ {
+ if (ic.can_node)
+ ic.can_node.style.display = 'none';
+ }
+}) ();
+
+MIM.focus_in = function (event)
+{
+ var target = event.target;
+ var ic = target.mim_ic;
+ if (ic.wait_update == true)
+ {
+ Xex.Log ("Focus in " + target.tagName + ' IGNORED');
+ event.preventDefault ();
+ return false;
+ }
+ Xex.Log ("Focus in " + target.tagName);
+ ic.Filter (MIM.Key.FocusIn);
+ function up () {MIM.update (target, ic);}
+ setTimeout (up, 100);
+}
+
+MIM.focus_out = function (event)