Commit 8e95e850 authored by webchick's avatar webchick
Browse files

jQuery UI module is a wrapper around the jQuery UI library, which lets you do...

jQuery UI module is a wrapper around the jQuery UI library, which lets you do all kinds of swishy, swooshy effects.
// $Id$
* Introduction
* Installation
* Jeff Robbins (jjeff)
* Angela Byron (webchick)
* Addison Berry (add1sun)
This Module Made by Robots:
jQuery UI ( is a set of cool widgets and effects that
developers can use to add some pizazz to their modules.
This module is more-or-less a utility module that should simply be required by
other modules that depend on jQuery UI being available. It doesn't do anything
on its own.
1. Copy the jquery_ui directory to your sites/SITENAME/modules directory.
2. Download the full version of jQuery UI from
3. Extract it as a sub-directory called 'jquery.ui' in the jquery_ui folder:
4. Enable the module at Administer >> Site building >> Modules.
5. If desired, configure the module at Administer >> Site configuration >>
jQuery UI. Here you may select which level of compression the jQuery library
should use. It defaults to 'minified' compression, which strips comments and
white space.
Developers who wish to use jQuery UI effects in their modules need only make
the following changes:
1. In your module's .info file, add the following line:
dependencies[] = jquery_ui
This will force users to have the jQuery UI module installed before they can
enable your module.
2. In your module, call the following function:
For example:
jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.sortable'));
See the contents of the jquery.ui-X.X sub-directory for a list of available
files that may be included, and see for details on
how to use them. The required ui.core file is automatically included, as is
effects.core if you include any effects files.
If you wish to override the compression type selected in the settings
screen, you may do so by passing in an optional $type parameter. Possible
values are 'none', 'minified', and 'packed'.
jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.sortable'), 'none');
; $Id$
name = jQuery UI
description = Provides the jQuery UI plug-in to other Drupal modules.
core = 6.x
dependencies[] = jquery_update
// $Id$
* @file
* Installation file for jQuery UI module.
* Implementation of hook_requirements().
function jquery_ui_requirements($phase) {
$requirements = array();
$t = get_t();
$jquery_ui_version = 0;
if ($phase == 'install') {
// The jquery_ui_get_version() function is in the .module file, which isn't
// loaded yet.
include_once base_path() . drupal_get_path('module', 'jquery_ui') . '/jquery_ui.module';
$requirements['jquery_ui']['title'] = $t('jQuery UI');
if ($jquery_ui_version = jquery_ui_get_version()) {
// Everything looks good; display the current jQuery UI version.
$requirements['jquery_ui']['value'] = $jquery_ui_version;
$requirements['jquery_ui']['severity'] = REQUIREMENT_OK;
else {
// Required library wasn't found. Abort installation.
$requirements['jquery_ui']['value'] = $t('Not found');
$requirements['jquery_ui']['description'] = $t('Missing jQuery UI plug-in. Please !download and extract it to your jquery_ui module directory. See README.txt for more info.', array('!download' => l(t('download jQuery UI'), '')));
$requirements['jquery_ui']['severity'] = REQUIREMENT_ERROR;
return $requirements;
// $Id$
* @file
* Provides the jQuery UI plug-in to other Drupal modules.
* This module doesn't do too much, but it is a central location for any other
* modules that implement the JQuery UI library. It ensures that multiple
* modules will all include the same library script just once on any given page.
* Add JQuery interface library to this page.
* @param $files
* An array of what additional files (other than UI core) should be loaded
* on the page.
* @param $type
* Compression type: leave empty to use admin setting.
* Possible values: 'minified', 'packed', 'none'
function jquery_ui_add($files = array(), $type = NULL) {
static $loaded_files, $ui_core, $effects_core;
$jquery_ui_path = drupal_get_path('module', 'jquery_ui') . '/jquery.ui';
// If a type wasn't specified, then default to whatever was specified in the
// settings page.
if (is_null($type)) {
$type = variable_get('jquery_ui_compression_type', 'minified');
// If core hasn't been added yet, add it.
if (!isset($ui_core)) {
$ui_core = TRUE;
// Loop through list of files to include and add them to the page.
foreach ($files as $file) {
// Any effects files require the effects core file.
if (!isset($effects_core) && strpos($file, 'effects.') === 0) {
$effects_core = TRUE;
// Load other files.
if (!isset($loaded_files[$file])) {
switch ($type) {
case 'none':
$file_path = "$file.js";
case 'packed':
$file_path = "packed-javascript/$file.packed.js";
case 'minified':
$file_path = "minified-javascript/$file.min.js";
$js_path = $jquery_ui_path . '/' . $file_path;
$loaded_files[$file] = $js_path; // or TRUE...
* 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_admin_settings'),
'access arguments' => array('access site configuration'),
return $items;
* Admin settings form.
function jquery_ui_admin_settings() {
$form['jquery_ui_compression_type'] = array(
'#type' => 'radios',
'#title' => t('jQuery UI compression type'),
'#options' => drupal_map_assoc(array('packed', 'minified', 'none')),
'#default_value' => variable_get('jquery_ui_compression_type', 'minified'),
'#description' => t("Type of compression to use. 'Packed' uses Dean Edward's packer to make the file size as small as possible, but may require more browser processing. 'Minified' takes out all comments, whitespace, etc. to reduce the file size to a lesser degree, maintaining performance. 'None' leaves the full source intact."),
return system_settings_form($form);
* Return the version of jQuery UI installed.
function jquery_ui_get_version() {
$version = 0;
// Attempt to locate the jQuery UI directory and extract the version.
$module_directory = drupal_get_path('module', 'jquery_ui') . '/jquery.ui';
$files = file_scan_directory($module_directory, 'jquery\.ui-all-.*\.js$', $nomask = array('.', '..', 'CVS'), $callback = 0, $recurse = FALSE);
$file = array_shift($files);
if (preg_match('#jquery\.ui-all-(.+)$#', $file->name, $matches)) {
$version = $matches[1];
return $version;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment