Skip to content

Commit 8a331f0

Browse files
authored
feat(calendar): multimonth, parser & modal usage fix
Several small fixes: Multimonth calendar offset was only possible by providing it via data attributes data-month-offset. This is now also possible by using the monthOffset value as well. This PR also fixes date parsing in case whitespace is part of the date. By disabling the observer in the popupoptions by default the calendar works properly when used inside modals multimonth calendars now appear in the same way inside popup as a single calendar
1 parent f0a2ebc commit 8a331f0

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/definitions/modules/calendar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ $.fn.calendar = function(parameters) {
746746
return $module.data(metadata.maxDate) || null;
747747
},
748748
monthOffset: function () {
749-
return $module.data(metadata.monthOffset) || 0;
749+
return $module.data(metadata.monthOffset) || settings.monthOffset || 0;
750750
},
751751
mode: function () {
752752
//only returns valid modes for the current settings
@@ -1452,6 +1452,7 @@ $.fn.calendar.settings = {
14521452
startCalendar : null, // jquery object or selector for another calendar that represents the start date of a date range
14531453
endCalendar : null, // jquery object or selector for another calendar that represents the end date of a date range
14541454
multiMonth : 1, // show multiple months when in 'day' mode
1455+
monthOffset : 0, // position current month by offset when multimonth > 1
14551456
minTimeGap : 5,
14561457
showWeekNumbers : null, // show Number of Week at the very first column of a dayView
14571458
disabledHours : [], // specific hour(s) which won't be selectable and contain additional information.
@@ -1467,6 +1468,7 @@ $.fn.calendar.settings = {
14671468
position: 'bottom left',
14681469
lastResort: 'bottom left',
14691470
prefer: 'opposite',
1471+
observeChanges: false,
14701472
hideOnScroll: false
14711473
},
14721474

@@ -1558,7 +1560,7 @@ $.fn.calendar.settings = {
15581560
if (!text) {
15591561
return null;
15601562
}
1561-
text = String(text).trim();
1563+
text = String(text).replace(/\s/g,'');
15621564
if (text.length === 0) {
15631565
return null;
15641566
}

src/definitions/modules/calendar.less

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,26 @@
172172
}
173173
}
174174

175+
& when (@variationCalendarMultiMonth) {
176+
.ui.calendar.popup > .ui.grid {
177+
margin: @multiMonthMargin;
178+
& > .column:not(:first-child) {
179+
padding-left: @multiMonthPadding;
180+
& > .ui.table {
181+
border-top-left-radius:0;
182+
border-bottom-left-radius:0;
183+
}
184+
}
185+
& > .column:not(:last-child) {
186+
padding-right:@multiMonthPadding;
187+
& > .ui.table {
188+
border-top-right-radius:0;
189+
border-bottom-right-radius:0;
190+
}
191+
}
192+
}
193+
}
194+
175195
/*******************************
176196
States
177197
*******************************/

src/themes/default/globals/variation.variables

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@
488488
/* Calendar */
489489
@variationCalendarInverted: true;
490490
@variationCalendarDisabled: true;
491+
@variationCalendarMultiMonth: true;
491492

492493
/* Checkbox */
493494
@variationCheckboxDisabled: true;

src/themes/default/modules/calendar.variables

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
@adjacentBackground: @subtleTransparentBlack;
1919
@adjacentInvertedTextColor: @invertedMutedTextColor;
2020
@adjacentInvertedBackground: @subtleTransparentWhite;
21+
22+
@multiMonthMargin: -1rem;
23+
@multiMonthPadding: 0;

0 commit comments

Comments
 (0)