/** 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
// 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
&& 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;
// 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)
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)
);
},
- 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 = {
(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;
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) {
return position;
},
- mouseDrag: function(e) {
+ _mouseDrag: function(e) {
//Compute the helpers position
this.position = this._generatePosition(e);
return false;
},
- mouseStop: function(e) {
+ _mouseStop: function(e) {
//If we are using droppables, inform the manager about the drop
var dropped = false;
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();
}
}));
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"]);
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;
}
//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 {
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
});
}
- this.mouseInit();
+ this._mouseInit();
},
plugins: {},
ui: function() {
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")
_destroy(wrapped);
}
},
- mouseStart: function(e) {
+ _mouseStart: function(e) {
if(this.options.disabled) return false;
var handle = false;
this._propagate("start", e);
return true;
},
- mouseDrag: function(e) {
+ _mouseDrag: function(e) {
//Increase performance, avoid regex
var el = this.helper, o = this.options, props = {},
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;
this.selectees = selectees.addClass("ui-selectee");
- this.mouseInit();
+ this._mouseInit();
this.helper = $(document.createElement('div'))
.css({border:'1px dotted black'})
.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];
});
return this.options.keyboard ? !isSelectee : true;
},
- mouseDrag: function(e) {
+ _mouseDrag: function(e) {
var self = this;
this.dragged = true;
return false;
},
- mouseStop: function(e) {
+ _mouseStop: function(e) {
var self = this;
this.dragged = false;
this.offset = this.element.offset();
//Initialize mouse events for interaction
- this.mouseInit();
+ this._mouseInit();
},
plugins: {},
.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");
};
},
- mouseCapture: function(e, overrideHandle) {
+ _mouseCapture: function(e, overrideHandle) {
if(this.options.disabled || this.options.type == 'static') return false;
},
- mouseStart: function(e, overrideHandle, noActivation) {
+ _mouseStart: function(e, overrideHandle, noActivation) {
var o = this.options;
this.currentContainer = this;
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;
return position;
},
- mouseDrag: function(e) {
+ _mouseDrag: function(e) {
//Compute the helpers position
this.position = this._generatePosition(e);
},
- 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)