diff --git jquery_ui.module jquery_ui.module index 0ae9fd9..6a8cf6d 100644 --- jquery_ui.module +++ jquery_ui.module @@ -11,20 +11,6 @@ */ /** - * Path to jQuery UI library. - * - * During site installation, JQUERY_UI_PATH is the absolute path to the - * jQuery UI library. At all other times JQUERY_UI_PATH is relative, and - * safe for use in URLs. - */ -if (defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install') { - define('JQUERY_UI_PATH', dirname(__FILE__) . '/jquery.ui'); -} -else { - define('JQUERY_UI_PATH', drupal_get_path('module', 'jquery_ui') . '/jquery.ui'); -} - -/** * Add the specified jQuery UI library files to this page. * * The ui.core file is always included automatically, as well as the @@ -36,7 +22,7 @@ else { */ function jquery_ui_add($files = array()) { static $loaded_files, $ui_core, $effects_core; - $jquery_ui_path = JQUERY_UI_PATH . '/ui'; + $jquery_ui_path = jquery_ui_get_path() . '/ui'; $compression = variable_get('jquery_update_compression_type', 'mini'); // Convert file to an array if it's not one already, to compensate for @@ -88,10 +74,37 @@ function jquery_ui_add($files = array()) { function jquery_ui_get_version() { $version = 0; - if (file_exists(JQUERY_UI_PATH . '/version.txt')) { - $version = file_get_contents(JQUERY_UI_PATH . '/version.txt'); + $version_file = jquery_ui_get_path() . '/version.txt'; + if (file_exists($version_file)) { + $version = file_get_contents($version_file); } return $version; } +/** + * Return the path of installed jQuery UI. + */ +function jquery_ui_get_path() { + static $jquery_ui_path; + + if (isset($jquery_ui_path)) { + return $jquery_ui_path; + } + + // check first for the standard default libraries directory + // then for any other libraries directory + // and finally for the in jquery ui module directory + $static_libraries = 'sites/all/libraries/jquery.ui'; + if (file_exists($static_libraries) && is_dir($static_libraries)) { + $jquery_ui_path = $static_libraries; + } + elseif (function_exists('libraries_get_path')) { + $jquery_ui_path = libraries_get_path('jquery.ui'); + } + else { + $jquery_ui_path = drupal_get_path('module', 'jquery_ui') . '/jquery.ui'; + } + + return $jquery_ui_path; +}