X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Foutside_in%2Foutside_in.module;fp=web%2Fcore%2Fmodules%2Foutside_in%2Foutside_in.module;h=0000000000000000000000000000000000000000;hp=6673fa37185c100c85c2a2ab0ea3259f330fd329;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/outside_in/outside_in.module b/web/core/modules/outside_in/outside_in.module deleted file mode 100644 index 6673fa371..000000000 --- a/web/core/modules/outside_in/outside_in.module +++ /dev/null @@ -1,165 +0,0 @@ -' . t('About') . ''; - $output .= '

' . t('The Settings Tray module provides an \'edit mode\' in which clicking on a block opens a slide-out tray which allows configuration to be altered without leaving the page.For more information, see the online documentation for the Settings Tray module.', [':outside-in-documentation' => 'https://www.drupal.org/documentation/modules/outside_in']) . '

'; - $output .= '

' . t('Uses') . '

'; - $output .= '
'; - $output .= '
' . t('Editing blocks on the same page in the slide-out tray') . '
'; - $output .= '
'; - return ['#markup' => $output]; - } -} - -/** - * Implements hook_contextual_links_view_alter(). - * - * Change Configure Blocks into off_canvas links. - */ -function outside_in_contextual_links_view_alter(&$element, $items) { - if (isset($element['#links']['outside-inblock-configure'])) { - // Place outside_in link first. - $outside_in_link = $element['#links']['outside-inblock-configure']; - unset($element['#links']['outside-inblock-configure']); - $element['#links'] = ['outside-inblock-configure' => $outside_in_link] + $element['#links']; - - $element['#links']['outside-inblock-configure']['attributes'] = [ - 'class' => ['use-ajax'], - 'data-dialog-type' => 'dialog', - 'data-dialog-renderer' => 'off_canvas', - 'data-outside-in-edit' => TRUE, - ]; - // If this is content block change title to avoid duplicate "Quick Edit". - if (isset($element['#links']['block-contentblock-edit'])) { - $element['#links']['outside-inblock-configure']['title'] = t('Quick edit settings'); - } - - $element['#attached']['library'][] = 'outside_in/drupal.off_canvas'; - } -} - -/** - * Implements hook_block_view_alter(). - */ -function outside_in_block_view_alter(array &$build) { - // Force a new 'data-contextual-id' attribute on blocks when this module is - // enabled so as not to reuse stale data cached client-side. - // @todo Remove when https://www.drupal.org/node/2773591 is fixed. - $build['#contextual_links']['outside_in'] = [ - 'route_parameters' => [], - ]; -} - -/** - * Implements hook_element_info_alter(). - */ -function outside_in_element_info_alter(&$type) { - if (isset($type['page'])) { - $type['page']['#theme_wrappers']['outside_in_page_wrapper'] = ['#weight' => -1000]; - } -} - -/** - * Implements hook_theme(). - */ -function outside_in_theme() { - return [ - 'outside_in_page_wrapper' => [ - 'variables' => ['children' => NULL], - ], - ]; -} - -/** - * Implements hook_entity_type_build(). - */ -function outside_in_entity_type_build(array &$entity_types) { - /* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */ - $entity_types['block'] - ->setFormClass('off_canvas', BlockEntityOffCanvasForm::class) - ->setLinkTemplate('off_canvas-form', '/admin/structure/block/manage/{block}/off-canvas'); -} - -/** - * Implements hook_preprocess_HOOK() for block templates. - */ -function outside_in_preprocess_block(&$variables) { - // The main system block does not contain the block contextual links. - $variables['#cache']['contexts'][] = 'outside_in_is_applied'; - if ($variables['plugin_id'] !== 'system_main_block' && \Drupal::service('outside_in.manager')->isApplicable()) { - // Add class and attributes to all blocks to allow Javascript to target. - $variables['attributes']['class'][] = 'outside-in-editable'; - $variables['attributes']['data-drupal-outsidein'] = 'editable'; - } -} - -/** - * Implements hook_toolbar_alter(). - * - * Includes outside_library if Edit link is in toolbar. - */ -function outside_in_toolbar_alter(&$items) { - $items['contextual']['#cache']['contexts'][] = 'outside_in_is_applied'; - if (isset($items['contextual']['tab']) && \Drupal::service('outside_in.manager')->isApplicable()) { - $items['contextual']['#weight'] = -1000; - $items['contextual']['#attached']['library'][] = 'outside_in/drupal.outside_in'; - $items['contextual']['tab']['#attributes']['data-drupal-outsidein'] = 'toggle'; - - // Set a class on items to mark whether they should be active in edit mode. - // @todo Create a dynamic method for modules to set their own items. - // https://www.drupal.org/node/2784589 - - $edit_mode_items = ['contextual', 'block_place']; - foreach ($items as $key => $item) { - if (!in_array($key, $edit_mode_items) && (!isset($items[$key]['#wrapper_attributes']['class']) || !in_array('hidden', $items[$key]['#wrapper_attributes']['class']))) { - $items[$key]['#wrapper_attributes']['class'][] = 'edit-mode-inactive'; - } - } - } -} - -/** - * Implements hook_block_alter(). - */ -function outside_in_block_alter(&$definitions) { - if (!empty($definitions['system_branding_block'])) { - $definitions['system_branding_block']['forms']['off_canvas'] = SystemBrandingOffCanvasForm::class; - } - - // Since menu blocks use derivatives, check the definition ID instead of - // relying on the plugin ID. - foreach ($definitions as &$definition) { - if ($definition['id'] === 'system_menu_block') { - $definition['forms']['off_canvas'] = SystemMenuOffCanvasForm::class; - } - } -} - -/** - * Implements hook_css_alter(). - */ -function outside_in_css_alter(&$css, AttachedAssetsInterface $assets) { - // @todo Remove once conditional ordering is introduced in - // https://www.drupal.org/node/1945262. - $path = drupal_get_path('module', 'outside_in') . '/css/outside_in.theme.css'; - if (isset($css[$path])) { - // Use 200 to come after CSS_AGGREGATE_THEME. - $css[$path]['group'] = 200; - } -}