From 07e78b106e33c09dd46e874aca04c739e0140851 Mon Sep 17 00:00:00 2001 From: Sem Date: Thu, 30 Aug 2012 06:17:57 +0200 Subject: Linked initial date and end date in edit form --- .../css/elements/forms/datepicker_multi.php | 39 ++++++++++++++++++++++ views/default/event_calendar/datetime_edit.php | 11 +++--- views/default/js/event_calendar/event_calendar.php | 13 ++++++++ 3 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 views/default/css/elements/forms/datepicker_multi.php (limited to 'views/default') diff --git a/views/default/css/elements/forms/datepicker_multi.php b/views/default/css/elements/forms/datepicker_multi.php new file mode 100644 index 000000000..4a18bdad1 --- /dev/null +++ b/views/default/css/elements/forms/datepicker_multi.php @@ -0,0 +1,39 @@ + + +.ui-datepicker.ui-datepicker-multi { + width: auto; +} +.ui-datepicker-multi .ui-datepicker-group { + float: left; +} +.ui-datepicker-multi .ui-datepicker-group table { + margin-bottom: 0.4em; + margin-left: auto; + margin-right: auto; + margin-top: 0; + width: 95%; +} +.ui-datepicker-multi-2 .ui-datepicker-group { + width: 50%; +} +.ui-datepicker-multi-3 .ui-datepicker-group { + width: 33.3%; +} +.ui-datepicker-multi-4 .ui-datepicker-group { + width: 25%; +} +.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { + border-left-width-ltr-source: physical; + border-left-width-rtl-source: physical; + border-left-width-value: 0; +} +.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { + border-left-width-ltr-source: physical; + border-left-width-rtl-source: physical; + border-left-width-value: 0; +} +.ui-datepicker-multi .ui-datepicker-buttonpane { + clear: left; +} diff --git a/views/default/event_calendar/datetime_edit.php b/views/default/event_calendar/datetime_edit.php index 7abc3bb62..2e0830167 100644 --- a/views/default/event_calendar/datetime_edit.php +++ b/views/default/event_calendar/datetime_edit.php @@ -8,20 +8,17 @@ if ($event_calendar_times != 'no') { if ($event_calendar_hide_end != 'yes') { $body .= '

'; } - $body .= elgg_view("event_calendar/input/date_local",array( - //'timestamp'=>TRUE, - 'autocomplete'=>'off', + $body .= elgg_view("input/date", array( 'class'=>'event-calendar-compressed-date', 'name' => 'start_date', - 'value'=>$vars['start_date'])); + 'value'=>$vars['start_date'], + )); $body .= ''; $body .= elgg_view("input/timepicker",array('name' => 'start_time','value'=>$vars['start_time'])); $body .= ''; if ($event_calendar_hide_end != 'yes') { $body .= '

'; - $body .= elgg_view("event_calendar/input/date_local",array( - //'timestamp'=>TRUE, - 'autocomplete'=>'off', + $body .= elgg_view("input/date", array( 'class'=>'event-calendar-compressed-date', 'name' => 'end_date', 'value'=>$vars['end_date'], diff --git a/views/default/js/event_calendar/event_calendar.php b/views/default/js/event_calendar/event_calendar.php index 360f39f6c..f9e3d63c2 100644 --- a/views/default/js/event_calendar/event_calendar.php +++ b/views/default/js/event_calendar/event_calendar.php @@ -21,6 +21,11 @@ elgg.event_calendar.init = function () { $('#event-calendar-end-time-wrapper').attr('disabled','disabled'); } all_day_field.change(elgg.event_calendar.handleAllDayField); + + $('.elgg-input-date[name="start_date"], .elgg-input-date[name="end_date"]').datepicker({ + numberOfMonths: 3, + onSelect: elgg.event_calendar.handleDateRangeSelect, + }); } elgg.event_calendar.handleScheduleType = function(e) { @@ -61,6 +66,14 @@ elgg.event_calendar.handleAllDayField = function(e) { } } +elgg.event_calendar.handleDateRangeSelect = function(selectedDate) { + if (this.name == 'start_date') { + $('.elgg-input-date[name="end_date"]').datepicker("option", "minDate", selectedDate); + } else { + $('.elgg-input-date[name="start_date"]').datepicker("option", "maxDate", selectedDate); + } +} + elgg.event_calendar.handleEditFormSubmit = function(e) { if ($.trim($('[name="title"]').val()) == '') { alert(elgg.echo('event_calendar:edit_form:error:missing_title')); -- cgit v1.2.3