mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-08-17 11:19:14 +08:00
issue 829, and tests
This commit is contained in:
@@ -35,9 +35,12 @@ $.extend(DayGrid.prototype, {
|
||||
|
||||
// Removes all rendered event elements
|
||||
destroyEvents: function() {
|
||||
var rowStructs = this.rowStructs || [];
|
||||
var rowStructs;
|
||||
var rowStruct;
|
||||
|
||||
Grid.prototype.destroyEvents.call(this); // call the super-method
|
||||
|
||||
rowStructs = this.rowStructs || [];
|
||||
while ((rowStruct = rowStructs.pop())) {
|
||||
rowStruct.tbodyEl.remove();
|
||||
}
|
||||
|
||||
+14
-10
@@ -4,9 +4,9 @@
|
||||
|
||||
$.extend(Grid.prototype, {
|
||||
|
||||
isMouseOverSeg: false, // is the user's mouse over a segment?
|
||||
isDraggingSeg: false, // is a segment being dragged?
|
||||
isResizingSeg: false, // is a segment being resized?
|
||||
mousedOverSeg: null, // the segment object the user's mouse is over. null if over nothing
|
||||
isDraggingSeg: false, // is a segment being dragged? boolean
|
||||
isResizingSeg: false, // is a segment being resized? boolean
|
||||
|
||||
|
||||
// Renders the given events onto the grid
|
||||
@@ -21,9 +21,9 @@ $.extend(Grid.prototype, {
|
||||
},
|
||||
|
||||
|
||||
// Unrenders all events
|
||||
// Unrenders all events. Subclasses should implement, calling this super-method first.
|
||||
destroyEvents: function() {
|
||||
// subclasses must implement
|
||||
this.triggerSegMouseout(); // trigger an eventMouseout if user's mouse is over an event
|
||||
},
|
||||
|
||||
|
||||
@@ -146,17 +146,21 @@ $.extend(Grid.prototype, {
|
||||
|
||||
// Updates internal state and triggers handlers for when an event element is moused over
|
||||
triggerSegMouseover: function(seg, ev) {
|
||||
if (!this.isMouseOverSeg) {
|
||||
this.isMouseOverSeg = true;
|
||||
if (!this.mousedOverSeg) {
|
||||
this.mousedOverSeg = seg;
|
||||
this.view.trigger('eventMouseover', seg.el[0], seg.event, ev);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// Updates internal state and triggers handlers for when an event element is moused out
|
||||
// Updates internal state and triggers handlers for when an event element is moused out.
|
||||
// Can be given no arguments, in which case it will mouseout the segment that was previously moused over.
|
||||
triggerSegMouseout: function(seg, ev) {
|
||||
if (this.isMouseOverSeg) {
|
||||
this.isMouseOverSeg = false;
|
||||
ev = ev || {}; // if given no args, make a mock mouse event
|
||||
|
||||
if (this.mousedOverSeg) {
|
||||
seg = seg || this.mousedOverSeg; // if given no args, use the currently moused-over segment
|
||||
this.mousedOverSeg = null;
|
||||
this.view.trigger('eventMouseout', seg.el[0], seg.event, ev);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -27,6 +27,8 @@ $.extend(TimeGrid.prototype, {
|
||||
|
||||
// Removes all event segment elements from the view
|
||||
destroyEvents: function() {
|
||||
Grid.prototype.destroyEvents.call(this); // call the super-method
|
||||
|
||||
if (this.eventSkeletonEl) {
|
||||
this.eventSkeletonEl.remove();
|
||||
this.eventSkeletonEl = null;
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
describe('eventMouseover', function() {
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-08-01',
|
||||
scrollTime: '00:00:00'
|
||||
};
|
||||
});
|
||||
|
||||
[ 'month', 'agendaWeek' ].forEach(function(viewName) {
|
||||
describe('for ' + viewName + ' view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = viewName;
|
||||
});
|
||||
it('will trigger a eventMouseout with updateEvent', function(done) {
|
||||
options.events = [ {
|
||||
title: 'event',
|
||||
start: '2014-08-02T01:00:00',
|
||||
className: 'event'
|
||||
} ];
|
||||
options.eventMouseover = function(event, ev) {
|
||||
expect(typeof event).toBe('object');
|
||||
expect(typeof ev).toBe('object');
|
||||
event.title = "YO";
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
};
|
||||
options.eventMouseout = function(event, ev) {
|
||||
expect(typeof event).toBe('object');
|
||||
expect(typeof ev).toBe('object');
|
||||
done();
|
||||
};
|
||||
spyOn(options, 'eventMouseout').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.event').simulate('mouseover');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user