amsul / amsul/pickadate.js

Way to overwrite createYearLabel function

オープン
#1,080 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
7.6k
フォーク
981
PR マージ指標
30日以内にマージされた PR はありません

説明

I have two issue with the library and I am wondering if there is a way to overwrite a specific function in pickadate?

- DatePicker.prototype.nodes.createYearLabel: Instead of using the focusYear, I want to use the current year.
- DatePicker.prototype.nodes.createYearLabel: I do not want the number of years to be divided by 2:

```
createYearLabel = function() {

var focusedYear = viewsetObject.year;

settings.equallySplitYears = false;
settings.useFocusYear = false;

// if user wants to equally split the years, the year number will be divided in half and added to the
// lowest year and to the highest year
if(settings.equallySplitYears) {
numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears / 2 )
} else {
numberYears = settings.selectYears === true ? 5 : ~~( settings.selectYears )
}

// If there are years to select, add a dropdown menu.
if (numberYears) {

// initialize variables
var minYear, maxYear, lowestYear, highestYear;

if(settings.useFocusYear) {
// calendar uses the selected year in the dropdown to calculate new years.
minYear = minLimitObject.year;
maxYear = maxLimitObject.year;
lowestYear = focusedYear - numberYears;

if(settings.equallySplitYears) {
highestYear = focusedYear + numberYears;
}
} else {
// calendar uses todays year to calculate new years
minYear = minLimitObject.year;
maxYear = maxLimitObject.year;
lowestYear = nowObject.year - numberYears;

if(settings.equallySplitYears) {
highestYear = nowObject + numberYears;
}
} ...
```
I tried to overwrite this prototype function but I am having problems accessing the DatePicker object. Any hint would be appreciated.

Thanks for this awesome library.

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。