frontello-ui-datepicker
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -13,3 +13,2 @@ "use strict"; | ||
labelMonth: 'Month', | ||
labelNoDate: 'No date', | ||
labelClear: 'Clear', | ||
@@ -44,2 +43,19 @@ labelToday: 'Today', | ||
openPicker() | ||
{ | ||
this.container.style.display = ''; | ||
if (this.getDate() == null) this.setDate('today'); | ||
} | ||
closePicker() | ||
{ | ||
this.container.style.display = 'none'; | ||
} | ||
isOpen() | ||
{ | ||
return this.container.style.display != 'none'; | ||
} | ||
unsetDate() | ||
@@ -210,3 +226,3 @@ { | ||
if (this.date == null) { | ||
this.fieldLabel.value = this.config.labelNoDate; | ||
this.fieldLabel.value = ''; | ||
@@ -289,2 +305,3 @@ return; | ||
this.container.style.userSelect = 'none'; | ||
this.container.style.display = 'none'; | ||
this.fieldLabel.after(this.container); | ||
@@ -296,27 +313,68 @@ | ||
this._buildNav(); | ||
this._displayManagment(); | ||
} | ||
_displayManagment() | ||
{ | ||
// Nothing to do | ||
this.fieldLabel.addEventListener('click', (event) => { | ||
event.stopPropagation(); | ||
}); | ||
this.container.addEventListener('click', (event) => { | ||
event.stopPropagation(); | ||
}); | ||
this.controls.addEventListener('click', (event) => { | ||
event.stopPropagation(); | ||
}); | ||
// Open | ||
this.fieldLabel.addEventListener('focus', (event) => { | ||
this.openPicker(); | ||
}); | ||
this.fieldLabel.addEventListener('click', (event) => { | ||
this.openPicker(); | ||
event.stopPropagation(); | ||
}); | ||
this.actionToday.addEventListener('click', (event) => { | ||
this.openPicker(); | ||
}); | ||
// Close | ||
this.fieldLabel.addEventListener('focusout', (event) => { | ||
//this.closePicker(); | ||
// Selecting the date on click triggers a focusout... | ||
}); | ||
this.actionClear.addEventListener('click', () => { | ||
this.closePicker(); | ||
}); | ||
window.addEventListener('click', () => { | ||
this.closePicker(); | ||
}); | ||
} | ||
_buildControls() | ||
{ | ||
let controls = document.createElement('nav'); | ||
controls.classList.add(this.config.classControls); | ||
this.fieldLabel.after(controls); | ||
this.controls = document.createElement('nav'); | ||
this.controls .classList.add(this.config.classControls); | ||
this.fieldLabel.after(this.controls ); | ||
this.actionClear = null; | ||
if (this.nulable) { | ||
let clear = document.createElement('a'); | ||
clear.classList.add('clear'); | ||
clear.title = this.config.labelClear; | ||
clear.addEventListener('click', (e) => { | ||
this.actionClear = document.createElement('a'); | ||
this.actionClear.classList.add('clear'); | ||
this.actionClear.title = this.config.labelClear; | ||
this.actionClear.addEventListener('click', (e) => { | ||
this.unsetDate(); | ||
}); | ||
controls.append(clear); | ||
this.controls .append(this.actionClear); | ||
} | ||
let today = document.createElement('a'); | ||
today.classList.add('today'); | ||
today.title = this.config.labelToday; | ||
today.addEventListener('click', (e) => { | ||
this.actionToday = document.createElement('a'); | ||
this.actionToday.classList.add('today'); | ||
this.actionToday.title = this.config.labelToday; | ||
this.actionToday.addEventListener('click', (e) => { | ||
this.setDate('today'); | ||
}); | ||
controls.append(today); | ||
this.controls .append(this.actionToday); | ||
} | ||
@@ -323,0 +381,0 @@ |
{ | ||
"name": "frontello-ui-datepicker", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "UI datepicker", | ||
@@ -5,0 +5,0 @@ "main": "datepicker.js", |
Sorry, the diff of this file is not supported yet
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
17742
550