Default month/day to 01 in Timeline if missing

This causes any item with just a year to show up at the start of the
year (instead of just not showing up, which I think was the case
before). Unfortunately they can then go out of view, and it's not
possible to scroll to view more, though that could probably be fixed.
This commit is contained in:
Dan Stillman 2017-07-29 22:13:47 -04:00
parent fba412fe4a
commit 168e4e4b45

View file

@ -34,10 +34,10 @@ Zotero.Timeline = {
var date = item.getField(dateType, true, true);
if (date) {
let sqlDate = (dateType == 'date') ? Zotero.Date.multipartToSQL(date) : date;
sqlDate = sqlDate.replace("00-00", "01-01");
sqlDate = sqlDate.replace("-00-", "-01-").replace(/-00$/, "-01");
let content = '<event start="' + Zotero.Date.sqlToDate(sqlDate) + '" ';
let title = item.getField('title');
content += 'title=" ' + (title ? escapeXML(title) : '') + '" ';
content += 'title="' + (title ? escapeXML(title) : '') + '" ';
content += 'icon="' + item.getImageSrc() + '" ';
content += 'color="black">';
content += item.id;