Commit 91b465bd authored by webchick's avatar webchick

Issue #2171071 by jessebeach, Wim Leers: Remove drupal_add_library().

parent 1f9a06c6
......@@ -2474,7 +2474,7 @@ function drupal_pre_render_scripts($elements) {
* FALSE if there were any missing library dependencies; TRUE if all library
* dependencies were met.
*
* @see drupal_add_library()
* @see _drupal_add_library()
* @see _drupal_add_js()
* @see _drupal_add_css()
* @see drupal_render()
......@@ -2490,7 +2490,7 @@ function drupal_process_attached($elements, $dependency_check = FALSE) {
// Add the libraries first.
$success = TRUE;
foreach ($elements['#attached']['library'] as $library) {
if (drupal_add_library($library[0], $library[1]) === FALSE) {
if (_drupal_add_library($library[0], $library[1]) === FALSE) {
$success = FALSE;
// Exit if the dependency is missing.
if ($dependency_check) {
......@@ -2692,7 +2692,7 @@ function drupal_process_states(&$elements) {
* @see hook_library_info()
* @see hook_library_info_alter()
*/
function drupal_add_library($module, $name, $every_page = NULL) {
function _drupal_add_library($module, $name, $every_page = NULL) {
$added = &drupal_static(__FUNCTION__, array());
// Only process the library if it exists and it was not added already.
......@@ -2752,7 +2752,7 @@ function drupal_add_library($module, $name, $every_page = NULL) {
* or FALSE if it does not exist. If no $name was passed, an associative array
* of libraries registered by $module is returned (which may be empty).
*
* @see drupal_add_library()
* @see _drupal_add_library()
* @see hook_library_info()
* @see hook_library_info_alter()
*
......
......@@ -1566,7 +1566,8 @@ function theme_tableselect($variables) {
// checkboxes/radios in the first table column.
if ($element['#js_select']) {
// Add a "Select all" checkbox.
drupal_add_library('system', 'drupal.tableselect');
$attached['#attached']['library'][] = array('system', 'drupal.tableselect');
drupal_render($attached);
array_unshift($header, array('class' => array('select-all')));
}
else {
......
......@@ -1558,7 +1558,8 @@ function theme_table($variables) {
// Add sticky headers, if applicable.
if (count($header) && $sticky) {
drupal_add_library('system', 'drupal.tableheader');
$attached['#attached']['library'][] = array('system', 'drupal.tableheader');
drupal_render($attached);
// Add 'sticky-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
$attributes['class'][] = 'sticky-enabled';
......@@ -1567,7 +1568,8 @@ function theme_table($variables) {
// with the classes represented by the constants RESPONSIVE_PRIORITY_MEDIUM
// and RESPONSIVE_PRIORITY_LOW, add the tableresponsive behaviors.
if (count($header) && $responsive) {
drupal_add_library('system', 'drupal.tableresponsive');
$attached['#attached']['library'][] = array('system', 'drupal.tableresponsive');
drupal_render($attached);
// Add 'responsive-enabled' class to the table to identify it for JS.
// This is needed to target tables constructed by this function.
$attributes['class'][] = 'responsive-enabled';
......@@ -2160,7 +2162,8 @@ function template_preprocess_html(&$variables) {
drupal_add_html_head($element, $name);
}
drupal_add_library('system', 'html5shiv', TRUE);
$attached['#attached']['library'][] = array('system', 'html5shiv');
drupal_render($attached);
$variables['page_top'][] = array('#markup' => $page->getBodyTop());
$variables['page_bottom'][] = array('#markup' => $page->getBodyBottom());
......
......@@ -124,7 +124,9 @@ public function setDialogTitle($title) {
*/
public function render() {
// Add the library for handling the dialog in the response.
drupal_add_library('system', 'drupal.dialog.ajax');
$attached['#attached']['library'][] = array('system', 'drupal.dialog.ajax');
drupal_render($attached);
// For consistency ensure the modal option is set to TRUE or FALSE.
$this->dialogOptions['modal'] = isset($this->dialogOptions['modal']) && $this->dialogOptions['modal'];
......
......@@ -121,9 +121,9 @@ function testExportTranslation() {
* Test exportation of translation template file.
*/
function testExportTranslationTemplateFile() {
// Load an admin page with JavaScript so drupal_add_library() fires at least
// once and _locale_parse_js_file() gets to run at least once so that the
// locales_source table gets populated with something.
// Load an admin page with JavaScript so _drupal_add_library() fires at
// least once and _locale_parse_js_file() gets to run at least once so that
// the locales_source table gets populated with something.
$this->drupalGet('admin/config/regional/language');
// Get the translation template file.
$this->drupalPostForm('admin/config/regional/translate/export', array(), t('Export'));
......
......@@ -36,7 +36,8 @@ public static function getInfo() {
* @see locale_library_info_alter()
*/
public function testLibraryInfoAlter() {
drupal_add_library('system', 'jquery.ui.datepicker');
$attached['#attached']['library'][] = array('system', 'jquery.ui.datepicker');
drupal_render($attached);
$scripts = drupal_get_js();
$this->assertTrue(strpos($scripts, 'locale.datepicker.js'), 'locale.datepicker.js added to scripts.');
}
......
......@@ -17,8 +17,6 @@
function theme_simpletest_test_table($variables) {
$table = $variables['table'];
drupal_add_library('simpletest', 'drupal.simpletest');
// Create header for test selection table.
$header = array(
array('class' => array('select-all')),
......@@ -133,6 +131,7 @@ function theme_simpletest_test_table($variables) {
// Add js array of settings.
$attached = array();
$attached['#attached']['library'][] = array('simpletest', 'drupal.simpletest');
$attached['#attached']['js'][] = array(
'data' => array('simpleTest' => $js),
'type' => 'setting',
......
......@@ -311,7 +311,7 @@ function hook_js_alter(&$javascript) {
* An array defining libraries associated with a module.
*
* @see system_library_info()
* @see drupal_add_library()
* @see _drupal_add_library()
* @see drupal_get_library()
*/
function hook_library_info() {
......
......@@ -1260,6 +1260,7 @@ function system_library_info() {
'version' => '3.6.2',
'js' => array(
'core/assets/vendor/html5shiv/html5.js' => array(
'every_page' => TRUE,
'group' => JS_LIBRARY,
'weight' => -22,
'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE),
......@@ -2183,7 +2184,7 @@ function system_user_timezone(&$form, &$form_state) {
if (!$account->getTimezone() && $account->id() == $user->id() && empty($form_state['input']['timezone'])) {
$form['timezone']['#description'] = t('Your time zone setting will be automatically detected if possible. Confirm the selection and click save.');
$form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect'));
drupal_add_library('system', 'drupal.timezone');
$form['#attached']['library'][] = array('system', 'drupal.timezone');
}
}
......
......@@ -360,7 +360,8 @@ function views_preprocess_page(&$variables) {
unset($class[$key]);
$attributes['class'] = $class;
$attributes['data-views-page-contextual-id'] = $variables['title_suffix']['contextual_links']['#id'];
drupal_add_library('views', 'views.contextual-links');
$attached['#attached']['library'][] = array('views', 'views.contextual-links');
drupal_render($attached);
}
}
}
......
......@@ -5,7 +5,7 @@
* Contains \Drupal\Tests\Core\Ajax\AjaxCommandsTest.
*/
namespace Drupal\Tests\Core\Ajax {
namespace Drupal\Tests\Core\Ajax;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Ajax\AddCssCommand;
......@@ -424,13 +424,3 @@ public function testRedirectCommand() {
}
}
}
namespace {
if (!function_exists('drupal_add_library')) {
function drupal_add_library() {
return TRUE;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment