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

Commit cc55663

Browse files
committed
Add support for more options
* Add tests * Upgrade to bootstrap-datepicker 1.3.1 * Upgrade to Ember CLI 0.1.5, https://github.com/ember-cli/ember-cli/releases/tag/v0.1.5 * Scriptify the project 😄 * Add the playground page * Add support for `calendarWeeks` option * Add support for `clearBtn` option * Add support for `daysOfWeekDisabled` option * Add support for `endDate` option * Add support for `startDate` option * Add support for `forceParse` option * Add support for `keyboardNavigation` option * Add support for `minViewMode` option * Add support for `orientation` option * Add support for `startView` option * Get back to Ember.Component, but keep all attribute bindings
1 parent a40de58 commit cc55663

File tree

26 files changed

+856
-76
lines changed

26 files changed

+856
-76
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ indent_size = 2
2929
indent_style = space
3030
indent_size = 2
3131

32-
[*.md]
32+
[*.{diff,md}]
3333
trim_trailing_whitespace = false

.jshintrc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"predef": [
3+
"document",
4+
"window",
5+
"-Promise"
6+
],
7+
"browser": true,
8+
"boss": true,
9+
"curly": true,
10+
"debug": false,
11+
"devel": true,
12+
"eqeqeq": true,
13+
"evil": true,
14+
"forin": false,
15+
"immed": false,
16+
"laxbreak": false,
17+
"newcap": true,
18+
"noarg": true,
19+
"noempty": false,
20+
"nonew": false,
21+
"nomen": false,
22+
"onevar": false,
23+
"plusplus": false,
24+
"regexp": false,
25+
"undef": true,
26+
"sub": true,
27+
"strict": false,
28+
"white": false,
29+
"eqnull": true,
30+
"esnext": true,
31+
"unused": true
32+
}

.travis.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ cache:
77
directories:
88
- node_modules
99

10+
before_install:
11+
- "npm config set spin false"
12+
- "npm install -g npm@^2"
13+
1014
install:
11-
- npm install -g bower
12-
- npm install
13-
- bower install
15+
- script/bootstrap
1416

1517
script:
16-
- npm test
18+
- script/cibuild

Brocfile.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* jshint node: true */
12
/* global require, module */
23

34
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
@@ -17,4 +18,11 @@ var app = new EmberAddon();
1718
// please specify an object with the list of modules as keys
1819
// along with the exports of each module as its value.
1920

21+
app.import('bower_components/bootstrap/dist/css/bootstrap.css');
22+
app.import('bower_components/bootstrap/dist/css/bootstrap.css.map', {
23+
destDir: 'assets'
24+
});
25+
26+
app.import('bower_components/bootstrap-datepicker/js/locales/bootstrap-datepicker.de.js');
27+
2028
module.exports = app.toTree();

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 Alexander Sulim
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 136 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,188 @@
11
# Ember CLI datepicker
22

3+
[![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)
4+
35
The addon provides you a `bootstrap-datepicker` input component. It can be used in Ember CLI applications.
46

5-
The input component is based on [bootstrap-datepicker library](https://github.com/eternicode/bootstrap-datepicker). The datepicker input field extends [`Ember.TextField`](http://emberjs.com/api/classes/Ember.TextField.html). That means you have all attribute bindings available on `Ember.TextField`.
7+
The input component is based on [bootstrap-datepicker library](https://github.com/eternicode/bootstrap-datepicker).
68

79
## Installation
810

11+
If you are using Ember CLI 0.1.5 and higher, just run within your project directory:
12+
13+
```bash
14+
ember install:addon ember-cli-bootstrap-datepicker
15+
```
16+
17+
When your Ember CLI version is below 0.1.5, please run within your project directory:
18+
919
```bash
1020
npm install --save-dev ember-cli-bootstrap-datepicker
1121
ember generate bootstrap-datepicker
1222
```
1323

1424
## Usage
1525

26+
Basic example:
27+
1628
```handlebars
1729
{{bootstrap-datepicker value=expiresAt}}
1830
```
1931

20-
The component supports many options of the bootstrap-datepicker library:
32+
The component supports many options of the bootstrap-datepicker library. Let me show you how to use them :sparkles:
33+
34+
### Available options
35+
36+
#### autoclose
37+
38+
Type: `Boolean`
39+
Default: `false`
40+
41+
```handlebars
42+
{{bootstrap-datepicker value=expiresAt autoclose=true}}
43+
```
44+
45+
#### calendarWeeks
46+
47+
Type: `Boolean`
48+
Default: `false`
49+
50+
```handlebars
51+
{{bootstrap-datepicker value=expiresAt calendarWeeks=true}}
52+
```
53+
54+
#### clearBtn
55+
56+
Type: `Boolean`
57+
Default: `false`
2158

22-
* **autoclose**, default value `true`
23-
* **format**, default value `dd.mm.yyyy`
24-
* **language**, default value `en`
25-
* **todayBtn**, default value `false`
26-
* **todayHighlight**, default value `false`
27-
* **weekStart**, default value 1 (Monday)
59+
```handlebars
60+
{{bootstrap-datepicker value=expiresAt clearBtn=true}}
61+
```
2862

29-
Let me show you how to use all these options.
63+
#### daysOfWeekDisabled
3064

31-
Autoclose:
65+
Type: `Array` or `String`
66+
Default: `""` or `[]`
3267

3368
```handlebars
34-
{{bootstrap-datepicker value=expiresAt autoclose=false}}
69+
{{bootstrap-datepicker value=expiresAt daysOfWeekDisabled="1,2"}}
3570
```
3671

37-
Format:
72+
#### endDate
73+
74+
Type: `Date` or `String`
75+
Default: `Infinity` (end of time)
3876

3977
```handlebars
40-
{{bootstrap-datepicker value=expiresAt format="dd/mm/yy"}}
78+
{{bootstrap-datepicker value=expiresAt endDate="01/01/2018"}}
4179
```
4280

43-
language:
81+
#### forceParse
82+
83+
Type: `Boolean`
84+
Default: `true`
4485

45-
Default locale is `en`. When you need another language, you should import a locale file, e.g.
86+
```handlebars
87+
{{bootstrap-datepicker value=expiresAt forceParse=false}}
88+
```
89+
90+
#### format
91+
92+
Type: `String`
93+
Default: `'mm/dd/yyyy'`
94+
95+
```handlebars
96+
{{bootstrap-datepicker value=expiresAt format="dd.mm.yy"}}
97+
```
98+
99+
#### keyboardNavigation
100+
101+
Type: `Boolean`
102+
Default: `true`
103+
104+
```handlebars
105+
{{bootstrap-datepicker value=expiresAt keyboardNavigation=false}}
106+
```
107+
108+
#### language
109+
110+
Type: `String`
111+
Default: `'en'`
112+
113+
When you need another language, you should import a locale file using your Brocfile.js. Just import `bower_components/bootstrap-datepicker/js/locales/bootstrap-datepicker.<LANGUAGE_CODE>.js`, e.g.:
46114

47115
```javascript
48116
// Brocfile.js
49-
50117
app.import('bower_components/bootstrap-datepicker/js/locales/bootstrap-datepicker.de.js');
51118
```
52-
53119
```handlebars
120+
{{! somewhere in template }}
54121
{{bootstrap-datepicker value=expiresAt language="de"}}
55122
```
56123

57-
todayBtn:
124+
#### minViewMode
125+
126+
Type: `Number` or `String`
127+
Default: `0` or `'days'`
58128

59129
```handlebars
60-
{{bootstrap-datepicker value=expiresAt todayBtn=true}}
130+
{{bootstrap-datepicker value=expiresAt minViewMode="months"}}
61131
```
62132

63-
todayHighlight:
133+
#### orientation
134+
135+
Type: `String`
136+
Default: `'auto'`
64137

65138
```handlebars
66-
{{bootstrap-datepicker value=expiresAt todayHighlight=true}}
139+
{{bootstrap-datepicker value=expiresAt orientation="right"}}
67140
```
68141

69-
weekStart:
142+
#### startDate
143+
144+
Type: `Date` or `String`
145+
Default: `-Infinity` (beginning of time)
70146

71147
```handlebars
72-
{{bootstrap-datepicker value=expiresAt weekStart=0}}
148+
{{bootstrap-datepicker value=expiresAt startDate="01/01/2014"}}
73149
```
74150

75-
All options at once:
151+
#### startView
152+
153+
Type: `Number` or `String`
154+
Default: `0` or `'month'`
76155

77156
```handlebars
78-
{{bootstrap-datepicker value=expiresAt autoclose=false format="dd/mm/yy" language="de" todayBtn=true todayHighlight=true weekStart=0}}
157+
{{bootstrap-datepicker value=expiresAt startView="decade"}}
158+
```
159+
160+
#### todayBtn
161+
162+
Type: `Boolean`
163+
Default: `false`
164+
165+
```handlebars
166+
{{bootstrap-datepicker value=expiresAt todayBtn=true}}
167+
```
168+
169+
#### todayHighlight
170+
171+
Type: `Boolean`
172+
Default: `false`
173+
174+
```handlebars
175+
{{bootstrap-datepicker value=expiresAt todayHighlight=true}}
176+
```
177+
178+
#### weekStart
179+
180+
Type: `Number`
181+
Default: `0` (Sunday)
182+
183+
184+
```handlebars
185+
{{bootstrap-datepicker value=expiresAt weekStart=1}}
79186
```
80187

81188
## Contributing
@@ -85,3 +192,7 @@ All options at once:
85192
3. Commit your changes (`git commit -am 'Add some feature'`)
86193
4. Push to the branch (`git push origin my-new-feature`)
87194
5. Create a new Pull Request
195+
196+
## License
197+
198+
[MIT License](https://github.com/soulim/ember-cli-bootstrap-datepicker/blob/master/LICENSE.md)

0 commit comments

Comments
 (0)