mirror of
https://github.com/wassname/fullcalendar.git
synced 2026-06-27 16:10:13 +08:00
Removing unused files
This commit is contained in:
@@ -1,942 +0,0 @@
|
||||
|
||||
function AgendaEventRenderer() {
|
||||
var t = this;
|
||||
|
||||
|
||||
// exports
|
||||
t.renderEvents = renderEvents;
|
||||
t.clearEvents = clearEvents;
|
||||
t.slotSegHtml = slotSegHtml;
|
||||
|
||||
|
||||
// imports
|
||||
DayEventRenderer.call(t);
|
||||
var opt = t.opt;
|
||||
var trigger = t.trigger;
|
||||
var isEventDraggable = t.isEventDraggable;
|
||||
var isEventResizable = t.isEventResizable;
|
||||
var eventElementHandlers = t.eventElementHandlers;
|
||||
var setHeight = t.setHeight;
|
||||
var getDaySegmentContainer = t.getDaySegmentContainer;
|
||||
var getSlotSegmentContainer = t.getSlotSegmentContainer;
|
||||
var getHoverListener = t.getHoverListener;
|
||||
var computeDateTop = t.computeDateTop;
|
||||
var getIsCellAllDay = t.getIsCellAllDay;
|
||||
var colContentLeft = t.colContentLeft;
|
||||
var colContentRight = t.colContentRight;
|
||||
var cellToDate = t.cellToDate;
|
||||
var getColCnt = t.getColCnt;
|
||||
var getColWidth = t.getColWidth;
|
||||
var getSnapHeight = t.getSnapHeight;
|
||||
var getSnapDuration = t.getSnapDuration;
|
||||
var getSlotHeight = t.getSlotHeight;
|
||||
var getSlotDuration = t.getSlotDuration;
|
||||
var getSlotContainer = t.getSlotContainer;
|
||||
var reportEventElement = t.reportEventElement;
|
||||
var showEvents = t.showEvents;
|
||||
var hideEvents = t.hideEvents;
|
||||
var eventDrop = t.eventDrop;
|
||||
var eventResize = t.eventResize;
|
||||
var renderDayOverlay = t.renderDayOverlay;
|
||||
var clearOverlays = t.clearOverlays;
|
||||
var renderDayEvents = t.renderDayEvents;
|
||||
var getMinTime = t.getMinTime;
|
||||
var getMaxTime = t.getMaxTime;
|
||||
var calendar = t.calendar;
|
||||
var formatDate = calendar.formatDate;
|
||||
var getEventEnd = calendar.getEventEnd;
|
||||
|
||||
|
||||
// overrides
|
||||
t.draggableDayEvent = draggableDayEvent;
|
||||
|
||||
|
||||
|
||||
/* Rendering
|
||||
----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
function renderEvents(events, modifiedEventId) {
|
||||
var i, len=events.length,
|
||||
dayEvents=[],
|
||||
slotEvents=[];
|
||||
for (i=0; i<len; i++) {
|
||||
if (events[i].allDay) {
|
||||
dayEvents.push(events[i]);
|
||||
}else{
|
||||
slotEvents.push(events[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (opt('allDaySlot')) {
|
||||
renderDayEvents(dayEvents, modifiedEventId);
|
||||
setHeight(); // no params means set to viewHeight
|
||||
}
|
||||
|
||||
renderSlotSegs(compileSlotSegs(slotEvents), modifiedEventId);
|
||||
}
|
||||
|
||||
|
||||
function clearEvents() {
|
||||
getDaySegmentContainer().empty();
|
||||
getSlotSegmentContainer().empty();
|
||||
}
|
||||
|
||||
|
||||
function compileSlotSegs(events) {
|
||||
var colCnt = getColCnt(),
|
||||
minTime = getMinTime(),
|
||||
maxTime = getMaxTime(),
|
||||
cellDate,
|
||||
i,
|
||||
j, seg,
|
||||
colSegs,
|
||||
segs = [];
|
||||
|
||||
for (i=0; i<colCnt; i++) {
|
||||
cellDate = cellToDate(0, i);
|
||||
|
||||
colSegs = sliceSegs(
|
||||
events,
|
||||
cellDate.clone().time(minTime),
|
||||
cellDate.clone().time(maxTime)
|
||||
);
|
||||
|
||||
colSegs = placeSlotSegs(colSegs); // returns a new order
|
||||
|
||||
for (j=0; j<colSegs.length; j++) {
|
||||
seg = colSegs[j];
|
||||
seg.col = i;
|
||||
segs.push(seg);
|
||||
}
|
||||
}
|
||||
|
||||
return segs;
|
||||
}
|
||||
|
||||
|
||||
function sliceSegs(events, rangeStart, rangeEnd) {
|
||||
|
||||
// normalize, because all dates will be compared w/o zones
|
||||
rangeStart = rangeStart.clone().stripZone();
|
||||
rangeEnd = rangeEnd.clone().stripZone();
|
||||
|
||||
var segs = [],
|
||||
i, len=events.length, event,
|
||||
eventStart, eventEnd,
|
||||
segStart, segEnd,
|
||||
isStart, isEnd;
|
||||
for (i=0; i<len; i++) {
|
||||
|
||||
event = events[i];
|
||||
|
||||
// get dates, make copies, then strip zone to normalize
|
||||
eventStart = event.start.clone().stripZone();
|
||||
eventEnd = getEventEnd(event).stripZone();
|
||||
|
||||
if (eventEnd > rangeStart && eventStart < rangeEnd) {
|
||||
|
||||
if (eventStart < rangeStart) {
|
||||
segStart = rangeStart.clone();
|
||||
isStart = false;
|
||||
}
|
||||
else {
|
||||
segStart = eventStart;
|
||||
isStart = true;
|
||||
}
|
||||
|
||||
if (eventEnd > rangeEnd) {
|
||||
segEnd = rangeEnd.clone();
|
||||
isEnd = false;
|
||||
}
|
||||
else {
|
||||
segEnd = eventEnd;
|
||||
isEnd = true;
|
||||
}
|
||||
|
||||
segs.push({
|
||||
event: event,
|
||||
start: segStart,
|
||||
end: segEnd,
|
||||
isStart: isStart,
|
||||
isEnd: isEnd
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return segs.sort(compareSlotSegs);
|
||||
}
|
||||
|
||||
|
||||
// renders events in the 'time slots' at the bottom
|
||||
// TODO: when we refactor this, when user returns `false` eventRender, don't have empty space
|
||||
// TODO: refactor will include using pixels to detect collisions instead of dates (handy for seg cmp)
|
||||
|
||||
function renderSlotSegs(segs, modifiedEventId) {
|
||||
|
||||
var i, segCnt=segs.length, seg,
|
||||
event,
|
||||
top,
|
||||
bottom,
|
||||
columnLeft,
|
||||
columnRight,
|
||||
columnWidth,
|
||||
width,
|
||||
left,
|
||||
right,
|
||||
html = '',
|
||||
eventElements,
|
||||
eventElement,
|
||||
triggerRes,
|
||||
titleElement,
|
||||
height,
|
||||
slotSegmentContainer = getSlotSegmentContainer(),
|
||||
isRTL = opt('isRTL');
|
||||
|
||||
// calculate position/dimensions, create html
|
||||
for (i=0; i<segCnt; i++) {
|
||||
seg = segs[i];
|
||||
event = seg.event;
|
||||
top = computeDateTop(seg.start, seg.start);
|
||||
bottom = computeDateTop(seg.end, seg.start);
|
||||
columnLeft = colContentLeft(seg.col);
|
||||
columnRight = colContentRight(seg.col);
|
||||
columnWidth = columnRight - columnLeft;
|
||||
|
||||
// shave off space on right near scrollbars (2.5%)
|
||||
// TODO: move this to CSS somehow
|
||||
columnRight -= columnWidth * .025;
|
||||
columnWidth = columnRight - columnLeft;
|
||||
|
||||
width = columnWidth * (seg.forwardCoord - seg.backwardCoord);
|
||||
|
||||
if (opt('slotEventOverlap')) {
|
||||
// double the width while making sure resize handle is visible
|
||||
// (assumed to be 20px wide)
|
||||
width = Math.max(
|
||||
(width - (20/2)) * 2,
|
||||
width // narrow columns will want to make the segment smaller than
|
||||
// the natural width. don't allow it
|
||||
);
|
||||
}
|
||||
|
||||
if (isRTL) {
|
||||
right = columnRight - seg.backwardCoord * columnWidth;
|
||||
left = right - width;
|
||||
}
|
||||
else {
|
||||
left = columnLeft + seg.backwardCoord * columnWidth;
|
||||
right = left + width;
|
||||
}
|
||||
|
||||
// make sure horizontal coordinates are in bounds
|
||||
left = Math.max(left, columnLeft);
|
||||
right = Math.min(right, columnRight);
|
||||
width = right - left;
|
||||
|
||||
seg.top = top;
|
||||
seg.left = left;
|
||||
seg.outerWidth = width;
|
||||
seg.outerHeight = bottom - top;
|
||||
html += slotSegHtml(event, seg);
|
||||
}
|
||||
|
||||
slotSegmentContainer[0].innerHTML = html; // faster than html()
|
||||
eventElements = slotSegmentContainer.children();
|
||||
|
||||
// retrieve elements, run through eventRender callback, bind event handlers
|
||||
for (i=0; i<segCnt; i++) {
|
||||
seg = segs[i];
|
||||
event = seg.event;
|
||||
eventElement = $(eventElements[i]); // faster than eq()
|
||||
triggerRes = trigger('eventRender', event, event, eventElement);
|
||||
if (triggerRes === false) {
|
||||
eventElement.remove();
|
||||
}else{
|
||||
if (triggerRes && triggerRes !== true) {
|
||||
eventElement.remove();
|
||||
eventElement = $(triggerRes)
|
||||
.css({
|
||||
position: 'absolute',
|
||||
top: seg.top,
|
||||
left: seg.left
|
||||
})
|
||||
.appendTo(slotSegmentContainer);
|
||||
}
|
||||
seg.element = eventElement;
|
||||
if (event._id === modifiedEventId) {
|
||||
bindSlotSeg(event, eventElement, seg);
|
||||
}else{
|
||||
eventElement[0]._fci = i; // for lazySegBind
|
||||
}
|
||||
reportEventElement(event, eventElement);
|
||||
}
|
||||
}
|
||||
|
||||
lazySegBind(slotSegmentContainer, segs, bindSlotSeg);
|
||||
|
||||
// record event sides and title positions
|
||||
for (i=0; i<segCnt; i++) {
|
||||
seg = segs[i];
|
||||
if ((eventElement = seg.element)) {
|
||||
seg.vsides = vsides(eventElement, true);
|
||||
seg.hsides = hsides(eventElement, true);
|
||||
titleElement = eventElement.find('.fc-event-title');
|
||||
if (titleElement.length) {
|
||||
seg.contentTop = titleElement[0].offsetTop;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set all positions/dimensions at once
|
||||
for (i=0; i<segCnt; i++) {
|
||||
seg = segs[i];
|
||||
if ((eventElement = seg.element)) {
|
||||
eventElement[0].style.width = Math.max(0, seg.outerWidth - seg.hsides) + 'px';
|
||||
height = Math.max(0, seg.outerHeight - seg.vsides);
|
||||
eventElement[0].style.height = height + 'px';
|
||||
event = seg.event;
|
||||
if (seg.contentTop !== undefined && height - seg.contentTop < 10) {
|
||||
// not enough room for title, put it in the time (TODO: maybe make both display:inline instead)
|
||||
eventElement.find('div.fc-event-time')
|
||||
.text(
|
||||
formatDate(event.start, opt('timeFormat')) + ' - ' + event.title
|
||||
);
|
||||
eventElement.find('div.fc-event-title')
|
||||
.remove();
|
||||
}
|
||||
trigger('eventAfterRender', event, event, eventElement);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function slotSegHtml(event, seg) {
|
||||
var html = "<";
|
||||
var url = event.url;
|
||||
var skinCss = getSkinCss(event, opt);
|
||||
var classes = ['fc-event', 'fc-event-vert'];
|
||||
if (isEventDraggable(event)) {
|
||||
classes.push('fc-event-draggable');
|
||||
}
|
||||
if (seg.isStart) {
|
||||
classes.push('fc-event-start');
|
||||
}
|
||||
if (seg.isEnd) {
|
||||
classes.push('fc-event-end');
|
||||
}
|
||||
classes = classes.concat(event.className);
|
||||
if (event.source) {
|
||||
classes = classes.concat(event.source.className || []);
|
||||
}
|
||||
if (url) {
|
||||
html += "a href='" + htmlEscape(event.url) + "'";
|
||||
}else{
|
||||
html += "div";
|
||||
}
|
||||
|
||||
html +=
|
||||
" class='" + classes.join(' ') + "'" +
|
||||
" style=" +
|
||||
"'" +
|
||||
"position:absolute;" +
|
||||
"top:" + seg.top + "px;" +
|
||||
"left:" + seg.left + "px;" +
|
||||
skinCss +
|
||||
"'" +
|
||||
">" +
|
||||
"<div class='fc-event-inner'>" +
|
||||
"<div class='fc-event-time'>" +
|
||||
htmlEscape(t.getEventTimeText(event)) +
|
||||
"</div>" +
|
||||
"<div class='fc-event-title'>" +
|
||||
htmlEscape(event.title || '') +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"<div class='fc-event-bg'></div>";
|
||||
|
||||
if (seg.isEnd && isEventResizable(event)) {
|
||||
html +=
|
||||
"<div class='ui-resizable-handle ui-resizable-s'>=</div>";
|
||||
}
|
||||
html +=
|
||||
"</" + (url ? "a" : "div") + ">";
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
function bindSlotSeg(event, eventElement, seg) {
|
||||
var timeElement = eventElement.find('div.fc-event-time');
|
||||
if (isEventDraggable(event)) {
|
||||
draggableSlotEvent(event, eventElement, timeElement);
|
||||
}
|
||||
if (seg.isEnd && isEventResizable(event)) {
|
||||
resizableSlotEvent(event, eventElement, timeElement);
|
||||
}
|
||||
eventElementHandlers(event, eventElement);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Dragging
|
||||
-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// when event starts out FULL-DAY
|
||||
// overrides DayEventRenderer's version because it needs to account for dragging elements
|
||||
// to and from the slot area.
|
||||
|
||||
function draggableDayEvent(event, eventElement, seg) {
|
||||
var isStart = seg.isStart;
|
||||
var origWidth;
|
||||
var revert;
|
||||
var allDay = true;
|
||||
var dayDelta;
|
||||
|
||||
var hoverListener = getHoverListener();
|
||||
var colWidth = getColWidth();
|
||||
var minTime = getMinTime();
|
||||
var slotDuration = getSlotDuration();
|
||||
var slotHeight = getSlotHeight();
|
||||
var snapDuration = getSnapDuration();
|
||||
var snapHeight = getSnapHeight();
|
||||
|
||||
eventElement.draggable({
|
||||
opacity: opt('dragOpacity', 'month'), // use whatever the month view was using
|
||||
revertDuration: opt('dragRevertDuration'),
|
||||
start: function(ev, ui) {
|
||||
|
||||
trigger('eventDragStart', eventElement[0], event, ev, ui);
|
||||
hideEvents(event, eventElement);
|
||||
origWidth = eventElement.width();
|
||||
|
||||
hoverListener.start(function(cell, origCell) {
|
||||
clearOverlays();
|
||||
if (cell) {
|
||||
revert = false;
|
||||
|
||||
var origDate = cellToDate(0, origCell.col);
|
||||
var date = cellToDate(0, cell.col);
|
||||
dayDelta = date.diff(origDate, 'days');
|
||||
|
||||
if (!cell.row) { // on full-days
|
||||
|
||||
renderDayOverlay(
|
||||
event.start.clone().add(dayDelta, 'days'),
|
||||
getEventEnd(event).add(dayDelta, 'days')
|
||||
);
|
||||
|
||||
resetElement();
|
||||
}
|
||||
else { // mouse is over bottom slots
|
||||
|
||||
if (isStart) {
|
||||
if (allDay) {
|
||||
// convert event to temporary slot-event
|
||||
eventElement.width(colWidth - 10); // don't use entire width
|
||||
setOuterHeight(eventElement, calendar.defaultTimedEventDuration / slotDuration * slotHeight); // the default height
|
||||
eventElement.draggable('option', 'grid', [ colWidth, 1 ]);
|
||||
allDay = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
revert = true;
|
||||
}
|
||||
}
|
||||
|
||||
revert = revert || (allDay && !dayDelta);
|
||||
}
|
||||
else {
|
||||
resetElement();
|
||||
revert = true;
|
||||
}
|
||||
|
||||
eventElement.draggable('option', 'revert', revert);
|
||||
|
||||
}, ev, 'drag');
|
||||
},
|
||||
stop: function(ev, ui) {
|
||||
hoverListener.stop();
|
||||
clearOverlays();
|
||||
trigger('eventDragStop', eventElement[0], event, ev, ui);
|
||||
|
||||
if (revert) { // hasn't moved or is out of bounds (draggable has already reverted)
|
||||
|
||||
resetElement();
|
||||
eventElement.css('filter', ''); // clear IE opacity side-effects
|
||||
showEvents(event, eventElement);
|
||||
}
|
||||
else { // changed!
|
||||
|
||||
var eventStart = event.start.clone().add(dayDelta, 'days'); // already assumed to have a stripped time
|
||||
var snapTime;
|
||||
var snapIndex;
|
||||
if (!allDay) {
|
||||
snapIndex = Math.round((eventElement.offset().top - getSlotContainer().offset().top) / snapHeight); // why not use ui.offset.top?
|
||||
snapTime = moment.duration(minTime + snapIndex * snapDuration);
|
||||
eventStart = calendar.rezoneDate(eventStart.clone().time(snapTime));
|
||||
}
|
||||
|
||||
eventDrop(
|
||||
eventElement[0],
|
||||
event,
|
||||
eventStart,
|
||||
ev,
|
||||
ui
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
function resetElement() {
|
||||
if (!allDay) {
|
||||
eventElement
|
||||
.width(origWidth)
|
||||
.height('')
|
||||
.draggable('option', 'grid', null);
|
||||
allDay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// when event starts out IN TIMESLOTS
|
||||
|
||||
function draggableSlotEvent(event, eventElement, timeElement) {
|
||||
var coordinateGrid = t.getCoordinateGrid();
|
||||
var colCnt = getColCnt();
|
||||
var colWidth = getColWidth();
|
||||
var snapHeight = getSnapHeight();
|
||||
var snapDuration = getSnapDuration();
|
||||
|
||||
// states
|
||||
var origPosition; // original position of the element, not the mouse
|
||||
var origCell;
|
||||
var isInBounds, prevIsInBounds;
|
||||
var isAllDay, prevIsAllDay;
|
||||
var colDelta, prevColDelta;
|
||||
var dayDelta; // derived from colDelta
|
||||
var snapDelta, prevSnapDelta; // the number of snaps away from the original position
|
||||
|
||||
// newly computed
|
||||
var eventStart, eventEnd;
|
||||
|
||||
eventElement.draggable({
|
||||
scroll: false,
|
||||
grid: [ colWidth, snapHeight ],
|
||||
axis: colCnt==1 ? 'y' : false,
|
||||
opacity: opt('dragOpacity'),
|
||||
revertDuration: opt('dragRevertDuration'),
|
||||
start: function(ev, ui) {
|
||||
|
||||
trigger('eventDragStart', eventElement[0], event, ev, ui);
|
||||
hideEvents(event, eventElement);
|
||||
|
||||
coordinateGrid.build();
|
||||
|
||||
// initialize states
|
||||
origPosition = eventElement.position();
|
||||
origCell = coordinateGrid.cell(ev.pageX, ev.pageY);
|
||||
isInBounds = prevIsInBounds = true;
|
||||
isAllDay = prevIsAllDay = getIsCellAllDay(origCell);
|
||||
colDelta = prevColDelta = 0;
|
||||
dayDelta = 0;
|
||||
snapDelta = prevSnapDelta = 0;
|
||||
|
||||
eventStart = null;
|
||||
eventEnd = null;
|
||||
},
|
||||
drag: function(ev, ui) {
|
||||
|
||||
// NOTE: this `cell` value is only useful for determining in-bounds and all-day.
|
||||
// Bad for anything else due to the discrepancy between the mouse position and the
|
||||
// element position while snapping. (problem revealed in PR #55)
|
||||
//
|
||||
// PS- the problem exists for draggableDayEvent() when dragging an all-day event to a slot event.
|
||||
// We should overhaul the dragging system and stop relying on jQuery UI.
|
||||
var cell = coordinateGrid.cell(ev.pageX, ev.pageY);
|
||||
|
||||
// update states
|
||||
isInBounds = !!cell;
|
||||
if (isInBounds) {
|
||||
isAllDay = getIsCellAllDay(cell);
|
||||
|
||||
// calculate column delta
|
||||
colDelta = Math.round((ui.position.left - origPosition.left) / colWidth);
|
||||
if (colDelta != prevColDelta) {
|
||||
// calculate the day delta based off of the original clicked column and the column delta
|
||||
var origDate = cellToDate(0, origCell.col);
|
||||
var col = origCell.col + colDelta;
|
||||
col = Math.max(0, col);
|
||||
col = Math.min(colCnt-1, col);
|
||||
var date = cellToDate(0, col);
|
||||
dayDelta = date.diff(origDate, 'days');
|
||||
}
|
||||
|
||||
// calculate minute delta (only if over slots)
|
||||
if (!isAllDay) {
|
||||
snapDelta = Math.round((ui.position.top - origPosition.top) / snapHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// any state changes?
|
||||
if (
|
||||
isInBounds != prevIsInBounds ||
|
||||
isAllDay != prevIsAllDay ||
|
||||
colDelta != prevColDelta ||
|
||||
snapDelta != prevSnapDelta
|
||||
) {
|
||||
|
||||
// compute new dates
|
||||
if (isAllDay) {
|
||||
eventStart = event.start.clone().stripTime().add(dayDelta, 'days');
|
||||
eventEnd = eventStart.clone().add(calendar.defaultAllDayEventDuration);
|
||||
}
|
||||
else {
|
||||
eventStart = event.start.clone().add(snapDelta * snapDuration).add(dayDelta, 'days');
|
||||
eventEnd = getEventEnd(event).add(snapDelta * snapDuration).add(dayDelta, 'days');
|
||||
}
|
||||
|
||||
updateUI();
|
||||
|
||||
// update previous states for next time
|
||||
prevIsInBounds = isInBounds;
|
||||
prevIsAllDay = isAllDay;
|
||||
prevColDelta = colDelta;
|
||||
prevSnapDelta = snapDelta;
|
||||
}
|
||||
|
||||
// if out-of-bounds, revert when done, and vice versa.
|
||||
eventElement.draggable('option', 'revert', !isInBounds);
|
||||
|
||||
},
|
||||
stop: function(ev, ui) {
|
||||
|
||||
clearOverlays();
|
||||
trigger('eventDragStop', eventElement[0], event, ev, ui);
|
||||
|
||||
if (isInBounds && (isAllDay || dayDelta || snapDelta)) { // changed!
|
||||
eventDrop(
|
||||
eventElement[0],
|
||||
event,
|
||||
eventStart,
|
||||
ev,
|
||||
ui
|
||||
);
|
||||
}
|
||||
else { // either no change or out-of-bounds (draggable has already reverted)
|
||||
|
||||
// reset states for next time, and for updateUI()
|
||||
isInBounds = true;
|
||||
isAllDay = false;
|
||||
colDelta = 0;
|
||||
dayDelta = 0;
|
||||
snapDelta = 0;
|
||||
|
||||
updateUI();
|
||||
eventElement.css('filter', ''); // clear IE opacity side-effects
|
||||
|
||||
// sometimes fast drags make event revert to wrong position, so reset.
|
||||
// also, if we dragged the element out of the area because of snapping,
|
||||
// but the *mouse* is still in bounds, we need to reset the position.
|
||||
eventElement.css(origPosition);
|
||||
|
||||
showEvents(event, eventElement);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function updateUI() {
|
||||
clearOverlays();
|
||||
if (isInBounds) {
|
||||
if (isAllDay) {
|
||||
timeElement.hide();
|
||||
eventElement.draggable('option', 'grid', null); // disable grid snapping
|
||||
renderDayOverlay(eventStart, eventEnd);
|
||||
}
|
||||
else {
|
||||
updateTimeText();
|
||||
timeElement.css('display', ''); // show() was causing display=inline
|
||||
eventElement.draggable('option', 'grid', [colWidth, snapHeight]); // re-enable grid snapping
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateTimeText() {
|
||||
if (eventStart) { // must of had a state change
|
||||
timeElement.text(
|
||||
t.getEventTimeText(eventStart, event.end ? eventEnd : null)
|
||||
// ^
|
||||
// only display the new end if there was an old end
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Resizing
|
||||
--------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
function resizableSlotEvent(event, eventElement, timeElement) {
|
||||
var snapDelta, prevSnapDelta;
|
||||
var snapHeight = getSnapHeight();
|
||||
var snapDuration = getSnapDuration();
|
||||
var eventEnd;
|
||||
|
||||
eventElement.resizable({
|
||||
handles: {
|
||||
s: '.ui-resizable-handle'
|
||||
},
|
||||
grid: snapHeight,
|
||||
start: function(ev, ui) {
|
||||
snapDelta = prevSnapDelta = 0;
|
||||
hideEvents(event, eventElement);
|
||||
trigger('eventResizeStart', eventElement[0], event, ev, ui);
|
||||
},
|
||||
resize: function(ev, ui) {
|
||||
// don't rely on ui.size.height, doesn't take grid into account
|
||||
snapDelta = Math.round((Math.max(snapHeight, eventElement.height()) - ui.originalSize.height) / snapHeight);
|
||||
if (snapDelta != prevSnapDelta) {
|
||||
eventEnd = getEventEnd(event).add(snapDuration * snapDelta);
|
||||
var text;
|
||||
if (snapDelta) { // has there been a change?
|
||||
text = t.getEventTimeText(event.start, eventEnd);
|
||||
}
|
||||
else {
|
||||
text = t.getEventTimeText(event); // the original time text
|
||||
}
|
||||
timeElement.text(text);
|
||||
prevSnapDelta = snapDelta;
|
||||
}
|
||||
},
|
||||
stop: function(ev, ui) {
|
||||
trigger('eventResizeStop', eventElement[0], event, ev, ui);
|
||||
if (snapDelta) {
|
||||
eventResize(
|
||||
eventElement[0],
|
||||
event,
|
||||
eventEnd,
|
||||
ev,
|
||||
ui
|
||||
);
|
||||
}
|
||||
else {
|
||||
showEvents(event, eventElement);
|
||||
// BUG: if event was really short, need to put title back in span
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Agenda Event Segment Utilities
|
||||
-----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// Sets the seg.backwardCoord and seg.forwardCoord on each segment and returns a new
|
||||
// list in the order they should be placed into the DOM (an implicit z-index).
|
||||
function placeSlotSegs(segs) {
|
||||
var levels = buildSlotSegLevels(segs);
|
||||
var level0 = levels[0];
|
||||
var i;
|
||||
|
||||
computeForwardSlotSegs(levels);
|
||||
|
||||
if (level0) {
|
||||
|
||||
for (i=0; i<level0.length; i++) {
|
||||
computeSlotSegPressures(level0[i]);
|
||||
}
|
||||
|
||||
for (i=0; i<level0.length; i++) {
|
||||
computeSlotSegCoords(level0[i], 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return flattenSlotSegLevels(levels);
|
||||
}
|
||||
|
||||
|
||||
// Builds an array of segments "levels". The first level will be the leftmost tier of segments
|
||||
// if the calendar is left-to-right, or the rightmost if the calendar is right-to-left.
|
||||
function buildSlotSegLevels(segs) {
|
||||
var levels = [];
|
||||
var i, seg;
|
||||
var j;
|
||||
|
||||
for (i=0; i<segs.length; i++) {
|
||||
seg = segs[i];
|
||||
|
||||
// go through all the levels and stop on the first level where there are no collisions
|
||||
for (j=0; j<levels.length; j++) {
|
||||
if (!computeSlotSegCollisions(seg, levels[j]).length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
(levels[j] || (levels[j] = [])).push(seg);
|
||||
}
|
||||
|
||||
return levels;
|
||||
}
|
||||
|
||||
|
||||
// For every segment, figure out the other segments that are in subsequent
|
||||
// levels that also occupy the same vertical space. Accumulate in seg.forwardSegs
|
||||
function computeForwardSlotSegs(levels) {
|
||||
var i, level;
|
||||
var j, seg;
|
||||
var k;
|
||||
|
||||
for (i=0; i<levels.length; i++) {
|
||||
level = levels[i];
|
||||
|
||||
for (j=0; j<level.length; j++) {
|
||||
seg = level[j];
|
||||
|
||||
seg.forwardSegs = [];
|
||||
for (k=i+1; k<levels.length; k++) {
|
||||
computeSlotSegCollisions(seg, levels[k], seg.forwardSegs);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Figure out which path forward (via seg.forwardSegs) results in the longest path until
|
||||
// the furthest edge is reached. The number of segments in this path will be seg.forwardPressure
|
||||
function computeSlotSegPressures(seg) {
|
||||
var forwardSegs = seg.forwardSegs;
|
||||
var forwardPressure = 0;
|
||||
var i, forwardSeg;
|
||||
|
||||
if (seg.forwardPressure === undefined) { // not already computed
|
||||
|
||||
for (i=0; i<forwardSegs.length; i++) {
|
||||
forwardSeg = forwardSegs[i];
|
||||
|
||||
// figure out the child's maximum forward path
|
||||
computeSlotSegPressures(forwardSeg);
|
||||
|
||||
// either use the existing maximum, or use the child's forward pressure
|
||||
// plus one (for the forwardSeg itself)
|
||||
forwardPressure = Math.max(
|
||||
forwardPressure,
|
||||
1 + forwardSeg.forwardPressure
|
||||
);
|
||||
}
|
||||
|
||||
seg.forwardPressure = forwardPressure;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Calculate seg.forwardCoord and seg.backwardCoord for the segment, where both values range
|
||||
// from 0 to 1. If the calendar is left-to-right, the seg.backwardCoord maps to "left" and
|
||||
// seg.forwardCoord maps to "right" (via percentage). Vice-versa if the calendar is right-to-left.
|
||||
//
|
||||
// The segment might be part of a "series", which means consecutive segments with the same pressure
|
||||
// who's width is unknown until an edge has been hit. `seriesBackwardPressure` is the number of
|
||||
// segments behind this one in the current series, and `seriesBackwardCoord` is the starting
|
||||
// coordinate of the first segment in the series.
|
||||
function computeSlotSegCoords(seg, seriesBackwardPressure, seriesBackwardCoord) {
|
||||
var forwardSegs = seg.forwardSegs;
|
||||
var i;
|
||||
|
||||
if (seg.forwardCoord === undefined) { // not already computed
|
||||
|
||||
if (!forwardSegs.length) {
|
||||
|
||||
// if there are no forward segments, this segment should butt up against the edge
|
||||
seg.forwardCoord = 1;
|
||||
}
|
||||
else {
|
||||
|
||||
// sort highest pressure first
|
||||
forwardSegs.sort(compareForwardSlotSegs);
|
||||
|
||||
// this segment's forwardCoord will be calculated from the backwardCoord of the
|
||||
// highest-pressure forward segment.
|
||||
computeSlotSegCoords(forwardSegs[0], seriesBackwardPressure + 1, seriesBackwardCoord);
|
||||
seg.forwardCoord = forwardSegs[0].backwardCoord;
|
||||
}
|
||||
|
||||
// calculate the backwardCoord from the forwardCoord. consider the series
|
||||
seg.backwardCoord = seg.forwardCoord -
|
||||
(seg.forwardCoord - seriesBackwardCoord) / // available width for series
|
||||
(seriesBackwardPressure + 1); // # of segments in the series
|
||||
|
||||
// use this segment's coordinates to computed the coordinates of the less-pressurized
|
||||
// forward segments
|
||||
for (i=0; i<forwardSegs.length; i++) {
|
||||
computeSlotSegCoords(forwardSegs[i], 0, seg.forwardCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Outputs a flat array of segments, from lowest to highest level
|
||||
function flattenSlotSegLevels(levels) {
|
||||
var segs = [];
|
||||
var i, level;
|
||||
var j;
|
||||
|
||||
for (i=0; i<levels.length; i++) {
|
||||
level = levels[i];
|
||||
|
||||
for (j=0; j<level.length; j++) {
|
||||
segs.push(level[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return segs;
|
||||
}
|
||||
|
||||
|
||||
// Find all the segments in `otherSegs` that vertically collide with `seg`.
|
||||
// Append into an optionally-supplied `results` array and return.
|
||||
function computeSlotSegCollisions(seg, otherSegs, results) {
|
||||
results = results || [];
|
||||
|
||||
for (var i=0; i<otherSegs.length; i++) {
|
||||
if (isSlotSegCollision(seg, otherSegs[i])) {
|
||||
results.push(otherSegs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
// Do these segments occupy the same vertical space?
|
||||
function isSlotSegCollision(seg1, seg2) {
|
||||
return seg1.end > seg2.start && seg1.start < seg2.end;
|
||||
}
|
||||
|
||||
|
||||
// A cmp function for determining which forward segment to rely on more when computing coordinates.
|
||||
function compareForwardSlotSegs(seg1, seg2) {
|
||||
// put higher-pressure first
|
||||
return seg2.forwardPressure - seg1.forwardPressure ||
|
||||
// put segments that are closer to initial edge first (and favor ones with no coords yet)
|
||||
(seg1.backwardCoord || 0) - (seg2.backwardCoord || 0) ||
|
||||
// do normal sorting...
|
||||
compareSlotSegs(seg1, seg2);
|
||||
}
|
||||
|
||||
|
||||
// A cmp function for determining which segment should be closer to the initial edge
|
||||
// (the left edge on a left-to-right calendar).
|
||||
function compareSlotSegs(seg1, seg2) {
|
||||
return seg1.start - seg2.start || // earlier start time goes first
|
||||
(seg2.end - seg2.start) - (seg1.end - seg1.start) || // tie? longer-duration goes first
|
||||
(seg1.event.title || '').localeCompare(seg2.event.title); // tie? alphabetically by title
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
function BasicEventRenderer() {
|
||||
var t = this;
|
||||
|
||||
|
||||
// exports
|
||||
t.renderEvents = renderEvents;
|
||||
t.clearEvents = clearEvents;
|
||||
|
||||
|
||||
// imports
|
||||
DayEventRenderer.call(t);
|
||||
|
||||
|
||||
function renderEvents(events, modifiedEventId) {
|
||||
t.renderDayEvents(events, modifiedEventId);
|
||||
}
|
||||
|
||||
|
||||
function clearEvents() {
|
||||
t.getDaySegmentContainer().empty();
|
||||
}
|
||||
|
||||
|
||||
// TODO: have this class (and AgendaEventRenderer) be responsible for creating the event container div
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
|
||||
function CoordinateGrid(buildFunc) {
|
||||
|
||||
var t = this;
|
||||
var rows;
|
||||
var cols;
|
||||
|
||||
|
||||
t.build = function() {
|
||||
rows = [];
|
||||
cols = [];
|
||||
buildFunc(rows, cols);
|
||||
};
|
||||
|
||||
|
||||
t.cell = function(x, y) {
|
||||
var rowCnt = rows.length;
|
||||
var colCnt = cols.length;
|
||||
var i, r=-1, c=-1;
|
||||
for (i=0; i<rowCnt; i++) {
|
||||
if (y >= rows[i][0] && y < rows[i][1]) {
|
||||
r = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (i=0; i<colCnt; i++) {
|
||||
if (x >= cols[i][0] && x < cols[i][1]) {
|
||||
c = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (r>=0 && c>=0) ? { row: r, col: c } : null;
|
||||
};
|
||||
|
||||
|
||||
t.rect = function(row0, col0, row1, col1, originElement) { // row1,col1 is inclusive
|
||||
var origin = originElement.offset();
|
||||
return {
|
||||
top: rows[row0][0] - origin.top,
|
||||
left: cols[col0][0] - origin.left,
|
||||
width: cols[col1][1] - cols[col0][0],
|
||||
height: rows[row1][1] - rows[row0][0]
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,798 +0,0 @@
|
||||
|
||||
function DayEventRenderer() {
|
||||
var t = this;
|
||||
|
||||
|
||||
// exports
|
||||
t.renderDayEvents = renderDayEvents;
|
||||
t.draggableDayEvent = draggableDayEvent; // made public so that subclasses can override
|
||||
t.resizableDayEvent = resizableDayEvent; // "
|
||||
|
||||
|
||||
// imports
|
||||
var opt = t.opt;
|
||||
var trigger = t.trigger;
|
||||
var isEventDraggable = t.isEventDraggable;
|
||||
var isEventResizable = t.isEventResizable;
|
||||
var reportEventElement = t.reportEventElement;
|
||||
var eventElementHandlers = t.eventElementHandlers;
|
||||
var showEvents = t.showEvents;
|
||||
var hideEvents = t.hideEvents;
|
||||
var eventDrop = t.eventDrop;
|
||||
var eventResize = t.eventResize;
|
||||
var getRowCnt = t.getRowCnt;
|
||||
var getColCnt = t.getColCnt;
|
||||
var allDayRow = t.allDayRow; // TODO: rename
|
||||
var colLeft = t.colLeft;
|
||||
var colRight = t.colRight;
|
||||
var colContentLeft = t.colContentLeft;
|
||||
var colContentRight = t.colContentRight;
|
||||
var getDaySegmentContainer = t.getDaySegmentContainer;
|
||||
var renderDayOverlay = t.renderDayOverlay;
|
||||
var clearOverlays = t.clearOverlays;
|
||||
var clearSelection = t.clearSelection;
|
||||
var getHoverListener = t.getHoverListener;
|
||||
var rangeToSegments = t.rangeToSegments;
|
||||
var cellToDate = t.cellToDate;
|
||||
var cellToCellOffset = t.cellToCellOffset;
|
||||
var cellOffsetToDayOffset = t.cellOffsetToDayOffset;
|
||||
var dateToDayOffset = t.dateToDayOffset;
|
||||
var dayOffsetToCellOffset = t.dayOffsetToCellOffset;
|
||||
var calendar = t.calendar;
|
||||
var getEventEnd = calendar.getEventEnd;
|
||||
|
||||
|
||||
// Render `events` onto the calendar, attach mouse event handlers, and call the `eventAfterRender` callback for each.
|
||||
// Mouse event will be lazily applied, except if the event has an ID of `modifiedEventId`.
|
||||
// Can only be called when the event container is empty (because it wipes out all innerHTML).
|
||||
function renderDayEvents(events, modifiedEventId) {
|
||||
|
||||
// do the actual rendering. Receive the intermediate "segment" data structures.
|
||||
var segments = _renderDayEvents(
|
||||
events,
|
||||
false, // don't append event elements
|
||||
true // set the heights of the rows
|
||||
);
|
||||
|
||||
// report the elements to the View, for general drag/resize utilities
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
reportEventElement(segment.event, element);
|
||||
});
|
||||
|
||||
// attach mouse handlers
|
||||
attachHandlers(segments, modifiedEventId);
|
||||
|
||||
// call `eventAfterRender` callback for each event
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
trigger('eventAfterRender', segment.event, segment.event, element);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Render an event on the calendar, but don't report them anywhere, and don't attach mouse handlers.
|
||||
// Append this event element to the event container, which might already be populated with events.
|
||||
// If an event's segment will have row equal to `adjustRow`, then explicitly set its top coordinate to `adjustTop`.
|
||||
// This hack is used to maintain continuity when user is manually resizing an event.
|
||||
// Returns an array of DOM elements for the event.
|
||||
function renderTempDayEvent(event, adjustRow, adjustTop) {
|
||||
|
||||
// actually render the event. `true` for appending element to container.
|
||||
// Recieve the intermediate "segment" data structures.
|
||||
var segments = _renderDayEvents(
|
||||
[ event ],
|
||||
true, // append event elements
|
||||
false // don't set the heights of the rows
|
||||
);
|
||||
|
||||
var elements = [];
|
||||
|
||||
// Adjust certain elements' top coordinates
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
if (segment.row === adjustRow) {
|
||||
element.css('top', adjustTop);
|
||||
}
|
||||
elements.push(element[0]); // accumulate DOM nodes
|
||||
});
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
|
||||
// Render events onto the calendar. Only responsible for the VISUAL aspect.
|
||||
// Not responsible for attaching handlers or calling callbacks.
|
||||
// Set `doAppend` to `true` for rendering elements without clearing the existing container.
|
||||
// Set `doRowHeights` to allow setting the height of each row, to compensate for vertical event overflow.
|
||||
function _renderDayEvents(events, doAppend, doRowHeights) {
|
||||
|
||||
// where the DOM nodes will eventually end up
|
||||
var finalContainer = getDaySegmentContainer();
|
||||
|
||||
// the container where the initial HTML will be rendered.
|
||||
// If `doAppend`==true, uses a temporary container.
|
||||
var renderContainer = doAppend ? $("<div/>") : finalContainer;
|
||||
|
||||
var segments = buildSegments(events);
|
||||
var html;
|
||||
var elements;
|
||||
|
||||
// calculate the desired `left` and `width` properties on each segment object
|
||||
calculateHorizontals(segments);
|
||||
|
||||
// build the HTML string. relies on `left` property
|
||||
html = buildHTML(segments);
|
||||
|
||||
// render the HTML. innerHTML is considerably faster than jQuery's .html()
|
||||
renderContainer[0].innerHTML = html;
|
||||
|
||||
// retrieve the individual elements
|
||||
elements = renderContainer.children();
|
||||
|
||||
// if we were appending, and thus using a temporary container,
|
||||
// re-attach elements to the real container.
|
||||
if (doAppend) {
|
||||
finalContainer.append(elements);
|
||||
}
|
||||
|
||||
// assigns each element to `segment.event`, after filtering them through user callbacks
|
||||
resolveElements(segments, elements);
|
||||
|
||||
// Calculate the left and right padding+margin for each element.
|
||||
// We need this for setting each element's desired outer width, because of the W3C box model.
|
||||
// It's important we do this in a separate pass from acually setting the width on the DOM elements
|
||||
// because alternating reading/writing dimensions causes reflow for every iteration.
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
segment.hsides = hsides(element, true); // include margins = `true`
|
||||
});
|
||||
|
||||
// Set the width of each element
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
element.width(
|
||||
Math.max(0, segment.outerWidth - segment.hsides)
|
||||
);
|
||||
});
|
||||
|
||||
// Grab each element's outerHeight (setVerticals uses this).
|
||||
// To get an accurate reading, it's important to have each element's width explicitly set already.
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
segment.outerHeight = element.outerHeight(true); // include margins = `true`
|
||||
});
|
||||
|
||||
// Set the top coordinate on each element (requires segment.outerHeight)
|
||||
setVerticals(segments, doRowHeights);
|
||||
|
||||
return segments;
|
||||
}
|
||||
|
||||
|
||||
// Generate an array of "segments" for all events.
|
||||
function buildSegments(events) {
|
||||
var resources = t.getResources;
|
||||
var segments = [];
|
||||
var i, eventSegments;
|
||||
|
||||
if (typeof resources === 'undefined'){
|
||||
for (i=0; i<events.length; i++) {
|
||||
eventSegments = buildSegmentsForEvent(events[i]);
|
||||
segments.push.apply(segments, eventSegments); // append an array to an array
|
||||
}
|
||||
} else {
|
||||
for (i=0; i<resources().length; i++) {
|
||||
var resourceEvents = eventsForResource(resources()[i], events);
|
||||
|
||||
for (var j=0; j<resourceEvents.length; j++) {
|
||||
eventSegments = buildSegmentsForEvent(resourceEvents[j], i);
|
||||
segments.push.apply(segments, eventSegments); // append an array to an array
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
function eventsForResource(resource, events) {
|
||||
var resourceEvents = [];
|
||||
var hasResource = function(event) {
|
||||
return event.resources && $.grep(event.resources, function(id) {
|
||||
return id == resource.id;
|
||||
}).length;
|
||||
};
|
||||
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
if (hasResource(events[i])) {
|
||||
resourceEvents.push(events[i]);
|
||||
}
|
||||
}
|
||||
return resourceEvents;
|
||||
}
|
||||
|
||||
// Generate an array of segments for a single event.
|
||||
// A "segment" is the same data structure that View.rangeToSegments produces,
|
||||
// with the addition of the `event` property being set to reference the original event.
|
||||
function buildSegmentsForEvent(event, resourceCol) {
|
||||
var segments = rangeToSegments(event.start, getEventEnd(event));
|
||||
for (var i=0; i<segments.length; i++) {
|
||||
if (typeof resourceCol !== 'undefined'){
|
||||
segments[i].leftCol = resourceCol;
|
||||
segments[i].rightCol = resourceCol;
|
||||
}
|
||||
segments[i].event = event;
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
|
||||
// Sets the `left` and `outerWidth` property of each segment.
|
||||
// These values are the desired dimensions for the eventual DOM elements.
|
||||
function calculateHorizontals(segments) {
|
||||
var isRTL = opt('isRTL');
|
||||
for (var i=0; i<segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
|
||||
// Determine functions used for calulating the elements left/right coordinates,
|
||||
// depending on whether the view is RTL or not.
|
||||
// NOTE:
|
||||
// colLeft/colRight returns the coordinate butting up the edge of the cell.
|
||||
// colContentLeft/colContentRight is indented a little bit from the edge.
|
||||
var leftFunc = (isRTL ? segment.isEnd : segment.isStart) ? colContentLeft : colLeft;
|
||||
var rightFunc = (isRTL ? segment.isStart : segment.isEnd) ? colContentRight : colRight;
|
||||
|
||||
var left = leftFunc(segment.leftCol);
|
||||
var right = rightFunc(segment.rightCol);
|
||||
segment.left = left;
|
||||
segment.outerWidth = right - left;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Build a concatenated HTML string for an array of segments
|
||||
function buildHTML(segments) {
|
||||
var html = '';
|
||||
for (var i=0; i<segments.length; i++) {
|
||||
html += buildHTMLForSegment(segments[i]);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
// Build an HTML string for a single segment.
|
||||
// Relies on the following properties:
|
||||
// - `segment.event` (from `buildSegmentsForEvent`)
|
||||
// - `segment.left` (from `calculateHorizontals`)
|
||||
function buildHTMLForSegment(segment) {
|
||||
var html = '';
|
||||
var isRTL = opt('isRTL');
|
||||
var event = segment.event;
|
||||
var url = event.url;
|
||||
|
||||
// generate the list of CSS classNames
|
||||
var classNames = [ 'fc-event', 'fc-event-hori' ];
|
||||
if (isEventDraggable(event)) {
|
||||
classNames.push('fc-event-draggable');
|
||||
}
|
||||
if (segment.isStart) {
|
||||
classNames.push('fc-event-start');
|
||||
}
|
||||
if (segment.isEnd) {
|
||||
classNames.push('fc-event-end');
|
||||
}
|
||||
// use the event's configured classNames
|
||||
// guaranteed to be an array via `buildEvent`
|
||||
classNames = classNames.concat(event.className);
|
||||
if (event.source) {
|
||||
// use the event's source's classNames, if specified
|
||||
classNames = classNames.concat(event.source.className || []);
|
||||
}
|
||||
|
||||
// generate a semicolon delimited CSS string for any of the "skin" properties
|
||||
// of the event object (`backgroundColor`, `borderColor` and such)
|
||||
var skinCss = getSkinCss(event, opt);
|
||||
|
||||
if (url) {
|
||||
html += "<a href='" + htmlEscape(url) + "'";
|
||||
}else{
|
||||
html += "<div";
|
||||
}
|
||||
html +=
|
||||
" class='" + classNames.join(' ') + "'" +
|
||||
" style=" +
|
||||
"'" +
|
||||
"position:absolute;" +
|
||||
"left:" + segment.left + "px;" +
|
||||
skinCss +
|
||||
"'" +
|
||||
">" +
|
||||
"<div class='fc-event-inner'>";
|
||||
if (!event.allDay && segment.isStart) {
|
||||
html +=
|
||||
"<span class='fc-event-time'>" +
|
||||
htmlEscape(t.getEventTimeText(event)) +
|
||||
"</span>";
|
||||
}
|
||||
html +=
|
||||
"<span class='fc-event-title'>" +
|
||||
htmlEscape(event.title || '') +
|
||||
"</span>" +
|
||||
"</div>";
|
||||
if (event.allDay && segment.isEnd && isEventResizable(event)) {
|
||||
html +=
|
||||
"<div class='ui-resizable-handle ui-resizable-" + (isRTL ? 'w' : 'e') + "'>" +
|
||||
" " + // makes hit area a lot better for IE6/7
|
||||
"</div>";
|
||||
}
|
||||
html += "</" + (url ? "a" : "div") + ">";
|
||||
|
||||
// TODO:
|
||||
// When these elements are initially rendered, they will be briefly visibile on the screen,
|
||||
// even though their widths/heights are not set.
|
||||
// SOLUTION: initially set them as visibility:hidden ?
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
// Associate each segment (an object) with an element (a jQuery object),
|
||||
// by setting each `segment.element`.
|
||||
// Run each element through the `eventRender` filter, which allows developers to
|
||||
// modify an existing element, supply a new one, or cancel rendering.
|
||||
function resolveElements(segments, elements) {
|
||||
for (var i=0; i<segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
var event = segment.event;
|
||||
var element = elements.eq(i);
|
||||
|
||||
// call the trigger with the original element
|
||||
var triggerRes = trigger('eventRender', event, event, element);
|
||||
|
||||
if (triggerRes === false) {
|
||||
// if `false`, remove the event from the DOM and don't assign it to `segment.event`
|
||||
element.remove();
|
||||
}
|
||||
else {
|
||||
if (triggerRes && triggerRes !== true) {
|
||||
// the trigger returned a new element, but not `true` (which means keep the existing element)
|
||||
|
||||
// re-assign the important CSS dimension properties that were already assigned in `buildHTMLForSegment`
|
||||
triggerRes = $(triggerRes)
|
||||
.css({
|
||||
position: 'absolute',
|
||||
left: segment.left
|
||||
});
|
||||
|
||||
element.replaceWith(triggerRes);
|
||||
element = triggerRes;
|
||||
}
|
||||
|
||||
segment.element = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Top-coordinate Methods
|
||||
-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
// Sets the "top" CSS property for each element.
|
||||
// If `doRowHeights` is `true`, also sets each row's first cell to an explicit height,
|
||||
// so that if elements vertically overflow, the cell expands vertically to compensate.
|
||||
function setVerticals(segments, doRowHeights) {
|
||||
var rowContentHeights = calculateVerticals(segments); // also sets segment.top
|
||||
var rowContentElements = getRowContentElements(); // returns 1 inner div per row
|
||||
var rowContentTops = [];
|
||||
var i;
|
||||
|
||||
// Set each row's height by setting height of first inner div
|
||||
if (doRowHeights) {
|
||||
for (i=0; i<rowContentElements.length; i++) {
|
||||
rowContentElements[i].height(rowContentHeights[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Get each row's top, relative to the views's origin.
|
||||
// Important to do this after setting each row's height.
|
||||
for (i=0; i<rowContentElements.length; i++) {
|
||||
rowContentTops.push(
|
||||
rowContentElements[i].position().top
|
||||
);
|
||||
}
|
||||
|
||||
// Set each segment element's CSS "top" property.
|
||||
// Each segment object has a "top" property, which is relative to the row's top, but...
|
||||
segmentElementEach(segments, function(segment, element) {
|
||||
element.css(
|
||||
'top',
|
||||
rowContentTops[segment.row] + segment.top // ...now, relative to views's origin
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Calculate the "top" coordinate for each segment, relative to the "top" of the row.
|
||||
// Also, return an array that contains the "content" height for each row
|
||||
// (the height displaced by the vertically stacked events in the row).
|
||||
// Requires segments to have their `outerHeight` property already set.
|
||||
function calculateVerticals(segments) {
|
||||
var rowCnt = getRowCnt();
|
||||
var colCnt = getColCnt();
|
||||
var rowContentHeights = []; // content height for each row
|
||||
var segmentRows = buildSegmentRows(segments); // an array of segment arrays, one for each row
|
||||
var colI;
|
||||
|
||||
for (var rowI=0; rowI<rowCnt; rowI++) {
|
||||
var segmentRow = segmentRows[rowI];
|
||||
|
||||
// an array of running total heights for each column.
|
||||
// initialize with all zeros.
|
||||
var colHeights = [];
|
||||
for (colI=0; colI<colCnt; colI++) {
|
||||
colHeights.push(0);
|
||||
}
|
||||
|
||||
// loop through every segment
|
||||
for (var segmentI=0; segmentI<segmentRow.length; segmentI++) {
|
||||
var segment = segmentRow[segmentI];
|
||||
|
||||
// find the segment's top coordinate by looking at the max height
|
||||
// of all the columns the segment will be in.
|
||||
segment.top = arrayMax(
|
||||
colHeights.slice(
|
||||
segment.leftCol,
|
||||
segment.rightCol + 1 // make exclusive for slice
|
||||
)
|
||||
);
|
||||
|
||||
// adjust the columns to account for the segment's height
|
||||
for (colI=segment.leftCol; colI<=segment.rightCol; colI++) {
|
||||
colHeights[colI] = segment.top + segment.outerHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// the tallest column in the row should be the "content height"
|
||||
rowContentHeights.push(arrayMax(colHeights));
|
||||
}
|
||||
|
||||
return rowContentHeights;
|
||||
}
|
||||
|
||||
|
||||
// Build an array of segment arrays, each representing the segments that will
|
||||
// be in a row of the grid, sorted by which event should be closest to the top.
|
||||
function buildSegmentRows(segments) {
|
||||
var rowCnt = getRowCnt();
|
||||
var segmentRows = [];
|
||||
var segmentI;
|
||||
var segment;
|
||||
var rowI;
|
||||
|
||||
// group segments by row
|
||||
for (segmentI=0; segmentI<segments.length; segmentI++) {
|
||||
segment = segments[segmentI];
|
||||
rowI = segment.row;
|
||||
if (segment.element) { // was rendered?
|
||||
if (segmentRows[rowI]) {
|
||||
// already other segments. append to array
|
||||
segmentRows[rowI].push(segment);
|
||||
}
|
||||
else {
|
||||
// first segment in row. create new array
|
||||
segmentRows[rowI] = [ segment ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sort each row
|
||||
for (rowI=0; rowI<rowCnt; rowI++) {
|
||||
segmentRows[rowI] = sortSegmentRow(
|
||||
segmentRows[rowI] || [] // guarantee an array, even if no segments
|
||||
);
|
||||
}
|
||||
|
||||
return segmentRows;
|
||||
}
|
||||
|
||||
|
||||
// Sort an array of segments according to which segment should appear closest to the top
|
||||
function sortSegmentRow(segments) {
|
||||
var sortedSegments = [];
|
||||
|
||||
// build the subrow array
|
||||
var subrows = buildSegmentSubrows(segments);
|
||||
|
||||
// flatten it
|
||||
for (var i=0; i<subrows.length; i++) {
|
||||
sortedSegments.push.apply(sortedSegments, subrows[i]); // append an array to an array
|
||||
}
|
||||
|
||||
return sortedSegments;
|
||||
}
|
||||
|
||||
|
||||
// Take an array of segments, which are all assumed to be in the same row,
|
||||
// and sort into subrows.
|
||||
function buildSegmentSubrows(segments) {
|
||||
|
||||
// Give preference to elements with certain criteria, so they have
|
||||
// a chance to be closer to the top.
|
||||
segments.sort(compareDaySegments);
|
||||
|
||||
var subrows = [];
|
||||
for (var i=0; i<segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
|
||||
// loop through subrows, starting with the topmost, until the segment
|
||||
// doesn't collide with other segments.
|
||||
for (var j=0; j<subrows.length; j++) {
|
||||
if (!isDaySegmentCollision(segment, subrows[j])) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// `j` now holds the desired subrow index
|
||||
if (subrows[j]) {
|
||||
subrows[j].push(segment);
|
||||
}
|
||||
else {
|
||||
subrows[j] = [ segment ];
|
||||
}
|
||||
}
|
||||
|
||||
return subrows;
|
||||
}
|
||||
|
||||
|
||||
// Return an array of jQuery objects for the placeholder content containers of each row.
|
||||
// The content containers don't actually contain anything, but their dimensions should match
|
||||
// the events that are overlaid on top.
|
||||
function getRowContentElements() {
|
||||
var i;
|
||||
var rowCnt = getRowCnt();
|
||||
var rowDivs = [];
|
||||
for (i=0; i<rowCnt; i++) {
|
||||
rowDivs[i] = allDayRow(i)
|
||||
.find('div.fc-day-content > div');
|
||||
}
|
||||
return rowDivs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Mouse Handlers
|
||||
---------------------------------------------------------------------------------------------------*/
|
||||
// TODO: better documentation!
|
||||
|
||||
|
||||
function attachHandlers(segments, modifiedEventId) {
|
||||
var segmentContainer = getDaySegmentContainer();
|
||||
|
||||
segmentElementEach(segments, function(segment, element, i) {
|
||||
var event = segment.event;
|
||||
if (event._id === modifiedEventId) {
|
||||
bindDaySeg(event, element, segment);
|
||||
}else{
|
||||
element[0]._fci = i; // for lazySegBind
|
||||
}
|
||||
});
|
||||
|
||||
lazySegBind(segmentContainer, segments, bindDaySeg);
|
||||
}
|
||||
|
||||
|
||||
function bindDaySeg(event, eventElement, segment) {
|
||||
|
||||
if (isEventDraggable(event)) {
|
||||
t.draggableDayEvent(event, eventElement, segment); // use `t` so subclasses can override
|
||||
}
|
||||
|
||||
if (
|
||||
event.allDay &&
|
||||
segment.isEnd && // only allow resizing on the final segment for an event
|
||||
isEventResizable(event)
|
||||
) {
|
||||
t.resizableDayEvent(event, eventElement, segment); // use `t` so subclasses can override
|
||||
}
|
||||
|
||||
// attach all other handlers.
|
||||
// needs to be after, because resizableDayEvent might stopImmediatePropagation on click
|
||||
eventElementHandlers(event, eventElement);
|
||||
}
|
||||
|
||||
|
||||
function draggableDayEvent(event, eventElement) {
|
||||
var hoverListener = getHoverListener();
|
||||
var dayDelta;
|
||||
var eventStart;
|
||||
eventElement.draggable({
|
||||
delay: 50,
|
||||
opacity: opt('dragOpacity'),
|
||||
revertDuration: opt('dragRevertDuration'),
|
||||
start: function(ev, ui) {
|
||||
trigger('eventDragStart', eventElement[0], event, ev, ui);
|
||||
hideEvents(event, eventElement);
|
||||
hoverListener.start(function(cell, origCell, rowDelta, colDelta) {
|
||||
eventElement.draggable('option', 'revert', !cell || !rowDelta && !colDelta);
|
||||
clearOverlays();
|
||||
if (cell) {
|
||||
var origCellDate = cellToDate(origCell);
|
||||
var cellDate = cellToDate(cell);
|
||||
dayDelta = cellDate.diff(origCellDate, 'days');
|
||||
eventStart = event.start.clone().add(dayDelta, 'days');
|
||||
renderDayOverlay(
|
||||
eventStart,
|
||||
getEventEnd(event).add(dayDelta, 'days')
|
||||
);
|
||||
}
|
||||
else {
|
||||
dayDelta = 0;
|
||||
}
|
||||
}, ev, 'drag');
|
||||
},
|
||||
stop: function(ev, ui) {
|
||||
hoverListener.stop();
|
||||
clearOverlays();
|
||||
trigger('eventDragStop', eventElement[0], event, ev, ui);
|
||||
if (dayDelta) {
|
||||
eventDrop(
|
||||
eventElement[0],
|
||||
event,
|
||||
eventStart,
|
||||
ev,
|
||||
ui
|
||||
);
|
||||
}
|
||||
else {
|
||||
eventElement.css('filter', ''); // clear IE opacity side-effects
|
||||
showEvents(event, eventElement);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function resizableDayEvent(event, element, segment) {
|
||||
var isRTL = opt('isRTL');
|
||||
var direction = isRTL ? 'w' : 'e';
|
||||
var handle = element.find('.ui-resizable-' + direction); // TODO: stop using this class because we aren't using jqui for this
|
||||
var isResizing = false;
|
||||
|
||||
// TODO: look into using jquery-ui mouse widget for this stuff
|
||||
disableTextSelection(element); // prevent native <a> selection for IE
|
||||
element
|
||||
.mousedown(function(ev) { // prevent native <a> selection for others
|
||||
ev.preventDefault();
|
||||
})
|
||||
.click(function(ev) {
|
||||
if (isResizing) {
|
||||
ev.preventDefault(); // prevent link from being visited (only method that worked in IE6)
|
||||
ev.stopImmediatePropagation(); // prevent fullcalendar eventClick handler from being called
|
||||
// (eventElementHandlers needs to be bound after resizableDayEvent)
|
||||
}
|
||||
});
|
||||
|
||||
handle.mousedown(function(ev) {
|
||||
if (ev.which != 1) {
|
||||
return; // needs to be left mouse button
|
||||
}
|
||||
isResizing = true;
|
||||
var hoverListener = getHoverListener();
|
||||
var elementTop = element.css('top');
|
||||
var dayDelta;
|
||||
var eventEnd;
|
||||
var helpers;
|
||||
var eventCopy = $.extend({}, event);
|
||||
var minCellOffset = dayOffsetToCellOffset(dateToDayOffset(event.start));
|
||||
clearSelection();
|
||||
$('body')
|
||||
.css('cursor', direction + '-resize')
|
||||
.one('mouseup', mouseup);
|
||||
trigger('eventResizeStart', element[0], event, ev, {}); // {} is dummy jqui event
|
||||
hoverListener.start(function(cell, origCell) {
|
||||
if (cell) {
|
||||
|
||||
var origCellOffset = cellToCellOffset(origCell);
|
||||
var cellOffset = cellToCellOffset(cell);
|
||||
|
||||
// don't let resizing move earlier than start date cell
|
||||
cellOffset = Math.max(cellOffset, minCellOffset);
|
||||
|
||||
dayDelta =
|
||||
cellOffsetToDayOffset(cellOffset) -
|
||||
cellOffsetToDayOffset(origCellOffset);
|
||||
|
||||
eventEnd = getEventEnd(event).add(dayDelta, 'days'); // assumed to already have a stripped time
|
||||
|
||||
if (dayDelta) {
|
||||
eventCopy.end = eventEnd;
|
||||
var oldHelpers = helpers;
|
||||
helpers = renderTempDayEvent(eventCopy, segment.row, elementTop);
|
||||
helpers = $(helpers); // turn array into a jQuery object
|
||||
helpers.find('*').css('cursor', direction + '-resize');
|
||||
if (oldHelpers) {
|
||||
oldHelpers.remove();
|
||||
}
|
||||
hideEvents(event);
|
||||
}
|
||||
else {
|
||||
if (helpers) {
|
||||
showEvents(event);
|
||||
helpers.remove();
|
||||
helpers = null;
|
||||
}
|
||||
}
|
||||
|
||||
clearOverlays();
|
||||
renderDayOverlay( // coordinate grid already rebuilt with hoverListener.start()
|
||||
event.start,
|
||||
eventEnd
|
||||
// TODO: instead of calling renderDayOverlay() with dates,
|
||||
// call _renderDayOverlay (or whatever) with cell offsets.
|
||||
);
|
||||
}
|
||||
}, ev);
|
||||
|
||||
function mouseup(ev) {
|
||||
trigger('eventResizeStop', element[0], event, ev, {}); // {} is dummy jqui event
|
||||
$('body').css('cursor', '');
|
||||
hoverListener.stop();
|
||||
clearOverlays();
|
||||
|
||||
if (dayDelta) {
|
||||
eventResize(
|
||||
element[0],
|
||||
event,
|
||||
eventEnd,
|
||||
ev,
|
||||
{} // dummy jqui event
|
||||
);
|
||||
// event redraw will clear helpers
|
||||
}
|
||||
// otherwise, the drag handler already restored the old events
|
||||
|
||||
setTimeout(function() { // make this happen after the element's click event
|
||||
isResizing = false;
|
||||
},0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Generalized Segment Utilities
|
||||
-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
function isDaySegmentCollision(segment, otherSegments) {
|
||||
for (var i=0; i<otherSegments.length; i++) {
|
||||
var otherSegment = otherSegments[i];
|
||||
if (
|
||||
otherSegment.leftCol <= segment.rightCol &&
|
||||
otherSegment.rightCol >= segment.leftCol
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function segmentElementEach(segments, callback) { // TODO: use in AgendaView?
|
||||
for (var i=0; i<segments.length; i++) {
|
||||
var segment = segments[i];
|
||||
var element = segment.element;
|
||||
if (element) {
|
||||
callback(segment, element, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// A cmp function for determining which segments should appear higher up
|
||||
function compareDaySegments(a, b) {
|
||||
return (b.rightCol - b.leftCol) - (a.rightCol - a.leftCol) || // put wider events first
|
||||
b.event.allDay - a.event.allDay || // if tie, put all-day events first (booleans cast to 0/1)
|
||||
a.event.start - b.event.start || // if a tie, sort by event start date
|
||||
(a.event.title || '').localeCompare(b.event.title); // if a tie, sort by event title
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
|
||||
function HorizontalPositionCache(getElement) {
|
||||
|
||||
var t = this,
|
||||
elements = {},
|
||||
lefts = {},
|
||||
rights = {};
|
||||
|
||||
function e(i) {
|
||||
return (elements[i] = (elements[i] || getElement(i)));
|
||||
}
|
||||
|
||||
t.left = function(i) {
|
||||
return (lefts[i] = (lefts[i] === undefined ? e(i).position().left : lefts[i]));
|
||||
};
|
||||
|
||||
t.right = function(i) {
|
||||
return (rights[i] = (rights[i] === undefined ? t.left(i) + e(i).width() : rights[i]));
|
||||
};
|
||||
|
||||
t.clear = function() {
|
||||
elements = {};
|
||||
lefts = {};
|
||||
rights = {};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
function HoverListener(coordinateGrid) {
|
||||
|
||||
|
||||
var t = this;
|
||||
var bindType;
|
||||
var change;
|
||||
var firstCell;
|
||||
var cell;
|
||||
|
||||
|
||||
t.start = function(_change, ev, _bindType) {
|
||||
change = _change;
|
||||
firstCell = cell = null;
|
||||
coordinateGrid.build();
|
||||
mouse(ev);
|
||||
bindType = _bindType || 'mousemove';
|
||||
$(document).bind(bindType, mouse);
|
||||
};
|
||||
|
||||
|
||||
function mouse(ev) {
|
||||
_fixUIEvent(ev); // see below
|
||||
var newCell = coordinateGrid.cell(ev.pageX, ev.pageY);
|
||||
if (
|
||||
Boolean(newCell) !== Boolean(cell) ||
|
||||
newCell && (newCell.row != cell.row || newCell.col != cell.col)
|
||||
) {
|
||||
if (newCell) {
|
||||
if (!firstCell) {
|
||||
firstCell = newCell;
|
||||
}
|
||||
change(newCell, firstCell, newCell.row-firstCell.row, newCell.col-firstCell.col);
|
||||
}else{
|
||||
change(newCell, firstCell);
|
||||
}
|
||||
cell = newCell;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
t.stop = function() {
|
||||
$(document).unbind(bindType, mouse);
|
||||
return cell;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this fix was only necessary for jQuery UI 1.8.16 (and jQuery 1.7 or 1.7.1)
|
||||
// upgrading to jQuery UI 1.8.17 (and using either jQuery 1.7 or 1.7.1) fixed the problem
|
||||
// but keep this in here for 1.8.16 users
|
||||
// and maybe remove it down the line
|
||||
|
||||
function _fixUIEvent(event) { // for issue 1168
|
||||
if (event.pageX === undefined) {
|
||||
event.pageX = event.originalEvent.pageX;
|
||||
event.pageY = event.originalEvent.pageY;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
function OverlayManager() {
|
||||
var t = this;
|
||||
|
||||
|
||||
// exports
|
||||
t.renderOverlay = renderOverlay;
|
||||
t.clearOverlays = clearOverlays;
|
||||
|
||||
|
||||
// locals
|
||||
var usedOverlays = [];
|
||||
var unusedOverlays = [];
|
||||
|
||||
|
||||
function renderOverlay(rect, parent) {
|
||||
var e = unusedOverlays.shift();
|
||||
if (!e) {
|
||||
e = $("<div class='fc-cell-overlay' style='position:absolute;z-index:3'/>");
|
||||
}
|
||||
if (e[0].parentNode != parent[0]) {
|
||||
e.appendTo(parent);
|
||||
}
|
||||
usedOverlays.push(e.css(rect).show());
|
||||
return e;
|
||||
}
|
||||
|
||||
|
||||
function clearOverlays() {
|
||||
var e;
|
||||
while ((e = usedOverlays.shift())) {
|
||||
unusedOverlays.push(e.hide().unbind());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,122 +0,0 @@
|
||||
|
||||
//BUG: unselect needs to be triggered when events are dragged+dropped
|
||||
|
||||
function SelectionManager() {
|
||||
var t = this;
|
||||
|
||||
|
||||
// exports
|
||||
t.select = select;
|
||||
t.unselect = unselect;
|
||||
t.reportSelection = reportSelection;
|
||||
t.daySelectionMousedown = daySelectionMousedown;
|
||||
t.selectionManagerDestroy = destroy;
|
||||
|
||||
|
||||
// imports
|
||||
var calendar = t.calendar;
|
||||
var opt = t.opt;
|
||||
var trigger = t.trigger;
|
||||
var defaultSelectionEnd = t.defaultSelectionEnd;
|
||||
var renderSelection = t.renderSelection;
|
||||
var clearSelection = t.clearSelection;
|
||||
|
||||
|
||||
// locals
|
||||
var selected = false;
|
||||
|
||||
|
||||
|
||||
// unselectAuto
|
||||
if (opt('selectable') && opt('unselectAuto')) {
|
||||
$(document).on('mousedown', documentMousedown);
|
||||
}
|
||||
|
||||
|
||||
function documentMousedown(ev) {
|
||||
var ignore = opt('unselectCancel');
|
||||
if (ignore) {
|
||||
if ($(ev.target).parents(ignore).length) { // could be optimized to stop after first match
|
||||
return;
|
||||
}
|
||||
}
|
||||
unselect(ev);
|
||||
}
|
||||
|
||||
|
||||
function select(start, end) {
|
||||
unselect();
|
||||
|
||||
start = calendar.moment(start);
|
||||
if (end) {
|
||||
end = calendar.moment(end);
|
||||
}
|
||||
else {
|
||||
end = defaultSelectionEnd(start);
|
||||
}
|
||||
|
||||
renderSelection(start, end);
|
||||
reportSelection(start, end);
|
||||
}
|
||||
// TODO: better date normalization. see notes in automated test
|
||||
|
||||
|
||||
function unselect(ev) {
|
||||
if (selected) {
|
||||
selected = false;
|
||||
clearSelection();
|
||||
trigger('unselect', null, ev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function reportSelection(start, end, ev) {
|
||||
selected = true;
|
||||
trigger('select', null, start, end, ev);
|
||||
}
|
||||
|
||||
|
||||
function daySelectionMousedown(ev) { // not really a generic manager method, oh well
|
||||
var cellToDate = t.cellToDate;
|
||||
var getIsCellAllDay = t.getIsCellAllDay;
|
||||
var hoverListener = t.getHoverListener();
|
||||
var reportDayClick = t.reportDayClick; // this is hacky and sort of weird
|
||||
|
||||
if (ev.which == 1 && opt('selectable')) { // which==1 means left mouse button
|
||||
unselect(ev);
|
||||
var dates;
|
||||
hoverListener.start(function(cell, origCell) { // TODO: maybe put cellToDate/getIsCellAllDay info in cell
|
||||
clearSelection();
|
||||
if (cell && getIsCellAllDay(cell)) {
|
||||
dates = [ cellToDate(origCell), cellToDate(cell) ].sort(dateCompare);
|
||||
renderSelection(
|
||||
dates[0],
|
||||
dates[1].clone().add(1, 'days') // make exclusive
|
||||
);
|
||||
}else{
|
||||
dates = null;
|
||||
}
|
||||
}, ev);
|
||||
$(document).one('mouseup', function(ev) {
|
||||
hoverListener.stop();
|
||||
if (dates) {
|
||||
if (+dates[0] == +dates[1]) {
|
||||
reportDayClick(dates[0], ev);
|
||||
}
|
||||
reportSelection(
|
||||
dates[0],
|
||||
dates[1].clone().add(1, 'days'), // make exclusive
|
||||
ev
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function destroy() {
|
||||
$(document).off('mousedown', documentMousedown);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="./lib/bootstrap.min.css" />
|
||||
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3 class="text-center">Calendar demo</h3>
|
||||
|
||||
<div id="calendar"></div>
|
||||
|
||||
<script src='../build/out/jquery.js'></script>
|
||||
<script src='../build/out/jquery-ui.js'></script>
|
||||
|
||||
<script src="./lib/bootstrap.min.js"></script>
|
||||
|
||||
<script src='../src/defaults.js'></script>
|
||||
<script src='../src/main.js'></script>
|
||||
<script src='../src/Calendar.js'></script>
|
||||
<script src='../src/Header.js'></script>
|
||||
<script src='../src/EventManager.js'></script>
|
||||
<script src='../src/ResourceManager.js'></script>
|
||||
<script src='../src/date_util.js'></script>
|
||||
<script src='../src/util.js'></script>
|
||||
<script src='../src/basic/MonthView.js'></script>
|
||||
<script src='../src/basic/BasicWeekView.js'></script>
|
||||
<script src='../src/basic/BasicDayView.js'></script>
|
||||
<script src='../src/basic/BasicView.js'></script>
|
||||
<script src='../src/basic/BasicEventRenderer.js'></script>
|
||||
<script src='../src/agenda/AgendaWeekView.js'></script>
|
||||
<script src='../src/agenda/AgendaDayView.js'></script>
|
||||
<script src='../src/agenda/AgendaView.js'></script>
|
||||
<script src='../src/agenda/AgendaEventRenderer.js'></script>
|
||||
<script src='../src/resource/ResourceDayView.js'></script>
|
||||
<script src='../src/resource/ResourceView.js'></script>
|
||||
<script src='../src/resource/ResourceEventRenderer.js'></script>
|
||||
<script src='../src/common/View.js'></script>
|
||||
<script src='../src/common/DayEventRenderer.js'></script>
|
||||
<script src='../src/common/SelectionManager.js'></script>
|
||||
<script src='../src/common/OverlayManager.js'></script>
|
||||
<script src='../src/common/CoordinateGrid.js'></script>
|
||||
<script src='../src/common/HoverListener.js'></script>
|
||||
<script src='../src/common/HorizontalPositionCache.js'></script>
|
||||
<script src='../build/out/gcal.js'></script>
|
||||
|
||||
<script src="dateFormat.min.js"></script>
|
||||
<script>
|
||||
// Code goes here
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
var study;
|
||||
|
||||
var ecoEvents = [{
|
||||
title: 'Test 1',
|
||||
start: new Date(y, m, d, 09, 15),
|
||||
end: new Date(y, m, d, 10, 00),
|
||||
allDay: false,
|
||||
resources: ['1','2']
|
||||
}, {
|
||||
title: 'Test 2',
|
||||
start: new Date(y, m, d, 08, 30),
|
||||
end: new Date(y, m, d, 09, 00),
|
||||
allDay: false,
|
||||
resources: ['2']
|
||||
}];
|
||||
|
||||
var ecoResources = [{'id':'1','name':'Eco Office 1'},{'id':'2', 'name':'Eco Office 2'}];
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
//When you click and select a time range show up the modal, with date,
|
||||
//start and end time fields populated (Didn´t add fields).
|
||||
select: function(start, end, allDay, ev, resources) {
|
||||
console.log(start);
|
||||
console.log(ev.data);
|
||||
},
|
||||
/*Clicking on an event makes an ajax request with the parameters I pass on the showModal
|
||||
function, and shows the modal with all the fields populated. */
|
||||
eventClick: function(event) {
|
||||
console.log(event);
|
||||
},
|
||||
resources: ecoResources,
|
||||
events: ecoEvents,
|
||||
titleFormat: {
|
||||
day: 'dd/MM/yyyy',
|
||||
week: "MMMM dd[ yyyy]{ '—'[ MMMM] d yyyy}"
|
||||
},
|
||||
columnFormat: {
|
||||
day: 'dddd dd/MM/yyyy',
|
||||
week: "dddd dd"
|
||||
},
|
||||
defaultView: 'resourceDay',
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'agendaWeek, agendaDay, resourceDay'
|
||||
},
|
||||
editable: true,
|
||||
eventDrop: function (event, delta, revertFunc) {
|
||||
console.log(event.resources);
|
||||
},
|
||||
allDaySlot: true,
|
||||
selectable: true,
|
||||
selectHelper: true,
|
||||
|
||||
droppable: true,
|
||||
snapMinutes: 5,
|
||||
slotMinutes: 15,
|
||||
aspectRatio: 2,
|
||||
height: 500,
|
||||
theme: false,
|
||||
buttonIcons: false,
|
||||
minTime: 8,
|
||||
maxTime: 21
|
||||
});
|
||||
|
||||
$("#study-selector").change(function(a, b, c) {
|
||||
var office = $(this).val();
|
||||
|
||||
// TAC
|
||||
if (office == 2){
|
||||
events = [{
|
||||
title: 'TAC Appointment',
|
||||
start: new Date(y, m, d, 08, 30),
|
||||
end: new Date(y, m, d, 09, 00),
|
||||
allDay: false,
|
||||
resources: ['3']
|
||||
}];
|
||||
resources = [{'id':'3','name':'Tac Office'}];
|
||||
} else if (office == 3){
|
||||
events = [{
|
||||
title: 'RMN Appointment',
|
||||
start: new Date(y, m, d, 09, 15),
|
||||
end: new Date(y, m, d, 10, 00),
|
||||
allDay: false,
|
||||
resources: ['4']
|
||||
}];
|
||||
resources = [{'id':'4','name':'RMS Office'}];
|
||||
} else {
|
||||
events = ecoEvents;
|
||||
resources = ecoResources;
|
||||
}
|
||||
|
||||
cal = $('#calendar');
|
||||
cal.fullCalendar('setResources', resources)
|
||||
cal.fullCalendar('removeEvents')
|
||||
cal.fullCalendar('render')
|
||||
cal.fullCalendar('addEventSource', events)
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,52 +0,0 @@
|
||||
|
||||
describe('agenda view rendering', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when isRTL is false', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'agendaWeek',
|
||||
isRTL: false
|
||||
});
|
||||
});
|
||||
|
||||
it('should have have days ordered sun to sat', function() {
|
||||
var fc = $('#cal').find('.fc-view > table > thead th');
|
||||
expect(fc[0]).toHaveClass('fc-axis');
|
||||
expect(fc[1]).toHaveClass('fc-sun');
|
||||
expect(fc[2]).toHaveClass('fc-mon');
|
||||
expect(fc[3]).toHaveClass('fc-tue');
|
||||
expect(fc[4]).toHaveClass('fc-wed');
|
||||
expect(fc[5]).toHaveClass('fc-thu');
|
||||
expect(fc[6]).toHaveClass('fc-fri');
|
||||
expect(fc[7]).toHaveClass('fc-sat');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when isRTL is true', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'agendaWeek',
|
||||
isRTL: true
|
||||
});
|
||||
});
|
||||
|
||||
it('should have have days ordered sat to sun', function() {
|
||||
var fc = $('#cal').find('.fc-view > table > thead th');
|
||||
expect(fc[0]).toHaveClass('fc-sat');
|
||||
expect(fc[1]).toHaveClass('fc-fri');
|
||||
expect(fc[2]).toHaveClass('fc-thu');
|
||||
expect(fc[3]).toHaveClass('fc-wed');
|
||||
expect(fc[4]).toHaveClass('fc-tue');
|
||||
expect(fc[5]).toHaveClass('fc-mon');
|
||||
expect(fc[6]).toHaveClass('fc-sun');
|
||||
expect(fc[7]).toHaveClass('fc-axis');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,210 +0,0 @@
|
||||
|
||||
describe('allDayDefault', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when undefined', function() {
|
||||
|
||||
it('guesses false if T in ISO8601 start date', function() {
|
||||
$('#cal').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01T06:00:00'
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
it('guesses false if T in ISO8601 end date', function() {
|
||||
$('#cal').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01',
|
||||
end: '2014-05-01T08:00:00'
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
it('guesses true if ISO8601 start date with no time and unspecified end date', function() {
|
||||
$('#cal').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01'
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(true);
|
||||
});
|
||||
|
||||
it('guesses true if ISO8601 start and end date with no times', function() {
|
||||
$('#cal').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01',
|
||||
end: '2014-05-03'
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(true);
|
||||
});
|
||||
|
||||
it('guesses false if start is a unix timestamp (which implies it has a time)', function() {
|
||||
$('#cal').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: 1398902400000,
|
||||
end: '2014-05-03'
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
it('guesses false if end is a unix timestamp (which implies it has a time)', function() {
|
||||
$('#cal').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01',
|
||||
end: 1399075200000
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when specified', function() {
|
||||
|
||||
it('has an effect when an event\'s allDay is not specified', function() {
|
||||
$('#cal').fullCalendar({
|
||||
allDayDefault: false,
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01'
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
it('has no effect when an event\'s allDay is specified', function() {
|
||||
$('#cal').fullCalendar({
|
||||
allDayDefault: false,
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01T00:00:00',
|
||||
allDay: true
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('source.allDayDefault', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
it('has an effect when an event\'s allDay is not specified', function() {
|
||||
$('#cal').fullCalendar({
|
||||
eventSources: [
|
||||
{
|
||||
allDayDefault: false,
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
it('a true value can override the global allDayDefault', function() {
|
||||
$('#cal').fullCalendar({
|
||||
allDayDefault: false,
|
||||
eventSources: [
|
||||
{
|
||||
allDayDefault: true,
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01T06:00:00'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(true);
|
||||
});
|
||||
|
||||
it('a false value can override the global allDayDefault', function() {
|
||||
$('#cal').fullCalendar({
|
||||
allDayDefault: true,
|
||||
eventSources: [
|
||||
{
|
||||
allDayDefault: false,
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
it('has no effect when an event\'s allDay is specified', function() {
|
||||
$('#cal').fullCalendar({
|
||||
eventSources: [
|
||||
{
|
||||
allDayDefault: true,
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-01',
|
||||
allDay: false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
||||
var eventObj = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
expect(eventObj.allDay).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,80 +0,0 @@
|
||||
|
||||
describe('allDaySlots', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when allDaySlots is not set', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should default to having an allDaySlots table', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDaySlotCount = $('.fc-day-grid').length;
|
||||
expect(allDaySlotCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should default to having an allDaySlots table', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDaySlotCount = $('.fc-day-grid').length;
|
||||
expect(allDaySlotCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when allDaySlots is set true', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should default to having an allDaySlots table', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
allDaySlot: true
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDaySlotCount = $('.fc-day-grid').length;
|
||||
expect(allDaySlotCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should default to having an allDaySlots table', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
allDaySlot: true
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDaySlotCount = $('.fc-day-grid').length;
|
||||
expect(allDaySlotCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when allDaySlots is set false', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should default to having an allDaySlots table', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
allDaySlot: false
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDaySlotCount = $('.fc-day-grid').length;
|
||||
expect(allDaySlotCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should default to having an allDaySlots table', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
allDaySlot: false
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDaySlotCount = $('.fc-day-grid').length;
|
||||
expect(allDaySlotCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,108 +0,0 @@
|
||||
|
||||
describe('allDayText', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when allDaySlots is not set', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should default allDayText to using \'all-day\'', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('all-day');
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should default allDayText to using \'all-day\'', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('all-day');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when allDaySlots is set true', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should default allDayText to using \'all-day\'', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
allDaySlot: true
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('all-day');
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should default allDayText to using \'all-day\'', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
allDaySlot: true
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('all-day');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when allDaySlots is set true and language is not default', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should use the language\'s all-day value', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
allDaySlot: true,
|
||||
lang: 'pt-br'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('dia inteiro');
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should use the language\'s all-day value', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
allDaySlot: true,
|
||||
lang: 'pt-br'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('dia inteiro');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when allDaySlots is set true and allDayText is specified', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should show specified all day text', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
allDaySlot: true,
|
||||
allDayText: 'axis-phosy'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('axis-phosy');
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should show specified all day text', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
allDayText: 'axis-phosy'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var allDayText = $('.fc-day-grid > .fc-row > .fc-bg .fc-axis').text();
|
||||
expect(allDayText).toEqual('axis-phosy');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,139 +0,0 @@
|
||||
|
||||
describe('aspectRatio', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when default settings are used', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(675);
|
||||
$('#cal').fullCalendar();
|
||||
});
|
||||
it('fc-content should use the ratio 1:35 to set height', function() {
|
||||
var height = $('.fc-view-container').height();
|
||||
expect(height).toEqual(500);
|
||||
});
|
||||
it('fc-content should have width of div', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(675);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when initializing the aspectRatio', function() {
|
||||
|
||||
describe('to 2', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(1000);
|
||||
$('#cal').fullCalendar({
|
||||
aspectRatio: 2
|
||||
});
|
||||
});
|
||||
it('should not change the width', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(1000);
|
||||
});
|
||||
it('should set the height to width sizes very close to ratio of 2', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
var height = $('.fc-view-container').height();
|
||||
var ratio = Math.round(width / height * 100);
|
||||
expect(ratio).toEqual(200);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to 1', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(1000);
|
||||
$('#cal').fullCalendar({
|
||||
aspectRatio: 1
|
||||
});
|
||||
});
|
||||
it('should not change the width', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(1000);
|
||||
});
|
||||
it('should set the height to width sizes very close to ratio of 2', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
var height = $('.fc-view-container').height();
|
||||
var ratio = Math.round(width / height * 100);
|
||||
expect(ratio).toEqual(100);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to less than 0.5', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(1000);
|
||||
$('#cal').fullCalendar({
|
||||
aspectRatio: 0.4
|
||||
});
|
||||
});
|
||||
it('should not change the width', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(1000);
|
||||
});
|
||||
it('should set the height to width ratio to 0.5', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
var height = $('.fc-view-container').height();
|
||||
var ratio = Math.round(width / height * 100);
|
||||
expect(ratio).toEqual(50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to negative', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(1000);
|
||||
$('#cal').fullCalendar({
|
||||
aspectRatio: -2
|
||||
});
|
||||
});
|
||||
it('should not change the width', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(1000);
|
||||
});
|
||||
it('should set the height to width ratio to 0.5', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
var height = $('.fc-view-container').height();
|
||||
var ratio = Math.round(width / height * 100);
|
||||
expect(ratio).toEqual(50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to zero', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(1000);
|
||||
$('#cal').fullCalendar({
|
||||
aspectRatio: 0
|
||||
});
|
||||
});
|
||||
it('should not change the width', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(1000);
|
||||
});
|
||||
it('should set the height to width ratio to 0.5', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
var height = $('.fc-view-container').height();
|
||||
var ratio = Math.round(width / height * 100);
|
||||
expect(ratio).toEqual(50);
|
||||
});
|
||||
});
|
||||
|
||||
describe('to very large', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(1000);
|
||||
$('#cal').fullCalendar({
|
||||
aspectRatio: 4000
|
||||
});
|
||||
});
|
||||
it('should not change the width', function() {
|
||||
var width = $('.fc-view-container').width();
|
||||
expect(width).toEqual(1000);
|
||||
});
|
||||
it('should cause rows to be natural height', function() {
|
||||
var actualHeight = $('.fc-view-container').height();
|
||||
$('tr.fc-week td:first-child > div').css('min-height', '').css('background', 'red');
|
||||
var naturalHeight = $('.fc-view-container').height();
|
||||
expect(actualHeight).toEqual(naturalHeight);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,33 +0,0 @@
|
||||
describe('axisFormat', function() {
|
||||
|
||||
var options;
|
||||
|
||||
function getAxisText() {
|
||||
return $('.fc-slats tr:first-child .fc-time').text();
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-06-04',
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
});
|
||||
|
||||
it('renders correctly when default', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getAxisText()).toBe('12am');
|
||||
});
|
||||
|
||||
it('renders correctly when default and the language is customized', function() {
|
||||
options.lang = 'en-gb';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getAxisText()).toBe('00');
|
||||
});
|
||||
|
||||
it('renders correctly when customized', function() {
|
||||
options.axisFormat = 'H:mm:mm[!]';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getAxisText()).toBe('0:00:00!');
|
||||
});
|
||||
});
|
||||
@@ -1,50 +0,0 @@
|
||||
|
||||
describe('basic view rendering', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when isRTL is false', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'month',
|
||||
isRTL: false
|
||||
});
|
||||
});
|
||||
|
||||
it('should have have days ordered sun to sat', function() {
|
||||
var fc = $('#cal').find('.fc-day-header');
|
||||
expect(fc[0]).toHaveClass('fc-sun');
|
||||
expect(fc[1]).toHaveClass('fc-mon');
|
||||
expect(fc[2]).toHaveClass('fc-tue');
|
||||
expect(fc[3]).toHaveClass('fc-wed');
|
||||
expect(fc[4]).toHaveClass('fc-thu');
|
||||
expect(fc[5]).toHaveClass('fc-fri');
|
||||
expect(fc[6]).toHaveClass('fc-sat');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when isRTL is true', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'month',
|
||||
isRTL: true
|
||||
});
|
||||
});
|
||||
|
||||
it('should have have days ordered sat to sun', function() {
|
||||
var fc = $('#cal').find('.fc-day-header');
|
||||
expect(fc[0]).toHaveClass('fc-sat');
|
||||
expect(fc[1]).toHaveClass('fc-fri');
|
||||
expect(fc[2]).toHaveClass('fc-thu');
|
||||
expect(fc[3]).toHaveClass('fc-wed');
|
||||
expect(fc[4]).toHaveClass('fc-tue');
|
||||
expect(fc[5]).toHaveClass('fc-mon');
|
||||
expect(fc[6]).toHaveClass('fc-sun');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,92 +0,0 @@
|
||||
describe('buttonIcons', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when buttonIcons is not set', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'prevYear, nextYear'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should have default values', function() {
|
||||
var prevBtn = $('#cal').find('.fc-prev-button');
|
||||
var nextBtn = $('#cal').find('.fc-next-button');
|
||||
var nextYearBtn = $('#cal').find('.fc-nextYear-button');
|
||||
var prevYearBtn = $('#cal').find('.fc-prevYear-button');
|
||||
|
||||
expect(prevBtn.find('span:first')).toHaveClass('fc-icon-left-single-arrow');
|
||||
expect(nextBtn.find('span:first')).toHaveClass('fc-icon-right-single-arrow');
|
||||
expect(nextYearBtn.find('span:first')).toHaveClass('fc-icon-right-double-arrow');
|
||||
expect(prevYearBtn.find('span:first')).toHaveClass('fc-icon-left-double-arrow');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when buttonIcons is set and theme is falsy', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
buttonIcons: {
|
||||
prev: 'some-icon-left',
|
||||
next: 'some-icon-right',
|
||||
prevYear: 'some-icon-leftYear',
|
||||
nextYear: 'some-icon-rightYear'
|
||||
},
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'prevYear, nextYear'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the set values', function() {
|
||||
var prevBtn = $('#cal').find('.fc-prev-button');
|
||||
var nextBtn = $('#cal').find('.fc-next-button');
|
||||
var prevYearBtn = $('#cal').find('.fc-prevYear-button');
|
||||
var nextYearBtn = $('#cal').find('.fc-nextYear-button');
|
||||
|
||||
|
||||
expect(prevBtn.find('span:first')).toHaveClass('fc-icon-some-icon-left');
|
||||
expect(prevBtn.find('span:first')).toHaveClass('fc-icon-some-icon-left');
|
||||
expect(prevYearBtn.find('span:first')).toHaveClass('fc-icon-some-icon-leftYear');
|
||||
expect(nextYearBtn.find('span:first')).toHaveClass('fc-icon-some-icon-rightYear');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when theme is true', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
theme: true,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'prevYear, nextYear'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('buttonIcons is ignored', function() {
|
||||
var prevBtn = $('#cal').find('.fc-prev-button');
|
||||
var nextBtn = $('#cal').find('.fc-next-button');
|
||||
var prevYearBtn = $('#cal').find('.fc-prevYear-button');
|
||||
var nextYearBtn = $('#cal').find('.fc-nextYear-button');
|
||||
|
||||
var classesToSearch = [ '.fc-icon-left-single-arrow', '.fc-icon-right-double-arrow',
|
||||
'.fc-icon-right-single-arrow', '.fc-icon-left-double-arrow' ];
|
||||
|
||||
for (var i = 0; i < classesToSearch.length; i++) {
|
||||
var cls = classesToSearch[i];
|
||||
expect($('#cal').find(cls).length).toBe(0);
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,225 +0,0 @@
|
||||
describe('button text', function() {
|
||||
|
||||
var settings;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
settings = {
|
||||
header: {
|
||||
left: 'prevYear,prev,today,next,nextYear',
|
||||
center: '',
|
||||
right: 'month,basicWeek,basicDay,agendaWeek,agendaDay'
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('with default language', function() {
|
||||
|
||||
describe('with default buttonIcons', function() {
|
||||
|
||||
it('should contain default text values', function() {
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
// will have button icons, to text will be empty
|
||||
expect($('.fc-next-button')).toHaveText('');
|
||||
expect($('.fc-nextYear-button')).toHaveText('');
|
||||
expect($('.fc-prev-button')).toHaveText('');
|
||||
expect($('.fc-prevYear-button')).toHaveText('');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('today');
|
||||
expect($('.fc-month-button')).toHaveText('month');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('week');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('week');
|
||||
expect($('.fc-basicDay-button')).toHaveText('day');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('day');
|
||||
});
|
||||
|
||||
it('should contain specified text values', function() {
|
||||
settings.buttonText = {
|
||||
prev: '<-',
|
||||
next: '->',
|
||||
prevYear: '<--',
|
||||
nextYear: '-->',
|
||||
today: 'tidei',
|
||||
month: 'mun',
|
||||
week: 'wiki',
|
||||
day: 'dei'
|
||||
};
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-next-button')).toHaveText('->');
|
||||
expect($('.fc-nextYear-button')).toHaveText('-->');
|
||||
expect($('.fc-prev-button')).toHaveText('<-');
|
||||
expect($('.fc-prevYear-button')).toHaveText('<--');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('tidei');
|
||||
expect($('.fc-month-button')).toHaveText('mun');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('dei');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('wiki');
|
||||
expect($('.fc-basicDay-button')).toHaveText('dei');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('wiki');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with buttonIcons turned off', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
settings.buttonIcons = false;
|
||||
});
|
||||
|
||||
it('should contain default text values', function() {
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
// will have actual text now
|
||||
expect($('.fc-next-button')).toHaveText('next');
|
||||
expect($('.fc-nextYear-button')).toHaveText('next year');
|
||||
expect($('.fc-prev-button')).toHaveText('prev');
|
||||
expect($('.fc-prevYear-button')).toHaveText('prev year');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('today');
|
||||
expect($('.fc-month-button')).toHaveText('month');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('week');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('week');
|
||||
expect($('.fc-basicDay-button')).toHaveText('day');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('day');
|
||||
});
|
||||
|
||||
it('should contain specified text values', function() {
|
||||
settings.buttonText = {
|
||||
prev: '<-',
|
||||
next: '->',
|
||||
prevYear: '<--',
|
||||
nextYear: '-->',
|
||||
today: 'tidei',
|
||||
month: 'mun',
|
||||
week: 'wiki',
|
||||
day: 'dei'
|
||||
};
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-next-button')).toHaveText('->');
|
||||
expect($('.fc-nextYear-button')).toHaveText('-->');
|
||||
expect($('.fc-prev-button')).toHaveText('<-');
|
||||
expect($('.fc-prevYear-button')).toHaveText('<--');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('tidei');
|
||||
expect($('.fc-month-button')).toHaveText('mun');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('dei');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('wiki');
|
||||
expect($('.fc-basicDay-button')).toHaveText('dei');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('wiki');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when lang is not default', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
settings.lang = 'fr';
|
||||
});
|
||||
|
||||
describe('with default buttonIcons', function() {
|
||||
|
||||
it('should contain default text values', function() {
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
// will contain icons, so will contain no text
|
||||
expect($('.fc-next-button')).toHaveText('');
|
||||
expect($('.fc-nextYear-button')).toHaveText('');
|
||||
expect($('.fc-prev-button')).toHaveText('');
|
||||
expect($('.fc-prevYear-button')).toHaveText('');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('Aujourd\'hui');
|
||||
expect($('.fc-month-button')).toHaveText('Mois');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('Semaine');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('Semaine');
|
||||
expect($('.fc-basicDay-button')).toHaveText('Jour');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('Jour');
|
||||
});
|
||||
|
||||
it('should contain specified text values', function() {
|
||||
settings.buttonText = {
|
||||
prev: '<-',
|
||||
next: '->',
|
||||
prevYear: '<--',
|
||||
nextYear: '-->',
|
||||
today: 'tidei',
|
||||
month: 'mun',
|
||||
week: 'wiki',
|
||||
day: 'dei'
|
||||
};
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-next-button')).toHaveText('->');
|
||||
expect($('.fc-nextYear-button')).toHaveText('-->');
|
||||
expect($('.fc-prev-button')).toHaveText('<-');
|
||||
expect($('.fc-prevYear-button')).toHaveText('<--');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('tidei');
|
||||
expect($('.fc-month-button')).toHaveText('mun');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('dei');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('wiki');
|
||||
expect($('.fc-basicDay-button')).toHaveText('dei');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('wiki');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('with buttonIcons turned off', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
settings.buttonIcons = false;
|
||||
});
|
||||
|
||||
it('should contain default text values', function() {
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
// will have the language's actual text now
|
||||
expect($('.fc-next-button')).toHaveText('Suivant');
|
||||
expect($('.fc-prev-button')).toHaveText('Précédent');
|
||||
//// languages files don't have data for prev/next *year*
|
||||
//expect($('.fc-nextYear-button')).toHaveText('Suivant');
|
||||
//expect($('.fc-prevYear-button')).toHaveText('Précédent');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('Aujourd\'hui');
|
||||
expect($('.fc-month-button')).toHaveText('Mois');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('Semaine');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('Semaine');
|
||||
expect($('.fc-basicDay-button')).toHaveText('Jour');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('Jour');
|
||||
});
|
||||
|
||||
it('should contain specified text values', function() {
|
||||
settings.buttonText = {
|
||||
prev: '<-',
|
||||
next: '->',
|
||||
prevYear: '<--',
|
||||
nextYear: '-->',
|
||||
today: 'tidei',
|
||||
month: 'mun',
|
||||
week: 'wiki',
|
||||
day: 'dei'
|
||||
};
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-next-button')).toHaveText('->');
|
||||
expect($('.fc-nextYear-button')).toHaveText('-->');
|
||||
expect($('.fc-prev-button')).toHaveText('<-');
|
||||
expect($('.fc-prevYear-button')).toHaveText('<--');
|
||||
|
||||
expect($('.fc-today-button')).toHaveText('tidei');
|
||||
expect($('.fc-month-button')).toHaveText('mun');
|
||||
expect($('.fc-agendaDay-button')).toHaveText('dei');
|
||||
expect($('.fc-agendaWeek-button')).toHaveText('wiki');
|
||||
expect($('.fc-basicDay-button')).toHaveText('dei');
|
||||
expect($('.fc-basicWeek-button')).toHaveText('wiki');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,115 +0,0 @@
|
||||
describe('columnFormat', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when columnFormat is not set', function() {
|
||||
|
||||
var viewWithFormat = [ { view: 'month', expected: 'Sun', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'basicWeek', expected: 'Sun 5/11', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaWeek', expected: 'Sun 5/11', selector: 'th.fc-widget-header.fc-sun' },
|
||||
{ view: 'basicDay', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaDay', expected: 'Sunday', selector: 'th.fc-widget-header.fc-sun' } ];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-05-11'
|
||||
});
|
||||
});
|
||||
|
||||
it('should have default values', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
describe('when columnFormat is set on a per-view basis', function() {
|
||||
|
||||
var viewWithFormat = [ { view: 'month', expected: 'Sunday', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'basicWeek', expected: 'Sunday 11 - 5', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaWeek', expected: 'Sunday 11 , 5', selector: 'th.fc-widget-header.fc-sun' },
|
||||
{ view: 'basicDay', expected: 'Sunday 11 | 5', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaDay', expected: 'Sunday 5/11', selector: 'th.fc-widget-header.fc-sun' } ];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-05-11',
|
||||
columnFormat: {
|
||||
month: 'dddd',
|
||||
agendaDay: 'dddd M/D',
|
||||
agendaWeek: 'dddd D , M',
|
||||
basicDay: 'dddd D | M',
|
||||
basicWeek: 'dddd D - M'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the correct values', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
describe('when lang is French', function() {
|
||||
|
||||
var viewWithFormat = [ { view: 'month', expected: 'dim.', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'basicWeek', expected: 'dim. 11/05', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaWeek', expected: 'dim. 11/05', selector: 'th.fc-widget-header.fc-sun' },
|
||||
{ view: 'basicDay', expected: 'dimanche', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaDay', expected: 'dimanche', selector: 'th.fc-widget-header.fc-sun' } ];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-05-11',
|
||||
lang: 'fr'
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the translated dates', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
describe('when lang is Korean', function() {
|
||||
|
||||
var viewWithFormat = [ { view: 'month', expected: '일', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'basicWeek', expected: '일 05.11', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaWeek', expected: '일 05.11', selector: 'th.fc-widget-header.fc-sun' },
|
||||
{ view: 'basicDay', expected: '일요일', selector: 'th.fc-day-header.fc-sun' },
|
||||
{ view: 'agendaDay', expected: '일요일', selector: 'th.fc-widget-header.fc-sun' } ];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-05-11',
|
||||
lang: 'ko'
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the translated dates and columnFormat should be computed differently', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(crtView.selector).text()).toBe(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,87 +0,0 @@
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#calendar');
|
||||
});
|
||||
|
||||
it('should return a jQuery object for chaining', function() {
|
||||
var res = $('#calendar').fullCalendar();
|
||||
expect(res instanceof jQuery).toBe(true);
|
||||
});
|
||||
|
||||
it('should not modify the options object', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
scrollTime: '09:00:00',
|
||||
slotDuration: { minutes: 45 }
|
||||
};
|
||||
var optionsCopy = $.extend({}, options, true);
|
||||
$('#calendar').fullCalendar(options);
|
||||
expect(options).toEqual(optionsCopy);
|
||||
});
|
||||
|
||||
it('should not modify the events array', function() {
|
||||
var options = {
|
||||
defaultView: 'month',
|
||||
defaultDate: '2014-05-27',
|
||||
events: [
|
||||
{
|
||||
title: 'mytitle',
|
||||
start: '2014-05-27'
|
||||
}
|
||||
]
|
||||
};
|
||||
var optionsCopy = $.extend(true, {}, options); // recursive copy
|
||||
$('#calendar').fullCalendar(options);
|
||||
expect(options).toEqual(optionsCopy);
|
||||
});
|
||||
|
||||
it('should not modify the eventSources array', function() {
|
||||
var options = {
|
||||
defaultView: 'month',
|
||||
defaultDate: '2014-05-27',
|
||||
eventSources: [
|
||||
{ events: [
|
||||
{
|
||||
title: 'mytitle',
|
||||
start: '2014-05-27'
|
||||
}
|
||||
] }
|
||||
]
|
||||
};
|
||||
var optionsCopy = $.extend(true, {}, options); // recursive copy
|
||||
$('#calendar').fullCalendar(options);
|
||||
expect(options).toEqual(optionsCopy);
|
||||
});
|
||||
|
||||
describe('when called on a div', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
$('#calendar').fullCalendar();
|
||||
});
|
||||
|
||||
it('should contain a table fc-toolbar', function() {
|
||||
var header = $('#calendar > .fc-toolbar');
|
||||
expect(header[0]).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should contain a div fc-view-container', function() {
|
||||
var content = ($('#calendar > .fc-view-container'));
|
||||
expect(content[0]).not.toBeUndefined();
|
||||
});
|
||||
|
||||
it('should only contain 2 elements', function() {
|
||||
var calenderNodeCount = $('#calendar >').length;
|
||||
expect(calenderNodeCount).toEqual(2);
|
||||
});
|
||||
|
||||
describe('and then called again', function() {
|
||||
it('should still only have a single set of calendar [header,content]', function() {
|
||||
$('#calendar').fullCalendar();
|
||||
var count = $('#calendar >').length;
|
||||
expect(count).toEqual(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,49 +0,0 @@
|
||||
|
||||
describe('contentHeight', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
$('#cal').width(900);
|
||||
});
|
||||
|
||||
describe('when the default options are used', function() {
|
||||
it('should set the height', function() {
|
||||
$('#cal').width(1350);
|
||||
$('#cal').fullCalendar();
|
||||
var height = $('.fc-content').height();
|
||||
expect(height).toEqual(1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the content height is set', function() {
|
||||
it('should set the content height', function() {
|
||||
$('#cal').fullCalendar({
|
||||
contentHeight: 1000
|
||||
});
|
||||
var height = $('.fc-content').height();
|
||||
expect(height).toEqual(1000);
|
||||
});
|
||||
it('should not change the container width', function() {
|
||||
$('#cal').fullCalendar({
|
||||
contentHeight: 1000
|
||||
});
|
||||
var width = $('#cal').width();
|
||||
expect(width).toEqual(900);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when the content height setter is used', function() {
|
||||
it('should set the content height', function() {
|
||||
$('#cal').fullCalendar();
|
||||
$('#cal').fullCalendar('option', 'contentHeight', 1137);
|
||||
var height = $('.fc-content').height();
|
||||
expect(height).toEqual(1137);
|
||||
});
|
||||
it('should not change the container width', function() {
|
||||
$('#cal').fullCalendar();
|
||||
$('#cal').fullCalendar('option', 'contentHeight', 1137);
|
||||
var width = $('#cal').width();
|
||||
expect(width).toEqual(900);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,290 +0,0 @@
|
||||
describe('current date', function() {
|
||||
|
||||
var TITLE_FORMAT = 'MMMM D YYYY';
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
titleFormat: TITLE_FORMAT,
|
||||
defaultDate: '2014-06-01'
|
||||
};
|
||||
});
|
||||
|
||||
describe('defaultDate & getDate', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should initialize at the date', function() {
|
||||
options.defaultDate = '2011-03-10';
|
||||
$('#cal').fullCalendar(options);
|
||||
expectViewDates('2011-02-27', '2011-04-10', '2011-03-01');
|
||||
var currentDate = $('#cal').fullCalendar('getDate');
|
||||
expect(moment.isMoment(currentDate)).toEqual(true); // test the type, but only here
|
||||
expect(currentDate).toEqualMoment('2011-03-10');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should initialize at the date, given a date string', function() {
|
||||
options.defaultDate = '2011-03-10';
|
||||
$('#cal').fullCalendar(options);
|
||||
expectViewDates('2011-03-06', '2011-03-13');
|
||||
expect($('#cal').fullCalendar('getDate')).toEqualMoment('2011-03-10');
|
||||
});
|
||||
it('should initialize at the date, given a Moment object', function() {
|
||||
options.defaultDate = $.fullCalendar.moment('2011-03-10');
|
||||
$('#cal').fullCalendar(options);
|
||||
expectViewDates('2011-03-06', '2011-03-13');
|
||||
expect($('#cal').fullCalendar('getDate')).toEqualMoment('2011-03-10');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should initialize at the date', function() {
|
||||
options.defaultDate = '2011-03-10';
|
||||
$('#cal').fullCalendar(options);
|
||||
expectViewDates('2011-03-10');
|
||||
expect($('#cal').fullCalendar('getDate')).toEqualMoment('2011-03-10');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('gotoDate', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should go to a date when given a date string', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('gotoDate', '2015-04-01');
|
||||
expectViewDates('2015-03-29', '2015-05-10', '2015-04-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should go to a date when given a date string', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('gotoDate', '2015-04-01');
|
||||
expectViewDates('2015-03-29', '2015-04-05');
|
||||
});
|
||||
it('should go to a date when given a date string with a time', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('gotoDate', '2015-04-01T12:00:00');
|
||||
expectViewDates('2015-03-29', '2015-04-05');
|
||||
});
|
||||
it('should go to a date when given a moment object', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('gotoDate', $.fullCalendar.moment('2015-04-01'));
|
||||
expectViewDates('2015-03-29', '2015-04-05');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should go to a date when given a date string', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('gotoDate', '2015-04-01');
|
||||
expectViewDates('2015-04-01');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('incrementDate', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should increment the date when given a Duration object', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('incrementDate', { months: -1 });
|
||||
expectViewDates('2014-04-27', '2014-06-08', '2014-05-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should increment the date when given a Duration object', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('incrementDate', { weeks: -2 });
|
||||
expectViewDates('2014-05-18', '2014-05-25');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should increment the date when given a Duration object', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('incrementDate', { days: 2 });
|
||||
expectViewDates('2014-06-03');
|
||||
});
|
||||
it('should increment the date when given a Duration string', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('incrementDate', '2.00:00:00');
|
||||
expectViewDates('2014-06-03');
|
||||
});
|
||||
it('should increment the date when given a Duration string with a time', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('incrementDate', '2.05:30:00');
|
||||
expectViewDates('2014-06-03');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('prev', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should move the calendar back a month', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('prev');
|
||||
expectViewDates('2014-04-27', '2014-06-08', '2014-05-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should move the calendar back a week', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('prev');
|
||||
expectViewDates('2014-05-25', '2014-06-01');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should move the calendar back a week', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('prev');
|
||||
expectViewDates('2014-05-31');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('next', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should move the calendar forward a month', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('next');
|
||||
expectViewDates('2014-06-29', '2014-08-10', '2014-07-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should move the calendar forward a week', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('next');
|
||||
expectViewDates('2014-06-08', '2014-06-15');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should move the calendar forward a week', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('next');
|
||||
expectViewDates('2014-06-02');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('prevYear', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should move the calendar back a year', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('prevYear');
|
||||
expectViewDates('2013-05-26', '2013-07-07', '2013-06-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should move the calendar back a year', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('prevYear');
|
||||
expectViewDates('2013-05-26', '2013-06-02');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should move the calendar back a year', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('prevYear');
|
||||
expectViewDates('2013-06-01');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('nextYear', function() {
|
||||
describeWhenInMonth(function() {
|
||||
it('should move the calendar forward a year', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('nextYear');
|
||||
expectViewDates('2015-05-31', '2015-07-12', '2015-06-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should move the calendar forward a year', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('nextYear');
|
||||
expectViewDates('2015-05-31', '2015-06-07');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should move the calendar forward a year', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('nextYear');
|
||||
expectViewDates('2015-06-01');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('today', function() {
|
||||
beforeEach(function() {
|
||||
options.now = '2016-03-15'; // the "today" date
|
||||
});
|
||||
describeWhenInMonth(function() {
|
||||
it('should move the calendar to now', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('today');
|
||||
expectViewDates('2016-02-28', '2016-04-10', '2016-03-01');
|
||||
});
|
||||
});
|
||||
describeWhenInWeek(function() {
|
||||
it('should move the calendar to now', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('today');
|
||||
expectViewDates('2016-03-13', '2016-03-20');
|
||||
});
|
||||
});
|
||||
describeWhenInDay(function() {
|
||||
it('should move the calendar to now', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('today');
|
||||
expectViewDates('2016-03-15');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// UTILS
|
||||
// -----
|
||||
|
||||
function describeWhenInMonth(func) {
|
||||
describeWhenIn('month', func);
|
||||
}
|
||||
|
||||
function describeWhenInWeek(func) {
|
||||
describeWhenIn('basicWeek', func);
|
||||
describeWhenIn('agendaWeek', func);
|
||||
}
|
||||
|
||||
function describeWhenInDay(func) {
|
||||
describeWhenIn('basicDay', func);
|
||||
describeWhenIn('agendaDay', func);
|
||||
}
|
||||
|
||||
function describeWhenIn(viewName, func) {
|
||||
describe('when in ' + viewName, function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = viewName;
|
||||
});
|
||||
func();
|
||||
});
|
||||
}
|
||||
|
||||
function expectViewDates(start, end, titleDate) {
|
||||
var view = $('#cal').fullCalendar('getView');
|
||||
var calculatedEnd;
|
||||
var title;
|
||||
|
||||
start = $.fullCalendar.moment(start);
|
||||
calculatedEnd = end ? $.fullCalendar.moment(end) : start.clone().add(1, 'days');
|
||||
expect(start).toEqualMoment(view.start);
|
||||
expect(calculatedEnd).toEqualMoment(view.end);
|
||||
|
||||
if (titleDate || !end) {
|
||||
title = $.fullCalendar.moment(titleDate || start).format(TITLE_FORMAT);
|
||||
}
|
||||
else {
|
||||
title = $.fullCalendar.formatRange(
|
||||
start,
|
||||
calculatedEnd.clone().add(-1, 'ms'),
|
||||
TITLE_FORMAT
|
||||
);
|
||||
}
|
||||
expect($('.fc-toolbar h2')).toContainText(title);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1,144 +0,0 @@
|
||||
describe('dayClick', function() {
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-05-27',
|
||||
selectable: false
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('#cal').fullCalendar('destroy');
|
||||
});
|
||||
|
||||
[ false, true ].forEach(function(isRTL) {
|
||||
describe('when isRTL is ' + isRTL, function() {
|
||||
beforeEach(function() {
|
||||
options.isRTL = isRTL;
|
||||
});
|
||||
[ false, true ].forEach(function(selectable) {
|
||||
describe('when selectable is ' + selectable, function() {
|
||||
beforeEach(function() {
|
||||
options.selectable = selectable;
|
||||
});
|
||||
|
||||
describe('when in month view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'month';
|
||||
});
|
||||
it('fires correctly when clicking on a cell', function(done) {
|
||||
options.dayClick = function(date, jsEvent, view) {
|
||||
expect(moment.isMoment(date)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(date.hasTime()).toEqual(false);
|
||||
expect(date).toEqualMoment('2014-05-07');
|
||||
};
|
||||
spyOn(options, 'dayClick').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
|
||||
var dayCell = $('.fc-day:eq(10)'); // 2014-05-07 (regardless of isRTL)
|
||||
|
||||
// for simulating the mousedown/mouseup/click (relevant for selectable)
|
||||
dayCell.simulate('drag-n-drop', {
|
||||
callback: function() {
|
||||
dayCell.simulate('click');
|
||||
expect(options.dayClick).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when in agendaWeek view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'agendaWeek';
|
||||
});
|
||||
it('fires correctly when clicking on an all-day slot', function(done) {
|
||||
options.dayClick = function(date, jsEvent, view) {
|
||||
expect(moment.isMoment(date)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(date.hasTime()).toEqual(false);
|
||||
expect(date).toEqualMoment('2014-05-28');
|
||||
};
|
||||
spyOn(options, 'dayClick').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
|
||||
// 2014-05-28 (regardless of isRTL)
|
||||
var dayContent = $('.fc-agenda-view .fc-day-grid .fc-day:eq(3)');
|
||||
|
||||
// for simulating the mousedown/mouseup/click (relevant for selectable)
|
||||
dayContent.simulate('drag-n-drop', {
|
||||
callback: function() {
|
||||
dayContent.simulate('click');
|
||||
expect(options.dayClick).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
it('fires correctly when clicking on a timed slot', function(done) {
|
||||
|
||||
// make sure the click slot will be in scroll view
|
||||
options.contentHeight = 500;
|
||||
options.scrollTime = '07:00:00';
|
||||
|
||||
options.dayClick = function(date, jsEvent, view) {
|
||||
expect(moment.isMoment(date)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(date.hasTime()).toEqual(true);
|
||||
expect(date).toEqualMoment('2014-05-28T09:00:00');
|
||||
};
|
||||
spyOn(options, 'dayClick').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
|
||||
// the middle is 2014-05-28T09:00:00 (regardless of isRTL)
|
||||
var slotRow = $('.fc-slats tr:eq(18) td:not(.fc-time)');
|
||||
|
||||
// for simulating the mousedown/mouseup/click (relevant for selectable)
|
||||
slotRow.simulate('drag-n-drop', {
|
||||
callback: function() {
|
||||
expect(options.dayClick).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// issue 2217
|
||||
it('fires correctly when clicking on a timed slot, with minTime set', function(done) {
|
||||
|
||||
// make sure the click slot will be in scroll view
|
||||
options.contentHeight = 500;
|
||||
options.scrollTime = '07:00:00';
|
||||
options.minTime = '02:00:00';
|
||||
|
||||
options.dayClick = function(date, jsEvent, view) {
|
||||
expect(moment.isMoment(date)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(date.hasTime()).toEqual(true);
|
||||
expect(date).toEqualMoment('2014-05-28T11:00:00');
|
||||
};
|
||||
spyOn(options, 'dayClick').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
|
||||
// the middle is 2014-05-28T11:00:00 (regardless of isRTL)
|
||||
var slotRow = $('.fc-slats tr:eq(18) td:not(.fc-time)');
|
||||
|
||||
// for simulating the mousedown/mouseup/click (relevant for selectable)
|
||||
slotRow.simulate('drag-n-drop', {
|
||||
callback: function() {
|
||||
expect(options.dayClick).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,94 +0,0 @@
|
||||
describe('day names', function() {
|
||||
var settings = {};
|
||||
var testableClasses = [
|
||||
'basicDay',
|
||||
'agendaDay'
|
||||
];
|
||||
var dayClasses = [
|
||||
'.fc-sun',
|
||||
'.fc-mon',
|
||||
'.fc-tue',
|
||||
'.fc-wed',
|
||||
'.fc-thu',
|
||||
'.fc-fri',
|
||||
'.fc-sat'
|
||||
];
|
||||
var referenceDate = '2014-05-25 06:00'; // A sunday
|
||||
var languages = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ];
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
settings = {
|
||||
now: moment(referenceDate).toISOString()
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
moment.lang('en'); // reset moment's global language
|
||||
});
|
||||
|
||||
testableClasses.forEach(function(viewClass, index, viewClasses) {
|
||||
describe('when view is basicDay', function() {
|
||||
beforeEach(function() {
|
||||
settings.defaultView = 'basicDay';
|
||||
});
|
||||
|
||||
describe('when lang is default', function() {
|
||||
beforeEach(function() {
|
||||
settings.lang = 'en';
|
||||
});
|
||||
|
||||
dayClasses.forEach(function(cls, index, classes) {
|
||||
var weekdays = moment.weekdays();
|
||||
it('should be ' + weekdays[index], function() {
|
||||
settings.now = moment(referenceDate).add(index, 'days');
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-view thead ' + dayClasses[index])).toHaveText(weekdays[index]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$.each(languages, function(index, language) {
|
||||
describe('when lang is ' + language, function() {
|
||||
beforeEach(function() {
|
||||
moment.lang(language);
|
||||
});
|
||||
|
||||
dayClasses.forEach(function(cls, index, classes) {
|
||||
it('should be the translation for ' + moment.weekdays()[index], function() {
|
||||
settings.lang = language;
|
||||
settings.now = moment(referenceDate).add(index, 'days');
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-view thead ' + dayClasses[index])).toHaveText(moment.weekdays()[index]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when daynames are specified', function() {
|
||||
var weekdays = [
|
||||
'Hovjaj',
|
||||
'maSjaj',
|
||||
'veSjaj',
|
||||
'mechjaj',
|
||||
'jevjaj',
|
||||
'parmaqjaj',
|
||||
'HoSjaj'
|
||||
];
|
||||
|
||||
dayClasses.forEach(function(cls, idx, classes) {
|
||||
it('should be ' + weekdays[idx], function() {
|
||||
settings.dayNames = [].slice.call(weekdays); // copy. in case there is a mutation
|
||||
settings.now = moment(referenceDate).add(idx, 'days');
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
expect($('.fc-view thead ' + cls)).toHaveText(weekdays[idx]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,78 +0,0 @@
|
||||
describe('short day names', function() {
|
||||
var settings = {};
|
||||
var testableClasses = [
|
||||
'month',
|
||||
'agendaWeek',
|
||||
'basicWeek'
|
||||
];
|
||||
var dayClasses = [
|
||||
'.fc-sun',
|
||||
'.fc-mon',
|
||||
'.fc-tue',
|
||||
'.fc-wed',
|
||||
'.fc-thu',
|
||||
'.fc-fri',
|
||||
'.fc-sat'
|
||||
];
|
||||
var languages = [ 'es', 'fr', 'de', 'zh-cn', 'es' ];
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
settings = { };
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
moment.lang('en'); // reset moment's global language
|
||||
});
|
||||
|
||||
testableClasses.forEach(function(viewClass, index, viewClasses) {
|
||||
describe('when view is ' + viewClass, function() {
|
||||
beforeEach(function() {
|
||||
settings.defaultView = viewClass;
|
||||
});
|
||||
|
||||
describe('when lang is default', function() {
|
||||
it('should be in English', function() {
|
||||
moment.lang('en');
|
||||
$('#cal').fullCalendar(settings);
|
||||
var weekdays = moment.weekdaysShort();
|
||||
|
||||
dayClasses.forEach(function(cls, index, classes) {
|
||||
expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when lang is not default', function() {
|
||||
languages.forEach(function(language, index, languages) {
|
||||
it('should be in the selected language', function() {
|
||||
settings.lang = language;
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
moment.lang(language);
|
||||
var dow = moment.langData(language)._week.dow;
|
||||
var weekdays = moment.weekdaysShort();
|
||||
|
||||
dayClasses.forEach(function(cls, index, classes) {
|
||||
expect($('.fc-view thead ' + cls)[0]).toContainText(weekdays[index]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when specified', function() {
|
||||
it('should contain the specified names in the given order', function() {
|
||||
var days = [
|
||||
'Hov.', 'maS.', 'veS.', 'mech.', 'parmaq.', 'HoS.'
|
||||
];
|
||||
settings.dayNamesShort = days;
|
||||
$('#cal').fullCalendar(settings);
|
||||
|
||||
dayClasses.forEach(function(cls, index, classes) {
|
||||
expect($('.fc-view thead ' + cls)[0]).toContainText(days[index]);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,86 +0,0 @@
|
||||
|
||||
describe('dayRender', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
it('is triggered upon initialization of a view, with correct parameters', function() {
|
||||
var options = {
|
||||
defaultView: 'month',
|
||||
weekMode: 'fixed',
|
||||
defaultDate: '2014-05-01',
|
||||
dayRender: function(date, cell) {
|
||||
expect(moment.isMoment(date)).toEqual(true);
|
||||
expect(date.hasTime()).toEqual(false);
|
||||
expect(date.format()).toEqual(cell.data('date'));
|
||||
expect(cell).toBeInDOM();
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(options, 'dayRender').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(options.dayRender.calls.count()).toEqual(42);
|
||||
});
|
||||
|
||||
it('is called when view is changed', function() {
|
||||
var options = {
|
||||
defaultView: 'month',
|
||||
weekMode: 'fixed',
|
||||
defaultDate: '2014-05-01',
|
||||
dayRender: function(date, cell) { }
|
||||
};
|
||||
|
||||
spyOn(options, 'dayRender').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
options.dayRender.calls.reset();
|
||||
$('#cal').fullCalendar('changeView', 'basicWeek');
|
||||
expect(options.dayRender.calls.count()).toEqual(7);
|
||||
});
|
||||
|
||||
// called if the date is navigated to a different visible range
|
||||
it('is called when view is changed', function() {
|
||||
var options = {
|
||||
defaultView: 'basicWeek',
|
||||
defaultDate: '2014-05-01',
|
||||
dayRender: function(date, cell) { }
|
||||
};
|
||||
|
||||
spyOn(options, 'dayRender').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
options.dayRender.calls.reset();
|
||||
$('#cal').fullCalendar('gotoDate', '2014-05-04'); // a day in the next week
|
||||
expect(options.dayRender.calls.count()).toEqual(7);
|
||||
});
|
||||
|
||||
it('won\'t be called when date is navigated but remains in the current visible range', function() {
|
||||
var options = {
|
||||
defaultView: 'basicWeek',
|
||||
defaultDate: '2014-05-01',
|
||||
dayRender: function(date, cell) { }
|
||||
};
|
||||
|
||||
spyOn(options, 'dayRender').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
options.dayRender.calls.reset();
|
||||
$('#cal').fullCalendar('gotoDate', '2014-05-02'); // a day in the same week
|
||||
expect(options.dayRender.calls.count()).toEqual(0);
|
||||
});
|
||||
|
||||
it('allows you to modify the element', function() {
|
||||
var options = {
|
||||
defaultView: 'month',
|
||||
weekMode: 'fixed',
|
||||
defaultDate: '2014-05-01',
|
||||
dayRender: function(date, cell) {
|
||||
if (date.isSame('2014-05-01')) {
|
||||
cell.addClass('mycustomclass');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(options);
|
||||
expect($('#cal td[data-date="2014-05-01"]')).toHaveClass('mycustomclass');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,87 +0,0 @@
|
||||
describe('defaultAllDayEventDuration', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
|
||||
options = {
|
||||
defaultDate: '2014-05-01',
|
||||
defaultView: 'month'
|
||||
};
|
||||
});
|
||||
|
||||
describe('when forceEventDuration is on', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.forceEventDuration = true;
|
||||
});
|
||||
|
||||
it('correctly calculates an unspecified end when using a Duration object input', function() {
|
||||
options.defaultAllDayEventDuration = { days: 2 };
|
||||
options.events = [
|
||||
{
|
||||
allDay: true,
|
||||
start: '2014-05-05'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var event = $('#cal').fullCalendar('clientEvents')[0];
|
||||
expect(event.end).toEqualMoment('2014-05-07');
|
||||
});
|
||||
|
||||
it('correctly calculates an unspecified end when using a string Duration input', function() {
|
||||
options.defaultAllDayEventDuration = '3.00:00:00';
|
||||
options.events = [
|
||||
{
|
||||
allDay: true,
|
||||
start: '2014-05-05'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var event = $('#cal').fullCalendar('clientEvents')[0];
|
||||
expect(event.end).toEqualMoment('2014-05-08');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when forceEventDuration is off', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.forceEventDuration = false;
|
||||
});
|
||||
|
||||
[ 'basicWeek', 'agendaWeek' ].forEach(function(viewName) { // because they render all-day events in similar ways
|
||||
describe('with ' + viewName + ' view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = viewName;
|
||||
});
|
||||
it('renders an all-day event with no `end` to appear to have the default duration', function(done) {
|
||||
options.defaultAllDayEventDuration = { days: 2 };
|
||||
options.events = [
|
||||
{
|
||||
// a control. so we know how wide it should be
|
||||
title: 'control event',
|
||||
allDay: true,
|
||||
start: '2014-04-28',
|
||||
end: '2014-04-30'
|
||||
},
|
||||
{
|
||||
// one day after the control. no specified end
|
||||
title: 'test event',
|
||||
allDay: true,
|
||||
start: '2014-04-28'
|
||||
}
|
||||
];
|
||||
options.eventAfterAllRender = function() {
|
||||
var eventElms = $('#cal .fc-event');
|
||||
var width0 = eventElms.eq(0).outerWidth();
|
||||
var width1 = eventElms.eq(1).outerWidth();
|
||||
expect(width0).toEqual(width1);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,117 +0,0 @@
|
||||
describe('defaultTimedEventDuration', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
|
||||
options = {
|
||||
defaultDate: '2014-05-01',
|
||||
defaultView: 'month'
|
||||
};
|
||||
});
|
||||
|
||||
describe('when forceEventDuration is on', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.forceEventDuration = true;
|
||||
});
|
||||
|
||||
it('correctly calculates an unspecified end when using a Duration object input', function() {
|
||||
options.defaultTimedEventDuration = { hours: 2, minutes: 30 };
|
||||
options.events = [
|
||||
{
|
||||
allDay: false,
|
||||
start: '2014-05-05T04:00:00'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var event = $('#cal').fullCalendar('clientEvents')[0];
|
||||
expect(event.end).toEqualMoment('2014-05-05T06:30:00');
|
||||
});
|
||||
|
||||
it('correctly calculates an unspecified end when using a string Duration input', function() {
|
||||
options.defaultTimedEventDuration = '03:15:00';
|
||||
options.events = [
|
||||
{
|
||||
allDay: false,
|
||||
start: '2014-05-05T04:00:00'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var event = $('#cal').fullCalendar('clientEvents')[0];
|
||||
expect(event.end).toEqualMoment('2014-05-05T07:15:00');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when forceEventDuration is off', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.forceEventDuration = false;
|
||||
});
|
||||
|
||||
describe('with agendaWeek view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'agendaWeek';
|
||||
});
|
||||
it('renders a timed event with no `end` to appear to have the default duration', function(done) {
|
||||
options.defaultTimedEventDuration = '01:15:00';
|
||||
options.events = [
|
||||
{
|
||||
// a control. so we know how tall it should be
|
||||
title: 'control event',
|
||||
allDay: false,
|
||||
start: '2014-05-01T04:00:00',
|
||||
end: '2014-05-01T05:15:00'
|
||||
},
|
||||
{
|
||||
// one day after the control. no specified end
|
||||
title: 'test event',
|
||||
allDay: false,
|
||||
start: '2014-05-02T04:00:00'
|
||||
}
|
||||
];
|
||||
options.eventAfterAllRender = function() {
|
||||
var eventElms = $('#cal .fc-event');
|
||||
var height0 = eventElms.eq(0).outerHeight();
|
||||
var height1 = eventElms.eq(1).outerHeight();
|
||||
expect(height0).toEqual(height1);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with basicWeek view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'basicWeek';
|
||||
});
|
||||
it('renders a timed event with no `end` to appear to have the default duration', function(done) {
|
||||
options.defaultTimedEventDuration = { days: 2 };
|
||||
options.events = [
|
||||
{
|
||||
// a control. so we know how wide it should be
|
||||
title: 'control event',
|
||||
allDay: false,
|
||||
start: '2014-04-28T04:00:00',
|
||||
end: '2014-04-30T00:00:00'
|
||||
},
|
||||
{
|
||||
// one day after the control. no specified end
|
||||
title: 'test event',
|
||||
allDay: false,
|
||||
start: '2014-04-28T04:00:00'
|
||||
}
|
||||
];
|
||||
options.eventAfterAllRender = function() {
|
||||
var eventElms = $('#cal .fc-event');
|
||||
var width0 = eventElms.eq(0).outerWidth();
|
||||
var width1 = eventElms.eq(1).outerWidth();
|
||||
expect(width0).toEqual(width1);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,32 +0,0 @@
|
||||
|
||||
// can't do event dragging yet.
|
||||
// need to work out how fullCalendar is intercepting events.
|
||||
/*
|
||||
xdescribe('when event is dragged from one cell to another', function() {
|
||||
it('should move to the new cell', function() {
|
||||
var eventName = 'xyzAllDayEvent';
|
||||
$('#calendar').fullCalendar({
|
||||
editable: true
|
||||
});
|
||||
$('#calendar').fullCalendar('addEventSource', {
|
||||
events: [
|
||||
{
|
||||
title: eventName,
|
||||
start: new Date()
|
||||
}
|
||||
]
|
||||
});
|
||||
var el = $('div .fc-event');
|
||||
var offsetBefore = el.offset();
|
||||
dump(offsetBefore);
|
||||
var options = {
|
||||
dx: 200,
|
||||
dy: 0,
|
||||
moves: 10,
|
||||
handle: 'corner'
|
||||
};
|
||||
el.simulate('drag', options);
|
||||
dump(el.offset());
|
||||
});
|
||||
});
|
||||
*/
|
||||
@@ -1,72 +0,0 @@
|
||||
describe('event feed params', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
|
||||
options = {
|
||||
defaultDate: '2014-05-01',
|
||||
defaultView: 'month'
|
||||
};
|
||||
|
||||
$.mockjax({
|
||||
url: '*',
|
||||
contentType: 'text/json',
|
||||
responseText: [
|
||||
{
|
||||
title: 'my event',
|
||||
start: '2014-05-21'
|
||||
}
|
||||
]
|
||||
});
|
||||
$.mockjaxSettings.log = function() { }; // don't console.log
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$.mockjaxClear();
|
||||
});
|
||||
|
||||
it('utilizes custom startParam, endParam, and timezoneParam names', function() {
|
||||
options.events = 'my-feed.php';
|
||||
options.timezone = 'America/Los_Angeles';
|
||||
options.startParam = 'mystart';
|
||||
options.endParam = 'myend';
|
||||
options.timezoneParam = 'currtz';
|
||||
$('#cal').fullCalendar(options);
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toBeUndefined();
|
||||
expect(request.data.end).toBeUndefined();
|
||||
expect(request.data.timezone).toBeUndefined();
|
||||
expect(request.data.mystart).toEqual('2014-04-27');
|
||||
expect(request.data.myend).toEqual('2014-06-08');
|
||||
expect(request.data.currtz).toEqual('America/Los_Angeles');
|
||||
});
|
||||
|
||||
it('utilizes event-source-specific startParam, endParam, and timezoneParam names', function() {
|
||||
options.timezone = 'America/Los_Angeles';
|
||||
options.startParam = 'mystart';
|
||||
options.endParam = 'myend';
|
||||
options.timezoneParam = 'currtz';
|
||||
options.eventSources = [
|
||||
{
|
||||
url: 'my-feed.php',
|
||||
startParam: 'feedstart',
|
||||
endParam: 'feedend',
|
||||
timezoneParam: 'feedctz'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toBeUndefined();
|
||||
expect(request.data.end).toBeUndefined();
|
||||
expect(request.data.timezone).toBeUndefined();
|
||||
expect(request.data.mystart).toBeUndefined();
|
||||
expect(request.data.myend).toBeUndefined();
|
||||
expect(request.data.currtz).toBeUndefined();
|
||||
expect(request.data.feedstart).toEqual('2014-04-27');
|
||||
expect(request.data.feedend).toEqual('2014-06-08');
|
||||
expect(request.data.feedctz).toEqual('America/Los_Angeles');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,109 +0,0 @@
|
||||
describe('event object creation', function() {
|
||||
|
||||
/*
|
||||
|
||||
NOTE: Where possible, if there is a specific option that affects event object creation
|
||||
behavior, write your tests in the individual file for that option, instead of here.
|
||||
Examples of this:
|
||||
allDayDefault (tests allDay guessing behavior too)
|
||||
eventDataTransform
|
||||
forceEventDuration
|
||||
|
||||
*/
|
||||
|
||||
var event;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
event = null;
|
||||
});
|
||||
|
||||
function init(singleEventData) {
|
||||
$('#cal').fullCalendar({
|
||||
events: [ singleEventData ]
|
||||
});
|
||||
event = $('#cal').fullCalendar('clientEvents')[0];
|
||||
}
|
||||
|
||||
it('accepts `date` property as alias for `start`', function() {
|
||||
init({
|
||||
date: '2014-05-05'
|
||||
});
|
||||
expect(moment.isMoment(event.start)).toEqual(true);
|
||||
expect(event.start).toEqualMoment('2014-05-05');
|
||||
});
|
||||
|
||||
it('doesn\'t produce an event when an invalid start', function() {
|
||||
init({
|
||||
start: new Date('asdf') // we use Date constructor to avoid annoying momentjs warning
|
||||
});
|
||||
expect(event).toBeUndefined();
|
||||
});
|
||||
|
||||
it('doesn\'t produce an event when an invalid end', function() {
|
||||
init({
|
||||
end: new Date('asdf') // we use Date constructor to avoid annoying momentjs warning
|
||||
});
|
||||
expect(event).toBeUndefined();
|
||||
});
|
||||
|
||||
it('strips times of dates when event is all-day', function() {
|
||||
init({
|
||||
start: '2014-05-01T01:00:00-12:00',
|
||||
end: '2014-05-02T01:00:00+12:00',
|
||||
allDay: true
|
||||
});
|
||||
expect(event.start.hasTime()).toEqual(false);
|
||||
expect(event.start).toEqualMoment('2014-05-01');
|
||||
expect(event.end.hasTime()).toEqual(false);
|
||||
expect(event.end).toEqualMoment('2014-05-02');
|
||||
});
|
||||
|
||||
it('gives 00:00 times to ambiguously-timed dates when event is timed', function() {
|
||||
init({
|
||||
start: '2014-05-01',
|
||||
end: '2014-05-03',
|
||||
allDay: false
|
||||
});
|
||||
expect(event.start.hasTime()).toEqual(true);
|
||||
expect(event.start).toEqualMoment('2014-05-01T00:00:00');
|
||||
expect(event.end.hasTime()).toEqual(true);
|
||||
expect(event.end).toEqualMoment('2014-05-03T00:00:00');
|
||||
});
|
||||
|
||||
it('sets the source', function() {
|
||||
init({
|
||||
start: '2014-05-01'
|
||||
});
|
||||
expect(typeof event.source).toEqual('object');
|
||||
});
|
||||
|
||||
it('accepts an array `className`', function() {
|
||||
init({
|
||||
start: '2014-05-01',
|
||||
className: [ 'class1', 'class2' ]
|
||||
});
|
||||
expect($.isArray(event.className)).toEqual(true);
|
||||
expect(event.className).toEqual([ 'class1', 'class2' ]);
|
||||
});
|
||||
|
||||
it('accepts a string `className`', function() {
|
||||
init({
|
||||
start: '2014-05-01',
|
||||
className: 'class1 class2'
|
||||
});
|
||||
expect($.isArray(event.className)).toEqual(true);
|
||||
expect(event.className).toEqual([ 'class1', 'class2' ]);
|
||||
});
|
||||
|
||||
it('copies over custom properties', function() {
|
||||
init({
|
||||
start: '2014-05-01',
|
||||
prop1: 'prop1val',
|
||||
prop2: [ 'a', 'b' ]
|
||||
});
|
||||
expect(event.prop1).toEqual('prop1val');
|
||||
expect(event.prop2).toEqual([ 'a', 'b' ]);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,57 +0,0 @@
|
||||
|
||||
describe('events as an array', function() {
|
||||
|
||||
var options;
|
||||
var eventArray;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultView: 'month',
|
||||
defaultDate: '2014-05-01'
|
||||
};
|
||||
eventArray = [
|
||||
{
|
||||
title: 'my event',
|
||||
start: '2014-05-21'
|
||||
}
|
||||
];
|
||||
});
|
||||
|
||||
it('accepts an event using basic form', function(done) {
|
||||
options.events = eventArray;
|
||||
options.eventRender = function(eventObj, eventElm) {
|
||||
expect(eventObj.title).toEqual('my event');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('accepts an event using extended form', function(done) {
|
||||
options.eventSources = [
|
||||
{
|
||||
className: 'customeventclass',
|
||||
events: eventArray
|
||||
}
|
||||
];
|
||||
options.eventRender = function(eventObj, eventElm) {
|
||||
expect(eventObj.title).toEqual('my event');
|
||||
expect(eventElm).toHaveClass('customeventclass');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('doesn\'t mutate the original array', function(done) {
|
||||
var origArray = eventArray;
|
||||
var origEvent = eventArray[0];
|
||||
options.events = eventArray;
|
||||
options.eventRender = function(eventObj, eventElm) {
|
||||
expect(origArray).toEqual(eventArray);
|
||||
expect(origEvent).toEqual(eventArray[0]);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,134 +0,0 @@
|
||||
|
||||
describe('events as a function', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultView: 'month',
|
||||
defaultDate: '2014-05-01'
|
||||
};
|
||||
});
|
||||
|
||||
it('requests correctly when no timezone', function(done) {
|
||||
options.events = function(start, end, timezone, callback) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(start.hasZone()).toEqual(false);
|
||||
expect(start.format()).toEqual('2014-04-27');
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(end.hasZone()).toEqual(false);
|
||||
expect(end.format()).toEqual('2014-06-08');
|
||||
expect(timezone).toEqual(false);
|
||||
expect(typeof callback).toEqual('function');
|
||||
callback([]);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('requests correctly when local timezone', function(done) {
|
||||
options.timezone = 'local';
|
||||
options.events = function(start, end, timezone, callback) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(start.hasZone()).toEqual(false);
|
||||
expect(start.format()).toEqual('2014-04-27');
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(end.hasZone()).toEqual(false);
|
||||
expect(end.format()).toEqual('2014-06-08');
|
||||
expect(timezone).toEqual('local');
|
||||
expect(typeof callback).toEqual('function');
|
||||
callback([]);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('requests correctly when UTC timezone', function(done) {
|
||||
options.timezone = 'UTC';
|
||||
options.events = function(start, end, timezone, callback) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(start.hasZone()).toEqual(false);
|
||||
expect(start.format()).toEqual('2014-04-27');
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(end.hasZone()).toEqual(false);
|
||||
expect(end.format()).toEqual('2014-06-08');
|
||||
expect(timezone).toEqual('UTC');
|
||||
expect(typeof callback).toEqual('function');
|
||||
callback([]);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('requests correctly when custom timezone', function(done) {
|
||||
options.timezone = 'America/Chicago';
|
||||
options.events = function(start, end, timezone, callback) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(start.hasZone()).toEqual(false);
|
||||
expect(start.format()).toEqual('2014-04-27');
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(end.hasZone()).toEqual(false);
|
||||
expect(end.format()).toEqual('2014-06-08');
|
||||
expect(timezone).toEqual('America/Chicago');
|
||||
expect(typeof callback).toEqual('function');
|
||||
callback([]);
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('requests correctly with event source extended form', function(done) {
|
||||
var eventSource = {
|
||||
className: 'customeventclass',
|
||||
events: function(start, end, timezone, callback) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(start.hasZone()).toEqual(false);
|
||||
expect(start.format()).toEqual('2014-04-27');
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(end.hasZone()).toEqual(false);
|
||||
expect(end.format()).toEqual('2014-06-08');
|
||||
expect(timezone).toEqual(false);
|
||||
expect(typeof callback).toEqual('function');
|
||||
callback([
|
||||
{
|
||||
title: 'event1',
|
||||
start: '2014-05-10'
|
||||
}
|
||||
]);
|
||||
}
|
||||
};
|
||||
spyOn(eventSource, 'events').and.callThrough();
|
||||
options.eventSources = [ eventSource ];
|
||||
options.eventRender = function(eventObj, eventElm) {
|
||||
expect(eventSource.events.calls.count()).toEqual(1);
|
||||
expect(eventElm).toHaveClass('customeventclass');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('requests the correct dates when days at the start/end of the month are hidden', function(done) {
|
||||
options.currentView = 'month';
|
||||
options.defaultDate = '2013-06-01'; // June 2013 has first day as Saturday, and last as Sunday!
|
||||
options.weekends = false;
|
||||
options.weekMode = 'variable';
|
||||
options.events = function(start, end, timezone, callback) {
|
||||
expect(start).toEqualMoment('2013-06-03');
|
||||
expect(end).toEqualMoment('2013-06-29');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,117 +0,0 @@
|
||||
|
||||
describe('Google Calendar plugin', function() {
|
||||
|
||||
var options;
|
||||
var currentRequest;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
|
||||
options = {
|
||||
defaultView: 'month',
|
||||
defaultDate: '2014-05-01',
|
||||
events: 'http://www.google.com/calendar/feeds/notarealfeed/public/basic'
|
||||
};
|
||||
|
||||
// workaround. wanted to use mockedAjaxCalls(), but JSONP requests get mangled later on
|
||||
currentRequest = null;
|
||||
$.mockjaxSettings.log = function(mockHandler, request) {
|
||||
currentRequest = currentRequest || $.extend({}, request); // copy
|
||||
};
|
||||
|
||||
// fake the JSONP call (which actually calls to /full)
|
||||
$.mockjax({
|
||||
url: 'http://www.google.com/calendar/feeds/notarealfeed/public/*',
|
||||
responseText: JSON.parse(
|
||||
'{"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch"' +
|
||||
':"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gCal":"http://schemas.google.com/gCal/2005","xmlns' +
|
||||
'$gd":"http://schemas.google.com/g/2005","id":{"$t":"http://www.google.com/calendar/feeds/usa__en%40h' +
|
||||
'oliday.calendar.google.com/public/full"},"updated":{"$t":"2014-05-22T13:00:40.000Z"},"category":[{"s' +
|
||||
'cheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.com/g/2005#event"}],"ti' +
|
||||
'tle":{"$t":"Holidays in United States","type":"text"},"subtitle":{"$t":"Holidays and Observances in ' +
|
||||
'United States","type":"text"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.googl' +
|
||||
'e.com/calendar/embed?src=usa__en%40holiday.calendar.google.com"},{"rel":"http://schemas.google.com/g' +
|
||||
'/2005#feed","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/usa__en%40hol' +
|
||||
'iday.calendar.google.com/public/full"},{"rel":"http://schemas.google.com/g/2005#batch","type":"appli' +
|
||||
'cation/atom+xml","href":"http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/' +
|
||||
'public/full/batch"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calend' +
|
||||
'ar/feeds/usa__en%40holiday.calendar.google.com/public/full?alt=json-in-script&max-results=9999&start' +
|
||||
'-min=2014-04-27T00%3A00%3A00Z&singleevents=true&start-max=2014-06-08T00%3A00%3A00Z"}],"author":[{"na' +
|
||||
'me":{"$t":"Holidays in United States"}}],"generator":{"$t":"Google Calendar","version":"1.0","uri":"' +
|
||||
'http://www.google.com/calendar"},"openSearch$totalResults":{"$t":2},"openSearch$startIndex":{"$t":1}' +
|
||||
',"openSearch$itemsPerPage":{"$t":9999},"gCal$timezone":{"value":"UTC"},"gCal$timesCleaned":{"value":' +
|
||||
'0},"entry":[{"id":{"$t":"http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/' +
|
||||
'public/full/20140511_60o30dr560o30e1g60o30dr4ck"},"published":{"$t":"2014-05-22T13:00:40.000Z"},"upd' +
|
||||
'ated":{"$t":"2014-05-22T13:00:40.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind' +
|
||||
'","term":"http://schemas.google.com/g/2005#event"}],"title":{"$t":"Mothers Day","type":"text"},"cont' +
|
||||
'ent":{"$t":"","type":"text"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.google' +
|
||||
'.com/calendar/event?eid=MjAxNDA1MTFfNjBvMzBkcjU2MG8zMGUxZzYwbzMwZHI0Y2sgdXNhX19lbkBo","title":"alter' +
|
||||
'nate"},{"rel":"self","type":"application/atom+xml","href":"http://www.google.com/calendar/feeds/usa_' +
|
||||
'_en%40holiday.calendar.google.com/public/full/20140511_60o30dr560o30e1g60o30dr4ck"}],"author":[{"nam' +
|
||||
'e":{"$t":"Holidays in United States"}}],"gd$comments":{"gd$feedLink":{"href":"http://www.google.com/' +
|
||||
'calendar/feeds/usa__en%40holiday.calendar.google.com/public/full/20140511_60o30dr560o30e1g60o30dr4ck' +
|
||||
'/comments"}},"gd$eventStatus":{"value":"http://schemas.google.com/g/2005#event.confirmed"},"gd$where' +
|
||||
'":[{}],"gd$who":[{"email":"usa__en@holiday.calendar.google.com","rel":"http://schemas.google.com/g/2' +
|
||||
'005#event.organizer","valueString":"Holidays in United States"}],"gd$when":[{"endTime":"2014-05-12",' +
|
||||
'"startTime":"2014-05-11"}],"gd$transparency":{"value":"http://schemas.google.com/g/2005#event.transp' +
|
||||
'arent"},"gCal$anyoneCanAddSelf":{"value":"false"},"gCal$guestsCanInviteOthers":{"value":"true"},"gCa' +
|
||||
'l$guestsCanModify":{"value":"false"},"gCal$guestsCanSeeGuests":{"value":"true"},"gCal$sequence":{"va' +
|
||||
'lue":0},"gCal$uid":{"value":"20140511_60o30dr560o30e1g60o30dr4ck@google.com"}},{"id":{"$t":"http://w' +
|
||||
'ww.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/full/20140526_60o30dr56co3' +
|
||||
'0e1g60o30dr4ck"},"published":{"$t":"2014-05-22T13:00:40.000Z"},"updated":{"$t":"2014-05-22T13:00:40.' +
|
||||
'000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://schemas.google.c' +
|
||||
'om/g/2005#event"}],"title":{"$t":"Memorial Day","type":"text"},"content":{"$t":"","type":"text"},"li' +
|
||||
'nk":[{"rel":"alternate","type":"text/html","href":"http://www.google.com/calendar/event?eid=MjAxNDA1' +
|
||||
'MjZfNjBvMzBkcjU2Y28zMGUxZzYwbzMwZHI0Y2sgdXNhX19lbkBo","title":"alternate"},{"rel":"self","type":"app' +
|
||||
'lication/atom+xml","href":"http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.co' +
|
||||
'm/public/full/20140526_60o30dr56co30e1g60o30dr4ck"}],"author":[{"name":{"$t":"Holidays in United Sta' +
|
||||
'tes"}}],"gd$comments":{"gd$feedLink":{"href":"http://www.google.com/calendar/feeds/usa__en%40holiday' +
|
||||
'.calendar.google.com/public/full/20140526_60o30dr56co30e1g60o30dr4ck/comments"}},"gd$eventStatus":{"' +
|
||||
'value":"http://schemas.google.com/g/2005#event.confirmed"},"gd$where":[{}],"gd$who":[{"email":"usa__' +
|
||||
'en@holiday.calendar.google.com","rel":"http://schemas.google.com/g/2005#event.organizer","valueStrin' +
|
||||
'g":"Holidays in United States"}],"gd$when":[{"endTime":"2014-05-27","startTime":"2014-05-26"}],"gd$t' +
|
||||
'ransparency":{"value":"http://schemas.google.com/g/2005#event.transparent"},"gCal$anyoneCanAddSelf":' +
|
||||
'{"value":"false"},"gCal$guestsCanInviteOthers":{"value":"true"},"gCal$guestsCanModify":{"value":"fal' +
|
||||
'se"},"gCal$guestsCanSeeGuests":{"value":"true"},"gCal$sequence":{"value":0},"gCal$uid":{"value":"201' +
|
||||
'40526_60o30dr56co30e1g60o30dr4ck@google.com"}}]}}'
|
||||
)
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$.mockjaxClear();
|
||||
$.mockjaxSettings.log = function() { };
|
||||
});
|
||||
|
||||
it('sends request correctly when no timezone', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(currentRequest.data['start-min']).toEqual('2014-04-27');
|
||||
expect(currentRequest.data['start-max']).toEqual('2014-06-08');
|
||||
expect(currentRequest.data.ctz).toBeUndefined();
|
||||
});
|
||||
|
||||
it('sends request correctly when local timezone', function() {
|
||||
options.timezone = 'local';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(currentRequest.data['start-min']).toEqual('2014-04-27');
|
||||
expect(currentRequest.data['start-max']).toEqual('2014-06-08');
|
||||
expect(currentRequest.data.ctz).toBeUndefined();
|
||||
});
|
||||
|
||||
it('sends request correctly when UTC timezone', function() {
|
||||
options.timezone = 'UTC';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(currentRequest.data['start-min']).toEqual('2014-04-27');
|
||||
expect(currentRequest.data['start-max']).toEqual('2014-06-08');
|
||||
expect(currentRequest.data.ctz).toEqual('UTC');
|
||||
});
|
||||
|
||||
it('sends request correctly when custom timezone', function() {
|
||||
options.timezone = 'America/Chicago';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(currentRequest.data['start-min']).toEqual('2014-04-27');
|
||||
expect(currentRequest.data['start-max']).toEqual('2014-06-08');
|
||||
expect(currentRequest.data.ctz).toEqual('America/Chicago');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,122 +0,0 @@
|
||||
|
||||
describe('events as a json feed', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
|
||||
options = {
|
||||
defaultDate: '2014-05-01',
|
||||
defaultView: 'month'
|
||||
};
|
||||
|
||||
$.mockjax({
|
||||
url: '*',
|
||||
contentType: 'text/json',
|
||||
responseText: [
|
||||
{
|
||||
title: 'my event',
|
||||
start: '2014-05-21'
|
||||
}
|
||||
]
|
||||
});
|
||||
$.mockjaxSettings.log = function() { }; // don't console.log
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$.mockjaxClear();
|
||||
});
|
||||
|
||||
it('requests correctly when no timezone', function() {
|
||||
options.events = 'my-feed.php';
|
||||
$('#cal').fullCalendar(options);
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toEqual('2014-04-27');
|
||||
expect(request.data.end).toEqual('2014-06-08');
|
||||
expect(request.data.timezone).toBeUndefined();
|
||||
});
|
||||
|
||||
it('requests correctly when local timezone', function() {
|
||||
options.events = 'my-feed.php';
|
||||
options.timezone = 'local';
|
||||
$('#cal').fullCalendar(options);
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toEqual('2014-04-27');
|
||||
expect(request.data.end).toEqual('2014-06-08');
|
||||
expect(request.data.timezone).toBeUndefined();
|
||||
});
|
||||
|
||||
it('requests correctly when UTC timezone', function() {
|
||||
options.events = 'my-feed.php';
|
||||
options.timezone = 'UTC';
|
||||
$('#cal').fullCalendar(options);
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toEqual('2014-04-27');
|
||||
expect(request.data.end).toEqual('2014-06-08');
|
||||
expect(request.data.timezone).toEqual('UTC');
|
||||
});
|
||||
|
||||
it('requests correctly when custom timezone', function() {
|
||||
options.events = 'my-feed.php';
|
||||
options.timezone = 'America/Chicago';
|
||||
$('#cal').fullCalendar(options);
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toEqual('2014-04-27');
|
||||
expect(request.data.end).toEqual('2014-06-08');
|
||||
expect(request.data.timezone).toEqual('America/Chicago');
|
||||
});
|
||||
|
||||
it('requests correctly with event source extended form', function(done) {
|
||||
var eventSource = {
|
||||
url: 'my-feed.php',
|
||||
className: 'customeventclass'
|
||||
};
|
||||
options.eventSources = [ eventSource ];
|
||||
options.timezone = 'America/Chicago';
|
||||
options.eventRender = function(eventObj, eventElm) {
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.start).toEqual('2014-04-27');
|
||||
expect(request.data.end).toEqual('2014-06-08');
|
||||
expect(request.data.timezone).toEqual('America/Chicago');
|
||||
expect(eventElm).toHaveClass('customeventclass');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('accepts jQuery.ajax params', function(done) {
|
||||
var eventSource = {
|
||||
url: 'my-feed.php',
|
||||
data: {
|
||||
customParam: 'yes'
|
||||
},
|
||||
success: function() {
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.customParam).toMatch('yes');
|
||||
done();
|
||||
}
|
||||
};
|
||||
options.eventSources = [ eventSource ];
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('accepts a dynamic data function', function(done) {
|
||||
var eventSource = {
|
||||
url: 'my-feed.php',
|
||||
data: function() {
|
||||
return {
|
||||
customParam: 'heckyeah'
|
||||
};
|
||||
}
|
||||
};
|
||||
options.eventSources = [ eventSource ];
|
||||
options.eventAfterAllRender = function() {
|
||||
var request = $.mockjax.mockedAjaxCalls()[0];
|
||||
expect(request.data.customParam).toMatch('heckyeah');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,201 +0,0 @@
|
||||
|
||||
describe('First Day', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when using default settings', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar();
|
||||
});
|
||||
it('should make Sunday the first day of the week', function() {
|
||||
var dayFirst = $('.fc-day-header')[0];
|
||||
expect(dayFirst).toHaveClass('fc-sun');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 0', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 0
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Sunday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-sat');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 1', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 1
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Monday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-sun');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 2', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 2
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Tuesday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-mon');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 3', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 3
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Wednesday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-tue');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 4', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 4
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Thursday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-wed');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 5', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 5
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Friday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-thu');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting firstDay to 6', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 6
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should make Saturday the first day of the week', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-fri');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when new firstDay options are set', function() {
|
||||
it('should change the first day of week to Monday', function() {
|
||||
$('#cal').fullCalendar({
|
||||
firstDay: 1
|
||||
});
|
||||
expect($('.fc-day-header')[0]).toHaveClass('fc-mon');
|
||||
});
|
||||
it('shoule change the first day of week to Thursday', function() {
|
||||
$('#cal').fullCalendar({
|
||||
firstDay: 4
|
||||
});
|
||||
expect($('.fc-day-header')[0]).toHaveClass('fc-thu');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when first day is set to Tuesday and isRTL is true', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
firstDay: 2,
|
||||
isRTL: true
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
it('should put days mon, sun, sat ...', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-tue');
|
||||
});
|
||||
});
|
||||
|
||||
it('should have a different default value based on the language', function() {
|
||||
$('#cal').fullCalendar({
|
||||
lang: 'en-gb'
|
||||
});
|
||||
// firstDay will be 1 (Monday) in Great Britain
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-wed');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-fri');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-sat');
|
||||
expect(daysOfWeek[6]).toHaveClass('fc-sun');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,64 +0,0 @@
|
||||
describe('forceEventDuration', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
|
||||
options = {
|
||||
defaultDate: '2014-05-01',
|
||||
defaultView: 'month'
|
||||
};
|
||||
});
|
||||
|
||||
describe('when turned off', function() {
|
||||
beforeEach(function() {
|
||||
options.forceEventDuration = false;
|
||||
});
|
||||
it('allows a null end date for all-day and timed events', function() {
|
||||
options.events = [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-10'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
start: '2014-05-10T14:00:00'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var events = $('#cal').fullCalendar('clientEvents');
|
||||
expect(events[0].end).toBeNull();
|
||||
expect(events[1].end).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when turned on', function() {
|
||||
beforeEach(function() {
|
||||
options.forceEventDuration = true;
|
||||
});
|
||||
it('allows a null end date for all-day and timed events', function() {
|
||||
options.events = [
|
||||
{
|
||||
id: '1',
|
||||
start: '2014-05-10'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
start: '2014-05-10T14:00:00'
|
||||
}
|
||||
];
|
||||
$('#cal').fullCalendar(options);
|
||||
var events = $('#cal').fullCalendar('clientEvents');
|
||||
expect(events[0].id).toEqual('1');
|
||||
expect(moment.isMoment(events[0].end)).toEqual(true);
|
||||
expect(events[1].id).toEqual('2');
|
||||
expect(moment.isMoment(events[1].end)).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
// NOTE: the actual verification of the correct calculation of the end
|
||||
// (using defaultTimedEventDuration and defaultAllDayEventDuration)
|
||||
// is done in those test files.
|
||||
|
||||
});
|
||||
@@ -1,148 +0,0 @@
|
||||
|
||||
describe('formatRange', function() {
|
||||
|
||||
it('doesn\'t do any splitting when dates have different years', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2015-01-01', 'MMMM Do YYYY');
|
||||
expect(s).toEqual('January 1st 2014 - January 1st 2015');
|
||||
});
|
||||
|
||||
it('splits correctly on day when dates have same month', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-05', 'MMMM Do YYYY');
|
||||
expect(s).toEqual('January 1st - 5th 2014');
|
||||
});
|
||||
|
||||
it('splits correctly on day when dates have same month and smaller unit in front', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-05', 'dddd MMMM Do YYYY');
|
||||
expect(s).toEqual('Wednesday January 1st - Sunday January 5th 2014');
|
||||
});
|
||||
|
||||
it('splits correctly on the time when dates have the same day', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T08:00:00', 'MMMM Do YYYY h:mma');
|
||||
expect(s).toEqual('January 1st 2014 6:00am - 8:00am');
|
||||
});
|
||||
|
||||
it('splits correctly on the time when dates have the same day and hour but different am/pm', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T18:00:00', 'MMMM Do YYYY h:mma');
|
||||
expect(s).toEqual('January 1st 2014 6:00am - 6:00pm');
|
||||
});
|
||||
|
||||
it('splits correctly on the time when the dates have the same hour', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T06:30:00', 'MMMM Do YYYY h:mma');
|
||||
expect(s).toEqual('January 1st 2014 6:00am - 6:30am');
|
||||
});
|
||||
|
||||
it('outputs the single date when the dates have the same day and time', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T06:00:00', 'MMMM Do YYYY h:mma');
|
||||
expect(s).toEqual('January 1st 2014 6:00am');
|
||||
});
|
||||
|
||||
it('outputs the single date when the dates have the same day and the format string is vague', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-01', 'MMMM Do YYYY');
|
||||
expect(s).toEqual('January 1st 2014');
|
||||
});
|
||||
|
||||
it('uses a custom separator', function() {
|
||||
var s = $.fullCalendar.formatRange(
|
||||
'2014-01-01T06:00:00',
|
||||
'2014-01-01T06:30:00',
|
||||
'MMMM Do YYYY h:mma',
|
||||
'<...>'
|
||||
);
|
||||
expect(s).toEqual('January 1st 2014 6:00am<...>6:30am');
|
||||
});
|
||||
|
||||
describe('when called with isRTL', function() {
|
||||
|
||||
it('doesn\'t do any splitting when dates have different years', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2015-01-01', 'MMMM Do YYYY', null, true);
|
||||
expect(s).toEqual('January 1st 2015 - January 1st 2014');
|
||||
});
|
||||
|
||||
it('splits correctly on day when dates have same month', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-05', 'MMMM Do YYYY', null, true);
|
||||
expect(s).toEqual('January 5th - 1st 2014');
|
||||
});
|
||||
|
||||
it('splits correctly on day when dates have same month and smaller unit in front', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-05', 'dddd MMMM Do YYYY', null, true);
|
||||
expect(s).toEqual('Sunday January 5th - Wednesday January 1st 2014');
|
||||
});
|
||||
|
||||
it('splits correctly on the time when dates have the same day', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T08:00:00', 'MMMM Do YYYY h:mma', null, true);
|
||||
expect(s).toEqual('January 1st 2014 8:00am - 6:00am');
|
||||
});
|
||||
|
||||
it('splits correctly on the time when dates have the same day and hour but different am/pm', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T18:00:00', 'MMMM Do YYYY h:mma', null, true);
|
||||
expect(s).toEqual('January 1st 2014 6:00pm - 6:00am');
|
||||
});
|
||||
|
||||
it('splits correctly on the time when the dates have the same hour', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T06:30:00', 'MMMM Do YYYY h:mma', null, true);
|
||||
expect(s).toEqual('January 1st 2014 6:30am - 6:00am');
|
||||
});
|
||||
|
||||
it('outputs the single date when the dates have the same day and time', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01T06:00:00', '2014-01-01T06:00:00', 'MMMM Do YYYY h:mma', null, true);
|
||||
expect(s).toEqual('January 1st 2014 6:00am');
|
||||
});
|
||||
|
||||
it('outputs the single date when the dates have the same day and the format string is vague', function() {
|
||||
var s = $.fullCalendar.formatRange('2014-01-01', '2014-01-01', 'MMMM Do YYYY', null, true);
|
||||
expect(s).toEqual('January 1st 2014');
|
||||
});
|
||||
|
||||
it('uses a custom separator', function() {
|
||||
var s = $.fullCalendar.formatRange(
|
||||
'2014-01-01T06:00:00',
|
||||
'2014-01-01T06:30:00',
|
||||
'MMMM Do YYYY h:mma',
|
||||
'<...>',
|
||||
true
|
||||
);
|
||||
expect(s).toEqual('January 1st 2014 6:30am<...>6:00am');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when calendar has isRTL', function() {
|
||||
|
||||
it('splits correctly on day when dates have same month', function() {
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'basicWeek',
|
||||
defaultDate: '2014-05-20',
|
||||
isRTL: true,
|
||||
titleFormat: 'MMMM Do YYYY'
|
||||
});
|
||||
expect($('.fc-toolbar h2')).toHaveText('May 24th - 18th 2014');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when calendar has a customized lang', function() {
|
||||
|
||||
it('uses language and splits correctly on day when dates have same month', function() {
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'basicWeek',
|
||||
defaultDate: '2014-05-20',
|
||||
lang: 'fr',
|
||||
titleFormat: 'dddd MMMM D YYYY'
|
||||
});
|
||||
expect($('.fc-toolbar h2')).toHaveText('lundi mai 19 - dimanche mai 25 2014');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('splits correctly on day when dates have same month, when given real moments', function() {
|
||||
var s = $.fullCalendar.formatRange(
|
||||
moment.utc('2014-01-01'),
|
||||
moment.utc('2015-01-01'),
|
||||
'MMMM Do YYYY'
|
||||
);
|
||||
expect(s).toEqual('January 1st 2014 - January 1st 2015');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,22 +0,0 @@
|
||||
|
||||
describe('handleWindowResize', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
// not true
|
||||
/*
|
||||
xdescribe('When default is used, should fire resize event', function() {
|
||||
it('should fire resize', function() {
|
||||
var resized = 0;
|
||||
$('#cal').fullCalendar({
|
||||
windowResize: function(view) {
|
||||
resized++;
|
||||
}
|
||||
});
|
||||
expect(resized).toEqual(1);
|
||||
});
|
||||
});
|
||||
*/
|
||||
});
|
||||
@@ -1,60 +0,0 @@
|
||||
|
||||
describe('header navigation', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#calendar');
|
||||
var options = {
|
||||
header: {
|
||||
left: 'next,prev,prevYear,nextYear today',
|
||||
center: '',
|
||||
right: 'title'
|
||||
}
|
||||
};
|
||||
$('#calendar').fullCalendar(options);
|
||||
});
|
||||
|
||||
describe('and click next', function() {
|
||||
it('should change view to next month', function() {
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-next-button').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate).toEqualMoment('2010-03-01');
|
||||
});
|
||||
});
|
||||
|
||||
describe('and click prev', function() {
|
||||
it('should change view to prev month', function() {
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-prev-button').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate).toEqualMoment('2010-01-01');
|
||||
});
|
||||
});
|
||||
|
||||
describe('and click prevYear', function() {
|
||||
it('should change view to prev month', function() {
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-prevYear-button').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate).toEqualMoment('2009-02-01');
|
||||
});
|
||||
});
|
||||
|
||||
describe('and click nextYear', function() {
|
||||
it('should change view to prev month', function() {
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-nextYear-button').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate).toEqualMoment('2011-02-01');
|
||||
});
|
||||
});
|
||||
|
||||
describe('and click today', function() {
|
||||
it('should change view to prev month', function() {
|
||||
$('#calendar').fullCalendar('gotoDate', '2010-02-01');
|
||||
$('.fc-today-button').simulate('click');
|
||||
var newDate = $('#calendar').fullCalendar('getDate');
|
||||
expect(newDate).toEqualNow();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,136 +0,0 @@
|
||||
|
||||
describe('header rendering', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#calendar');
|
||||
});
|
||||
|
||||
describe('when using default header options', function() {
|
||||
it('should have title as default on left', function() {
|
||||
$('#calendar').fullCalendar();
|
||||
expect($('#calendar > .fc-toolbar > .fc-left > *')).toBeMatchedBy('h2');
|
||||
});
|
||||
it('should have empty center', function() {
|
||||
$('#calendar').fullCalendar();
|
||||
var center = $('#calendar > .fc-toolbar > .fc-center');
|
||||
expect(center).toBeEmpty();
|
||||
});
|
||||
it('should have right with today|space|left|right', function() {
|
||||
$('#calendar').fullCalendar();
|
||||
var rightChildren = $('#calendar > .fc-toolbar > .fc-right > *');
|
||||
var todayButton = rightChildren.eq(0);
|
||||
var buttonGroup = rightChildren.eq(1);
|
||||
var prevNextButtons = buttonGroup.children();
|
||||
expect(todayButton).toHaveClass('fc-today-button');
|
||||
expect(buttonGroup).toHaveClass('fc-button-group');
|
||||
expect(prevNextButtons.eq(0)).toHaveClass('fc-prev-button');
|
||||
expect(prevNextButtons.eq(1)).toHaveClass('fc-next-button');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when supplying header options', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
header: {
|
||||
left: 'next,prev',
|
||||
center: 'prevYear today nextYear agendaView,dayView',
|
||||
right: 'title'
|
||||
}
|
||||
};
|
||||
$('#calendar').fullCalendar(options);
|
||||
});
|
||||
it('should have title on the right', function() {
|
||||
expect($('#calendar > .fc-toolbar > .fc-right > *')).toBeMatchedBy('h2');
|
||||
});
|
||||
it('should have next|prev on left', function() {
|
||||
var buttonGroup = $('#calendar > .fc-toolbar > .fc-left > *');
|
||||
var prevNextButtons = buttonGroup.children();
|
||||
expect(prevNextButtons.eq(0)).toHaveClass('fc-next-button');
|
||||
expect(prevNextButtons.eq(1)).toHaveClass('fc-prev-button');
|
||||
});
|
||||
it('should have prevYear|space|today|space|nextYear in center', function() {
|
||||
var items = $('#calendar > .fc-toolbar > .fc-center > *');
|
||||
expect(items.eq(0)).toHaveClass('fc-prevYear-button');
|
||||
expect(items.eq(1)).toHaveClass('fc-today-button');
|
||||
expect(items.eq(2)).toHaveClass('fc-nextYear-button');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting header to false', function() {
|
||||
beforeEach(function() {
|
||||
var options = {
|
||||
header: false
|
||||
};
|
||||
$('#calendar').fullCalendar(options);
|
||||
});
|
||||
it('should not have header table', function() {
|
||||
expect($('.fc-toolbar')).not.toBeInDOM();
|
||||
});
|
||||
});
|
||||
|
||||
describe('renders left and right literally', function() {
|
||||
[ true, false ].forEach(function(isRTL) {
|
||||
describe('when isRTL is ' + isRTL, function() {
|
||||
beforeEach(function() {
|
||||
var options = {};
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev',
|
||||
center: 'today',
|
||||
right: 'next'
|
||||
},
|
||||
isRTL: isRTL
|
||||
});
|
||||
});
|
||||
it('should have prev in left', function() {
|
||||
var fcHeaderLeft = $('#calendar .fc-toolbar > .fc-left');
|
||||
expect(fcHeaderLeft).toContainElement('.fc-prev-button');
|
||||
});
|
||||
it('should have today in center', function() {
|
||||
var fcHeaderCenter = $('#calendar .fc-toolbar > .fc-center');
|
||||
expect(fcHeaderCenter).toContainElement('.fc-today-button');
|
||||
});
|
||||
it('should have next in right', function() {
|
||||
var fcHeaderRight = $('#calendar .fc-toolbar > .fc-right');
|
||||
expect(fcHeaderRight).toContainElement('.fc-next-button');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when calendar is within a form', function() {
|
||||
beforeEach(function() {
|
||||
$('#calendar').wrap('<form action="http://google.com/"></form>');
|
||||
});
|
||||
it('should not submit the form when clicking the button', function(done) {
|
||||
var options = {
|
||||
header: {
|
||||
left: 'prev,next',
|
||||
right: 'title'
|
||||
}
|
||||
};
|
||||
var unloadCalled = false;
|
||||
|
||||
function beforeUnloadHandler() {
|
||||
console.log('when calendar is within a form, it submits!!!');
|
||||
unloadCalled = true;
|
||||
cleanup();
|
||||
return 'click stay on this page';
|
||||
}
|
||||
$(window).on('beforeunload', beforeUnloadHandler);
|
||||
|
||||
function cleanup() {
|
||||
$(window).off('beforeunload', beforeUnloadHandler);
|
||||
}
|
||||
|
||||
$('#calendar').fullCalendar(options);
|
||||
$('.fc-next-button').simulate('click');
|
||||
|
||||
setTimeout(function() { // wait to see if handler was called
|
||||
expect(unloadCalled).toBe(false);
|
||||
cleanup();
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,49 +0,0 @@
|
||||
|
||||
describe('height', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when using default height', function() {
|
||||
it('should use default height based on default aspect ratio of 1:35', function() {
|
||||
$('#cal').width(1350);
|
||||
$('#cal').fullCalendar();
|
||||
var height = $('.fc-content').height();
|
||||
expect(height).toEqual(1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting height with the setter', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(673);
|
||||
$('#cal').fullCalendar();
|
||||
$('#cal').fullCalendar('option', 'height', 751);
|
||||
});
|
||||
it('should not change the width of the block level container', function() {
|
||||
var width = $('#cal').width();
|
||||
expect(width).toEqual(673);
|
||||
});
|
||||
it('should set the size of the block level container to the height', function() {
|
||||
var height = $('#cal').height();
|
||||
expect(height).toEqual(751);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting height at instantiation', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').width(673);
|
||||
$('#cal').fullCalendar({
|
||||
height: 751
|
||||
});
|
||||
});
|
||||
it('should not change the width of the block level container', function() {
|
||||
var width = $('#cal').width();
|
||||
expect(width).toEqual(673);
|
||||
});
|
||||
it('should set the size of the block level container to the height', function() {
|
||||
var height = $('#cal').height();
|
||||
expect(height).toEqual(751);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,88 +0,0 @@
|
||||
|
||||
describe('hiddenDays', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when using default', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar();
|
||||
});
|
||||
it('should show 7 days of the week', function() {
|
||||
var daysCount = $('.fc-day-header').length;
|
||||
expect(daysCount).toEqual(7);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting an empty hiddenDays', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
hiddenDays: []
|
||||
});
|
||||
});
|
||||
it('should return 7 days of the week', function() {
|
||||
var daysCount = $('.fc-day-header').length;
|
||||
expect(daysCount).toEqual(7);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting hiddenDays with 1', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
hiddenDays: [ 1 ]
|
||||
});
|
||||
});
|
||||
it('should return 6 days', function() {
|
||||
var daysCount = $('.fc-day-header').length;
|
||||
expect(daysCount).toEqual(6);
|
||||
});
|
||||
it('should return sun,tue,wed..sat days', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[5]).toHaveClass('fc-sat');
|
||||
});
|
||||
it('should expect 7th day to be undefined', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[6]).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting hiddenDays with 3,5', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
hiddenDays: [ 3, 5 ]
|
||||
});
|
||||
});
|
||||
it('should return 6 days', function() {
|
||||
var daysCount = $('.fc-day-header').length;
|
||||
expect(daysCount).toEqual(5);
|
||||
});
|
||||
it('should return s,m,t,t,s ', function() {
|
||||
var daysOfWeek = $('.fc-day-header');
|
||||
expect(daysOfWeek[0]).toHaveClass('fc-sun');
|
||||
expect(daysOfWeek[1]).toHaveClass('fc-mon');
|
||||
expect(daysOfWeek[2]).toHaveClass('fc-tue');
|
||||
expect(daysOfWeek[3]).toHaveClass('fc-thu');
|
||||
expect(daysOfWeek[4]).toHaveClass('fc-sat');
|
||||
});
|
||||
it('should expect wed and fri be undefined', function() {
|
||||
var fri = $('.fc-day-header.fc-fri')[0];
|
||||
var wed = $('.fc-day-header.fc-wed')[0];
|
||||
expect(fri).toBeUndefined();
|
||||
expect(wed).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting all hiddenDays', function() {
|
||||
it('should expect to throw an exception', function() {
|
||||
var options = {
|
||||
hiddenDays: [ 0, 1, 2, 3, 4, 5, 6 ]
|
||||
};
|
||||
expect(function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
}).toThrow('invalid hiddenDays');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
describe('isRTL', function() {
|
||||
|
||||
it('has it\'s default value computed differently based off of the language', function() {
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
lang: 'ar' // Arabic is RTL
|
||||
});
|
||||
var isRTL = $('#cal').fullCalendar('option', 'isRTL');
|
||||
expect(isRTL).toEqual(true);
|
||||
});
|
||||
|
||||
// NOTE: don't put tests related to other options in here!
|
||||
// Put them in the test file for the individual option!
|
||||
|
||||
});
|
||||
@@ -1,53 +0,0 @@
|
||||
|
||||
describe('lang', function() {
|
||||
|
||||
afterEach(function() {
|
||||
moment.lang('en');
|
||||
});
|
||||
|
||||
it('is not affected by global moment lang when unset', function() {
|
||||
moment.lang('fr');
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar();
|
||||
var calendar = $('#cal').fullCalendar('getCalendar');
|
||||
var mom = calendar.moment('2014-05-01');
|
||||
var s = mom.format('dddd MMMM Do YYYY');
|
||||
expect(s).toEqual('Thursday May 1st 2014');
|
||||
});
|
||||
|
||||
it('is not affected by global moment lang when unset', function() {
|
||||
moment.lang('fr');
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
lang: 'es'
|
||||
});
|
||||
var calendar = $('#cal').fullCalendar('getCalendar');
|
||||
var mom = calendar.moment('2014-05-01');
|
||||
var s = mom.format('dddd MMMM Do YYYY');
|
||||
expect(s).toEqual('jueves mayo 1º 2014');
|
||||
});
|
||||
|
||||
it('doesn\'t side-effect the global moment lang when customized', function() {
|
||||
moment.lang('fr');
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
lang: 'es'
|
||||
});
|
||||
var mom = moment.utc('2014-05-01');
|
||||
var s = mom.format('dddd MMMM Do YYYY');
|
||||
expect(s).toEqual('jeudi mai 1er 2014');
|
||||
expect(moment.lang()).toEqual('fr');
|
||||
});
|
||||
|
||||
it('defaults to English when configured to language that isn\'t loaded', function() {
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
lang: 'zz'
|
||||
});
|
||||
var calendar = $('#cal').fullCalendar('getCalendar');
|
||||
var mom = calendar.moment('2014-05-01');
|
||||
var s = mom.format('dddd MMMM Do YYYY');
|
||||
expect(s).toEqual('Thursday May 1st 2014');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,124 +0,0 @@
|
||||
describe('maxTime', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
var numToStringConverter = function(timeIn) {
|
||||
var time = (timeIn % 12) || 12;
|
||||
var amPm = 'am';
|
||||
if ((timeIn % 24) > 11) {
|
||||
amPm = 'pm';
|
||||
}
|
||||
return time + amPm;
|
||||
};
|
||||
|
||||
describe('when using the default settings', function() {
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
it('should start at 12am', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
|
||||
expect(lastSlotText).toEqual('11pm');
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
it('should start at 12am', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
|
||||
expect(lastSlotText).toEqual('11pm');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when using a whole number', function() {
|
||||
|
||||
var hourNumbers = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ];
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should end at ' + hourNumber, function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
maxTime: { hours: hourNumber }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
|
||||
var expected = numToStringConverter(hourNumber - 1);
|
||||
expect(lastSlotText).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should end at ' + hourNumber, function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
maxTime: hourNumber + ':00' // in addition, test string duration input
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
|
||||
var expected = numToStringConverter(hourNumber - 1);
|
||||
expect(lastSlotText).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when using default slotInterval and \'uneven\' maxTime', function() {
|
||||
|
||||
var hourNumbers = [ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 ];
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should end at ' + hourNumber + ':20', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
maxTime: { hours: hourNumber, minutes: 20 }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
|
||||
// since exclusive end is :20, last slot will be on the current hour's 00:00
|
||||
var expected = numToStringConverter(hourNumber);
|
||||
expect(lastSlotText).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should end at ' + hourNumber + ':20', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
maxTime: { hours: hourNumber, minutes: 20 }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var lastSlotText = $('.fc-slats tr:not(.fc-minor):last .fc-time').text();
|
||||
// since exclusive end is :20, last slot will be on the current hour's 00:00
|
||||
var expected = numToStringConverter(hourNumber);
|
||||
expect(lastSlotText).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,126 +0,0 @@
|
||||
describe('minTime', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
var numToStringConverter = function(timeIn, mins) {
|
||||
var time = (timeIn % 12) || 12;
|
||||
var amPm = 'am';
|
||||
if ((timeIn % 24) > 11) {
|
||||
amPm = 'pm';
|
||||
}
|
||||
return time + (mins != null ? ':' + mins : '') + amPm;
|
||||
};
|
||||
|
||||
describe('when using the default settings', function() {
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
it('should start at 12am', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
|
||||
expect(firstSlotText).toEqual('12am');
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
it('should start at 12am', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
|
||||
expect(firstSlotText).toEqual('12am');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when using a whole number', function() {
|
||||
|
||||
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should start at ' + hourNumber, function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
minTime: { hours: hourNumber }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
|
||||
var expected = numToStringConverter(hourNumber);
|
||||
expect(firstSlotText).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should start at ' + hourNumber, function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
minTime: hourNumber + ':00' // in addition, test string duration input
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var firstSlotText = $('.fc-slats tr:eq(0) .fc-time').text();
|
||||
var expected = numToStringConverter(hourNumber);
|
||||
expect(firstSlotText).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when using default slotInterval and \'uneven\' minTime', function() {
|
||||
|
||||
var hourNumbers = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ];
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should start at ' + hourNumber + ':20', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
minTime: { hours: hourNumber, minutes: 20 }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var slatRows = $('.fc-slats tr');
|
||||
expect(slatRows.eq(0)).toHaveClass('fc-minor');
|
||||
expect(slatRows.eq(1)).toHaveClass('fc-minor');
|
||||
expect(slatRows.eq(2)).toHaveClass('fc-minor');
|
||||
// TODO: fix bad behavior in src where no slots have text
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
hourNumbers.forEach(function(hourNumber) {
|
||||
it('should start at ' + hourNumber + ':20', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay',
|
||||
minTime: { hours: hourNumber, minutes: 20 }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var slatRows = $('.fc-slats tr');
|
||||
expect(slatRows.eq(0)).toHaveClass('fc-minor');
|
||||
expect(slatRows.eq(1)).toHaveClass('fc-minor');
|
||||
expect(slatRows.eq(2)).toHaveClass('fc-minor');
|
||||
// TODO: fix bad behavior in src where no slots have text
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,184 +0,0 @@
|
||||
|
||||
describe('ambiguously-zoned moment', function() {
|
||||
|
||||
it('has a false hasZone', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('has a true hasTime', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
});
|
||||
|
||||
it('has a zero zone', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('formats without a zone part', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.format()).toBe('2014-06-08T10:00:00');
|
||||
});
|
||||
|
||||
it('formats via toISOString without a zone part', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.toISOString()).toBe('2014-06-08T10:00:00');
|
||||
});
|
||||
|
||||
it('is correctly cloned', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
var clone = mom.clone();
|
||||
expect(clone.hasZone()).toBe(false);
|
||||
expect(clone.format()).toBe('2014-06-08T10:00:00');
|
||||
expect(clone).not.toBe(mom);
|
||||
clone.add(1, 'months');
|
||||
expect(+clone).not.toBe(+mom);
|
||||
});
|
||||
|
||||
it('can be given a zone via utc', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.zone()).toBe(0);
|
||||
mom.utc();
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('can be given a zone via local', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
var equivDate = new Date(Date.UTC(2014, 5, 8, 10, 0, 0));
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 10, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.zone()).toBe(0);
|
||||
mom.local();
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 10, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(equivDate.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('can be given a zone via zone', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08T10:00:00');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.zone()).toBe(0);
|
||||
mom.zone(-420);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(-420);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('ambiguously-timed moment', function() {
|
||||
|
||||
it('has a false hasTime', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
});
|
||||
|
||||
it('has a false hasZone', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('has a zero time', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
var time = mom.time();
|
||||
expect(+time).toBe(0);
|
||||
});
|
||||
|
||||
it('formats without a zone part', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.format()).toBe('2014-06-08');
|
||||
});
|
||||
|
||||
it('formats via toISOString without a time part', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.toISOString()).toBe('2014-06-08');
|
||||
});
|
||||
|
||||
it('is correctly cloned', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
var clone = mom.clone();
|
||||
expect(clone.hasTime()).toBe(false);
|
||||
expect(clone.format()).toBe('2014-06-08');
|
||||
expect(clone).not.toBe(mom);
|
||||
clone.add(1, 'months');
|
||||
expect(+clone).not.toBe(+mom);
|
||||
});
|
||||
|
||||
it('can be given a time', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
var time = moment.duration({ hours: 1, minutes: 25 });
|
||||
mom.time(time);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(+mom.time()).toBe(+time);
|
||||
});
|
||||
|
||||
it('can be given a time and zone via utc', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.zone()).toBe(0);
|
||||
mom.utc();
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('can be given a time and zone via local', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
var equivDate = new Date(2014, 5, 8, 10, 0, 0);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.zone()).toBe(0);
|
||||
mom.local();
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(equivDate.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('can be given a time and zone via zone', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-08');
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.zone()).toBe(0);
|
||||
mom.zone(-420);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(-420);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('unambiguous moment', function() {
|
||||
|
||||
it('can be made ambiguously-zoned via stripZone', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-06-08T10:00:00-0000');
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
mom.stripZone();
|
||||
expect(mom.format()).toBe('2014-06-08T10:00:00');
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
});
|
||||
|
||||
it('can be made ambigously-timed via stripTime', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-06-08T10:00:00-0000');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
mom.stripTime();
|
||||
expect(mom.format()).toBe('2014-06-08');
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,646 +0,0 @@
|
||||
(function() {
|
||||
|
||||
describe('$.fullCalendar.moment', function() {
|
||||
testDefaultProcessing($.fullCalendar.moment);
|
||||
});
|
||||
|
||||
describe('$.fullCalendar.moment.utc', function() {
|
||||
testForcedUTCProcessing($.fullCalendar.moment.utc);
|
||||
});
|
||||
|
||||
describe('$.fullCalendar.moment.parseZone', function() {
|
||||
testLiteralProcessing($.fullCalendar.moment.parseZone);
|
||||
});
|
||||
|
||||
describe('Calendar::moment', function() {
|
||||
[
|
||||
{
|
||||
description: 'when there is no timezone',
|
||||
timezone: false,
|
||||
testMethod: testLiteralProcessing
|
||||
},
|
||||
{
|
||||
description: 'when timezone is local',
|
||||
timezone: 'local',
|
||||
testMethod: testForcedLocalProcessing
|
||||
},
|
||||
{
|
||||
description: 'when timezone is UTC',
|
||||
timezone: 'UTC',
|
||||
testMethod: testForcedUTCProcessing
|
||||
},
|
||||
{
|
||||
description: 'when timezone is custom',
|
||||
timezone: 'America/Unknown',
|
||||
testMethod: testLiteralProcessing
|
||||
}
|
||||
]
|
||||
.forEach(function(scenario) {
|
||||
describe(scenario.description, function() {
|
||||
var calendarObj;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
$('#cal').fullCalendar({
|
||||
timezone: scenario.timezone
|
||||
});
|
||||
calendarObj = $('#cal').fullCalendar('getCalendar');
|
||||
});
|
||||
|
||||
scenario.testMethod(function() {
|
||||
return calendarObj.moment.apply(calendarObj, arguments);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function testDefaultProcessing(construct) {
|
||||
|
||||
describe('when given an ISO8601 string', function() {
|
||||
|
||||
it('is local regardless of inputted zone', function() {
|
||||
var mom = construct('2014-06-08T10:00:00+0130');
|
||||
var simpleMoment = moment('2014-06-08T10:00:00+0130');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(simpleMoment.zone());
|
||||
});
|
||||
|
||||
it('parses as local when no zone', function() {
|
||||
var mom = construct('2014-06-08T10:00:00');
|
||||
var dateEquiv = new Date(2014, 5, 8, 10);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 10, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('accepts an ambiguous time', function() {
|
||||
var mom = construct('2014-06-08');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('assumes first-of-month and ambiguous time when no date-of-month', function() {
|
||||
var mom = construct('2014-06');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 1, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('parses string/format combo as local', function() {
|
||||
var mom = construct('12-25-1995', 'MM-DD-YYYY');
|
||||
var dateEquiv = new Date(1995, 11, 25);
|
||||
expect(mom.toArray()).toEqual([ 1995, 11, 25, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local when given no arguments', function() {
|
||||
var mom = construct();
|
||||
var dateEquiv = new Date();
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local when given a native Date', function() {
|
||||
var date = new Date();
|
||||
var mom = construct(date);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(date.getTimezoneOffset());
|
||||
});
|
||||
|
||||
describe('when given an array', function() {
|
||||
|
||||
it('is local and has a time when given hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8, 11, 0, 0 ];
|
||||
var dateEquiv = new Date(2014, 5, 8, 11, 0, 0);
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 11, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local and has a time even when no hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8 ];
|
||||
var dateEquiv = new Date(2014, 5, 8);
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given an existing FullCalendar moment', function() {
|
||||
|
||||
it('remains ambiguously-zoned', function() {
|
||||
var noTzMoment = $.fullCalendar.moment.parseZone('2014-05-28T00:00:00');
|
||||
var newMoment = construct(noTzMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('remains ambiguously-timed', function() {
|
||||
var noTimeMoment = $.fullCalendar.moment('2014-05-28');
|
||||
var newMoment = construct(noTimeMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(false);
|
||||
expect(newMoment.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
{ description: 'when given an existing FullCalendar moment', moment: $.fullCalendar.moment },
|
||||
{ description: 'when given an existing basic moment', moment: moment }
|
||||
]
|
||||
.forEach(function(scenario) {
|
||||
describe(scenario.description, function() {
|
||||
|
||||
it('remains local', function() {
|
||||
var localMoment = scenario.moment('2014-05-28T00:00:00');
|
||||
var newMoment = construct(localMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(localMoment.zone());
|
||||
});
|
||||
|
||||
it('remains UTC', function() {
|
||||
var utcMoment = scenario.moment.utc('2014-05-28T00:00:00');
|
||||
var newMoment = construct(utcMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('remains in a custom timezone', function() {
|
||||
var tzMoment = scenario.moment.parseZone('2014-05-28T00:00:00+13:00');
|
||||
var newMoment = construct(tzMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(-780);
|
||||
});
|
||||
|
||||
it('produces a new moment that is in no way bound to the old', function() {
|
||||
var oldMoment = scenario.moment();
|
||||
var newMoment = construct(oldMoment);
|
||||
expect(newMoment).not.toBe(oldMoment);
|
||||
expect(+newMoment).toBe(+oldMoment);
|
||||
newMoment.add(1, 'months');
|
||||
expect(+newMoment).not.toBe(+oldMoment);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testForcedLocalProcessing(construct) {
|
||||
|
||||
describe('when given an ISO8601 string', function() {
|
||||
|
||||
it('is local regardless of inputted zone', function() {
|
||||
var mom = construct('2014-06-08T10:00:00+0130');
|
||||
var simpleMoment = moment('2014-06-08T10:00:00+0130');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(simpleMoment.zone());
|
||||
});
|
||||
|
||||
it('parses as local when no zone', function() {
|
||||
var mom = construct('2014-06-08T10:00:00');
|
||||
var dateEquiv = new Date(2014, 5, 8, 10);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 10, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('accepts an ambiguous time', function() {
|
||||
var mom = construct('2014-06-08');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('assumes first-of-month and ambiguous time when no date-of-month', function() {
|
||||
var mom = construct('2014-06');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 1, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('parses string/format combo as local', function() {
|
||||
var mom = construct('12-25-1995', 'MM-DD-YYYY');
|
||||
var dateEquiv = new Date(1995, 11, 25);
|
||||
expect(mom.toArray()).toEqual([ 1995, 11, 25, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local when given no arguments', function() {
|
||||
var mom = construct();
|
||||
var dateEquiv = new Date();
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local when given a native Date', function() {
|
||||
var date = new Date();
|
||||
var mom = construct(date);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(date.getTimezoneOffset());
|
||||
});
|
||||
|
||||
describe('when given an array', function() {
|
||||
|
||||
it('is local and has a time when given hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8, 11, 0, 0 ];
|
||||
var dateEquiv = new Date(2014, 5, 8, 11, 0, 0);
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 11, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local and has a time even when no hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8 ];
|
||||
var dateEquiv = new Date(2014, 5, 8);
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given an existing FullCalendar moment', function() {
|
||||
|
||||
it('converts to local when ambiguously-zoned', function() {
|
||||
var noTzMoment = $.fullCalendar.moment.parseZone('2014-05-28T00:00:00');
|
||||
var newMoment = construct(noTzMoment);
|
||||
var dateEquiv = new Date(2014, 4, 28);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('remains ambiguously-timed', function() {
|
||||
var noTimeMoment = $.fullCalendar.moment('2014-05-28');
|
||||
var newMoment = construct(noTimeMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(false);
|
||||
expect(newMoment.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
{ description: 'when given an existing FullCalendar moment', moment: $.fullCalendar.moment },
|
||||
{ description: 'when given an existing basic moment', moment: moment }
|
||||
]
|
||||
.forEach(function(scenario) {
|
||||
describe(scenario.description, function() {
|
||||
|
||||
it('remains local', function() {
|
||||
var localMoment = scenario.moment('2014-05-28T00:00:00');
|
||||
var newMoment = construct(localMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(localMoment.zone());
|
||||
});
|
||||
|
||||
it('converts to local when UTC', function() {
|
||||
var utcMoment = scenario.moment.utc('2014-05-28T00:00:00');
|
||||
var newMoment = construct(utcMoment);
|
||||
var dateEquiv = new Date(Date.UTC(2014, 4, 28));
|
||||
expect(+newMoment).toBe(+dateEquiv);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('converts to local when in a custom zone', function() {
|
||||
var tzMoment = scenario.moment.parseZone('2014-05-28T00:00:00+13:00');
|
||||
var dateEquiv = tzMoment.toDate();
|
||||
var newMoment = construct(tzMoment);
|
||||
expect(+newMoment).toBe(+dateEquiv);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('produces a new moment that is in no way bound to the old', function() {
|
||||
var oldMoment = scenario.moment();
|
||||
var newMoment = construct(oldMoment);
|
||||
expect(newMoment).not.toBe(oldMoment);
|
||||
expect(+newMoment).toBe(+oldMoment);
|
||||
newMoment.add(1, 'months');
|
||||
expect(+newMoment).not.toBe(+oldMoment);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testForcedUTCProcessing(construct) {
|
||||
|
||||
describe('when given an ISO8601 string', function() {
|
||||
|
||||
it('is UTC regardless of inputted zone', function() {
|
||||
var mom = construct('2014-06-08T10:00:00+0130');
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('parses as UTC when no zone', function() {
|
||||
var mom = construct('2014-06-08T10:00:00');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 10, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('accepts an ambiguous time', function() {
|
||||
var mom = construct('2014-06-08');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('assumes first-of-month and ambiguous time when no date-of-month', function() {
|
||||
var mom = construct('2014-06');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 1, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('parses string/format combo as UTC', function() {
|
||||
var mom = construct('12-25-1995', 'MM-DD-YYYY');
|
||||
expect(mom.toArray()).toEqual([ 1995, 11, 25, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('is UTC when given no arguments', function() {
|
||||
var mom = construct();
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('is UTC when given a native Date', function() {
|
||||
var date = new Date();
|
||||
var mom = construct(date);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
describe('when given an array', function() {
|
||||
|
||||
it('is UTC and has a time when given hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8, 11, 0, 0 ];
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 11, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('is UTC and has a time even when no hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8 ];
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given an existing FullCalendar moment', function() {
|
||||
|
||||
it('converts to UTC when ambiguously-zoned', function() {
|
||||
var noTzMoment = $.fullCalendar.moment.utc('2014-05-28T00:00:00');
|
||||
var newMoment = construct(noTzMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('remains ambiguously-timed', function() {
|
||||
var noTimeMoment = $.fullCalendar.moment('2014-05-28');
|
||||
var newMoment = construct(noTimeMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(false);
|
||||
expect(newMoment.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
{ description: 'when given an existing FullCalendar moment', moment: $.fullCalendar.moment },
|
||||
{ description: 'when given an existing basic moment', moment: moment }
|
||||
]
|
||||
.forEach(function(scenario) {
|
||||
describe(scenario.description, function() {
|
||||
|
||||
it('converts to UTC when local', function() {
|
||||
var localMoment = scenario.moment('2014-05-28T00:00:00');
|
||||
var newMoment = construct(localMoment);
|
||||
expect(+newMoment).toBe(+localMoment); // same point in time
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('remains UTC', function() {
|
||||
var utcMoment = scenario.moment.utc('2014-05-28T00:00:00');
|
||||
var newMoment = construct(utcMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('converts to UTC when in a custom zone', function() {
|
||||
var tzMoment = scenario.moment.parseZone('2014-05-28T00:00:00+13:00');
|
||||
var newMoment = construct(tzMoment);
|
||||
expect(+newMoment).toBe(+tzMoment); // same point in time
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('produces a new moment that is in no way bound to the old', function() {
|
||||
var oldMoment = scenario.moment.utc();
|
||||
var newMoment = construct(oldMoment);
|
||||
expect(newMoment).not.toBe(oldMoment);
|
||||
expect(+newMoment).toBe(+oldMoment);
|
||||
newMoment.add(1, 'months');
|
||||
expect(+newMoment).not.toBe(+oldMoment);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testLiteralProcessing(construct) {
|
||||
|
||||
describe('when given an ISO8601 string', function() {
|
||||
|
||||
it('retains the inputted zone', function() {
|
||||
var mom = construct('2014-06-08T11:00:00+0130');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 11, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(-90);
|
||||
});
|
||||
|
||||
it('accepts an ambiguous zone', function() {
|
||||
var mom = construct('2014-06-08T11:00:00');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 11, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('accepts an ambiguous time', function() {
|
||||
var mom = construct('2014-06-08');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('assumes first-of-month and ambiguous time when no date-of-month', function() {
|
||||
var mom = construct('2014-06');
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 1, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(false);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
it('parses string/format combo as UTC', function() {
|
||||
var mom = construct('12-25-1995', 'MM-DD-YYYY');
|
||||
expect(mom.toArray()).toEqual([ 1995, 11, 25, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('is local when given no arguments', function() {
|
||||
var mom = construct();
|
||||
var dateEquiv = new Date();
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(dateEquiv.getTimezoneOffset());
|
||||
});
|
||||
|
||||
it('is local when given a native Date', function() {
|
||||
var date = new Date();
|
||||
var mom = construct(date);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(true);
|
||||
expect(mom.zone()).toBe(date.getTimezoneOffset());
|
||||
});
|
||||
|
||||
describe('when given an array', function() {
|
||||
|
||||
it('is ambiguously-zoned and has a time when given hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8, 11, 0, 0 ];
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 11, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('is ambiguously-zoned and has a time even when no hours/minutes/seconds', function() {
|
||||
var a = [ 2014, 5, 8 ];
|
||||
var mom = construct(a);
|
||||
expect(mom.toArray()).toEqual([ 2014, 5, 8, 0, 0, 0, 0 ]);
|
||||
expect(mom.hasTime()).toBe(true);
|
||||
expect(mom.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when given an existing FullCalendar moment', function() {
|
||||
|
||||
it('remains ambiguously-zoned', function() {
|
||||
var noTzMoment = $.fullCalendar.moment.parseZone('2014-05-28T00:00:00');
|
||||
var newMoment = construct(noTzMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(false);
|
||||
});
|
||||
|
||||
it('remains ambiguously-timed', function() {
|
||||
var noTimeMoment = $.fullCalendar.moment('2014-05-28');
|
||||
var newMoment = construct(noTimeMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(false);
|
||||
expect(newMoment.hasZone()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
[
|
||||
{ description: 'when given an existing FullCalendar moment', moment: $.fullCalendar.moment },
|
||||
{ description: 'when given an existing basic moment', moment: moment }
|
||||
]
|
||||
.forEach(function(scenario) {
|
||||
describe(scenario.description, function() {
|
||||
|
||||
it('remains local', function() {
|
||||
var localMoment = scenario.moment('2014-05-28T00:00:00');
|
||||
var newMoment = construct(localMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(localMoment.zone());
|
||||
});
|
||||
|
||||
it('remains UTC', function() {
|
||||
var utcMoment = scenario.moment.utc('2014-05-28T00:00:00');
|
||||
var newMoment = construct(utcMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(0);
|
||||
});
|
||||
|
||||
it('remains in a custom timezone', function() {
|
||||
var tzMoment = scenario.moment.parseZone('2014-05-28T00:00:00+13:00');
|
||||
var newMoment = construct(tzMoment);
|
||||
expect(newMoment.toArray()).toEqual([ 2014, 4, 28, 0, 0, 0, 0 ]);
|
||||
expect(newMoment.hasTime()).toBe(true);
|
||||
expect(newMoment.hasZone()).toBe(true);
|
||||
expect(newMoment.zone()).toBe(-780);
|
||||
});
|
||||
|
||||
it('produces a new moment that is in no way bound to the old', function() {
|
||||
var oldMoment = scenario.moment();
|
||||
var newMoment = construct(oldMoment);
|
||||
expect(newMoment).not.toBe(oldMoment);
|
||||
expect(+newMoment).toBe(+oldMoment);
|
||||
newMoment.add(1, 'months');
|
||||
expect(+newMoment).not.toBe(+oldMoment);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -1,68 +0,0 @@
|
||||
|
||||
describe('moment date formatting', function() {
|
||||
|
||||
it('should let vanilla momentjs formatting to work correctly', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T14:00:00');
|
||||
var s1 = mom.format('dddd, MMMM Do YYYY, h:mm:ss a');
|
||||
var s2 = mom.format('ddd, hA Z');
|
||||
expect(s1).toEqual('Tuesday, May 20th 2014, 2:00:00 pm');
|
||||
expect(s2).toEqual('Tue, 2PM +00:00');
|
||||
});
|
||||
|
||||
it('should allow momentjs text escaping', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T14:00:00');
|
||||
var s = mom.format('MMMM Do YYYY [TIME:] h:mm:ss a');
|
||||
expect(s).toEqual('May 20th 2014 TIME: 2:00:00 pm');
|
||||
});
|
||||
|
||||
it('should correctly output LT (regression)', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T06:00:00');
|
||||
var s = mom.format('ddd, LT');
|
||||
expect(s).toEqual('Tue, 6:00 AM');
|
||||
});
|
||||
|
||||
it('should correctly output hT (regression)', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T06:00:00');
|
||||
var s = mom.format('ddd, hT');
|
||||
expect(s).toEqual('Tue, 6A');
|
||||
});
|
||||
|
||||
it('should output A/P with the \'T\' formatting character', function() {
|
||||
var mom1 = $.fullCalendar.moment.utc('2014-05-20T06:00:00');
|
||||
var mom2 = $.fullCalendar.moment.utc('2014-05-20T14:00:00');
|
||||
var s1 = mom1.format('ddd, h T');
|
||||
var s2 = mom2.format('ddd, h T');
|
||||
expect(s1).toEqual('Tue, 6 A');
|
||||
expect(s2).toEqual('Tue, 2 P');
|
||||
});
|
||||
|
||||
it('should output A/P with the \'t\' formatting character', function() {
|
||||
var mom1 = $.fullCalendar.moment.utc('2014-05-20T06:00:00');
|
||||
var mom2 = $.fullCalendar.moment.utc('2014-05-20T14:00:00');
|
||||
var s1 = mom1.format('ddd, h t');
|
||||
var s2 = mom2.format('ddd, h t');
|
||||
expect(s1).toEqual('Tue, 6 a');
|
||||
expect(s2).toEqual('Tue, 2 p');
|
||||
});
|
||||
|
||||
it('should output non-zero numbers enclosed in parenthesis', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T06:30:00');
|
||||
var s = mom.format('ddd h(:mm)a');
|
||||
expect(s).toEqual('Tue 6:30am');
|
||||
});
|
||||
|
||||
it('should not output zero numbers enclosed in parenthesis', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T06:00:00');
|
||||
var s = mom.format('ddd h(:mm)a');
|
||||
expect(s).toEqual('Tue 6am');
|
||||
});
|
||||
|
||||
it('should allow escaping of parenthesis as literal text', function() {
|
||||
var mom = $.fullCalendar.moment.utc('2014-05-20T06:00:00');
|
||||
var s1 = mom.format('ddd h[(]:mm)a');
|
||||
//var s2 = mom.format('ddd h(:mm[)]a'); // we currently cant nest [] inside ()
|
||||
expect(s1).toEqual('Tue 6(:00)am');
|
||||
//expect(s2).toEqual('Tue 6(:00)am');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,177 +0,0 @@
|
||||
|
||||
(function() {
|
||||
|
||||
var momentTypeSuffixes = {
|
||||
'ambiguously-timed': '',
|
||||
'ambiguously-zoned': 'T00:30:00',
|
||||
timed: 'T00:30:00-0500'
|
||||
};
|
||||
|
||||
describe('isSame', function() {
|
||||
|
||||
describe('when no units provided', function() {
|
||||
|
||||
it('returns false when the dates are different', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25T07:00:00');
|
||||
expect(m1.isSame(m2)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when the dates are the same, but different zone-ambiguation', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00+00:00');
|
||||
expect(m1.isSame(m2)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false when the dates are the same, but different hasTime', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-25');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
expect(m1.isSame(m2)).toBe(false);
|
||||
});
|
||||
|
||||
it('returns true when the dates are exactly the same', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-25');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25');
|
||||
expect(m1.isSame(m2)).toBe(true);
|
||||
m1 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
expect(m1.isSame(m2)).toBe(true);
|
||||
m1 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00+05:00');
|
||||
m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00+05:00');
|
||||
expect(m1.isSame(m2)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when units are provided', function() {
|
||||
|
||||
it('returns true when dates are the same day but different zone-ambiguation', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00-11:00');
|
||||
expect(m1.isSame(m2, 'day')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns true when dates are the same day but different hasTime', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-25');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00-11:00');
|
||||
expect(m1.isSame(m2, 'day')).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false when dates are a different day', function() {
|
||||
var m1 = $.fullCalendar.moment.parseZone('2014-08-24T00:00:00');
|
||||
var m2 = $.fullCalendar.moment.parseZone('2014-08-25T06:00:00');
|
||||
expect(m1.isSame(m2, 'day')).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isWithin', function() {
|
||||
$.each(momentTypeSuffixes, function(thisType, thisSuffix) {
|
||||
describe('when the moment is ' + thisType, function() {
|
||||
$.each(momentTypeSuffixes, function(otherType, otherSuffix) {
|
||||
describe('and other moments are ' + otherType, function() {
|
||||
|
||||
it('is clearly within', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other1 = $.fullCalendar.moment.parseZone('2014-06-01' + otherSuffix);
|
||||
var other2 = $.fullCalendar.moment.parseZone('2014-07-01' + otherSuffix);
|
||||
var res = mom.isWithin(other1, other2);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('is clearly not within', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other1 = $.fullCalendar.moment.parseZone('2014-09-01' + otherSuffix);
|
||||
var other2 = $.fullCalendar.moment.parseZone('2014-10-01' + otherSuffix);
|
||||
var res = mom.isWithin(other1, other2);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
it('is within when equal to start', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other1 = $.fullCalendar.moment.parseZone('2014-06-15' + otherSuffix);
|
||||
var other2 = $.fullCalendar.moment.parseZone('2014-07-01' + otherSuffix);
|
||||
var res = mom.isWithin(other1, other2);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('is not within when equal to end', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other1 = $.fullCalendar.moment.parseZone('2014-06-01' + otherSuffix);
|
||||
var other2 = $.fullCalendar.moment.parseZone('2014-06-15' + otherSuffix);
|
||||
var res = mom.isWithin(other1, other2);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isBefore', function() {
|
||||
$.each(momentTypeSuffixes, function(thisType, thisSuffix) {
|
||||
describe('when the moment is ' + thisType, function() {
|
||||
$.each(momentTypeSuffixes, function(otherType, otherSuffix) {
|
||||
describe('and other moment is ' + otherType, function() {
|
||||
|
||||
it('is clearly before', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other = $.fullCalendar.moment.parseZone('2015-01-01' + otherSuffix);
|
||||
var res = mom.isBefore(other);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('is clearly not before', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other = $.fullCalendar.moment.parseZone('2013-01-01' + otherSuffix);
|
||||
var res = mom.isBefore(other);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
it('is equal', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other = $.fullCalendar.moment.parseZone('2014-06-15' + otherSuffix);
|
||||
var res = mom.isBefore(other);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('isAfter', function() {
|
||||
$.each(momentTypeSuffixes, function(thisType, thisSuffix) {
|
||||
describe('when the moment is ' + thisType, function() {
|
||||
$.each(momentTypeSuffixes, function(otherType, otherSuffix) {
|
||||
describe('and other moment is ' + otherType, function() {
|
||||
|
||||
it('is clearly after', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other = $.fullCalendar.moment.parseZone('2013-01-01' + otherSuffix);
|
||||
var res = mom.isAfter(other);
|
||||
expect(res).toBe(true);
|
||||
});
|
||||
|
||||
it('is clearly not after', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other = $.fullCalendar.moment.parseZone('2015-01-01' + otherSuffix);
|
||||
var res = mom.isAfter(other);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
it('is equal', function() {
|
||||
var mom = $.fullCalendar.moment.parseZone('2014-06-15' + thisSuffix);
|
||||
var other = $.fullCalendar.moment.parseZone('2014-06-15' + otherSuffix);
|
||||
var res = mom.isAfter(other);
|
||||
expect(res).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
@@ -1,103 +0,0 @@
|
||||
describe('month name', function() {
|
||||
var settings = {};
|
||||
var referenceDate = '2014-01-01'; // The day the world is hung-over
|
||||
var languages = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ];
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
settings = {
|
||||
defaultDate: referenceDate
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
moment.lang('en'); // reset moment's global language
|
||||
});
|
||||
|
||||
[ 'month', 'agendaDay', 'basicDay' ].forEach(function(viewClass, index, viewClasses) {
|
||||
describe('when view is ' + viewClass, function() {
|
||||
beforeEach(function() {
|
||||
settings.defaultView = viewClass;
|
||||
});
|
||||
|
||||
describe('when lang is default', function() {
|
||||
beforeEach(function() {
|
||||
settings.lang = 'en';
|
||||
moment.lang('en');
|
||||
});
|
||||
|
||||
moment.months().forEach(function(month, index, months) {
|
||||
it('should be ' + month, function(done) {
|
||||
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
|
||||
settings.eventAfterAllRender = function() {
|
||||
expect($('.fc-toolbar h2')).toContainText(month);
|
||||
done();
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
languages.forEach(function(language, index, languages) {
|
||||
describe('when lang is ' + language, function() {
|
||||
beforeEach(function() {
|
||||
settings.lang = language;
|
||||
moment.lang(language);
|
||||
});
|
||||
|
||||
moment.months().forEach(function(month, index, months) { // `month` will always be English
|
||||
it('should be the translated name for ' + month, function(done) {
|
||||
var langMonths = moment.months();
|
||||
var langMonth = langMonths[index];
|
||||
|
||||
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
|
||||
settings.eventAfterAllRender = function() {
|
||||
if (viewClass == 'month') { // with month view check for occurence of the monthname in the title
|
||||
expect($('.fc-toolbar h2')).toContainText(langMonth);
|
||||
}
|
||||
else { // with day views ensure that title contains the properly formatted phrase
|
||||
expect($('.fc-toolbar h2')).toHaveText(settings.defaultDate.format('LL'));
|
||||
}
|
||||
done();
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when names are specified', function() {
|
||||
var months = [
|
||||
'I',
|
||||
'II',
|
||||
'III',
|
||||
'IV',
|
||||
'V',
|
||||
'VI',
|
||||
'VII',
|
||||
'IIX',
|
||||
'IX',
|
||||
'X',
|
||||
'XI',
|
||||
'XII'
|
||||
];
|
||||
|
||||
months.forEach(function(month, index, months) { // `month` is our custom month name
|
||||
it('should be the translated name for ' + month, function(done) {
|
||||
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
|
||||
settings.monthNames = months;
|
||||
settings.eventAfterAllRender = function() {
|
||||
expect($('.fc-toolbar h2')).toContainText(month);
|
||||
done();
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,98 +0,0 @@
|
||||
describe('short month name', function() {
|
||||
var settings = {};
|
||||
var referenceDate = '2014-01-01'; // The day the world is hung-over
|
||||
var languages = [ 'es', 'fr', 'de', 'zh-cn', 'nl' ];
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
settings = {
|
||||
defaultDate: referenceDate
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
moment.lang('en'); // reset moment's global language
|
||||
});
|
||||
|
||||
[ 'agendaWeek', 'basicWeek' ].forEach(function(viewClass, index, viewClasses) {
|
||||
describe('when view is ' + viewClass, function() {
|
||||
beforeEach(function() {
|
||||
settings.defaultView = viewClass;
|
||||
});
|
||||
|
||||
describe('when lang is default', function() {
|
||||
beforeEach(function() {
|
||||
settings.lang = 'en';
|
||||
moment.lang('en');
|
||||
});
|
||||
|
||||
moment.monthsShort().forEach(function(monthShort, index) {
|
||||
it('should be ' + monthShort, function(done) {
|
||||
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
|
||||
settings.eventAfterAllRender = function() {
|
||||
expect($('.fc-toolbar h2')).toContainText(monthShort);
|
||||
done();
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
languages.forEach(function(language, index, languages) {
|
||||
describe('when lang is ' + language, function() {
|
||||
beforeEach(function() {
|
||||
settings.lang = language;
|
||||
moment.lang(language);
|
||||
});
|
||||
|
||||
moment.monthsShort().forEach(function(monthShort, index) { // `monthShort` will always be English
|
||||
it('should be the translated name for ' + monthShort, function(done) {
|
||||
var langMonthsShort = moment.monthsShort();
|
||||
var langMonthShort = langMonthsShort[index];
|
||||
|
||||
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
|
||||
settings.eventAfterAllRender = function() {
|
||||
expect($('.fc-toolbar h2')).toContainText(langMonthShort);
|
||||
done();
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when names are specified', function() {
|
||||
var monthsShort = [
|
||||
'I',
|
||||
'II',
|
||||
'III',
|
||||
'IV',
|
||||
'V',
|
||||
'VI',
|
||||
'VII',
|
||||
'IIX',
|
||||
'IX',
|
||||
'X',
|
||||
'XI',
|
||||
'XII'
|
||||
];
|
||||
|
||||
monthsShort.forEach(function(monthShort, index) { // `monthShort` will be our custom month name
|
||||
it('should be the translated name for ' + monthShort, function(done) {
|
||||
settings.defaultDate = $.fullCalendar.moment(referenceDate).add(index, 'months');
|
||||
settings.monthNamesShort = monthsShort;
|
||||
settings.eventAfterAllRender = function() {
|
||||
expect($('.fc-toolbar h2')).toContainText(monthShort);
|
||||
done();
|
||||
};
|
||||
|
||||
$('#cal').fullCalendar(settings);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,70 +0,0 @@
|
||||
|
||||
describe('nextDayThreshold', function() {
|
||||
|
||||
// when a view object exposes its nextDayThreshold value (after some refactoring)...
|
||||
// TODO: detect the default of 9am
|
||||
// TODO: detect 2 or more different types of Duration-ish parsing
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
it('renders an event before the threshold', function() {
|
||||
$('#cal').fullCalendar({
|
||||
nextDayThreshold: '10:00:00',
|
||||
defaultDate: '2014-06',
|
||||
defaultView: 'month',
|
||||
events: [
|
||||
{
|
||||
title: 'event1',
|
||||
start: '2014-06-08T22:00:00',
|
||||
end: '2014-06-10T09:00:00'
|
||||
}
|
||||
]
|
||||
});
|
||||
expect(renderedDayCount()).toBe(2);
|
||||
});
|
||||
|
||||
it('renders an event equal to the threshold', function() {
|
||||
$('#cal').fullCalendar({
|
||||
nextDayThreshold: '10:00:00',
|
||||
defaultDate: '2014-06',
|
||||
defaultView: 'month',
|
||||
events: [
|
||||
{
|
||||
title: 'event1',
|
||||
start: '2014-06-08T22:00:00',
|
||||
end: '2014-06-10T10:00:00'
|
||||
}
|
||||
]
|
||||
});
|
||||
expect(renderedDayCount()).toBe(3);
|
||||
});
|
||||
|
||||
it('renders an event after the threshold', function() {
|
||||
$('#cal').fullCalendar({
|
||||
nextDayThreshold: '10:00:00',
|
||||
defaultDate: '2014-06',
|
||||
defaultView: 'month',
|
||||
events: [
|
||||
{
|
||||
title: 'event1',
|
||||
start: '2014-06-08T22:00:00',
|
||||
end: '2014-06-10T11:00:00'
|
||||
}
|
||||
]
|
||||
});
|
||||
expect(renderedDayCount()).toBe(3);
|
||||
});
|
||||
|
||||
|
||||
function renderedDayCount() { // assumes only one event on the calendar
|
||||
var cellWidth = $('.fc-sun').outerWidth(); // works with basic and agenda
|
||||
var totalWidth = 0;
|
||||
$('.fc-event').each(function() {
|
||||
totalWidth += $(this).outerWidth();
|
||||
});
|
||||
return Math.round(totalWidth / cellWidth);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -1,59 +0,0 @@
|
||||
describe('now', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-05-01'
|
||||
};
|
||||
});
|
||||
|
||||
describe('when month view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'month';
|
||||
});
|
||||
it('changes the highlighted day when customized', function() {
|
||||
options.now = '2014-05-06';
|
||||
$('#cal').fullCalendar(options);
|
||||
var todayCell = $('#cal td.fc-today');
|
||||
var todayDate = todayCell.data('date');
|
||||
expect(todayDate).toEqual('2014-05-06');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when agendaWeek view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'agendaWeek';
|
||||
});
|
||||
it('changes the highlighted day when customized', function() {
|
||||
options.now = '2014-04-29T12:00:00';
|
||||
$('#cal').fullCalendar(options);
|
||||
var todayCell = $('#cal td.fc-today');
|
||||
expect(todayCell.data('date')).toBe('2014-04-29');
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts a function that returns a moment', function() {
|
||||
options.defaultView = 'month';
|
||||
options.now = function() {
|
||||
return moment.utc('2014-05-01');
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var todayCell = $('#cal td.fc-today');
|
||||
var todayDate = todayCell.data('date');
|
||||
expect(todayDate).toEqual('2014-05-01');
|
||||
});
|
||||
|
||||
it('accepts a function that returns a moment-ish string', function() {
|
||||
options.defaultView = 'month';
|
||||
options.now = function() {
|
||||
return '2014-05-01';
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var todayCell = $('#cal td.fc-today');
|
||||
var todayDate = todayCell.data('date');
|
||||
expect(todayDate).toEqual('2014-05-01');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,40 +0,0 @@
|
||||
describe('scrollTime', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
});
|
||||
|
||||
it('accepts a string Duration', function() {
|
||||
options.scrollTime = '02:00:00';
|
||||
options.height = 400; // short enough to make scrolling happen
|
||||
$('#cal').fullCalendar(options);
|
||||
var slotCell = $('.fc-slats tr:eq(4)'); // 2am slot
|
||||
var slotTop = slotCell.position().top;
|
||||
var scrollContainer = $('.fc-time-grid-container');
|
||||
var scrollTop = scrollContainer.scrollTop();
|
||||
var diff = Math.abs(slotTop - scrollTop);
|
||||
expect(slotTop).toBeGreaterThan(0);
|
||||
expect(scrollTop).toBeGreaterThan(0);
|
||||
expect(diff).toBeLessThan(3);
|
||||
});
|
||||
|
||||
it('accepts a Duration object', function() {
|
||||
options.scrollTime = { hours: 2 };
|
||||
options.height = 400; // short enough to make scrolling happen
|
||||
$('#cal').fullCalendar(options);
|
||||
var slotCell = $('.fc-slats tr:eq(4)'); // 2am slot
|
||||
var slotTop = slotCell.position().top;
|
||||
var scrollContainer = $('.fc-time-grid-container');
|
||||
var scrollTop = scrollContainer.scrollTop();
|
||||
var diff = Math.abs(slotTop - scrollTop);
|
||||
expect(slotTop).toBeGreaterThan(0);
|
||||
expect(scrollTop).toBeGreaterThan(0);
|
||||
expect(diff).toBeLessThan(3);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,185 +0,0 @@
|
||||
describe('select callback', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-05-25',
|
||||
selectable: true
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('#cal').fullCalendar('destroy');
|
||||
});
|
||||
|
||||
[ false, true ].forEach(function(isRTL) {
|
||||
describe('when isRTL is ' + isRTL, function() {
|
||||
beforeEach(function() {
|
||||
options.isRTL = isRTL;
|
||||
});
|
||||
describe('when in month view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'month';
|
||||
});
|
||||
it('gets fired correctly when the user selects cells', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-04-28');
|
||||
expect(end).toEqualMoment('2014-05-07');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-day[data-date="2014-04-28"]').simulate('drag-n-drop', {
|
||||
dropTarget: '.fc-day[data-date="2014-05-06"]',
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
it('gets fired correctly when the user selects just one cell', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-04-28');
|
||||
expect(end).toEqualMoment('2014-04-29');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-day[data-date="2014-04-28"]').simulate('drag-n-drop', {
|
||||
dropTarget: '.fc-day[data-date="2014-04-28"]',
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when in agendaWeek view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'agendaWeek';
|
||||
});
|
||||
describe('when selecting all-day slots', function() {
|
||||
it('gets fired correctly when the user selects cells', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-05-28');
|
||||
expect(end).toEqualMoment('2014-05-30');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-agenda-view .fc-day-grid .fc-day:eq(3)').simulate('drag-n-drop', { // will be 2014-05-28 for LTR and RTL
|
||||
dx: $('.fc-sun').outerWidth() * (isRTL ? -1 : 1), // the width of one column
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
it('gets fired correctly when the user selects a single cell', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-05-28');
|
||||
expect(end).toEqualMoment('2014-05-29');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-agenda-view .fc-day-grid .fc-day:eq(3)').simulate('drag-n-drop', { // will be 2014-05-28 for LTR and RTL
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('when selecting timed slots', function(done) {
|
||||
it('gets fired correctly when the user selects slots', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(true);
|
||||
expect(start).toEqualMoment('2014-05-28T09:00:00');
|
||||
expect(end).toEqualMoment('2014-05-28T10:30:00');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
|
||||
dy: $('.fc-slats tr:eq(18)').outerHeight() * 2, // move down two slots
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
it('gets fired correctly when the user selects slots in a different day', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(true);
|
||||
expect(start).toEqualMoment('2014-05-28T09:00:00');
|
||||
expect(end).toEqualMoment('2014-05-29T10:30:00');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
|
||||
dx: $('.fc-day-header:first').outerWidth() * .9 * (isRTL ? -1 : 1), // one day ahead
|
||||
dy: $('.fc-slats tr:eq(18)').outerHeight() * 2, // move down two slots
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
it('gets fired correctly when the user selects a single slot', function(done) {
|
||||
options.select = function(start, end, jsEvent, view) {
|
||||
expect(moment.isMoment(start)).toEqual(true);
|
||||
expect(moment.isMoment(end)).toEqual(true);
|
||||
expect(typeof jsEvent).toEqual('object'); // TODO: more descrimination
|
||||
expect(typeof view).toEqual('object'); // "
|
||||
expect(start.hasTime()).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(true);
|
||||
expect(start).toEqualMoment('2014-05-28T09:00:00');
|
||||
expect(end).toEqualMoment('2014-05-28T09:30:00');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('.fc-slats tr:eq(18) td:not(.fc-time)').simulate('drag-n-drop', { // middle will be 2014-05-28T09:00:00
|
||||
callback: function() {
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
done();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,198 +0,0 @@
|
||||
describe('select method', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-05-25',
|
||||
selectable: true
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
$('#cal').fullCalendar('destroy');
|
||||
});
|
||||
|
||||
/*
|
||||
THINGS TO IMPLEMENT IN SRC (in addition to notes further down):
|
||||
- better date normalization (for both render and reporting to select callback)
|
||||
- if second date is the same or before the first
|
||||
- if given a mixture of timed/all-day
|
||||
- for basic/month views, when given timed dates, should really be all-day
|
||||
*/
|
||||
|
||||
[ false, true ].forEach(function(isRTL) {
|
||||
describe('when isRTL is ' + isRTL, function() {
|
||||
beforeEach(function() {
|
||||
options.isRTL = isRTL;
|
||||
});
|
||||
describe('when in month view', function() {
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'month';
|
||||
});
|
||||
describe('when called with all-day moments', function() {
|
||||
describe('when in bounds', function() {
|
||||
it('renders a selection', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-07', '2014-05-09');
|
||||
expect($('.fc-highlight')).toBeVisible();
|
||||
});
|
||||
it('renders a selection when called with one argument', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-07');
|
||||
expect($('.fc-highlight')).toBeVisible();
|
||||
});
|
||||
it('fires a selection event', function() {
|
||||
options.select = function(start, end) {
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-05-07');
|
||||
expect(end).toEqualMoment('2014-05-09');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-07', '2014-05-09');
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
describe('when out of bounds', function() {
|
||||
it('doesn\'t render a selection', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2015-05-07', '2015-05-09');
|
||||
expect($('.fc-highlight')).not.toBeVisible();
|
||||
});
|
||||
/*
|
||||
TODO: implement this behavior
|
||||
it('doesn\'t fire a selection event', function() {
|
||||
options.select = function(start, end) {
|
||||
expect(start).toEqualMoment('2014-05-07');
|
||||
expect(end).toEqualMoment('2014-05-09');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2015-05-07', '2015-05-09');
|
||||
expect(options.select).not.toHaveBeenCalled();
|
||||
});
|
||||
*/
|
||||
});
|
||||
});
|
||||
describe('when called with timed moments', function() {
|
||||
it('renders a selection', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-07T06:00:00', '2014-05-09T07:00:00');
|
||||
expect($('.fc-highlight')).toBeVisible();
|
||||
});
|
||||
it('fires a selection event', function() {
|
||||
options.select = function(start, end) {
|
||||
expect(start.hasTime()).toEqual(true);
|
||||
expect(end.hasTime()).toEqual(true);
|
||||
expect(start).toEqualMoment('2014-05-07T06:00:00');
|
||||
expect(end).toEqualMoment('2014-05-09T06:00:00');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-07T06:00:00', '2014-05-09T06:00:00');
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('when in agendaWeek view', function() { // May 25 - 31
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'agendaWeek';
|
||||
options.scrollTime = '01:00:00'; // so that most events will be below the divider
|
||||
options.height = 400; // short enought to make scrolling happen
|
||||
});
|
||||
describe('when called with timed moments', function() {
|
||||
describe('when in bounds', function() {
|
||||
it('renders a selection when called with one argument', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-26T06:00:00');
|
||||
expect($('.fc-highlight')).toBeVisible();
|
||||
});
|
||||
it('renders a selection over the slot area', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-26T06:00:00', '2014-05-26T08:00:00');
|
||||
expect($('.fc-highlight')).toBeVisible();
|
||||
var slotAreaTop = $('.fc-time-grid-container').offset().top;
|
||||
var overlayTop = $('.fc-highlight').offset().top;
|
||||
expect(overlayTop).toBeGreaterThan(slotAreaTop);
|
||||
});
|
||||
});
|
||||
describe('when out of bounds', function() {
|
||||
it('doesn\'t render a selection', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2015-05-26T06:00:00', '2015-05-26T07:00:00');
|
||||
expect($('.fc-highlight')).not.toBeVisible();
|
||||
});
|
||||
/*
|
||||
TODO: implement this behavior
|
||||
it('doesn\'t fire a selection event', function() {
|
||||
options.select = function(start, end) {
|
||||
expect(start).toEqualMoment('2015-05-07T06:00:00');
|
||||
expect(end).toEqualMoment('2015-05-09T07:00:00');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2015-05-07T06:00:00', '2015-05-09T07:00:00');
|
||||
expect(options.select).not.toHaveBeenCalled();
|
||||
});
|
||||
*/
|
||||
});
|
||||
});
|
||||
describe('when called with all-day moments', function() { // forget about in/out bounds for this :)
|
||||
describe('when allDaySlot is on', function() {
|
||||
beforeEach(function() {
|
||||
options.allDaySlot = true;
|
||||
});
|
||||
it('renders a selection over the day area', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-26', '2014-05-28');
|
||||
expect($('.fc-highlight')).toBeVisible();
|
||||
var slotAreaTop = $('.fc-time-grid-container').offset().top;
|
||||
var overlayTop = $('.fc-highlight').offset().top;
|
||||
expect(overlayTop).toBeLessThan(slotAreaTop);
|
||||
});
|
||||
it('fires a selection event', function() {
|
||||
options.select = function(start, end) {
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-05-26');
|
||||
expect(end).toEqualMoment('2014-05-28');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-26', '2014-05-28');
|
||||
expect(options.select).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
describe('when allDaySlot is off', function() {
|
||||
beforeEach(function() {
|
||||
options.allDaySlot = false;
|
||||
});
|
||||
it('doesn\'t render', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-26', '2014-05-28');
|
||||
expect($('.fc-highlight')).not.toBeVisible();
|
||||
});
|
||||
/*
|
||||
TODO: implement
|
||||
it('doesn\'t fire a selection event', function() {
|
||||
options.select = function(start, end) {
|
||||
expect(start.hasTime()).toEqual(false);
|
||||
expect(end.hasTime()).toEqual(false);
|
||||
expect(start).toEqualMoment('2014-05-26');
|
||||
expect(end).toEqualMoment('2014-05-28');
|
||||
};
|
||||
spyOn(options, 'select').and.callThrough();
|
||||
$('#cal').fullCalendar(options);
|
||||
$('#cal').fullCalendar('select', '2014-05-26', '2014-05-28');
|
||||
expect(options.select).not.toHaveBeenCalled();
|
||||
});
|
||||
*/
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,96 +0,0 @@
|
||||
|
||||
describe('slotDuration', function() {
|
||||
|
||||
var minutesInADay = 1440;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when using the default settings', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should have slots 1440/30 slots', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var slotCount = $('.fc-slats tr').length;
|
||||
expect(slotCount).toEqual(Math.ceil(minutesInADay / 30));
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should have slots 1440/30 slots', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var slotCount = $('.fc-slats tr').length;
|
||||
expect(slotCount).toEqual(Math.ceil(minutesInADay / 30));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when slotMinutes is set to 30', function() {
|
||||
describe('in agendaWeek', function() {
|
||||
it('should have slots 1440/30 slots', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var slotCount = $('.fc-slats tr').length;
|
||||
expect(slotCount).toEqual(Math.ceil(minutesInADay / 30));
|
||||
});
|
||||
});
|
||||
describe('in agendaDay', function() {
|
||||
it('should have slots 1440/30 slots', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaDay'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
var slotCount = $('.fc-slats tr').length;
|
||||
expect(slotCount).toEqual(Math.ceil(minutesInADay / 30));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when slotMinutes is set to a series of times', function() {
|
||||
|
||||
var slotMinutesList = [ 10, 12, 15, 17, 20, 30, 35, 45, 60, 62, 120, 300 ];
|
||||
|
||||
describe('in agendaWeek', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
slotMinutesList.forEach(function(slotMinutes) {
|
||||
it('should have slots 1440/x slots', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
slotDuration: { minutes: slotMinutes }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var slotCount = $('.fc-slats tr').length;
|
||||
var expected = Math.ceil(minutesInADay / slotMinutes);
|
||||
expect(slotCount).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('in agendaDay', function() {
|
||||
beforeEach(function() {
|
||||
affix('#cal2');
|
||||
});
|
||||
slotMinutesList.forEach(function(slotMinutes) {
|
||||
it('should have slots 1440/x slots', function() {
|
||||
var options = {
|
||||
defaultView: 'agendaWeek',
|
||||
slotDuration: { minutes: slotMinutes }
|
||||
};
|
||||
$('#cal2').fullCalendar(options);
|
||||
var slotCount = $('.fc-slats tr').length;
|
||||
var expected = Math.ceil(minutesInADay / slotMinutes);
|
||||
expect(slotCount).toEqual(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,65 +0,0 @@
|
||||
describe('themeButtonIcons', function() {
|
||||
|
||||
var options;
|
||||
var defaultSelectors = [
|
||||
'.ui-icon-circle-triangle-w',
|
||||
'.ui-icon-circle-triangle-e',
|
||||
'.ui-icon-seek-prev',
|
||||
'.ui-icon-seek-next'
|
||||
];
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
header: {
|
||||
left: 'prevYear,prev,next,nextYear today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
describe('when theme is off', function() {
|
||||
beforeEach(function() {
|
||||
options.theme = false;
|
||||
});
|
||||
it('should not have any of the default theme icon classes', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
defaultSelectors.forEach(function(selector) {
|
||||
expect($(selector)).not.toBeInDOM();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when theme is on', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.theme = true;
|
||||
});
|
||||
|
||||
it('should have all of the deafult theme icon classes', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
defaultSelectors.forEach(function(selector) {
|
||||
expect($(selector)).toBeInDOM();
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept values that override the individual defaults', function() {
|
||||
options.themeButtonIcons = {
|
||||
prev: 'arrowthickstop-1-w',
|
||||
next: 'arrowthickstop-1-e'
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
[
|
||||
'.ui-icon-arrowthickstop-1-w',
|
||||
'.ui-icon-arrowthickstop-1-e',
|
||||
'.ui-icon-seek-prev', // prev/next year should remain
|
||||
'.ui-icon-seek-next' //
|
||||
]
|
||||
.forEach(function(selector) {
|
||||
expect($(selector)).toBeInDOM();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,68 +0,0 @@
|
||||
describe('timeFormat', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-06-04',
|
||||
events: [ {
|
||||
title: 'my event',
|
||||
start: '2014-06-04T15:00:00',
|
||||
end: '2014-06-04T17:00:00'
|
||||
} ]
|
||||
};
|
||||
});
|
||||
|
||||
function getRenderedEventTime() {
|
||||
return $('.fc-event:first .fc-time').text();
|
||||
}
|
||||
|
||||
describe('when in month view', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'month';
|
||||
});
|
||||
|
||||
it('renders correctly when default', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedEventTime()).toBe('3p');
|
||||
});
|
||||
|
||||
it('renders correctly when default and the language is customized', function() {
|
||||
options.lang = 'en-gb';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedEventTime()).toBe('15');
|
||||
});
|
||||
|
||||
it('renders correctly when customized', function() {
|
||||
options.timeFormat = 'Hh:mm:mm';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedEventTime()).toBe('153:00:00');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when in agendaWeek view', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.defaultView = 'agendaWeek';
|
||||
});
|
||||
|
||||
it('renders correctly when default', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedEventTime()).toBe('3:00 - 5:00');
|
||||
});
|
||||
|
||||
it('renders correctly when default and the language is customized', function() {
|
||||
options.lang = 'en-gb';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedEventTime()).toBe('15:00 - 17:00');
|
||||
});
|
||||
|
||||
it('renders correctly when customized', function() {
|
||||
options.timeFormat = 'Hh:mm:mm';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedEventTime()).toBe('153:00:00 - 175:00:00');
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,113 +0,0 @@
|
||||
|
||||
describe('timezone', function() {
|
||||
|
||||
// NOTE: Only deals with the processing of *received* events.
|
||||
// Verification of a correct AJAX *request* is done in events-json-feed.js
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultView: 'month',
|
||||
defaultDate: '2014-05-01',
|
||||
events: [
|
||||
{
|
||||
id: '1',
|
||||
title: 'all day event',
|
||||
start: '2014-05-02'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
title: 'timed event',
|
||||
start: '2014-05-10T12:00:00'
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
title: 'timed and zoned event',
|
||||
start: '2014-05-10T14:00:00+11:00'
|
||||
}
|
||||
]
|
||||
};
|
||||
});
|
||||
|
||||
it('receives events correctly when no timezone', function(done) {
|
||||
options.eventAfterAllRender = function() {
|
||||
var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0];
|
||||
var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0];
|
||||
expect(allDayEvent.start.hasZone()).toEqual(false);
|
||||
expect(allDayEvent.start.hasTime()).toEqual(false);
|
||||
expect(allDayEvent.start.format()).toEqual('2014-05-02');
|
||||
expect(timedEvent.start.hasZone()).toEqual(false);
|
||||
expect(timedEvent.start.hasTime()).toEqual(true);
|
||||
expect(timedEvent.start.format()).toEqual('2014-05-10T12:00:00');
|
||||
expect(zonedEvent.start.hasZone()).toEqual(true);
|
||||
expect(zonedEvent.start.hasTime()).toEqual(true);
|
||||
expect(zonedEvent.start.format()).toEqual('2014-05-10T14:00:00+11:00');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('receives events correctly when local timezone', function(done) {
|
||||
options.timezone = 'local';
|
||||
options.eventAfterAllRender = function() {
|
||||
var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0];
|
||||
var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0];
|
||||
expect(allDayEvent.start.hasZone()).toEqual(false);
|
||||
expect(allDayEvent.start.hasTime()).toEqual(false);
|
||||
expect(allDayEvent.start.format()).toEqual('2014-05-02');
|
||||
expect(timedEvent.start.hasZone()).toEqual(true);
|
||||
expect(timedEvent.start.hasTime()).toEqual(true);
|
||||
expect(timedEvent.start.zone()).toEqual(new Date(2014, 4, 10, 12).getTimezoneOffset());
|
||||
expect(zonedEvent.start.hasZone()).toEqual(true);
|
||||
expect(zonedEvent.start.hasTime()).toEqual(true);
|
||||
expect(zonedEvent.start.zone()).toEqual(new Date('Sat May 10 2014 14:00:00 GMT+1100').getTimezoneOffset());
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('receives events correctly when UTC timezone', function(done) {
|
||||
options.timezone = 'UTC';
|
||||
options.eventAfterAllRender = function() {
|
||||
var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0];
|
||||
var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0];
|
||||
expect(allDayEvent.start.hasZone()).toEqual(false);
|
||||
expect(allDayEvent.start.hasTime()).toEqual(false);
|
||||
expect(allDayEvent.start.format()).toEqual('2014-05-02');
|
||||
expect(timedEvent.start.hasZone()).toEqual(true);
|
||||
expect(timedEvent.start.hasTime()).toEqual(true);
|
||||
expect(timedEvent.start.format()).toEqual('2014-05-10T12:00:00+00:00');
|
||||
expect(zonedEvent.start.hasZone()).toEqual(true);
|
||||
expect(zonedEvent.start.hasTime()).toEqual(true);
|
||||
expect(zonedEvent.start.format()).toEqual('2014-05-10T03:00:00+00:00');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
it('receives events correctly when custom timezone', function(done) {
|
||||
options.timezone = 'America/Chicago';
|
||||
options.eventAfterAllRender = function() {
|
||||
var allDayEvent = $('#cal').fullCalendar('clientEvents', '1')[0];
|
||||
var timedEvent = $('#cal').fullCalendar('clientEvents', '2')[0];
|
||||
var zonedEvent = $('#cal').fullCalendar('clientEvents', '3')[0];
|
||||
expect(allDayEvent.start.hasZone()).toEqual(false);
|
||||
expect(allDayEvent.start.hasTime()).toEqual(false);
|
||||
expect(allDayEvent.start.format()).toEqual('2014-05-02');
|
||||
expect(timedEvent.start.hasZone()).toEqual(false);
|
||||
expect(timedEvent.start.hasTime()).toEqual(true);
|
||||
expect(timedEvent.start.format()).toEqual('2014-05-10T12:00:00');
|
||||
expect(zonedEvent.start.hasZone()).toEqual(true);
|
||||
expect(zonedEvent.start.hasTime()).toEqual(true);
|
||||
expect(zonedEvent.start.format()).toEqual('2014-05-10T14:00:00+11:00');
|
||||
done();
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,97 +0,0 @@
|
||||
describe('titleFormat', function() {
|
||||
|
||||
var SELECTOR = '.fc-toolbar h2';
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when default', function() {
|
||||
|
||||
var viewWithFormat = [
|
||||
{ view: 'month', expected: 'June 2014' },
|
||||
{ view: 'basicWeek', expected: /Jun 8 - 14,? 2014/ }, // moment changed LL defaults after 2.8
|
||||
{ view: 'agendaWeek', expected: /Jun 8 - 14,? 2014/ }, // "
|
||||
{ view: 'basicDay', expected: /June 12,? 2014/ }, // "
|
||||
{ view: 'agendaDay', expected: /June 12,? 2014/ } // "
|
||||
];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-06-12'
|
||||
});
|
||||
});
|
||||
|
||||
it('should have default values', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(SELECTOR).text()).toMatch(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
describe('when set on a per-view basis', function() {
|
||||
|
||||
var viewWithFormat = [
|
||||
{ view: 'month', expected: '2014, June' },
|
||||
{ view: 'basicWeek', expected: '8 - 14 6 2014' },
|
||||
{ view: 'agendaWeek', expected: '8 - 14, 6, 2014' },
|
||||
{ view: 'basicDay', expected: 'Thursday June 12 2014' },
|
||||
{ view: 'agendaDay', expected: 'Thursday, June, 12, 2014' }
|
||||
];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-06-12',
|
||||
titleFormat: {
|
||||
month: 'YYYY, MMMM',
|
||||
basicWeek: 'D M YYYY',
|
||||
agendaWeek: 'D, M, YYYY',
|
||||
basicDay: 'dddd MMMM D YYYY',
|
||||
agendaDay: 'dddd, MMMM, D, YYYY'
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the correct values', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(SELECTOR).text()).toBe(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
describe('when default and language is French', function() {
|
||||
|
||||
var viewWithFormat = [
|
||||
{ view: 'month', expected: 'juin 2014' },
|
||||
{ view: 'basicWeek', expected: '9 - 15 juin 2014' },
|
||||
{ view: 'agendaWeek', expected: '9 - 15 juin 2014' },
|
||||
{ view: 'basicDay', expected: '12 juin 2014' },
|
||||
{ view: 'agendaDay', expected: '12 juin 2014' }
|
||||
];
|
||||
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2014-06-12',
|
||||
lang: 'fr'
|
||||
});
|
||||
});
|
||||
|
||||
it('should have the translated dates', function() {
|
||||
var cal = $('#cal');
|
||||
|
||||
for (var i = 0; i < viewWithFormat.length; i++) {
|
||||
var crtView = viewWithFormat[i];
|
||||
cal.fullCalendar('changeView', crtView.view);
|
||||
expect(cal.find(SELECTOR).text()).toBe(crtView.expected);
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,485 +0,0 @@
|
||||
|
||||
describe('updateEvent', function() {
|
||||
|
||||
var options;
|
||||
var event;
|
||||
var relatedEvent;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
defaultDate: '2014-05-01',
|
||||
defaultView: 'month'
|
||||
};
|
||||
event = null;
|
||||
relatedEvent = null;
|
||||
});
|
||||
|
||||
function init() {
|
||||
$('#cal').fullCalendar(options);
|
||||
var events = $('#cal').fullCalendar('clientEvents');
|
||||
event = events[0];
|
||||
relatedEvent = events[1];
|
||||
}
|
||||
|
||||
describe('when moving an all-day event\'s start', function() {
|
||||
describe('when a related event doesn\'t have an end', function() {
|
||||
it('should move the start by the delta and leave the end as null', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.start.add(2, 'days');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-03');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-12');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
describe('when a related event has an end', function() {
|
||||
it('should move the start and end by the delta', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-12', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.start.add(2, 'days');
|
||||
expect(event.start).toEqualMoment('2014-05-03');
|
||||
expect(event.end).toBeNull();
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-12');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-14');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when moving an timed event\'s start', function() {
|
||||
describe('when a related event doesn\'t have an end', function() {
|
||||
it('should move the start by the delta and leave the end as null', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T12:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T06:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.start.add({ days: 2, hours: 2 });
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-03T14:00:00');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-12T08:00:00');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
describe('when a related event has an end', function() {
|
||||
it('should move the start and end by the delta', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T12:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T06:00:00', end: '2014-05-12T08:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.start.add({ days: 2, hours: 2 });
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-03T14:00:00');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-12T08:00:00');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-14T10:00:00');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when moving an all-day event\'s end', function() {
|
||||
describe('when a related event doesn\'t have an end', function() {
|
||||
it('should give the end a default duration plus the delta', function() {
|
||||
options.defaultAllDayEventDuration = { days: 2 };
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.end.add(1, 'days');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-01');
|
||||
expect(event.end).toEqualMoment('2014-05-04');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-13');
|
||||
});
|
||||
});
|
||||
describe('when a related event has an end', function() {
|
||||
it('should move the end by the delta', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.end.add(1, 'days');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-01');
|
||||
expect(event.end).toEqualMoment('2014-05-04');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-14');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when moving a timed event\'s end', function() {
|
||||
describe('when a related event doesn\'t have an end', function() {
|
||||
describe('when forceEventDuration is off', function() {
|
||||
it('should give the end a default duration plus the delta', function() {
|
||||
options.forceEventDuration = false;
|
||||
options.defaultTimedEventDuration = { hours: 2 };
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T12:00:00', end: '2014-05-01T15:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T16:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.end.add({ days: 1, hours: 1 });
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-01T12:00:00');
|
||||
expect(event.end).toEqualMoment('2014-05-02T16:00:00');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10T16:00:00');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-11T19:00:00');
|
||||
});
|
||||
});
|
||||
describe('when forceEventDuration is on', function() {
|
||||
it('should give the end a default duration plus the delta', function() {
|
||||
options.forceEventDuration = true;
|
||||
options.defaultTimedEventDuration = { hours: 2 };
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T12:00:00', end: '2014-05-01T15:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T16:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.end.add({ days: 1, hours: 1 });
|
||||
relatedEvent.end = null;
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-01T12:00:00');
|
||||
expect(event.end).toEqualMoment('2014-05-02T16:00:00');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10T16:00:00');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-11T19:00:00');
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('when a related event has an end', function() {
|
||||
it('should move the end by the delta', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T12:00:00', end: '2014-05-01T14:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T16:00:00', end: '2014-05-10T19:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.end.add({ days: 1, hours: 1 });
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-01T12:00:00');
|
||||
expect(event.end).toEqualMoment('2014-05-02T15:00:00');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10T16:00:00');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-11T20:00:00');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when moving an all-day event\'s start and end', function() {
|
||||
it('should move the start and end of related events', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.start.add(2, 'days');
|
||||
event.end.add(3, 'day');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-03');
|
||||
expect(event.end).toEqualMoment('2014-05-06');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-12');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-16');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when moving a timed event\'s start and end', function() {
|
||||
it('should move the start and end of related events', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00', end: '2014-05-03T06:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T06:00:00', end: '2014-05-13T06:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.start.add({ days: 2, hours: 1 });
|
||||
event.end.add({ days: 3, hours: 2 });
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.start).toEqualMoment('2014-05-03T07:00:00');
|
||||
expect(event.end).toEqualMoment('2014-05-06T08:00:00');
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-12T07:00:00');
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-16T08:00:00');
|
||||
});
|
||||
});
|
||||
|
||||
describe('when giving a time to an all-day event\'s start', function() {
|
||||
it('should make the event and related events timed', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.start.time('18:00');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(false);
|
||||
expect(event.start).toEqualMoment('2014-05-01T18:00:00');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.allDay).toEqual(false);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10T18:00:00');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('when changing an event from all-day to timed', function() {
|
||||
describe('when the event\'s dates remain all-day', function() {
|
||||
it('should make the event and related events allDay=false and 00:00', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.allDay = false;
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(false);
|
||||
expect(event.start).toEqualMoment('2014-05-01T00:00:00');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.allDay).toEqual(false);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10T00:00:00');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
describe('when the event\'s dates are set to a time', function() {
|
||||
it('should adjust the event and related event\'s allDay/start/end', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.allDay = false;
|
||||
event.start.time('14:00');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(false);
|
||||
expect(event.start).toEqualMoment('2014-05-01T14:00:00');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.allDay).toEqual(false);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10T14:00:00');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
describe('when the event\'s start is also moved', function() {
|
||||
it('should adjust the event and related event\'s allDay/start/end', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-10', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.allDay = false;
|
||||
event.start.add(1, 'days');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(false);
|
||||
expect(event.start).toEqualMoment('2014-05-02T00:00:00');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.allDay).toEqual(false);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-11T00:00:00');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when changing an event from timed to all-day', function() {
|
||||
it('should adjust the event and related event\'s allDay/start/end', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00', end: '2014-05-03T06:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T06:00:00', end: '2014-05-13T06:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.allDay = true;
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(true);
|
||||
expect(event.start).toEqualMoment('2014-05-01');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.allDay).toEqual(true);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-10');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
it('should adjust the event and related event\'s allDay/start/end and account for a new start', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00', end: '2014-05-03T06:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T06:00:00', end: '2014-05-13T06:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.allDay = true;
|
||||
event.start.add(1, 'days');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(true);
|
||||
expect(event.start).toEqualMoment('2014-05-02');
|
||||
expect(event.end).toBeNull();
|
||||
expect(relatedEvent.allDay).toEqual(true);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-11');
|
||||
expect(relatedEvent.end).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('should accept moments that have unnormalized start/end', function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00', end: '2014-05-03T06:00:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-10T06:00:00', end: '2014-05-13T06:00:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.start = '2014-05-02T06:00:00'; // move by 1 day
|
||||
event.end = '2014-05-05T06:00:00'; // increase duration by 1 day
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
expect(event.allDay).toEqual(false);
|
||||
expect(moment.isMoment(event.start)).toEqual(true);
|
||||
expect(event.start).toEqualMoment('2014-05-02T06:00:00');
|
||||
expect(moment.isMoment(event.end)).toEqual(true);
|
||||
expect(event.end).toEqualMoment('2014-05-05T06:00:00');
|
||||
expect(relatedEvent.allDay).toEqual(false);
|
||||
expect(moment.isMoment(relatedEvent.start)).toEqual(true);
|
||||
expect(relatedEvent.start).toEqualMoment('2014-05-11T06:00:00');
|
||||
expect(moment.isMoment(relatedEvent.end)).toEqual(true);
|
||||
expect(relatedEvent.end).toEqualMoment('2014-05-15T06:00:00');
|
||||
});
|
||||
|
||||
function whenMovingStart(should) {
|
||||
describe('when moving an timed event\'s start', function() {
|
||||
beforeEach(function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00+05:00', end: '2014-05-03T06:00:00+05:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.start.add(2, 'hours');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
});
|
||||
should();
|
||||
});
|
||||
}
|
||||
|
||||
function whenMovingEnd(should) {
|
||||
describe('when moving a timed event\'s end', function() {
|
||||
beforeEach(function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00+05:00', end: '2014-05-03T06:00:00+05:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
event.end.add(2, 'hours');
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
});
|
||||
should();
|
||||
});
|
||||
}
|
||||
|
||||
function whenMovingToTimed(should) {
|
||||
describe('when moving an all-day event to timed', function() {
|
||||
beforeEach(function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01', end: '2014-05-03', allDay: true },
|
||||
{ id: '1', start: '2014-05-11', end: '2014-05-13', allDay: true }
|
||||
];
|
||||
init();
|
||||
event.allDay = false;
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
});
|
||||
should();
|
||||
});
|
||||
}
|
||||
|
||||
function whenReportingUnchanged(should) { // not used right now
|
||||
describe('when reporting an event that hasn\'t changed', function() {
|
||||
beforeEach(function() {
|
||||
options.events = [
|
||||
{ id: '1', start: '2014-05-01T06:00:00+05:00', end: '2014-05-03T06:00:00+05:00', allDay: false },
|
||||
{ id: '1', start: '2014-05-11T06:00:00+05:00', end: '2014-05-13T06:00:00+05:00', allDay: false }
|
||||
];
|
||||
init();
|
||||
$('#cal').fullCalendar('updateEvent', event);
|
||||
});
|
||||
should();
|
||||
});
|
||||
}
|
||||
|
||||
function shouldBeAmbiguouslyZoned() {
|
||||
it('should make the events ambiguously zoned', function() {
|
||||
expect(event.start.hasZone()).toEqual(false);
|
||||
if (event.end) {
|
||||
expect(event.end.hasZone()).toEqual(false);
|
||||
}
|
||||
expect(relatedEvent.start.hasZone()).toEqual(false);
|
||||
if (relatedEvent.end) {
|
||||
expect(relatedEvent.end.hasZone()).toEqual(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function shouldBeLocal() {
|
||||
it('should make the events local', function() {
|
||||
expect(event.start.hasZone()).toEqual(true);
|
||||
expect(event.start._isUTC).toEqual(false);
|
||||
if (event.end) {
|
||||
expect(event.end.hasZone()).toEqual(true);
|
||||
expect(event.end._isUTC).toEqual(false);
|
||||
}
|
||||
expect(relatedEvent.start.hasZone()).toEqual(true);
|
||||
expect(relatedEvent.start._isUTC).toEqual(false);
|
||||
if (relatedEvent.end) {
|
||||
expect(relatedEvent.end.hasZone()).toEqual(true);
|
||||
expect(relatedEvent.end._isUTC).toEqual(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function shouldBeUTC() {
|
||||
it('should make the events UTC', function() {
|
||||
expect(event.start.hasZone()).toEqual(true);
|
||||
expect(event.start._isUTC).toEqual(true);
|
||||
if (event.end) {
|
||||
expect(event.end.hasZone()).toEqual(true);
|
||||
expect(event.end._isUTC).toEqual(true);
|
||||
}
|
||||
expect(event.start.hasZone()).toEqual(true);
|
||||
expect(event.start._isUTC).toEqual(true);
|
||||
if (relatedEvent.end) {
|
||||
expect(relatedEvent.end.hasZone()).toEqual(true);
|
||||
expect(relatedEvent.end._isUTC).toEqual(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
describe('when calendar has no timezone', function() {
|
||||
beforeEach(function() {
|
||||
options.timezone = false;
|
||||
});
|
||||
whenMovingStart(shouldBeAmbiguouslyZoned);
|
||||
whenMovingEnd(shouldBeAmbiguouslyZoned);
|
||||
whenMovingToTimed(shouldBeAmbiguouslyZoned);
|
||||
});
|
||||
|
||||
describe('when calendar has a local timezone', function() {
|
||||
beforeEach(function() {
|
||||
options.timezone = 'local';
|
||||
});
|
||||
whenMovingStart(shouldBeLocal);
|
||||
whenMovingEnd(shouldBeLocal);
|
||||
whenMovingToTimed(shouldBeLocal);
|
||||
});
|
||||
|
||||
describe('when calendar has a UTC timezone', function() {
|
||||
beforeEach(function() {
|
||||
options.timezone = 'UTC';
|
||||
});
|
||||
whenMovingStart(shouldBeUTC);
|
||||
whenMovingEnd(shouldBeUTC);
|
||||
whenMovingToTimed(shouldBeUTC);
|
||||
});
|
||||
|
||||
describe('when calendar has a custom timezone', function() {
|
||||
beforeEach(function() {
|
||||
options.timezone = 'America/Chicago';
|
||||
});
|
||||
whenMovingStart(shouldBeAmbiguouslyZoned);
|
||||
whenMovingEnd(shouldBeAmbiguouslyZoned);
|
||||
whenMovingToTimed(shouldBeAmbiguouslyZoned);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,169 +0,0 @@
|
||||
|
||||
describe('weekMode', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when weekMode is default', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar();
|
||||
});
|
||||
it('should show 6 weeks for a 5 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should show 6 weeks for a 4 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-03-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should show 6 weeks for a 6 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should not change height whether 4,5 or weeks', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-02-01');
|
||||
var fourWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var fiveWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var sixWeekHeight = $('.fc-week:first').outerHeight();
|
||||
expect(fourWeekHeight).toBeGreaterThan(0);
|
||||
expect(fiveWeekHeight).toBeGreaterThan(0);
|
||||
expect(sixWeekHeight).toBeGreaterThan(0);
|
||||
expect(fourWeekHeight).toEqual(fiveWeekHeight);
|
||||
expect(fiveWeekHeight).toEqual(sixWeekHeight);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when weekMode is set to fixed', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
weekMode: 'fixed'
|
||||
});
|
||||
});
|
||||
it('should show 6 weeks for a 5 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should show 6 weeks for a 4 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-03-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should show 6 weeks for a 6 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when weekMode is set to liquid', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
weekMode: 'liquid'
|
||||
});
|
||||
});
|
||||
it('should show 5 weeks for a 5 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(5);
|
||||
});
|
||||
it('should show 4 weeks for a 4 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-02-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(4);
|
||||
});
|
||||
it('should show 6 weeks for a 6 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should increase height when moving from 6 week to 5 weeks', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var fiveWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var sixWeekHeight = $('.fc-week:first').outerHeight();
|
||||
expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
|
||||
});
|
||||
it('should reduce height when moving from 5 weeks to 6 weeks', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var sixWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var fiveWeekHeight = $('.fc-week:first').outerHeight();
|
||||
expect(fiveWeekHeight).toBeGreaterThan(sixWeekHeight);
|
||||
});
|
||||
it('should increase height when moving from 5 weeks to 4 weeks', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-05-01');
|
||||
var fiveWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2009-02-01');
|
||||
var fourWeekHeight = $('.fc-week:first').outerHeight();
|
||||
expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
|
||||
});
|
||||
it('should reduce height when moving from 4 weeks to 5 weeks', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-02-01');
|
||||
var fourWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-05-01');
|
||||
var fiveWeekHeight = $('.fc-week:first').outerHeight();
|
||||
expect(fourWeekHeight).toBeGreaterThan(fiveWeekHeight);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not display an empty week when no visible days and weekMode is set to liquid', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday!
|
||||
weekMode: 'liquid',
|
||||
weekends: false
|
||||
});
|
||||
expect($('.fc-week').length).toBe(4);
|
||||
});
|
||||
|
||||
describe('when weekMode is set to variable', function() {
|
||||
beforeEach(function() {
|
||||
$('#cal').fullCalendar({
|
||||
weekMode: 'variable'
|
||||
});
|
||||
});
|
||||
it('should show 5 weeks for a 5 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(5);
|
||||
});
|
||||
it('should show 4 weeks for a 4 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-02-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(4);
|
||||
});
|
||||
it('should show 6 weeks for a 6 week month', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var weekCount = $('.fc-week').length;
|
||||
expect(weekCount).toEqual(6);
|
||||
});
|
||||
it('should not change height whether 4,5 or weeks', function() {
|
||||
$('#cal').fullCalendar('gotoDate', '2009-02-01');
|
||||
var fourWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-10-01');
|
||||
var fiveWeekHeight = $('.fc-week:first').outerHeight();
|
||||
$('#cal').fullCalendar('gotoDate', '2013-06-01');
|
||||
var sixWeekHeight = $('.fc-week:first').outerHeight();
|
||||
expect(fourWeekHeight).toBeGreaterThan(0);
|
||||
expect(fiveWeekHeight).toBeGreaterThan(0);
|
||||
expect(sixWeekHeight).toBeGreaterThan(0);
|
||||
expect(fourWeekHeight).toEqual(fiveWeekHeight);
|
||||
expect(fiveWeekHeight).toEqual(sixWeekHeight);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not display an empty week when no visible days and weekMode is set to variable', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultDate: '2013-06-01', // June 2013 has first day as Saturday, and last as Sunday!
|
||||
weekMode: 'variable',
|
||||
weekends: false
|
||||
});
|
||||
expect($('.fc-week').length).toBe(4);
|
||||
});
|
||||
});
|
||||
@@ -1,68 +0,0 @@
|
||||
|
||||
describe('weekNumberCalculation', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
options = {
|
||||
weekNumbers: true
|
||||
};
|
||||
});
|
||||
|
||||
function getRenderedWeekNumber() {
|
||||
// works for both kinds of views
|
||||
var text = $('.fc-agenda-view .fc-week-number, .fc-week:first .fc-content-skeleton .fc-week-number').text();
|
||||
return parseInt(text.replace(/\D/g, ''), 10);
|
||||
}
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
[ 'basicDay', 'agendaDay' ].forEach(function(viewType) {
|
||||
describe('when in ' + viewType + ' view', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.defaultView = viewType;
|
||||
});
|
||||
|
||||
it('should display the American standard when using \'local\'', function() {
|
||||
options.defaultDate = '2013-11-23'; // a Saturday
|
||||
options.weekNumberCalculation = 'local';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumber()).toBe(47);
|
||||
});
|
||||
|
||||
it('should display a language-specific local week number', function() {
|
||||
options.defaultDate = '2013-11-23'; // a Saturday
|
||||
options.lang = 'ar';
|
||||
options.weekNumberCalculation = 'local';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumber()).toBe(48);
|
||||
});
|
||||
|
||||
// another local test, but to make sure it is different from ISO
|
||||
it('should display the American standard when using \'local\'', function() {
|
||||
options.defaultDate = '2013-11-17'; // a Sunday
|
||||
options.weekNumberCalculation = 'local';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumber()).toBe(47);
|
||||
});
|
||||
|
||||
it('should display ISO standard when using \'ISO\'', function() {
|
||||
options.defaultDate = '2013-11-17'; // a Sunday
|
||||
options.weekNumberCalculation = 'ISO';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumber()).toBe(46);
|
||||
});
|
||||
|
||||
it('should display the calculated number when a custom function', function() {
|
||||
options.weekNumberCalculation = function() {
|
||||
return 4;
|
||||
};
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumber()).toBe(4);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,51 +0,0 @@
|
||||
describe('weekNumberTitle', function() {
|
||||
|
||||
var options;
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
options = {
|
||||
weekNumbers: true
|
||||
};
|
||||
});
|
||||
|
||||
function getRenderedWeekNumberTitle() {
|
||||
// works for both kinds of views
|
||||
var text = $('th.fc-week-number').text();
|
||||
return text.replace(/\d/g, '');
|
||||
}
|
||||
|
||||
[ 'basicWeek', 'agendaWeek' ].forEach(function(viewName) {
|
||||
describe('when views is ' + viewName, function() {
|
||||
|
||||
beforeEach(function() {
|
||||
options.defaultView = viewName;
|
||||
});
|
||||
|
||||
it('renders correctly by default', function() {
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumberTitle()).toBe('W');
|
||||
});
|
||||
|
||||
it('renders correctly when unspecified and when language is customized', function() {
|
||||
options.lang = 'es';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumberTitle()).toBe('Sm');
|
||||
});
|
||||
|
||||
it('renders correctly when customized and LTR', function() {
|
||||
options.isRTL = false;
|
||||
options.weekNumberTitle = 'YO';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumberTitle()).toBe('YO');
|
||||
});
|
||||
|
||||
it('renders correctly when customized and RTL', function() {
|
||||
options.isRTL = true;
|
||||
options.weekNumberTitle = 'YO';
|
||||
$('#cal').fullCalendar(options);
|
||||
expect(getRenderedWeekNumberTitle()).toBe('YO');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,118 +0,0 @@
|
||||
|
||||
describe('weekNumbers', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#cal');
|
||||
});
|
||||
|
||||
describe('when using month view', function() {
|
||||
|
||||
describe('when using default weekNumbers', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'month'
|
||||
});
|
||||
var weekNumbersCount = $('.fc-content-skeleton thead .fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting weekNumbers to false', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'month',
|
||||
weekNumbers: false
|
||||
});
|
||||
var weekNumbersCount = $('.fc-content-skeleton thead .fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when setting weekNumbers to true', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'month',
|
||||
weekNumbers: true,
|
||||
weekMode: 'fixed' // will make 6 rows
|
||||
});
|
||||
var weekNumbersCount = $('.fc-content-skeleton thead .fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(6);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when using basicWeek view', function() {
|
||||
|
||||
describe('with default weekNumbers ', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'basicWeek'
|
||||
});
|
||||
var weekNumbersCount = $('.fc-content-skeleton thead .fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with weekNumbers to false', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'basicWeek',
|
||||
weekNumbers: false
|
||||
});
|
||||
var weekNumbersCount = $('.fc-content-skeleton thead .fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with weekNumbers to true', function() {
|
||||
it('should display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'basicWeek',
|
||||
weekNumbers: true
|
||||
});
|
||||
var weekNumbersCount = $('.fc-content-skeleton thead .fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when using an agenda view', function() {
|
||||
|
||||
describe('with default weekNumbers', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'agendaWeek'
|
||||
});
|
||||
var weekNumbersCount = $('.fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with weekNumbers to false', function() {
|
||||
it('should not display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'agendaWeek',
|
||||
weekNumbers: false
|
||||
});
|
||||
var weekNumbersCount = $('.fc-week-number').length;
|
||||
expect(weekNumbersCount).toEqual(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with weekNumbers to true', function() {
|
||||
it('should display weekNumbers', function() {
|
||||
$('#cal').fullCalendar({
|
||||
defaultView: 'agendaWeek',
|
||||
weekNumbers: true
|
||||
});
|
||||
var weekNumbersCount = $('.fc-week-number').length;
|
||||
// 1 row is axis
|
||||
expect(weekNumbersCount).toEqual(1);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
describe('when weekends option is set', function() {
|
||||
|
||||
beforeEach(function() {
|
||||
affix('#calendar');
|
||||
});
|
||||
|
||||
it('should show sat and sun if true', function() {
|
||||
var options = {
|
||||
weekends: true
|
||||
};
|
||||
$('#calendar').fullCalendar(options);
|
||||
var sun = $('.fc-day-header.fc-sun')[0];
|
||||
var sat = $('.fc-day-header.fc-sun')[0];
|
||||
expect(sun).toBeDefined();
|
||||
expect(sat).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not show sat and sun if false', function() {
|
||||
var options = {
|
||||
weekends: false
|
||||
};
|
||||
$('#calendar').fullCalendar(options);
|
||||
var sun = $('.fc-day-header.fc-sun')[0];
|
||||
var sat = $('.fc-day-header.fc-sun')[0];
|
||||
expect(sun).not.toBeDefined();
|
||||
expect(sat).not.toBeDefined();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,12 +0,0 @@
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
year: 2010,
|
||||
month: 0,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: {
|
||||
url: "many_events_json.txt",
|
||||
data: function() {
|
||||
var custom_data = { q: 'custom data value' }; // should see this in Networking
|
||||
console.log('setting custom_data as part of the eventSource fetch');
|
||||
return custom_data;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,14 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../lib/moment/min/langs.min.js'></script>
|
||||
<script>fc = {}</script>
|
||||
<script src='../src/util.js'></script>
|
||||
<script src='../src/moment-ext.js'></script>
|
||||
<script src='../src/date-formatting.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,108 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
dayRender: function(date, td) {
|
||||
//console.log(date, td);
|
||||
td.find('.fc-day-content').prepend('this is the ' + date.getDate());
|
||||
},
|
||||
|
||||
dayClick: function(date, allDay) {
|
||||
console.log(date, allDay);
|
||||
},
|
||||
weekNumbers: true,
|
||||
//selectable: true,
|
||||
//isRTL: true,
|
||||
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 5),
|
||||
end: new Date(y, m, d, 14, 43),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,101 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
eventRender: function(event, element) {
|
||||
element.bind('dblclick', function() {
|
||||
alert('double click!');
|
||||
});
|
||||
// alert shows up in linux chrome, but messes up draggable
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 5),
|
||||
end: new Date(y, m, d, 14, 43),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,75 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
|
||||
<script src='../build/out/jquery.js'></script>
|
||||
<script src='../build/out/jquery-ui.js'></script>
|
||||
<script src='../build/out/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
defaultView: 'resourceDay',
|
||||
editable: true,
|
||||
eventDrop: function (event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) {
|
||||
var resourceNames = '';
|
||||
for (var i = 0; i < event.resources.length; i++) {
|
||||
var resources = $.grep(view.getResources, function (r) { return r.id == event.resources[i]; });
|
||||
for (var resourceIndex = 0; resourceIndex < resources.length; resourceIndex++) {
|
||||
resourceNames += resources[resourceIndex].name + ' ';
|
||||
}
|
||||
}
|
||||
alert(resourceNames);
|
||||
},
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'resourceDay'
|
||||
},
|
||||
resources: [{ 'id': 'resource1', 'name': 'Resource 1' }, { 'id': 'resource2', 'name': 'Resource 2' }, { 'id': 'resource3', 'name': 'Resource 3' }],
|
||||
events: [
|
||||
{
|
||||
title: 'R1: breakfast',
|
||||
start: new Date(y, m, d, 09, 00),
|
||||
end: new Date(y, m, d, 09, 30),
|
||||
allDay: false,
|
||||
resources: ['resource1']
|
||||
},
|
||||
{
|
||||
title: 'R1: All day',
|
||||
start: new Date(y, m, d, 08, 30),
|
||||
end: new Date(y, m, d, 09, 00),
|
||||
allDay: true,
|
||||
resources: 'resource1'
|
||||
},
|
||||
{
|
||||
title: 'R1 & R2: Lunch',
|
||||
start: new Date(y, m, d, 12, 30),
|
||||
end: new Date(y, m, d, 13, 00),
|
||||
allDay: false,
|
||||
resources: ['resource1', 'resource2']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,167 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
editable: true,
|
||||
droppable: true,
|
||||
drop: function(date, allDay, ev) {
|
||||
console.log('drop', date, allDay, ev);
|
||||
},
|
||||
//defaultView: 'agendaWeek',
|
||||
|
||||
//firstDay: 1,
|
||||
//hiddenDays: [ 4, 6 ], // hide thursday and saturday
|
||||
//isRTL: true,
|
||||
//minTime: '6:30am',
|
||||
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 5),
|
||||
end: new Date(y, m, d, 14, 43),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$('.external-event').draggable({
|
||||
revert: true,
|
||||
revertDuration: 0,
|
||||
zIndex: 999
|
||||
});
|
||||
|
||||
$('#calendar2').fullCalendar({
|
||||
//isRTL: true,
|
||||
droppable: true,
|
||||
dropAccept: '.for-calendar2',
|
||||
/*
|
||||
dropAccept: function(e) {
|
||||
console.log(e);
|
||||
console.log(this);
|
||||
return e.text() == 'Draggable 1';
|
||||
},
|
||||
*/
|
||||
drop: function(date, allDay) {
|
||||
console.log('drop 2nd calendar', date, allDay);
|
||||
},
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#external-events {
|
||||
position: relative;
|
||||
left: 50px;
|
||||
text-align: left;
|
||||
float: left;
|
||||
width: 140px;
|
||||
padding: 10px;
|
||||
border: 1px solid #aaa;
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.external-event {
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
color: #fff;
|
||||
background: blue;
|
||||
margin-bottom: 10px;
|
||||
padding-left: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#calendar2 {
|
||||
width: 900px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
<div id='external-events'>
|
||||
<div class='external-event'>Draggable 1</div>
|
||||
<div class='external-event'>Draggable 2</div>
|
||||
<div class='external-event for-calendar2'>Draggable 3</div>
|
||||
</div>
|
||||
<div style='clear:both'></div>
|
||||
<div id='calendar2'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,107 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../build/out/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../build/out/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../build/out/jquery.js'></script>
|
||||
<script src='../build/out/jquery-ui.js'></script>
|
||||
<script src='../build/out/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
defaultView: 'resourceDay',
|
||||
editable: true,
|
||||
droppable: true,
|
||||
drop: function (dt, allDay, ev, ui, view) {
|
||||
console.log('drop', dt, allDay, ev);
|
||||
},
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
resources: [{ 'id': 'resource1', 'name': 'Resource 1' }, { 'id': 'resource2', 'name': 'Resource 2' }, { 'id': 'resource3', 'name': 'Resource 3' }],
|
||||
events: [
|
||||
{
|
||||
title: 'R1: breakfast',
|
||||
start: new Date(y, m, d, 09, 00),
|
||||
end: new Date(y, m, d, 09, 30),
|
||||
allDay: false,
|
||||
resources: ['resource1']
|
||||
},
|
||||
{
|
||||
title: 'R1: All day',
|
||||
start: new Date(y, m, d, 08, 30),
|
||||
end: new Date(y, m, d, 09, 00),
|
||||
allDay: true,
|
||||
resources: 'resource1'
|
||||
},
|
||||
{
|
||||
title: 'R1 & R2: Lunch',
|
||||
start: new Date(y, m, d, 12, 30),
|
||||
end: new Date(y, m, d, 13, 00),
|
||||
allDay: false,
|
||||
resources: ['resource1', 'resource2']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$('.external-event').draggable({
|
||||
revert: true,
|
||||
revertDuration: 0,
|
||||
zIndex: 999
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
#external-events {
|
||||
position: relative;
|
||||
left: 50px;
|
||||
text-align: left;
|
||||
float: left;
|
||||
width: 140px;
|
||||
padding: 10px;
|
||||
border: 1px solid #aaa;
|
||||
background: #ccc;
|
||||
}
|
||||
|
||||
.external-event {
|
||||
height: 20px;
|
||||
line-height: 20px;
|
||||
color: #fff;
|
||||
background: blue;
|
||||
margin-bottom: 10px;
|
||||
padding-left: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
<div id='external-events'>
|
||||
<div class='external-event'>Draggable 1</div>
|
||||
<div class='external-event'>Draggable 2</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,109 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
|
||||
eventDataTransform: function(event) {
|
||||
var copy = $.extend({}, event);
|
||||
copy.title += "*";
|
||||
return copy;
|
||||
},
|
||||
events: {
|
||||
eventDataTransform: function(event) {
|
||||
var copy = $.extend({}, event);
|
||||
copy.title += "!";
|
||||
return copy;
|
||||
},
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 5),
|
||||
end: new Date(y, m, d, 14, 43),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,106 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 5),
|
||||
end: new Date(y, m, d, 14, 43),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
],
|
||||
weekMode: 'liquid',
|
||||
height: calcCalendarHeight()
|
||||
});
|
||||
|
||||
function calcCalendarHeight() {
|
||||
var h = $(window).height() - 40;
|
||||
console.log(h);
|
||||
return h;
|
||||
}
|
||||
|
||||
$(window).resize(function() {
|
||||
$('#calendar').fullCalendar('option', 'height', calcCalendarHeight());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin: 20px 200px 20px 20px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,62 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script src='../dist/gcal.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#calendar').fullCalendar({
|
||||
weekends: false,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
//editable: true,
|
||||
eventSources: [
|
||||
{
|
||||
url: "http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic",
|
||||
editable: true,
|
||||
className: 'holiday'
|
||||
},
|
||||
/*
|
||||
$.fullCalendar.gcalFeed(
|
||||
"http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic",
|
||||
{
|
||||
editable: true,
|
||||
className: 'holiday'
|
||||
}
|
||||
),
|
||||
*/
|
||||
{
|
||||
url: "https://www.google.com/calendar/feeds/ht3jlfaac5lfd6263ulfh4tql8%40group.calendar.google.com/public/basic",
|
||||
currentTimezone: 'America/Edmonton', // 'America/Los_Angeles' 'America/Los Angeles'
|
||||
editable: true
|
||||
}
|
||||
],
|
||||
eventClick: function(event) {
|
||||
console.log(event.start);
|
||||
console.log(event.end);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
.holiday * {
|
||||
color: yellow !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body style='font-size:12px'>
|
||||
<div id='calendar' style='width:900px;margin:20px auto 0;font-family:arial'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
|
||||
year: 2013,
|
||||
month: 6, // july
|
||||
|
||||
//weekNumbers: true,
|
||||
isRTL: true,
|
||||
//selectable: true,
|
||||
//firstDay: 2,
|
||||
//weekends: false,
|
||||
hiddenDays: [ 4 ], // thursday
|
||||
|
||||
events: [
|
||||
{
|
||||
title: '1 Day',
|
||||
start: new Date(2013, 6, 17)
|
||||
},
|
||||
{
|
||||
title: '2 Day',
|
||||
start: new Date(2013, 6, 17),
|
||||
end: new Date(2013, 6, 18)
|
||||
},
|
||||
{
|
||||
title: '3 Day',
|
||||
start: new Date(2013, 6, 17),
|
||||
end: new Date(2013, 6, 19)
|
||||
},
|
||||
{
|
||||
title: '1 Day IN GAP',
|
||||
start: new Date(2013, 6, 18) // won't be visible
|
||||
}
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel='stylesheet' href='lib/fancybox/jquery.fancybox-1.3.4.css' />
|
||||
<script src='lib/jquery-1.4.3.min.js'></script>
|
||||
<script src='lib/fancybox/jquery.fancybox-1.3.4.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#fullcalendar-link').fancybox({
|
||||
width: 1100,
|
||||
height: 800
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id='content'>
|
||||
|
||||
<h1>FancyBox <em>v1.2.6</em></h1>
|
||||
|
||||
<p>
|
||||
<a id='fullcalendar-link' class='iframe' href='plain.html'>Open a FullCalendar</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,81 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
a {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="tests"></div>
|
||||
<script>
|
||||
var tests = [
|
||||
'data_as_a_function.html',
|
||||
'day_render.html',
|
||||
'dbclick.html',
|
||||
'droppable.html',
|
||||
'event_data_transform.html',
|
||||
'fullheight.html',
|
||||
'gcal.html',
|
||||
'hiddenDays.html',
|
||||
'iframe.html',
|
||||
'issue_206_parseDate_dst.html',
|
||||
'issue_220_buttons_ie6.html',
|
||||
'issue_221_quick_remove_source.html',
|
||||
'issue_230_height_json_events.html',
|
||||
'issue_244_aspectRatio_0.html',
|
||||
'issue_251_empty_end_date.html',
|
||||
'issue_333_blinking.html',
|
||||
'issue_417_refetchEvents.html',
|
||||
'issue_429_gotoDate.html',
|
||||
'issue_477_event_width.html',
|
||||
'issue_517_js_error_ie.html',
|
||||
'issue_554.html',
|
||||
'issue_586_refetchEvents.html',
|
||||
'issue_616.html',
|
||||
'issue_679.html',
|
||||
'issue_688_parseInt.html',
|
||||
'issue_740_event_resizing.html',
|
||||
'issue_750.html',
|
||||
'issue_757_removeEvents.html',
|
||||
'liquidwidth.html',
|
||||
'locale.html',
|
||||
'long_event_titles.html',
|
||||
'many_agenda_events.html',
|
||||
'many_events.html',
|
||||
'method_destroy.html',
|
||||
'methods.html',
|
||||
'no_event_titles.html',
|
||||
'options.html',
|
||||
'past_future_classNames.html',
|
||||
'plain.html',
|
||||
'resourceDayView.html',
|
||||
'selectable.html',
|
||||
'short_agenda.html',
|
||||
'skip-redraw-test.html',
|
||||
'snap.html',
|
||||
'sources.html',
|
||||
'sources_new.html',
|
||||
'stacking.html',
|
||||
'tabs.html',
|
||||
'theming.html',
|
||||
'triggers.html',
|
||||
'triggers_view.html',
|
||||
'week_numbers.html'
|
||||
];
|
||||
|
||||
var html = '';
|
||||
var div = document.getElementById('tests');
|
||||
for(var i = 0; i < tests.length; i++){
|
||||
var a = document.createElement('a');
|
||||
a.href = tests[i];
|
||||
a.innerHTML = tests[i];
|
||||
div.appendChild(a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,106 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
defaultView: 'agendaWeek',
|
||||
selectable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 5),
|
||||
end: new Date(y, m, d, 14, 43),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.fc-agenda-slots td div {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>The selection box for selecting agenda slot cells should align to the grid.</p>
|
||||
<p>(even though <code>.fc-agenda-slots td div</code> has been set to 10px tall)</p>
|
||||
|
||||
<div id='calendar'></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,68 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
defaultView: 'agendaWeek',
|
||||
defaultDate: '2013-08-01',
|
||||
scrollTime: '00:00',
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: '2013-08-01'
|
||||
}
|
||||
],
|
||||
eventDrop: function(event, delta, revertFunc) {
|
||||
if (!confirm('Move event?')) {
|
||||
revertFunc();
|
||||
}
|
||||
else {
|
||||
alert(
|
||||
'delta (days/hours/minutes) is ' +
|
||||
Math.floor(delta.asDays()) + '/' +
|
||||
delta.hours() + '/' +
|
||||
delta.minutes()
|
||||
);
|
||||
alert('allDay is ' + event.allDay);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,64 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
// set your time to Tehran time (GMT+03:30)
|
||||
// (recreated on a Windows XP machine, after restarting)
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
year: 2010,
|
||||
month: 2,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'Yay Tehran!',
|
||||
start: '2010-03-21' // should NOT show up on the 20th
|
||||
//allDay: false // if uncommented, will show 1am
|
||||
|
||||
// HOWEVER, when set to 2010-03-21T00:30:00, this ends up being 2010-03-21T01:30:00
|
||||
// should it be 2010-03-21T01:00:00 instead!!??
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,125 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../lib/moment-timezone/moment-timezone.js'></script>
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
//moment-timezone-data
|
||||
moment.tz.add({
|
||||
"zones": {
|
||||
"CET": [
|
||||
"1 C-Eur CE%sT"
|
||||
],
|
||||
"Etc/GMT": [
|
||||
"0 - GMT"
|
||||
],
|
||||
"Etc/UTC": [
|
||||
"0 - UTC"
|
||||
],
|
||||
"Europe/Berlin": [
|
||||
"0:53:28 - LMT 1893_3 0:53:28",
|
||||
"1 C-Eur CE%sT 1945_4_24_2 2",
|
||||
"1 SovietZone CE%sT 1946 1",
|
||||
"1 Germany CE%sT 1980 1",
|
||||
"1 EU CE%sT"
|
||||
]
|
||||
},
|
||||
"rules": {
|
||||
"C-Eur": [
|
||||
"1916 1916 3 30 7 23 0 1 S",
|
||||
"1916 1916 9 1 7 1 0 0",
|
||||
"1917 1918 3 15 1 2 2 1 S",
|
||||
"1917 1918 8 15 1 2 2 0",
|
||||
"1940 1940 3 1 7 2 2 1 S",
|
||||
"1942 1942 10 2 7 2 2 0",
|
||||
"1943 1943 2 29 7 2 2 1 S",
|
||||
"1943 1943 9 4 7 2 2 0",
|
||||
"1944 1945 3 1 1 2 2 1 S",
|
||||
"1944 1944 9 2 7 2 2 0",
|
||||
"1945 1945 8 16 7 2 2 0",
|
||||
"1977 1980 3 1 0 2 2 1 S",
|
||||
"1977 1977 8 0 8 2 2 0",
|
||||
"1978 1978 9 1 7 2 2 0",
|
||||
"1979 1995 8 0 8 2 2 0",
|
||||
"1981 9999 2 0 8 2 2 1 S",
|
||||
"1996 9999 9 0 8 2 2 0"
|
||||
],
|
||||
"SovietZone": [
|
||||
"1945 1945 4 24 7 2 0 2 M",
|
||||
"1945 1945 8 24 7 3 0 1 S",
|
||||
"1945 1945 10 18 7 2 2 0"
|
||||
],
|
||||
"Germany": [
|
||||
"1946 1946 3 14 7 2 2 1 S",
|
||||
"1946 1946 9 7 7 2 2 0",
|
||||
"1947 1949 9 1 0 2 2 0",
|
||||
"1947 1947 3 6 7 3 2 1 S",
|
||||
"1947 1947 4 11 7 2 2 2 M",
|
||||
"1947 1947 5 29 7 3 0 1 S",
|
||||
"1948 1948 3 18 7 2 2 1 S",
|
||||
"1949 1949 3 10 7 2 2 1 S"
|
||||
],
|
||||
"EU": [
|
||||
"1977 1980 3 1 0 1 1 1 S",
|
||||
"1977 1977 8 0 8 1 1 0",
|
||||
"1978 1978 9 1 7 1 1 0",
|
||||
"1979 1995 8 0 8 1 1 0",
|
||||
"1981 9999 2 0 8 1 1 1 S",
|
||||
"1996 9999 9 0 8 1 1 0"
|
||||
]
|
||||
},
|
||||
"links": {}
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
editable: true,
|
||||
timezone: 'Europe/Berlin',
|
||||
events: [
|
||||
{
|
||||
title: "event1",
|
||||
start: moment.parseZone('2014-05-30T10:00:00+02:00').tz('Europe/Berlin')
|
||||
}
|
||||
],
|
||||
eventRender: function(event, el) {
|
||||
// render the timezone offset below the event title
|
||||
if (event.start.hasZone()) {
|
||||
el.find('.fc-event-title').after(
|
||||
$('<div class="tzo"/>').text(event.start.format('Z'))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 40px auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id='calendar'></div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style='height:108px;position:relative'></div>
|
||||
<div style='position:relative;margin-top:-50px;width:900px;z-index:2'>
|
||||
<div style='position:relative;padding:3px'>
|
||||
|
||||
<div style='margin: 10px 20px 0'>Nav</div>
|
||||
|
||||
<div style='margin:20px 0 0;padding:0 20px'>
|
||||
|
||||
<p>
|
||||
this is a paragraph
|
||||
</p>
|
||||
|
||||
<div id='calendar' style='margin:3em 0;direction:ltr'></div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,63 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script src='../dist/gcal.js'></script>
|
||||
<script>
|
||||
|
||||
var gcalFeed = $.fullCalendar.gcalFeed("http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic");
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var cal = $('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
loading: function(bool) {
|
||||
if (bool) {
|
||||
$('#loading').show();
|
||||
}else{
|
||||
$('#loading').hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cal.fullCalendar('addEventSource', gcalFeed);
|
||||
cal.fullCalendar('removeEventSource', gcalFeed);
|
||||
|
||||
// events should not be rendered when jsonp returns!
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
.red-event a {
|
||||
background: red;
|
||||
}
|
||||
|
||||
.yellow-event a {
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.black-text-event a {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
button {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body style='font-size:12px'>
|
||||
<div id='loading' style='position:absolute;top:0;left:0;display:none'>loading...</div>
|
||||
<div id='calendar' style='width:900px;margin:20px auto 0;font-family:arial'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
//year: 2009,
|
||||
//month: 10,
|
||||
//date: 22,
|
||||
//defaultView: 'agendaWeek', // error also occured with month view
|
||||
editable: true,
|
||||
events: "../demos/json-events.php"
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('option', 'height', $(window).height()-80);
|
||||
// shouldn't throw an error
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,47 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
defaultView: 'agendaWeek', // month view also looked scrunched
|
||||
aspectRatio: 0
|
||||
});
|
||||
|
||||
// shouldnt allow aspectRatios to *actually* go under .5
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,56 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1),
|
||||
end: '' // shouldn't choke on empty string
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,100 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
defaultView: 'agendaDay',
|
||||
minTime: 0,
|
||||
maxTime: 24,
|
||||
firstDay: 1,
|
||||
allDayText: "dieną",
|
||||
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d-5),
|
||||
end: new Date(y, m, d-2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d-3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d+4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 0),
|
||||
end: new Date(y, m, d, 14, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d+1, 19, 0),
|
||||
end: new Date(y, m, d+1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
],
|
||||
|
||||
header: {
|
||||
left: 'prev',
|
||||
center: 'title',
|
||||
right: 'next next next'
|
||||
},
|
||||
allDaySlot: true,
|
||||
editable: true,
|
||||
titleFormat:
|
||||
{
|
||||
month: 'MMMM yyyy', // September 2009
|
||||
week: "MMM d[ yyyy]{ '—'[ MMM] d yyyy}", // Sep 7 - 13 2009
|
||||
day: 'dddd' // Tuesday, Sep 8, 2009
|
||||
},
|
||||
|
||||
axisFormat: 'HH(:mm)',
|
||||
timeFormat: { agenda: 'HH:mm{ - HH:mm}' },
|
||||
weekends: true
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div id="calendar"> </div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,62 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script src='../dist/gcal.js'></script>
|
||||
<script>
|
||||
|
||||
/*
|
||||
- click on day button
|
||||
- click refetchEvents
|
||||
- click on month button
|
||||
event shouldn't disappear!!!
|
||||
*/
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
year: 2010,
|
||||
month: 9,
|
||||
date: 31,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaDay'
|
||||
},
|
||||
editable: true,
|
||||
events: $.fullCalendar.gcalFeed('http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="$('#calendar').fullCalendar('refetchEvents')">refetchEvents</button>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,47 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
year: 2015,
|
||||
month: 0,
|
||||
date: 31
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="$('#calendar').fullCalendar('gotoDate', 2015, 1)">gotoDate - feb 2015</button>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// need to change to GMT+2 to recreate this bug!!!!
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
year: 2010,
|
||||
month: 4,
|
||||
firstDay: 1,
|
||||
events: [
|
||||
{"id":"1","title":"testcase 1 BAD","start":"1272822975","end":"1272837609","allDay":false}
|
||||
//{"id":"2","title":"testcase 2 GOOD","start":"1272822975","end":"1272837809","allDay":false},
|
||||
//{"id":"3","title":"testcase 3 GOOD too","start":"1272822975","end":"1272837609","allDay":true}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,131 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
defaultView: 'agendaWeek',
|
||||
events: [
|
||||
{
|
||||
title: 'Event1',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event2',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event3',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event4',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event5',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event6',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event7',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event8',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event9',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event10',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event11',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event12',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event13',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event14',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event15',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
},
|
||||
{
|
||||
title: 'Event16',
|
||||
start: new Date(y, m, d, 6, 0),
|
||||
allDay : false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 400px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script src='../dist/gcal.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
year: 2010,
|
||||
month: 9,
|
||||
date: 31,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaDay'
|
||||
},
|
||||
events: $.fullCalendar.gcalFeed('http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick="$('#calendar').fullCalendar('gotoDate',2010,10,11);$('#calendar').fullCalendar('changeView','agendaDay')">gotoDate + changeView</button>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,61 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script src='../dist/gcal.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: $.fullCalendar.gcalFeed('http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic')
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function doit() {
|
||||
var calendar = $('#calendar');
|
||||
calendar.fullCalendar('removeEvents');
|
||||
calendar.fullCalendar('refetchEvents');
|
||||
calendar.fullCalendar('refetchEvents');
|
||||
calendar.fullCalendar('refetchEvents');
|
||||
calendar.fullCalendar('refetchEvents');
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick='doit()'>do it</button>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,60 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link href='../dist/fullcalendar.css' rel='stylesheet' />
|
||||
<link href='../dist/fullcalendar.print.css' rel='stylesheet' media='print' />
|
||||
<script src='../lib/jquery/dist/jquery.js'></script>
|
||||
<script src='../lib/moment/moment.js'></script>
|
||||
<script src='../dist/fullcalendar.js'></script>
|
||||
<script src='../dist/gcal.js'></script>
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,basicWeek,agendaDay,basicDay'
|
||||
},
|
||||
editable: true
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
function doit() {
|
||||
var calendar = $('#calendar');
|
||||
var gcal = $.fullCalendar.gcalFeed('http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic');
|
||||
calendar.fullCalendar('addEventSource', gcal);
|
||||
calendar.fullCalendar('refetchEvents');
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin-top: 40px;
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
|
||||
}
|
||||
|
||||
#calendar {
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<button onclick='doit()'>do it</button>
|
||||
<div id='calendar'></div>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user