Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
build: release 1.0.0-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuanchen committed Jun 30, 2018
1 parent a7562bc commit de31a91
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 903 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.0.0-beta (Jun 30, 2018)

- Fix the issue of years and months view rendering problem (#113).
- Add a second parameter to the `filter` function option (#116, #151).
- Enhance the `setStartDate` and `setEndDate` methods, supports `null` as argument (#157).
- Change NPM package name scope from `@fengyuanchen` to `@chenfengyuan`.

## 0.6.5 (Mar 31, 2018)

- Remove added data when destroy.
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Datepicker

[![Build Status](https://travis-ci.org/fengyuanchen/datepicker.svg)](https://travis-ci.org/fengyuanchen/datepicker) [![Downloads](https://img.shields.io/npm/dm/@fengyuanchen/datepicker.svg)](https://www.npmjs.com/package/@fengyuanchen/datepicker) [![Version](https://img.shields.io/npm/v/@fengyuanchen/datepicker.svg)](https://www.npmjs.com/package/@fengyuanchen/datepicker)
[![Build Status](https://travis-ci.org/fengyuanchen/datepicker.svg)](https://travis-ci.org/fengyuanchen/datepicker) [![Downloads](https://img.shields.io/npm/dm/@chenfengyuan/datepicker.svg)](https://www.npmjs.com/package/@chenfengyuan/datepicker) [![Version](https://img.shields.io/npm/v/@chenfengyuan/datepicker.svg)](https://www.npmjs.com/package/@chenfengyuan/datepicker)

> A simple jQuery datepicker plugin.
Expand Down Expand Up @@ -47,7 +47,7 @@ dist/
### Install

```shell
npm install @fengyuanchen/datepicker
npm install @chenfengyuan/datepicker
```

Include files:
Expand Down Expand Up @@ -359,20 +359,18 @@ The CSS `z-index` style for the datepicker.

- Type: `Function`
- Default: `null`
- Syntax: `filter(date, view)`
- `date`: the date for checking.
- `view`: the the current view, one of `day`, `month` or `year`.

Filter each date item. If return a `false` value, the related date will be disabled.
The function gets two parameters - the actual date that is to be filtered or not and
the context where this filtering is being applied. The context is a string with one
of the values - `day`, `month` or `year`. If for example the function is being called
to determine whether a month should be enabled or not, the date will be the first day
of the month and the context will be `month`.

```js
var now = Date.now();

$().datepicker({
filter: function(date, ctx) {
if (date.getDay() === 0 && ctx === 'day') {
filter: function(date, view) {
if (date.getDay() === 0 && view === 'day') {
return false; // Disable all Sundays, but still leave months/years, whose first day is a Sunday, enabled.
}
}
Expand Down Expand Up @@ -515,14 +513,14 @@ $().datepicker('setDate', '02/14/2014');
### setStartDate(date)

- **date**:
- Type: `Date` or `String`
- Type: `Date` or `String` or `null`

Set the start view date with a new date.

### setEndDate(date)

- **date**:
- Type: `Date` or `String`
- Type: `Date` or `String` or `null`

Set the end view date with a new date.

Expand Down
70 changes: 38 additions & 32 deletions dist/datepicker.common.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Datepicker v0.6.5
* https://github.com/fengyuanchen/datepicker
* Datepicker v1.0.0-beta
* https://fengyuanchen.github.io/datepicker
*
* Copyright (c) 2014-2018 Chen Fengyuan
* Copyright 2014-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2018-03-31T06:17:11.587Z
* Date: 2018-06-30T09:15:49.717Z
*/

'use strict';
Expand Down Expand Up @@ -334,22 +334,22 @@ var methods = {
* Get the month name with given argument or the current date
*
* @param {Number} month (optional)
* @param {Boolean} short (optional)
* @param {Boolean} shortForm (optional)
* @return {String} (month name)
*/
getMonthName: function getMonthName(month, short) {
getMonthName: function getMonthName(month, shortForm) {
var options = this.options;
var monthsShort = options.monthsShort;
var months = options.months;


if ($.isNumeric(month)) {
month = Number(month);
} else if (isUndefined(short)) {
short = month;
} else if (isUndefined(shortForm)) {
shortForm = month;
}

if (short === true) {
if (shortForm === true) {
months = monthsShort;
}

Expand All @@ -361,11 +361,11 @@ var methods = {
* Get the day name with given argument or the current date
*
* @param {Number} day (optional)
* @param {Boolean} short (optional)
* @param {Boolean} shortForm (optional)
* @param {Boolean} min (optional)
* @return {String} (day name)
*/
getDayName: function getDayName(day, short, min) {
getDayName: function getDayName(day, shortForm, min) {
var options = this.options;
var days = options.days;

Expand All @@ -374,17 +374,17 @@ var methods = {
day = Number(day);
} else {
if (isUndefined(min)) {
min = short;
min = shortForm;
}

if (isUndefined(short)) {
short = day;
if (isUndefined(shortForm)) {
shortForm = day;
}
}

if (min) {
days = options.daysMin;
} else if (short) {
} else if (shortForm) {
days = options.daysShort;
}

Expand Down Expand Up @@ -419,7 +419,7 @@ var methods = {
if (isDate(date) || isString(date)) {
date = this.parseDate(date);

if ($.isFunction(filter) && filter.call(this.$element, date) === false) {
if ($.isFunction(filter) && filter.call(this.$element, date, 'day') === false) {
return;
}

Expand All @@ -440,31 +440,35 @@ var methods = {
/**
* Set the start view date with a new date
*
* @param {Date} date
* @param {Date|string|null} date
*/
setStartDate: function setStartDate(date) {
if (isDate(date) || isString(date)) {
this.startDate = this.parseDate(date);
} else {
this.startDate = null;
}

if (this.built) {
this.render();
}
if (this.built) {
this.render();
}
},


/**
* Set the end view date with a new date
*
* @param {Date} date
* @param {Date|string|null} date
*/
setEndDate: function setEndDate(date) {
if (isDate(date) || isString(date)) {
this.endDate = this.parseDate(date);
} else {
this.endDate = null;
}

if (this.built) {
this.render();
}
if (this.built) {
this.render();
}
},

Expand All @@ -482,7 +486,7 @@ var methods = {

if (isDate(date)) {
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
} else if (isString(date)) {
}if (isString(date)) {
parts = date.match(REGEXP_DIGITS) || [];
}

Expand Down Expand Up @@ -630,6 +634,7 @@ var handlers = {
this.showView(VIEWS.MONTHS);
} else {
$target.addClass(options.pickedClass).siblings().removeClass(options.pickedClass);
this.renderYears();
this.hideView();
}

Expand Down Expand Up @@ -679,6 +684,7 @@ var handlers = {
this.showView(VIEWS.DAYS);
} else {
$target.addClass(options.pickedClass).siblings().removeClass(options.pickedClass);
this.renderMonths();
this.hideView();
}

Expand Down Expand Up @@ -814,7 +820,7 @@ var render = {
}

if (!disabled && filter) {
disabled = filter.call(this.$element, date) === false;
disabled = filter.call(this.$element, date, 'year') === false;
}

var picked = viewYear + i === year;
Expand Down Expand Up @@ -869,7 +875,7 @@ var render = {
}

if (!disabled && filter) {
disabled = filter.call(this.$element, date) === false;
disabled = filter.call(this.$element, date, 'month') === false;
}

var picked = viewYear === year && i === month;
Expand Down Expand Up @@ -959,7 +965,7 @@ var render = {
}

if (!disabled && filter) {
disabled = filter.call($element, prevViewDate) === false;
disabled = filter.call($element, prevViewDate, 'day') === false;
}

prevItems.push(this.createItem({
Expand Down Expand Up @@ -1010,7 +1016,7 @@ var render = {
}

if (!_disabled && filter) {
_disabled = filter.call($element, date) === false;
_disabled = filter.call($element, date, 'day') === false;
}

nextItems.push(this.createItem({
Expand Down Expand Up @@ -1041,7 +1047,7 @@ var render = {
}

if (!_disabled2 && filter) {
_disabled2 = filter.call($element, _date) === false;
_disabled2 = filter.call($element, _date, 'day') === false;
}

var _picked = viewYear === year && viewMonth === month && i === day;
Expand Down Expand Up @@ -1085,7 +1091,7 @@ var Datepicker = function () {

this.$element = $(element);
this.element = element;
this.options = $.extend({}, DEFAULTS, LANGUAGES[options.language], options);
this.options = $.extend({}, DEFAULTS, LANGUAGES[options.language], $.isPlainObject(options) && options);
this.built = false;
this.shown = false;
this.isInput = false;
Expand Down Expand Up @@ -1459,7 +1465,7 @@ var Datepicker = function () {
value: function setDefaults() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

$.extend(DEFAULTS, LANGUAGES[options.language], options);
$.extend(DEFAULTS, LANGUAGES[options.language], $.isPlainObject(options) && options);
}
}]);

Expand Down
8 changes: 4 additions & 4 deletions dist/datepicker.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* Datepicker v0.6.5
* https://github.com/fengyuanchen/datepicker
* Datepicker v1.0.0-beta
* https://fengyuanchen.github.io/datepicker
*
* Copyright (c) 2014-2018 Chen Fengyuan
* Copyright 2014-present Chen Fengyuan
* Released under the MIT license
*
* Date: 2018-03-31T06:16:43.444Z
* Date: 2018-06-30T09:15:24.612Z
*/

.datepicker-container {
Expand Down
Loading

0 comments on commit de31a91

Please sign in to comment.