Bug Tracker

Changeset 5645

Show
Ignore:
Timestamp:
05/20/08 20:13:08 (6 months ago)
Author:
braeker
Message:

alsoResize now supporting individual elements and css properties

Files:
1 modified

Legend:

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

    r5628 r5645  
    684684         
    685685        start: function(e, ui) { 
    686             var o = ui.options, self = ui.instance; 
    687              
    688             $(o.alsoResize).each(function() { 
    689                 $(this).data("resizable-alsoresize-start", { 
    690                     width: parseInt($(this).css('width'), 10), height: parseInt($(this).css('height'), 10), 
    691                     left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) 
     686            var o = ui.options, self = ui.instance,  
     687             
     688            _store = function(exp) { 
     689                $(exp).each(function() { 
     690                    $(this).data("resizable-alsoresize-start", { 
     691                        width: parseInt($(this).css('width'), 10), height: parseInt($(this).css('height'), 10), 
     692                        left: parseInt($(this).css('left'), 10), top: parseInt($(this).css('top'), 10) 
     693                    }); 
    692694                }); 
    693             }); 
     695            }; 
     696             
     697            if (typeof(o.alsoResize) == 'object') { 
     698                $.each(o.alsoResize, function(exp, c) { _store(exp); }); 
     699            }else{ 
     700                _store(o.alsoResize); 
     701            }  
    694702        }, 
    695703         
    696704        resize: function(e, ui){ 
    697             var o = ui.options, self = ui.instance; 
    698              
    699             var delta = { 
    700                 height: (self.size.height - self.originalSize.height) || 0, 
    701                 width: (self.size.width - self.originalSize.width) || 0, 
    702                 top: (self.position.top - self.originalPosition.top) || 0, 
    703                 left: (self.position.left - self.originalPosition.left) || 0 
     705            var o = ui.options, self = ui.instance, os = self.originalSize, op = self.originalPosition; 
     706             
     707            var delta = {  
     708                height: (self.size.height - os.height) || 0, width: (self.size.width - os.width) || 0, 
     709                top: (self.position.top - op.top) || 0, left: (self.position.left - op.left) || 0 
     710            }, 
     711             
     712            _alsoResize = function(exp, c) { 
     713                $(exp).each(function() { 
     714                    var start = $(this).data("resizable-alsoresize-start"), style = {}, css = c && c.length ? c : ['width', 'height', 'top', 'left']; 
     715                     
     716                    $.each(css || ['width', 'height', 'top', 'left'], function(i, prop) { 
     717                        style[prop] = (start[prop] + delta[prop]) || null 
     718                    }); 
     719                     
     720                    $(this).css(style); 
     721                }); 
    704722            }; 
    705723             
    706             $(o.alsoResize, self.element).each(function() { 
    707                 var start = $(this).data("resizable-alsoresize-start"), style = {}; 
    708                  
    709                 $.each(o.alsoResizeCss || ['width', 'height', 'top', 'left'], function(i, prop) { 
    710                     style[prop] = (start[prop] + delta[prop]) || null 
    711                 }); 
    712                  
    713                 $(this).css(style); 
    714             }); 
     724            if (typeof(o.alsoResize) == 'object') { 
     725                $.each(o.alsoResize, function(exp, c) { _alsoResize(exp, c); }); 
     726            }else{ 
     727                _alsoResize(o.alsoResize); 
     728            } 
    715729        }, 
    716730         
     
    718732            $(this).removeData("resizable-alsoresize-start"); 
    719733        } 
    720          
    721734    }); 
    722735