Comparing version 1.2.4 to 1.2.5
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
[1.2.5] - 2018-09-06 | ||
* Improve pluralize. Now as function. | ||
[1.2.4] - 2018-08-26 | ||
@@ -5,0 +8,0 @@ * Tooltip on disabled days. |
14
demo.js
@@ -151,3 +151,15 @@ var rangeText = function (start, end) { | ||
locale: { | ||
tooltip: ['день', 'дня', 'дней'], | ||
tooltip: { | ||
one: 'день', | ||
few: 'дня', | ||
many: 'дней', | ||
}, | ||
pluralize: function(i, locale) { | ||
if ('one' in locale && i % 10 === 1 && !(i % 100 === 11)) return locale.one; | ||
if ('few' in locale && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 && !(i % 100 >= 12 && i % 100 <= 14)) return locale.few; | ||
if ('many' in locale && (i % 10 === 0 || i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 || i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)) return locale.many; | ||
if ('other' in locale) return locale.other; | ||
return ''; | ||
} | ||
}, | ||
@@ -154,0 +166,0 @@ onSelect: function(start, end){ |
@@ -66,4 +66,15 @@ /** | ||
}, | ||
tooltip: ['day', 'days'], | ||
tooltip: { | ||
one: 'day', | ||
other: 'days', | ||
}, | ||
tooltipOnDisabled: null, | ||
pluralize: function(i, locale){ | ||
if (typeof i === "string") i = parseInt(i, 10); | ||
if (i === 1 && 'one' in locale) return locale.one; | ||
if ('other' in locale) return locale.other; | ||
return ''; | ||
} | ||
} | ||
@@ -358,9 +369,2 @@ }, | ||
plural = function(value, arr) | ||
{ | ||
return value % 10 == 1 && value % 100 != 11 | ||
? arr[0] | ||
: (value % 10 >= 2 && value % 10 <= 4 && (value % 100 < 10 || value % 100 >= 20 ) ? arr[1] : (arr[2] || arr[1])); | ||
}, | ||
Lightpick = function(options) | ||
@@ -676,3 +680,9 @@ { | ||
if (days > 0 && !target.classList.contains('is-disabled')) { | ||
self.showTooltip(target, days + ' ' + plural(days, opts.locale.tooltip)); | ||
var pluralText = ''; | ||
if (typeof opts.locale.pluralize === 'function') { | ||
pluralText = opts.locale.pluralize.call(self, days, opts.locale.tooltip); | ||
} | ||
self.showTooltip(target, days + ' ' + pluralText); | ||
} | ||
@@ -679,0 +689,0 @@ else { |
{ | ||
"name": "lightpick", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "Javascript date range picker - lightweight, no jQuery", | ||
@@ -5,0 +5,0 @@ "main": "lightpick.js", |
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
105476
1788