crsten / datepickk

Simple, beautiful and powerful datepicker!
https://crsten.github.io/datepickk
MIT License
165 stars 42 forks source link

Tooltips #6

Open bugToaster opened 7 years ago

bugToaster commented 7 years ago

tooltips function does not working for multiple option. It just for single date.

bugToaster commented 7 years ago

By this tooltip possible to describe event number or something. So in this purpose need multiple tool-tips

MrIsaacs commented 6 years ago

you mean multiple entries in one cell, in other words for one day?

bugToaster commented 6 years ago

Yeah , Different time hour / text

MrIsaacs commented 6 years ago

I needed it for an importer some days ago and came up with this:

function import(data) {
    var tmpCal = [];
    var tooltips = [];

    // for all your calender events
    for (let i = 1; i < data.length; i++) {
        [date, client, description] = getEntry(data, i);

        // if no order exist make an entry on that date
        if (!(date in tmpCal)) {
            tmpCal[date] = `${client}: ${description}`;
        }
        // if an order already exist append the next on that date
        else {
            tmpCal[date] += `<br>${client}: ${description}`;
        }

        tooltips.push({
            date: new Date(date),
            text: tmpCal[date]
        });
    }

    datepicker.tooltips = tooltips;
}

function getEntry(data, i) {
    return [
        data[i][1][0][3],  // date 
        data[i][1][10][3], // client
        data[i][1][5][3]  // description
    ];
}

It's not the cleanest solution, but serves as a workaround. What you do with getEntry is up to you. I use date as a YYYY-MM-DD string for indicating a day entry in the temporary calender and then append on that entry if an entry exists. You can add time to the returned value of getEntry and change the template literals in import to your needs. When you do so you need to adjust your matched array to something like the following:

[date, time, client, description] = getEntry(data, i);