[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/js/dynapi/api/ -> mouse_ie.js (source)

   1  /*
   2      DynAPI Distribution
   3      MouseEvent Class
   4  
   5      The DynAPI Distribution is distributed under the terms of the GNU LGPL license.
   6      
   7      requires: dynapi.api.DynDocument
   8  */
   9  
  10  function MouseEvent(dyndoc) {
  11      this.DynEvent = DynEvent;
  12      this.DynEvent();
  13      this.bubble = true;
  14      this._mouseEvent = null;
  15      this._relative = null;
  16      this._dyndoc = dyndoc;
  17  };
  18  var p = dynapi.setPrototype('MouseEvent','DynEvent');
  19  p.getX = function() {return this.x};
  20  p.getY = function() {return this.y};
  21  p.getPageX = function() {return this.pageX};
  22  p.getPageY = function() {return this.pageY};
  23  p.getRelative = function() {return this._relative};
  24  p.preventBubble = function() {this.bubble = false;};
  25  p.getButton = function() {
  26      if (!this._mouseEvent) return "left";
  27      var b = this._mouseEvent.button;
  28      if (b==4) return "middle";
  29      if (b==2) return "right";
  30      else return "left";
  31  };
  32  p._init = function(type,e,src) {
  33      this.type = type;
  34      this._mouseEvent = e;
  35      this.origin = src;
  36      this.bubbleChild = null;
  37      this.defaultValue = true;
  38      this.bubble = true;
  39  };
  40  p._invoke = function() {
  41      var o = this.origin;
  42      o.invokeEvent(this.type,this);
  43  };
  44  
  45  MouseEvent._getContainerLayerOf = function(element) {
  46      if (!element) return null;
  47      while (!element._dynobj && element.parentElement && element.parentElement!=element) {
  48          element = element.parentElement;
  49      }
  50      return element._dynobj;
  51  };
  52  //MouseEvent.trapMouseUp = dynapi.functions.False; // or MouseEvent.trapMouseUp=null
  53  
  54  MouseEvent._eventHandler = function() {
  55      var e = dynapi.frame.event;
  56      var dynobj;
  57      if (this._dynobj) dynobj = this._dynobj;
  58      else if (e.srcElement._dynobj) dynobj = e.srcElement._dynobj;
  59      else dynobj = dynapi.document;
  60      
  61      var dyndoc = dynobj._dyndoc;
  62      var target = e.srcElement;
  63  
  64      var me = dyndoc._mouseEvent;
  65      var src = MouseEvent._getContainerLayerOf(target);
  66      me._init(e.type,e,src);
  67  
  68      var rel = e.type=="mouseout"? e.toElement : e.fromElement;
  69      var r = me._relative = MouseEvent._getContainerLayerOf(rel);
  70      if (e.type=="mouseout" || e.type=="mouseover") {
  71          if (r && src && (r==src||src.isParentOf(r))) return; //fix for #15 (ie only)
  72          if (r && src && (r==src.parent||r.isChildOf(src.parent))) me.bubble=false;
  73      }
  74      me.pageX = e.clientX;
  75      me.pageY = e.clientY;
  76      if(!src) return;
  77      me.x = (me.pageX + (document.body.scrollLeft||0)) - src.getPageX(); //offsetX;
  78      me.y = (me.pageY + (document.body.scrollTop||0)) - src.getPageY(); //offsetY;
  79      e.cancelBubble = true;
  80      me._invoke();
  81  
  82      var tt=target.type;
  83      var tn=(target.tagName+'').toLowerCase();
  84      
  85      // fix for form elements inside drag-enabled layer #08
  86      if(tt=='textarea'||tt=='text' && target.onselectstart==null) target.onselectstart = dynapi.functions.Allow;
  87      if(e.type=='mousedown' && tn=='input'||tn=='textarea'||tn=='button') {
  88          var de=dynapi.frame.DragEvent;
  89          de=(de && de.dragevent)? de.dragevent:null;
  90          if(de && de.isDragging) de.cancelDrag();
  91      }
  92      
  93      // prevent image dragging
  94      if(target.tagName=='IMG' && typeof(target.ondragstart)!="function") {
  95          target.ondragstart=dynapi.functions.False;
  96      }
  97      
  98  };
  99  
 100  DynElement.prototype.disableContextMenu = function(){
 101      this._noContextMenu = true;
 102      if(this.elm) this.elm.oncontextmenu = dynapi.functions.False;
 103  };
 104  DynElement.prototype.captureMouseEvents = function() {
 105      this._hasMouseEvents = true;
 106      if (this.elm) {
 107          var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm;
 108          elm.onmouseover = elm.onmouseout = elm.onmousedown = elm.onmouseup = elm.onclick = elm.ondblclick = elm.onmousemove = MouseEvent._eventHandler;
 109          if(this._noContextMenu) elm.oncontextmenu = dynapi.functions.False;
 110      }
 111  };
 112  DynElement.prototype.releaseMouseEvents = function() {
 113      this._hasMouseEvents = false;
 114      if (this.elm) {
 115          var elm = (this.getClassName()=='DynDocument')? this.doc : this.elm;
 116          elm.onmousedown = elm.onmouseup = elm.onclick = elm.ondblclick = null;
 117          elm.oncontextmenu = null;
 118      }
 119  };
 120  
 121  function main_mouse_ie() { 
 122      dynapi.document._mouseEvent = new MouseEvent(dynapi.document); 
 123  };
 124  if (!dynapi.loaded) main_mouse_ie();


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7