Bug Tracker

Changeset 5655

Show
Ignore:
Timestamp:
05/21/08 12:10:13 (4 months ago)
Author:
scott.gonzalez
Message:

ui-experimental mouse: cleanup

Files:
1 modified

Legend:

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

    r5652 r5655  
    156156     
    157157    /** Mouse Interaction Plugin **/ 
    158  
     158     
    159159    $.ui.mouse = { 
    160160        mouseInit: function() { 
    161161            var self = this; 
    162  
     162             
    163163            this.element.bind('mousedown.mouse', function(e) { 
    164164                return self.mouseDown(e); 
    165165            }); 
    166  
     166             
    167167            // Prevent text selection in IE 
    168168            if ($.browser.msie) { 
     
    170170                this.element.attr('unselectable', 'on'); 
    171171            } 
    172  
     172             
    173173            this.started = false; 
    174174        }, 
    175  
     175         
    176176        mouseDestroy: function() { 
    177177            this.element.unbind('.mouse'); 
    178  
     178             
    179179            // Restore text selection in IE 
    180             if ($.browser.msie) { 
    181                 this.element.attr('unselectable', this._mouseUnselectable); 
    182             } 
    183         }, 
    184  
    185         // These are placeholder methods, to be overriden by extending plugin 
    186         mouseStart: function(e) {}, 
    187         mouseDrag: function(e) {}, 
    188         mouseStop: function(e) {}, 
    189  
     180            ($.browser.msie 
     181                && this.element.attr('unselectable', this._mouseUnselectable)); 
     182        }, 
     183         
    190184        mouseDown: function(e) { 
    191             var self = this; 
    192             self._mouseDownEvent = e; 
    193  
    194             var btnIsLeft = (e.which == 1); 
    195             var elIsCancel = ($(e.target).is(this.options.cancel)); 
    196             if (!btnIsLeft || elIsCancel) 
     185            this._mouseDownEvent = e; 
     186             
     187            var self = this, 
     188                btnIsLeft = (e.which == 1), 
     189                elIsCancel = ($(e.target).is(this.options.cancel)); 
     190            if (!btnIsLeft || elIsCancel) { 
    197191                return true; 
    198  
     192            } 
     193             
    199194            this._mouseDelayMet = false; 
    200             this._mouseDelayTimer = setTimeout(function() { self._mouseDelayMet = true; } , this.options.delay) 
    201  
     195            this._mouseDelayTimer = setTimeout(function() { 
     196                self._mouseDelayMet = true; 
     197            } , this.options.delay); 
     198             
    202199            $(document) 
    203                 .bind('mousemove.mouse', function(e) { return self.mouseMove(e); }) 
    204                 .bind('mouseup.mouse', function(e) { return self.mouseUp(e); }); 
    205  
     200                .bind('mousemove.mouse', function(e) { 
     201                    return self.mouseMove(e); 
     202                }) 
     203                .bind('mouseup.mouse', function(e) { 
     204                    return self.mouseUp(e); 
     205                }); 
     206             
    206207            return false; 
    207208        }, 
     209         
    208210        mouseMove: function(e) { 
    209211            // IE mouseup check - mouseup happened when mouse was out of window 
    210             if ($.browser.msie && !e.button) 
     212            if ($.browser.msie && !e.button) { 
    211213                return this.mouseUp(e); 
    212  
     214            } 
     215             
    213216            if (this._mouseStarted) { 
    214217                this.mouseDrag(e); 
     
    217220             
    218221            if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) { 
    219                 this._mouseStarted = (this.mouseStart(this._mouseDownEvent, e) !== false); 
    220                 if (!this._mouseStarted) 
    221                     this.mouseUp(e); 
    222             } 
    223  
     222                this._mouseStarted = 
     223                    (this.mouseStart(this._mouseDownEvent, e) !== false); 
     224                (this._mouseStarted || this.mouseUp(e)); 
     225            } 
     226             
    224227            return !this._mouseStarted; 
    225228        }, 
     229         
    226230        mouseUp: function(e) { 
    227231            $(document).unbind('.mouse'); 
     232             
    228233            if (this._mouseStarted) { 
    229234                this._mouseStarted = false; 
    230235                this.mouseStop(e); 
    231236            } 
     237             
    232238            return false; 
    233239        }, 
     240         
    234241        mouseDistanceMet: function(e) { 
    235242            return (Math.max( 
     
    239246            ); 
    240247        }, 
     248         
    241249        mouseDelayMet: function(e) { 
    242250            return this._mouseDelayMet; 
    243         } 
    244     } 
    245  
     251        }, 
     252         
     253        // These are placeholder methods, to be overriden by extending plugin 
     254        mouseStart: function(e) {}, 
     255        mouseDrag: function(e) {}, 
     256        mouseStop: function(e) {} 
     257    }; 
     258     
    246259    $.ui.mouse.defaults = { 
    247260        cancel: "", 
     
    249262        delay: 0 
    250263    }; 
    251      
    252264})(jQuery);