diff -rNu --exclude=CVS date_2.1-orig/date/date_admin.inc date/date/date_admin.inc --- date_2.1-orig/date/date_admin.inc 2009-03-03 07:16:54.000000000 -0800 +++ date/date/date_admin.inc 2009-04-22 11:45:50.000000000 -0700 @@ -245,7 +245,8 @@ case 'save': - $options = array('granularity', 'timezone_db', 'tz_handling', 'todate', 'repeat', 'repeat_collapsed', 'default_format'); + $options = array('granularity', 'timezone_db', 'tz_handling', 'todate', 'repeat', 'repeat_collapsed', 'default_format', 'all_day'); + return $options; case 'database columns': @@ -316,6 +317,9 @@ $db_columns['offset'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE, 'views' => FALSE); if (!empty($field['todate'])) $db_columns['offset2'] = array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE, 'views' => FALSE); } + if (isset($field['all_day']) && $field['all_day'] == TRUE) { + $db_columns['all_day'] = array('type' => 'int', 'length' => 1, 'not null' => FALSE, 'sortable' => FALSE); + } if (isset($field['repeat']) && $field['repeat'] == 1) { $db_columns['rrule'] = array('type' => 'text', 'not null' => FALSE, 'sortable' => FALSE, 'views' => FALSE); } @@ -334,6 +338,7 @@ $granularity = array('year', 'month', 'day', 'hour', 'minute'); } $tz_handling = isset($field['tz_handling']) ? $field['tz_handling'] : (date_has_time($granularity) ? 'site' : 'none'); + $all_day = isset($field['all_day']) ? $field['all_day'] : FALSE; // If adding a repeat, override the Content module's handling of the multiple values option. if (module_exists('date_repeat') && date_is_repeat_field($field)) { @@ -370,7 +375,6 @@ '#options' => $format_types, '#description' => t('Select a default format type to be used for the date display. Visit the Date and time date format page to add and edit format types.', array('@date-time-page' => base_path() .'admin/settings/date-time/formats')), ); - $description = t('Select the timezone handling method to be used for this date field.'); $description .= date_data_loss_warning('Time zone handling'); $form['tz_handling'] = array( @@ -380,6 +384,13 @@ '#options' => date_timezone_handling_options(), '#description' => $description, ); + $form['all_day'] = array( + '#type' => 'checkbox', + '#title' => t('All-day checkbox'), + '#default_value' => $all_day, + '#description' => t('If turned on, all-day property of the dates can be handled.'), + ); + // Force this value to hidden because we don't want to allow it to be changed right now, // but allow it to be a variable if needed. $form['timezone_db'] = array( @@ -712,4 +723,4 @@ ); } return $form; -} \ No newline at end of file +} diff -rNu --exclude=CVS date_2.1-orig/date/date_all_day.js date/date/date_all_day.js --- date_2.1-orig/date/date_all_day.js 1969-12-31 16:00:00.000000000 -0800 +++ date/date/date_all_day.js 2009-03-20 11:35:46.000000000 -0700 @@ -0,0 +1,208 @@ +Drupal.behaviors.dateAllDay = function(context){ + $('#edit-field-time-off-0-all-day:not(.dateAllDay-processed)', context).addClass('dateAllDay-processed').each(function () { + dateAllDayToggle($('#edit-field-time-off-0-all-day').val(), 'field-time-off', '0') + }); + $('.form-submit:not(.dateAllDay-processed)', context).addClass('dateAllDay-processed').each(function () { + $(this).click(function(){ + $("#edit-field-time-off-0-value-timeEntry-popup-1, #edit-field-time-off-0-value2-timeEntry-popup-1").removeAttr("disabled"); + }); + }); +} + +function addDefaultDate(default_year, default_month, default_day, fieldClass) { + var currentDate = new Date(); + currentDate.setFullYear(default_year, default_month, default_day); + var curr_month = currentDate.getMonth() + 1; + var curr_day = currentDate.getDate(); + var curr_year = currentDate.getFullYear(); + + var mm = new String(curr_month); + var dd = new String(curr_day); + if ( mm.length == 1 ) mm = "0" + mm; // Add leading zeros to month and day if required + if ( dd.length == 1 ) dd = "0" + dd; + var curr_date = curr_year+'-'+mm+'-'+dd; + + if($("#edit-"+fieldClass+"-0-value-day").val() == "") { + $("#edit-"+fieldClass+"-0-value-day").val(curr_day); + } + if($("#edit-"+fieldClass+"-0-value-month").val() == "") { + $("#edit-"+fieldClass+"-0-value-month").val(curr_month); + } + if($("#edit-"+fieldClass+"-0-value-year").val() == "") { + $("#edit-"+fieldClass+"-0-value-year").val(curr_year); + } + if($("#edit-"+fieldClass+"-0-value-hour").val() == "") $("#edit-"+fieldClass+"-0-value-hour").val("1"); + if($("#edit-"+fieldClass+"-0-value-minute").val() == "") $("#edit-"+fieldClass+"-0-value-minute").val("00"); + if($("#edit-"+fieldClass+"-0-value-ampm").val() == "") $("#edit-"+fieldClass+"-0-value-ampm").val("am"); + + $("#edit-"+fieldClass+"-0-value-date").val(curr_date); + $("#edit-"+fieldClass+"-0-value-timeEntry-popup-1").val('00:00'); +} + +function dateAllDayToggle (is_checked, fieldClass, is_required) { + if (is_checked) { + DateAllDayYes(fieldClass); + } + else { + DateAllDayNo(fieldClass, is_required); + } +} + +function DateAllDayYes(fieldClass) { + var currentDate = new Date(); + var curr_hours = currentDate.getHours() + 1; + var curr_minutes = currentDate.getMinutes() + 1; + var curr_month = currentDate.getMonth() + 1; + var mm = new String(curr_month); + var curr_day = currentDate.getDate(); + var dd = new String(curr_day); + var curr_year = currentDate.getFullYear(); + + if ( mm.length == 1 ) mm = "0" + mm; // Add leading zeros to month and day if required + if ( dd.length == 1 ) dd = "0" + dd; + + var curr_date = curr_year+'-'+mm+'-'+dd; + + if($("#edit-"+fieldClass+"-0-value2-day").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-day").val() != "") $("#edit-"+fieldClass+"-0-value2-day").val($("#edit-"+fieldClass+"-0-value-day").val()); + else $("#edit-"+fieldClass+"-0-value2-day").val(curr_day); + } + if($("#edit-"+fieldClass+"-0-value2-month").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-month").val() != "") $("#edit-"+fieldClass+"-0-value2-month").val($("#edit-"+fieldClass+"-0-value-month").val()); + else $("#edit-"+fieldClass+"-0-value2-month").val(curr_month); + } + if($("#edit-"+fieldClass+"-0-value2-year").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-year").val() != "") $("#edit-"+fieldClass+"-0-value2-year").val($("#edit-"+fieldClass+"-0-value-year").val()); + else $("#edit-"+fieldClass+"-0-value2-year").val(curr_year); + } + + if($("#edit-"+fieldClass+"-0-value-day").val() == "") { + if ($("#edit-"+fieldClass+"-0-value2-day").val() != "") $("#edit-"+fieldClass+"-0-value-day").val($("#edit-"+fieldClass+"-0-value2-day").val()); + else $("#edit-"+fieldClass+"-0-value-day").val(curr_day); + } + + if($("#edit-"+fieldClass+"-0-value-month").val() == "") { + if ($("#edit-"+fieldClass+"-0-value2-month").val() != "") $("#edit-"+fieldClass+"-0-value-month").val($("#edit-"+fieldClass+"-0-value2-month").val()); + else $("#edit-"+fieldClass+"-0-value-month").val(curr_month); + } + + if($("#edit-"+fieldClass+"-0-value-year").val() == "") { + if ($("#edit-"+fieldClass+"-0-value2-year").val() != "") $("#edit-"+fieldClass+"-0-value-year").val($("#edit-"+fieldClass+"-0-value2-year").val()); + else $("#edit-"+fieldClass+"-0-value-year").val(curr_year); + } + + if($("#edit-"+fieldClass+"-0-value2-date").val() == "") { + if (($("#edit-"+fieldClass+"-0-value-date").val() != "") && ($("#edit-"+fieldClass+"-0-value-date").val() != undefined)) $("#edit-"+fieldClass+"-0-value2-date").val($("#edit-"+fieldClass+"-0-value-date").val()); + else $("#edit-"+fieldClass+"-0-value2-date").val(curr_date); + } + + if($("#edit-"+fieldClass+"-0-value-date").val() == "") { + if (($("#edit-"+fieldClass+"-0-value2-date").val() != "") && ($("#edit-"+fieldClass+"-0-value2-date").val() != undefined)) $("#edit-"+fieldClass+"-0-value-date").val($("#edit-"+fieldClass+"-0-value2-date").val()); + else $("#edit-"+fieldClass+"-0-value-date").val(curr_date); + } + + if($("#edit-"+fieldClass+"-0-value-hour").val() == "") { + if ($("#edit-"+fieldClass+"-0-value-ampm").val() == undefined) { + $("#edit-"+fieldClass+"-0-value-hour").val("0"); + } + else { + $("#edit-"+fieldClass+"-0-value2-hour").val("1"); + if($("#edit-"+fieldClass+"-0-value-ampm").val() == "") $("#edit-"+fieldClass+"-0-value-ampm").val("am"); + } + } + if($("#edit-"+fieldClass+"-0-value-minute").val() == "") $("#edit-"+fieldClass+"-0-value-minute").val("00"); + + if ($("#edit-"+fieldClass+"-0-value2-ampm").val() == undefined) { + $("#edit-"+fieldClass+"-0-value2-hour").val("23"); + } + else { + $("#edit-"+fieldClass+"-0-value2-hour").val("11"); + $("#edit-"+fieldClass+"-0-value2-ampm").val("pm"); + } + $("#edit-"+fieldClass+"-0-value2-minute").val("59"); + + //if ($("#edit-"+fieldClass+"-0-value-timeEntry-popup-1").val() == "") { + $("#edit-"+fieldClass+"-0-value-timeEntry-popup-1").val('00:00').attr("disabled", "disabled"); + //} + //if ($("#edit-"+fieldClass+"-0-value2-timeEntry-popup-1").val() == "") { + $("#edit-"+fieldClass+"-0-value2-timeEntry-popup-1").val('23:59').attr("disabled", "disabled"); + //} +} + +function DateAllDayNo(fieldClass, is_required) { + var currentDate = new Date(); + var curr_hours = currentDate.getHours() + 1; + var curr_minutes = currentDate.getMinutes() + 1; + var curr_month = currentDate.getMonth() + 1; + var mm = new String(curr_month); + var curr_day = currentDate.getDate(); + var dd = new String(curr_day); + var curr_year = currentDate.getFullYear(); + + if (is_required == "") is_required = "0"; + + if ( mm.length == 1 ) mm = "0" + mm; // Add leading zeros to month and day if required + if ( dd.length == 1 ) dd = "0" + dd; + + var curr_date = curr_year+'-'+mm+'-'+dd; + + if((($("#edit-"+fieldClass+"-0-value2-day").val() == curr_day) || ($("#edit-"+fieldClass+"-0-value2-day").val() == $("#edit-"+fieldClass+"-0-value-day").val())) + && (($("#edit-"+fieldClass+"-0-value2-month").val() == curr_month) || ($("#edit-"+fieldClass+"-0-value2-month").val() == $("#edit-"+fieldClass+"-0-value-month").val())) + && (($("#edit-"+fieldClass+"-0-value2-year").val() == curr_year) || ($("#edit-"+fieldClass+"-0-value2-year").val() == $("#edit-"+fieldClass+"-0-value-year").val())) + && (((($("#edit-"+fieldClass+"-0-value2-hour").val() == "11") || ($("#edit-"+fieldClass+"-0-value2-hour").val() == "23")) && ($("#edit-"+fieldClass+"-0-value2-minute").val() == "59") + && ($("#edit-"+fieldClass+"-0-value2-ampm").val() == "pm")) + || (((($("#edit-"+fieldClass+"-0-value2-hour").val() == "11") || ($("#edit-"+fieldClass+"-0-value2-hour").val() == "23")) && ($("#edit-"+fieldClass+"-0-value2-minute").val() == "59")) + && ($("#edit-"+fieldClass+"-0-value2-ampm").val() == undefined))) + ) { + $("#edit-"+fieldClass+"-0-value2-year").val("") + $("#edit-"+fieldClass+"-0-value2-month").val("") + $("#edit-"+fieldClass+"-0-value2-day").val(""); + $("#edit-"+fieldClass+"-0-value2-minute").val(""); + $("#edit-"+fieldClass+"-0-value2-hour").val(""); + $("#edit-"+fieldClass+"-0-value2-ampm").val(""); + } + + if ((($("#edit-"+fieldClass+"-0-value-day").val() == curr_day) + || ($("#edit-"+fieldClass+"-0-value-day").val() == $("#edit-"+fieldClass+"-0-value2-day").val()) + || ($("#edit-"+fieldClass+"-0-value2-day").val() == "") + ) + && (($("#edit-"+fieldClass+"-0-value-month").val() == curr_month) + || ($("#edit-"+fieldClass+"-0-value-month").val() == $("#edit-"+fieldClass+"-0-value2-month").val()) + || ($("#edit-"+fieldClass+"-0-value2-month").val() == "") + ) + && (($("#edit-"+fieldClass+"-0-value-year").val() == curr_year) + || ($("#edit-"+fieldClass+"-0-value-year").val() == $("#edit-"+fieldClass+"-0-value2-year").val()) + || ($("#edit-"+fieldClass+"-0-value2-year").val() == "") + ) + && (((($("#edit-"+fieldClass+"-0-value-hour").val() == "0") || ($("#edit-"+fieldClass+"-0-value-hour").val() == "1")) && ($("#edit-"+fieldClass+"-0-value-minute").val() == "00") + && ($("#edit-"+fieldClass+"-0-value-ampm").val() == "am")) + || ((($("#edit-"+fieldClass+"-0-value-hour").val() == "0") || ($("#edit-"+fieldClass+"-0-value-hour").val() == "1")) && ($("#edit-"+fieldClass+"-0-value-minute").val() == "00")) + && ($("#edit-"+fieldClass+"-0-value-ampm").val() == undefined)) + && (is_required == "0") + ) { + $("#edit-"+fieldClass+"-0-value-year").val(""); + $("#edit-"+fieldClass+"-0-value-month").val(""); + $("#edit-"+fieldClass+"-0-value-day").val(""); + $("#edit-"+fieldClass+"-0-value-minute").val(""); + $("#edit-"+fieldClass+"-0-value-hour").val(""); + $("#edit-"+fieldClass+"-0-value-ampm").val(""); + } + + if ((($("#edit-"+fieldClass+"-0-value2-date").val() == curr_date) && ($("#edit-"+fieldClass+"-0-value-date").val() == curr_date)) + || (($("#edit-"+fieldClass+"-0-value2-date").val() == undefined) && ($("#edit-"+fieldClass+"-0-value-date").val() == curr_date)) + || ($("#edit-"+fieldClass+"-0-value2-date").val() == $("#edit-"+fieldClass+"-0-value-date").val())) { + $("#edit-"+fieldClass+"-0-value-date").val(""); + } + + if (($("#edit-"+fieldClass+"-0-value2-date").val() == curr_date) || ($("#edit-"+fieldClass+"-0-value2-date").val() == $("#edit-"+fieldClass+"-0-value-date").val()) + || ($("#edit-"+fieldClass+"-0-value-date").val() == "")) { + $("#edit-"+fieldClass+"-0-value2-date").val(""); + } + + if ($("#edit-"+fieldClass+"-0-value-timeEntry-popup-1").val() == "00:00") { + $("#edit-"+fieldClass+"-0-value-timeEntry-popup-1").val("09:00").removeAttr("disabled"); + } + if ($("#edit-"+fieldClass+"-0-value2-timeEntry-popup-1").val() == "23:59") { + $("#edit-"+fieldClass+"-0-value2-timeEntry-popup-1").val("17:00").removeAttr("disabled"); + } +} diff -rNu --exclude=CVS date_2.1-orig/date/date_elements.inc date/date/date_elements.inc --- date_2.1-orig/date/date_elements.inc 2009-03-19 17:28:33.000000000 -0700 +++ date/date/date_elements.inc 2009-04-22 11:45:50.000000000 -0700 @@ -60,9 +60,17 @@ continue; } + if ($item['all_day'] == TRUE) { + $items[$delta]['value'] = date(DATE_FORMAT_DATE, strtotime($items[$delta]['value'])); + if ($field['todate']) { + $items[$delta]['value2'] = date(DATE_FORMAT_DATE, strtotime($items[$delta]['value2'])); + } + } + // Special case for ISO dates which may have been given artificial values for // some date parts to make them into valid dates. - if ($field['type'] == DATE_ISO) { + elseif ($field['type'] == DATE_ISO) { + $items[$delta]['value'] = date_limit_value($items[$delta]['value'], date_granularity($field), $field['type']); if ($field['todate']) { $items[$delta]['value2'] = date_limit_value($items[$delta]['value2'], date_granularity($field), $field['type']); @@ -170,6 +178,19 @@ _date_repeat_widget($element, $field, $items, $delta); $element['rrule']['#weight'] = $field['widget']['weight'] + .4; } + + if ($field['all_day'] == TRUE) { + $element['all_day'] = array( + '#title' => t('All-day'), + '#type' => 'checkbox', + '#delta' => $delta, + '#default_value' => $items[$delta]['all_day'], + '#description' => t('Turn on if the date is all-day.'), + '#attributes' => array('onclick' => 'dateAllDayToggle(this.checked, \''. str_replace('_', '-', $field['field_name']) .'\', \''. $field['required'] .'\')'), + ); + drupal_add_js(drupal_get_path('module', 'date') .'/date_all_day.js'); + } + return $element; } diff -rNu --exclude=CVS date_2.1-orig/theme/theme.inc date/theme/theme.inc --- date_2.1-orig/theme/theme.inc 2009-02-17 09:04:31.000000000 -0800 +++ date/theme/theme.inc 2009-04-22 11:50:26.000000000 -0700 @@ -159,6 +159,9 @@ $events[$uid]['timezone'] = ''; } $date_format = ($row->calendar_all_day == TRUE) ? DATE_FORMAT_ICAL_DATE : DATE_FORMAT_ICAL; + if ($event['end'] && $row->calendar_all_day == TRUE){ + $event['end']->modify("+1 day"); + } $events[$uid]['start'] = date_format($event['start'], $date_format); if ($event['start'] && $event['end']) { $events[$uid]['end'] = date_format($event['end'], $date_format); @@ -325,4 +328,4 @@ } function theme_date_part_label_timezone($part_type, $element) { return t('Timezone'); -} \ No newline at end of file +}