Skip to content

Commit

Permalink
release: 2.1.6-beta.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz committed Feb 12, 2018
1 parent 3ff6910 commit f63648f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-statusbar": "^2.2.2",
"cordova-plugin-whitelist": "^1.3.1",
"ion2-calendar": "^2.1.6-beta.1",
"ion2-calendar": "^2.1.6-beta.2",
"ionic-angular": "3.9.2",
"ionic-plugin-keyboard": "^2.2.1",
"ionicons": "3.0.0",
Expand Down Expand Up @@ -61,4 +61,4 @@
"ionic-plugin-keyboard": {}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ion2-calendar",
"version": "2.1.6-beta.1",
"version": "2.1.6-beta.2",
"description": "A date picker component for ionic2 ",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/calendar.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export interface CalendarOptions {
defaultTitle?: string;
defaultSubtitle?: string;
daysConfig?: Array<DayConfig>;
/**
/**
* show last month & next month days fill six weeks
*/
showOtherMonthDay?: boolean;
showAdjacentMonthDay?: boolean;
}

export interface CalendarComponentOptions extends CalendarOptions {
Expand Down
3 changes: 2 additions & 1 deletion src/components/calendar.modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,13 @@ export class CalendarModal implements OnInit {

ionViewDidLoad(): void {
this.findCssClass();

this.scrollToDefaultDate();
}

init(): void {
this._d = this.calSvc.safeOpt(this.params.get('options'));

this._d.showAdjacentMonthDay = false;
this.step = this._d.step;
if (this.step < 1) {
this.step = 1;
Expand Down
30 changes: 16 additions & 14 deletions src/services/calendar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class CalendarService {
weekdays = defaults.WEEKS_FORMAT,
daysConfig = _daysConfig,
disableWeeks = _disableWeeks,
showOtherMonthDay = true
showAdjacentMonthDay = true
} = calendarOptions || {};

return {
Expand Down Expand Up @@ -76,7 +76,7 @@ export class CalendarService {
defaultDate: calendarOptions.defaultDate || null,
defaultDates: calendarOptions.defaultDates || null,
defaultDateRange: calendarOptions.defaultDateRange || null,
showOtherMonthDay
showAdjacentMonthDay
}
}

Expand Down Expand Up @@ -180,19 +180,21 @@ export class CalendarService {
}
}

const _booleanMap = days.map(e => !!e);
const thisMonth = moment(original.time).month();
let startOffsetIndex = _booleanMap.indexOf(true) - 1;
let endOffsetIndex = _booleanMap.lastIndexOf(true) + 1;
for (startOffsetIndex; startOffsetIndex >= 0; startOffsetIndex--) {
const dayBefore = moment(days[startOffsetIndex + 1].time).clone().subtract(1, 'd');
days[startOffsetIndex] = this.createCalendarDay(dayBefore.valueOf(), opt, thisMonth);
}
if (opt.showAdjacentMonthDay) {
const _booleanMap = days.map(e => !!e);
const thisMonth = moment(original.time).month();
let startOffsetIndex = _booleanMap.indexOf(true) - 1;
let endOffsetIndex = _booleanMap.lastIndexOf(true) + 1;
for (startOffsetIndex; startOffsetIndex >= 0; startOffsetIndex--) {
const dayBefore = moment(days[startOffsetIndex + 1].time).clone().subtract(1, 'd');
days[startOffsetIndex] = this.createCalendarDay(dayBefore.valueOf(), opt, thisMonth);
}

if (!(_booleanMap.length % 7 === 0 && _booleanMap[_booleanMap.length - 1])) {
for (endOffsetIndex; endOffsetIndex < days.length + (endOffsetIndex % 7); endOffsetIndex++) {
const dayAfter = moment(days[endOffsetIndex - 1].time).clone().add(1, 'd');
days[endOffsetIndex] = this.createCalendarDay(dayAfter.valueOf(), opt, thisMonth);
if (!(_booleanMap.length % 7 === 0 && _booleanMap[_booleanMap.length - 1])) {
for (endOffsetIndex; endOffsetIndex < days.length + (endOffsetIndex % 7); endOffsetIndex++) {
const dayAfter = moment(days[endOffsetIndex - 1].time).clone().add(1, 'd');
days[endOffsetIndex] = this.createCalendarDay(dayAfter.valueOf(), opt, thisMonth);
}
}
}

Expand Down

0 comments on commit f63648f

Please sign in to comment.