From 356113af63d89e6998f955ee22dbf0ca95339cce Mon Sep 17 00:00:00 2001 From: bshuttle Date: Tue, 10 Jan 2006 13:47:01 +0000 Subject: [PATCH] date range widget (criteria) now works. --- lib/browse/Criteria.inc | 12 ++++++++++++ resources/js/kt3calendar.js | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ templates/ktcore/boolean_search.smarty | 6 ++++++ 3 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 resources/js/kt3calendar.js diff --git a/lib/browse/Criteria.inc b/lib/browse/Criteria.inc index de3c4f0..62ef340 100644 --- a/lib/browse/Criteria.inc +++ b/lib/browse/Criteria.inc @@ -272,12 +272,24 @@ class DateCreatedCriterion extends BrowseCriterion { } function searchWidget ($aRequest) { global $default; + + // this is not ideal, but we don't actually have access to the + // dispatcher's oPage object. + + // even worse, we may _not_ have the items we want. + + global $main; + $sStartWidget = $this->getWidgetBase() . "_start"; $sEndWidget = $this->getWidgetBase() . "_end"; + /* // legacy code. $sToRender = "After date: "; $sToRender .= "  graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\">"; $sToRender .= "   Before date: "; $sToRender .= "  graphicsUrl/calendar/calendar.gif\" name=\"imgCalendar\" width=\"34\" height=\"21\" border=\"0\" alt=\"\">"; + */ + $sToRender = 'After Date: No Date Selected — '; + $sToRender .= 'Before Date: No Date Selected
'; return $sToRender; } function searchSQL ($aRequest) { diff --git a/resources/js/kt3calendar.js b/resources/js/kt3calendar.js new file mode 100644 index 0000000..594cdd6 --- /dev/null +++ b/resources/js/kt3calendar.js @@ -0,0 +1,68 @@ +/* + * KT3 Calendar wrapper. + * + * use this with the following example code: + + + No Date Selected + + + + + */ + +function breadcrumbFind(elem, tagName) { + var stopTag = 'BODY'; + var currentTag = elem.tagName; + var currentElem = elem; + while ((currentTag != stopTag) && (currentTag != tagName)) { + currentElem = currentElem.parentNode; + currentTag = currentElem.tagName; + } + + if (currentTag == tagName) { + return currentElem; + } else { + return null; + } +} + +function resolve_calendar_date(display, store, calendar, date) { + store.value = date; + display.innerHTML = date; + calendar.hide(); +} + +function close_calendar_ev(calendar) { calendar.hide(); } + +function init_kt_calendar(source) { + var match = breadcrumbFind(source, 'SPAN'); + if (match == null) { + alert('invalid target for calendar.'); + } + + // if we have done this already: + if (typeof(match._kt3cal) != 'undefined') { + match._kt3cal.show(); + } else { + // create the partial'd functions. + var dwL = getElementsByTagAndClassName(null, 'kt_calendar_datetext', match); + var sL = getElementsByTagAndClassName(null, 'kt_calendar_value', match); + + if ((dwL.length == 0) || (sL.length == 0)) { + return null; // fail out. + } + + var resolve = partial(resolve_calendar_date, dwL[0], sL[0]); + + var c = new Calendar(0, null, resolve, close_calendar_ev); + c.showsTime = true; + c.setDateFormat('%Y/%m/%d %H:%M'); + + c.create(); + c.showAtElement(source,'Bc'); // the button + c.show(); + match._kt3cal = c; + } +} + diff --git a/templates/ktcore/boolean_search.smarty b/templates/ktcore/boolean_search.smarty index e58cc95..d80685b 100644 --- a/templates/ktcore/boolean_search.smarty +++ b/templates/ktcore/boolean_search.smarty @@ -6,6 +6,12 @@ {$context->oPage->requireJSResource("resources/js/taillog.js")} {$context->oPage->requireJSResource("resources/js/constructed_search.js")} +{$context->oPage->requireJSResource("resources/js/kt3calendar.js")} +{$context->oPage->requireJSResource("thirdpartyjs/jscalendar-1.0/calendar.js")} +{$context->oPage->requireJSResource("thirdpartyjs/jscalendar-1.0/lang/calendar-en.js")} +{$context->oPage->requireJSResource("thirdpartyjs/jscalendar-1.0/calendar-setup.js")} +{$context->oPage->requireCSSResource("thirdpartyjs/jscalendar-1.0/calendar-system.css")} + {capture assign=sJS} {literal} function testStartup() { -- libgit2 0.21.4