From 66393ab9f0c6af77ba9c9ba0e91e6eaeac8043f8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Fri, 18 Dec 2009 13:26:22 -0700 Subject: [PATCH] Horde_Calendar now fires event on selection; fix Date-related bugs --- imp/js/search.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/imp/js/search.js b/imp/js/search.js index ec7486a4e..cdd24b2fa 100644 --- a/imp/js/search.js +++ b/imp/js/search.js @@ -264,16 +264,16 @@ var ImpSearch = { new Element('EM').insert(this.getLabel(id)), new Element('SPAN').insert(new Element('SPAN')).insert(new Element('A', { href: '#', className: 'calendarPopup', title: this.text.dateselection }).insert(new Element('SPAN', { className: 'searchuiImg searchuiCalendar' }))) ]; - this.replaceDate(this.insertCriteria(tmp), id, { y: d.getFullYear(), m: d.getMonth(), d: d.getDate() }); + this.replaceDate(this.insertCriteria(tmp), id, d); }, - replaceDate: function(id, type, date) + replaceDate: function(id, type, d) { - $(id).down('TD SPAN SPAN').update(this.data.months[data.getMonth()] + ' ' + data.getDate() + ', ' + data.getYear() + 1900); + $(id).down('TD SPAN SPAN').update(this.data.months[d.getMonth()] + ' ' + d.getDate() + ', ' + (d.getYear() + 1900)); // Need to store date information at all times in criteria, since we // have no other way to track this information (there is not form // field for this type). - this.criteria[id] = { t: type, v: data }; + this.criteria[id] = { t: type, v: d }; }, insertWithin: function(id, data) @@ -416,8 +416,7 @@ var ImpSearch = { e.stop(); return; } else if (elt.hasClassName('searchuiCalendar')) { - tmp = this.criteria[elt.up('TR').identify()]; - Horde_Calendar.open(elt.identify(), new Date(tmp.v.y, tmp.v.m, tmp.v.d), this.replaceDate.bind(this, elt.up('TR').identify(), tmp.t)); + Horde_Calendar.open(elt.identify(), this.criteria[elt.up('TR').identify()].v); e.stop(); return; } @@ -440,9 +439,16 @@ var ImpSearch = { { this.updateFolderList(r.responseJSON); this.updateSelectedFolders(flist); + }, + + calendarSelectHandler: function(e) + { + var elt = e.element(); + this.replaceDate(elt.up('TR').identify(), this.criteria[elt.identify()], e.memo); } }; -document.observe('change', ImpSearch.changeHandler.bind(ImpSearch)); -document.observe('click', ImpSearch.clickHandler.bind(ImpSearch)); +document.observe('change', ImpSearch.changeHandler.bindAsEventListener(ImpSearch)); +document.observe('click', ImpSearch.clickHandler.bindAsEventListener(ImpSearch)); +document.observe('Horde_Calendar:select', ImpSearch.calendarSelectHandler.bindAsEventListener(ImpSearch)); -- 2.11.0