# HG changeset patch # User Paul Boddie # Date 1443389931 -7200 # Node ID 57c3866a301d641f083509f5842fe4554efe1841 # Parent 584eb65342ac54a686a7b6eef7b49bd0fadf5540 Moved selection and new event controls together with calendar day tables inside div elements for improved CSS selector performance. Added a summary field to the new event controls. diff -r 584eb65342ac -r 57c3866a301d htdocs/styles.css --- a/htdocs/styles.css Sun Sep 27 17:53:46 2015 +0200 +++ b/htdocs/styles.css Sun Sep 27 23:38:51 2015 +0200 @@ -129,12 +129,8 @@ display: none; } -input.newevent.selector:checked ~ p .newevent-no-periods { - display: none; -} - -input.newevent.selector:checked ~ p .newevent-with-periods { - display: inline; +input.newevent.selector:checked ~ p.newevent-with-periods { + display: block; } th.container, @@ -184,8 +180,8 @@ /* Hide calendar rows depending on the selected controls. */ -input#hidebusy:checked ~ .calendar tr.slot.busy, -input#showdays:not(:checked) ~ .calendar.empty, +input#hidebusy:checked ~ div.calendar tr.slot.busy, +input#showdays:not(:checked) ~ div.calendar .calendar.empty, /* Hiding/showing end datetimes and start/end times. */ @@ -215,7 +211,7 @@ /* Show slot endpoints when hiding adjacent busy periods. */ -input#hidebusy:checked ~ .calendar th.timeslot span.endpoint { +input#hidebusy:checked ~ div.calendar th.timeslot span.endpoint { display: block; } diff -r 584eb65342ac -r 57c3866a301d imipweb/calendar.py --- a/imipweb/calendar.py Sun Sep 27 17:53:46 2015 +0200 +++ b/imipweb/calendar.py Sun Sep 27 23:38:51 2015 +0200 @@ -53,6 +53,7 @@ slots = args.get("slot", []) participants = args.get("participants", []) + summary = args.get("summary", [None])[0] if not slots: return @@ -120,7 +121,7 @@ end_value, end_attr = get_datetime_item(end, tzid) rwrite(("UID", {}, uid)) - rwrite(("SUMMARY", {}, "New event at %s" % utcnow)) + rwrite(("SUMMARY", {}, summary or ("New event at %s" % utcnow))) rwrite(("DTSTAMP", {}, utcnow)) rwrite(("DTSTART", start_attr, start_value)) rwrite(("DTEND", end_attr, end_value)) @@ -379,18 +380,7 @@ add_empty_days(days, tzid) - # Show the controls permitting day selection as well as the controls - # configuring the new event display. - - self.show_calendar_day_controls(days) - self.show_calendar_interval_controls(days) - - # Show a button for scheduling a new event. - - page.p(class_="controls") - page.input(name="newevent", type="submit", value="New event", id="newevent", class_="newevent-with-periods", accesskey="N") - page.span("Select days or periods for a new event.", class_="newevent-no-periods") - page.p.close() + page.p("Select days or periods for a new event.") # Show controls for hiding empty days and busy slots. # The positioning of the control, paragraph and table are important here. @@ -417,16 +407,12 @@ # More page fragment methods. - def show_calendar_day_controls(self, days): + def show_calendar_day_controls(self, day): - "Show controls for the given 'days' in the calendar." + "Show controls for the given 'day' in the calendar." page = self.page - slots = self.env.get_args().get("slot", []) - - for day in days: - value, identifier = self._day_value_and_identifier(day) - self._slot_selector(value, identifier, slots) + daystr, dayid = self._day_value_and_identifier(day) # Generate a dynamic stylesheet to allow day selections to colour # specific days. @@ -435,13 +421,42 @@ page.style(type="text/css") + page.add("""\ +input.newevent.selector#%s:checked ~ table#region-%s label.day, +input.newevent.selector#%s:checked ~ table#region-%s label.timepoint { + background-color: #5f4; + text-decoration: underline; +} +""" % (dayid, dayid, dayid, dayid)) + + page.style.close() + + # Generate controls to select days. + + slots = self.env.get_args().get("slot", []) + value, identifier = self._day_value_and_identifier(day) + self._slot_selector(value, identifier, slots) + + def show_calendar_interval_controls(self, day, intervals): + + "Show controls for the intervals provided by 'day' and 'intervals'." + + page = self.page + daystr, dayid = self._day_value_and_identifier(day) + + # Generate a dynamic stylesheet to allow day selections to colour + # specific days. + # NOTE: The style details need to be coordinated with the static + # NOTE: stylesheet. + l = [] - for day in days: - daystr, dayid = self._day_value_and_identifier(day) + for point, endpoint in intervals: + timestr, timeid = self._slot_value_and_identifier(point, endpoint) l.append("""\ -input.newevent.selector#%s:checked ~ table#region-%s label.day, -input.newevent.selector#%s:checked ~ table#region-%s label.timepoint""" % (dayid, dayid, dayid, dayid)) +input.newevent.selector#%s:checked ~ table#region-%s th#region-%s""" % (timeid, dayid, timeid)) + + page.style(type="text/css") page.add(",\n".join(l)) page.add(""" { @@ -452,42 +467,12 @@ page.style.close() - def show_calendar_interval_controls(self, days): - - "Show controls for the intervals provided by 'days'." - - page = self.page - slots = self.env.get_args().get("slot", []) - - for day, intervals in days.items(): - for point, endpoint in intervals: - value, identifier = self._slot_value_and_identifier(point, endpoint) - self._slot_selector(value, identifier, slots) - - # Generate a dynamic stylesheet to allow day selections to colour - # specific days. - # NOTE: The style details need to be coordinated with the static - # NOTE: stylesheet. + # Generate controls to select time periods. - page.style(type="text/css") - - l = [] - - for day, intervals in days.items(): - daystr, dayid = self._day_value_and_identifier(day) - for point, endpoint in intervals: - timestr, timeid = self._slot_value_and_identifier(point, endpoint) - l.append("""\ -input.newevent.selector#%s:checked ~ table#region-%s th#region-%s""" % (timeid, dayid, timeid)) - - page.add(",\n".join(l)) - page.add(""" { - background-color: #5f4; - text-decoration: underline; -} -""") - - page.style.close() + slots = self.env.get_args().get("slot", []) + for point, endpoint in intervals: + value, identifier = self._slot_value_and_identifier(point, endpoint) + self._slot_selector(value, identifier, slots) def show_calendar_participant_headings(self, group_types, group_sources, group_columns): @@ -556,6 +541,18 @@ daystr, dayid = self._day_value_and_identifier(day) + # Put calendar tables within elements for quicker CSS selection. + + page.div(class_="calendar") + + # Show the controls permitting day selection as well as the controls + # configuring the new event display. + + self.show_calendar_day_controls(day) + self.show_calendar_interval_controls(day, intervals) + + # Show an actual table containing the day information. + page.table(cellspacing=5, cellpadding=5, class_="calendar %s" % (is_empty and " empty" or ""), id="region-%s" % dayid) page.caption(class_="dayheading container separator") @@ -570,6 +567,16 @@ page.table.close() + # Show a button for scheduling a new event. + + page.p(class_="newevent-with-periods") + page.label("Summary:") + page.input(name="summary", type="text") + page.input(name="newevent", type="submit", value="New event", accesskey="N") + page.p.close() + + page.div.close() + def show_calendar_points(self, intervals, groups, group_types, group_columns): """