diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 2c6826d..0b1995d 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -55,7 +55,7 @@ a.block-demo-backlink:hover { .block-list-right .form-type-search { padding: 0 1em; } -.block-list-left .block-placed { +#block-placed { background-color: #ffd; } diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 0cca062..39f9212 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -72,11 +72,10 @@ function showBlockEntry (index, block) { * Highlights the block that was just placed into the block listing. */ Drupal.behaviors.blockHighlightPlacement = { - attach: function () { - var match = window.location.href.match(/#block-placement:(.*)$/); - if (match) { + attach: function (context, settings) { + if (settings.blockPlacement) { var $container = $('#blocks'); - var $element = $container.find('.' + match[1]).addClass('block-placed'); + var $element = $('#block-placed'); $('html, body').animate({ scrollTop: $element.offset().top - $container.offset().top + $container.scrollTop() }, 500); diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 45a2b71..30fd6db 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -294,7 +294,7 @@ public function submit(array $form, array &$form_state) { drupal_set_message($this->t('The block configuration has been saved.')); Cache::invalidateTags(array('content' => TRUE)); $form_state['redirect'] = array('admin/structure/block/list/' . $entity->get('theme'), array( - 'fragment' => 'block-placement:' . drupal_html_class($this->entity->id()), + 'query' => array('block-placement' => drupal_html_class($this->entity->id())), )); } diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index 4e17d76..4acc4ae 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -119,6 +119,15 @@ public function getFormID() { * Form constructor for the main block administration form. */ public function buildForm(array $form, array &$form_state) { + $request = \Drupal::request(); + $placement = FALSE; + if ($request->query->has('block-placement')) { + $placement = $request->query->get('block-placement'); + $form['#attached']['js'][] = array( + 'type' => 'setting', + 'data' => array('blockPlacement' => $placement), + ); + } $entities = $this->load(); $form['#attached']['library'][] = array('system', 'drupal.tableheader'); $form['#attached']['library'][] = array('block', 'drupal.block'); @@ -224,9 +233,12 @@ public function buildForm(array $form, array &$form_state) { $form['left']['blocks'][$entity_id] = array( '#attributes' => array( - 'class' => array('draggable', drupal_html_class($entity_id)), + 'class' => array('draggable'), ), ); + if ($placement && $placement == drupal_html_class($entity_id)) { + $form['left']['blocks'][$entity_id]['#attributes']['id'] = 'block-placed'; + } $form['left']['blocks'][$entity_id]['info'] = array( '#markup' => check_plain($info['admin_label']),