code42day-calendar
Advanced tools
Comparing version 0.2.4 to 1.0.0
1.0.0 / 2017-02-03 | ||
================== | ||
* use Intl to localize month and weekdays | ||
* breaking change: locale() now takes the String with desired locale (before it took object with month and weekday names) | ||
* remove dependencies required only for non ES5 compliant browsers, upgrade other dependencies | ||
* switch to yarn (from npm) | ||
0.2.4 / 2015-09-18 | ||
@@ -3,0 +11,0 @@ ================== |
@@ -6,4 +6,3 @@ | ||
var bind = require('bind') | ||
, domify = require('domify') | ||
var domify = require('domify') | ||
, Emitter = require('emitter') | ||
@@ -44,7 +43,7 @@ , classes = require('classes') | ||
this.el.appendChild(this.days.el); | ||
this.on('change', bind(this, this.show)); | ||
this.days.on('prev', bind(this, this.prev)); | ||
this.days.on('next', bind(this, this.next)); | ||
this.days.on('year', bind(this, this.menuChange, 'year')); | ||
this.days.on('month', bind(this, this.menuChange, 'month')); | ||
this.on('change', this.show.bind(this)); | ||
this.days.on('prev', this.prev.bind(this)); | ||
this.days.on('next', this.next.bind(this)); | ||
this.days.on('year', this.menuChange.bind(this, 'year')); | ||
this.days.on('month', this.menuChange.bind(this, 'month')); | ||
this.show(date || new Date); | ||
@@ -234,10 +233,10 @@ this.days.on('change', function(date){ | ||
* | ||
* @param {months, weekdaysMin} - array of months labels and array of weekdays shortcuts | ||
* @param locales A string with a BCP 47 language tag, or an array of such strings (optional) | ||
* @api public | ||
*/ | ||
Calendar.prototype.locale = function(locale) { | ||
this.days.setLocale(locale); | ||
Calendar.prototype.locale = function(locales) { | ||
this.days.setLocale(locales); | ||
this.days.show(this._date); | ||
return this; | ||
}; |
var Bounds = require('bounds'); | ||
var type; | ||
if (typeof window !== 'undefined') { | ||
type = require('type'); | ||
} else { | ||
type = require('type-component'); | ||
} | ||
module.exports = DayRange; | ||
function date(d) { | ||
return type(d) === 'date' ? d : new Date(d[0], d[1], d[2]); | ||
return Array.isArray(d) ? new Date(d[0], d[1], d[2]) : d; | ||
} | ||
@@ -25,6 +17,6 @@ | ||
return date(a).getTime() - date(b).getTime(); | ||
} | ||
}; | ||
DayRange.prototype._distance = function(a, b) { | ||
return Math.abs(this.compare(a, b)); | ||
} | ||
}; |
@@ -10,3 +10,2 @@ | ||
, events = require('event') | ||
, map = require('map') | ||
, template = require('./template.html') | ||
@@ -16,16 +15,6 @@ , inGroupsOf = require('in-groups-of') | ||
, range = require('range') | ||
, normalize = require('normalize') | ||
, DayRange = require('./dayrange'); | ||
, DayRange = require('./dayrange') | ||
, locale = require('./locale'); | ||
/** | ||
* Default locale - en | ||
*/ | ||
var LOCALE = { | ||
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'), | ||
weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_') | ||
}; | ||
/** | ||
* Get days in `month` for `year`. | ||
@@ -86,6 +75,6 @@ * | ||
this.validRange = new DayRange; | ||
this.locale = LOCALE; | ||
this.locale = locale(); | ||
// emit "day" | ||
events.bind(this.body, 'click', normalize(function(e){ | ||
events.bind(this.body, 'click', function(e){ | ||
if (e.target.tagName !== 'A') { | ||
@@ -109,6 +98,6 @@ return true; | ||
return false; | ||
})); | ||
}); | ||
// emit "prev" | ||
events.bind(this.el.querySelector('.prev'), 'click', normalize(function(ev){ | ||
events.bind(this.el.querySelector('.prev'), 'click', function(ev){ | ||
ev.preventDefault(); | ||
@@ -118,6 +107,6 @@ | ||
return false; | ||
})); | ||
}); | ||
// emit "next" | ||
events.bind(this.el.querySelector('.next'), 'click', normalize(function(ev){ | ||
events.bind(this.el.querySelector('.next'), 'click', function(ev){ | ||
ev.preventDefault(); | ||
@@ -127,3 +116,3 @@ | ||
return false; | ||
})); | ||
}); | ||
} | ||
@@ -154,8 +143,8 @@ | ||
* | ||
* @param {months, weekdaysMin} - array of months labels and array of weekdays shortcuts | ||
* @param A string with a BCP 47 language tag, or an array of such strings (optional) | ||
* @api public | ||
*/ | ||
Days.prototype.setLocale = function(locale) { | ||
this.locale = locale; | ||
Days.prototype.setLocale = function(locales) { | ||
this.locale = locale(locales); | ||
return this; | ||
@@ -268,3 +257,3 @@ }; | ||
Days.prototype.renderHeading = function(days){ | ||
var rows = '<tr class=subheading>' + map(days, function(day){ | ||
var rows = '<tr class=subheading>' + days.map(function(day){ | ||
return '<th>' + day + '</th>'; | ||
@@ -285,3 +274,3 @@ }).join('') + '</tr>'; | ||
var rows = this.rowsFor(date); | ||
var html = map(rows, function(row){ | ||
var html = rows.map(function(row){ | ||
return '<tr>' + row.join('') + '</tr>'; | ||
@@ -439,3 +428,3 @@ }).join('\n'); | ||
var years = range(from, to, 'inclusive'); | ||
var options = map(years, yearOption).join(''); | ||
var options = years.map(yearOption).join(''); | ||
return '<select class="calendar-select">' + options + '</select>'; | ||
@@ -449,3 +438,3 @@ } | ||
function monthDropdown(months) { | ||
var options = map(months, monthOption).join(''); | ||
var options = months.map(monthOption).join(''); | ||
return '<select class="calendar-select">' + options + '</select>'; | ||
@@ -452,0 +441,0 @@ } |
{ | ||
"name": "code42day-calendar", | ||
"version": "0.2.4", | ||
"version": "1.0.0", | ||
"description": "Calendar component", | ||
@@ -8,6 +8,3 @@ "scripts": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/code42day/calendar.git" | ||
}, | ||
"repository": "code42day/calendar.git", | ||
"keywords": [ | ||
@@ -21,3 +18,3 @@ "browser", | ||
"bounds": "^1.0.1", | ||
"component-bind": "*", | ||
"code42day-in-groups-of": "^1.0.1", | ||
"component-classes": "*", | ||
@@ -27,17 +24,11 @@ "component-domify": "*", | ||
"component-event": "*", | ||
"component-type": "*", | ||
"democracyos-normalize": "~0", | ||
"code42day-in-groups-of": "^1.0.1", | ||
"map-component": "*", | ||
"range-component": "^1.0.0", | ||
"type-component": "~0" | ||
"range-component": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^11.1.0", | ||
"browserify": "~14", | ||
"jshint": "^2.7.0", | ||
"mocha": "~1", | ||
"mocha": "~3", | ||
"stringify": "^3.1.0" | ||
}, | ||
"browser": { | ||
"bind": "component-bind", | ||
"domify": "component-domify", | ||
@@ -47,7 +38,4 @@ "classes": "component-classes", | ||
"in-groups-of": "code42day-in-groups-of", | ||
"map": "map-component", | ||
"range": "range-component", | ||
"emitter": "component-emitter", | ||
"type": "component-type", | ||
"normalize": "democracyos-normalize" | ||
"emitter": "component-emitter" | ||
}, | ||
@@ -60,5 +48,6 @@ "browserify": { | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/code42day/calendar/issues" | ||
} | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
] | ||
} |
@@ -0,1 +1,4 @@ | ||
[![NPM version][npm-image]][npm-url] | ||
[![Build Status][travis-image]][travis-url] | ||
[![Dependency Status][gemnasium-image]][gemnasium-url] | ||
@@ -13,3 +16,3 @@ # Calendar | ||
$ component install component/calendar | ||
$ nom install --save code42day-calendar | ||
@@ -19,3 +22,3 @@ ## Example | ||
```js | ||
var Calendar = require('calendar'); | ||
var Calendar = require('code42day-calendar'); | ||
var cal = new Calendar; | ||
@@ -71,8 +74,9 @@ cal.el.appendTo('body'); | ||
### Calendar#locale({months, weekdaysMin}) | ||
### Calendar#locale(locales) | ||
Set alternative locale: | ||
- `months` - an array of 12 strings representing month names _January..December_. | ||
- `weekdaysMin` - an array of 7 strings representing day names shortcuts _Sunday..Saturday_ | ||
- `locales` - Optional. A string with a BCP 47 language tag, or an array of such strings. For the general form and interpretation of the locales argument, see the [Intl] page. | ||
For [browsers][caniuse-intl] which do not support `Intl` in not available only English locale is supported. | ||
## Themes | ||
@@ -88,1 +92,13 @@ | ||
[Intl]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation | ||
[caniuse-intl]: http://caniuse.com/#search=Intl | ||
[npm-image]: https://img.shields.io/npm/v/code42day-calendar.svg | ||
[npm-url]: https://npmjs.org/package/code42day-calendar | ||
[travis-url]: https://travis-ci.org/code42day/calendar | ||
[travis-image]: https://img.shields.io/travis/code42day/calendar.svg | ||
[gemnasium-image]: https://img.shields.io/gemnasium/code42day/calendar.svg | ||
[gemnasium-url]: https://gemnasium.com/code42day/calendar | ||
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 3 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
21108
7
656
1
4
101
3
1
- Removedcomponent-bind@*
- Removedcomponent-type@*
- Removeddemocracyos-normalize@~0
- Removedmap-component@*
- Removedtype-component@~0
- Removedcomponent-bind@1.0.0(transitive)
- Removedcomponent-props@1.1.1(transitive)
- Removeddemocracyos-normalize@0.0.3(transitive)
- Removedmap-component@0.0.1(transitive)
- Removedto-function@2.0.6(transitive)
- Removedtype-component@0.0.1(transitive)