Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.857 diff -u -r1.857 system.module --- modules/system/system.module 6 Dec 2009 01:00:27 -0000 1.857 +++ modules/system/system.module 9 Dec 2009 04:44:24 -0000 @@ -1187,6 +1187,8 @@ ), 'dependencies' => array( array('system', 'ui'), + array('system', 'ui.draggable'), + array('system', 'ui.resizable'), ), ); $libraries['ui.draggable'] = array( Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.1061 diff -u -r1.1061 common.inc --- includes/common.inc 7 Dec 2009 08:46:59 -0000 1.1061 +++ includes/common.inc 9 Dec 2009 04:44:24 -0000 @@ -3999,6 +3999,7 @@ 'library' => array(), 'js' => array(), 'css' => array(), + 'ui' => array(), ); // Add the libraries first. @@ -4014,6 +4015,12 @@ } unset($elements['#attached']['library']); + // Add any bound jQuery UI elements. + foreach ($elements['#attached']['ui'] as $ui) { + drupal_add_ui($ui); + } + unset($elements['#attached']['ui']); + // Add both the JavaScript and the CSS. // The parameters for drupal_add_js() and drupal_add_css() require special // handling. @@ -4145,6 +4152,101 @@ } /** + * Adds a jQuery UI element to the page, and invokes its behaviors. + * + * @param $options + * An associative array with the following keys defining the jQuery UI being + * added: + * - selector: The jQuery selector for the element to apply the action to. + * - action: (optional) The name of the jQuery function to be called. This + * allows calling functions like "show", "hide", etc. If not provided, + * will default to the name of the library in use, through "library". + * - arguments: (optional) An array of arguments that are passed to the + * element during execution. + * - library: (optional) The name of the library to add, if desired. Some + * examples are "ui.dialog", "effects.resizable", "ui.accordion", etc. + * - module: (optional) When adding a library, this represents the name of the + * module that originally registered the library. Defaults to "system". + * - event: (optional) On what binded event the tool should be applied to the + * element. Defaults to once the element is ready, much like the effects of + * document.ready(). + * - bound_element: (optional) When binding on an event other than ready, will + * be the element that the event is binded to. Defaults to what was passed + * into the "selector" argument. + * - is: (optional) Allows applying the effect only when the given condition + * is met. To read more about "is", visit the jQuery documentation at: + * http://docs.jquery.com/Traversing/is . + * - is_selector: (optional) When acting on a conditioning attribute through + * the "is" parameter, this argument represents a jQuery selector pointing + * to the element that will be checked. Defaults to the "bound_element". + * - functions: (optional) An associative array of functions to declare during + * the execution of this effect. The key is the name of the function, and + * the value is the JavaScript code that will be executed. When processing + * the effect, it will iterate through all "arguments", and replace all the + * found function names with the actual function callback. This allows + * function callbacks to be passed through as arguments. + * - return_value: (optional) The value which should be returned after the action is + * taken on the bound element. Defaults to FALSE. + * - actions: (optional) An array of different actions to take on the given + * element. All parameters are inherited from the parent action, but can be + * overriden by the chind action. + * @return + * An array representing all elements added to the page so far. + */ +function drupal_add_ui(array $options = array()) { + // Merge in the defaults. + $options += array( + 'module' => 'system', + 'event' => 'ready', + ); + + // Prepare the jQuery UI Drupal behaviors. + $elements = &drupal_static(__FUNCTION__, array()); + if (empty($elements)) { + drupal_add_js('misc/ui.js'); + } + + // Allow multiple actions to be invoked on the element. + if (isset($options['actions'])) { + foreach ($options['actions'] as $action) { + // The base elements are inherited from the parent action so that the + // items don't have to be defined twice. + $action = array_merge($options, $action); + // Remove items that should not be inherited, and invoke the action. + unset($action['actions']); + drupal_add_ui($action); + } + } + + // Add the depending library, if needed. + if (isset($options['library'])) { + $library = $options['library']; + // Make sure to only add the library once. + if (!isset($elements[$library])) { + $elements[$library] = array(); + drupal_add_library($options['module'], $library); + } + + // The action defaults to the associated library if not explicitly provided. + if (!isset($options['action'])) { + // Remove the prefixing "ui." of jQuery UI widgets. + $options['action'] = str_replace('ui.', '', $library); + } + } + + // Add the settings so that the behaviors are attached to the elements. + if (isset($options['selector'])) { + $action = $options['action']; + $elements[$action][] = $options; + // Remove items that the JavaScript doesn't need, and add it to the settings. + unset($options['module'], $options['library'], $options['actions']); + $settings['ui'][$action][] = $options; + drupal_add_js($settings, 'setting'); + } + return $elements; +} + +/** * Retrieves information for a JavaScript/CSS library. * * Library information is statically cached. Libraries are keyed by module for Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.53 diff -u -r1.53 filter.admin.inc --- modules/filter/filter.admin.inc 8 Dec 2009 03:10:51 -0000 1.53 +++ modules/filter/filter.admin.inc 9 Dec 2009 04:44:24 -0000 @@ -168,7 +168,30 @@ $tiplist = '
' . t('No guidelines available.') . '
'; } else { - $tiplist .= theme('filter_tips_more_info'); + $tiplist .= '' . l(t('More information about text formats'), 'filter/tips', array('attributes' => array('class' => array('filter-tips-modal')))) . '
'; + + // Create a dialog box for the filter tips. + $tiplist .= '' . t('These are the guidelines that users will see for posting in this text format. They are automatically generated from the filter settings.') . '
'; $group .= $tiplist; Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.309 diff -u -r1.309 filter.module --- modules/filter/filter.module 8 Dec 2009 06:58:41 -0000 1.309 +++ modules/filter/filter.module 9 Dec 2009 04:44:24 -0000 @@ -57,9 +57,6 @@ 'variables' => array('tips' => NULL, 'long' => FALSE), 'file' => 'filter.pages.inc', ), - 'filter_tips_more_info' => array( - 'variables' => array(), - ), 'filter_guidelines' => array( 'variables' => array('format' => NULL), ), @@ -744,10 +741,40 @@ ); $form['format_help'] = array( '#prefix' => '' . l(t('More information about text formats'), 'filter/tips') . '
'; -} - -/** * Format guidelines for a text format. * * @param $variables Index: modules/filter/filter.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.pages.inc,v retrieving revision 1.9 diff -u -r1.9 filter.pages.inc --- modules/filter/filter.pages.inc 13 Oct 2009 15:39:41 -0000 1.9 +++ modules/filter/filter.pages.inc 9 Dec 2009 04:44:24 -0000 @@ -11,17 +11,9 @@ * Menu callback; show a page with long filter tips. */ function filter_tips_long() { - $format_id = arg(2); - if ($format_id) { - $output = theme('filter_tips', array('tips' => _filter_tips($format_id, TRUE), 'long' => TRUE)); - } - else { - $output = theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE)); - } - return $output; + return theme('filter_tips', array('tips' => _filter_tips(-1, TRUE), 'long' => TRUE)); } - /** * Render HTML for a set of filter tips. * Index: misc/ui.js =================================================================== RCS file: misc/ui.js diff -N misc/ui.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ misc/ui.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,89 @@ +// $Id$ +(function ($) { + +/** + * @file + * Provides the jQuery UI Drupal behaviors. + */ + +/** + * The base UI namespace. + */ +Drupal.ui = { + // An array of functions that will be dynamically created. + functions: [], + processFunctions: function (elements) { + // Recurse through the items and associate any provided function names + // with the correct function callback. + $.each(elements, function (index, value) { + // Make sure we only check for function names (aka strings). + if (typeof(value) == 'string') { + // See if the function exists and associate the callback. + if (Drupal.ui.functions[value] || false) { + elements[index] = Drupal.ui.functions[value]; + } + } + else { + // Since it's not a string, we should recurse into it. + elements[index] = Drupal.ui.processFunctions(value); + } + }); + return elements; + } +}; + +/** + * The jQuery UI Drupal behavior. + * + * This will go through all desired actions and apply them to the appropriate + * selectors with the given arguments. It also takes the binded events into + * consideration. + */ +Drupal.behaviors.ui = { + attach: function (context, settings) { + if (settings.ui || false) { + // Iterate through each desired jQuery UI effect and apply the tool to + // the elements. + $.each(settings.ui, function (action, effects) { + $.each(effects, function (index, effect) { + // Process the function declarations. + if (effect.functions || false) { + $.each(effect.functions, function (name, code) { + // Create the function callback, wrapping the code in jQuery. + Drupal.ui.functions[name] = new Function(name, '(function ($) {' + code + '})(jQuery);'); + }); + effect.arguments = Drupal.ui.processFunctions(effect.arguments); + } + + // See if we are to bind the tool to an event, or just apply it when + // the element itself is ready. + if (effect.event == 'ready') { + // Apply the jQuery UI's effect. + $(effect.selector, context).once('ui-' + action + '-' + index, function() { + // Since we are calling the function with a dynamic set of + // arguments, we have to use the JavaScript apply function. + $(this)[action].apply($(this), effect.arguments); + }); + } + else { + // Apply the jQuery UI's effect on the binded event. If a bound + // element isn't provided, we will use the original selected item. + $(effect.bound_element || effect.selector, context).once('ui-' + action + '-' + index).bind(effect.event, function() { + // Make sure the "is" argument is satisfied. + if (effect.is ? $(effect.is_selector ? effect.is_selector : this).is(effect.is) : true) { + // Apply the tool to the element using the arguments array. + var element = $(effect.selector); + element[action].apply(element, effect.arguments); + } + // Return the expected value, defaulting to false to override + // the default functionality of the action. + return effect.return_value || false; + }); + } + }); + }); + } + } +}; + +})(jQuery);