cropping png

This commit is contained in:
10001shh
2019-01-11 14:42:19 -06:00
parent 07f0ed43e3
commit 24110adcf3
2 changed files with 20 additions and 13 deletions

View File

@@ -43,7 +43,6 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
opacity: 0;
border: none;
}
/* Styling for each event from Schedule */
.fc-time-grid-event.fc-v-event.fc-event {
@@ -55,6 +54,9 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
opacity: 1;
}
.html2canvas-container { width: 3000px !important; height: 3000px !important; }
.fc-time-grid-event.fc-v-event.fc-event:hover {
box-shadow: 0 8px 12px 0 rgba(0, 0, 0, 0.3);
}
@@ -72,7 +74,7 @@ Colors: Use the following - https://www.google.com/design/spec/style/color.html#
.fc th {
border-style: ridge !important;
border-width: 1px !important;
padding: 2px 3px 2px 3px !important;
padding: 4px 3px 0px 3px !important;
vertical-align: top !important;
border-left-width: 0;

View File

@@ -108,12 +108,17 @@ $(function () {
window.open(currLink);
}, butdelay);
});
console.log($("#calendar").width());
$("#save").click(() => {
html2canvas(document.querySelector("#calendar"), {
foreignObjectRendering: true
}).then(canvas => {
let cropper = document.createElement('canvas').getContext('2d');
html2canvas(document.getElementById("calendar"), {
foreignObjectRendering: true,
}).then(c => {
cropper.canvas.width = $("#calendar").width();
cropper.canvas.height = $("#calendar").height() + 10;
cropper.drawImage(c, 0, 0);
var a = document.createElement('a');
a.href = canvas.toDataURL("image/png");
a.href = cropper.canvas.toDataURL("image/png");
a.download = 'mySchedule.png';
a.click();
});
@@ -178,7 +183,7 @@ $(function () {
var description = title.substring(title.indexOf('with'));
var time = event.start._d.toUTCString();
cal.addEvent(classname, description, event.building, event.start._i, event.end._i, {
rrule: `RRULE:FREQ=WEEKLY;BYDAY=${time.substring(0, time.indexOf(",")-1).toUpperCase()};INTERVAL=1`
rrule: `RRULE:FREQ=WEEKLY;BYDAY=${time.substring(0, time.indexOf(",") - 1).toUpperCase()};INTERVAL=1`
});
}
cal.download("My_Course_Calendar");
@@ -292,17 +297,17 @@ $(function () {
title: `${department}-${course_nbr} with ${uncapProf}`,
start: beg +
moment()
.day(fullday)
._d.toString()
.split(" ")[2] +
.day(fullday)
._d.toString()
.split(" ")[2] +
"T" +
session[1][0] +
":00",
end: beg +
moment()
.day(fullday)
._d.toString()
.split(" ")[2] +
.day(fullday)
._d.toString()
.split(" ")[2] +
"T" +
session[1][1] +
":00",