Change the background of some CalendarItem element in Lift / Scala

I am trying to use the Lift and CalendarMonthView widgets to create a destination system.

CalendarMonthView works very well with Lift, but I have a problem that failed to change the style of some CalendarItem displayed on the calendar.

According to the API document, I use the following code to change the css class of a specific CalendarItem when creating a calendar.

class MySnippet {
    def test (xhtml: NodeSeq) = {
        val c    = Calendar.getInstance
        val meta = MonthViewMeta (Calendar.SUNDAY, Locale.getDefault)

        c.set (2010, 0, 0)

        bind ("cal", xhtml, 
              "widget" -> CalendarMonthView (c, meta, cals, Empty, 
                                             Empty, Empty))
    }

    def cals = {
        val c1 = Calendar.getInstance
        val c2 = Calendar.getInstance

        c1.set (2010, 0, 5, 10, 0)
        c2.set (2010, 0, 6, 10, 0)

        val calitem1 = CalendarItem ("4", c1, CalendarType.MEETING).
                       optional (
                           _.subject     ("Red Item"),
                           _.description ("Background should be read")
                       )

        val calitem2 = CalendarItem ("5", c2, CalendarType.MEETING).
                       optional (
                           _.subject     ("Green Item"),
                           _.description ("Background should be green"),
                           _.baseCSSClassName ("greenItem")
                       )


        List (calitem1, calitem2)
    }

}

And I confirmed that in the HTML output, calitem2 has "cssClass", the attribute is set to "greenItem".

var calendars = {
    "items": [{"id": "4", "start": 20, "end": 48,
               "weekDay": "3", "startTime": "10:0",              
               "subject": "Red Item", "month": 0, "dayOfMonth": 5,              
               "description": "Background should be read"},
              {"id": "5", "start": 20, "end": 48, "weekDay": "4", 
               "startTime": "10:0", "subject": "Green Item", "month": 0, 
               "dayOfMonth": 6, "description": "Background should be green", 
               "cssClass": "greenItem"}]
};             

And I also redefine the original style. css comes with CalendarMonthView and put it under WEB-INF / classes / toserv / calendars / monthview.

, , CSS "greenItem".

.greenItem {
        margin: 1px;

}

.greenItem a {
        margin-left: 1px;
        color: #FFFFFF;
        text-decoration: none;
        background-color: #00FF00;
        display: block;

}

.greenItem a:hover {
        text-decoration: none;
        background-color: #ff6655;
        display: block;

}

.greenItemHead {
        margin: 1px;

}

.greenItemHead a {
        margin-left: 1px;
        color: #FFFFFF;
        text-decoration: none;
        background-color: #00FF00;
        display: block;

}

.greenItemHead a:hover {
        text-decoration: none;
        background-color: #ff6655;
        display: block;

}

.greenItemBody {
        margin: 1px;

}

.greenItemBody a {
        margin-left: 1px;
        color: #FFFFFF;
        text-decoration: none;
        background-color: #00FF00;
        display: block;

}

.greenItemBody a:hover {
        text-decoration: none;
        background-color: #ff6655;
        display: block;
}

, CalendarItem - , , CSS .

JavaScript JQuery, - ?

+3

Source: https://habr.com/ru/post/1751499/


All Articles