Skip to content

Commit

Permalink
Merge pull request naacl-org#34 from naacl-org/update-jspdf-and-autot…
Browse files Browse the repository at this point in the history
…able

Update jspdf and autotable plugin to latest versions
  • Loading branch information
desilinguist committed Jun 20, 2019
2 parents 1972c9d + 9485a84 commit 35afc23
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 259 deletions.
2 changes: 1 addition & 1 deletion _pages/program/schedule.md
Expand Up @@ -842,7 +842,7 @@ after_footer_scripts:
</div>
</div>
<div class="session session-break session-plenary" id="session-break-18"><span class="session-title">Short Break</span><br/><span class="session-time" title="Wednesday, June 05, 2019">16:30 &ndash; 16:45</span></div>
<div class="session session-expandable session-papers-best"><div id="expander"></div><a href="#" class="session-title">Best Paper Session</a><br/><span class="session-time" title="Wednesday, June 05, 2019">16:45 &ndash; 18:15</span><br/><span class="session-location btn btn--location">Nicollet Ballroom</span><br/><div class="paper-session-details"><br/><table class="paper-table">
<div class="session session-plenary session-expandable session-papers-best"><div id="expander"></div><a href="#" class="session-title">Best Paper Session</a><br/><span class="session-time" title="Wednesday, June 05, 2019">16:45 &ndash; 18:15</span><br/><span class="session-location btn btn--location">Nicollet Ballroom</span><br/><div class="paper-session-details"><br/><table class="paper-table">
<tr id="paper" paper-id="440"><td id="paper-time">16:45&ndash;17:03</td><td><span class="paper-title">CNM: An Interpretable Complex-valued Network for Matching. </span><em>Qiuchi Li, Benyou Wang and Massimo Melucci</em>&nbsp;&nbsp;<i class="far fa-file-pdf paper-icon" data="http://www.aclweb.org/anthology/N19-1420" title="PDF"></i></td></tr>
<tr id="paper" paper-id="610"><td id="paper-time">17:03&ndash;17:21</td><td><span class="paper-title">CommonsenseQA: A Question Answering Challenge Targeting Commonsense Knowledge. </span><em>Alon Talmor, Jonathan Herzig, Nicholas Lourie and Jonathan Berant</em>&nbsp;&nbsp;<i class="far fa-file-pdf paper-icon" data="http://www.aclweb.org/anthology/N19-1421" title="PDF"></i></td></tr>
<tr id="paper" paper-id="1458"><td id="paper-time">17:21&ndash;17:39</td><td><span class="paper-title">Probing the Need for Visual Context in Multimodal Machine Translation. </span><em>Ozan Caglayan, Pranava Madhyastha, Lucia Specia and Loïc Barrault</em>&nbsp;&nbsp;<i class="far fa-file-pdf paper-icon" data="http://www.aclweb.org/anthology/N19-1422" title="PDF"></i></td></tr>
Expand Down
30 changes: 16 additions & 14 deletions assets/js/main.min.js

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions assets/js/plugins/jspdf.plugin.autotable.min.js

Large diffs are not rendered by default.

101 changes: 56 additions & 45 deletions assets/js/schedule.js
Expand Up @@ -45,7 +45,7 @@ function generatePDFfromTable() {

var doc = new jsPDF('l', 'pt', 'letter');
doc.autoTable({
fromHtml: "#hidden-program-table",
html: "#hidden-program-table",
pagebreak: 'avoid',
avoidRowSplit: true,
theme: 'grid',
Expand All @@ -58,15 +58,14 @@ function generatePDFfromTable() {
lineWidth: 0.4,
fontSize: 11
},
columnStyles: {
columnStyles: {
0: { fontStyle: 'bold', halign: 'right', cellWidth: 70 },
1: { cellWidth: 110 },
2: { fontStyle: 'italic', cellWidth: 530 }
},
addPageContent: function (data) {
didDrawPage: function (data) {
/* HEADER only on the first page */
var pageNumber = doc.internal.getCurrentPageInfo().pageNumber;

if (pageNumber == 1) {
doc.setFontSize(16);
doc.setFontStyle('normal');
Expand All @@ -78,49 +77,62 @@ function generatePDFfromTable() {
doc.setFontSize(8);
doc.text('(Generated via https://naacl2019.org/schedule)', data.settings.margin.left, doc.internal.pageSize.height - 10);
},
drawCell: function(cell, data) {
var cellClass = cell.raw.content.className;
/* center the day header */
if (cellClass == 'info-day') {
cell.textPos.x = (530 - data.settings.margin.left)/2 + 120;
}
didDrawCell: function(data) {
/* split long plenary session text */
else if (cellClass == 'info-plenary') {
cell.text = doc.splitTextToSize(cell.text.join(' '), 530, {fontSize: 11});
if (data.row.section == 'body') {
var cellClass = data.cell.raw.className;
if (cellClass == 'info-plenary') {
data.cell.text = doc.splitTextToSize(data.cell.text.join(' '), 530, {fontSize: 11});
}
}
},
createdCell: function(cell, data) {
var cellClass = cell.raw.content.className;
var cellText = cell.text[0];
/* */
if (cellClass == 'info-day') {
cell.styles.fontStyle = 'bold';
cell.styles.fontSize = 12;
cell.styles.fillColor = [187, 187, 187];
willDrawCell: function(data) {
/* center the day header */
if (data.row.section == 'body') {
var cellClass = data.cell.raw.className;
if (cellClass == 'info-day') {
data.cell.textPos.x = (530 - data.settings.margin.left)/2 + 120;
}
}
else if (cellClass == 'info-plenary') {
cell.styles.fontSize = 11;
if (cellText.search(/break|lunch|breakfast/i) !== -1) {
cell.styles.fillColor = [238, 238, 238];
},
didParseCell: function(data) {
/* write day headers in bold text with dark gray background */
if (data.row.section == 'body') {
var cellClass = data.cell.raw.className;
var cellText = data.cell.text[0];
if (cellClass == 'info-day') {
data.cell.styles.fontStyle = 'bold';
data.cell.styles.fontSize = 12;
data.cell.styles.fillColor = [187, 187, 187];
}
}
else if (cellClass == 'info-poster') {
cell.styles.fontSize = 9;
}
else if (cellClass == "location" || cellClass == "time") {
var infoType = data.row.raw[2].content.className;
var infoText = data.row.raw[2].content.textContent;
if (infoType == "info-day" && cellText == '') {
cell.styles.fillColor = [187, 187, 187];
/* mark breaks explicitly with a different color */
else if (cellClass == 'info-plenary') {
data.cell.styles.fontSize = 11;
if (cellText.search(/break|lunch|breakfast/i) !== -1) {
data.cell.styles.fillColor = [238, 238, 238];
}
}
if (infoType == "info-plenary" &&
infoText.search(/(break|lunch|breakfast)/i) !== -1) {
cell.styles.fillColor = [238, 238, 238];
/* make poster titles smaller than usual */
else if (cellClass == 'info-poster') {
data.cell.styles.fontSize = 9;
}
/* fill the other empty cells with appropriate colors if we have breaks or day headers */
else if (cellClass == "location" || cellClass == "time") {
var rowCells = data.row.raw.cells;
var infoType = rowCells[rowCells.length-1].className;
var infoText = rowCells[rowCells.length-1].textContent;
if (infoType == "info-day" && cellText == '') {
data.cell.styles.fillColor = [187, 187, 187];
}
if (infoType == "info-plenary" &&
infoText.search(/(break|lunch|breakfast)/i) !== -1) {
data.cell.styles.fillColor = [238, 238, 238];
}
}
}
},
});
doc.output('save');
doc.output('save', 'schedule.pdf');
}

function getTutorialInfoFromTime(tutorialTimeObj) {
Expand Down Expand Up @@ -232,7 +244,7 @@ function makePaperRows(start, end, titles, sessions) {
for (var i=1; i<numConflicts; i++) {
var session = sessions[i];
var title = titles[i];
rows.push('<tr><td></td><td class="location">' + session.location + '</td><td class="info-paper">' + title + ' [' + session.title + ']</td></tr>')
rows.push('<tr><td class="location">' + session.location + '</td><td class="info-paper">' + title + ' [' + session.title + ']</td></tr>')
}
ans = rows;
}
Expand All @@ -251,7 +263,7 @@ function makeTutorialRows(start, end, titles, locations, sessions) {
var session = sessions[i];
var title = titles[i];
var location = locations[i];
rows.push('<tr><td></td><td class="location">' + location + '</td><td class="info-paper">' + title + ' [' + session.title + ']</td></tr>')
rows.push('<tr><td class="location">' + location + '</td><td class="info-paper">' + title + ' [' + session.title + ']</td></tr>')
}
ans = rows;
}
Expand All @@ -270,7 +282,7 @@ function makeWorkshopRows(start, end, titles, locations, sessions) {
var session = sessions[i];
var title = titles[i];
var location = locations[i];
rows.push('<tr><td></td><td class="location">' + location + '</td><td class="info-paper">' + title + ' [' + session.title + ']</td></tr>')
rows.push('<tr><td class="location">' + location + '</td><td class="info-paper">' + title + ' [' + session.title + ']</td></tr>')
}
ans = rows;
}
Expand All @@ -285,8 +297,7 @@ function makePosterRows(titles, types, sessions) {
for (var i=0; i<numPosters; i++) {
var title = titles[i];
var type = types[i];
/* rows.push('<tr><td></td><td></td><td class="info-poster">' + title + ' [' + type + ']</td></tr>'); */
rows.push('<tr><td></td><td></td><td class="info-poster">' + title + '</td></tr>');
rows.push('<tr><td class="info-poster">' + title + '</td></tr>');
}
return rows;
}
Expand Down Expand Up @@ -759,14 +770,14 @@ $(document).ready(function() {
});

/* when we mouse over a paper, highlight the conflicting papers */
$('body').on('mouseover', 'table.paper-table tr#paper', function(event) {
$('body').on('mouseover', 'div.session-expandable[id] table.paper-table tr#paper', function(event) {
var conflictingPapers = getConflicts($(this));
$(this).addClass('hovered');
$(conflictingPapers).addClass('conflicted');
});

/* when we mouse out, remove all highlights */
$('body').on('mouseout', 'table.paper-table tr#paper', function(event) {
$('body').on('mouseout', 'div.session-expandable[id] table.paper-table tr#paper', function(event) {
var conflictingPapers = getConflicts($(this));
$(this).removeClass('hovered');
$(conflictingPapers).removeClass('conflicted');
Expand Down Expand Up @@ -922,7 +933,7 @@ $(document).ready(function() {
}
});

$('body').on('click', 'table.paper-table tr#paper', function(event, fromSession) {
$('body').on('click', 'div.session-expandable[id] table.paper-table tr#paper', function(event, fromSession) {
event.preventDefault();
$(this).removeClass('hovered');
getConflicts($(this)).removeClass('conflicted');
Expand Down

0 comments on commit 35afc23

Please sign in to comment.