diff --git a/core/modules/block/css/block.admin.css b/core/modules/block/css/block.admin.css index 7cd9233..0b1995d 100644 --- a/core/modules/block/css/block.admin.css +++ b/core/modules/block/css/block.admin.css @@ -55,6 +55,9 @@ a.block-demo-backlink:hover { .block-list-right .form-type-search { padding: 0 1em; } +#block-placed { + background-color: #ffd; +} /* Wide screens */ @media diff --git a/core/modules/block/js/block.admin.js b/core/modules/block/js/block.admin.js index 93d9229..f22d547 100644 --- a/core/modules/block/js/block.admin.js +++ b/core/modules/block/js/block.admin.js @@ -68,4 +68,18 @@ function showBlockEntry (index, block) { } }; +/** + * Highlights the block that was just placed into the block listing. + */ +Drupal.behaviors.blockHighlightPlacement = { + attach: function (context, settings) { + if (settings.blockPlacement) { + var $container = $('#blocks'); + $('html, body').animate({ + scrollTop: $('#block-placed').offset().top - $container.offset().top + $container.scrollTop() + }, 500); + } + } +}; + }(jQuery, Drupal)); diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 83d10af..30fd6db 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -293,7 +293,9 @@ 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'] = 'admin/structure/block/list/' . $entity->get('theme'); + $form_state['redirect'] = array('admin/structure/block/list/' . $entity->get('theme'), array( + '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 b9d6218..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'); @@ -227,6 +236,9 @@ public function buildForm(array $form, array &$form_state) { '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']),