Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -100,48 +100,61 @@
|
|||
}
|
||||
}
|
||||
|
||||
$(window).on({
|
||||
'dialog:aftercreate': function (event, dialog, $element, settings) {
|
||||
if ($element.is('#drupal-offcanvas')) {
|
||||
var eventData = {settings: settings, $element: $element};
|
||||
$('.ui-dialog-offcanvas, .ui-dialog-offcanvas .ui-dialog-titlebar').toggleClass('ui-dialog-empty-title', !settings.title);
|
||||
/**
|
||||
* Attaches off-canvas dialog behaviors.
|
||||
*
|
||||
* @type {Drupal~behavior}
|
||||
*
|
||||
* @prop {Drupal~behaviorAttach} attach
|
||||
* Attaches event listeners for off-canvas dialogs.
|
||||
*/
|
||||
Drupal.behaviors.offCanvasEvents = {
|
||||
attach: function () {
|
||||
$(window).once('off-canvas').on({
|
||||
'dialog:aftercreate': function (event, dialog, $element, settings) {
|
||||
if ($element.is('#drupal-offcanvas')) {
|
||||
var eventData = {settings: settings, $element: $element};
|
||||
$('.ui-dialog-offcanvas, .ui-dialog-offcanvas .ui-dialog-titlebar').toggleClass('ui-dialog-empty-title', !settings.title);
|
||||
|
||||
$element
|
||||
.on('dialogresize.offcanvas', eventData, debounce(bodyPadding, 100))
|
||||
.on('dialogContentResize.offcanvas', eventData, handleDialogResize)
|
||||
.on('dialogContentResize.offcanvas', eventData, debounce(bodyPadding, 100))
|
||||
.trigger('dialogresize.offcanvas');
|
||||
$element
|
||||
.on('dialogresize.offcanvas', eventData, debounce(bodyPadding, 100))
|
||||
.on('dialogContentResize.offcanvas', eventData, handleDialogResize)
|
||||
.on('dialogContentResize.offcanvas', eventData, debounce(bodyPadding, 100))
|
||||
.trigger('dialogresize.offcanvas');
|
||||
|
||||
$element.dialog('widget').attr('data-offset-' + edge, '');
|
||||
$element.dialog('widget').attr('data-offset-' + edge, '');
|
||||
|
||||
$(window)
|
||||
.on('resize.offcanvas scroll.offcanvas', eventData, debounce(resetSize, 100))
|
||||
.trigger('resize.offcanvas');
|
||||
}
|
||||
},
|
||||
'dialog:beforecreate': function (event, dialog, $element, settings) {
|
||||
if ($element.is('#drupal-offcanvas')) {
|
||||
$('body').addClass('js-tray-open');
|
||||
// @see http://api.jqueryui.com/position/
|
||||
settings.position = {
|
||||
my: 'left top',
|
||||
at: edge + ' top',
|
||||
of: window
|
||||
};
|
||||
settings.dialogClass += ' ui-dialog-offcanvas';
|
||||
// Applies initial height to dialog based on window height.
|
||||
// See http://api.jqueryui.com/dialog for all dialog options.
|
||||
settings.height = $(window).height();
|
||||
}
|
||||
},
|
||||
'dialog:beforeclose': function (event, dialog, $element) {
|
||||
if ($element.is('#drupal-offcanvas')) {
|
||||
$('body').removeClass('js-tray-open');
|
||||
$(document).off('.offcanvas');
|
||||
$(window).off('.offcanvas');
|
||||
$mainCanvasWrapper.css('padding-' + edge, 0);
|
||||
}
|
||||
$(window)
|
||||
.on('resize.offcanvas scroll.offcanvas', eventData, debounce(resetSize, 100))
|
||||
.trigger('resize.offcanvas');
|
||||
}
|
||||
},
|
||||
'dialog:beforecreate': function (event, dialog, $element, settings) {
|
||||
if ($element.is('#drupal-offcanvas')) {
|
||||
$('body').addClass('js-tray-open');
|
||||
// @see http://api.jqueryui.com/position/
|
||||
settings.position = {
|
||||
my: 'left top',
|
||||
at: edge + ' top',
|
||||
of: window
|
||||
};
|
||||
settings.dialogClass += ' ui-dialog-offcanvas';
|
||||
// Applies initial height to dialog based on window height.
|
||||
// See http://api.jqueryui.com/dialog for all dialog options.
|
||||
settings.height = $(window).height();
|
||||
}
|
||||
},
|
||||
'dialog:beforeclose': function (event, dialog, $element) {
|
||||
if ($element.is('#drupal-offcanvas')) {
|
||||
$('body').removeClass('js-tray-open');
|
||||
// Remove all *.offcanvas events
|
||||
$(document).off('.offcanvas');
|
||||
$(window).off('.offcanvas');
|
||||
$mainCanvasWrapper.css('padding-' + edge, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, Drupal.debounce, Drupal.displace);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
data.$el.find(blockConfigureSelector)
|
||||
.on('click.outsidein', function () {
|
||||
if (!isInEditMode()) {
|
||||
$(toggleEditSelector).trigger('click.outsidein');
|
||||
$(toggleEditSelector).trigger('click').trigger('click.outside_in');
|
||||
}
|
||||
// Always disable QuickEdit regardless of whether "EditMode" was just enabled.
|
||||
disableQuickEdit();
|
||||
|
|
|
@ -81,7 +81,7 @@ class SystemMenuOffCanvasForm extends PluginFormBase implements ContainerInjecti
|
|||
|
||||
$form['entity_form'] = [
|
||||
'#type' => 'details',
|
||||
'#title' => $this->t('Edit menu %label', array('%label' => $this->entity->label())),
|
||||
'#title' => $this->t('Edit menu %label', ['%label' => $this->entity->label()]),
|
||||
'#open' => TRUE,
|
||||
];
|
||||
$form['entity_form'] += $this->getEntityForm($this->entity)->buildForm([], $form_state);
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\offcanvas_test\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Provides an 'Off-canvas test block' block.
|
||||
*
|
||||
* @Block(
|
||||
* id = "offcanvas_links_block",
|
||||
* admin_label = @Translation("Off-canvas test block")
|
||||
* )
|
||||
*/
|
||||
class TestBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
return [
|
||||
'offcanvas_link_1' => [
|
||||
'#title' => $this->t('Click Me 1!'),
|
||||
'#type' => 'link',
|
||||
'#url' => Url::fromRoute('offcanvas_test.thing1'),
|
||||
'#attributes' => [
|
||||
'class' => ['use-ajax'],
|
||||
'data-dialog-type' => 'offcanvas',
|
||||
],
|
||||
],
|
||||
'offcanvas_link_2' => [
|
||||
'#title' => $this->t('Click Me 2!'),
|
||||
'#type' => 'link',
|
||||
'#url' => Url::fromRoute('offcanvas_test.thing2'),
|
||||
'#attributes' => [
|
||||
'class' => ['use-ajax'],
|
||||
'data-dialog-type' => 'offcanvas',
|
||||
],
|
||||
],
|
||||
'#attached' => [
|
||||
'library' => [
|
||||
'outside_in/drupal.off_canvas',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -11,6 +11,8 @@ use Drupal\user\Entity\Role;
|
|||
*/
|
||||
class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
||||
|
||||
const TOOLBAR_EDIT_LINK_SELECTOR = '#toolbar-bar div.contextual-toolbar-tab button';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -71,9 +73,9 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
$this->waitForNoElement("#toolbar-administration a.is-active");
|
||||
}
|
||||
$page->find('css', $toolbar_item)->click();
|
||||
$this->waitForElement("{$toolbar_item}.is-active");
|
||||
$web_assert->waitForElementVisible('css', "{$toolbar_item}.is-active");
|
||||
}
|
||||
$this->toggleEditingMode();
|
||||
$this->enableEditMode();
|
||||
if (isset($toolbar_item)) {
|
||||
$this->waitForNoElement("{$toolbar_item}.is-active");
|
||||
}
|
||||
|
@ -104,12 +106,11 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
|
||||
$this->openBlockForm($block_selector);
|
||||
|
||||
$this->toggleEditingMode();
|
||||
$this->disableEditMode();
|
||||
// Canvas should close when editing module is closed.
|
||||
$this->waitForOffCanvasToClose();
|
||||
|
||||
// Go into Edit mode again.
|
||||
$this->toggleEditingMode();
|
||||
$this->enableEditMode();
|
||||
|
||||
$element_selector = "$block_selector {$element_selector}";
|
||||
// Open block form by clicking a element inside the block.
|
||||
|
@ -124,6 +125,7 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
$this->getSession()->executeScript('jQuery("body").trigger(jQuery.Event("keyup", { keyCode: 27 }));');
|
||||
$this->waitForOffCanvasToClose();
|
||||
$this->getSession()->wait(100);
|
||||
$this->assertEditModeDisabled();
|
||||
$web_assert->elementTextContains('css', '#drupal-live-announce', 'Exited edit mode.');
|
||||
$web_assert->elementTextNotContains('css', '.contextual-toolbar-tab button', 'Editing');
|
||||
$web_assert->elementAttributeNotContains('css', '.dialog-offcanvas__main-canvas', 'class', 'js-outside-in-edit-mode');
|
||||
|
@ -163,18 +165,19 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Enables Editing mode by pressing "Edit" button in the toolbar.
|
||||
* Enables edit mode by pressing edit button in the toolbar.
|
||||
*/
|
||||
protected function toggleEditingMode() {
|
||||
$this->waitForElement('div[data-contextual-id="block:block=powered:langcode=en|outside_in::langcode=en"] .contextual-links a', 10000);
|
||||
// Waiting for QuickEdit icon animation.
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
protected function enableEditMode() {
|
||||
$this->pressToolbarEditButton();
|
||||
$this->assertEditModeEnabled();
|
||||
}
|
||||
|
||||
$edit_button = $this->getSession()->getPage()->find('css', '#toolbar-bar div.contextual-toolbar-tab button');
|
||||
|
||||
$edit_button->press();
|
||||
// Waiting for Toolbar animation.
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
/**
|
||||
* Disables edit mode by pressing edit button in the toolbar.
|
||||
*/
|
||||
protected function disableEditMode() {
|
||||
$this->pressToolbarEditButton();
|
||||
$this->assertEditModeDisabled();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -235,29 +238,28 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
$this->drupalGet('node/' . $node->id());
|
||||
// Waiting for Toolbar module.
|
||||
// @todo Remove the hack after https://www.drupal.org/node/2542050.
|
||||
$this->waitForElement('.toolbar-fixed');
|
||||
$web_assert->waitForElementVisible('css', '.toolbar-fixed');
|
||||
// Waiting for Toolbar animation.
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
// The 2nd page load we should already be in edit mode.
|
||||
if ($page_load_times == 1) {
|
||||
$this->toggleEditingMode();
|
||||
$this->enableEditMode();
|
||||
}
|
||||
// In Edit mode clicking field should open QuickEdit toolbar.
|
||||
$page->find('css', $body_selector)->click();
|
||||
$this->waitForElement($quick_edit_selector);
|
||||
// Exit Edit mode.
|
||||
$this->toggleEditingMode();
|
||||
$web_assert->waitForElementVisible('css', $quick_edit_selector);
|
||||
|
||||
$this->disableEditMode();
|
||||
// Exiting Edit mode should close QuickEdit toolbar.
|
||||
$web_assert->elementNotExists('css', $quick_edit_selector);
|
||||
// When not in Edit mode QuickEdit toolbar should not open.
|
||||
$page->find('css', $body_selector)->click();
|
||||
$web_assert->elementNotExists('css', $quick_edit_selector);
|
||||
|
||||
// Enter Edit mode.
|
||||
$this->toggleEditingMode();
|
||||
$this->enableEditMode();
|
||||
$this->openBlockForm($block_selector);
|
||||
$page->find('css', $body_selector)->click();
|
||||
$this->waitForElement($quick_edit_selector);
|
||||
$web_assert->waitForElementVisible('css', $quick_edit_selector);
|
||||
// Offcanvas should be closed when opening QuickEdit toolbar.
|
||||
$this->waitForOffCanvasToClose();
|
||||
|
||||
|
@ -269,10 +271,10 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
// Check using contextual links to invoke QuickEdit and open the tray.
|
||||
$this->drupalGet('node/' . $node->id());
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
$this->toggleEditingMode();
|
||||
$this->disableEditMode();
|
||||
// Open QuickEdit toolbar before going into Edit mode.
|
||||
$this->clickContextualLink('.node', "Quick edit");
|
||||
$this->waitForElement($quick_edit_selector);
|
||||
$web_assert->waitForElementVisible('css', $quick_edit_selector);
|
||||
// Open off-canvas and enter Edit mode via contextual link.
|
||||
$this->clickContextualLink($block_selector, "Quick edit");
|
||||
$this->waitForOffCanvasToOpen();
|
||||
|
@ -281,7 +283,85 @@ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase {
|
|||
// Open QuickEdit toolbar via contextual link while in Edit mode.
|
||||
$this->clickContextualLink('.node', "Quick edit", FALSE);
|
||||
$this->waitForOffCanvasToClose();
|
||||
$this->waitForElement($quick_edit_selector);
|
||||
$web_assert->waitForElementVisible('css', $quick_edit_selector);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests enabling and disabling Edit Mode.
|
||||
*/
|
||||
public function testEditModeEnableDisable() {
|
||||
foreach (['contextual_link', 'toolbar_link'] as $enable_option) {
|
||||
$this->drupalGet('user');
|
||||
$this->assertEditModeDisabled();
|
||||
switch ($enable_option) {
|
||||
// Enable Edit mode.
|
||||
case 'contextual_link':
|
||||
$this->clickContextualLink('#block-powered', "Quick edit");
|
||||
$this->waitForOffCanvasToOpen();
|
||||
$this->assertEditModeEnabled();
|
||||
break;
|
||||
|
||||
case 'toolbar_link':
|
||||
$this->enableEditMode();
|
||||
break;
|
||||
}
|
||||
$this->disableEditMode();
|
||||
|
||||
// Make another page request to ensure Edit mode is still disabled.
|
||||
$this->drupalGet('user');
|
||||
$this->assertEditModeDisabled();
|
||||
// Make sure on this page request it also re-enables and disables
|
||||
// correctly.
|
||||
$this->enableEditMode();
|
||||
$this->disableEditMode();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that edit mode has been properly enabled.
|
||||
*/
|
||||
protected function assertEditModeEnabled() {
|
||||
$web_assert = $this->assertSession();
|
||||
// No contextual triggers should be hidden.
|
||||
$web_assert->elementNotExists('css', '.contextual .trigger.visually-hidden');
|
||||
// The toolbar edit button should read "Editing".
|
||||
$web_assert->elementContains('css', static::TOOLBAR_EDIT_LINK_SELECTOR, 'Editing');
|
||||
// The main canvas element should have the "js-outside-in-edit-mode" class.
|
||||
$web_assert->elementExists('css', '.dialog-offcanvas__main-canvas.js-outside-in-edit-mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that edit mode has been properly disabled.
|
||||
*/
|
||||
protected function assertEditModeDisabled() {
|
||||
$web_assert = $this->assertSession();
|
||||
// Contextual triggers should be hidden.
|
||||
$web_assert->elementExists('css', '.contextual .trigger.visually-hidden');
|
||||
// No contextual triggers should be not hidden.
|
||||
$web_assert->elementNotExists('css', '.contextual .trigger:not(.visually-hidden)');
|
||||
// The toolbar edit button should read "Edit".
|
||||
$web_assert->elementContains('css', static::TOOLBAR_EDIT_LINK_SELECTOR, 'Edit');
|
||||
// The main canvas element should NOT have the "js-outside-in-edit-mode"
|
||||
// class.
|
||||
$web_assert->elementNotExists('css', '.dialog-offcanvas__main-canvas.js-outside-in-edit-mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* Press the toolbar Edit button provided by the contextual module.
|
||||
*/
|
||||
protected function pressToolbarEditButton() {
|
||||
$this->assertSession()
|
||||
->waitForElementVisible('css', 'div[data-contextual-id="block:block=powered:langcode=en|outside_in::langcode=en"] .contextual-links a', 10000);
|
||||
// Waiting for QuickEdit icon animation.
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
|
||||
$edit_button = $this->getSession()
|
||||
->getPage()
|
||||
->find('css', static::TOOLBAR_EDIT_LINK_SELECTOR);
|
||||
|
||||
$edit_button->press();
|
||||
// Waiting for Toolbar animation.
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function drupalGet($path, array $options = array(), array $headers = array()) {
|
||||
protected function drupalGet($path, array $options = [], array $headers = []) {
|
||||
$return = parent::drupalGet($path, $options, $headers);
|
||||
|
||||
// After the page loaded we need to additionally wait until the settings
|
||||
|
@ -42,7 +42,7 @@ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase {
|
|||
protected function waitForOffCanvasToOpen() {
|
||||
$web_assert = $this->assertSession();
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
$this->waitForElement('#drupal-offcanvas');
|
||||
$web_assert->waitForElementVisible('css', '#drupal-offcanvas');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,19 +52,6 @@ abstract class OutsideInJavascriptTestBase extends JavascriptTestBase {
|
|||
$this->waitForNoElement('#drupal-offcanvas');
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for an element to appear on the page.
|
||||
*
|
||||
* @param string $selector
|
||||
* CSS selector.
|
||||
* @param int $timeout
|
||||
* (optional) Timeout in milliseconds, defaults to 10000.
|
||||
*/
|
||||
protected function waitForElement($selector, $timeout = 10000) {
|
||||
$condition = "(jQuery('$selector').length > 0)";
|
||||
$this->assertJsCondition($condition, $timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Off-Canvas tray element.
|
||||
*
|
||||
|
|
Reference in a new issue