Skip to content
Permalink
Browse files

Resizable automated tests - Resize fixed

  • Loading branch information
eduardolundgren committed May 24, 2008
1 parent 058fcb6 commit 26b2908040c48ffbd8f53bdb0d8bee66a93e0da3
Showing with 43 additions and 20 deletions.
  1. +1 −0 ui/tests/resizable.html
  2. +42 −20 ui/tests/resizable.js
@@ -18,6 +18,7 @@
<h1 id="header">jQuery Test Suite</h1>
<h2 id="banner"></h2>
<h2 id="userAgent"></h2>
<h2 id="log"></h2>

<div id="main" style="border: 1px solid black; padding: 10px; margin: 10px;">
<div id='resizable1' style="background: green; width: 200px; height: 100px;">I'm a resizable.</div>
@@ -1,3 +1,9 @@
var console = console || {
log: function(l) {
$('log').append(l + <br/>);
}
};

var num = function(i) {
return parseInt(i, 10);
};
@@ -8,30 +14,42 @@ var animateClick = function(co) {
.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);
}

return evt;
};


$.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) {
@@ -43,6 +61,8 @@ $(document).ready(function() {

$("#resizable1").resizable({

//maxHeight: 200,

start: function(e, ui) {
console.log('start: [' + e.pageX + ', ' + e.pageY + ']' )
console.log(ui.instance.size, ui.instance.position)
@@ -63,14 +83,16 @@ $(document).ready(function() {
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 );



0 comments on commit 26b2908

Please sign in to comment.
You can’t perform that action at this time.