From 35aa002432dd36bddd968fce5c7e004f43f2eb1b Mon Sep 17 00:00:00 2001
From: Jesse Beach <splendidnoise@gmail.com>
Date: Sun, 18 Dec 2011 18:43:57 -0500
Subject: [PATCH] Issue #1375232 by jessebeach: Added support for displaying configuration in the block edit form vertical tab.

Signed-off-by: Jesse Beach <splendidnoise@gmail.com>
---
 javascript_libraries.module              |    6 ++++
 js/javascript_libraries.vertical-tabs.js |   49 ++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)
 create mode 100644 js/javascript_libraries.vertical-tabs.js

diff --git a/javascript_libraries.module b/javascript_libraries.module
index 3fb1010..ecf3e21 100644
--- a/javascript_libraries.module
+++ b/javascript_libraries.module
@@ -356,6 +356,7 @@ function javascript_libraries_form_block_admin_configure_alter(&$form, &$form_st
   $delta = $form['delta']['#value'];
   $settings = variable_get('javascript_libraries_block_settings', array());
   $form['actions']['#weight'] = 100;
+  $path = drupal_get_path('module', 'javascript_libraries');
 
   $custom = variable_get('javascript_libraries_custom_libraries', array());
   $options = array();
@@ -374,6 +375,11 @@ function javascript_libraries_form_block_admin_configure_alter(&$form, &$form_st
     '#description' => t('Specify which custom libraries should be loaded in the footer on pages where this block is visible.'),
     '#tree' => TRUE,
     '#weight' => 50,
+    '#attached' => array(
+      'js' => array(
+        'vertical-tabs' => $path . '/js/javascript_libraries.vertical-tabs.js',
+      ),
+    ),
   );
   $form['visibility']['javascript_libraries']['custom'] = array(
     '#type' => 'checkboxes',
diff --git a/js/javascript_libraries.vertical-tabs.js b/js/javascript_libraries.vertical-tabs.js
new file mode 100644
index 0000000..234a07e
--- /dev/null
+++ b/js/javascript_libraries.vertical-tabs.js
@@ -0,0 +1,49 @@
+/*jslint bitwise: true, eqeqeq: true, immed: true, newcap: true, nomen: false,
+ onevar: false, plusplus: false, regexp: true, undef: true, white: true, indent: 2
+ browser: true */
+
+/*global jQuery: true Drupal: true window: true ThemeBuilder: true */
+
+(function ($) {
+
+  Drupal.javascriptLibraries = Drupal.javascriptLibraries || {};
+
+  Drupal.behaviors.javascriptLibraries = {
+    attach: function (context) {
+      // The drupalSetSummary method required for this behavior is not available
+      // on the Blocks administration page, so we need to make sure this
+      // behavior is processed only if drupalSetSummary is defined.
+      if (typeof jQuery.fn.drupalSetSummary === 'undefined') {
+        return;
+      }
+      $('fieldset#edit-javascript-libraries', context).drupalSetSummary(function (context) {
+        var output = [],
+            libraries = $('#edit-javascript-libraries-custom :checked', context);
+        if (libraries.length > 0) {
+          var limit = 2,
+              extra = 0;
+          libraries.each(function (index, element) {
+            if (index < limit) {
+              var $this = $(this);
+              // Push the text of the checkbox label into the output.
+              output.push($this.siblings('label').text().trim());
+            }
+            // If the limit is reached, just print 'and N more'.
+            if (index >= limit) {
+              var params = {
+                '@extra': ++extra
+              };
+              output[limit] = Drupal.t(' and @extra more', params);
+            }
+          });
+        }
+        else {
+          output.push(Drupal.t('No libraries selected'));
+        }
+
+        // Join the various vertical tab messages with a break in between them.
+        return output.join('<br />');
+      });
+    }
+  };
+}(jQuery));
-- 
1.7.3.4

