Changeset 467

Show
Ignore:
Timestamp:
07/17/08 08:04:42 (20 months ago)
Author:
paul.bakaus
Message:

draggable: fixed relative position bug (please NEVER check in elem.style just for performance optimizations)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ui/ui.draggable.js

    r455 r467  
    1616        init: function() { 
    1717                 
    18                 //Initialize needed constants 
    19                 var o = this.options, positioned = /^(?:r|a|f)/, element = this.element[0]; 
    20                  
    21                 if (!this.element.length) 
     18                if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) 
     19                        this.element[0].style.position = 'relative'; 
     20 
     21                (this.options.disabled && this.element.addClass('ui-draggable-disabled')); 
     22                 
     23                this.mouseInit(); 
     24                 
     25        }, 
     26        mouseStart: function(e) { 
     27                 
     28                var o = this.options; 
     29                 
     30                if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) 
    2231                        return false; 
    23  
    24                 var style = element.style || {},  
    25                         position = style.position || "static";  
    26                  
    27                 //Position the node 
    28                 if (o.helper == 'original' && !positioned.test(position)) 
    29                         style.position = 'relative'; 
    30  
    31                 (o.disabled && this.element.addClass('ui-draggable-disabled')); 
    32                  
    33                 this.mouseInit(); 
    34                  
    35         }, 
    36         mouseStart: function(e) { 
    37                 var o = this.options; 
    38                  
    39                 if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false; 
    40                  
     32                 
     33                //Check if we have a valid handle 
    4134                var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; 
    42                  
    43          
    4435                $(this.options.handle, this.element).find("*").andSelf().each(function() { 
    4536                        if(this == e.target) handle = true; 
     
    4738                if (!handle) return false; 
    4839                 
    49                 if($.ui.ddmanager) $.ui.ddmanager.current = this; 
     40                if($.ui.ddmanager) 
     41                        $.ui.ddmanager.current = this; 
    5042                 
    5143                //Create and append the visible helper