summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-25 21:16:31 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-25 21:16:31 +0000
commit2c7e1f2a41ce1af8e582b540a3b580955c26c0d0 (patch)
treee98fac38ae876a9b2ba9f13845ce313165651ddc /modules
parentb1cf3f1d26f9fd177548f5305f104c2d8d8df90e (diff)
downloadbrdo-2c7e1f2a41ce1af8e582b540a3b580955c26c0d0.tar.gz
brdo-2c7e1f2a41ce1af8e582b540a3b580955c26c0d0.tar.bz2
#505084 by Rob Loach: Added an #attached_library() FAPI property for drupal_add_library(), for consistency with #attached_css and #attached_js.
Diffstat (limited to 'modules')
-rw-r--r--modules/color/color.module28
-rw-r--r--modules/simpletest/tests/common.test14
-rw-r--r--modules/system/system.module13
3 files changed, 45 insertions, 10 deletions
diff --git a/modules/color/color.module b/modules/color/color.module
index d3ddeadc1..2cefe7d43 100644
--- a/modules/color/color.module
+++ b/modules/color/color.module
@@ -154,16 +154,6 @@ function color_scheme_form(&$form_state, $theme) {
$base = drupal_get_path('module', 'color');
$info = color_get_info($theme);
- // Add Farbtastic color picker.
- drupal_add_library('system', 'farbtastic');
-
- // Add custom CSS and JS.
- drupal_add_css($base . '/color.css', array('preprocess' => FALSE));
- drupal_add_js($base . '/color.js');
- drupal_add_js(array('color' => array(
- 'reference' => color_get_palette($theme, TRUE)
- )), 'setting');
-
// See if we're using a predefined scheme.
$current = implode(',', variable_get('color_' . $theme . '_palette', array()));
// Note: we use the original theme when the default scheme is chosen.
@@ -176,6 +166,24 @@ function color_scheme_form(&$form_state, $theme) {
'#title' => t('Color set'),
'#options' => $info['schemes'],
'#default_value' => $current,
+ // Add Farbtastic color picker.
+ '#attached_library' => array(
+ array('system', 'farbtastic'),
+ ),
+ // Add custom CSS.
+ '#attached_css' => array(
+ $base . '/color.css' => array('preprocess' => FALSE),
+ ),
+ // Add custom JavaScript.
+ '#attached_js' => array(
+ $base . '/color.js',
+ array(
+ 'data' => array('color' => array(
+ 'reference' => color_get_palette($theme, TRUE),
+ )),
+ 'type' => 'setting',
+ ),
+ ),
);
// Add palette fields.
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 13aad21e0..ad565b1ab 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -857,6 +857,20 @@ class JavaScriptTestCase extends DrupalWebTestCase {
$scripts = drupal_get_js();
$this->assertTrue(strpos($scripts, 'unknown') === FALSE, t('Unknown library was not added to the page.'));
}
+
+ /**
+ * Tests the addition of libraries through the #attached_library property.
+ */
+ function testAttachedLibrary() {
+ $element = array(
+ '#attached_library' => array(
+ array('system', 'farbtastic'),
+ )
+ );
+ drupal_render($element);
+ $scripts = drupal_get_js();
+ $this->assertTrue(strpos($scripts, 'misc/farbtastic/farbtastic.js'), t('The attached_library property adds the additional libraries.'));
+ }
}
/**
diff --git a/modules/system/system.module b/modules/system/system.module
index 274558e0d..a4c0a600d 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -931,6 +931,19 @@ function system_library() {
),
);
+ // Vertical Tabs.
+ $libraries['vertical-tabs'] = array(
+ 'title' => 'Vertical Tabs',
+ 'website' => 'http://drupal.org/node/323112',
+ 'version' => '1.0',
+ 'js' => array(
+ 'misc/vertical-tabs.js' => array(),
+ ),
+ 'css' => array(
+ 'misc/vertical-tabs.css' => array(),
+ ),
+ );
+
// Farbtastic.
$libraries['farbtastic'] = array(
'title' => 'Farbtastic',