pass native js event to select/unselect callbacks, final touches for 1.4.7

This commit is contained in:
Adam Shaw 2010-07-05 16:07:40 -07:00
parent 1729499290
commit 91e436dc0a
8 changed files with 58 additions and 21 deletions

View file

@ -1,4 +1,18 @@
version 1.4.7 (7/5/10)
- "dropping" external objects onto the calendar
- droppable (boolean, to turn on/off)
- dropAccept (to filter which events the calendar will accept)
- drop (trigger)
- selectable options can now be specified with a View Option Hash
- bugfixes
- dragged & reverted events having wrong time text (issue 406)
- bug rendering events that have an endtime with seconds, but no hours/minutes (issue 477)
- gotoDate date overflow bug (issue 429)
- wrong date reported when clicking on edge of last column in agenda views (412)
- support newlines in event titles
- select/unselect callbacks now passes native js event
version 1.4.6 (5/31/10) version 1.4.6 (5/31/10)
- "selecting" days or timeslots - "selecting" days or timeslots
- options: selectable, selectHelper, unselectAuto, unselectCancel - options: selectable, selectHelper, unselectAuto, unselectCancel

View file

@ -971,7 +971,7 @@ function Agenda(element, options, methods, viewName) {
function slotSelectionMousedown(ev) { function slotSelectionMousedown(ev) {
if (view.option('selectable')) { if (view.option('selectable')) {
unselect(); unselect(ev);
var _mousedownElement = this; var _mousedownElement = this;
var dates; var dates;
hoverListener.start(function(cell, origCell) { hoverListener.start(function(cell, origCell) {
@ -995,8 +995,9 @@ function Agenda(element, options, methods, viewName) {
if (dates) { if (dates) {
if (+dates[0] == +dates[1]) { if (+dates[0] == +dates[1]) {
view.trigger('dayClick', _mousedownElement, dates[0], false, ev); view.trigger('dayClick', _mousedownElement, dates[0], false, ev);
// BUG: _mousedownElement will sometimes be the overlay
} }
reportSelection(dates[0], dates[3], false); reportSelection(dates[0], dates[3], false, ev);
} }
}); });
} }
@ -1021,16 +1022,16 @@ function Agenda(element, options, methods, viewName) {
reportSelection(startDate, endDate, allDay); reportSelection(startDate, endDate, allDay);
}; };
function reportSelection(startDate, endDate, allDay) { function reportSelection(startDate, endDate, allDay, ev) {
selected = true; selected = true;
view.trigger('select', view, startDate, endDate, allDay); view.trigger('select', view, startDate, endDate, allDay, ev);
} }
function unselect() { function unselect(ev) {
if (selected) { if (selected) {
clearSelection(); clearSelection();
selected = false; selected = false;
view.trigger('unselect', view); view.trigger('unselect', view, ev);
} }
} }
view.unselect = unselect; view.unselect = unselect;

View file

@ -542,16 +542,16 @@ function Grid(element, options, methods, viewName) {
reportSelection(startDate, endDate, allDay); reportSelection(startDate, endDate, allDay);
}; };
function reportSelection(startDate, endDate, allDay) { function reportSelection(startDate, endDate, allDay, ev) {
selected = true; selected = true;
view.trigger('select', view, startDate, endDate, allDay); view.trigger('select', view, startDate, endDate, allDay, ev);
} }
function unselect() { function unselect(ev) {
if (selected) { if (selected) {
clearOverlay(); clearOverlay();
selected = false; selected = false;
view.trigger('unselect', view); view.trigger('unselect', view, ev);
} }
} }
view.unselect = unselect; view.unselect = unselect;

View file

@ -71,7 +71,9 @@ var defaults = {
}, },
//selectable: false, //selectable: false,
unselectAuto: true unselectAuto: true,
dropAccept: '*'
}; };
@ -834,7 +836,7 @@ $.fn.fullCalendar = function(options) {
var e = $(_e); var e = $(_e);
if (!e.parents('.fc').length) { // not already inside a calendar if (!e.parents('.fc').length) { // not already inside a calendar
var accept = options.dropAccept; var accept = options.dropAccept;
if (!accept || ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept))) { if ($.isFunction(accept) ? accept.call(_e, e) : e.is(accept)) {
_dragElement = _e; _dragElement = _e;
view.dragStart(_dragElement, ev, ui); view.dragStart(_dragElement, ev, ui);
} }

View file

@ -3,7 +3,7 @@
function selection_dayMousedown(view, hoverListener, cellDate, cellIsAllDay, renderSelection, clearSelection, reportSelection, unselect) { function selection_dayMousedown(view, hoverListener, cellDate, cellIsAllDay, renderSelection, clearSelection, reportSelection, unselect) {
return function(ev) { return function(ev) {
if (view.option('selectable')) { if (view.option('selectable')) {
unselect(); unselect(ev);
var _mousedownElement = this; var _mousedownElement = this;
var dates; var dates;
hoverListener.start(function(cell, origCell) { hoverListener.start(function(cell, origCell) {
@ -20,8 +20,9 @@ function selection_dayMousedown(view, hoverListener, cellDate, cellIsAllDay, ren
if (dates) { if (dates) {
if (+dates[0] == +dates[1]) { if (+dates[0] == +dates[1]) {
view.trigger('dayClick', _mousedownElement, dates[0], true, ev); view.trigger('dayClick', _mousedownElement, dates[0], true, ev);
// BUG: _mousedownElement will sometimes be the overlay
} }
reportSelection(dates[0], dates[1], true); reportSelection(dates[0], dates[1], true, ev);
} }
}); });
} }
@ -38,7 +39,7 @@ function selection_unselectAuto(view, unselect) {
return; return;
} }
} }
unselect(); unselect(ev);
}); });
} }
} }

View file

@ -13,13 +13,18 @@
var y = date.getFullYear(); var y = date.getFullYear();
$('#calendar').fullCalendar({ $('#calendar').fullCalendar({
editable: true, editable: true,
droppable: true, droppable: true,
drop: function(date, allDay) { drop: function(date, allDay, ev) {
console.log('drop', date, allDay); console.log('drop', date, allDay, ev);
}, },
//defaultView: 'agendaWeek', //defaultView: 'agendaWeek',
//firstDay: 1,
//isRTL: true, //isRTL: true,
//minTime: '6:30am',
header: { header: {
left: 'prev,next today', left: 'prev,next today',
center: 'title', center: 'title',

View file

@ -80,9 +80,11 @@ if (_build) {
includeJS('../src/gcal.js'); includeJS('../src/gcal.js');
} }
if (!window.DISABLE_FIREBUG_LITE) { //if (!window.DISABLE_FIREBUG_LITE) {
if (!window.console || !console.log) {
includeJS('firebug-lite/firebug-lite-compressed.js'); includeJS('firebug-lite/firebug-lite-compressed.js');
} }
//}
window.onload = function() { window.onload = function() {
$('body').append( $('body').append(

View file

@ -21,10 +21,13 @@
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay' right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
}, },
//defaultView: 'agendaWeek', //defaultView: 'agendaWeek',
//firstDay: 1,
//isRTL: true, //isRTL: true,
//minTime: 7, //minTime: 7,
//weekends: false, //weekends: false,
//allDaySlot: false, //allDaySlot: false,
selectable: true, selectable: true,
/* /*
selectable: { selectable: {
@ -32,24 +35,33 @@
agenda: true agenda: true
}, },
*/ */
//selectHelper: true,
selectHelper: true,
/* /*
selectHelper: function(start, end) { selectHelper: function(start, end) {
return $("<div style='background:red' />").text(start+' '+end); return $("<div style='background:red' />").text(start+' '+end);
}, },
*/ */
//unselectAuto: false, //unselectAuto: false,
//unselectCancel: '.fc', //unselectCancel: '.fc',
select: function(start, end, allDay) {
select: function(start, end, allDay, ev) {
console.log( console.log(
'---- selection ----\n' + '---- selection ----\n' +
'start: ' + start + '\n' + 'start: ' + start + '\n' +
'end: ' + end + '\n' + 'end: ' + end + '\n' +
'allDay: ' + allDay 'allDay: ' + allDay
); );
if (ev) {
//console.log('select mouse: ' + ev.pageX + ', ' + ev.pageY);
}
}, },
unselect: function() { unselect: function(ev) {
console.log('unselect'); console.log('unselect');
if (ev) {
//console.log('unselect mouse: ' + ev.pageX + ', ' + ev.pageY);
}
}, },
dayClick: function(date, allDay) { dayClick: function(date, allDay) {
console.log('DAYCLICK', date, allDay); console.log('DAYCLICK', date, allDay);