+var console = console || {
+ log: function(l) {
+ $('log').append(l + <br/>);
+ }
+};
+
var num = function(i) {
return parseInt(i, 10);
};
.animate({ width: 80, height: 80, left: co.x-40, top: co.y-40, opacity: 'hide' }, 1000, function() { $(this).remove(); });
};
-var initMouseEvent = function(type, el, co) {
- var evt = document.createEvent("MouseEvents");
- evt.initMouseEvent(type, true, true, window, 0, 0, 0, co.x, co.y, false, false, false, false, 0, null);
+var initMouseEvent = function(type, el, co, relatedTarget) {
- el.dispatchEvent(evt);
+ //check for DOM-compliant browsers
+ if ($.isFunction(document.createEvent)) {
- if (/^mouseup|mousedown|click$/i.test(type)) {
+ var evt = document.createEvent("MouseEvents");
+ evt.initMouseEvent(type, true, true, window, 0, 0, 0, co.x, co.y, false, false, false, false, 0, null);
+
+ if (relatedTarget && !evt.relatedTarget) {
+ if (type == "mouseout") {
+ evt.toElement = relatedTarget;
+ }
+ else
+ if (type == "mouseover") {
+ evt.fromElement = relatedTarget;
+ }
+ }
+
+ el.dispatchEvent(evt);
+ }
+
+ // IE
+ if (document.createEventObject) {
+
+ }
+
+ if (/^mouseup|mousdemove|mousedown|click$/i.test(type)) {
animateClick(co);
}
};
-$.fn.triggerMousedown = function(co) {
- return initMouseEvent("mousedown", this[0], co);
-};
-
-$.fn.triggerMouseup = function(co) {
- return initMouseEvent("mouseup", this[0], co);
-};
-
-$.fn.triggerMousemove = function(co, target) {
- return initMouseEvent("mousemove", this[0], co);
+$.fn.triggerMouse = function(type, co, relatedTarget) {
+ return initMouseEvent(type, this[0], co, relatedTarget);
};
var xy = function(el, offset) {
$("#resizable1").resizable({
+ //maxHeight: 200,
+
start: function(e, ui) {
console.log('start: [' + e.pageX + ', ' + e.pageY + ']' )
console.log(ui.instance.size, ui.instance.position)
handler.mousedown(function() { /*console.log('down')*/ });
handler.mouseup(function() { /*console.log('up')*/ });
- handler.triggerMousedown( xy(handler) );
+ handler.triggerMouse( "mouseover", xy(handler), handler[0] );
+ handler.triggerMouse( "mousedown", xy(handler) );
+
+ var lastco = [], distance = 30;
- for (var x = 0; x < 50; x += 10) {
- var evt = $(handler).triggerMousemove( xy(handler, [x, x]) );
- console.log(evt)
+ for (var x = 0; x < distance; x++) {
+ var evt = $(handler).triggerMouse( "mousemove", lastco = xy(handler, [x, x]) );
}
- handler.triggerMouseup( xy(handler, [50, 50]) );
+ handler.triggerMouse( "mouseup", lastco );