]> source.dussan.org Git - jquery-ui.git/commitdiff
internal methods: mouse*
authorChi Cheng <cloudream@gmail.com>
Sun, 17 Aug 2008 08:15:49 +0000 (08:15 +0000)
committerChi Cheng <cloudream@gmail.com>
Sun, 17 Aug 2008 08:15:49 +0000 (08:15 +0000)
ui/ui.core.js
ui/ui.draggable.js
ui/ui.resizable.js
ui/ui.selectable.js
ui/ui.sortable.js

index 49828f9bf9124e7b4d611371e33ebc2c064bc131..3110c12268a8e1ee1567af94f6e4b1e79276525d 100644 (file)
@@ -202,11 +202,11 @@ $.ui = {
 /** Mouse Interaction Plugin **/
 
 $.ui.mouse = {
-       mouseInit: function() {
+       _mouseInit: function() {
                var self = this;
        
                this.element.bind('mousedown.'+this.widgetName, function(e) {
-                       return self.mouseDown(e);
+                       return self._mouseDown(e);
                });
                
                // Prevent text selection in IE
@@ -220,7 +220,7 @@ $.ui.mouse = {
        
        // TODO: make sure destroying one instance of mouse doesn't mess with
        // other instances of mouse
-       mouseDestroy: function() {
+       _mouseDestroy: function() {
                this.element.unbind('.'+this.widgetName);
                
                // Restore text selection in IE
@@ -228,28 +228,28 @@ $.ui.mouse = {
                        && this.element.attr('unselectable', this._mouseUnselectable));
        },
        
-       mouseDown: function(e) {
+       _mouseDown: function(e) {
                // we may have missed mouseup (out of window)
-               (this._mouseStarted && this.mouseUp(e));
+               (this._mouseStarted && this._mouseUp(e));
                
                this._mouseDownEvent = e;
                
                var self = this,
                        btnIsLeft = (e.which == 1),
                        elIsCancel = (typeof this.options.cancel == "string" ? $(e.target).parents().add(e.target).filter(this.options.cancel).length : false);
-               if (!btnIsLeft || elIsCancel || !this.mouseCapture(e)) {
+               if (!btnIsLeft || elIsCancel || !this._mouseCapture(e)) {
                        return true;
                }
                
-               this._mouseDelayMet = !this.options.delay;
-               if (!this._mouseDelayMet) {
+               this.mouseDelayMet = !this.options.delay;
+               if (!this.mouseDelayMet) {
                        this._mouseDelayTimer = setTimeout(function() {
-                               self._mouseDelayMet = true;
+                               self.mouseDelayMet = true;
                        }, this.options.delay);
                }
                
-               if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
-                       this._mouseStarted = (this.mouseStart(e) !== false);
+               if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
+                       this._mouseStarted = (this._mouseStart(e) !== false);
                        if (!this._mouseStarted) {
                                e.preventDefault();
                                return true;
@@ -258,10 +258,10 @@ $.ui.mouse = {
                
                // these delegates are required to keep context
                this._mouseMoveDelegate = function(e) {
-                       return self.mouseMove(e);
+                       return self._mouseMove(e);
                };
                this._mouseUpDelegate = function(e) {
-                       return self.mouseUp(e);
+                       return self._mouseUp(e);
                };
                $(document)
                        .bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
@@ -270,40 +270,40 @@ $.ui.mouse = {
                return false;
        },
        
-       mouseMove: function(e) {
+       _mouseMove: function(e) {
                // IE mouseup check - mouseup happened when mouse was out of window
                if ($.browser.msie && !e.button) {
-                       return this.mouseUp(e);
+                       return this._mouseUp(e);
                }
                
                if (this._mouseStarted) {
-                       this.mouseDrag(e);
+                       this._mouseDrag(e);
                        return false;
                }
                
-               if (this.mouseDistanceMet(e) && this.mouseDelayMet(e)) {
+               if (this._mouseDistanceMet(e) && this._mouseDelayMet(e)) {
                        this._mouseStarted =
-                               (this.mouseStart(this._mouseDownEvent, e) !== false);
-                       (this._mouseStarted ? this.mouseDrag(e) : this.mouseUp(e));
+                               (this._mouseStart(this._mouseDownEvent, e) !== false);
+                       (this._mouseStarted ? this._mouseDrag(e) : this._mouseUp(e));
                }
                
                return !this._mouseStarted;
        },
        
-       mouseUp: function(e) {
+       _mouseUp: function(e) {
                $(document)
                        .unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
                        .unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
                
                if (this._mouseStarted) {
                        this._mouseStarted = false;
-                       this.mouseStop(e);
+                       this._mouseStop(e);
                }
                
                return false;
        },
        
-       mouseDistanceMet: function(e) {
+       _mouseDistanceMet: function(e) {
                return (Math.max(
                                Math.abs(this._mouseDownEvent.pageX - e.pageX),
                                Math.abs(this._mouseDownEvent.pageY - e.pageY)
@@ -311,15 +311,15 @@ $.ui.mouse = {
                );
        },
        
-       mouseDelayMet: function(e) {
-               return this._mouseDelayMet;
+       _mouseDelayMet: function(e) {
+               return this.mouseDelayMet;
        },
        
        // These are placeholder methods, to be overriden by extending plugin
-       mouseStart: function(e) {},
-       mouseDrag: function(e) {},
-       mouseStop: function(e) {},
-       mouseCapture: function(e) { return true; }
+       _mouseStart: function(e) {},
+       _mouseDrag: function(e) {},
+       _mouseStop: function(e) {},
+       _mouseCapture: function(e) { return true; }
 };
 
 $.ui.mouse.defaults = {
index 905a170914292ae8630595348a84762344e673f3..82feaf2e29a09054b7f420e92619492466d57d0b 100644 (file)
@@ -21,10 +21,10 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                (this.options.cssNamespace && this.element.addClass(this.options.cssNamespace+"-draggable"));
                (this.options.disabled && this.element.addClass('ui-draggable-disabled'));
                
-               this.mouseInit();
+               this._mouseInit();
                
        },
-       mouseStart: function(e) {
+       _mouseStart: function(e) {
                
                var o = this.options;
                
@@ -135,7 +135,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                if ($.ui.ddmanager && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e);
                
                this.helper.addClass("ui-draggable-dragging");
-               this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+               this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
                return true;
        },
        _convertPositionTo: function(d, pos) {
@@ -207,7 +207,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                
                return position;
        },
-       mouseDrag: function(e) {
+       _mouseDrag: function(e) {
        
                //Compute the helpers position
                this.position = this._generatePosition(e);
@@ -222,7 +222,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
                
                return false;
        },
-       mouseStop: function(e) {
+       _mouseStop: function(e) {
                
                //If we are using droppables, inform the manager about the drop
                var dropped = false;
@@ -268,7 +268,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
        destroy: function() {
                if(!this.element.data('draggable')) return;
                this.element.removeData("draggable").unbind(".draggable").removeClass('ui-draggable-dragging ui-draggable-disabled');
-               this.mouseDestroy();
+               this._mouseDestroy();
        }
 }));
 
@@ -492,7 +492,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
                                this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
                                if(this.shouldRevert) this.instance.options.revert = true; //revert here
-                               this.instance.mouseStop(e);
+                               this.instance._mouseStop(e);
                                
                                //Also propagate receive event, since the sortable is actually receiving a element
                                this.instance.element.triggerHandler("sortreceive", [e, $.extend(this.instance.ui(), { sender: inst.element })], this.instance.options["receive"]);
@@ -534,8 +534,8 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                        this.instance.options.helper = function() { return ui.helper[0]; };
                                
                                        e.target = this.instance.currentItem[0];
-                                       this.instance.mouseCapture(e, true);
-                                       this.instance.mouseStart(e, true, true);
+                                       this.instance._mouseCapture(e, true);
+                                       this.instance._mouseStart(e, true, true);
 
                                        //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
                                        this.instance.offset.click.top = inst.offset.click.top;
@@ -548,7 +548,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                }
                                
                                //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
-                               if(this.instance.currentItem) this.instance.mouseDrag(e);
+                               if(this.instance.currentItem) this.instance._mouseDrag(e);
                                
                        } else {
                                
@@ -558,7 +558,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
                                        this.instance.isOver = 0;
                                        this.instance.cancelHelperRemoval = true;
                                        this.instance.options.revert = false; //No revert here
-                                       this.instance.mouseStop(e, true);
+                                       this.instance._mouseStop(e, true);
                                        this.instance.options.helper = this.instance.options._helper;
                                        
                                        //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
index d8509deaa1aa395798298656612d852600902b52..0e0e447c6ffeb3ecb13869862e0494478b71b651 100644 (file)
@@ -212,7 +212,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
                        });
                }
                
-               this.mouseInit();
+               this._mouseInit();
        },
        plugins: {},
        ui: function() {
@@ -234,7 +234,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
        destroy: function() {
                var el = this.element, wrapped = el.children(".ui-resizable").get(0);
                
-               this.mouseDestroy();
+               this._mouseDestroy();
                
                var _destroy = function(exp) {
                        $(exp).removeClass("ui-resizable ui-resizable-disabled")
@@ -257,7 +257,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
                        _destroy(wrapped);
                }
        },
-       mouseStart: function(e) {
+       _mouseStart: function(e) {
                if(this.options.disabled) return false;
                
                var handle = false;
@@ -312,7 +312,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
                this._propagate("start", e);
                return true;
        },
-       mouseDrag: function(e) {
+       _mouseDrag: function(e) {
                
                //Increase performance, avoid regex
                var el = this.helper, o = this.options, props = {},
@@ -348,7 +348,7 @@ $.widget("ui.resizable", $.extend({}, $.ui.mouse, {
                
                return false;
        },
-       mouseStop: function(e) {
+       _mouseStop: function(e) {
                
                this.options.resizing = false;
                var o = this.options, num = function(v) { return parseInt(v, 10) || 0; }, self = this;
index bcea447d00e7f5d9d5504efd84f411d0a3c89311..862894c51db4f7dcfc4308ca0853ac454754cc95 100644 (file)
@@ -45,7 +45,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
 
                this.selectees = selectees.addClass("ui-selectee");
                
-               this.mouseInit();
+               this._mouseInit();
                
                this.helper = $(document.createElement('div'))
                        .css({border:'1px dotted black'})
@@ -63,9 +63,9 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
                        .removeClass("ui-selectable ui-selectable-disabled")
                        .removeData("selectable")
                        .unbind(".selectable");
-               this.mouseDestroy();
+               this._mouseDestroy();
        },
-       mouseStart: function(e) {
+       _mouseStart: function(e) {
                var self = this;
                
                this.opos = [e.pageX, e.pageY];
@@ -121,7 +121,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
                });
                return this.options.keyboard ? !isSelectee : true;
        },
-       mouseDrag: function(e) {
+       _mouseDrag: function(e) {
                var self = this;
                this.dragged = true;
                
@@ -210,7 +210,7 @@ $.widget("ui.selectable", $.extend({}, $.ui.mouse, {
                
                return false;
        },
-       mouseStop: function(e) {
+       _mouseStop: function(e) {
                var self = this;
                
                this.dragged = false;
index 0813d16cb5a5797aeee311cb0d2697ac5843be18..9ca6519ccfe4f1bd20ddbba21f302957f6185bbf 100644 (file)
@@ -41,7 +41,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                this.offset = this.element.offset();
 
                //Initialize mouse events for interaction
-               this.mouseInit();
+               this._mouseInit();
                
        },
        plugins: {},
@@ -283,7 +283,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                        .removeClass("ui-sortable ui-sortable-disabled")
                        .removeData("sortable")
                        .unbind(".sortable");
-               this.mouseDestroy();
+               this._mouseDestroy();
                
                for ( var i = this.items.length - 1; i >= 0; i-- )
                        this.items[i].item.removeData("sortable-item");
@@ -360,7 +360,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                };                      
        },
        
-       mouseCapture: function(e, overrideHandle) {
+       _mouseCapture: function(e, overrideHandle) {
        
                if(this.options.disabled || this.options.type == 'static') return false;
 
@@ -390,7 +390,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                        
        },
        
-       mouseStart: function(e, overrideHandle, noActivation) {
+       _mouseStart: function(e, overrideHandle, noActivation) {
 
                var o = this.options;
                this.currentContainer = this;
@@ -499,7 +499,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
 
                this.dragging = true;
 
-               this.mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
+               this._mouseDrag(e); //Execute the drag once - this causes the helper not to be visible before getting its correct position
                return true;
 
 
@@ -566,7 +566,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
                return position;
        },
        
-       mouseDrag: function(e) {
+       _mouseDrag: function(e) {
 
                //Compute the helpers position
                this.position = this._generatePosition(e);
@@ -633,7 +633,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
 
        },
        
-       mouseStop: function(e, noPropagation) {
+       _mouseStop: function(e, noPropagation) {
 
                //If we are using droppables, inform the manager about the drop
                if ($.ui.ddmanager && !this.options.dropBehaviour)