Skip to content

Commit

Permalink
Added support for eventOrder and released version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertHajbok committed Nov 27, 2017
1 parent e5b35d6 commit 1d0f18e
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 36 deletions.
4 changes: 2 additions & 2 deletions FullCalendarMVC/FullCalendar.MVC4/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
4 changes: 2 additions & 2 deletions FullCalendarMVC/FullCalendar.MVC5/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
27 changes: 20 additions & 7 deletions FullCalendarMVC/FullCalendar.UI/Scripts/fullcalendar.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
eventbordercolor: { name: 'eventBorderColor', type: 'string' },
eventtextcolor: { name: 'eventTextColor', type: 'string' },
nextdaythreshold: { name: 'nextDayThreshold', type: 'duration' },
eventorder: { name: 'eventOrder', type: 'custom' },
eventrenderwait: { name: 'eventRenderWait', type: 'integer' },
eventrender: { name: 'eventRender', type: 'callback' },
eventafterrender: { name: 'eventAfterRender', type: 'callback' },
Expand Down Expand Up @@ -165,7 +166,7 @@
calendarObj[calendarParameter.name] = parseData(data[item], calendarParameter);
$(calendars[i]).removeAttr("data-fc-" + item.substring(2));
});
console.log(calendarObj);
//console.log(calendarObj);
$(calendars[i]).fullCalendar(calendarObj);
}
});
Expand Down Expand Up @@ -194,12 +195,7 @@
parseCallbackData(JSON.parse(data.replace(/\'/g, '"')).function);
case 'callback/string':
case 'function/string':
var value = JSON.parse(data.replace(/\'/g, '"')).function;
try {
return parseFunctionData(value);
} catch (e) {
return value;
}
return parseFunctionStringData(JSON.parse(data.replace(/\'/g, '"')).function);
case 'function/object':
var returnValue = null;
try {
Expand Down Expand Up @@ -249,6 +245,14 @@
return eval('(' + data + ')');
}

function parseFunctionStringData(data) {
try {
return parseFunctionData(data);
} catch (e) {
return data;
}
}

function parseCallbackData(data) {
try {
return parseFunctionData(data);
Expand Down Expand Up @@ -327,6 +331,15 @@
});
});
return obj;
case 'eventOrder':
var obj = parseObjectData(data);
if (obj.length == 1) {
return parseFunctionStringData(obj[0]);
}
for (i = 0; i < obj.length; i++) {
obj[i] = parseFunctionStringData(obj[i]);
}
return obj;
}
}

Expand Down

Large diffs are not rendered by default.

36 changes: 23 additions & 13 deletions FullCalendarMVC/FullCalendar.UI/Views/Home/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,34 @@
@Scripts.Render("~/bundles/scripts")
@Styles.Render("~/bundles/styles")
@*<script>
var EventClick = function (calEvent, jsEvent, view) {
alert('Event: ' + calEvent.title);
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
alert('View: ' + view.name);
var EventClick = function (calEvent, jsEvent, view) {
alert('Event: ' + calEvent.title);
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
alert('View: ' + view.name);
// change the border color just for fun
$(this).css('border-color', 'red');
};
// change the border color just for fun
$(this).css('border-color', 'red');
};
var EventResize = function (event, delta, revertFunc) {
alert(event.title + " end is now " + event.end.format());
var EventResize = function (event, delta, revertFunc) {
alert(event.title + " end is now " + event.end.format());
if (!confirm("is this okay?")) {
revertFunc();
}
if (!confirm("is this okay?")) {
revertFunc();
}
}
var EventOrder = function (a, b) {
if (a.id < b.id) {
return -1;
}
if (a.title > b.title) {
return 1;
}
</script>*@
// a must be equal to b
return 0;
}
</script>*@
</head>
<body>
<div class="header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,5 @@
// }
// }
//};
//settings.EventOrder = new string[] { "start", "EventOrder" };
})
11 changes: 11 additions & 0 deletions FullCalendarMVC/FullCalendar/FullCalendarParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,17 @@ public class FullCalendarParameters
/// </summary>
public TimeSpan NextDayThreshold { get; set; }

/// <summary>
/// Determines the vertical ordering events that have the same dates / times.
/// By default, FullCalendar decides that events with longer durations and earlier start times are sorted above other events. However, events often have the same exact start time and duration, which is especially true for all-day events. By default, when this happens, events are sorted alphabetically by title. eventOrder provides the ability to override this behavior.
/// This setting accepts a few different arguments:
/// (1) a name of an Event Object property, like "title". This can be the name of a non-standard field. Sorting will happen in ascending order. If prefixed with a minus sign like "-title", sorting will happen in descending order.
/// (2) a comma-separated string of property names, like "title,propA,-propB".
/// (3) a function that accepts two arguments and returns -1 or 1, similar to sort's compare function.
/// (4) an array of property names and functions like [ "title", "-propA", myFunc ].
/// </summary>
public string[] EventOrder { get; set; }

/// <summary>
/// The amount of milliseconds to wait after an operation, before rendering events.
/// When this value is specified as a millisecond number value, the calendar will begin to wait after any operation that might result in an event rerendering, such as renderEvent and updateEvent. After this time has passed, the calendar will render all events together. This reduces the number of rerenders, for performance reasons.
Expand Down
4 changes: 2 additions & 2 deletions FullCalendarMVC/FullCalendar/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.1.0")]
[assembly: AssemblyFileVersion("1.0.1.0")]
27 changes: 20 additions & 7 deletions FullCalendarMVC/FullCalendar/Scripts/fullcalendar.helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
eventbordercolor: { name: 'eventBorderColor', type: 'string' },
eventtextcolor: { name: 'eventTextColor', type: 'string' },
nextdaythreshold: { name: 'nextDayThreshold', type: 'duration' },
eventorder: { name: 'eventOrder', type: 'custom' },
eventrenderwait: { name: 'eventRenderWait', type: 'integer' },
eventrender: { name: 'eventRender', type: 'callback' },
eventafterrender: { name: 'eventAfterRender', type: 'callback' },
Expand Down Expand Up @@ -165,7 +166,7 @@
calendarObj[calendarParameter.name] = parseData(data[item], calendarParameter);
$(calendars[i]).removeAttr("data-fc-" + item.substring(2));
});
console.log(calendarObj);
//console.log(calendarObj);
$(calendars[i]).fullCalendar(calendarObj);
}
});
Expand Down Expand Up @@ -194,12 +195,7 @@
parseCallbackData(JSON.parse(data.replace(/\'/g, '"')).function);
case 'callback/string':
case 'function/string':
var value = JSON.parse(data.replace(/\'/g, '"')).function;
try {
return parseFunctionData(value);
} catch (e) {
return value;
}
return parseFunctionStringData(JSON.parse(data.replace(/\'/g, '"')).function);
case 'function/object':
var returnValue = null;
try {
Expand Down Expand Up @@ -249,6 +245,14 @@
return eval('(' + data + ')');
}

function parseFunctionStringData(data) {
try {
return parseFunctionData(data);
} catch (e) {
return data;
}
}

function parseCallbackData(data) {
try {
return parseFunctionData(data);
Expand Down Expand Up @@ -327,6 +331,15 @@
});
});
return obj;
case 'eventOrder':
var obj = parseObjectData(data);
if (obj.length == 1) {
return parseFunctionStringData(obj[0]);
}
for (i = 0; i < obj.length; i++) {
obj[i] = parseFunctionStringData(obj[i]);
}
return obj;
}
}

Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public JsonResult GetDiaryEvents(DateTime start, DateTime end)
| eventBorderColor | | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
| eventTextColor | | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
| nextDayThreshold | | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
| eventOrder | | ![#f03c15](https://placehold.it/13/f03c15/000000?text=+) not supported |
| eventOrder | All 4 versions supported as array | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
| eventRenderWait | | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
| eventRender (callback) | | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
| eventAfterRender (callback) | | ![#008000](https://placehold.it/13/008000/000000?text=+) supported |
Expand Down

0 comments on commit 1d0f18e

Please sign in to comment.