| | |
| | | // static functions for event handling |
| | | var rcube_event = { |
| | | |
| | | /** |
| | | * returns the event key code |
| | | */ |
| | | get_keycode: function(e) |
| | | { |
| | | e = e || window.event; |
| | | return e && e.keyCode ? e.keyCode : (e && e.which ? e.which : 0); |
| | | }, |
| | | /** |
| | | * returns the event target element |
| | | */ |
| | | get_target: function(e) |
| | | { |
| | | e = e || window.event; |
| | | return e && e.target ? e.target : e.srcElement; |
| | | }, |
| | | |
| | | /** |
| | | * returns the event key code |
| | | */ |
| | | get_keycode: function(e) |
| | | { |
| | | e = e || window.event; |
| | | return e && e.keyCode ? e.keyCode : (e && e.which ? e.which : 0); |
| | | }, |
| | | |
| | | /** |
| | | * returns modifier key (constants defined at top of file) |
| | |
| | | if (p.element.addEventListener) |
| | | p.element.addEventListener(p.event, p.object._rc_events[key], false); |
| | | else if (p.element.attachEvent) |
| | | { |
| | | // IE allows multiple events with the same function to be applied to the same object |
| | | // forcibly detach the event, then attach |
| | | p.element.detachEvent('on'+p.event, p.object._rc_events[key]); |
| | | p.element.attachEvent('on'+p.event, p.object._rc_events[key]); |
| | | } |
| | | else |
| | | p.element['on'+p.event] = p.object._rc_events[key]; |
| | | }, |
| | |
| | | // tiny replacement for Firebox functionality |
| | | function rcube_console() |
| | | { |
| | | this.box = rcube_find_object('console'); |
| | | |
| | | this.log = function(msg) |
| | | { |
| | | if (this.box) |
| | | this.box.value += str+'\n--------------------------------------\n'; |
| | | box = rcube_find_object('console'); |
| | | if (box) |
| | | if (msg[msg.length-1]=='\n') |
| | | box.value += msg+'--------------------------------------\n'; |
| | | else |
| | | box.value += msg+'\n--------------------------------------\n'; |
| | | }; |
| | | |
| | | |
| | | this.reset = function() |
| | | { |
| | | if (this.box) |
| | | this.box.value = ''; |
| | | box = rcube_find_object('console'); |
| | | if (box) |
| | | box.value = ''; |
| | | }; |
| | | } |
| | | |