diff --git includes/common.inc includes/common.inc index 9f45fec..1d4cf5c 100644 --- includes/common.inc +++ includes/common.inc @@ -3185,6 +3185,8 @@ function drupal_get_js($scope = 'header', $javascript = NULL) { * An array of JavaScript components to add. * @param $css * An array of cascading stylesheets to add. + * @param $dialog + * An array of parameters as expected by drupal_add_dialog(). * @param $weight * The default weight of JavaScript and CSS being added. This is only applied * to the stylesheets and JavaScript items that don't have an explicit weight @@ -3199,7 +3201,7 @@ function drupal_get_js($scope = 'header', $javascript = NULL) { * * @see drupal_add_library(), drupal_render() */ -function drupal_process_attached(array $libraries = array(), array $js = array(), array $css = array(), $weight = JS_DEFAULT, $dependency_check = FALSE) { +function drupal_process_attached(array $libraries = array(), array $js = array(), array $css = array(), array $dialogs, $weight = JS_DEFAULT, $dependency_check = FALSE) { // Add the libraries first. $success = TRUE; foreach ($libraries as $library) { @@ -3234,6 +3236,12 @@ function drupal_process_attached(array $libraries = array(), array $js = array() call_user_func('drupal_add_' . $type, $data, $options); } } + + // Dialogs to the page. + foreach ($dialogs as $dialog) { + call_user_func_array('drupal_add_dialog', $dialog); + } + return $success; } @@ -3266,7 +3274,7 @@ function drupal_add_library($module, $name) { if (!isset($added[$module][$name])) { if ($library = drupal_get_library($module, $name)) { // Add all components within the library. - $added[$module][$name] = drupal_process_attached($library['dependencies'], $library['js'], $library['css'], JS_LIBRARY, TRUE); + $added[$module][$name] = drupal_process_attached($library['dependencies'], $library['js'], $library['css'], array(), JS_LIBRARY, TRUE); } else { // Requested library does not exist. @@ -4119,7 +4127,8 @@ function drupal_render(&$elements) { drupal_process_attached( isset($elements['#attached_library']) ? $elements['#attached_library'] : array(), isset($elements['#attached_js']) ? $elements['#attached_js'] : array(), - isset($elements['#attached_css']) ? $elements['#attached_css'] : array() + isset($elements['#attached_css']) ? $elements['#attached_css'] : array(), + isset($elements['#attached_dialog']) ? $elements['#attached_dialog'] : array() ); $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : ''; @@ -4230,7 +4239,8 @@ function drupal_render_cache_get($elements) { drupal_process_attached( isset($cache->data['#attached_library']) ? $cache->data['#attached_library'] : array(), isset($cache->data['#attached_js']) ? $cache->data['#attached_js'] : array(), - isset($cache->data['#attached_css']) ? $cache->data['#attached_css'] : array() + isset($cache->data['#attached_css']) ? $cache->data['#attached_css'] : array(), + isset($cache->data['#attached_dialog']) ? $cache->data['#attached_dialog'] : array() ); // Return the rendered output. return $cache->data['#markup'];; @@ -5409,3 +5419,34 @@ function xmlrpc($url) { return call_user_func_array('_xmlrpc', $args); } +/** + * Adds a dialog using jQuery UI. + * + * @param $trigger_selector + * A jQuery selector which should open a dialog when clicked. + * Example: 'a#modal-link' + * @param $content_selector + * A jQuery selector which contains the content for display in the dialog. + * @param $options + * An array of dialog options keyed by option name. + * See http://docs.jquery.com/UI/Dialog#options for available options. + */ +function drupal_add_dialog($trigger_selector = '', $content_selector = '', $options = array()) { + $dialogs = &drupal_static(__FUNCTION__, array()); + if (!count($dialogs)) { + drupal_add_library('system', 'ui.dialog'); + drupal_add_library('system', 'ui.draggable'); + drupal_add_library('system', 'ui.resizable'); + drupal_add_js('misc/dialog.js'); + } + if (!isset($dialogs[$trigger_selector])) { + $dialogs[$trigger_selector] = array( + 'content_selector' => $content_selector, + 'options' => $options, + ); + // Allow modules to alter dialogs. + drupal_alter('dialog', $dialogs); + drupal_add_js(array('dialogs' => $dialogs), 'setting'); + } + return $dialogs; +} diff --git modules/filter/filter.module modules/filter/filter.module index 6ab8245..cdc3182 100644 --- modules/filter/filter.module +++ modules/filter/filter.module @@ -57,9 +57,6 @@ function filter_theme() { 'arguments' => array('tips' => NULL, 'long' => FALSE), 'file' => 'filter.pages.inc', ), - 'filter_tips_more_info' => array( - 'arguments' => array(), - ), 'filter_guidelines' => array( 'arguments' => array('format' => NULL), ), @@ -635,10 +632,11 @@ function filter_form($selected_format = FILTER_FORMAT_DEFAULT, $weight = NULL, $ ); $form['format_help'] = array( '#prefix' => '
' . l(t('More information about text formats'), 'filter/tips') . '
'; +function filter_tips_more_info() { + $build['more'] = array('#markup' => l(t('More information about text formats'), 'filter/tips', array('attributes' => array('class' => 'filter-tips-modal')))); + $build['long'] = array( + '#prefix' => '