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

Custom badge problem #19

Closed
badeamihai opened this issue Dec 15, 2014 · 1 comment
Closed

Custom badge problem #19

badeamihai opened this issue Dec 15, 2014 · 1 comment

Comments

@badeamihai
Copy link

Hello, these days, as i was working with the calendar i had to modify a piece of code so that i could add a custom class to the selected date. I didn't want to commit the changes on the repo because it may not be something you wanted, or i misunderstood it.

The original code is here:

// drawEvents function
...
if (typeof(value.badge) !== 'undefined' && value.badge !== false) {
    var badgeClass = (value.badge === true) ? '' : ' badge-' + value.badge;
    var dayLabel = $dayElement.data('day');
    $dayElement.html('<span class="badge badge-event' + badgeClass + '">' + dayLabel + '</span>');
}
...

The code seems to be able to take a class as a parameter ( besides true / false ) but the default class is also preserved, and may come in conflict with the one i supplied. ( default is orange and i want blue )

So i think it should look like this:

// drawEvents function
...
if (typeof(value.badge) !== 'undefined' && value.badge !== false) {
    var badgeClass = (value.badge === true) ? 'badge-event' : value.badge;
    var dayLabel = $dayElement.data('day');
    $dayElement.html('<span class="badge ' + badgeClass + '">' + dayLabel + '</span>');
}
...

Here is a fiddle i used for testing:
http://jsfiddle.net/1470bg5q/6/

You can also check and force a prefix to the class ( like 'badge-') but i think it might be confusing. People will add a class and expect that the same name will be used. Also they wont know the prefix until they search for it.

Hope this helps.

@zabuto
Copy link
Owner

zabuto commented Nov 2, 2017

the .badge-event class contains styling that I want to be applied to all badges to maintain an overall design. This includes padding and font-size.

Your own css can be used to override the appearance of the base event badge class, for example change orange to blue while still preserving the overall appearance. You can achieve this with a simple color override. And you don't have to worry about the spacing.

@zabuto zabuto closed this as completed Nov 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants