Calendar Wijmo
by betbest
HTML
<script src="https://cdn.grapecity.com/wijmo/5.20202.724/controls/wijmo.min.js"></script>
<script src="https://cdn.grapecity.com/wijmo/5.20202.724/controls/wijmo.input.min.js"></script>
<link rel="stylesheet" href="https://cdn.grapecity.com/wijmo/5.20202.724/styles/wijmo.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<div class="container-fluid">
<input id="theCalendar">
<div>
The current date is <b><span id="theCalendarOutput"></span></b>.
</div>
</div>
CSS
@media (min-width: 1200px) {
.container-fluid {
width: 1250px;
}
}
body {
background-color: #f5f5f5;
font-size: 16px;
font-family: -apple-system-font, 'Segoe UI', 'Roboto', sans-serif;
padding: 0 0 10px;
}
.legend {
display: flex;
justify-content: flex-end;
}
.legend div {
margin-left: 24px;
}
.calendar {
display: flex;
flex-wrap: wrap;
justify-content: center;
margin-top: 32px;
padding-bottom: 90px;
}
.calendar .wj-calendar {
width: 390px;
padding: 12px 12px 36px;
background-color: white;
margin: 8px;
}
.calendar .wj-calendar .wj-content {
border: none;
}
.calendar .wj-calendar .wj-day-today {
font-weight: normal;
}
.calendar .wj-calendar .wj-state-selected {
background: inherit;
color: inherit;
}
.calendar .wj-calendar tr:not(.wj-header) td:hover {
background: #eee;
}
.calendar .wj-calendar .month-header {
display: flex;
justify-content: space-between;
align-items: baseline;
font-weight: bold;
margin-bottom: 20px;
}
.calendar .wj-calendar .month-header .month-title{
font-size: 150%;
}
.calendar .wj-calendar img {
height: 12px;
margin-top: -12px;
}
.calendar .wj-calendar-month .wj-header {
font-size: 100%;
background-color: inherit;
font-weight: normal;
}
.calendar .wj-calendar .wj-day-othermonth {
visibility: hidden;
}
.wj-tooltip {
background-color: #fff;
padding: 0;
border: 1px solid rgba(0,0,0,0.1);
border-radius: 0;
box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
box-sizing: border-box;
width: 450px;
}
.wj-tooltip .event {
margin-top: 12px;
font-weight: bold;
}
.wj-tooltip .event-tip {
border-top: 4px solid green;
padding: 24px;
}
.wj-tooltip .event-tip.event-type-maintenance {
border-top-color: #3f46ad;
}
.wj-tooltip .event-tip.event-type-incident {
border-top-color: #eeb522;
}
.wj-tooltip...
JavaScript
document.readyState === 'complete' ? init() : window.onload = init;
function init() {
var events;
let theCalendar = new wijmo.input.Calendar('#theCalendar', {
valueChanged: () => showCurrentDate(),
showHeader: true,
//selectionMode: 'None',
value: new Date(),
//formatItem: formatDayCell
});
let tooltip = new wijmo.Tooltip();
theCalendar.formatItem.addHandler((sender, e) => {
formatDayCell(sender,e)
});
theCalendar.valueChanged.addHandler(valueChanged);
function valueChanged(s, e) {
theDate = s.value.getFullYear();
console.log(theDate);
//inputDate.value = inputTime.value = calendar.value = theDate;
//document.getElementById('theDate').textContent = wijmo.Globalize.format(theDate, 'F');
}
events = getEvents();
function getEvents() {
let arr = [], types = ['Maintenance', 'Incident', 'Notice', 'Outage'], messages = ['Connectivity Issues', 'ISP Reported Problem', 'Message Server Overflow', 'Security Alert', 'Email Failure', 'Power Instability', 'Power Outage'];
//
arr.push({
id: 1, date: new Date(), type: 'Outage' , msg: 'Mensaje Leandro' });
return arr;
}
// show the currently selected date
function showCurrentDate() {
// let el = document.querySelector('#theCalendarOutput');
//el.textContent = wijmo.Globalize.format(theCalendar.value, 'D');
}
// showCurrentDate();
// format the calendar cells to show events
function formatDayCell(sender, e) {
// console.log(e.data);
let event = getEvent(e.data), html = `<div>${e.data.getDate()}</div>`;
html += event
? `<a href="#" target="_blank" class="leandro"><img data-id="${event.id}" src="https://status.slack.com/img/v2/Table${event.type}.png"/><a>`
: '<img/>';
// format cell content
e.item.innerHTML = html;
// add tooltip to...