Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-cli-bootstrap-datepicker

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-bootstrap-datepicker - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

60

addon/components/datepicker-support.js

@@ -9,3 +9,4 @@ import Ember from 'ember';

element = this.$(),
value = this.get('value');
value = this.get('value'),
dates = [];

@@ -24,2 +25,4 @@ element.

minViewMode: this.get('minViewMode'),
multidate: this.get('multidate'),
multidateSeparator: this.get('multidateSeparator'),
orientation: this.get('orientation'),

@@ -39,3 +42,17 @@ startDate: this.get('startDate'),

if (value) {
element.datepicker('update', new Date(value));
if (this.get('multidate')) {
// split datesIsoString by multidate separator
var multidateSeparator = this.get('multidateSeparator') || ',';
var isoDates = value.split(multidateSeparator);
// generate array of date objecs
dates = isoDates.map(function(date) {
return self._resetTime(new Date(date));
});
}
else {
dates = [self._resetTime(new Date(value))];
}
element.datepicker.
apply(element, Array.prototype.concat.call(['update'], dates));
}

@@ -52,7 +69,44 @@ }.on('didInsertElement'),

if (event.date) {
isoDate = this.$().datepicker('getUTCDate').toISOString();
if (this.get('multidate')) {
// set value to array if multidate
isoDate = this.$().datepicker('getUTCDates').map(function(date) {
return date.toISOString();
});
}
else {
isoDate = this.$().datepicker('getUTCDate').toISOString();
}
}
this.set('value', isoDate);
},
didChangeValue: function() {
var self = this,
element = this.$(),
value = this.get('value'),
dates = [];
if (Ember.isArray(value)) {
dates = value.map(function(date) {
return self._resetTime(new Date(date));
});
} else {
dates = [self._resetTime(new Date(value))];
}
element.datepicker.
apply(element, Array.prototype.concat.call(['update'], dates));
}.observes('value'),
// HACK: Have to reset time to 00:00:00 because of the bug in
// bootstrap-datepicker
// Issue: http://git.io/qH7Hlg
_resetTime: function(date) {
date.setHours(0);
date.setMinutes(0);
date.setSeconds(0);
return date;
}
});

2

package.json
{
"name": "ember-cli-bootstrap-datepicker",
"version": "0.3.0",
"version": "0.3.1",
"description": "Datepicker component for Ember CLI based on bootstrap-datepicker",

@@ -5,0 +5,0 @@ "directories": {

@@ -43,1 +43,26 @@ import { test, moduleForComponent } from 'ember-qunit';

});
test('should set dates provided by value (multidate, default multidateSeparator)', function(){
expect(2);
var component = this.subject({
value: '2015-01-13T00:00:00.000Z,2015-01-07T00:00:00.000Z,2015-01-15T00:00:00.000Z',
multidate: true
});
equal(this.$().val(), '01/13/2015,01/07/2015,01/15/2015', 'should set value as input field value');
equal(this.$().datepicker('getDates').length, 3, 'should set internal datepicker dates by value');
});
test('should set dates provided by value (multidate, multidateSeparator provided)', function(){
expect(2);
var component = this.subject({
value: '2015-01-13T00:00:00.000Z;2015-01-07T00:00:00.000Z;2015-01-15T00:00:00.000Z',
multidate: true,
multidateSeparator: ';'
});
equal(this.$().val(), '01/13/2015;01/07/2015;01/15/2015', 'should set value as input field value using multidate separator');
equal(this.$().datepicker('getDates').length, 3, 'should set internal datepicker dates by value');
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc