mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-08-07 11:22:28 +08:00
hack to give jquery-simulate drag-n-drop a default interpolation
This commit is contained in:
@@ -32,11 +32,7 @@ describe('eventDrop', function() {
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('.fc-day').width() * 2,
|
||||
dy: $('.fc-day').height(),
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dy: $('.fc-day').height()
|
||||
});
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
@@ -72,11 +68,7 @@ describe('eventDrop', function() {
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('.fc-day').width() * -2,
|
||||
dy: $('.fc-day').height(),
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dy: $('.fc-day').height()
|
||||
});
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
@@ -118,13 +110,8 @@ describe('eventDrop', function() {
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('th.fc-wed').width(), // 1 day
|
||||
dy: $('tr.fc-slot1').height() * 3, // 1.5 hours
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dy: $('tr.fc-slot1').height() * 3 // 1.5 hours
|
||||
});
|
||||
called = true;
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
expect(delta.days()).toBe(1);
|
||||
@@ -158,13 +145,8 @@ describe('eventDrop', function() {
|
||||
$('.fc-event')
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('th.fc-wed').width() * 2, // 2 days
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dx: $('th.fc-wed').width() * 2 // 2 days
|
||||
});
|
||||
called = true;
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
expect(delta.days()).toBe(2);
|
||||
@@ -200,13 +182,8 @@ describe('eventDrop', function() {
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('th.fc-wed').width() * -1,
|
||||
dy: $('.fc-agenda-allday').outerHeight() + $('.fc-agenda-divider').outerHeight(),
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dy: $('.fc-agenda-allday').outerHeight() + $('.fc-agenda-divider').outerHeight()
|
||||
});
|
||||
called = true;
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
expect(delta.days()).toBe(-1);
|
||||
@@ -247,10 +224,6 @@ describe('eventDrop', function() {
|
||||
.simulate('drag', {
|
||||
dx: $('th.fc-wed').width() * -1,
|
||||
dy: -$('.fc-agenda-allday').outerHeight(),
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
// the all day slot works off of mouse-moving coordinates
|
||||
var offset = eventElm.offset();
|
||||
|
||||
@@ -32,11 +32,7 @@ describe('eventResize', function() {
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('.fc-day').width() * -2,
|
||||
dy: $('.fc-day').height(),
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dy: $('.fc-day').height()
|
||||
});
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
@@ -92,11 +88,7 @@ describe('eventResize', function() {
|
||||
$('.fc-event .ui-resizable-handle')
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dx: $('th.fc-wed').width() * 1.5, // two days
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dx: $('th.fc-wed').width() * 1.5 // two days
|
||||
});
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
@@ -118,25 +110,23 @@ describe('eventResize', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when resizing a timed event', function() {
|
||||
it('should have correct arguments with a timed delta', function(done) {
|
||||
describe('when resizing a timed event with an end', function() {
|
||||
beforeEach(function() {
|
||||
options.events = [ {
|
||||
title: 'timed event event',
|
||||
start: '2014-06-11T05:00:00',
|
||||
end: '2014-06-11T07:00:00',
|
||||
allDay: false
|
||||
} ];
|
||||
});
|
||||
|
||||
it('should have correct arguments with a timed delta', function(done) {
|
||||
init(
|
||||
function() {
|
||||
$('.fc-event .ui-resizable-handle')
|
||||
.simulate('mouseover') // for our dumb optimization
|
||||
.simulate('drag-n-drop', {
|
||||
dy: $('tr.fc-slot1').height() * 4.5, // 5 slots, so 2.5 hours
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
}
|
||||
dy: $('tr.fc-slot1').height() * 4.5 // 5 slots, so 2.5 hours
|
||||
});
|
||||
},
|
||||
function(event, delta, revertFunc) {
|
||||
|
||||
@@ -38,10 +38,6 @@ describe('select callback', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-day[data-date="2014-04-28"]').simulate('drag-n-drop', {
|
||||
dropTarget: '.fc-day[data-date="2014-05-06"]',
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
@@ -63,10 +59,6 @@ describe('select callback', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-day[data-date="2014-04-28"]').simulate('drag-n-drop', {
|
||||
dropTarget: '.fc-day[data-date="2014-04-28"]',
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
@@ -95,10 +87,6 @@ describe('select callback', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-agenda-allday .fc-day-content').simulate('drag-n-drop', { // middle will be 2014-05-28
|
||||
dx: $('.fc-sun').outerWidth() * (isRTL ? -1 : 1), // the width of one column
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
@@ -119,10 +107,6 @@ describe('select callback', function() {
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-agenda-allday .fc-day-content').simulate('drag-n-drop', { // middle will be 2014-05-28
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
@@ -146,10 +130,6 @@ describe('select callback', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('tr.fc-slot18 td').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
|
||||
dy: $('tr.fc-slot18 td').outerHeight() * 2, // move down two slots
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
@@ -170,10 +150,6 @@ describe('select callback', function() {
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('tr.fc-slot18 td').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
|
||||
interpolation: {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
},
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
|
||||
Vendored
+23
@@ -28,4 +28,27 @@
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Give jquery-simulate-ext drag-n-drop a default interpolation.
|
||||
*/
|
||||
|
||||
var originalSimulate = $.fn.simulate;
|
||||
|
||||
$.fn.simulate = function(eventName, options) {
|
||||
|
||||
if (eventName == 'drag' || eventName == 'drop' || eventName == 'drag-n-drop') {
|
||||
options = options || {};
|
||||
if (options.interpolation === undefined) {
|
||||
options.interpolation = {
|
||||
stepCount: 10,
|
||||
duration: 100
|
||||
};
|
||||
}
|
||||
return originalSimulate.call(this, eventName, options);
|
||||
}
|
||||
|
||||
return originalSimulate.apply(this, arguments);
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user