Changeset 11999

Show
Ignore:
Timestamp:
09/04/07 15:34:08 (1 year ago)
Author:
w_i
Message:

Updated the drag plugin

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/static/jQuery/jquery.easydrag-1.3.js

    r11886 r11999  
    77*/ 
    88 
    9 (function(jQuery){ 
     9(function($){ 
    1010 
    1111        // to track if the mouse button is pressed 
     
    2626 
    2727        // returns the mouse (cursor) current position 
    28         jQuery.getMousePosition = function(e){ 
     28        $.getMousePosition = function(e){ 
    2929                var posx = 0; 
    3030                var posy = 0; 
     
    4545 
    4646        // 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); 
    4949 
    5050                var spanX = (pos.x - lastMouseX); 
    5151                var spanY = (pos.y - lastMouseY); 
    5252 
    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)); 
    5555        } 
    5656 
    5757        // when the mouse is moved while the mouse button is pressed 
    58         jQuery(document).mousemove(function(e){ 
     58        $(document).mousemove(function(e){ 
    5959                if(isMouseDown){ 
    6060                        // update the position and call the registered function 
    61                         jQuery.updatePosition(e); 
     61                        $.updatePosition(e); 
    6262                        if(dragCallbacks[currentElement.id] != undefined){ 
    6363                                dragCallbacks[currentElement.id](e); 
     
    6969 
    7070        // when the mouse button is released 
    71         jQuery(document).mouseup(function(e){ 
     71        $(document).mouseup(function(e){ 
    7272                if(isMouseDown){ 
    7373                        isMouseDown = false; 
     
    8181 
    8282        // register the function to be called while an element is being dragged 
    83         jQuery.fn.ondrag = function(callback){ 
     83        $.fn.ondrag = function(callback){ 
    8484                return this.each(function(){ 
    8585                        dragCallbacks[this.id] = callback; 
     
    8888 
    8989        // register the function to be called when an element is dropped 
    90         jQuery.fn.ondrop = function(callback){ 
     90        $.fn.ondrop = function(callback){ 
    9191                return this.each(function(){ 
    9292                        dropCallbacks[this.id] = callback; 
     
    9595 
    9696        // set an element as draggable - allowBubbling enables/disables event bubbling 
    97         jQuery.fn.easydrag = function(allowBubbling){ 
     97        $.fn.easydrag = function(allowBubbling){ 
    9898 
    9999                return this.each(function(){ 
     
    103103 
    104104                        // change the mouse pointer 
    105                         jQuery(this).css("cursor", "move"); 
     105                        $(this).css("cursor", "move"); 
    106106 
    107107                        // when an element receives a mouse press 
    108                         jQuery(this).mousedown(function(e){                    
     108                        $(this).mousedown(function(e){                         
    109109 
    110110                                // set it as absolute positioned 
    111                                 jQuery(this).css("position", "absolute"); 
     111                                $(this).css("position", "absolute"); 
    112112 
    113113                                // set z-index 
    114                                 jQuery(this).css("z-index", "10000"); 
     114                                $(this).css("z-index", "10000"); 
    115115 
    116116                                // update track variables 
     
    119119 
    120120                                // retrieve positioning properties 
    121                                 var pos    = jQuery.getMousePosition(e); 
     121                                var pos    = $.getMousePosition(e); 
    122122                                lastMouseX = pos.x; 
    123123                                lastMouseY = pos.y; 
     
    126126                                lastElemLeft = this.offsetLeft; 
    127127 
    128                                 jQuery.updatePosition(e); 
     128                                $.updatePosition(e); 
    129129 
    130130                                return allowBubbling ? true : false;