Skip to content

Commit

Permalink
DATA-122: fix JQuery import.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-daures committed Mar 18, 2022
1 parent e6b109c commit df2f5d9
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 151 deletions.
60 changes: 28 additions & 32 deletions dist/ng2-daterangepicker/esm2020/lib/daterangepicker.component.mjs

Large diffs are not rendered by default.

59 changes: 28 additions & 31 deletions dist/ng2-daterangepicker/fesm2015/ng2-daterangepicker.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as i0 from '@angular/core';
import { Injectable, EventEmitter, Directive, Input, Output, NgModule } from '@angular/core';
import * as $ from 'jquery';
import $__default from 'jquery';
import 'bootstrap-daterangepicker';

class DaterangepickerConfig {
Expand Down Expand Up @@ -55,38 +56,34 @@ class DaterangePickerComponent {
render() {
this.targetOptions = Object.assign({}, this.config.settings, this.options);
// cast $ to any to avoid jquery type checking
if ($) {
$(this.input.nativeElement).daterangepicker(this.targetOptions, this.callback.bind(this));
this.datePicker = $(this.input.nativeElement).data('daterangepicker');
}
$__default(this.input.nativeElement).daterangepicker(this.targetOptions, this.callback.bind(this));
this.datePicker = $__default(this.input.nativeElement).data('daterangepicker');
}
attachEvents() {
if ($) {
$(this.input.nativeElement).on('cancel.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.cancelDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('apply.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.applyDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('hideCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideCalendarDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('showCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showCalendarDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('hide.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('show.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showDaterangepicker.emit(event);
});
}
$__default(this.input.nativeElement).on('cancel.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.cancelDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('apply.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.applyDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('hideCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideCalendarDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('showCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showCalendarDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('hide.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('show.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showDaterangepicker.emit(event);
});
}
callback(start, end, label) {
this.activeRange = {
Expand All @@ -98,7 +95,7 @@ class DaterangePickerComponent {
}
destroyPicker() {
try {
$(this.input.nativeElement).data('daterangepicker').remove();
$__default(this.input.nativeElement).data('daterangepicker').remove();
}
catch (e) {
console.log(e.message);
Expand Down

Large diffs are not rendered by default.

59 changes: 28 additions & 31 deletions dist/ng2-daterangepicker/fesm2020/ng2-daterangepicker.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as i0 from '@angular/core';
import { Injectable, EventEmitter, Directive, Input, Output, NgModule } from '@angular/core';
import * as $ from 'jquery';
import $__default from 'jquery';
import 'bootstrap-daterangepicker';

class DaterangepickerConfig {
Expand Down Expand Up @@ -55,38 +56,34 @@ class DaterangePickerComponent {
render() {
this.targetOptions = Object.assign({}, this.config.settings, this.options);
// cast $ to any to avoid jquery type checking
if ($) {
$(this.input.nativeElement).daterangepicker(this.targetOptions, this.callback.bind(this));
this.datePicker = $(this.input.nativeElement).data('daterangepicker');
}
$__default(this.input.nativeElement).daterangepicker(this.targetOptions, this.callback.bind(this));
this.datePicker = $__default(this.input.nativeElement).data('daterangepicker');
}
attachEvents() {
if ($) {
$(this.input.nativeElement).on('cancel.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.cancelDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('apply.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.applyDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('hideCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideCalendarDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('showCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showCalendarDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('hide.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideDaterangepicker.emit(event);
});
$(this.input.nativeElement).on('show.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showDaterangepicker.emit(event);
});
}
$__default(this.input.nativeElement).on('cancel.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.cancelDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('apply.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.applyDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('hideCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideCalendarDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('showCalendar.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showCalendarDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('hide.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.hideDaterangepicker.emit(event);
});
$__default(this.input.nativeElement).on('show.daterangepicker', (e, picker) => {
let event = { event: e, picker: picker };
this.showDaterangepicker.emit(event);
});
}
callback(start, end, label) {
this.activeRange = {
Expand All @@ -98,7 +95,7 @@ class DaterangePickerComponent {
}
destroyPicker() {
try {
$(this.input.nativeElement).data('daterangepicker').remove();
$__default(this.input.nativeElement).data('daterangepicker').remove();
}
catch (e) {
console.log(e.message);
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ng2-daterangepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-daterangepicker",
"version": "2.1.2",
"version": "2.1.3",
"peerDependencies": {
"@angular/common": "^13.2.0",
"@angular/core": "^13.2.0",
Expand Down
2 changes: 1 addition & 1 deletion projects/ng2-daterangepicker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-daterangepicker",
"version": "2.1.2",
"version": "2.1.3",
"peerDependencies": {
"@angular/common": "^13.2.0",
"@angular/core": "^13.2.0",
Expand Down
100 changes: 47 additions & 53 deletions projects/ng2-daterangepicker/src/lib/daterangepicker.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Directive, OnInit, AfterViewInit, Input, Output, EventEmitter } from '@angular/core';
import { KeyValueDiffer, KeyValueDiffers, ElementRef, OnDestroy, DoCheck } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { Directive, AfterViewInit, Input, Output, EventEmitter } from '@angular/core';
import { KeyValueDiffers, ElementRef, OnDestroy, DoCheck } from '@angular/core';
import { DaterangepickerConfig } from './config.service';

import * as $ from "jquery";
import $ from "jquery";
import * as moment from 'moment';
import 'bootstrap-daterangepicker';


@Directive({
selector: '[daterangepicker]',
})
Expand Down Expand Up @@ -49,58 +49,52 @@ export class DaterangePickerComponent implements AfterViewInit, OnDestroy, DoChe
this.targetOptions = Object.assign({}, this.config.settings, this.options);

// cast $ to any to avoid jquery type checking
if ($)
{
(<any>$(this.input.nativeElement)).daterangepicker(this.targetOptions, this.callback.bind(this));
this.datePicker = (<any>$(this.input.nativeElement)).data('daterangepicker');
}
(<any>$(this.input.nativeElement)).daterangepicker(this.targetOptions, this.callback.bind(this));
this.datePicker = $(this.input.nativeElement).data('daterangepicker');
}

attachEvents() {
if ($)
{
$(this.input.nativeElement).on('cancel.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.cancelDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('apply.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.applyDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('hideCalendar.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.hideCalendarDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('showCalendar.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.showCalendarDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('hide.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.hideDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('show.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.showDaterangepicker.emit(event);
}
);
}
$(this.input.nativeElement).on('cancel.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.cancelDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('apply.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.applyDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('hideCalendar.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.hideCalendarDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('showCalendar.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.showCalendarDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('hide.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.hideDaterangepicker.emit(event);
}
);

$(this.input.nativeElement).on('show.daterangepicker',
(e:any, picker:any) => {
let event = { event: e, picker: picker };
this.showDaterangepicker.emit(event);
}
);
}

private callback(start?: any, end?: any, label?: any): void {
Expand Down

0 comments on commit df2f5d9

Please sign in to comment.