Skip to content

Commit 6c00adc

Browse files
committed
Use configuration setting for date and time icons. Fixes #13.
1 parent f02f507 commit 6c00adc

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

README.md

+3-13
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ See [momentjs'](http://momentjs.com/docs/#/displaying/format/) docs for valid fo
8484

8585

8686

87-
#### iconClasses, iconText
88-
89-
Defaults: `glyphicon glyphicon-calendar`, ''
90-
91-
Accepts: `string`
92-
93-
```handlebars
94-
{{bs-datetimepicker iconClasses='material-icons' iconText='face'}}
95-
```
96-
97-
Replaces the calendar icon class and text.
98-
99-
10087
#### icons
10188

10289
Defaults: `component defaults`
@@ -112,6 +99,9 @@ Defaults: `component defaults`
11299

113100
Replaces icon classes globally.
114101
Supported icons include `clear`, `close`, `date`, `down`, `next`, `previous`, `time`, `today` and `up`.
102+
If inner html has to be set (Material Icons), use `::after` pseudo selector.
103+
104+
*Note:* When using only the time picker, pass `isTime=true` so that the correct icon is displayed.
115105

116106

117107

addon/components/bs-datetimepicker.js

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,29 @@ import layout from '../templates/components/bs-datetimepicker';
33

44
const {
55
$,
6-
Component
6+
Component,
7+
computed
78
} = Ember;
89

10+
const {
11+
defaults
12+
} = $.fn.datetimepicker;
13+
914
export default Component.extend({
1015
layout,
1116
tagName: 'div',
1217
classNames: ['input-group date'],
13-
iconClasses: ['glyphicon glyphicon-calendar'],
14-
iconText: '',
18+
19+
iconClasses: computed('isTime', function() {
20+
if (this.get('isTime')) {
21+
return this.getWithDefault('config.icons.time', defaults.icons.time);
22+
}
23+
24+
return this.getWithDefault('config.icons.date', defaults.icons.date);
25+
}),
1526

1627
didInsertElement() {
1728
this._super(...arguments);
18-
let { defaults } = $.fn.datetimepicker;
1929

2030
let icons = {
2131
clear: this.getWithDefault('config.icons.clear', defaults.icons.clear),
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<input type="text" class="form-control">
22
<span class="input-group-addon">
3-
<i class={{iconClasses}}>
4-
{{iconText}}
5-
</i>
3+
<i class={{iconClasses}}></i>
64
</span>

0 commit comments

Comments
 (0)