Commit ff4a8e9f authored by alexpott's avatar alexpott

Issue #2095335 by Wim Leers, vijaycs85: Remove drupal_add_css() and...

Issue #2095335 by Wim Leers, vijaycs85: Remove drupal_add_css() and drupal_add_js() from the ajax system.
parent b795708d
......@@ -47,14 +47,35 @@ public function testOrder() {
// Expected commands, in a very specific order.
$expected_commands[0] = new SettingsCommand(array('ajax' => 'test'), TRUE);
drupal_static_reset('drupal_add_css');
drupal_add_css($path . '/css/system.admin.css');
drupal_add_css($path . '/css/system.maintenance.css');
$attached = array(
'#attached' => array(
'css' => array(
$path . '/css/system.admin.css' => array(),
$path . '/css/system.maintenance.css' => array()
),
),
);
drupal_render($attached);
$expected_commands[1] = new AddCssCommand(drupal_get_css(drupal_add_css(), TRUE));
drupal_static_reset('drupal_add_js');
drupal_add_js($path . '/system.js');
$attached = array(
'#attached' => array(
'js' => array(
$path . '/system.js' => array(),
),
),
);
drupal_render($attached);
$expected_commands[2] = new PrependCommand('head', drupal_get_js('header', drupal_add_js(), TRUE));
drupal_static_reset('drupal_add_js');
drupal_add_js($path . '/system.modules.js', array('scope' => 'footer'));
$attached = array(
'#attached' => array(
'js' => array(
$path . '/system.modules.js' => array('scope' => 'footer'),
),
),
);
drupal_render($attached);
$expected_commands[3] = new AppendCommand('body', drupal_get_js('footer', drupal_add_js(), TRUE));
$expected_commands[4] = new HtmlCommand('body', 'Hello, world!');
......
......@@ -414,8 +414,21 @@ function ajax_forms_test_advanced_commands_add_css_callback($form, $form_state)
* Ajax callback for 'settings' but with setting overrides.
*/
function ajax_forms_test_advanced_commands_settings_with_merging_callback($form, $form_state) {
drupal_add_js(array('ajax_forms_test' => array('foo' => 42)), 'setting');
drupal_add_js(array('ajax_forms_test' => array('foo' => 9001)), 'setting');
$attached = array(
'#attached' => array(
'js' => array(
0 => array(
'type' => 'setting',
'data' => array('ajax_forms_test' => array('foo' => 42)),
),
'1' => array(
'type' => 'setting',
'data' => array('ajax_forms_test' => array('foo' => 9001)),
),
),
),
);
drupal_render($attached);
$response = new AjaxResponse();
return $response;
......@@ -541,9 +554,22 @@ function ajax_forms_test_lazy_load_form($form, &$form_state) {
*/
function ajax_forms_test_lazy_load_form_submit($form, &$form_state) {
if ($form_state['values']['add_files']) {
drupal_add_js(array('ajax_forms_test_lazy_load_form_submit' => 'executed'), 'setting');
drupal_add_css(drupal_get_path('module', 'system') . '/css/system.admin.css');
drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
$path = drupal_get_path('module', 'system');
$attached = array(
'#attached' => array(
'css' => array(
$path . '/css/system.admin.css' => array(),
),
'js' => array(
0 => array(
'type' => 'setting',
'data' => array('ajax_forms_test_lazy_load_form_submit' => 'executed'),
),
$path . '/system.js' => array(),
),
),
);
drupal_render($attached);
}
$form_state['rebuild'] = TRUE;
}
......
......@@ -43,7 +43,17 @@ function ajax_test_system_theme_info() {
* @deprecated \Drupal\ajax_test\Controller\AjaxTestController::render()
*/
function ajax_test_render() {
drupal_add_js(array('ajax' => 'test'), 'setting');
$attached = array(
'#attached' => array(
'js' => array(
0 => array(
'type' => 'setting',
'data' => array('ajax' => 'test'),
),
),
),
);
drupal_render($attached);
$response = new AjaxResponse();
return $response;
}
......@@ -60,14 +70,26 @@ function ajax_test_order() {
$path = drupal_get_path('module', 'system');
// HTML insertion command.
$response->addCommand(new HtmlCommand('body', 'Hello, world!'));
// Add two CSS files (order should remain the same).
drupal_add_css($path . '/css/system.admin.css');
drupal_add_css($path . '/css/system.maintenance.css');
// Add two JavaScript files (first to the footer, should appear last).
drupal_add_js($path . '/system.modules.js', array('scope' => 'footer'));
drupal_add_js($path . '/system.js');
// Finally, add a JavaScript setting.
drupal_add_js(array('ajax' => 'test'), 'setting');
$attached = array(
'#attached' => array(
'css' => array(
// Add two CSS files (order should remain the same).
$path . '/css/system.admin.css' => array(),
$path . '/css/system.maintenance.css' => array(),
),
'js' => array(
// Add two JavaScript files (first to the footer, should appear last).
$path . '/system.modules.js' => array('scope' => 'footer'),
$path . '/system.js' => array(),
// Finally, add a JavaScript setting.
0 => array(
'type' => 'setting',
'data' => array('ajax' => 'test'),
),
),
),
);
drupal_render($attached);
return $response;
}
......
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