mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Resizable automated tests - Resize fixed
This commit is contained in:
parent
058fcb6d5b
commit
26b2908040
@ -18,6 +18,7 @@
|
|||||||
<h1 id="header">jQuery Test Suite</h1>
|
<h1 id="header">jQuery Test Suite</h1>
|
||||||
<h2 id="banner"></h2>
|
<h2 id="banner"></h2>
|
||||||
<h2 id="userAgent"></h2>
|
<h2 id="userAgent"></h2>
|
||||||
|
<h2 id="log"></h2>
|
||||||
|
|
||||||
<div id="main" style="border: 1px solid black; padding: 10px; margin: 10px;">
|
<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>
|
<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) {
|
var num = function(i) {
|
||||||
return parseInt(i, 10);
|
return parseInt(i, 10);
|
||||||
};
|
};
|
||||||
@ -8,13 +14,33 @@ var animateClick = function(co) {
|
|||||||
.animate({ width: 80, height: 80, left: co.x-40, top: co.y-40, opacity: 'hide' }, 1000, function() { $(this).remove(); });
|
.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 initMouseEvent = function(type, el, co, relatedTarget) {
|
||||||
var evt = document.createEvent("MouseEvents");
|
|
||||||
evt.initMouseEvent(type, true, true, window, 0, 0, 0, co.x, co.y, false, false, false, false, 0, null);
|
|
||||||
|
|
||||||
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);
|
animateClick(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,16 +48,8 @@ var initMouseEvent = function(type, el, co) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$.fn.triggerMousedown = function(co) {
|
$.fn.triggerMouse = function(type, co, relatedTarget) {
|
||||||
return initMouseEvent("mousedown", this[0], co);
|
return initMouseEvent(type, this[0], co, relatedTarget);
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.triggerMouseup = function(co) {
|
|
||||||
return initMouseEvent("mouseup", this[0], co);
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.triggerMousemove = function(co, target) {
|
|
||||||
return initMouseEvent("mousemove", this[0], co);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var xy = function(el, offset) {
|
var xy = function(el, offset) {
|
||||||
@ -43,6 +61,8 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$("#resizable1").resizable({
|
$("#resizable1").resizable({
|
||||||
|
|
||||||
|
//maxHeight: 200,
|
||||||
|
|
||||||
start: function(e, ui) {
|
start: function(e, ui) {
|
||||||
console.log('start: [' + e.pageX + ', ' + e.pageY + ']' )
|
console.log('start: [' + e.pageX + ', ' + e.pageY + ']' )
|
||||||
console.log(ui.instance.size, ui.instance.position)
|
console.log(ui.instance.size, ui.instance.position)
|
||||||
@ -63,14 +83,16 @@ $(document).ready(function() {
|
|||||||
handler.mousedown(function() { /*console.log('down')*/ });
|
handler.mousedown(function() { /*console.log('down')*/ });
|
||||||
handler.mouseup(function() { /*console.log('up')*/ });
|
handler.mouseup(function() { /*console.log('up')*/ });
|
||||||
|
|
||||||
handler.triggerMousedown( xy(handler) );
|
handler.triggerMouse( "mouseover", xy(handler), handler[0] );
|
||||||
|
handler.triggerMouse( "mousedown", xy(handler) );
|
||||||
|
|
||||||
for (var x = 0; x < 50; x += 10) {
|
var lastco = [], distance = 30;
|
||||||
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 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user