ember-cli-bootstrap-datepicker
Advanced tools
Comparing version 0.5.5 to 0.5.6
@@ -12,5 +12,7 @@ import Ember from 'ember'; | ||
endDate: undefined, | ||
customParser: function(value) { | ||
return value; | ||
}, | ||
setupBootstrapDatepicker: Ember.on('didInsertElement', function() { | ||
var self = this; | ||
@@ -29,3 +31,3 @@ this.$(). | ||
forceParse: this.get('forceParse'), | ||
format: this.get('format'), | ||
format: this._toString(this.get('format')), | ||
immediateUpdates: this.get('immediateUpdates'), | ||
@@ -48,11 +50,26 @@ keyboardNavigation: this.get('keyboardNavigation'), | ||
}). | ||
on('changeDate', function(event) { | ||
Ember.run(function() { | ||
self._didChangeDate(event); | ||
on('changeDate', event => { | ||
Ember.run(() => { | ||
this._didChangeDate(event); | ||
}); | ||
}). | ||
on('input', function() { | ||
if (!self.$().val()) { | ||
self.set('value', null); | ||
} | ||
on('changeMonth', event => { | ||
this.sendAction('changeMonth', event.date); | ||
}). | ||
on('focusout', event => { | ||
this.sendAction('focus-out', this, event); | ||
}). | ||
on('focusin', event => { | ||
this.sendAction('focus-in', this, event); | ||
}). | ||
on('clearDate', event => { | ||
Ember.run(() => { | ||
this._didChangeDate(event); | ||
}); | ||
}). | ||
on('show', () => { | ||
this.sendAction('show'); | ||
}). | ||
on('hide', () => { | ||
this.sendAction('hide'); | ||
}); | ||
@@ -84,3 +101,7 @@ | ||
this.set('value', value); | ||
this.sendAction('changeDate', value); | ||
if (event.type === 'clearDate') { | ||
this.sendAction('clearDate'); | ||
} else { | ||
this.sendAction('changeDate', value); | ||
} | ||
}, | ||
@@ -116,4 +137,5 @@ | ||
this.addObserver('format', function() { | ||
this.$().datepicker('format', this.get('format')); | ||
this.$().data('datepicker')._process_options({format: this.get('format')}); | ||
let format = this._toString(this.get('format')); | ||
this.$().datepicker('format', format); | ||
this.$().data('datepicker')._process_options({format: format}); | ||
this._updateDatepicker(); | ||
@@ -124,5 +146,5 @@ }); | ||
_updateDatepicker: function() { | ||
var self = this, | ||
element = this.$(), | ||
var element = this.$(), | ||
value = this.get('value'), | ||
customParser = this.get('customParser'), | ||
dates = []; | ||
@@ -135,2 +157,4 @@ | ||
value = customParser(value); | ||
switch (Ember.typeOf(value)) { | ||
@@ -146,4 +170,4 @@ case 'array': | ||
} | ||
dates = dates.map(function(date) { | ||
return (Ember.isNone(date)) ? null : self._getDateCloneWithNoTime(date); | ||
dates = dates.map(date => { | ||
return (Ember.isNone(date)) ? null : this._getDateCloneWithNoTime(date); | ||
}); | ||
@@ -167,3 +191,21 @@ | ||
return clone; | ||
}, | ||
/** | ||
* Fix Issue #59 | ||
* _toString Checks and converts the input object and returns a String if it is required and feasible | ||
* @param {Object} obj The object to check | ||
* @return {Object} The object as a String | ||
*/ | ||
_toString: function (obj) { | ||
if (typeof obj !== typeof Undefined && obj !== typeof String) { | ||
if (typeof obj.toString === typeof Function) { | ||
obj = obj.toString(); | ||
} else { | ||
// No toString() method available - There is nothing else that can be done | ||
throw new Error("At _toString() (datepicker-support.js) - No toString() method available for the passed object."); | ||
} | ||
} | ||
return obj; | ||
} | ||
}); |
@@ -0,1 +1,2 @@ | ||
/*jshint node:true*/ | ||
module.exports = { | ||
@@ -2,0 +3,0 @@ scenarios: [ |
@@ -0,1 +1,2 @@ | ||
/*jshint node:true*/ | ||
'use strict'; | ||
@@ -2,0 +3,0 @@ |
@@ -10,5 +10,8 @@ /* jshint node: true */ | ||
app.import(app.bowerDirectory + '/bootstrap-datepicker/dist/js/bootstrap-datepicker.js'); | ||
app.import(app.bowerDirectory + '/bootstrap-datepicker/dist/css/bootstrap-datepicker.css'); | ||
if (process.env.EMBER_CLI_FASTBOOT !== 'true') { | ||
app.import(app.bowerDirectory + '/bootstrap-datepicker/dist/js/bootstrap-datepicker.js'); | ||
app.import(app.bowerDirectory + '/bootstrap-datepicker/dist/css/bootstrap-datepicker.css'); | ||
} | ||
} | ||
}; | ||
{ | ||
"name": "ember-cli-bootstrap-datepicker", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "Datepicker component for Ember CLI based on bootstrap-datepicker. It doesn't have any external dependency except bootstrap-datepicker, supports popup and inline modes.", | ||
@@ -21,20 +21,20 @@ "directories": { | ||
"devDependencies": { | ||
"broccoli-asset-rev": "^2.1.2", | ||
"ember-cli": "1.13.8", | ||
"ember-cli-app-version": "0.5.0", | ||
"broccoli-asset-rev": "^2.2.0", | ||
"ember-cli": "1.13.15", | ||
"ember-cli-app-version": "^1.0.0", | ||
"ember-cli-content-security-policy": "0.4.0", | ||
"ember-cli-dependency-checker": "^1.0.1", | ||
"ember-cli-htmlbars": "0.7.9", | ||
"ember-cli-htmlbars-inline-precompile": "^0.2.0", | ||
"ember-cli-ic-ajax": "0.2.1", | ||
"ember-cli-dependency-checker": "^1.1.0", | ||
"ember-cli-htmlbars": "^1.0.1", | ||
"ember-cli-htmlbars-inline-precompile": "^0.3.1", | ||
"ember-cli-ic-ajax": "0.2.4", | ||
"ember-cli-inject-live-reload": "^1.3.1", | ||
"ember-cli-qunit": "^1.0.0", | ||
"ember-cli-release": "0.2.3", | ||
"ember-cli-sri": "^1.0.3", | ||
"ember-cli-qunit": "^1.0.4", | ||
"ember-cli-release": "0.2.8", | ||
"ember-cli-sri": "^1.2.0", | ||
"ember-cli-uglify": "^1.2.0", | ||
"ember-data": "1.13.8", | ||
"ember-disable-proxy-controllers": "^1.0.0", | ||
"ember-export-application-global": "^1.0.3", | ||
"ember-data": "1.13.15", | ||
"ember-disable-proxy-controllers": "^1.0.1", | ||
"ember-export-application-global": "^1.0.4", | ||
"ember-disable-prototype-extensions": "^1.0.0", | ||
"ember-try": "0.0.6" | ||
"ember-try": "~0.0.8" | ||
}, | ||
@@ -50,3 +50,3 @@ "keywords": [ | ||
"dependencies": { | ||
"ember-cli-babel": "^5.1.3" | ||
"ember-cli-babel": "^5.1.5" | ||
}, | ||
@@ -53,0 +53,0 @@ "main": "index.js", |
100
README.md
@@ -206,2 +206,102 @@ # Ember CLI datepicker add-on | ||
### Actions | ||
#### changeDate | ||
The changeDate action is triggered when the selected date changes. It can be specified like this: | ||
```handlebars | ||
{{bootstrap-datepicker changeDate="changeDateAction"}} | ||
``` | ||
The action can be handled by a parent component, controller or route: | ||
```javascript | ||
actions: { | ||
changeDateAction(date) { | ||
// do sth with the new date | ||
} | ||
} | ||
``` | ||
### changeMonth | ||
The changeMonth action is triggered when the view month changes (e.g. user click on "prev"/"next" buttons). | ||
Action called has new view date as first argument. | ||
```handlebars | ||
{{bootstrap-datepicker changeMonth="changeMonthAction"}} | ||
``` | ||
```javascript | ||
actions: { | ||
changeDateAction(date) { | ||
// do sth with the new view date | ||
} | ||
} | ||
``` | ||
#### clearDate | ||
The clearDate action is triggered when the date is cleared (e.g. when the "clear" button is clicked). | ||
```handlebars | ||
{{bootstrap-datepicker clearDate="clearDateAction"}} | ||
``` | ||
The action can be handled by a parent component, controller or route: | ||
```javascript | ||
actions: { | ||
clearDateAction() { | ||
// do sth | ||
} | ||
} | ||
``` | ||
#### focus-in & focus-out | ||
The focus-in and focus-out actions are triggered when the respective focus events occur on the input field. | ||
```handlebars | ||
{{bootstrap-datepicker focus-in="focusInAction" focus-out="focusOutAction"}} | ||
``` | ||
The actions can be handled by a parent component, controller or route: | ||
```javascript | ||
actions: { | ||
focusInAction(component, event) { | ||
// handle event | ||
}, | ||
focusOutAction(component, event) { | ||
// handle event | ||
} | ||
} | ||
``` | ||
#### hide & show | ||
The hide and show actions are triggered when the datepicker is either hidden or displayed. | ||
```handlebars | ||
{{bootstrap-datepicker hide="hideAction" show="showAction"}} | ||
``` | ||
The actions can be handled by a parent component, controller or route: | ||
```javascript | ||
actions: { | ||
hideAction() { | ||
// datepicker is hidden | ||
}, | ||
showAction() { | ||
// datepicker is shown | ||
} | ||
} | ||
``` | ||
## Contributing | ||
@@ -208,0 +308,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20648
20
297
322
Updatedember-cli-babel@^5.1.5