thomascube
2008-09-12 f89f03cd6ae4a1b3f98e39c2e01d9e40f8a286b4
program/js/common.js
@@ -114,6 +114,15 @@
},
/**
 * returns the event key code
 */
get_button: function(e)
{
  e = e || window.event;
  return e && (typeof e.button != 'undefined') ? e.button : (e && e.which ? e.which : 0);
},
/**
 * returns modifier key (constants defined at top of file)
 */
get_modifier: function(e)
@@ -171,7 +180,12 @@
  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];
},
@@ -497,17 +511,24 @@
    var elm = obj.offsetParent;
    while(elm && elm!=null)
      {
      iX += elm.offsetLeft;
      iY += elm.offsetTop;
      iX += elm.offsetLeft - (elm.parentNode && elm.parentNode.scrollLeft ? elm.parentNode.scrollLeft : 0);
      iY += elm.offsetTop - (elm.parentNode && elm.parentNode.scrollTop ? elm.parentNode.scrollTop : 0);
      elm = elm.offsetParent;
      }
    }
  //if(bw.mac && bw.ie5) iX += document.body.leftMargin;
  //if(bw.mac && bw.ie5) iY += document.body.topMargin;
  return {x:iX, y:iY};
  }
// determine whether the mouse is over the given object or not
function rcube_mouse_is_over(ev, obj)
{
  var mouse = rcube_event.get_mouse_pos(ev);
  var pos = rcube_get_object_pos(obj);
  return ((mouse.x >= pos.x) && (mouse.x < (pos.x + obj.offsetWidth)) &&
    (mouse.y >= pos.y) && (mouse.y < (pos.y + obj.offsetHeight)));
}
/**
@@ -574,18 +595,21 @@
// 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 = '';
  };
}