=== jquery_ui.module ================================================================== --- jquery_ui.module (revision 2695) +++ jquery_ui.module (local) @@ -34,11 +34,15 @@ * An array of what additional files (other than UI core) should be loaded * on the page, or a string with a single file name. */ -function jquery_ui_add($files = array()) { +function jquery_ui_add($files = array(), $theme = NULL) { static $loaded_files, $ui_core, $effects_core; $jquery_ui_path = JQUERY_UI_PATH . '/ui'; $compression = variable_get('jquery_update_compression_type', 'mini'); + // Set the theme. + $theme_name = $theme ? $theme : variable_get('jquery_ui_theme', 'base'); + $theme_path = JQUERY_UI_PATH . '/themes/' . $theme_name; + // Convert file to an array if it's not one already, to compensate for // lazy developers. ;) if (!is_array($files)) { @@ -48,7 +52,9 @@ // If core hasn't been added yet, add it. if (!isset($ui_core)) { $ui_core = TRUE; - jquery_ui_add(array('ui.core')); + jquery_ui_add(array('ui.core'), $theme); + drupal_add_css($theme_path . '/ui.core.css'); + drupal_add_css($theme_path . '/ui.theme.css'); } // Loop through list of files to include and add them to the page. @@ -56,7 +62,7 @@ // Any effects files require the effects core file. if (!isset($effects_core) && strpos($file, 'effects.') === 0) { $effects_core = TRUE; - jquery_ui_add(array('effects.core')); + jquery_ui_add(array('effects.core'), $theme); } // Load other files. @@ -77,6 +83,8 @@ } $js_path = $jquery_ui_path . '/' . $file_path; drupal_add_js($js_path); + $css_path = $theme_path . '/' . $file . '.css'; + drupal_add_css($css_path); $loaded_files[$file] = $js_path; } } @@ -95,3 +103,35 @@ return $version; } +/** + * Implementation of hook_menu() + */ +function jquery_ui_menu() { + $items['admin/settings/jquery_ui'] = array( + 'title' => 'jQuery UI', + 'description' => 'Configure settings for jQuery UI module.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('jquery_ui_settings'), + 'access arguments' => array('administer site configuration'), + ); + return $items; +} + +function jquery_ui_settings() { + $theme_path = JQUERY_UI_PATH . '/themes'; + $files = file_scan_directory($theme_path, '.*', array('.', '..', 'CVS', '.DS_Store'), 0, FALSE, 'basename'); + + $options = array(); + foreach ($files as $name => $file) { + $options[$name] = $name; + } + + $form['jquery_ui_theme'] = array( + '#type' => 'radios', + '#title' => t('Choose jQuery UI theme'), + '#default_value' => variable_get('jquery_ui_theme', 'base'), + '#options' => $options, + ); + + return system_settings_form($form); +}