mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-18 22:43:47 +01:00
LSformElement_date : Added 'today' button
This commit is contained in:
parent
10ef09c5e7
commit
87dfb979d1
2 changed files with 28 additions and 1 deletions
|
@ -156,7 +156,8 @@ class LSformElement_date extends LSformElement {
|
|||
LSsession :: addHelpInfos(
|
||||
'LSformElement_date',
|
||||
array(
|
||||
'now' => _('Now.')
|
||||
'now' => _('Now.'),
|
||||
'today' => _('Today.')
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -43,9 +43,35 @@ var LSformElement_date_field = new Class({
|
|||
this.nowBtn.addEvent('click',this.onNowBtnClick.bind(this));
|
||||
this.nowBtn.injectAfter(this.input);
|
||||
varLSdefault.addHelpInfo(this.nowBtn,'LSformElement_date','now');
|
||||
|
||||
this.todayBtn = new Element('img');
|
||||
this.todayBtn.src = varLSdefault.imagePath('calendar.png');
|
||||
this.todayBtn.addClass('btn');
|
||||
this.todayBtn.addEvent('click',this.onTodayBtnClick.bind(this));
|
||||
this.todayBtn.injectAfter(this.nowBtn);
|
||||
varLSdefault.addHelpInfo(this.todayBtn,'LSformElement_date','today');
|
||||
},
|
||||
|
||||
onNowBtnClick: function() {
|
||||
this.input.value = new Date().format(this.params.format);
|
||||
},
|
||||
|
||||
onTodayBtnClick: function() {
|
||||
if (this.input.value) {
|
||||
var cur = Date.parse(this.input.value,this.params.format);
|
||||
if (cur == null) {
|
||||
var cur = Date.parse(this.input.value);
|
||||
}
|
||||
if (cur) {
|
||||
var now = new Date();
|
||||
var today = cur.clone();
|
||||
today.set({
|
||||
year: now.get('year'),
|
||||
mo: now.get('mo'),
|
||||
date: now.get('date')
|
||||
});
|
||||
this.input.value = today.format(this.params.format);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue