--- jquery_ui.module Thu Feb 24 22:08:46 2011 +++ jquery_ui.module Wed May 11 01:44:53 2011 @@ -19,7 +19,7 @@ * 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_get_path(); @@ -29,6 +29,12 @@ $jquery_ui_path .= '/ui'; $compression = variable_get('jquery_update_compression_type', 'mini'); + // Select theme to use. + if ($theme == NULL) { + $theme = variable_get('jquery_ui_theme', 'base'); + } + $theme_path = jquery_ui_get_path() . '/themes/' . $theme; + // Convert file to an array if it's not one already, to compensate for // lazy developers. ;) if (!is_array($files)) { @@ -39,6 +45,17 @@ if (!isset($ui_core)) { $ui_core = TRUE; jquery_ui_add(array('ui.core')); + + // Add minimal CSS when using base theme, otherwise add full themeroller + // style. + if ($theme == 'base') { + drupal_add_css($theme_path . '/ui.theme.css'); + } + else { + drupal_add_css($theme_path . '/ui.all.css'); + $css_path = $theme_path . '/jquery-ui-'.jquery_ui_get_version().'.custom.css'; + drupal_add_css($css_path); + } } // Loop through list of files to include and add them to the page. @@ -67,6 +84,11 @@ } $js_path = $jquery_ui_path . '/' . $file_path; drupal_add_js($js_path); + + // Add modular CSS files when using base theme. + if ($theme == 'base') { + drupal_add_css($theme_path . '/' . $file . '.css'); + } $loaded_files[$file] = $js_path; } } @@ -133,3 +155,38 @@ 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; +} + +/** + * Menu callback to display settings form. + */ +function jquery_ui_settings() { + $theme_path = jquery_ui_get_path() . '/themes'; + $options = array('base' => '<' . t('default') . '>'); + + $files = file_scan_directory($theme_path, '.*', array('.', '..', 'CVS', 'base', '.DS_Store'), 0, FALSE, 'basename'); + foreach ($files as $name => $file) { + $options[$name] = $name; + } + + $form['jquery_ui_theme'] = array( + '#type' => 'radios', + '#title' => t('Select jQuery UI theme'), + '#default_value' => variable_get('jquery_ui_theme', 'base'), + '#options' => $options, + ); + + return system_settings_form($form); +} \ No newline at end of file