2008-06-06 03:58:15 +00:00
|
|
|
/*
|
2009-02-02 07:12:37 +00:00
|
|
|
* draggable_core.js
|
2008-06-06 03:58:15 +00:00
|
|
|
*/
|
2009-02-01 00:25:58 +00:00
|
|
|
|
|
|
|
(function($) {
|
2008-06-06 06:34:09 +00:00
|
|
|
|
2008-06-07 18:03:19 +00:00
|
|
|
module("draggable");
|
2008-06-04 02:34:33 +00:00
|
|
|
|
2008-06-07 06:09:04 +00:00
|
|
|
test("element types", function() {
|
2012-04-19 14:27:06 +00:00
|
|
|
var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form' +
|
|
|
|
',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr' +
|
2012-10-30 23:12:17 +00:00
|
|
|
',acronym,code,samp,kbd,var,img,hr' +
|
2012-04-19 14:27:06 +00:00
|
|
|
',input,button,label,select,iframe').split(',');
|
2008-06-07 06:09:04 +00:00
|
|
|
|
2012-11-09 20:02:12 +00:00
|
|
|
expect( typeNames.length * 2 );
|
2012-10-30 23:12:17 +00:00
|
|
|
|
2008-06-07 06:09:04 +00:00
|
|
|
$.each(typeNames, function(i) {
|
2012-11-03 20:17:16 +00:00
|
|
|
var offsetBefore, offsetAfter,
|
|
|
|
typeName = typeNames[i],
|
|
|
|
el = $(document.createElement(typeName)).appendTo('#main');
|
|
|
|
|
2012-04-19 14:27:06 +00:00
|
|
|
(typeName === 'table' && el.append("<tr><td>content</td></tr>"));
|
2008-06-07 06:09:04 +00:00
|
|
|
el.draggable({ cancel: '' });
|
2012-10-30 23:12:17 +00:00
|
|
|
offsetBefore = el.offset();
|
2012-11-03 20:17:16 +00:00
|
|
|
TestHelpers.draggable.drag(el, 50, 50);
|
|
|
|
offsetAfter = el.offset();
|
2012-11-04 14:31:56 +00:00
|
|
|
// there are some rounding errors in FF, Chrome, and IE9, so we can't say equal, we have to settle for close enough
|
2012-11-09 20:02:12 +00:00
|
|
|
closeEnough(offsetBefore.left, offsetAfter.left - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
|
|
|
|
closeEnough(offsetBefore.top, offsetAfter.top - 50, 1, "dragged[50, 50] " + "<" + typeName + ">");
|
2008-06-07 06:09:04 +00:00
|
|
|
el.draggable("destroy");
|
|
|
|
el.remove();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2008-06-04 02:34:33 +00:00
|
|
|
test("No options, relative", function() {
|
2012-10-30 23:12:17 +00:00
|
|
|
expect( 1 );
|
2012-11-03 20:17:16 +00:00
|
|
|
var el = $("#draggable1").draggable();
|
2012-10-30 23:12:17 +00:00
|
|
|
TestHelpers.draggable.shouldMove(el);
|
2008-06-04 02:34:33 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test("No options, absolute", function() {
|
2012-10-30 23:12:17 +00:00
|
|
|
expect( 1 );
|
2012-11-03 20:17:16 +00:00
|
|
|
var el = $("#draggable2").draggable();
|
2012-10-30 23:12:17 +00:00
|
|
|
TestHelpers.draggable.shouldMove(el);
|
2008-06-04 02:34:33 +00:00
|
|
|
});
|
|
|
|
|
2008-06-09 05:59:18 +00:00
|
|
|
})(jQuery);
|