Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.

Commit 1f704c9

Browse files
committed
Add support for inline mode
1 parent c42aaec commit 1f704c9

File tree

7 files changed

+165
-119
lines changed

7 files changed

+165
-119
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Ember CLI datepicker
1+
# Ember CLI datepicker add-on
22

33
[![Build Status](https://travis-ci.org/soulim/ember-cli-bootstrap-datepicker.svg?branch=master&style=flat)](https://travis-ci.org/soulim/ember-cli-bootstrap-datepicker)
44

5-
The addon provides you a `bootstrap-datepicker` input component. It can be used in Ember CLI applications.
5+
The add-on provides you a date input component based on amazing bootstrap-datepicker library. It supports popup and inline mode, and can be used in Ember CLI applications.
66

7-
The input component is based on [bootstrap-datepicker library](https://github.com/eternicode/bootstrap-datepicker).
7+
[Online demo](http://sul.im/ember-cli-bootstrap-datepicker)
88

99
## Installation
1010

@@ -29,6 +29,12 @@ Basic example:
2929
{{bootstrap-datepicker value=expiresAt}}
3030
```
3131

32+
Use separate component for inline mode:
33+
34+
```handlebars
35+
{{bootstrap-datepicker-inline value=expiresAt}}
36+
```
37+
3238
The component supports many options of the bootstrap-datepicker library. Let me show you how to use them :sparkles:
3339

3440
### Available options
@@ -193,6 +199,11 @@ Default: `0` (Sunday)
193199
4. Push to the branch (`git push origin my-new-feature`)
194200
5. Create a new Pull Request
195201

202+
## Credits
203+
204+
The add-on is based on [bootstrap-datepicker](https://github.com/eternicode/bootstrap-datepicker).
205+
206+
196207
## License
197208

198209
[MIT License](https://github.com/soulim/ember-cli-bootstrap-datepicker/blob/master/LICENSE.md)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Ember from 'ember';
2+
import DatepickerSupport from 'ember-cli-bootstrap-datepicker/components/datepicker-support';
3+
4+
export default Ember.Component.extend(DatepickerSupport, {
5+
tagName: 'div'
6+
});
Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Ember from 'ember';
2+
import DatepickerSupport from 'ember-cli-bootstrap-datepicker/components/datepicker-support';
23

3-
export default Ember.Component.extend({
4+
export default Ember.Component.extend(DatepickerSupport, {
45
instrumentDisplay: '{{input type="text"}}',
56

67
classNames: ['ember-text-field'],
@@ -37,51 +38,5 @@ export default Ember.Component.extend({
3738
'type'
3839
],
3940

40-
type: 'text',
41-
42-
value: null,
43-
44-
setupBootstrapDatepicker: function() {
45-
var self = this,
46-
element = this.$(),
47-
value = this.get('value');
48-
49-
element.
50-
datepicker({
51-
autoclose: this.get('autoclose'),
52-
calendarWeeks: this.get('calendarWeeks'),
53-
clearBtn: this.get('clearBtn'),
54-
daysOfWeekDisabled: this.get('daysOfWeekDisabled'),
55-
endDate: this.get('endDate'),
56-
forceParse: this.get('forceParse'),
57-
format: this.get('format'),
58-
keyboardNavigation: this.get('keyboardNavigation'),
59-
language: this.get('language'),
60-
minViewMode: this.get('minViewMode'),
61-
orientation: this.get('orientation'),
62-
startDate: this.get('startDate'),
63-
startView: this.get('startView'),
64-
todayBtn: this.get('todayBtn'),
65-
todayHighlight: this.get('todayHighlight'),
66-
weekStart: this.get('weekStart')
67-
}).
68-
on('changeDate', function(event) {
69-
Ember.run(function() {
70-
self.didSelectDate(event);
71-
});
72-
});
73-
74-
if (value) {
75-
element.datepicker('update', new Date(value));
76-
}
77-
}.on('didInsertElement'),
78-
79-
teardownBootstrapDatepicker: function() {
80-
this.$().datepicker('remove');
81-
}.on('willDestroyElement'),
82-
83-
didSelectDate: function() {
84-
var date = this.$().datepicker('getUTCDate');
85-
this.set('value', date.toISOString());
86-
}
41+
type: 'text'
8742
});
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import Ember from 'ember';
2+
3+
export default Ember.Mixin.create({
4+
value: null,
5+
6+
setupBootstrapDatepicker: function() {
7+
var self = this,
8+
element = this.$(),
9+
value = this.get('value');
10+
11+
element.
12+
datepicker({
13+
autoclose: this.get('autoclose'),
14+
calendarWeeks: this.get('calendarWeeks'),
15+
clearBtn: this.get('clearBtn'),
16+
daysOfWeekDisabled: this.get('daysOfWeekDisabled'),
17+
endDate: this.get('endDate'),
18+
forceParse: this.get('forceParse'),
19+
format: this.get('format'),
20+
keyboardNavigation: this.get('keyboardNavigation'),
21+
language: this.get('language'),
22+
minViewMode: this.get('minViewMode'),
23+
orientation: this.get('orientation'),
24+
startDate: this.get('startDate'),
25+
startView: this.get('startView'),
26+
todayBtn: this.get('todayBtn'),
27+
todayHighlight: this.get('todayHighlight'),
28+
weekStart: this.get('weekStart')
29+
}).
30+
on('changeDate', function(event) {
31+
Ember.run(function() {
32+
self.didChangeDate(event);
33+
});
34+
});
35+
36+
if (value) {
37+
element.datepicker('update', new Date(value));
38+
}
39+
}.on('didInsertElement'),
40+
41+
teardownBootstrapDatepicker: function() {
42+
this.$().datepicker('remove');
43+
}.on('willDestroyElement'),
44+
45+
didChangeDate: function(event) {
46+
var isoDate = null;
47+
48+
if (event.date) {
49+
isoDate = this.$().datepicker('getUTCDate').toISOString();
50+
}
51+
52+
this.set('value', isoDate);
53+
}
54+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Ember from 'ember';
2+
import BootstrapDatepickerInlineComponent from 'ember-cli-bootstrap-datepicker/components/bootstrap-datepicker-inline';
3+
4+
export default BootstrapDatepickerInlineComponent;

tests/dummy/app/styles/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ body {
99
padding-bottom: 20px;
1010
}
1111

12-
.panel-footer pre {
12+
.panel-heading pre {
1313
padding: 0;
1414
margin-top: 0;
1515
margin-bottom: 0;

0 commit comments

Comments
 (0)