]> git.mjollnir.org Git - s9y.git/commitdiff
Fix drag+drop problem in konqueror.
authorgarvinhicking <garvinhicking>
Mon, 26 Jun 2006 11:58:52 +0000 (11:58 +0000)
committergarvinhicking <garvinhicking>
Mon, 26 Jun 2006 11:58:52 +0000 (11:58 +0000)
Major thanks to Ben Levy!

bundled-libs/dragdrop.js
include/functions_plugins_admin.inc.php

index 567b240dbe7ad50e09b639a47012da089b9e4687..a0520ee7b48f59557dbd3a0b616499b21cd674ac 100644 (file)
@@ -1,21 +1,21 @@
 /**********************************************************
  Very minorly modified from the example by Tim Taylor
  http://tool-man.org/examples/sorting.html
+
  Added Coordinate.prototype.inside( northwest, southeast );
+
     Copyright (c) 2005 Tim Taylor Consulting <http://tool-man.org/>
-    
+
     Permission is hereby granted, free of charge, to any person obtaining a
     copy of this software and associated documentation files (the "Software"),
     to deal in the Software without restriction, including without limitation
     the rights to use, copy, modify, merge, publish, distribute, sublicense,
     and/or sell copies of the Software, and to permit persons to whom the
     Software is furnished to do so, subject to the following conditions:
-    
+
     The above copyright notice and this permission notice shall be included
     in all copies or substantial portions of the Software.
-    
+
     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
     OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -124,7 +124,7 @@ Coordinate.prototype.equals = function(that) {
 Coordinate.prototype.inside = function(northwest, southeast) {
     if ((this.x >= northwest.x) && (this.x <= southeast.x) &&
         (this.y >= northwest.y) && (this.y <= southeast.y)) {
-        
+
         return true;
     }
     return false;
@@ -139,12 +139,12 @@ Coordinate.prototype.inside = function(northwest, southeast) {
 /**********************************************************
  Further modified from the example by Tim Taylor
  http://tool-man.org/examples/sorting.html
+
  Changed onMouseMove where it calls group.onDrag and then
  adjusts the offset for changes to the DOM.  If the item
  being moved changed parents it would be off so changed to
  get the absolute offset (recursive northwestOffset).
+
  **********************************************************/
 
 var Drag = {
@@ -167,7 +167,7 @@ var Drag = {
         group.onDragStart = new Function();
         group.onDragEnd = new Function();
         group.onDrag = new Function();
-        
+
         // TODO: use element.prototype.myFunc
         group.setDragHandle = Drag.setDragHandle;
         group.setDragThreshold = Drag.setDragThreshold;
@@ -200,16 +200,23 @@ var Drag = {
     },
 
     setDragHandle : function(handle) {
-        if (handle && handle != null) 
+        if (handle && handle != null) {
             this.handle = handle;
-        else
+        } else {
             this.handle = this;
+        }
 
         this.handle.group = this;
         this.onmousedown = null;
+        // this.onclick = Drag.toggleMe;
+        // this.handle.onclick = Drag.toggleMe;
         this.handle.onmousedown = Drag.onMouseDown;
     },
 
+    toggleMe : function(str) {
+        alert('Toggle: ' + str);
+    },
+
     setDragThreshold : function(threshold) {
         if (isNaN(parseInt(threshold))) return;
 
@@ -243,7 +250,7 @@ var Drag = {
         group.originalZIndex = group.style.zIndex;
         group.initialWindowCoordinate = mouse;
         // TODO: need a better name, but don't yet understand how it
-        // participates in the magic while dragging 
+        // participates in the magic while dragging
         group.dragCoordinate = mouse;
 
         Drag.showStatus(mouse, nwPosition, sePosition, nwOffset, seOffset);
@@ -252,15 +259,15 @@ var Drag = {
 
         // TODO: need better constraint API
         if (group.minX != null)
-            group.minMouseX = mouse.x - nwPosition.x + 
+            group.minMouseX = mouse.x - nwPosition.x +
                     group.minX - nwOffset.x;
-        if (group.maxX != null) 
+        if (group.maxX != null)
             group.maxMouseX = group.minMouseX + group.maxX - group.minX;
 
         if (group.minY != null)
-            group.minMouseY = mouse.y - nwPosition.y + 
+            group.minMouseY = mouse.y - nwPosition.y +
                     group.minY - nwOffset.y;
-        if (group.maxY != null) 
+        if (group.maxY != null)
             group.maxMouseY = group.minMouseY + group.maxY - group.minY;
 
         group.mouseMin = new Coordinate(group.minMouseX, group.minMouseY);
@@ -273,10 +280,10 @@ var Drag = {
     },
 
     showStatus : function(mouse, nwPosition, sePosition, nwOffset, seOffset) {
-        /*window.status = 
-                "mouse: " + mouse.toString() + "    " + 
-                "NW pos: " + nwPosition.toString() + "    " + 
-                "SE pos: " + sePosition.toString() + "    " + 
+        /*window.status =
+                "mouse: " + mouse.toString() + "    " +
+                "NW pos: " + nwPosition.toString() + "    " +
+                "SE pos: " + sePosition.toString() + "    " +
                 "NW offset: " + nwOffset.toString() + "    " +
                 "SE offset: " + seOffset.toString();*/
     },
@@ -324,7 +331,7 @@ var Drag = {
         // TODO: what we really want to do is find the offset from
         // our corner to the mouse coordinate and adjust to keep it
         // the same
-        
+
         // changed to be recursive/use absolute offset for corrections
         var offsetBefore = Coordinates.northwestOffset(group, true);
         group.onDrag(nwPosition, sePosition, nwOffset, seOffset);
@@ -376,7 +383,7 @@ var Drag = {
 /**********************************************************
  Adapted from the sortable lists example by Tim Taylor
  http://tool-man.org/examples/sorting.html
- Modified by Tom Westcott : http://www.cyberdummy.co.uk 
+ Modified by Tom Westcott : http://www.cyberdummy.co.uk
  **********************************************************/
 
 var DragDrop = {
@@ -396,7 +403,7 @@ var DragDrop = {
             this.lastContainer.nextContainer = list;
             this.lastContainer = list;
         }
-        
+
         // these functions are called when an item is draged over
         // a container or out of a container bounds.  onDragOut
         // is also called when the drag ends with an item having
@@ -405,19 +412,19 @@ var DragDrop = {
         list.onDragOut = new Function();
                 list.onDragDrop = new Function();
                 list.group = group;
-        
+
         var items = list.getElementsByTagName( "li" );
-        
+
         for (var i = 0; i < items.length; i++) {
             DragDrop.makeItemDragable(items[i]);
         }
     },
-        
+
     serData : function ( group, theid ) {
         var container = DragDrop.firstContainer;
         var j = 0;
         var string = "";
-        
+
         while (container != null) {
             if(theid != null && container.id != theid) {
               container = container.nextContainer;
@@ -428,13 +435,13 @@ var DragDrop = {
               container = container.nextContainer;
               continue;
             }
-        
+
             j ++;
             if (j > 1) {
               string += ":";
             }
             string += container.id;
-            
+
             var items = container.getElementsByTagName( "li" );
             string += "(";
             for (var i = 0; i < items.length; i++) {
@@ -445,23 +452,25 @@ var DragDrop = {
                 string += items[i].id;
             }
             string += ")";
-                    
+
             container = container.nextContainer;
         }
 
-        return string;   
+        return string;
     },
 
     makeItemDragable : function(item) {
         Drag.makeDraggable(item);
         item.setDragThreshold(5);
-        
+
         // tracks if the item is currently outside all containers
         item.isOutside = false;
-        
+
         item.onDragStart = DragDrop.onDragStart;
         item.onDrag = DragDrop.onDrag;
         item.onDragEnd = DragDrop.onDragEnd;
+
+        item.setDragHandle(document.getElementById('g' + item.id));
     },
 
     onDragStart : function(nwPosition, sePosition, nwOffset, seOffset) {
@@ -475,7 +484,7 @@ var DragDrop = {
             container.southeast = Coordinates.southeastOffset( container, true );
             container = container.nextContainer;
         }
-        
+
         // item starts out over current parent
         this.parentNode.onDragOver();
         parent_id = this.parentNode.id;
@@ -494,7 +503,7 @@ var DragDrop = {
                     // we're inside this one
                     container.onDragOver();
                     this.isOutside = false;
-                    
+
                     // since isOutside was true, the current parent is a
                     // temporary clone of some previous container node and
                     // it needs to be removed from the document
@@ -509,14 +518,14 @@ var DragDrop = {
             // we're still not inside the bounds of any container
             if (this.isOutside)
                 return;
-        
+
         // check if we're outside our parent's bounds
         } else if (!(nwOffset.inside( this.parentNode.northwest, this.parentNode.southeast ) ||
             seOffset.inside( this.parentNode.northwest, this.parentNode.southeast ))) {
-            
+
             this.parentNode.onDragOut();
             this.isOutside = true;
-            
+
             // check if we're inside a new container's bounds
             var container = DragDrop.firstContainer;
             while (container != null) {
@@ -543,13 +552,13 @@ var DragDrop = {
                 return;
             }
         }
-        
+
         // if we get here, we're inside some container bounds, so we do
         // everything the original dragsort script did to swap us into the
         // correct position
-        
+
         var parent = this.parentNode;
-                
+
         var item = this;
         var next = DragUtils.nextItem(item);
         while (next != null && this.offsetTop >= next.offsetTop - 2) {
@@ -575,7 +584,7 @@ var DragDrop = {
 
     onDragEnd : function(nwPosition, sePosition, nwOffset, seOffset) {
         // if the drag ends and we're still outside all containers
-        // it's time to remove ourselves from the document or add 
+        // it's time to remove ourselves from the document or add
                 // to the trash bin
         if (this.isOutside) {
             var container = DragDrop.firstContainer;
@@ -627,24 +636,24 @@ var DragUtils = {
             sibling = sibling.previousSibling;
         }
         return null;
-    }        
+    }
 };
 
 /*************************
  * Custom Serendipity code
  *************************/
+
 function pluginMoverInit() {
     var list = document.getElementById("left_col");
     DragDrop.makeListContainer(list, 'g1');
     list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
     list.onDragOut = function() { this.style["border"] = "none"; };
-    
+
     list = document.getElementById("hide_col");
     DragDrop.makeListContainer(list, 'g1');
     list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
     list.onDragOut = function() {this.style["border"] = "none"; };
-    
+
     list = document.getElementById("right_col");
     DragDrop.makeListContainer(list, 'g1');
     list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
@@ -656,7 +665,7 @@ function pluginMoverInitEvent() {
     DragDrop.makeListContainer(list, 'g1');
     list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
     list.onDragOut = function() { this.style["border"] = "none"; };
-    
+
     list = document.getElementById("eventh_col");
     DragDrop.makeListContainer(list, 'g1');
     list.onDragOver = function() { this.style["border"] = "1px solid #4d759b"; };
@@ -705,7 +714,7 @@ var DOMDrag = {
         o.minY  = typeof minY != 'undefined' ? minY : null;
         o.max   = typeof maxX != 'undefined' ? maxX : null;
         o.maxY  = typeof maxY != 'undefined' ? maxY : null;
-        
+
         o.xMapper = fXMapper ? fXMapper : null;
         o.yMapper = fYMapper ? fYMapper : null;
 
index f7c1683a847228670f97f2091335f2bc711b3aef..3fcfa48e8f81871fe8727d4d606d5b9e6a83f838 100644 (file)
@@ -154,7 +154,9 @@ function show_plugins($event_only = false)
             }
 ?>
             <li class="pluginmanager_item_<?php echo ($sort_idx % 2 ? 'even' : 'uneven'); ?>" id="<?php echo $css_key; ?>">
-                <a href="javascript: return false" id="grab<?php echo $css_key; ?>" class="pluginmanager_grablet"></a>
+                <div id="g<?php echo $css_key; ?>" class="pluginmanager_grablet">
+                    <a href="#" id="grab<?php echo $css_key; ?>"></a>
+                </div>
                 <?php if ($is_plugin_editable) { ?>
                     <input type="checkbox" name="serendipity[plugin_to_remove][]" value="<?php echo $plugin_data['name']; ?>" />
                 <?php } ?>