diff -u b/core/includes/theme.inc b/core/includes/theme.inc --- b/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1707,46 +1707,15 @@ } /** - * Builds a render array for theme_dropbutton(). - */ -function template_preprocess_dropbutton(&$variables) { - $variables['attributes']['class'][] = 'dropbutton'; - $variables['element'] = array( - '#theme' => 'links', - '#links' => $variables['links'], - '#attributes' => $variables['attributes'], - '#attached' => array( - 'library' => array( - array('system', 'drupal.dropbutton'), - ), - ), - ); - if (!empty($variables['links'])) { - $variables['element']['#prefix'] = '
'; - } - // Pass through title to the dropbutton options. - if (isset($variables['title'])) { - $variables['element']['#attached']['js'][] = array( - 'type' => 'setting', - 'data' => array('dropbutton' => array('title' => $variables['title'])), - ); - } -} - -/** - * Creates a dropbutton menu. + * Returns HTML for wrapping a dropbutton menu. * * @param array $variables * An associative array containing: - * - title: (optional) The text placed in the clickable area to activate the - * dropbutton. Defaults to 'Open dropbutton'. - * - links: An array of links to provide in the dropbutton. - * - attributes: (optional) An associative array of HTML attributes to apply - * to the dropbutton. + * - element: An associative array containing the properties and children of + * the dropbutton menu. Properties used: #children. */ -function theme_dropbutton($variables) { - return render($variables['element']); +function theme_dropbutton_wrapper($variables) { + return ''; } /** @@ -2947,8 +2916,8 @@ 'links' => array( 'variables' => array('links' => array(), 'attributes' => array('class' => array('links')), 'heading' => array()), ), - 'dropbutton' => array( - 'variables' => array('title' => NULL, 'links' => array(), 'attributes' => array()), + 'dropbutton_wrapper' => array( + 'render element' => 'element', ), 'image' => array( // HTML 4 and XHTML 1.0 always require an alt attribute. The HTML 5 draft diff -u b/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc --- b/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -539,9 +539,9 @@ // Render an unordered list of operations links. $options[$node->nid]['operations'] = array( 'data' => array( - '#theme' => 'dropbutton__node_operations', + '#type' => 'operations', + '#subtype' => 'node', '#links' => $operations, - '#attributes' => array('class' => array('links', 'inline')), ), ); } diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -535,6 +535,14 @@ '#default_tab' => '', '#process' => array('form_process_vertical_tabs'), ); + $types['dropbutton'] = array( + '#theme' => 'links__dropbutton', + '#pre_render' => array('drupal_pre_render_dropbutton'), + ); + $types['operations'] = array( + '#theme' => 'links__dropbutton__operations', + '#pre_render' => array('drupal_pre_render_dropbutton'), + ); $types['container'] = array( '#theme_wrappers' => array('container'), diff -u b/core/modules/system/tests/modules/theme_test/theme_test.module b/core/modules/system/tests/modules/theme_test/theme_test.module --- b/core/modules/system/tests/modules/theme_test/theme_test.module +++ b/core/modules/system/tests/modules/theme_test/theme_test.module @@ -174,7 +174,8 @@ $build['#rows']['long']['created'] = format_interval(3200); $build['#rows']['long']['operations'] = array( 'data' => array( - '#theme' => 'dropbutton__node_operations', + '#type' => 'operations', + '#subtype' => 'node', '#links' => array( 'edit' => array( 'title' => 'edit', @@ -206,7 +207,8 @@ $build['#rows']['one']['created'] = format_interval(12400); $build['#rows']['one']['operations'] = array( 'data' => array( - '#theme' => 'dropbutton__node_operations', + '#type' => 'operations', + '#subtype' => 'node', '#links' => array( 'edit' => array( 'title' => 'edit', @@ -221,7 +223,8 @@ $build['#rows']['view']['created'] = format_interval(12400); $build['#rows']['view']['operations'] = array( 'data' => array( - '#theme' => 'dropbutton__node_operations', + '#type' => 'operations', + '#subtype' => 'node', '#links' => array(), ), ); only in patch2: unchanged: --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -5461,6 +5461,26 @@ function drupal_pre_render_links($element) { } /** + * Pre-render callback: Attaches the dropbutton library and required markup. + */ +function drupal_pre_render_dropbutton($element) { + $element['#attached']['library'][] = array('system', 'drupal.dropbutton'); + $element['#attributes']['class'][] = 'dropbutton'; + if (!isset($element['#theme_wrappers'])) { + $element['#theme_wrappers'] = array(); + } + array_unshift($element['#theme_wrappers'], 'dropbutton_wrapper'); + + // Enable targeted theming of specific dropbuttons (e.g., 'operations' or + // 'operations__node'). + if (isset($element['#subtype'])) { + $element['#theme'] .= '__' . $element['#subtype']; + } + + return $element; +} + +/** * Pre-render callback: Appends contents in #markup to #children. * * This needs to be a #pre_render callback, because eventually assigned