Add a feature authored by Joscha Filius for the International Institue of
[evergreen-equinox.git] / Open-ILS / xul / staff_client / server / OpenILS / symbol_overlay.js
1 dump('entering symbol/clipboard.js\n');
2
3 function $(id) { return document.getElementById(id); }
4
5 var el = {};
6
7 dojo.addOnLoad(
8     function(){
9         dojo.query('.plain').forEach(function(node,index,arr){
10             node.addEventListener("keypress", function(event) { 
11                 if (event.charCode == 115 && event.ctrlKey){
12                         setNod(node);
13                         $('symbol-panel').openPopup(node, 'after_pointer' );
14                     }
15                  }, true);
16         });
17     }
18 );
19
20 function setNod(elm){
21     el = elm;
22 }
23
24 function ret(ins, e){
25     if (e.button == 0){
26         $('symbol-panel').hidePopup();
27         n = el;
28         
29         if (n.getAttribute('readonly')=='true') return;
30         
31         var v = n.value;
32         var start = n.selectionStart;
33         var end = n.selectionEnd;
34         n.value = v.substring(0, start) + ins + v.substring(end, v.length);
35         n.setSelectionRange(start + ins.length,start + ins.length);
36     }
37 }