Changeset 563

Show
Ignore:
Timestamp:
08/17/08 01:15:49 (19 months ago)
Author:
cloudream@…
Message:

internal methods: mouse*

Location:
trunk/ui
Files:
5 modified

Legend:

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

    r552 r563  
    203203 
    204204$.ui.mouse = { 
    205         mouseInit: function() { 
     205        _mouseInit: function() { 
    206206                var self = this; 
    207207         
    208208                this.element.bind('mousedown.'+this.widgetName, function(e) { 
    209                         return self.mouseDown(e); 
     209                        return self._mouseDown(e); 
    210210                }); 
    211211                 
     
    221221        // TODO: make sure destroying one instance of mouse doesn't mess with 
    222222        // other instances of mouse 
    223         mouseDestroy: function() { 
     223        _mouseDestroy: function() { 
    224224                this.element.unbind('.'+this.widgetName); 
    225225                 
     
    229229        }, 
    230230         
    231         mouseDown: function(e) { 
     231        _mouseDown: function(e) { 
    232232                // we may have missed mouseup (out of window) 
    233                 (this._mouseStarted && this.mouseUp(e)); 
     233                (this._mouseStarted && this._mouseUp(e)); 
    234234                 
    235235                this._mouseDownEvent = e; 
     
    238238                        btnIsLeft = (e.which == 1), 
    239239                        elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false); 
    240                 if (!btnIsLeft || elIsCancel || !this.mouseCapture(e)) { 
     240                if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) { 
    241241                        return true; 
    242242                } 
    243243                 
    244                 this._mouseDelayMet = !this.options.delay; 
    245                 if (!this._mouseDelayMet) { 
     244                this.mouseDelayMet = !this.options.delay; 
     245                if (!this.mouseDelayMet) { 
    246246                        this._mouseDelayTimer = setTimeout(function() { 
    247                                 self._mouseDelayMet = true; 
     247                                self.mouseDelayMet = true; 
    248248                        }, this.options.delay); 
    249249                } 
    250250                 
    251                 if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) { 
    252                         this._mouseStarted = (this.mouseStart(e) !== false); 
     251                if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) { 
     252                        this._mouseStarted = (this._mouseStart(e) !== false); 
    253253                        if (!this._mouseStarted) { 
    254254                                e.preventDefault(); 
     
    259259                // these delegates are required to keep context 
    260260                this._mouseMoveDelegate = function(e) { 
    261                         return self.mouseMove(e); 
     261                        return self._mouseMove(e); 
    262262                }; 
    263263                this._mouseUpDelegate = function(e) { 
    264                         return self.mouseUp(e); 
     264                        return self._mouseUp(e); 
    265265                }; 
    266266                $(document) 
     
    271271        }, 
    272272         
    273         mouseMove: function(e) { 
     273        _mouseMove: function(e) { 
    274274                // IE mouseup check - mouseup happened when mouse was out of window 
    275275                if ($.browser.msie && !e.button) { 
    276                         return this.mouseUp(e); 
     276                        return this._mouseUp(e); 
    277277                } 
    278278                 
    279279                if (this._mouseStarted) { 
    280                         this.mouseDrag(e); 
     280                        this._mouseDrag(e); 
    281281                        return false; 
    282282                } 
    283283                 
    284                 if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) { 
     284                if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) { 
    285285                        this._mouseStarted = 
    286                                 (this.mouseStart(this._mouseDownEvent, e) !== false); 
    287                         (this._mouseStarted ? this.mouseDrag(e) : this.mouseUp(e)); 
     286                                (this._mouseStart(this._mouseDownEvent, e) !== false); 
     287                        (this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e)); 
    288288                } 
    289289                 
     
    291291        }, 
    292292         
    293         mouseUp: function(e) { 
     293        _mouseUp: function(e) { 
    294294                $(document) 
    295295                        .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate) 
     
    298298                if (this._mouseStarted) { 
    299299                        this._mouseStarted = false; 
    300                         this.mouseStop(e); 
     300                        this._mouseStop(e); 
    301301                } 
    302302                 
     
    304304        }, 
    305305         
    306         mouseDistanceMet: function(e) { 
     306        _mouseDistanceMet: function(e) { 
    307307                return (Math.max( 
    308308                                Math.abs(this._mouseDownEvent.pageX - e.pageX), 
     
    312312        }, 
    313313         
    314         mouseDelayMet: function(e) { 
    315                 return this._mouseDelayMet; 
     314        _mouseDelayMet: function(e) { 
     315                return this.mouseDelayMet; 
    316316        }, 
    317317         
    318318        // These are placeholder methods, to be overriden by extending plugin 
    319         mouseStart: function(e) {}, 
    320         mouseDrag: function(e) {}, 
    321         mouseStop: function(e) {}, 
    322         mouseCapture: function(e) { return true; } 
     319        _mouseStart: function(e) {}, 
     320        _mouseDrag: function(e) {}, 
     321        _mouseStop: function(e) {}, 
     322        _mouseCapture: function(e) { return true; } 
    323323}; 
    324324 
  • trunk/ui/ui.draggable.js

    r561 r563  
    2222                (this.options.disabled && this.element.addClass('ui-draggable-disabled')); 
    2323                 
    24                 this.mouseInit(); 
    25                  
    26         }, 
    27         mouseStart: function(e) { 
     24                this._mouseInit(); 
     25                 
     26        }, 
     27        _mouseStart: function(e) { 
    2828                 
    2929                var o = this.options; 
     
    136136                 
    137137                this.helper.addClass("ui-draggable-dragging"); 
    138                 this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position 
     138                this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position 
    139139                return true; 
    140140        }, 
     
    208208                return position; 
    209209        }, 
    210         mouseDrag: function(e) { 
     210        _mouseDrag: function(e) { 
    211211         
    212212                //Compute the helpers position 
     
    223223                return false; 
    224224        }, 
    225         mouseStop: function(e) { 
     225        _mouseStop: function(e) { 
    226226                 
    227227                //If we are using droppables, inform the manager about the drop 
     
    269269                if(!this.element.data('draggable')) return; 
    270270                this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable-dragging ui-draggable-disabled'); 
    271                 this.mouseDestroy(); 
     271                this._mouseDestroy(); 
    272272        } 
    273273})); 
     
    493493                                this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work) 
    494494                                if(this.shouldRevert) this.instance.options.revert = true; //revert here 
    495                                 this.instance.mouseStop(e); 
     495                                this.instance._mouseStop(e); 
    496496                                 
    497497                                //Also propagate receive event, since the sortable is actually receiving a element 
     
    535535                                 
    536536                                        e.target = this.instance.currentItem[0]; 
    537                                         this.instance.mouseCapture(e, true); 
    538                                         this.instance.mouseStart(e, true, true); 
     537                                        this.instance._mouseCapture(e, true); 
     538                                        this.instance._mouseStart(e, true, true); 
    539539 
    540540                                        //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes 
     
    549549                                 
    550550                                //Provided we did all the previous steps, we can fire the drag event of the sortable on every draggable drag, when it intersects with the sortable 
    551                                 if(this.instance.currentItem) this.instance.mouseDrag(e); 
     551                                if(this.instance.currentItem) this.instance._mouseDrag(e); 
    552552                                 
    553553                        } else { 
     
    559559                                        this.instance.cancelHelperRemoval = true; 
    560560                                        this.instance.options.revert = false; //No revert here 
    561                                         this.instance.mouseStop(e, true); 
     561                                        this.instance._mouseStop(e, true); 
    562562                                        this.instance.options.helper = this.instance.options._helper; 
    563563                                         
  • trunk/ui/ui.resizable.js

    r560 r563  
    213213                } 
    214214                 
    215                 this.mouseInit(); 
     215                this._mouseInit(); 
    216216        }, 
    217217        plugins: {}, 
     
    235235                var el = this.element, wrapped = el.children(".ui-resizable").get(0); 
    236236                 
    237                 this.mouseDestroy(); 
     237                this._mouseDestroy(); 
    238238                 
    239239                var _destroy = function(exp) { 
     
    258258                } 
    259259        }, 
    260         mouseStart: function(e) { 
     260        _mouseStart: function(e) { 
    261261                if(this.options.disabled) return false; 
    262262                 
     
    313313                return true; 
    314314        }, 
    315         mouseDrag: function(e) { 
     315        _mouseDrag: function(e) { 
    316316                 
    317317                //Increase performance, avoid regex 
     
    349349                return false; 
    350350        }, 
    351         mouseStop: function(e) { 
     351        _mouseStop: function(e) { 
    352352                 
    353353                this.options.resizing = false; 
  • trunk/ui/ui.selectable.js

    r558 r563  
    4646                this.selectees = selectees.addClass("ui-selectee"); 
    4747                 
    48                 this.mouseInit(); 
     48                this._mouseInit(); 
    4949                 
    5050                this.helper = $(document.createElement('div')) 
     
    6464                        .removeData("selectable") 
    6565                        .unbind(".selectable"); 
    66                 this.mouseDestroy(); 
    67         }, 
    68         mouseStart: function(e) { 
     66                this._mouseDestroy(); 
     67        }, 
     68        _mouseStart: function(e) { 
    6969                var self = this; 
    7070                 
     
    122122                return this.options.keyboard ? !isSelectee : true; 
    123123        }, 
    124         mouseDrag: function(e) { 
     124        _mouseDrag: function(e) { 
    125125                var self = this; 
    126126                this.dragged = true; 
     
    211211                return false; 
    212212        }, 
    213         mouseStop: function(e) { 
     213        _mouseStop: function(e) { 
    214214                var self = this; 
    215215                 
  • trunk/ui/ui.sortable.js

    r562 r563  
    4242 
    4343                //Initialize mouse events for interaction 
    44                 this.mouseInit(); 
     44                this._mouseInit(); 
    4545                 
    4646        }, 
     
    284284                        .removeData("sortable") 
    285285                        .unbind(".sortable"); 
    286                 this.mouseDestroy(); 
     286                this._mouseDestroy(); 
    287287                 
    288288                for ( var i = this.items.length - 1; i >= 0; i-- ) 
     
    361361        }, 
    362362         
    363         mouseCapture: function(e, overrideHandle) { 
     363        _mouseCapture: function(e, overrideHandle) { 
    364364         
    365365                if(this.options.disabled || this.options.type == 'static') return false; 
     
    391391        }, 
    392392         
    393         mouseStart: function(e, overrideHandle, noActivation) { 
     393        _mouseStart: function(e, overrideHandle, noActivation) { 
    394394 
    395395                var o = this.options; 
     
    500500                this.dragging = true; 
    501501 
    502                 this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position 
     502                this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position 
    503503                return true; 
    504504 
     
    567567        }, 
    568568         
    569         mouseDrag: function(e) { 
     569        _mouseDrag: function(e) { 
    570570 
    571571                //Compute the helpers position 
     
    634634        }, 
    635635         
    636         mouseStop: function(e, noPropagation) { 
     636        _mouseStop: function(e, noPropagation) { 
    637637 
    638638                //If we are using droppables, inform the manager about the drop