Skip to content

Commit

Permalink
Merge pull request #20 from anhany/develop
Browse files Browse the repository at this point in the history
Fix some spacing around the dual picker
  • Loading branch information
anhany authored Jul 24, 2017
2 parents cf4ef56 + 1543ea3 commit 3c24f7e
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 27 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,9 @@ I have already implemented the datepicker using the renderer class to support An
Because the datepicker returns a moment date, not a string.



## Release Notes
- 3.1.1 -- Fix ViewChild syntax in dualpicker.
- 3.1.0 -- Fix bug when today was not in the validation range, the user could not select a date. Also update some styling for the carat below.
- 3.0.3 -- Fix bug with changeDate being called more than once
- 3.0.0-3.0.2 -- Don't ask
- 3.0.0 - 3.2.0 -- Merge fix for changeDate being called more than once. Merge fix for the date getter using the minDate if no date value is supplied.
- 2.5.3 -- Update ViewChild syntax. Also fix extra padding, which moved the picker off the input box.
- 2.5.0 -- Ability to specify a minDate without a maxDate for validation
- 2.4.0 -- Add ability to specify calendar default mode (globalMode), e.g. month/year.
- 2.2.3 -- Remove sourcemap from dist build.
Expand Down
5 changes: 2 additions & 3 deletions dist/ctng.umd.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {DatePickerModule, DatePickerConfig, DatePickerUtil} from './dist/ctng.umd.js';
export {DatePickerModule, DatePickerConfig, DatePickerUtil} from './dist/ctng.umd.js';
// export {DatePickerModule, DatePickerConfig, DatePickerUtil} from './src/datepicker.module';
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ct-ngx-datepicker",
"version": "2.5.2",
"version": "3.2.0",
"module": "index.js",
"description": "Angular 2 Datepicker for Centeva projects",
"main": "dist/ctng.umd.js",
Expand Down
2 changes: 1 addition & 1 deletion src/calendar-grid/calendar-grid.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('CalendarGridComponent.component', () => {
let dateFrom = moment("2017-01-05");
let dateTo = moment("2017-01-10");

// component.renderCalendar(date, () => {}, dateTo, dateFrom, null, null);
component.renderCalendar(date, () => {}, dateTo, dateFrom, null, null);

//From
let elFrom = $(nativeElement).find("[ct-dp-cal-day=5]");
Expand Down
7 changes: 0 additions & 7 deletions src/common/datepicker-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,4 @@ export abstract class DatePickerBase implements ControlValueAccessor {
}

public abstract writeValue(value: any);

public isSameDate(date1: moment.Moment, date2: moment.Moment) {
if (date1 instanceof moment && date2 instanceof moment) {
return date1.isSame(date2, 'day');
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/datepicker/datepicker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
--><button tabindex="-1" class="ct-dp-btn-year ct-dp-btn" (click)="changeMode(CalendarMode.Year)">{{cal.date.format("YYYY")}}</button><!--
--><button tabindex="-1" class="ct-dp-btn-next ct-dp-btn" (click)="goNext()" [disabled]="cal.mode == CalendarMode.Month">&gt;</button>
</div>
<ct-calendar></ct-calendar>
<ct-calendar #cal></ct-calendar>
<div class="clearfix"></div>
</div>
</div>
5 changes: 2 additions & 3 deletions src/datepicker/datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class DatePickerComponent extends DatePickerBase implements AfterViewInit
return this.dateValue || this.minDate;
}
set date(val) {
if (this.isSameDate(val, this.dateValue)) {
if (this.isSameDay(val, this.dateValue)) {
return;
}
if (val instanceof moment && val.isValid()) {
Expand All @@ -73,7 +73,7 @@ export class DatePickerComponent extends DatePickerBase implements AfterViewInit

@ContentChild('date') input: ElementRef;

@ViewChild(CalendarComponent) public cal: CalendarComponent;
@ViewChild('cal') public cal: CalendarComponent;
public mode: DatePickerMode = DatePickerMode.Hidden;

constructor(private myElement: ElementRef, private renderer: Renderer, private config: DatePickerConfig) {
Expand Down Expand Up @@ -137,7 +137,6 @@ export class DatePickerComponent extends DatePickerBase implements AfterViewInit
let picker = $(this.myElement.nativeElement).find(".ct-dp-picker-wrapper");
picker.removeClass("display-above");
picker.addClass("display-below");
// picker.css("top", ($(this.input.nativeElement).outerHeight()) + "px");
picker.css("left", "0px");
}

Expand Down
9 changes: 4 additions & 5 deletions src/dualpicker/dualpicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ export class DualPickerComponent extends DatePickerBase implements OnChanges {
/** Input definition for (from) */
@Input()
get dateFrom() {
return this.dateFromValue;
return this.dateFromValue || this.minDate;
}
set dateFrom(val) {
if (this.isSameDate(val, this.dateFromValue)) {
if (this.isSameDay(val, this.dateFromValue)) {
return;
}
if (val instanceof moment && val.isValid()) {
Expand All @@ -83,10 +83,10 @@ export class DualPickerComponent extends DatePickerBase implements OnChanges {
/** Input definition for (to) */
@Input()
get dateTo() {
return this.dateToValue;
return this.dateToValue || this.minDate;
}
set dateTo(val) {
if (this.isSameDate(val, this.dateToValue)) {
if (this.isSameDay(val, this.dateToValue)) {
return;
}
if (val instanceof moment && val.isValid()) {
Expand Down Expand Up @@ -190,7 +190,6 @@ export class DualPickerComponent extends DatePickerBase implements OnChanges {
let caret = $(this.myElement.nativeElement).find(".ct-dp-caret");
picker.removeClass("display-above");
picker.addClass("display-below");
picker.css("top", ($(element.nativeElement).height()) + "px");
picker.css("left", "0px");
caret.css({ "left": (left + (picker.width() * .05)) + "px" });
}
Expand Down

0 comments on commit 3c24f7e

Please sign in to comment.