Changeset 11999
- Timestamp:
- 09/04/07 15:34:08 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/static/jQuery/jquery.easydrag-1.3.js
r11886 r11999 7 7 */ 8 8 9 (function( jQuery){9 (function($){ 10 10 11 11 // to track if the mouse button is pressed … … 26 26 27 27 // returns the mouse (cursor) current position 28 jQuery.getMousePosition = function(e){28 $.getMousePosition = function(e){ 29 29 var posx = 0; 30 30 var posy = 0; … … 45 45 46 46 // updates the position of the current element being dragged 47 jQuery.updatePosition = function(e) {48 var pos = jQuery.getMousePosition(e);47 $.updatePosition = function(e) { 48 var pos = $.getMousePosition(e); 49 49 50 50 var spanX = (pos.x - lastMouseX); 51 51 var spanY = (pos.y - lastMouseY); 52 52 53 jQuery(currentElement).css("top", (lastElemTop + spanY));54 jQuery(currentElement).css("left", (lastElemLeft + spanX));53 $(currentElement).css("top", (lastElemTop + spanY)); 54 $(currentElement).css("left", (lastElemLeft + spanX)); 55 55 } 56 56 57 57 // when the mouse is moved while the mouse button is pressed 58 jQuery(document).mousemove(function(e){58 $(document).mousemove(function(e){ 59 59 if(isMouseDown){ 60 60 // update the position and call the registered function 61 jQuery.updatePosition(e);61 $.updatePosition(e); 62 62 if(dragCallbacks[currentElement.id] != undefined){ 63 63 dragCallbacks[currentElement.id](e); … … 69 69 70 70 // when the mouse button is released 71 jQuery(document).mouseup(function(e){71 $(document).mouseup(function(e){ 72 72 if(isMouseDown){ 73 73 isMouseDown = false; … … 81 81 82 82 // register the function to be called while an element is being dragged 83 jQuery.fn.ondrag = function(callback){83 $.fn.ondrag = function(callback){ 84 84 return this.each(function(){ 85 85 dragCallbacks[this.id] = callback; … … 88 88 89 89 // register the function to be called when an element is dropped 90 jQuery.fn.ondrop = function(callback){90 $.fn.ondrop = function(callback){ 91 91 return this.each(function(){ 92 92 dropCallbacks[this.id] = callback; … … 95 95 96 96 // set an element as draggable - allowBubbling enables/disables event bubbling 97 jQuery.fn.easydrag = function(allowBubbling){97 $.fn.easydrag = function(allowBubbling){ 98 98 99 99 return this.each(function(){ … … 103 103 104 104 // change the mouse pointer 105 jQuery(this).css("cursor", "move");105 $(this).css("cursor", "move"); 106 106 107 107 // when an element receives a mouse press 108 jQuery(this).mousedown(function(e){108 $(this).mousedown(function(e){ 109 109 110 110 // set it as absolute positioned 111 jQuery(this).css("position", "absolute");111 $(this).css("position", "absolute"); 112 112 113 113 // set z-index 114 jQuery(this).css("z-index", "10000");114 $(this).css("z-index", "10000"); 115 115 116 116 // update track variables … … 119 119 120 120 // retrieve positioning properties 121 var pos = jQuery.getMousePosition(e);121 var pos = $.getMousePosition(e); 122 122 lastMouseX = pos.x; 123 123 lastMouseY = pos.y; … … 126 126 lastElemLeft = this.offsetLeft; 127 127 128 jQuery.updatePosition(e);128 $.updatePosition(e); 129 129 130 130 return allowBubbling ? true : false;
