mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-08-11 11:18:47 +08:00
call things "snap" instead of "granularity"
This commit is contained in:
@@ -35,8 +35,8 @@ function AgendaEventRenderer() {
|
||||
var resizableDayEvent = t.resizableDayEvent; // TODO: streamline binding architecture
|
||||
var getColCnt = t.getColCnt;
|
||||
var getColWidth = t.getColWidth;
|
||||
var getGranularityHeight = t.getGranularityHeight;
|
||||
var getGranularityMinutes = t.getGranularityMinutes;
|
||||
var getSnapHeight = t.getSnapHeight;
|
||||
var getSnapMinutes = t.getSnapMinutes;
|
||||
var getBodyContent = t.getBodyContent;
|
||||
var reportEventElement = t.reportEventElement;
|
||||
var showEvents = t.showEvents;
|
||||
@@ -359,8 +359,8 @@ function AgendaEventRenderer() {
|
||||
var dis = opt('isRTL') ? -1 : 1;
|
||||
var hoverListener = getHoverListener();
|
||||
var colWidth = getColWidth();
|
||||
var granularityHeight = getGranularityHeight();
|
||||
var granularityMinutes = getGranularityMinutes();
|
||||
var snapHeight = getSnapHeight();
|
||||
var snapMinutes = getSnapMinutes();
|
||||
var minMinute = getMinMinute();
|
||||
eventElement.draggable({
|
||||
zIndex: 9,
|
||||
@@ -391,9 +391,9 @@ function AgendaEventRenderer() {
|
||||
eventElement.width(colWidth - 10); // don't use entire width
|
||||
setOuterHeight(
|
||||
eventElement,
|
||||
granularityHeight * Math.round(
|
||||
snapHeight * Math.round(
|
||||
(event.end ? ((event.end - event.start) / MINUTE_MS) : opt('defaultEventMinutes')) /
|
||||
granularityMinutes
|
||||
snapMinutes
|
||||
)
|
||||
);
|
||||
eventElement.draggable('option', 'grid', [colWidth, 1]);
|
||||
@@ -425,8 +425,8 @@ function AgendaEventRenderer() {
|
||||
// changed!
|
||||
var minuteDelta = 0;
|
||||
if (!allDay) {
|
||||
minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / granularityHeight)
|
||||
* granularityMinutes
|
||||
minuteDelta = Math.round((eventElement.offset().top - getBodyContent().offset().top) / snapHeight)
|
||||
* snapMinutes
|
||||
+ minMinute
|
||||
- (event.start.getHours() * 60 + event.start.getMinutes());
|
||||
}
|
||||
@@ -459,12 +459,12 @@ function AgendaEventRenderer() {
|
||||
var hoverListener = getHoverListener();
|
||||
var colCnt = getColCnt();
|
||||
var colWidth = getColWidth();
|
||||
var granularityHeight = getGranularityHeight();
|
||||
var granularityMinutes = getGranularityMinutes();
|
||||
var snapHeight = getSnapHeight();
|
||||
var snapMinutes = getSnapMinutes();
|
||||
eventElement.draggable({
|
||||
zIndex: 9,
|
||||
scroll: false,
|
||||
grid: [colWidth, granularityHeight],
|
||||
grid: [colWidth, snapHeight],
|
||||
axis: colCnt==1 ? 'y' : false,
|
||||
opacity: opt('dragOpacity'),
|
||||
revertDuration: opt('dragRevertDuration'),
|
||||
@@ -498,7 +498,7 @@ function AgendaEventRenderer() {
|
||||
}, ev, 'drag');
|
||||
},
|
||||
drag: function(ev, ui) {
|
||||
minuteDelta = Math.round((ui.position.top - origPosition.top) / granularityHeight) * granularityMinutes;
|
||||
minuteDelta = Math.round((ui.position.top - origPosition.top) / snapHeight) * snapMinutes;
|
||||
if (minuteDelta != prevMinuteDelta) {
|
||||
if (!allDay) {
|
||||
updateTimeText(minuteDelta);
|
||||
@@ -535,7 +535,7 @@ function AgendaEventRenderer() {
|
||||
// convert back to original slot-event
|
||||
if (allDay) {
|
||||
timeElement.css('display', ''); // show() was causing display=inline
|
||||
eventElement.draggable('option', 'grid', [colWidth, granularityHeight]);
|
||||
eventElement.draggable('option', 'grid', [colWidth, snapHeight]);
|
||||
allDay = false;
|
||||
}
|
||||
}
|
||||
@@ -548,39 +548,39 @@ function AgendaEventRenderer() {
|
||||
|
||||
|
||||
function resizableSlotEvent(event, eventElement, timeElement) {
|
||||
var granularityDelta, prevGranularityDelta;
|
||||
var granularityHeight = getGranularityHeight();
|
||||
var granularityMinutes = getGranularityMinutes();
|
||||
var snapDelta, prevSnapDelta;
|
||||
var snapHeight = getSnapHeight();
|
||||
var snapMinutes = getSnapMinutes();
|
||||
eventElement.resizable({
|
||||
handles: {
|
||||
s: '.ui-resizable-handle',
|
||||
},
|
||||
grid: granularityHeight,
|
||||
grid: snapHeight,
|
||||
start: function(ev, ui) {
|
||||
granularityDelta = prevGranularityDelta = 0;
|
||||
snapDelta = prevSnapDelta = 0;
|
||||
hideEvents(event, eventElement);
|
||||
eventElement.css('z-index', 9);
|
||||
trigger('eventResizeStart', this, event, ev, ui);
|
||||
},
|
||||
resize: function(ev, ui) {
|
||||
// don't rely on ui.size.height, doesn't take grid into account
|
||||
granularityDelta = Math.round((Math.max(granularityHeight, eventElement.height()) - ui.originalSize.height) / granularityHeight);
|
||||
if (granularityDelta != prevGranularityDelta) {
|
||||
snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight);
|
||||
if (snapDelta != prevSnapDelta) {
|
||||
timeElement.text(
|
||||
formatDates(
|
||||
event.start,
|
||||
(!granularityDelta && !event.end) ? null : // no change, so don't display time range
|
||||
addMinutes(eventEnd(event), granularityMinutes*granularityDelta),
|
||||
(!snapDelta && !event.end) ? null : // no change, so don't display time range
|
||||
addMinutes(eventEnd(event), snapMinutes*snapDelta),
|
||||
opt('timeFormat')
|
||||
)
|
||||
);
|
||||
prevGranularityDelta = granularityDelta;
|
||||
prevSnapDelta = snapDelta;
|
||||
}
|
||||
},
|
||||
stop: function(ev, ui) {
|
||||
trigger('eventResizeStop', this, event, ev, ui);
|
||||
if (granularityDelta) {
|
||||
eventResize(this, event, 0, granularityMinutes*granularityDelta, ev, ui);
|
||||
if (snapDelta) {
|
||||
eventResize(this, event, 0, snapMinutes*snapDelta, ev, ui);
|
||||
}else{
|
||||
eventElement.css('z-index', 8);
|
||||
showEvents(event, eventElement);
|
||||
|
||||
+14
-14
@@ -50,8 +50,8 @@ function AgendaView(element, calendar, viewName) {
|
||||
t.getRowCnt = function() { return 1 };
|
||||
t.getColCnt = function() { return colCnt };
|
||||
t.getColWidth = function() { return colWidth };
|
||||
t.getGranularityHeight = function() { return granularityHeight };
|
||||
t.getGranularityMinutes = function() { return granularityMinutes };
|
||||
t.getSnapHeight = function() { return snapHeight };
|
||||
t.getSnapMinutes = function() { return snapMinutes };
|
||||
t.defaultSelectionEnd = defaultSelectionEnd;
|
||||
t.renderDayOverlay = renderDayOverlay;
|
||||
t.renderSelection = renderSelection;
|
||||
@@ -108,9 +108,9 @@ function AgendaView(element, calendar, viewName) {
|
||||
var gutterWidth;
|
||||
var slotHeight; // TODO: what if slotHeight changes? (see issue 650)
|
||||
|
||||
var granularityMinutes;
|
||||
var granularityRatio; // ratio of number of "selection" slots to normal slots. (ex: 1, 2, 4)
|
||||
var granularityHeight; // holds the pixel hight of a "selection" slot
|
||||
var snapMinutes;
|
||||
var snapRatio; // ratio of number of "selection" slots to normal slots. (ex: 1, 2, 4)
|
||||
var snapHeight; // holds the pixel hight of a "selection" slot
|
||||
|
||||
var colCnt;
|
||||
var slotCnt;
|
||||
@@ -177,7 +177,7 @@ function AgendaView(element, calendar, viewName) {
|
||||
weekNumberFormat = "W";
|
||||
}
|
||||
|
||||
granularityMinutes = opt('granularityMinutes') || opt('slotMinutes');
|
||||
snapMinutes = opt('snapMinutes') || opt('slotMinutes');
|
||||
}
|
||||
|
||||
|
||||
@@ -388,8 +388,8 @@ function AgendaView(element, calendar, viewName) {
|
||||
|
||||
slotHeight = slotTableFirstInner.height() + 1; // +1 for border
|
||||
|
||||
granularityRatio = opt('slotMinutes') / granularityMinutes;
|
||||
granularityHeight = slotHeight / granularityRatio;
|
||||
snapRatio = opt('slotMinutes') / snapMinutes;
|
||||
snapHeight = slotHeight / snapRatio;
|
||||
|
||||
if (dateChanged) {
|
||||
resetScroll();
|
||||
@@ -578,10 +578,10 @@ function AgendaView(element, calendar, viewName) {
|
||||
function constrain(n) {
|
||||
return Math.max(slotScrollerTop, Math.min(slotScrollerBottom, n));
|
||||
}
|
||||
for (var i=0; i<slotCnt*granularityRatio; i++) { // adapt slot count to increased/decreased selection slot count
|
||||
for (var i=0; i<slotCnt*snapRatio; i++) { // adapt slot count to increased/decreased selection slot count
|
||||
rows.push([
|
||||
constrain(slotTableTop + granularityHeight*i),
|
||||
constrain(slotTableTop + granularityHeight*(i+1))
|
||||
constrain(slotTableTop + snapHeight*i),
|
||||
constrain(slotTableTop + snapHeight*(i+1))
|
||||
]);
|
||||
}
|
||||
});
|
||||
@@ -622,7 +622,7 @@ function AgendaView(element, calendar, viewName) {
|
||||
slotIndex--;
|
||||
}
|
||||
if (slotIndex >= 0) {
|
||||
addMinutes(d, minMinute + slotIndex * granularityMinutes);
|
||||
addMinutes(d, minMinute + slotIndex * snapMinutes);
|
||||
}
|
||||
return d;
|
||||
}
|
||||
@@ -785,9 +785,9 @@ function AgendaView(element, calendar, viewName) {
|
||||
var d2 = cellDate(cell);
|
||||
dates = [
|
||||
d1,
|
||||
addMinutes(cloneDate(d1), granularityMinutes), // calculate minutes depending on selection slot minutes
|
||||
addMinutes(cloneDate(d1), snapMinutes), // calculate minutes depending on selection slot minutes
|
||||
d2,
|
||||
addMinutes(cloneDate(d2), granularityMinutes)
|
||||
addMinutes(cloneDate(d2), snapMinutes)
|
||||
].sort(cmp);
|
||||
renderSlotSelection(dates[0], dates[3]);
|
||||
}else{
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
//slotMinutes: 30, // 20
|
||||
granularityMinutes: 15, // 5
|
||||
snapMinutes: 15, // 5
|
||||
|
||||
selectable: true,
|
||||
selectHelper: true,
|
||||
Reference in New Issue
Block a user