From 014659685c2e6e1f40a8e9168d3829809df4aa09 Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 3 Mar 2010 04:37:39 +0000 Subject: [PATCH] *** empty log message *** --- xex.js | 87 ++++++++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 22 deletions(-) diff --git a/xex.js b/xex.js index 78b1223..69c58f2 100644 --- a/xex.js +++ b/xex.js @@ -3057,35 +3057,78 @@ MIM.destroy_menu = function (event) 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']; -- 1.7.10.4