From d783a2c840f144b434d0a000fd8b18f0525986a1 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Tue, 14 Apr 2009 15:21:17 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSformElement=5Fdate=20:=20Correction=20d'u?= =?UTF-8?q?n=20bug=20=C3=A9nervant=20dans=20le=20JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/js/LSformElement_date_field.js | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/trunk/includes/js/LSformElement_date_field.js b/trunk/includes/js/LSformElement_date_field.js index 00e2febe..5c1f1e6f 100644 --- a/trunk/includes/js/LSformElement_date_field.js +++ b/trunk/includes/js/LSformElement_date_field.js @@ -20,7 +20,8 @@ var LSformElement_date_field = new Class({ this.params.firstDayOfWeek=0; } - this.input.addEvent('click',this.onCalendarBtnClick.bind(this)); + this.firstInputClick = 1; + this.input.addEvent('click',this.onInputClick.bind(this)); this.date = Date.parseDate(this.input.value,this.params.format); @@ -42,16 +43,42 @@ var LSformElement_date_field = new Class({ varLSdefault.addHelpInfo(this.nowBtn,'LSformElement_date','now'); }, + onInputClick: function() { + if(this.firstInputClick==1) { + this.toogle(); + this.firstInputClick=0; + } + }, + onCalendarBtnClick: function() { + this.toogle(); + }, + + open: function() { + this.opened = 1; this.calendar.showAtElement(this.calendarBtn); }, + close: function() { + this.opened = 0; + this.calendar.hide(); + }, + + toogle: function() { + if (this.opened) { + this.close(); + } + else { + this.open(); + } + }, + onChangeCalendar: function(calendar, date) { this.input.value = date; }, onCloseCalendar: function() { - this.calendar.hide(); + this.close(); }, onNowBtnClick: function() {