Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions addon/components/datepicker-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default Mixin.create({
},

setupBootstrapDatepicker: on('didInsertElement', function() {

this.$().
datepicker({
autoclose: this.get('autoclose'),
Expand Down Expand Up @@ -55,24 +54,34 @@ export default Mixin.create({
});
}).
on('changeMonth', event => {
this.sendAction('changeMonth', event.date);
if (this.changeMonth) {
this.changeMonth(event.date);
}
}).
on('focusout', event => {
this.sendAction('focus-out', this, event);
if (this.focusOut) {
this.focusOut(this, event);
}
}).
on('focusin', event => {
this.sendAction('focus-in', this, event);
if (this.focusIn) {
this.focusIn(this, event);
}
}).
on('clearDate', event => {
run(() => {
this._didChangeDate(event);
});
}).
on('show', () => {
this.sendAction('show');
if (this.show) {
this.show();
}
}).
on('hide', () => {
this.sendAction('hide');
if (this.hide) {
this.hide();
}
});

this._updateDatepicker();
Expand All @@ -97,12 +106,14 @@ export default Mixin.create({
}
}

this.set('mustUpdateInput', false);
this.set('value', value);
if (event.type === 'clearDate') {
this.sendAction('clearDate');
if (this.clearDate) {
this.clearDate();
}
} else {
this.sendAction('changeDate', value);
if (this.changeDate) {
this.changeDate(value);
}
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ moduleForComponent('bootstrap-datepicker', 'BootstrapDatepickerComponent', {
test('triggers specified action on focusout event', function (assert) {
assert.expect(1);

this.render(hbs`
{{bootstrap-datepicker focus-out="focusOutAction"}}
`);

var actionIsTriggered = false;
this.on('focusOutAction', () => {
actionIsTriggered = true;
});

this.render(hbs`
{{bootstrap-datepicker focusOut=(action "focusOutAction")}}
`);

this.$('input.ember-text-field').trigger('focusout');

assert.ok(actionIsTriggered, 'action is triggered on focusout');
Expand All @@ -25,15 +25,15 @@ test('triggers specified action on focusout event', function (assert) {
test('triggers specified action on focusin event', function (assert) {
assert.expect(1);

this.render(hbs`
{{bootstrap-datepicker focus-in="focusInAction"}}
`);

var actionIsTriggered = false;
this.on('focusInAction', () => {
actionIsTriggered = true;
});

this.render(hbs`
{{bootstrap-datepicker focusIn=(action "focusInAction")}}
`);

this.$('input.ember-text-field').trigger('focusin');

assert.ok(actionIsTriggered, 'action is triggered on focusin');
Expand All @@ -50,7 +50,7 @@ test('triggers changeDate action when date selection changes', function(assert)
});

this.render(hbs`
{{bootstrap-datepicker value=myDate changeDate="myAction"}}
{{bootstrap-datepicker value=myDate changeDate=(action "myAction")}}
`);

var input = this.$('input.ember-text-field');
Expand All @@ -70,7 +70,7 @@ test('triggers clearDate action when date selection is cleared', function(assert
});

this.render(hbs`
{{bootstrap-datepicker value=myDate clearDate="myAction"}}
{{bootstrap-datepicker value=myDate clearDate=(action "myAction")}}
`);

var input = this.$('input.ember-text-field');
Expand All @@ -88,7 +88,7 @@ test('triggers show action when date datepicker is displayed', function(assert)
});

this.render(hbs`
{{bootstrap-datepicker show="myAction"}}
{{bootstrap-datepicker show=(action "myAction")}}
`);

this.$('input.ember-text-field').trigger('show');
Expand All @@ -105,7 +105,7 @@ test('triggers hide action when date datepicker is hidden', function(assert) {
});

this.render(hbs`
{{bootstrap-datepicker hide="myAction"}}
{{bootstrap-datepicker hide=(action "myAction")}}
`);

this.$('input.ember-text-field').trigger('hide');
Expand All @@ -123,7 +123,7 @@ test('triggers changeMonth when month is changed', function(assert) {
});

this.render(hbs`
{{bootstrap-datepicker-inline changeMonth="myAction"}}
{{bootstrap-datepicker-inline changeMonth=(action "myAction")}}
`);

// there are several not visibile datepickers having .next; only trigger the visible one
Expand Down