]> err.no Git - scalable-opengroupware.org/blobdiff - UI/WebServerResources/SOGoDragHandles.js
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1059 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / WebServerResources / SOGoDragHandles.js
index aee95098f83f59bee9a753fcbd955eb2e3789599..f1501bca46ff0d530d40ac7e5ad5f1cddd9146bc 100644 (file)
@@ -13,6 +13,7 @@ var SOGoDragHandlesInterface = {
   lowerBlock: null,
   bind: function () {
     this.addEventListener("mousedown", this.startHandleDragging, false);
+    this.onmousedown = function() { return false }
   },
   _determineType: function () {
     if (this.leftBlock && this.rightBlock)
@@ -23,7 +24,14 @@ var SOGoDragHandlesInterface = {
   startHandleDragging: function (event) {
     if (!this.dhType)
       this._determineType();
-    if (event.button == 0) {
+    var targ;
+    if (!event)
+      var event = window.event;
+    if (event.target)
+      targ = event.target
+    else if (event.srcElement)
+      targ = event.srcElement
+    if (targ.nodeType == 1) {
       if (this.dhType == 'horizontal') {
         this.origX = this.offsetLeft;
         this.origLeft = this.leftBlock.offsetWidth;
@@ -38,8 +46,13 @@ var SOGoDragHandlesInterface = {
         document.body.style.cursor = "n-resize";
       }
       document._currentDragHandle = this;
-      document.addEventListener("mouseup", this.documentStopHandleDragging, true);
-      document.addEventListener("mousemove", this.documentMove, true);
+      if (document.addEventListener) {
+       document.addEventListener("mouseup", this.documentStopHandleDragging, true);
+       document.addEventListener("mousemove", this.documentMove, true);
+      } else if (window.addEventListener) {
+       window.addEventListener("mouseup", this.documentStopHandleDragging, true);
+       window.addEventListener("mousemove", this.documentMove, true);
+      }
       this.move(event);
       event.cancelBubble = true;
     }
@@ -52,6 +65,7 @@ var SOGoDragHandlesInterface = {
   },
   documentMove: function (event) {
     var handle = document._currentDragHandle;
+    if (!handle) return false;
     return handle.move(event);
   },
   stopHandleDragging: function (event) {
@@ -60,17 +74,22 @@ var SOGoDragHandlesInterface = {
     if (this.dhType == 'horizontal') {
       var deltaX
         = Math.floor(event.clientX - this.origX - (this.offsetWidth / 2));
-      this.rightBlock.style.left = (this.origRight + deltaX) + 'px;';
-      this.leftBlock.style.width = (this.origLeft + deltaX) + 'px;';
+      this.rightBlock.style.left = (this.origRight + deltaX) + 'px';
+      this.leftBlock.style.width = (this.origLeft + deltaX) + 'px';
     } else if (this.dhType == 'vertical') {
       var deltaY
         = Math.floor(event.clientY - this.origY - (this.offsetHeight / 2));
-      this.lowerBlock.style.top = (this.origLower + deltaY - delta) + 'px;';
-      this.upperBlock.style.height = (this.origUpper + deltaY - delta) + 'px;';
+      this.lowerBlock.style.top = (this.origLower + deltaY - delta) + 'px';
+      this.upperBlock.style.height = (this.origUpper + deltaY - delta) + 'px';
     }
  
-    document.removeEventListener("mouseup", this.documentStopHandleDragging, true);
-    document.removeEventListener("mousemove", this.documentMove, true);
+    if (window.addEventListener) {
+      window.removeEventListener("mouseup", this.documentStopHandleDragging, true);
+      window.removeEventListener("mousemove", this.documentMove, true);      
+    } else if (document.addEventListener) {
+      document.removeEventListener("mouseup", this.documentStopHandleDragging, true);
+      document.removeEventListener("mousemove", this.documentMove, true);
+    }
     document.body.setAttribute('style', '');
 
     this.move(event);
@@ -87,7 +106,7 @@ var SOGoDragHandlesInterface = {
       var hX = event.clientX;
       if (hX > -1) {
         var newLeft = Math.floor(hX - (width / 2));
-        this.style.left = newLeft + 'px;';
+        this.style.left = newLeft + 'px';
         event.cancelBubble = true;
       
         return false;
@@ -97,7 +116,7 @@ var SOGoDragHandlesInterface = {
       var hY = event.clientY;
       if (hY > -1) {
         var newTop = Math.floor(hY - (height / 2))  - delta;
-        this.style.top = newTop + 'px;';
+        this.style.top = newTop + 'px';
         event.cancelBubble = true;
 
         return false;
@@ -113,9 +132,9 @@ var SOGoDragHandlesInterface = {
       if (this.offsetLeft > lLeft) {
         var leftdelta = this.rightBlock.offsetLeft - this.offsetLeft;
 
-        this.style.left = lLeft + 'px;';
+        this.style.left = lLeft + 'px';
         this.leftBlock.style.width = '0px';
-        this.rightBlock.style.left = (lLeft + leftdelta) + 'px;';
+        this.rightBlock.style.left = (lLeft + leftdelta) + 'px';
       }
     } else if (this.dhType == 'vertical') {
       var uTop = this.upperBlock.offsetTop;
@@ -123,9 +142,9 @@ var SOGoDragHandlesInterface = {
       if (this.offsetTop > uTop) {
         var topdelta = this.lowerBlock.offsetTop - this.offsetTop;
       
-        this.style.top = uTop + 'px;';
+        this.style.top = uTop + 'px';
         this.upperBlock.style.width = '0px';
-        this.lowerBlock.style.top = (uTop + topdelta) + 'px;';
+        this.lowerBlock.style.top = (uTop + topdelta) + 'px';
       }
     }
   }