Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(calendar): add eventDates support and onSelect handler #677

Merged
merged 4 commits into from
Apr 27, 2019

Conversation

lubber-de
Copy link
Member

@lubber-de lubber-de commented Apr 17, 2019

Description

This PR adds support for eventDates and a new event handler onSelect to provide individual functionality whenever a cell-item was clicked.
This works similar as disabledDates by providing the option to set a tooltip given a message to a date cell.In addition a given class can be added to the cell. Otherwise a default eventClass (default blue) will be added to every event-cell.

Example using individual className for eventDate cells

$('.ui.calendar').calendar({
eventDates: [
    {
      date: new Date(2019,3,21),
      message: 'Show me in light purple',
      class: 'inverted purple'
    },{
      date: new Date(2019,3,22),
      message: 'Show me in green',
      class: 'green'
    }
]
});

Example using default className for each event

$('.ui.calendar').calendar({
eventClass: 'inverted red',
eventDates: [
    new Date(2019,3,20), //no message tooltip
    {
      date: new Date(2019,3,21),
      message: 'I got the default color (light red)'
    },{
      date: new Date(2019,3,22),
      message: 'Me too'
    }
]
});

Example using onSelect event handler

$('.ui.calendar').calendar({
onSelect: function(date,mode) {
  console.log('You have chosen',date,'in mode',mode);
  if(mode!=='day') {
    console.log('You cannot select anything else than a day!');
    return false;
  }
}
});

Testcase

eventDates

http://jsfiddle.net/nc0yutq2/

onSelect

http://jsfiddle.net/c7kLvef4/

Screenshot

eventdates

Closes

#674

@lubber-de lubber-de added type/feat Any feature requests or improvements lang/javascript Anything involving JavaScript state/awaiting-reviews Pull requests which are waiting for reviews labels Apr 17, 2019
@lubber-de lubber-de added this to the 2.7.5 milestone Apr 17, 2019
@lubber-de
Copy link
Member Author

lubber-de commented Apr 17, 2019

Btw: This PR also fixes the issue from #574 (check for undefined after parsing date) without the extra logging. I did this because the other PR did not receive any more feedback from the author since 2 weeks and the fix was only one LOC.

@lubber-de lubber-de added the state/awaiting-docs Pull requests which need doc changes/additions label Apr 17, 2019
@lubber-de
Copy link
Member Author

Last commit adds event handler onSelect

@lubber-de lubber-de changed the title [Calendar] eventDates support [Calendar] eventDates support and onSelect handler Apr 18, 2019
Copy link
Contributor

@prudho prudho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@y0hami y0hami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@exoego exoego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@ColinFrick ColinFrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lubber-de lubber-de added state/has-docs A issue/PR which requires documentation changes and has the corresponding PR open in the docs repo and removed state/awaiting-docs Pull requests which need doc changes/additions labels Apr 26, 2019
@y0hami y0hami removed the state/awaiting-reviews Pull requests which are waiting for reviews label Apr 27, 2019
@y0hami y0hami changed the title [Calendar] eventDates support and onSelect handler feat(calendar): add eventDates support and onSelect handler Apr 27, 2019
@y0hami y0hami merged commit 1b4a264 into fomantic:develop Apr 27, 2019
@lubber-de lubber-de deleted the feat/674/eventdates branch May 16, 2019 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang/javascript Anything involving JavaScript state/has-docs A issue/PR which requires documentation changes and has the corresponding PR open in the docs repo type/feat Any feature requests or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants