MIM.select_menu = function (event)
{
var target = event.target;
+ var sel;
if (! ((target.type == "text" || target.type == "textarea")
&& event.which == 1 && event.ctrlKey))
return;
-
- var sel = document.createElement ('select');
- sel.onclick = MIM.select_im;
- sel.onmouseout = MIM.destroy_menu;
- sel.style.position='absolute';
- sel.style.left = (event.clientX - 10) + "px";
- sel.style.top = (event.clientY - 10) + "px";
- sel.target = target;
- var idx = 0;
- for (var lang in MIM.imlist)
- for (var name in MIM.imlist[lang])
- {
- var option = document.createElement ('option');
- var imname = lang + "-" + name;
- option.appendChild (document.createTextNode (imname));
- option.value = imname;
- sel.appendChild (option);
- if (MIM.imlist[lang][name] == MIM.current)
- sel.selectedIndex = idx;
- idx++;
- }
- sel.size = idx;
+ if (! sel)
+ {
+ sel = document.createElement ('select');
+ sel.onclick = MIM.select_im;
+ sel.onmouseout = MIM.destroy_menu;
+ sel.style.position='absolute';
+ sel.style.left = (event.clientX - 10) + "px";
+ sel.style.top = (event.clientY - 10) + "px";
+ sel.target = target;
+ var idx = 0;
+ for (var lang in MIM.imlist)
+ for (var name in MIM.imlist[lang])
+ {
+ var option = document.createElement ('option');
+ var imname = lang + "-" + name;
+ option.appendChild (document.createTextNode (imname));
+ option.value = imname;
+ sel.appendChild (option);
+ if (MIM.imlist[lang][name] == MIM.current)
+ sel.selectedIndex = idx;
+ idx++;
+ }
+ sel.size = idx;
+ }
document.getElementsByTagName ('body')[0].appendChild (sel);
};
+MIM.select_menu = function (event)
+{
+ var target = event.target;
+ var menu;
+
+ if (! ((target.type == "text" || target.type == "textarea")
+ && event.which == 1 && event.ctrlKey))
+ return;
+ if (! menu)
+ {
+ menu = document.createElement ('select');
+ menu.onclick = MIM.select_im;
+ menu.onmouseout = MIM.destroy_menu;
+ menu.style.position='absolute';
+ menu.style.left = (event.clientX - 10) + "px";
+ menu.style.top = (event.clientY - 10) + "px";
+ menu.target = target;
+ var idx = 0;
+ for (var lang in MIM.imlist)
+ {
+ var sub = document.createElement ('option');
+ sub.appendChild (document.createTextNode ('+ ' + lang));
+ for (var name in MIM.imlist[lang])
+ {
+ var option = document.createElement ('option');
+ var imname = ' ' + lang + "-" + name;
+ option.appendChild (document.createTextNode (imname));
+ option.value = imname;
+ sub.appendChild (option);
+ if (MIM.imlist[lang][name] == MIM.current)
+ menu.selectedIndex = idx;
+ idx++;
+ }
+ menu.appendChild (sub);
+ }
+ menu.size = idx;
+ }
+ document.getElementsByTagName ('body')[0].appendChild (menu);
+};
+
MIM.test = function ()
{
var im = MIM.imlist['t']['latn-post'];