jQuery: The Write Less, Do More JavaScript Library

Changeset 5666

Show
Ignore:
Timestamp:
05/22/08 12:11:15 (3 months ago)
Author:
rdworth
Message:

ui experimental mouse - migrated resizable. Still a couple issues with draggable+resizable

Location:
branches/ui-experimental/mouse
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/ui-experimental/mouse/ui.core.js

    r5655 r5666  
    258258     
    259259    $.ui.mouse.defaults = { 
    260         cancel: "", 
     260        cancel: null, 
    261261        distance: 0, 
    262262        delay: 0 
  • branches/ui-experimental/mouse/ui.resizable.js

    r5663 r5666  
    1515;(function($) { 
    1616     
    17     $.widget("ui.resizable", { 
     17    $.widget("ui.resizable", $.extend($.ui.mouse, { 
    1818        init: function() { 
    1919 
    2020            var self = this, o = this.options; 
    21              
     21 
    2222            var elpos = this.element.css('position'); 
    2323             
     
    210210            } 
    211211         
    212             //Initialize mouse events for interaction 
    213             this.element.mouse({ 
    214                 executor: this, 
    215                 delay: 0, 
    216                 distance: 0, 
    217                 dragPrevention: ['input','textarea','button','select','option'], 
    218                 start: this.start, 
    219                 stop: this.stop, 
    220                 drag: this.drag, 
    221                 condition: function(e) { 
    222                     if(this.disabled) return false; 
    223                     for(var i in this.options.handles) { 
    224                         if($(this.options.handles[i])[0] == e.target) return true; 
    225                     } 
    226                     return false; 
    227                 } 
    228             }); 
     212            this.mouseInit(); 
    229213             
    230214        }, 
     
    242226        }, 
    243227        destroy: function() { 
    244             var el = this.element, wrapped = el.children(".ui-resizable").get(0), 
    245              
    246             _destroy = function(exp) { 
     228            var el = this.element, wrapped = el.children(".ui-resizable").get(0); 
     229             
     230            this.mouseDestroy(); 
     231 
     232            var _destroy = function(exp) { 
    247233                $(exp).removeClass("ui-resizable ui-resizable-disabled") 
    248                     .mouse("destroy").removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); 
     234                    .removeData("resizable").unbind(".resizable").find('.ui-resizable-handle').remove(); 
     235 
    249236            }; 
    250237             
     
    273260            this.disabled = true; 
    274261        }, 
    275         start: function(e) { 
     262        mouseStart: function(e) { 
     263            if(this.disabled) return false; 
     264 
    276265            var o = this.options, iniPos = this.element.position(), el = this.element,  
    277266                num = function(v) { return parseInt(v, 10) || 0; }, ie6 = $.browser.msie && $.browser.version < 7; 
     
    313302                 
    314303            this.propagate("start", e); 
     304            for(var i in this.options.handles) { 
     305                if($(this.options.handles[i])[0] == e.target) return true; 
     306            } 
    315307            return false; 
    316308        }, 
    317         stop: function(e) { 
     309        mouseDrag: function(e) { 
     310            //Increase performance, avoid regex 
     311            var el = this.helper, o = this.options, props = {}, 
     312                self = this, smp = this.originalMousePosition, a = this.axis; 
     313 
     314            var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0; 
     315            var trigger = this._change[a]; 
     316            if (!trigger) return false; 
     317             
     318            // Calculate the attrs that will be change 
     319            var data = trigger.apply(this, [e, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; 
     320             
     321            if (o._aspectRatio || e.shiftKey) 
     322                data = this._updateRatio(data, e); 
     323             
     324            data = this._respectSize(data, e); 
     325             
     326            this.propagate("resize", e); 
     327             
     328            el.css({ 
     329                top: this.position.top + "px", left: this.position.left + "px",  
     330                width: this.size.width + "px", height: this.size.height + "px" 
     331            }); 
     332             
     333            if (!o.proxy && o.proportionallyResize) 
     334                this._proportionallyResize(); 
     335             
     336            this._updateCache(data); 
     337             
     338            return false; 
     339        }, 
     340        mouseStop: function(e) { 
    318341            this.options.resizing = false; 
    319342            var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this; 
     
    339362     
    340363            this.propagate("stop", e);   
    341             return false; 
    342         }, 
    343         drag: function(e) { 
    344             //Increase performance, avoid regex 
    345             var el = this.helper, o = this.options, props = {}, 
    346                 self = this, smp = this.originalMousePosition, a = this.axis; 
    347  
    348             var dx = (e.pageX-smp.left)||0, dy = (e.pageY-smp.top)||0; 
    349             var trigger = this._change[a]; 
    350             if (!trigger) return false; 
    351              
    352             // Calculate the attrs that will be change 
    353             var data = trigger.apply(this, [e, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; 
    354              
    355             if (o._aspectRatio || e.shiftKey) 
    356                 data = this._updateRatio(data, e); 
    357              
    358             data = this._respectSize(data, e); 
    359              
    360             this.propagate("resize", e); 
    361              
    362             el.css({ 
    363                 top: this.position.top + "px", left: this.position.left + "px",  
    364                 width: this.size.width + "px", height: this.size.height + "px" 
    365             }); 
    366              
    367             if (!o.proxy && o.proportionallyResize) 
    368                 this._proportionallyResize(); 
    369              
    370             this._updateCache(data); 
    371              
    372364            return false; 
    373365        }, 
     
    499491            } 
    500492        } 
    501     }); 
     493    })); 
    502494     
    503495    $.extend($.ui.resizable, { 
    504496        defaults: { 
     497            cancel: ":input,button", 
     498            distance: 0, 
     499            delay: 0, 
     500 
    505501            preventDefault: true, 
    506502            transparent: false,