Commit e2e1f61c authored by webchick's avatar webchick

Issue #2803375 by cilefen, tedbow, saurabh-chugh, Wim Leers: Rename Outside-in...

Issue #2803375 by cilefen, tedbow, saurabh-chugh, Wim Leers: Rename Outside-in module to "Settings Tray" for real
parent 271134ee
......@@ -311,9 +311,6 @@ Node Access
Options
- ?
Outside In
- Ted Bowman 'tedbow' https://www.drupal.org/u/tedbow
Page Cache
- Lorenz Schori 'znerol' https://www.drupal.org/u/znerol
- Fabian Franz 'Fabianx' https://www.drupal.org/u/fabianx
......@@ -360,6 +357,9 @@ Search
Serialization
- Damian Lee 'damiankloip' https://www.drupal.org/u/damiankloip
Settings Tray
- Ted Bowman 'tedbow' https://www.drupal.org/u/tedbow
Seven
- ?
......
......@@ -123,7 +123,6 @@
"drupal/migrate_drupal_ui": "self.version",
"drupal/node": "self.version",
"drupal/options": "self.version",
"drupal/outside_in": "self.version",
"drupal/page_cache": "self.version",
"drupal/path": "self.version",
"drupal/quickedit": "self.version",
......@@ -132,6 +131,7 @@
"drupal/rest": "self.version",
"drupal/search": "self.version",
"drupal/serialization": "self.version",
"drupal/settings_tray": "self.version",
"drupal/seven": "self.version",
"drupal/shortcut": "self.version",
"drupal/simpletest": "self.version",
......
......@@ -14,10 +14,10 @@
float: right;
}
.dialog-off-canvas__main-canvas.js-outside-in-edit-mode a,
.dialog-off-canvas__main-canvas.js-outside-in-edit-mode input {
.dialog-off-canvas__main-canvas.js-settings-tray-edit-mode a,
.dialog-off-canvas__main-canvas.js-settings-tray-edit-mode input {
pointer-events: none;
}
.dialog-off-canvas__main-canvas.js-outside-in-edit-mode .contextual-links a {
.dialog-off-canvas__main-canvas.js-settings-tray-edit-mode .contextual-links a {
pointer-events: inherit;
}
......@@ -13,7 +13,7 @@
/* Transition the editables on the page, their contextual links and their hover states. */
.dialog-off-canvas__main-canvas .contextual,
.dialog-off-canvas__main-canvas .js-outside-in-edit-mode .outside-in-editable,
.dialog-off-canvas__main-canvas.js-tray-open .js-outside-in-edit-mode .outside-in-editable {
.dialog-off-canvas__main-canvas .js-settings-tray-edit-mode .settings-tray-editable,
.dialog-off-canvas__main-canvas.js-tray-open .js-settings-tray-edit-mode .settings-tray-editable {
transition: all .7s ease;
}
......@@ -8,13 +8,13 @@
*/
/* Style the edit mode toolbar and tabs. */
#toolbar-bar.js-outside-in-edit-mode {
#toolbar-bar.js-settings-tray-edit-mode {
background-image: linear-gradient(to bottom,#0c97ed,#1f86c7);
}
.js-outside-in-edit-mode .toolbar-item:not(.toolbar-icon-edit) {
.js-settings-tray-edit-mode .toolbar-item:not(.toolbar-icon-edit) {
color: #999;
}
.js-outside-in-edit-mode .toolbar-item:not(.toolbar-icon-edit) .is-active {
.js-settings-tray-edit-mode .toolbar-item:not(.toolbar-icon-edit) .is-active {
color: #333;
}
......@@ -60,11 +60,11 @@
}
/* Style the editables while in edit mode. */
.dialog-off-canvas__main-canvas.js-outside-in-edit-mode .outside-in-editable {
.dialog-off-canvas__main-canvas.js-settings-tray-edit-mode .settings-tray-editable {
outline: 1px dashed rgba(0,0,0,0.5);
box-shadow: 0 0 0 1px rgba(255,255,255,0.7);
}
.dialog-off-canvas__main-canvas.js-outside-in-edit-mode .outside-in-editable:hover,
.dialog-off-canvas__main-canvas.js-outside-in-edit-mode .outside-in-editable.outside-in-active-editable {
.dialog-off-canvas__main-canvas.js-settings-tray-edit-mode .settings-tray-editable:hover,
.dialog-off-canvas__main-canvas.js-settings-tray-edit-mode .settings-tray-editable.settings-tray-active-editable {
background-color: rgba(0,0,0,0.2);
}
......@@ -8,13 +8,13 @@
*/
/* Style the edit mode toolbar and tabs. */
#toolbar-bar.js-outside-in-edit-mode {
#toolbar-bar.js-settings-tray-edit-mode {
background-color: #fff;
}
#toolbar-bar.js-outside-in-edit-mode .toolbar-item {
#toolbar-bar.js-settings-tray-edit-mode .toolbar-item {
color: #999;
}
#toolbar-bar.js-outside-in-edit-mode .toolbar-item .is-active {
#toolbar-bar.js-settings-tray-edit-mode .toolbar-item .is-active {
color: #333;
}
......@@ -58,10 +58,10 @@ button.toolbar-icon.toolbar-icon-edit.toolbar-item:before:focus {
background-image: url(../../../misc/icons/ffffff/pencil.svg);
}
#toolbar-bar.js-outside-in-edit-mode button.toolbar-icon.toolbar-icon-edit.toolbar-item.is-active {
#toolbar-bar.js-settings-tray-edit-mode button.toolbar-icon.toolbar-icon-edit.toolbar-item.is-active {
background-image: none;
color: #fff;
}
#toolbar-bar.js-outside-in-edit-mode button.toolbar-icon.toolbar-icon-edit.toolbar-item.is-active:hover {
#toolbar-bar.js-settings-tray-edit-mode button.toolbar-icon.toolbar-icon-edit.toolbar-item.is-active:hover {
background-image: linear-gradient(to bottom, #0094f0, #0e69be);
}
......@@ -22,7 +22,7 @@
/**
* The minimum width to use body displace needs to match the width at which
* the tray will be %100 width. @see outside_in.module.css
* the tray will be %100 width. @see settings_tray.module.css
* @type {Number}
*/
minDisplaceWidth: 768,
......
......@@ -6,9 +6,9 @@
*/
(function ($, Drupal) {
const blockConfigureSelector = '[data-outside-in-edit]';
const toggleEditSelector = '[data-drupal-outsidein="toggle"]';
const itemsToToggleSelector = '[data-off-canvas-main-canvas], #toolbar-bar, [data-drupal-outsidein="editable"] a, [data-drupal-outsidein="editable"] button';
const blockConfigureSelector = '[data-settings-tray-edit]';
const toggleEditSelector = '[data-drupal-settingstray="toggle"]';
const itemsToToggleSelector = '[data-off-canvas-main-canvas], #toolbar-bar, [data-drupal-settingstray="editable"] a, [data-drupal-settingstray="editable"] button';
const contextualItemsSelector = '[data-contextual-id] a, [data-contextual-id] button';
const quickEditItemSelector = '[data-quickedit-entity-id]';
......@@ -67,7 +67,7 @@
*/
function setEditModeState(editMode) {
if (!document.querySelector('[data-off-canvas-main-canvas]')) {
throw new Error('data-off-canvas-main-canvas is missing from outside-in-page-wrapper.html.twig');
throw new Error('data-off-canvas-main-canvas is missing from settings-tray-page-wrapper.html.twig');
}
editMode = !!editMode;
const $editButton = $(toggleEditSelector);
......@@ -77,16 +77,16 @@
$editButton.text(Drupal.t('Editing'));
closeToolbarTrays();
$editables = $('[data-drupal-outsidein="editable"]').once('outsidein');
$editables = $('[data-drupal-settingstray="editable"]').once('settingstray');
if ($editables.length) {
// Use event capture to prevent clicks on links.
document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true);
// When a click occurs try and find the outside-in edit link
// When a click occurs try and find the settings-tray edit link
// and click it.
$editables
.not(contextualItemsSelector)
.on('click.outsidein', (e) => {
.on('click.settingstray', (e) => {
// Contextual links are allowed to function in Edit mode.
if ($(e.target).closest('.contextual').length || !localStorage.getItem('Drupal.contextualToolbar.isViewing')) {
return;
......@@ -96,7 +96,7 @@
});
$(quickEditItemSelector)
.not(contextualItemsSelector)
.on('click.outsidein', (e) => {
.on('click.settingstray', (e) => {
/**
* For all non-contextual links or the contextual QuickEdit link
* close the off-canvas dialog.
......@@ -114,31 +114,31 @@
}
// Disable edit mode.
else {
$editables = $('[data-drupal-outsidein="editable"]').removeOnce('outsidein');
$editables = $('[data-drupal-settingstray="editable"]').removeOnce('settingstray');
if ($editables.length) {
document.querySelector('[data-off-canvas-main-canvas]').removeEventListener('click', preventClick, true);
$editables.off('.outsidein');
$(quickEditItemSelector).off('.outsidein');
$editables.off('.settingstray');
$(quickEditItemSelector).off('.settingstray');
}
$editButton.text(Drupal.t('Edit'));
closeOffCanvas();
disableQuickEdit();
}
getItemsToToggle().toggleClass('js-outside-in-edit-mode', editMode);
getItemsToToggle().toggleClass('js-settings-tray-edit-mode', editMode);
$('.edit-mode-inactive').toggleClass('visually-hidden', editMode);
}
/**
* Helper to check the state of the outside-in mode.
* Helper to check the state of the settings-tray mode.
*
* @todo don't use a class for this.
*
* @return {boolean}
* State of the outside-in edit mode.
* State of the settings-tray edit mode.
*/
function isInEditMode() {
return $('#toolbar-bar').hasClass('js-outside-in-edit-mode');
return $('#toolbar-bar').hasClass('js-settings-tray-edit-mode');
}
/**
......@@ -161,7 +161,7 @@
$(document).on('drupalContextualLinkAdded', (event, data) => {
// When the first contextual link is added to the page set Edit Mode.
$('body').once('outside_in.edit_mode_init').each(() => {
$('body').once('settings_tray.edit_mode_init').each(() => {
const editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false';
if (editMode) {
setEditModeState(true);
......@@ -180,9 +180,9 @@
* mode also.
*/
data.$el.find(blockConfigureSelector)
.on('click.outsidein', () => {
.on('click.settingstray', () => {
if (!isInEditMode()) {
$(toggleEditSelector).trigger('click').trigger('click.outside_in');
$(toggleEditSelector).trigger('click').trigger('click.settings_tray');
}
/**
* Always disable QuickEdit regardless of whether "EditMode" was just
......@@ -192,7 +192,7 @@
});
});
$(document).on('keyup.outsidein', (e) => {
$(document).on('keyup.settingstray', (e) => {
if (isInEditMode() && e.keyCode === 27) {
Drupal.announce(
Drupal.t('Exited edit mode.'),
......@@ -202,16 +202,16 @@
});
/**
* Toggle the js-outside-edit-mode class on items that we want to disable while in edit mode.
* Toggle the js-settings-tray-edit-mode class on items that we want to disable while in edit mode.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Toggle the js-outside-edit-mode class.
* Toggle the js-settings-tray-edit-mode class.
*/
Drupal.behaviors.toggleEditMode = {
attach() {
$(toggleEditSelector).once('outsidein').on('click.outsidein', toggleEditMode);
$(toggleEditSelector).once('settingstray').on('click.settingstray', toggleEditMode);
// Find all Ajax instances that use the 'off_canvas' renderer.
Drupal.ajax.instances
// If there is an element and the renderer is 'off_canvas' then we want
......@@ -224,7 +224,7 @@
if (!('dialogOptions' in instance.options.data)) {
instance.options.data.dialogOptions = {};
}
instance.options.data.dialogOptions.outsideInActiveEditableId = $(instance.element).parents('.outside-in-editable').attr('id');
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
instance.progress = { type: 'fullscreen' };
});
},
......@@ -234,16 +234,16 @@
$(window).on({
'dialog:beforecreate': (event, dialog, $element, settings) => {
if ($element.is('#drupal-off-canvas')) {
$('body .outside-in-active-editable').removeClass('outside-in-active-editable');
const $activeElement = $(`#${settings.outsideInActiveEditableId}`);
$('body .settings-tray-active-editable').removeClass('settings-tray-active-editable');
const $activeElement = $(`#${settings.settingsTrayActiveEditableId}`);
if ($activeElement.length) {
$activeElement.addClass('outside-in-active-editable');
$activeElement.addClass('settings-tray-active-editable');
}
}
},
'dialog:beforeclose': (event, dialog, $element) => {
if ($element.is('#drupal-off-canvas')) {
$('body .outside-in-active-editable').removeClass('outside-in-active-editable');
$('body .settings-tray-active-editable').removeClass('settings-tray-active-editable');
}
},
});
......
......@@ -6,9 +6,9 @@
**/
(function ($, Drupal) {
var blockConfigureSelector = '[data-outside-in-edit]';
var toggleEditSelector = '[data-drupal-outsidein="toggle"]';
var itemsToToggleSelector = '[data-off-canvas-main-canvas], #toolbar-bar, [data-drupal-outsidein="editable"] a, [data-drupal-outsidein="editable"] button';
var blockConfigureSelector = '[data-settings-tray-edit]';
var toggleEditSelector = '[data-drupal-settingstray="toggle"]';
var itemsToToggleSelector = '[data-off-canvas-main-canvas], #toolbar-bar, [data-drupal-settingstray="editable"] a, [data-drupal-settingstray="editable"] button';
var contextualItemsSelector = '[data-contextual-id] a, [data-contextual-id] button';
var quickEditItemSelector = '[data-quickedit-entity-id]';
......@@ -37,7 +37,7 @@
function setEditModeState(editMode) {
if (!document.querySelector('[data-off-canvas-main-canvas]')) {
throw new Error('data-off-canvas-main-canvas is missing from outside-in-page-wrapper.html.twig');
throw new Error('data-off-canvas-main-canvas is missing from settings-tray-page-wrapper.html.twig');
}
editMode = !!editMode;
var $editButton = $(toggleEditSelector);
......@@ -47,18 +47,18 @@
$editButton.text(Drupal.t('Editing'));
closeToolbarTrays();
$editables = $('[data-drupal-outsidein="editable"]').once('outsidein');
$editables = $('[data-drupal-settingstray="editable"]').once('settingstray');
if ($editables.length) {
document.querySelector('[data-off-canvas-main-canvas]').addEventListener('click', preventClick, true);
$editables.not(contextualItemsSelector).on('click.outsidein', function (e) {
$editables.not(contextualItemsSelector).on('click.settingstray', function (e) {
if ($(e.target).closest('.contextual').length || !localStorage.getItem('Drupal.contextualToolbar.isViewing')) {
return;
}
$(e.currentTarget).find(blockConfigureSelector).trigger('click');
disableQuickEdit();
});
$(quickEditItemSelector).not(contextualItemsSelector).on('click.outsidein', function (e) {
$(quickEditItemSelector).not(contextualItemsSelector).on('click.settingstray', function (e) {
if (!$(e.target).parent().hasClass('contextual') || $(e.target).parent().hasClass('quickedit')) {
closeOffCanvas();
}
......@@ -70,23 +70,23 @@
});
}
} else {
$editables = $('[data-drupal-outsidein="editable"]').removeOnce('outsidein');
$editables = $('[data-drupal-settingstray="editable"]').removeOnce('settingstray');
if ($editables.length) {
document.querySelector('[data-off-canvas-main-canvas]').removeEventListener('click', preventClick, true);
$editables.off('.outsidein');
$(quickEditItemSelector).off('.outsidein');
$editables.off('.settingstray');
$(quickEditItemSelector).off('.settingstray');
}
$editButton.text(Drupal.t('Edit'));
closeOffCanvas();
disableQuickEdit();
}
getItemsToToggle().toggleClass('js-outside-in-edit-mode', editMode);
getItemsToToggle().toggleClass('js-settings-tray-edit-mode', editMode);
$('.edit-mode-inactive').toggleClass('visually-hidden', editMode);
}
function isInEditMode() {
return $('#toolbar-bar').hasClass('js-outside-in-edit-mode');
return $('#toolbar-bar').hasClass('js-settings-tray-edit-mode');
}
function toggleEditMode() {
......@@ -94,7 +94,7 @@
}
$(document).on('drupalContextualLinkAdded', function (event, data) {
$('body').once('outside_in.edit_mode_init').each(function () {
$('body').once('settings_tray.edit_mode_init').each(function () {
var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false';
if (editMode) {
setEditModeState(true);
......@@ -103,16 +103,16 @@
Drupal.attachBehaviors(data.$el[0]);
data.$el.find(blockConfigureSelector).on('click.outsidein', function () {
data.$el.find(blockConfigureSelector).on('click.settingstray', function () {
if (!isInEditMode()) {
$(toggleEditSelector).trigger('click').trigger('click.outside_in');
$(toggleEditSelector).trigger('click').trigger('click.settings_tray');
}
disableQuickEdit();
});
});
$(document).on('keyup.outsidein', function (e) {
$(document).on('keyup.settingstray', function (e) {
if (isInEditMode() && e.keyCode === 27) {
Drupal.announce(Drupal.t('Exited edit mode.'));
toggleEditMode();
......@@ -121,7 +121,7 @@
Drupal.behaviors.toggleEditMode = {
attach: function attach() {
$(toggleEditSelector).once('outsidein').on('click.outsidein', toggleEditMode);
$(toggleEditSelector).once('settingstray').on('click.settingstray', toggleEditMode);
Drupal.ajax.instances.filter(function (instance) {
return instance && $(instance.element).attr('data-dialog-renderer') === 'off_canvas';
......@@ -129,7 +129,7 @@
if (!('dialogOptions' in instance.options.data)) {
instance.options.data.dialogOptions = {};
}
instance.options.data.dialogOptions.outsideInActiveEditableId = $(instance.element).parents('.outside-in-editable').attr('id');
instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(instance.element).parents('.settings-tray-editable').attr('id');
instance.progress = { type: 'fullscreen' };
});
}
......@@ -138,16 +138,16 @@
$(window).on({
'dialog:beforecreate': function dialogBeforecreate(event, dialog, $element, settings) {
if ($element.is('#drupal-off-canvas')) {
$('body .outside-in-active-editable').removeClass('outside-in-active-editable');
var $activeElement = $('#' + settings.outsideInActiveEditableId);
$('body .settings-tray-active-editable').removeClass('settings-tray-active-editable');
var $activeElement = $('#' + settings.settingsTrayActiveEditableId);
if ($activeElement.length) {
$activeElement.addClass('outside-in-active-editable');
$activeElement.addClass('settings-tray-active-editable');
}
}
},
'dialog:beforeclose': function dialogBeforeclose(event, dialog, $element) {
if ($element.is('#drupal-off-canvas')) {
$('body .outside-in-active-editable').removeClass('outside-in-active-editable');
$('body .settings-tray-active-editable').removeClass('settings-tray-active-editable');
}
}
});
......
......@@ -6,7 +6,7 @@
*/
/**
* @defgroup outside_in Settings Tray API
* @defgroup settings_tray Settings Tray API
* @{
* Settings Tray API
*
......@@ -17,8 +17,8 @@
* - limits the form items displayed in the Settings Tray to only items that
* affect the content of the rendered block
* - adds additional form items to edit configuration that is rendered by the
* block. See \Drupal\outside_in\Form\SystemBrandingOffCanvasForm which adds
* site name and slogan configuration.
* block. See \Drupal\settings_tray\Form\SystemBrandingOffCanvasForm which
* adds site name and slogan configuration.
*
* These can be used to provide a better experience, so that the Settings Tray
* only displays what the user will expect to change when editing the block.
......@@ -54,8 +54,8 @@
* Therefore, the entire Settings Tray API is just this annotation: it controls
* what the Settings Tray does for a given block.
*
* @see outside_in_block_alter()
* @see \Drupal\Tests\outside_in\Functional\OutsideInBlockTest::testPossibleAnnotations()
* @see settings_tray_block_alter()
* @see \Drupal\Tests\settings_tray\Functional\SettingsTrayBlockTest::testPossibleAnnotations()
*
* @}
*/
......@@ -10,7 +10,7 @@
/**
* Implements hook_install().
*/
function outside_in_install() {
function settings_tray_install() {
// This module affects the rendering of blocks and of the page.
// @todo Remove in https://www.drupal.org/node/2783791.
Cache::invalidateTags(['rendered']);
......
drupal.outside_in:
drupal.settings_tray:
version: VERSION
js:
js/outside_in.js: {}
js/settings_tray.js: {}
css:
component:
css/outside_in.module.css: {}
css/outside_in.motion.css: {}
css/outside_in.toolbar.css: {}
css/settings_tray.module.css: {}
css/settings_tray.motion.css: {}
css/settings_tray.toolbar.css: {}
theme:
# @todo Set the group higher than CSS_AGGREGATE_THEME so that it overrides
# both jQuery UI and Classy's dialog.css, remove in
# https://www.drupal.org/node/1945262.
css/outside_in.theme.css: { group: 200 }
css/settings_tray.theme.css: { group: 200 }
dependencies:
- core/jquery
- core/drupal
......
outside_in.block_configure:
settings_tray.block_configure:
title: 'Quick edit'
route_name: 'entity.block.off_canvas_form'
group: 'block'
......@@ -7,4 +7,4 @@ outside_in.block_configure:
class: ['use-ajax']
data-dialog-type: dialog
data-dialog-renderer: off_canvas
data-outside-in-edit: true
data-settings-tray-edit: true
......@@ -7,18 +7,18 @@
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\outside_in\Block\BlockEntityOffCanvasForm;
use Drupal\outside_in\Form\SystemBrandingOffCanvasForm;
use Drupal\outside_in\Form\SystemMenuOffCanvasForm;
use Drupal\settings_tray\Block\BlockEntityOffCanvasForm;
use Drupal\settings_tray\Form\SystemBrandingOffCanvasForm;
use Drupal\settings_tray\Form\SystemMenuOffCanvasForm;
/**
* Implements hook_help().
*/
function outside_in_help($route_name, RouteMatchInterface $route_match) {
function settings_tray_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.outside_in':
case 'help.page.settings_tray':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . 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 <a href=":outside-in-documentation">online documentation for the Settings Tray module</a>.', [':outside-in-documentation' => 'https://www.drupal.org/documentation/modules/outside_in']) . '</p>';
$output .= '<p>' . 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 <a href=":settings-tray-documentation">online documentation for the Settings Tray module</a>.', [':settings-tray-documentation' => 'https://www.drupal.org/documentation/modules/settings_tray']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Editing blocks on the same page in the slide-out tray') . '</dt>';
......@@ -32,30 +32,30 @@ function outside_in_help($route_name, RouteMatchInterface $route_match) {
*
* 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'];
function settings_tray_contextual_links_view_alter(&$element, $items) {
if (isset($element['#links']['settings-trayblock-configure'])) {
// Place settings_tray link first.
$settings_tray_link = $element['#links']['settings-trayblock-configure'];
unset($element['#links']['settings-trayblock-configure']);
$element['#links'] = ['settings-trayblock-configure' => $settings_tray_link] + $element['#links'];
// 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['#links']['settings-trayblock-configure']['title'] = t('Quick edit settings');
}
$element['#attached']['library'][] = 'outside_in/drupal.off_canvas';
$element['#attached']['library'][] = 'settings_tray/drupal.off_canvas';
}
}
/**
* Implements hook_block_view_alter().
*/
function outside_in_block_view_alter(array &$build) {
function settings_tray_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'] = [
$build['#contextual_links']['settings_tray'] = [
'route_parameters' => [],
];
}
......@@ -63,18 +63,18 @@ function outside_in_block_view_alter(array &$build) {
/**
* Implements hook_element_info_alter().
*/
function outside_in_element_info_alter(&$type) {
function settings_tray_element_info_alter(&$type) {
if (isset($type['page'])) {
$type['page']['#theme_wrappers']['outside_in_page_wrapper'] = ['#weight' => -1000];
$type['page']['#theme_wrappers']['settings_tray_page_wrapper'] = ['#weight' => -1000];
}
}
/**
* Implements hook_theme().
*/
function outside_in_theme() {
function settings_tray_theme() {
return [
'outside_in_page_wrapper' => [
'settings_tray_page_wrapper' => [
'variables' => ['children' => NULL],
],
];
......@@ -83,7 +83,7 @@ function outside_in_theme() {
/**
* Implements hook_entity_type_build().
*/
function outside_in_entity_type_build(array &$entity_types) {
function settings_tray_entity_type_build(array &$entity_types) {
/* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['block']
->setFormClass('off_canvas', BlockEntityOffCanvasForm::class)
......@@ -93,24 +93,24 @@ function outside_in_entity_type_build(array &$entity_types) {
/**
* Implements hook_preprocess_HOOK() for block templates.
*/
function outside_in_preprocess_block(&$variables) {
function settings_tray_preprocess_block(&$variables) {
// Only blocks that have an settings_tray form will have a "Quick Edit" link.
// We could wait for the contextual links to be initialized on the client
// side, and then add the class and data- attribute below there (via
// JavaScript). But that would mean that it would be impossible to show
// Settings Tray's clickable regions immediately when the page loads. When
// latency is high, this will cause flicker.
// @see \Drupal\outside_in\Access\BlockPluginHasSettingsTrayFormAccessCheck
/** @var \Drupal\outside_in\Access\BlockPluginHasSettingsTrayFormAccessCheck $access_checker */
$access_checker = \Drupal::service('access_check.outside_in.block.settings_tray_form');
// @see \Drupal\settings_tray\Access\BlockPluginHasSettingsTrayFormAccessCheck
/** @var \Drupal\settings_tray\Access\BlockPluginHasSettingsTrayFormAccessCheck $access_checker */
$access_checker = \Drupal::service('access_check.settings_tray.block.settings_tray_form');
/** @var \Drupal\Core\Block\BlockManagerInterface $block_plugin_manager */
$block_plugin_manager = \Drupal::service('plugin.manager.block');
/** @var \Drupal\Core\Block\BlockPluginInterface $block_plugin */
$block_plugin = $block_plugin_manager->createInstance($variables['plugin_id']);
if ($access_checker->accessBlockPlugin($block_plugin)->isAllowed()) {
// Add class and attributes to all blocks to allow Javascript to target.
$variables['attributes']['class'][] = 'outside-in-editable';
$variables['attributes']['data-drupal-outsidein'] = 'editable';
$variables['attributes']['class'][] = 'settings-tray-editable';
$variables['attributes']['data-drupal-settingstray'] = 'editable';
}
}
......@@ -125,12 +125,12 @@ function outside_in_preprocess_block(&$variables) {
*
* @see contextual_toolbar()
*/
function outside_in_toolbar_alter(&$items) {
function settings_tray_toolbar_alter(&$items) {
$items['contextual']['#cache']['contexts'][] = 'user.permissions';
if (isset($items['contextual']['tab']) && \Drupal::currentUser()->hasPermission('administer blocks')) {
$items['contextual']['#weight'] = -1000;
$items['contextual']['#attached']['library'][] = 'outside_in/drupal.outside_in';
$items['contextual']['tab']['#attributes']['data-drupal-outsidein'] = 'toggle';
$items['contextual']['#attached']['library'][] = 'settings_tray/drupal.settings_tray';
$items['contextual']['tab']['#attributes']['data-drupal-settingstray'] = '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.
......@@ -149,9 +149,9 @@ function outside_in_toolbar_alter(&$items) {