diff --git a/components/date.inc b/components/date.inc index 2450f73..093d712 100644 --- a/components/date.inc +++ b/components/date.inc @@ -6,6 +6,21 @@ */ /** + * No date picker option. + */ +define('DATEPICKER_NONE', 0); + +/** + * Popup date picker option. + */ +define('DATEPICKER_POPUP', 1); + +/** + * Inline date picker option. + */ +define('DATEPICKER_INLINE', 2); + +/** * Implements _webform_defaults_component(). */ function _webform_defaults_date() { @@ -22,7 +37,7 @@ function _webform_defaults_date() { 'start_date' => '-2 years', 'end_date' => '+2 years', 'year_textfield' => 0, - 'datepicker' => 1, + 'datepicker' => DATEPICKER_POPUP, 'title_display' => 0, 'description' => '', 'description_above' => FALSE, @@ -90,10 +105,15 @@ function _webform_edit_date($component) { ); $form['display']['datepicker'] = array( - '#type' => 'checkbox', + '#type' => 'radios', '#title' => t('Enable popup calendar'), '#default_value' => $component['extra']['datepicker'], - '#description' => t('Enable a JavaScript date picker next to the date field.'), + '#options' => array( + DATEPICKER_POPUP => t('Popup calendar'), + DATEPICKER_INLINE => t('Inline calendar'), + DATEPICKER_NONE => t('No calendar'), + ), + '#description' => t('Enable a JavaScript date picker, either as a popup or inlined.'), '#weight' => 2, '#parents' => array('extra', 'datepicker'), ); @@ -190,8 +210,8 @@ function _webform_render_date($component, $value = NULL, $filter = TRUE, $submis '#translatable' => array('title', 'description'), ); - if ($component['extra']['datepicker']) { - $element['#datepicker'] = TRUE; + if ($component['extra']['datepicker'] != DATEPICKER_NONE) { + $element['#datepicker'] = $component['extra']['datepicker']; $element['#attached'] = array( 'library' => array( array('system', 'ui.datepicker'), @@ -375,8 +395,12 @@ function theme_webform_date($variables) { $class = array('webform-container-inline'); // Add the JavaScript calendar if available (provided by Date module package). - if (!empty($element['#datepicker'])) { + $datepicker = $element['#datepicker']; + if ($datepicker != DATEPICKER_NONE) { $class[] = 'webform-datepicker'; + if ($datepicker == DATEPICKER_INLINE) { + $class[] = 'webform-datepicker-inline'; + } $calendar_class = array('webform-calendar'); if ($element['#start_date']) { $calendar_class[] = 'webform-calendar-start-' . $element['#start_date']; @@ -386,8 +410,8 @@ function theme_webform_date($variables) { } $calendar_class[] ='webform-calendar-day-' . variable_get('date_first_day', 0); - $calendar = theme('webform_calendar', array('component' => $element['#webform_component'], 'calendar_classes' => $calendar_class)); - } + $calendar = theme('webform_calendar', array('component' => $element['#webform_component'], 'calendar_classes' => $calendar_class, 'datepicker_style' => $datepicker)); +} $output = ''; $output .= '