');
- this.$('[data-region-name="' + region.get('name') + '"]').append(empty_elem);
- }
-
- // Attach a View to this empty element.
- this.blockViews.push(new Drupal.panels_ipe.BlockView({
- 'model': block,
- 'el': "[data-block-id='" + block.get('uuid') + "']"
- }));
-
- // Fetch the block content from the server
- if (typeof empty_elem != 'undefined') {
- block.fetch();
- }
-
- }, this);
- }, this);
- }
-
- });
-
-}(jQuery, _, Backbone, Drupal));
reverted:
--- b/panels_ipe/js/views/TabsView.js
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * @file
- * The primary Backbone view for a tab collection.
- *
- * see Drupal.panels_ipe.TabCollection
- */
-
-(function ($, _, Backbone, Drupal) {
-
- Drupal.panels_ipe.TabsView = Backbone.View.extend(/** @lends Drupal.panels_ipe.TabsView# */{
-
- /**
- * @type {function}
- */
- template_tab: _.template('
<%= title %>'),
-
- /**
- * @type {function}
- */
- template_content: _.template('
'),
-
- /**
- * @type {object}
- */
- events: {
- 'click .ipe-tab > a': 'switchTab'
- },
-
- /**
- * @type {Drupal.panels_ipe.TabCollection}
- */
- collection: null,
-
- /**
- * @type {Object}
- *
- * An object mapping tab IDs to Backbone views.
- */
- tabViews: {},
-
- /**
- * @constructs
- *
- * @augments Backbone.TabsView
- *
- * @param {object} options
- * An object with the following keys:
- * @param {object} options.tabViews
- * An object mapping tab IDs to Backbone views.
- */
- initialize: function (options) {
- this.tabViews = options.tabViews;
- },
-
- /**
- * Renders our tab collection.
- */
- render: function() {
- // Empty our list.
- this.$el.empty();
-
- // Setup the initial wrapping elements.
- this.$el.append('
');
- this.$el.append('
');
-
- // Append each of our tabs and their tab content view.
- this.collection.each(function(tab) {
- // Append the tab.
- var id = tab.get('id');
- this.$('.ipe-tabs').append(this.template_tab(tab.toJSON()));
-
- // Render the tab content.
- this.$('.ipe-tabs-content').append(this.template_content(tab.toJSON()));
- // Check to see if this tab has content.
- if (tab.get('active') && this.tabViews[id]) {
- this.tabViews[id].setElement('[data-tab-content-id="' + id + '"]').render();
- }
- }, this);
- return this;
- },
-
- /**
- * Switches the current tab.
- */
- switchTab: function(e) {
- e.preventDefault();
- var id = $(e.currentTarget).parent().data('tab-id');
-
- // Disable all existing tabs.
- this.collection.each(function(tab) {
- // If the user is clicking the same tab twice, close it.
- if (tab.get('id') == id && tab.get('active') == true) {
- tab.set('active', false);
- }
- // If this is the first click, open the tab.
- else if (tab.get('id') == id) {
- tab.set('active', true);
- }
- // The tab wasn't clicked, make sure it's closed.
- else {
- tab.set('active', false);
- }
- });
-
- // Trigger a re-render.
- this.render();
- }
-
- });
-
-}(jQuery, _, Backbone, Drupal));
reverted:
--- b/panels_ipe/panels_ipe.info.yml
+++ /dev/null
@@ -1,8 +0,0 @@
-name: Panels IPE
-type: module
-description: Panels In-place editor.
-core: 8.x
-package: Panels
-dependencies:
- - panels
- - page_manager
\ No newline at end of file
reverted:
--- b/panels_ipe/panels_ipe.libraries.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-panels_ipe:
- version: VERSION
- js:
- # Core.
- js/panels_ipe.js: {}
- # Models.
- js/models/AppModel.js: {}
- js/models/BlockModel.js: {}
- js/models/RegionModel.js: {}
- js/models/TabModel.js: {}
- js/models/LayoutModel.js: {}
- # Views.
- js/views/AppView.js: {}
- js/views/BlockView.js: {}
- js/views/LayoutPicker.js: {}
- js/views/LayoutView.js: {}
- js/views/TabsView.js: {}
- css:
- component:
- css/panels_ipe.css: {}
- dependencies:
- - core/jquery
- - core/jquery.once
- - core/jquery.ui
- - core/jquery.ui.draggable
- - core/jquery.form
- - core/underscore
- - core/backbone
- - core/drupal
- - core/drupal.displace
- - core/drupal.form
- - core/drupal.ajax
- - core/drupal.debounce
- - core/drupalSettings
- - core/drupal.dialog
reverted:
--- b/panels_ipe/panels_ipe.permissions.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-access panels in-place editing:
- title: 'Access panels in-place editing'
\ No newline at end of file
reverted:
--- b/panels_ipe/panels_ipe.routing.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-panels_ipe.block:
- path: '/admin/panels_ipe/variant/{variant_id}/block/{block_id}'
- defaults:
- _controller: '\Drupal\panels_ipe\Controller\PanelsIPEPageController::getBlock'
- requirements:
- _permission: 'access panels in-place editing'
-
-panels_ipe.layouts:
- path: '/admin/panels_ipe/variant/{variant_id}/layouts'
- defaults:
- _controller: '\Drupal\panels_ipe\Controller\PanelsIPEPageController::getLayouts'
- requirements:
- _permission: 'access panels in-place editing'
-
-panels_ipe.layout:
- path: '/admin/panels_ipe/variant/{variant_id}/layouts/{layout_id}'
- defaults:
- _controller: '\Drupal\panels_ipe\Controller\PanelsIPEPageController::getLayout'
- requirements:
- _permission: 'access panels in-place editing'
\ No newline at end of file
reverted:
--- b/panels_ipe/src/Controller/PanelsIPEPageController.php
+++ /dev/null
@@ -1,222 +0,0 @@
-blockManager = $block_manager;
- $this->renderer = $renderer;
- }
-
- /**
- * {@inheritdoc}
- */
- public static function create(ContainerInterface $container) {
- return new static(
- $container->get('plugin.manager.block'),
- $container->get('renderer')
- );
- }
-
- /**
- * Gets a block's metadata and rendered HTML.
- *
- * @param string $variant_id
- * The machine name of the current display variant.
- * @param string $block_id
- * The UUID of the requested block.
- *
- * @return JsonResponse
- *
- * @throws AccessDeniedHttpException|NotFoundHttpException
- */
- public function getBlock($variant_id, $block_id) {
- // Check if the variant exists.
- /** @var \Drupal\page_manager\PageVariantInterface $variant */
- if (!$variant = PageVariant::load($variant_id)) {
- throw new NotFoundHttpException();
- }
-
- /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $variant_plugin */
- $variant_plugin = $variant->getVariantPlugin();
-
- // Check if the block exists.
- if (!$block = $variant_plugin->getBlock($block_id)) {
- throw new NotFoundHttpException();
- }
-
- // Check entity access before continuing.
- $user = $this->currentUser();
- if (!$block->access($user)) {
- throw new AccessDeniedHttpException();
- }
-
- // Assemble a render array for the block.
- // @todo Support contexts and revisions for all entities.
- $configuration = $block->getConfiguration();
- $elements = [
- '#theme' => 'block',
- '#attributes' => [
- 'data-block-id' => $block->getConfiguration()['uuid']
- ],
- '#configuration' => $configuration,
- '#plugin_id' => $block->getPluginId(),
- '#base_plugin_id' => $block->getBaseId(),
- '#derivative_plugin_id' => $block->getDerivativeId(),
- 'content' => $block->build()
- ];
-
- // Return a structured JSON response for our Backbone App.
- $data = [
- 'html' => $this->renderer->render($elements),
- 'uuid' => $configuration['uuid'],
- 'label' => $block->label(),
- 'id' => $block->getPluginId()
- ];
-
- return new JsonResponse($data);
- }
-
- /**
- * Gets a list of available Layouts, without wrapping HTML.
- *
- * @param string $variant_id
- * The machine name of the current display variant.
- *
- * @return JsonResponse
- *
- * @throws AccessDeniedHttpException|NotFoundHttpException
- */
- public function getLayouts($variant_id) {
- // Check if the variant exists.
- /** @var \Drupal\page_manager\PageVariantInterface $variant */
- if (!$variant = PageVariant::load($variant_id)) {
- throw new NotFoundHttpException();
- }
-
- /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $variant_plugin */
- $variant_plugin = $variant->getVariantPlugin();
-
- // Get the current layout.
- $layout = $variant_plugin->getConfiguration()['layout'];
-
- // Get a list of all available layouts.
- $layouts = Layout::getLayoutOptions();
- $data = [];
- foreach ($layouts as $id => $label) {
- $data[] = [
- 'id' => $id,
- 'label' => $label,
- 'current' => $layout == $id
- ];
- }
-
- // Return a structured JSON response for our Backbone App.
- return new JsonResponse($data);
- }
-
- /**
- * Gets a given layout with empty regions and relevant metadata.
- *
- * @param string $variant_id
- * The machine name of the current display variant.
- * @param string $layout_id
- * The machine name of the requested layout.
- *
- * @return JsonResponse
- *
- * @throws AccessDeniedHttpException|NotFoundHttpException
- */
- public function getLayout($variant_id, $layout_id) {
- // Check if the variant exists.
- /** @var \Drupal\page_manager\PageVariantInterface $variant */
- if (!$variant = PageVariant::load($variant_id)) {
- throw new NotFoundHttpException();
- }
-
- /** @var \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $variant_plugin */
- $variant_plugin = $variant->getVariantPlugin();
-
- // Build the requested layout.
- $configuration = $variant_plugin->getConfiguration();
- $configuration['layout'] = $layout_id;
- $variant_plugin->setConfiguration($configuration);
- $build = $variant_plugin->build();
-
- // Remove all blocks from the build.
- $regions = $variant_plugin->getRegionNames();
- $region_data = [];
- foreach ($regions as $id => $label) {
- // Get all block/random keys.
- $children = Element::getVisibleChildren($build[$id]);
- // Unset those keys, retaining the theme variables for the region.
- $build[$id] = array_diff_key($build[$id], array_flip($children));
-
- // Format region metadata.
- $region_data[] = [
- 'name' => $id,
- 'label' => $label
- ];
- }
-
- // Remove the wrapping elements, which our builder adds to every build.
- unset($build['#suffix']);
- unset($build['#prefix']);
-
- // Get the current layout.
- $current_layout = $variant_plugin->getConfiguration()['layout'];
-
- // Get a list of all available layouts.
- $layouts = Layout::getLayoutOptions();
-
- $data = [
- 'id' => $layout_id,
- 'label' => $layouts[$layout_id],
- 'current' => $current_layout == $layout_id,
- 'html' => $this->renderer->render($build),
- 'regions' => $region_data
- ];
-
- // Return a structured JSON response for our Backbone App.
- return new JsonResponse($data);
- }
-
-}
reverted:
--- b/panels_ipe/src/Plugin/DisplayBuilder/InPlaceEditorDisplayBuilder.php
+++ /dev/null
@@ -1,118 +0,0 @@
- [],
- ];
-
- // Add current block IDs to settings sorted by region.
- foreach ($regions as $region => $blocks) {
- $settings['regions'][$region] = [
- 'name' => $region,
- 'label' => '',
- 'blocks' => []
- ];
-
- if (!$blocks) {
- continue;
- }
-
- /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
- foreach ($blocks as $block_uuid => $block) {
- $settings['regions'][$region]['blocks'][$block_uuid] = [
- 'uuid' => $block_uuid,
- 'label' => $block->label(),
- 'id' => $block->getPluginId()
- ];
- }
- }
-
- // Add the layout information.
- if ($layout) {
- $layout_definition = $layout->getPluginDefinition();
- $settings['layout'] = [
- 'id' => $layout->getPluginId(),
- 'label' => $layout_definition['label']
- ];
- }
-
- // Explicitly support Page Manger, as we need to have a reference for where
- // to save the display.
- $variant = \Drupal::request()->attributes->get('page_manager_page_variant');
- if ($variant) {
- // Add the display variant's config.
- $settings['display_variant'] = [
- 'label' => $variant->label(),
- 'id' => $variant->id(),
- 'uuid' => $variant->uuid(),
- ];
- }
-
- return ['panels_ipe' => $settings];
- }
-
- /**
- * {@inheritdoc}
- */
- public function build(array $regions, array $contexts, LayoutInterface $layout = NULL) {
- $build = parent::build($regions, $contexts, $layout);
- // Attach the Panels In-place editor library based on permissions.
- if ($this->account->hasPermission('access panels in-place editing')) {
- foreach ($regions as $region => $blocks) {
- // Wrap each region with a unique class and data attribute.
- $region_name = Html::getClass("block-region-$region");
- $build[$region]['#prefix'] = '
';
- $build[$region]['#suffix'] = '
';
-
- if ($blocks) {
- foreach ($blocks as $block_id => $block) {
- $build[$region][$block_id]['#attributes']['data-block-id'] = $block_id;
- }
- }
- }
-
- // Attach the required settings and IPE.
- $build['#attached'] = [
- 'library' => ['panels_ipe/panels_ipe'],
- 'drupalSettings' => $this->getDrupalSettings($regions, $contexts, $layout)
- ];
-
- // Add our custom elements to the build.
- $build['#prefix'] = '
';
- $build['#suffix'] = '
';
- }
- return $build;
- }
-
-}