diff --git a/date_popup/date_popup.module b/date_popup/date_popup.module index f219a72..d10f1a4 100644 --- a/date_popup/date_popup.module +++ b/date_popup/date_popup.module @@ -57,17 +57,34 @@ function date_popup_css_options() { return $paths; } $version = jquery_ui_get_version(); - $jquery_ui_path = drupal_get_path('module', 'jquery_ui'); + // $jquery_ui_path should contain path to jquery.ui directory, not the module directory. + $jquery_ui_path = jquery_ui_get_path(); switch ($version) { case '1.6': $paths[drupal_get_path('module', 'date_popup') .'/themes/datepicker.css'] = t('Date Popup default'); - $paths[$jquery_ui_path .'/jquery.ui/themes/default/ui.datepicker.css'] = t('jQuery UI default'); + // $jquery_ui_path contains path to jquery.ui directory + $paths[$jquery_ui_path .'/themes/default/ui.datepicker.css'] = t('jQuery UI default'); break; default: $paths[drupal_get_path('module', 'date_popup') .'/themes/datepicker.1.7.css'] = t('Date Popup default'); - $paths[$jquery_ui_path .'/jquery.ui/themes/base/ui.datepicker.css'] = t('jQuery UI default'); + // $jquery_ui_path contains path to jquery.ui directory + $paths[$jquery_ui_path .'/themes/base/ui.datepicker.css'] = t('jQuery UI default'); break; } + // Populate options array with available themes from jQuery UI. + // Each theme must be put in jquery.ui/themes/ in their own directory + // e.g. jquery.ui/themes/cupertino, jquery.ui/themes/ui-lightness, etc. + // All themes can be downloaded from + // http://jquery-ui.googlecode.com/files/jquery-ui-themes-1.7.zip + if ($handle = opendir($jquery_ui_path .'/themes/')) { + while (false !== ($dir = readdir($handle))) { + $full_dir_path = $jquery_ui_path .'/themes/'. $dir; + if (is_dir($full_dir_path) && $dir != '.' && $dir != '..' && $dir != 'base') { + $paths[$full_dir_path .'/ui.datepicker.css'] = $dir; + } + } + closedir($handle); + } return $paths; } @@ -81,7 +98,18 @@ function date_popup_init() { return; } - drupal_add_css(variable_get('date_popup_css_file', date_popup_css_default())); + $date_popup_css_file = variable_get('date_popup_css_file', date_popup_css_default()); + + // Force loading base jquery-ui.css when using date_popup default theme, + // otherwise the popup calendar will be displayed with no theme at all. + if ($date_popup_css_file == date_popup_css_default()) { + drupal_add_css(jquery_ui_get_path() .'/themes/base/jquery-ui.css'); + } + // If use other theme then load the css file in the corresponding theme directory. + else { + drupal_add_css(dirname($date_popup_css_file) .'/jquery-ui.css'); + } + drupal_add_css($date_popup_css_file); if (variable_get('date_popup_timepicker', 'default') == 'default') { drupal_add_css(drupal_get_path('module', 'date_popup') .'/themes/jquery.timeentry.css');