Issue #1874640 by xjm, Wim Leers: Rename edit module to quickedit.
parent
a62511ffbd
commit
240392ccbb
|
@ -21,7 +21,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
* "string",
|
||||
* "email"
|
||||
* },
|
||||
* edit = {
|
||||
* quickedit = {
|
||||
* "editor" = "plain_text"
|
||||
* }
|
||||
* )
|
||||
|
|
|
@ -27,7 +27,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
* field_types = {
|
||||
* "comment"
|
||||
* },
|
||||
* edit = {
|
||||
* quickedit = {
|
||||
* "editor" = "disabled"
|
||||
* }
|
||||
* )
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
edit.metadata:
|
||||
path: '/edit/metadata'
|
||||
defaults:
|
||||
_controller: '\Drupal\edit\EditController::metadata'
|
||||
options:
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
|
||||
edit.attachments:
|
||||
path: '/edit/attachments'
|
||||
defaults:
|
||||
_controller: '\Drupal\edit\EditController::attachments'
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
|
||||
edit.field_form:
|
||||
path: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}'
|
||||
defaults:
|
||||
_controller: '\Drupal\edit\EditController::fieldForm'
|
||||
options:
|
||||
_access_mode: 'ALL'
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
_access_edit_entity_field: 'TRUE'
|
||||
|
||||
edit.entity_save:
|
||||
path: '/edit/entity/{entity_type}/{entity}'
|
||||
defaults:
|
||||
_controller: '\Drupal\edit\EditController::entitySave'
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
_access_edit_entity: 'TRUE'
|
|
@ -1,20 +0,0 @@
|
|||
services:
|
||||
plugin.manager.edit.editor:
|
||||
class: Drupal\edit\Plugin\InPlaceEditorManager
|
||||
parent: default_plugin_manager
|
||||
access_check.edit.entity_field:
|
||||
class: Drupal\edit\Access\EditEntityFieldAccessCheck
|
||||
arguments: ['@entity.manager']
|
||||
tags:
|
||||
- { name: access_check, applies_to: _access_edit_entity_field }
|
||||
access_check.edit.entity:
|
||||
class: Drupal\edit\Access\EditEntityAccessCheck
|
||||
arguments: ['@entity.manager']
|
||||
tags:
|
||||
- { name: access_check, applies_to: _access_edit_entity }
|
||||
edit.editor.selector:
|
||||
class: Drupal\edit\EditorSelector
|
||||
arguments: ['@plugin.manager.edit.editor', '@plugin.manager.field.formatter']
|
||||
edit.metadata.generator:
|
||||
class: Drupal\edit\MetadataGenerator
|
||||
arguments: ['@access_check.edit.entity_field', '@edit.editor.selector', '@plugin.manager.edit.editor']
|
|
@ -1,7 +0,0 @@
|
|||
name: 'Edit test'
|
||||
type: module
|
||||
description: 'Support module for the Edit module tests.'
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
||||
hidden: true
|
|
@ -31,12 +31,12 @@ drupal.editor.dialog:
|
|||
- core/drupal.ajax
|
||||
- core/drupalSettings
|
||||
|
||||
edit.inPlaceEditor.formattedText:
|
||||
quickedit.inPlaceEditor.formattedText:
|
||||
version: VERSION
|
||||
js:
|
||||
js/editor.formattedTextEditor.js: { scope: footer, attributes: { defer: true } }
|
||||
dependencies:
|
||||
- edit/edit
|
||||
- quickedit/quickedit
|
||||
- editor/drupal.editor
|
||||
- core/drupal.ajax
|
||||
- core/drupalSettings
|
||||
|
|
|
@ -13,7 +13,7 @@ editor.field_untransformed_text:
|
|||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
_access_edit_entity_field: 'TRUE'
|
||||
_access_quickedit_entity_field: 'TRUE'
|
||||
|
||||
editor.image_dialog:
|
||||
path: '/editor/dialog/image/{filter_format}'
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.editors.editor = Drupal.edit.EditorView.extend({
|
||||
Drupal.quickedit.editors.editor = Drupal.quickedit.EditorView.extend({
|
||||
|
||||
// The text format for this field.
|
||||
textFormat: null,
|
||||
|
@ -32,9 +32,9 @@
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
initialize: function (options) {
|
||||
Drupal.edit.EditorView.prototype.initialize.call(this, options);
|
||||
Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
|
||||
|
||||
var metadata = Drupal.edit.metadata.get(this.fieldModel.get('fieldID'), 'custom');
|
||||
var metadata = Drupal.quickedit.metadata.get(this.fieldModel.get('fieldID'), 'custom');
|
||||
this.textFormat = drupalSettings.editor.formats[metadata.format];
|
||||
this.textFormatHasTransformations = metadata.formatHasTransformations;
|
||||
this.textEditor = Drupal.editors[this.textFormat.editor];
|
||||
|
@ -137,7 +137,7 @@
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
getEditUISettings: function () {
|
||||
getQuickEditUISettings: function () {
|
||||
return { padding: true, unifiedToolbar: true, fullWidthToolbar: true, popup: false };
|
||||
},
|
||||
|
||||
|
@ -164,7 +164,7 @@
|
|||
|
||||
// Create a Drupal.ajax instance to load the form.
|
||||
var textLoaderAjax = new Drupal.ajax(fieldID, this.$el, {
|
||||
url: Drupal.edit.util.buildUrl(fieldID, Drupal.url('editor/!entity_type/!id/!field_name/!langcode/!view_mode')),
|
||||
url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('editor/!entity_type/!id/!field_name/!langcode/!view_mode')),
|
||||
event: 'editor-internal.editor',
|
||||
submit: { nocssjs: true },
|
||||
progress: { type: null } // No progress indicator.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace Drupal\editor\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
use Drupal\edit\Ajax\BaseCommand;
|
||||
use Drupal\quickedit\Ajax\BaseCommand;
|
||||
|
||||
/**
|
||||
* AJAX command to rerender a processed text field without any transformation
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace Drupal\editor\Plugin\InPlaceEditor;
|
|||
|
||||
use Drupal\Component\Plugin\PluginBase;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\edit\Plugin\InPlaceEditorInterface;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorInterface;
|
||||
use Drupal\filter\Plugin\FilterInterface;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ class Editor extends PluginBase implements InPlaceEditorInterface {
|
|||
$attachments = $manager->getAttachments($formats);
|
||||
|
||||
// Also include editor.module's formatted text editor.
|
||||
$attachments['library'][] = 'editor/edit.inPlaceEditor.formattedText';
|
||||
$attachments['library'][] = 'editor/quickedit.inPlaceEditor.formattedText';
|
||||
|
||||
return $attachments;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\editor\Tests\EditIntegrationLoadingTest.
|
||||
* Contains \Drupal\editor\Tests\QuickEditIntegrationLoadingTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\editor\Tests;
|
||||
|
@ -11,16 +11,16 @@ use Drupal\Component\Utility\Json;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests Edit module integration endpoints.
|
||||
* Tests Quick Edit module integration endpoints.
|
||||
*/
|
||||
class EditIntegrationLoadingTest extends WebTestBase {
|
||||
class QuickEditIntegrationLoadingTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('edit', 'filter', 'node', 'editor');
|
||||
public static $modules = array('quickedit', 'filter', 'node', 'editor');
|
||||
|
||||
/**
|
||||
* The basic permissions necessary to view content and use in-place editing.
|
||||
|
@ -32,7 +32,7 @@ class EditIntegrationLoadingTest extends WebTestBase {
|
|||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'In-place text editor loading',
|
||||
'description' => 'Tests Edit module integration endpoints.',
|
||||
'description' => 'Tests Quick Edit module integration endpoints.',
|
||||
'group' => 'Text Editor',
|
||||
);
|
||||
}
|
|
@ -2,25 +2,25 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\editor\Tests\EditIntegrationTest.
|
||||
* Contains \Drupal\editor\Tests\QuickEditIntegrationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\editor\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Json;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\edit\EditorSelector;
|
||||
use Drupal\edit\MetadataGenerator;
|
||||
use Drupal\edit\Plugin\InPlaceEditorManager;
|
||||
use Drupal\edit\Tests\EditTestBase;
|
||||
use Drupal\edit_test\MockEditEntityFieldAccessCheck;
|
||||
use Drupal\quickedit\EditorSelector;
|
||||
use Drupal\quickedit\MetadataGenerator;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorManager;
|
||||
use Drupal\quickedit\Tests\QuickEditTestBase;
|
||||
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
|
||||
use Drupal\editor\EditorController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Tests Edit module integration (Editor module's inline editing support).
|
||||
*/
|
||||
class EditIntegrationTest extends EditTestBase {
|
||||
class QuickEditIntegrationTest extends QuickEditTestBase {
|
||||
|
||||
/**
|
||||
* The manager for editor plug-ins.
|
||||
|
@ -32,21 +32,21 @@ class EditIntegrationTest extends EditTestBase {
|
|||
/**
|
||||
* The metadata generator object to be tested.
|
||||
*
|
||||
* @var \Drupal\edit\MetadataGeneratorInterface.php
|
||||
* @var \Drupal\quickedit\MetadataGeneratorInterface.php
|
||||
*/
|
||||
protected $metadataGenerator;
|
||||
|
||||
/**
|
||||
* The editor selector object to be used by the metadata generator object.
|
||||
*
|
||||
* @var \Drupal\edit\EditorSelectorInterface
|
||||
* @var \Drupal\quickedit\EditorSelectorInterface
|
||||
*/
|
||||
protected $editorSelector;
|
||||
|
||||
/**
|
||||
* The access checker object to be used by the metadata generator object.
|
||||
*
|
||||
* @var \Drupal\edit\Access\EditEntityFieldAccessCheckInterface
|
||||
* @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
|
||||
*/
|
||||
protected $accessChecker;
|
||||
|
||||
|
@ -59,7 +59,7 @@ class EditIntegrationTest extends EditTestBase {
|
|||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'In-place text editors (Edit module integration)',
|
||||
'name' => 'In-place text editors (Quick Edit module integration)',
|
||||
'description' => 'Tests Edit module integration (Editor module\'s inline editing support).',
|
||||
'group' => 'Text Editor',
|
||||
);
|
||||
|
@ -124,8 +124,8 @@ class EditIntegrationTest extends EditTestBase {
|
|||
* format compatibility.
|
||||
*/
|
||||
public function testEditorSelection() {
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->editorSelector = $this->container->get('edit.editor.selector');
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->editorSelector = $this->container->get('quickedit.editor.selector');
|
||||
|
||||
// Create an entity with values for this text field.
|
||||
$this->entity = entity_create('entity_test');
|
||||
|
@ -151,9 +151,9 @@ class EditIntegrationTest extends EditTestBase {
|
|||
* Tests (custom) metadata when the formatted text editor is used.
|
||||
*/
|
||||
public function testMetadata() {
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->accessChecker = new MockEditEntityFieldAccessCheck();
|
||||
$this->editorSelector = $this->container->get('edit.editor.selector');
|
||||
$this->editorSelector = $this->container->get('quickedit.editor.selector');
|
||||
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
|
||||
|
||||
// Create an entity with values for the field.
|
|
@ -1,24 +1,24 @@
|
|||
/**
|
||||
* @file
|
||||
* Icons for edit module.
|
||||
* Icons for Quick Edit module.
|
||||
*/
|
||||
|
||||
.edit .icon {
|
||||
.quickedit .icon {
|
||||
min-height: 1em;
|
||||
min-width: 2.5em;
|
||||
position: relative;
|
||||
}
|
||||
.edit .icon.icon-only {
|
||||
.quickedit .icon.icon-only {
|
||||
text-indent: -9999px;
|
||||
}
|
||||
.edit .icon.icon-end {
|
||||
.quickedit .icon.icon-end {
|
||||
padding-right: 2.5em; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .edit .icon.icon-end {
|
||||
[dir="rtl"] .quickedit .icon.icon-end {
|
||||
padding-left: 2.5em;
|
||||
padding-right: 0;
|
||||
}
|
||||
.edit .icon:before {
|
||||
.quickedit .icon:before {
|
||||
background-attachment: scroll;
|
||||
background-color: transparent;
|
||||
background-position: center center;
|
||||
|
@ -31,23 +31,23 @@
|
|||
top: 0;
|
||||
width: 100%;
|
||||
}
|
||||
[dir="rtl"] .edit .icon:before {
|
||||
[dir="rtl"] .quickedit .icon:before {
|
||||
left: auto;
|
||||
right: 0;
|
||||
}
|
||||
.edit .icon-end:before {
|
||||
.quickedit .icon-end:before {
|
||||
left: auto; /* LTR */
|
||||
right: 0.5em; /* LTR */
|
||||
width: 18px;
|
||||
}
|
||||
[dir="rtl"] .edit .icon-end:before {
|
||||
[dir="rtl"] .quickedit .icon-end:before {
|
||||
left: 0.5em;
|
||||
right: auto;
|
||||
}
|
||||
.edit button.icon {
|
||||
.quickedit button.icon {
|
||||
font-size: 1em;
|
||||
}
|
||||
.edit .icon-pencil {
|
||||
.quickedit .icon-pencil {
|
||||
margin-left: .5em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
@ -55,19 +55,19 @@
|
|||
/**
|
||||
* Images.
|
||||
*/
|
||||
.edit .icon-close:before {
|
||||
.quickedit .icon-close:before {
|
||||
background-image: url('../../../misc/icons/787878/ex.svg');
|
||||
height: 12px;
|
||||
top: 10px;
|
||||
}
|
||||
.edit .icon-close:hover:before,
|
||||
.edit .icon-close:active:before {
|
||||
.quickedit .icon-close:hover:before,
|
||||
.quickedit .icon-close:active:before {
|
||||
background-image: url('../../../misc/icons/000000/ex.svg');
|
||||
}
|
||||
.edit .icon-throbber:before {
|
||||
.quickedit .icon-throbber:before {
|
||||
background-image: url("../images/icon-throbber.gif");
|
||||
}
|
||||
.edit .icon-pencil:before {
|
||||
.quickedit .icon-pencil:before {
|
||||
background-image: url('../../../misc/icons/5181c6/pencil.svg');
|
||||
background-position: left center;
|
||||
background-size: 1.3em;
|
|
@ -1,34 +1,35 @@
|
|||
/**
|
||||
* @file
|
||||
* Generic base styles for edit module.
|
||||
* Generic base styles for Quick Edit module.
|
||||
*
|
||||
* Note: every class is prefixed with "edit-" to prevent collisions with modules
|
||||
* or themes. In Edit module-specific DOM subtrees, this is not necessary.
|
||||
* Note: every class is prefixed with "quickedit-" to prevent collisions with
|
||||
* modules or themes. In Edit module-specific DOM subtrees, this is not
|
||||
* necessary.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Editable.
|
||||
*/
|
||||
.edit-editable {
|
||||
.quickedit-editable {
|
||||
z-index: 98;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
.edit-editable:focus {
|
||||
.quickedit-editable:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlighted (hovered) editable.
|
||||
*/
|
||||
.edit-editable.edit-highlighted {
|
||||
.quickedit-editable.quickedit-highlighted {
|
||||
z-index: 99;
|
||||
}
|
||||
.edit-validation-errors > .messages {
|
||||
.quickedit-validation-errors > .messages {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
.edit-validation-errors > .messages > ul {
|
||||
.quickedit-validation-errors > .messages > ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
@ -37,18 +38,18 @@
|
|||
/**
|
||||
* In-place editors that don't use a popup.
|
||||
*/
|
||||
.edit-validation-errors {
|
||||
.quickedit-validation-errors {
|
||||
z-index: 300;
|
||||
position: relative;
|
||||
}
|
||||
.edit-validation-errors .messages.error {
|
||||
.quickedit-validation-errors .messages.error {
|
||||
position: absolute;
|
||||
top: 6px;
|
||||
left: -5px; /* LTR */
|
||||
margin: 0;
|
||||
border: none;
|
||||
}
|
||||
[dir="rtl"] .edit-validation-errors .messages.error {
|
||||
[dir="rtl"] .quickedit-validation-errors .messages.error {
|
||||
left: auto;
|
||||
right: -5px;
|
||||
}
|
||||
|
@ -56,46 +57,46 @@
|
|||
/**
|
||||
* Styling specific to the 'form' in-place editor.
|
||||
*/
|
||||
#edit_backstage {
|
||||
#quickedit_backstage {
|
||||
display: none;
|
||||
}
|
||||
.edit-form {
|
||||
.quickedit-form {
|
||||
position: absolute;
|
||||
z-index: 300;
|
||||
max-width: 35em;
|
||||
}
|
||||
.edit-form .placeholder {
|
||||
.quickedit-form .placeholder {
|
||||
min-height: 22px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default form styling overrides.
|
||||
*/
|
||||
.edit-form .form-wrapper .form-wrapper {
|
||||
.quickedit-form .form-wrapper .form-wrapper {
|
||||
margin: inherit;
|
||||
}
|
||||
.edit-form .form-actions {
|
||||
.quickedit-form .form-actions {
|
||||
display: none;
|
||||
}
|
||||
.edit-form input {
|
||||
.quickedit-form input {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity toolbar.
|
||||
*/
|
||||
.edit-toolbar-container {
|
||||
.quickedit-toolbar-container {
|
||||
max-width: 100%;
|
||||
position: absolute;
|
||||
max-width: 320px;
|
||||
width: 320px;
|
||||
z-index: 100;
|
||||
}
|
||||
.edit-toolbar-container > .edit-toolbar-pointer,
|
||||
.edit-toolbar-container > .edit-toolbar-lining {
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-pointer,
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-lining {
|
||||
display: none;
|
||||
}
|
||||
.edit-form-container {
|
||||
.quickedit-form-container {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
|
@ -103,16 +104,16 @@
|
|||
vertical-align: baseline;
|
||||
z-index: 100;
|
||||
}
|
||||
.edit-toolgroup.ops {
|
||||
.quickedit-toolgroup.ops {
|
||||
float: right; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .edit-toolgroup.ops {
|
||||
[dir="rtl"] .quickedit-toolgroup.ops {
|
||||
float: left;
|
||||
}
|
||||
.edit-toolbar-label {
|
||||
.quickedit-toolbar-label {
|
||||
overflow: hidden;
|
||||
}
|
||||
#edit-toolbar-fence {
|
||||
#quickedit-toolbar-fence {
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
|
@ -1,80 +1,80 @@
|
|||
/**
|
||||
* @file
|
||||
* Styling for edit module.
|
||||
* Styling for Quick Edit module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Editable.
|
||||
*/
|
||||
.edit-field.edit-editable,
|
||||
.edit-field .edit-editable {
|
||||
.quickedit-field.quickedit-editable,
|
||||
.quickedit-field .quickedit-editable {
|
||||
box-shadow: 0 0 0 2px #74b7ff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Highlighted (hovered) editable.
|
||||
*/
|
||||
.edit-field.edit-highlighted,
|
||||
.edit-form.edit-highlighted,
|
||||
.edit-field .edit-highlighted {
|
||||
.quickedit-field.quickedit-highlighted,
|
||||
.quickedit-form.quickedit-highlighted,
|
||||
.quickedit-field .quickedit-highlighted {
|
||||
box-shadow: 0 0 0 1px #74b7ff, 0 0 0 2px #007fff;
|
||||
}
|
||||
.edit-field.edit-changed,
|
||||
.edit-form.edit-changed,
|
||||
.edit-field .edit-changed {
|
||||
.quickedit-field.quickedit-changed,
|
||||
.quickedit-form.quickedit-changed,
|
||||
.quickedit-field .quickedit-changed {
|
||||
box-shadow: 0 0 0 1px #fec17e, 0 0 0 2px #f7870a;
|
||||
}
|
||||
.edit-editing.edit-validation-error,
|
||||
.edit-form.edit-validation-error {
|
||||
.quickedit-editing.quickedit-validation-error,
|
||||
.quickedit-form.quickedit-validation-error {
|
||||
box-shadow: 0 0 0px 1px #ee8b74, 0 0 0 2px #fa2209;
|
||||
}
|
||||
.edit-editing.edit-editor-is-popup {
|
||||
.quickedit-editing.quickedit-editor-is-popup {
|
||||
box-shadow: none;
|
||||
}
|
||||
.edit-form .form-item .error {
|
||||
.quickedit-form .form-item .error {
|
||||
border: 1px solid #eea0a0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default form styling overrides.
|
||||
*/
|
||||
.edit-form form {
|
||||
.quickedit-form form {
|
||||
padding: 0.5em;
|
||||
}
|
||||
.edit-form .form-item {
|
||||
.quickedit-form .form-item {
|
||||
margin: 0;
|
||||
}
|
||||
.edit-form .form-wrapper {
|
||||
.quickedit-form .form-wrapper {
|
||||
margin: .5em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Animations.
|
||||
*/
|
||||
.edit-animate-invisible {
|
||||
.quickedit-animate-invisible {
|
||||
opacity: 0;
|
||||
}
|
||||
.edit-animate-default {
|
||||
.quickedit-animate-default {
|
||||
-webkit-transition: all .4s ease;
|
||||
transition: all .4s ease;
|
||||
}
|
||||
.edit-animate-slow {
|
||||
.quickedit-animate-slow {
|
||||
-webkit-transition: all .6s ease;
|
||||
transition: all .6s ease;
|
||||
}
|
||||
.edit-animate-delay-veryfast {
|
||||
.quickedit-animate-delay-veryfast {
|
||||
-webkit-transition-delay: .05s;
|
||||
transition-delay: .05s;
|
||||
}
|
||||
.edit-animate-delay-fast {
|
||||
.quickedit-animate-delay-fast {
|
||||
-webkit-transition-delay: .2s;
|
||||
transition-delay: .2s;
|
||||
}
|
||||
.edit-animate-disable-width {
|
||||
.quickedit-animate-disable-width {
|
||||
-webkit-transition: width 0s;
|
||||
transition: width 0s;
|
||||
}
|
||||
.edit-animate-only-visibility {
|
||||
.quickedit-animate-only-visibility {
|
||||
-webkit-transition: opacity .2s ease;
|
||||
transition: opacity .2s ease;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@
|
|||
/**
|
||||
* In-place editors that don't use a popup.
|
||||
*/
|
||||
.edit-validation-errors .messages.error {
|
||||
.quickedit-validation-errors .messages.error {
|
||||
box-shadow: 0 0 1px 1px red, 0 0 3px 3px rgba(153, 153, 153, .5);
|
||||
background-color: white;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@
|
|||
/**
|
||||
* Styling specific to the 'form' in-place editor.
|
||||
*/
|
||||
.edit-form {
|
||||
.quickedit-form {
|
||||
box-shadow: 0 0 30px 4px #4f4f4f;
|
||||
background-color: white;
|
||||
}
|
||||
|
@ -98,14 +98,14 @@
|
|||
/**
|
||||
* Toolbars.
|
||||
*/
|
||||
.edit-toolbar-container {
|
||||
.quickedit-toolbar-container {
|
||||
font-family: 'Source Sans Pro','Lucida Grande', sans-serif;
|
||||
padding-bottom: 7px;
|
||||
padding-top: 7px;
|
||||
-webkit-transition: all 1s;
|
||||
transition: all 1s;
|
||||
}
|
||||
.edit-toolbar-container > .edit-toolbar-content {
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-content {
|
||||
background-image: -webkit-linear-gradient(top, #fff, #e4e4e4);
|
||||
background-image: -moz-linear-gradient(top, #fff, #e4e4e4);
|
||||
background-image: -o-linear-gradient(top, #fff, #e4e4e4);
|
||||
|
@ -122,7 +122,7 @@
|
|||
user-select: none;
|
||||
z-index: 2;
|
||||
}
|
||||
.edit-toolbar-container > .edit-toolbar-pointer {
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-pointer {
|
||||
background-color: #e4e4e4;
|
||||
bottom: 2px;
|
||||
box-shadow: 0 0 0 1px #818181, 0px 0px 0 4px rgba(150, 150, 150, 0.5);
|
||||
|
@ -136,15 +136,15 @@
|
|||
width: 16px;
|
||||
z-index: 1;
|
||||
}
|
||||
[dir="rtl"] .edit-toolbar-container > .edit-toolbar-pointer {
|
||||
[dir="rtl"] .quickedit-toolbar-container > .quickedit-toolbar-pointer {
|
||||
left: auto;
|
||||
right: 18px;
|
||||
}
|
||||
.edit-toolbar-container.edit-toolbar-pointer-top > .edit-toolbar-pointer {
|
||||
.quickedit-toolbar-container.quickedit-toolbar-pointer-top > .quickedit-toolbar-pointer {
|
||||
bottom: auto;
|
||||
top: 2px;
|
||||
}
|
||||
.edit-toolbar-container > .edit-toolbar-lining {
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-lining {
|
||||
bottom: 7px;
|
||||
box-shadow: 0 0 0 1px #818181, 0px 3px 0px 1px rgba(150, 150, 150, 0.5);
|
||||
display: block;
|
||||
|
@ -155,43 +155,43 @@
|
|||
z-index: 0;
|
||||
}
|
||||
|
||||
.edit-toolbar-label {
|
||||
.quickedit-toolbar-label {
|
||||
font-style: italic;
|
||||
overflow: hidden;
|
||||
padding: 0.333em 0.4em;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.edit-toolbar-label .field:after {
|
||||
.quickedit-toolbar-label .field:after {
|
||||
content: ' → ';
|
||||
}
|
||||
|
||||
/* The toolbar; these are not necessarily visible. */
|
||||
.edit-toolbar {
|
||||
.quickedit-toolbar {
|
||||
font-family: 'Droid sans', 'Lucida Grande', sans-serif;
|
||||
}
|
||||
.edit-toolbar-entity {
|
||||
.quickedit-toolbar-entity {
|
||||
padding: 0.1667em 0.2em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Info toolgroup.
|
||||
*/
|
||||
.edit-toolbar-fullwidth {
|
||||
.quickedit-toolbar-fullwidth {
|
||||
width: 100%;
|
||||
}
|
||||
.edit-toolgroup.wysiwyg-floated {
|
||||
.quickedit-toolgroup.wysiwyg-floated {
|
||||
float: right; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .edit-toolgroup.wysiwyg-floated {
|
||||
[dir="rtl"] .quickedit-toolgroup.wysiwyg-floated {
|
||||
float: left;
|
||||
}
|
||||
.edit-toolgroup.wysiwyg-main {
|
||||
.quickedit-toolgroup.wysiwyg-main {
|
||||
clear: both;
|
||||
width: 100%;
|
||||
padding-left: 0; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .edit-toolgroup.wysiwyg-main {
|
||||
[dir="rtl"] .quickedit-toolgroup.wysiwyg-main {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@
|
|||
/**
|
||||
* Buttons.
|
||||
*/
|
||||
.edit-button {
|
||||
.quickedit-button {
|
||||
background-color: #e4e4e4;
|
||||
border: 1px solid #d2d2d2;
|
||||
color: #5a5a5a;
|
||||
|
@ -211,29 +211,29 @@
|
|||
-webkit-transition: opacity .1s ease;
|
||||
transition: opacity .1s ease;
|
||||
}
|
||||
.edit-button[aria-hidden="true"] {
|
||||
.quickedit-button[aria-hidden="true"] {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
}
|
||||
.edit-button + .edit-button {
|
||||
.quickedit-button + .quickedit-button {
|
||||
margin-left: 0.2em; /* LTR */
|
||||
}
|
||||
[dir="rtl"] .edit-button + .edit-button {
|
||||
[dir="rtl"] .quickedit-button + .quickedit-button {
|
||||
margin-left: auto;
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
/* Button with icons. */
|
||||
.edit-button:hover,
|
||||
.edit-button:active {
|
||||
.quickedit-button:hover,
|
||||
.quickedit-button:active {
|
||||
background-color: #c8c8c8;
|
||||
border: 1px solid #a0a0a0;
|
||||
color: #2e2e2e;
|
||||
}
|
||||
.edit-toolbar-container .edit-button.action-cancel {
|
||||
.quickedit-toolbar-container .quickedit-button.action-cancel {
|
||||
background-color: transparent;
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.edit-button.action-save {
|
||||
.quickedit-button.action-save {
|
||||
color: white;
|
||||
background-color: #50a0e9;
|
||||
background-image: -webkit-linear-gradient(top, #50a0e9, #4481dc);
|
||||
|
@ -242,13 +242,13 @@
|
|||
background-image: linear-gradient(to bottom, #50a0e9, #4481dc);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.edit-button.action-save:hover,
|
||||
.edit-button.action-save:active {
|
||||
.quickedit-button.action-save:hover,
|
||||
.quickedit-button.action-save:active {
|
||||
border: 1px solid #a0a0a0;
|
||||
}
|
||||
.edit-button.action-saving,
|
||||
.edit-button.action-saving:hover,
|
||||
.edit-button.action-saving:active {
|
||||
.quickedit-button.action-saving,
|
||||
.quickedit-button.action-saving:hover,
|
||||
.quickedit-button.action-saving:active {
|
||||
background-color: #e4e4e4;
|
||||
background-image: none;
|
||||
border-color: #d2d2d2;
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.editors.form = Drupal.edit.EditorView.extend({
|
||||
Drupal.quickedit.editors.form = Drupal.quickedit.EditorView.extend({
|
||||
|
||||
// Tracks the form container DOM element that is used while in-place editing.
|
||||
$formContainer: null,
|
||||
|
@ -55,7 +55,7 @@
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
getEditUISettings: function () {
|
||||
getQuickEditUISettings: function () {
|
||||
return { padding: true, unifiedToolbar: true, fullWidthToolbar: true, popup: true };
|
||||
},
|
||||
|
||||
|
@ -66,17 +66,17 @@
|
|||
var fieldModel = this.fieldModel;
|
||||
|
||||
// Generate a DOM-compatible ID for the form container DOM element.
|
||||
var id = 'edit-form-for-' + fieldModel.id.replace(/[\/\[\]]/g, '_');
|
||||
var id = 'quickedit-form-for-' + fieldModel.id.replace(/[\/\[\]]/g, '_');
|
||||
|
||||
// Render form container.
|
||||
var $formContainer = this.$formContainer = $(Drupal.theme('editFormContainer', {
|
||||
var $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', {
|
||||
id: id,
|
||||
loadingMsg: Drupal.t('Loading…')
|
||||
}
|
||||
));
|
||||
$formContainer
|
||||
.find('.edit-form')
|
||||
.addClass('edit-editable edit-highlighted edit-editing')
|
||||
.find('.quickedit-form')
|
||||
.addClass('quickedit-editable quickedit-highlighted quickedit-editing')
|
||||
.attr('role', 'dialog');
|
||||
|
||||
// Insert form container in DOM.
|
||||
|
@ -103,14 +103,14 @@
|
|||
// for an entity that this needs to happen: precisely now!
|
||||
reset: !fieldModel.get('entity').get('inTempStore')
|
||||
};
|
||||
Drupal.edit.util.form.load(formOptions, function (form, ajax) {
|
||||
Drupal.quickedit.util.form.load(formOptions, function (form, ajax) {
|
||||
Drupal.AjaxCommands.prototype.insert(ajax, {
|
||||
data: form,
|
||||
selector: '#' + id + ' .placeholder'
|
||||
});
|
||||
|
||||
$formContainer
|
||||
.on('formUpdated.edit', ':input', function (event) {
|
||||
.on('formUpdated.quickedit', ':input', function (event) {
|
||||
var state = fieldModel.get('state');
|
||||
// If the form is in an invalid state, it will persist on the page.
|
||||
// Set the field to activating so that the user can correct the
|
||||
|
@ -124,7 +124,7 @@
|
|||
fieldModel.set('state', 'changed');
|
||||
}
|
||||
})
|
||||
.on('keypress.edit', 'input', function (event) {
|
||||
.on('keypress.quickedit', 'input', function (event) {
|
||||
if (event.keyCode === 13) {
|
||||
return false;
|
||||
}
|
||||
|
@ -147,8 +147,8 @@
|
|||
// Allow form widgets to detach properly.
|
||||
Drupal.detachBehaviors(this.$formContainer.get(0), null, 'unload');
|
||||
this.$formContainer
|
||||
.off('change.edit', ':input')
|
||||
.off('keypress.edit', 'input')
|
||||
.off('change.quickedit', ':input')
|
||||
.off('keypress.quickedit', 'input')
|
||||
.remove();
|
||||
this.$formContainer = null;
|
||||
},
|
||||
|
@ -158,23 +158,23 @@
|
|||
*/
|
||||
save: function () {
|
||||
var $formContainer = this.$formContainer;
|
||||
var $submit = $formContainer.find('.edit-form-submit');
|
||||
var $submit = $formContainer.find('.quickedit-form-submit');
|
||||
var editorModel = this.model;
|
||||
var fieldModel = this.fieldModel;
|
||||
|
||||
function cleanUpAjax() {
|
||||
Drupal.edit.util.form.unajaxifySaving(formSaveAjax);
|
||||
Drupal.quickedit.util.form.unajaxifySaving(formSaveAjax);
|
||||
formSaveAjax = null;
|
||||
}
|
||||
|
||||
// Create an AJAX object for the form associated with the field.
|
||||
var formSaveAjax = Drupal.edit.util.form.ajaxifySaving({
|
||||
var formSaveAjax = Drupal.quickedit.util.form.ajaxifySaving({
|
||||
nocssjs: false,
|
||||
other_view_modes: fieldModel.findOtherViewModes()
|
||||
}, $submit);
|
||||
|
||||
// Successfully saved.
|
||||
formSaveAjax.commands.editFieldFormSaved = function (ajax, response, status) {
|
||||
formSaveAjax.commands.quickeditFieldFormSaved = function (ajax, response, status) {
|
||||
cleanUpAjax();
|
||||
// First, transition the state to 'saved'.
|
||||
fieldModel.set('state', 'saved');
|
||||
|
@ -190,16 +190,16 @@
|
|||
};
|
||||
|
||||
// Unsuccessfully saved; validation errors.
|
||||
formSaveAjax.commands.editFieldFormValidationErrors = function (ajax, response, status) {
|
||||
formSaveAjax.commands.quickeditFieldFormValidationErrors = function (ajax, response, status) {
|
||||
editorModel.set('validationErrors', response.data);
|
||||
fieldModel.set('state', 'invalid');
|
||||
};
|
||||
|
||||
// The edit_field_form AJAX command is called upon attempting to save
|
||||
// The quickeditFieldForm AJAX command is called upon attempting to save
|
||||
// the form; Form API will mark which form items have errors, if any. This
|
||||
// command is invoked only if validation errors exist and then it runs
|
||||
// before editFieldFormValidationErrors().
|
||||
formSaveAjax.commands.editFieldForm = function (ajax, response, status) {
|
||||
formSaveAjax.commands.quickeditFieldForm = function (ajax, response, status) {
|
||||
Drupal.AjaxCommands.prototype.insert(ajax, {
|
||||
data: response.data,
|
||||
selector: '#' + $formContainer.attr('id') + ' form'
|
||||
|
@ -208,7 +208,7 @@
|
|||
|
||||
// Click the form's submit button; the scoped AJAX commands above will
|
||||
// handle the server's response.
|
||||
$submit.trigger('click.edit');
|
||||
$submit.trigger('click.quickedit');
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -216,8 +216,8 @@
|
|||
*/
|
||||
showValidationErrors: function () {
|
||||
this.$formContainer
|
||||
.find('.edit-form')
|
||||
.addClass('edit-validation-error')
|
||||
.find('.quickedit-form')
|
||||
.addClass('quickedit-validation-error')
|
||||
.find('form')
|
||||
.prepend(this.model.get('validationErrors'));
|
||||
}
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.editors.plain_text = Drupal.edit.EditorView.extend({
|
||||
Drupal.quickedit.editors.plain_text = Drupal.quickedit.EditorView.extend({
|
||||
|
||||
// Stores the textual DOM element that is being in-place edited.
|
||||
$textElement: null,
|
||||
|
@ -16,7 +16,7 @@
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
initialize: function (options) {
|
||||
Drupal.edit.EditorView.prototype.initialize.call(this, options);
|
||||
Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
|
||||
|
||||
var editorModel = this.model;
|
||||
var fieldModel = this.fieldModel;
|
||||
|
@ -99,7 +99,7 @@
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
getEditUISettings: function () {
|
||||
getQuickEditUISettings: function () {
|
||||
return { padding: true, unifiedToolbar: false, fullWidthToolbar: false, popup: false };
|
||||
},
|
||||
|
|
@ -2,21 +2,22 @@
|
|||
* @file
|
||||
* A Backbone Model for the state of the in-place editing application.
|
||||
*
|
||||
* @see Drupal.edit.AppView
|
||||
* @see Drupal.quickedit.AppView
|
||||
*/
|
||||
|
||||
(function (Backbone, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.AppModel = Backbone.Model.extend({
|
||||
Drupal.quickedit.AppModel = Backbone.Model.extend({
|
||||
|
||||
defaults: {
|
||||
// The currently state = 'highlighted' Drupal.edit.FieldModel, if any.
|
||||
// @see Drupal.edit.FieldModel.states
|
||||
// The currently state = 'highlighted' Drupal.quickedit.FieldModel, if
|
||||
// any.
|
||||
// @see Drupal.quickedit.FieldModel.states
|
||||
highlightedField: null,
|
||||
// The currently state = 'active' Drupal.edit.FieldModel, if any.
|
||||
// @see Drupal.edit.FieldModel.states
|
||||
// The currently state = 'active' Drupal.quickedit.FieldModel, if any.
|
||||
// @see Drupal.quickedit.FieldModel.states
|
||||
activeField: null,
|
||||
// Reference to a Drupal.dialog instance if a state change requires
|
||||
// confirmation.
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.BaseModel = Backbone.Model.extend({
|
||||
Drupal.quickedit.BaseModel = Backbone.Model.extend({
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
|
@ -2,14 +2,14 @@
|
|||
* @file
|
||||
* A Backbone Model for the state of an in-place editor.
|
||||
*
|
||||
* @see Drupal.edit.EditorView
|
||||
* @see Drupal.quickedit.EditorView
|
||||
*/
|
||||
|
||||
(function (Backbone, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.EditorModel = Backbone.Model.extend({
|
||||
Drupal.quickedit.EditorModel = Backbone.Model.extend({
|
||||
|
||||
defaults: {
|
||||
// Not the full HTML representation of this field, but the "actual"
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.EntityModel = Drupal.edit.BaseModel.extend({
|
||||
Drupal.quickedit.EntityModel = Drupal.quickedit.BaseModel.extend({
|
||||
|
||||
defaults: {
|
||||
// The DOM element that represents this entity. It may seem bizarre to
|
||||
|
@ -24,7 +24,7 @@
|
|||
id: null,
|
||||
// The label of the entity.
|
||||
label: null,
|
||||
// A Drupal.edit.FieldCollection for all fields of this entity.
|
||||
// A Drupal.quickedit.FieldCollection for all fields of this entity.
|
||||
fields: null,
|
||||
|
||||
// The attributes below are stateful. The ones above will never change
|
||||
|
@ -59,7 +59,7 @@
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
initialize: function () {
|
||||
this.set('fields', new Drupal.edit.FieldCollection());
|
||||
this.set('fields', new Drupal.quickedit.FieldCollection());
|
||||
|
||||
// Respond to entity state changes.
|
||||
this.listenTo(this, 'change:state', this.stateChange);
|
||||
|
@ -68,16 +68,16 @@
|
|||
// fields.
|
||||
this.listenTo(this.get('fields'), 'change:state', this.fieldStateChange);
|
||||
|
||||
// Call Drupal.edit.BaseModel's initialize() method.
|
||||
Drupal.edit.BaseModel.prototype.initialize.call(this);
|
||||
// Call Drupal.quickedit.BaseModel's initialize() method.
|
||||
Drupal.quickedit.BaseModel.prototype.initialize.call(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates FieldModels' states when an EntityModel change occurs.
|
||||
*
|
||||
* @param Drupal.edit.EntityModel entityModel
|
||||
* @param Drupal.quickedit.EntityModel entityModel
|
||||
* @param String state
|
||||
* The state of the associated entity. One of Drupal.edit.EntityModel.states.
|
||||
* The state of the associated entity. One of Drupal.quickedit.EntityModel.states.
|
||||
* @param Object options
|
||||
*/
|
||||
stateChange: function (entityModel, state, options) {
|
||||
|
@ -121,7 +121,7 @@
|
|||
// stored in TempStore.
|
||||
fields.chain()
|
||||
.filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], Drupal.edit.app.changedFieldStates).length;
|
||||
return _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length;
|
||||
})
|
||||
.each(function (fieldModel) {
|
||||
fieldModel.set('state', 'saving');
|
||||
|
@ -148,7 +148,7 @@
|
|||
this.set('state', 'opened', {confirming: true});
|
||||
// An action in reaction to state change must be deferred.
|
||||
_.defer(function () {
|
||||
Drupal.edit.app.confirmEntityDeactivation(entityModel);
|
||||
Drupal.quickedit.app.confirmEntityDeactivation(entityModel);
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -193,9 +193,9 @@
|
|||
*
|
||||
* Helper function.
|
||||
*
|
||||
* @param Drupal.edit.EntityModel entityModel
|
||||
* @param Drupal.quickedit.EntityModel entityModel
|
||||
* The model of the entity for which a field's state attribute has changed.
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* The model of the field whose state attribute has changed.
|
||||
*
|
||||
* @see fieldStateChange()
|
||||
|
@ -230,10 +230,10 @@
|
|||
/**
|
||||
* Reacts to state changes in this entity's fields.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* The model of the field whose state attribute changed.
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.FieldModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.FieldModel.states.
|
||||
*/
|
||||
fieldStateChange: function (fieldModel, state) {
|
||||
var entityModel = this;
|
||||
|
@ -262,7 +262,7 @@
|
|||
// A state change in reaction to another state change must be deferred.
|
||||
_.defer(function () {
|
||||
entityModel.set('state', 'opened', {
|
||||
'accept-field-states': Drupal.edit.app.readyFieldStates
|
||||
'accept-field-states': Drupal.quickedit.app.readyFieldStates
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
@ -300,7 +300,7 @@
|
|||
// Attempt to save the entity. If the entity's fields are not yet all in
|
||||
// a ready state, the save will not be processed.
|
||||
var options = {
|
||||
'accept-field-states': Drupal.edit.app.readyFieldStates
|
||||
'accept-field-states': Drupal.quickedit.app.readyFieldStates
|
||||
};
|
||||
if (entityModel.set('isCommitting', true, options)) {
|
||||
entityModel.save({
|
||||
|
@ -318,7 +318,7 @@
|
|||
entityModel.set('state', 'opened', { reason: 'networkerror' });
|
||||
// Show a modal to inform the user of the network error.
|
||||
var message = Drupal.t('Your changes to <q>@entity-title</q> could not be saved, either due to a website problem or a network connection problem.<br>Please try again.', { '@entity-title': entityModel.get('label') });
|
||||
Drupal.edit.util.networkErrorModal(Drupal.t('Sorry!'), message);
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Sorry!'), message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -330,7 +330,7 @@
|
|||
// A state change in reaction to another state change must be deferred.
|
||||
_.defer(function () {
|
||||
entityModel.set('state', 'closing', {
|
||||
'accept-field-states': Drupal.edit.app.readyFieldStates
|
||||
'accept-field-states': Drupal.quickedit.app.readyFieldStates
|
||||
});
|
||||
});
|
||||
break;
|
||||
|
@ -361,25 +361,25 @@
|
|||
|
||||
// @todo Simplify this once https://drupal.org/node/1533366 lands.
|
||||
// @see https://drupal.org/node/2029999.
|
||||
var id = 'edit-save-entity';
|
||||
var id = 'quickedit-save-entity';
|
||||
// Create a temporary element to be able to use Drupal.ajax.
|
||||
var $el = $('#edit-entity-toolbar').find('.action-save'); // This is the span element inside the button.
|
||||
var $el = $('#quickedit-entity-toolbar').find('.action-save'); // This is the span element inside the button.
|
||||
// Create a Drupal.ajax instance to save the entity.
|
||||
var entitySaverAjax = new Drupal.ajax(id, $el, {
|
||||
url: Drupal.url('edit/entity/' + entityModel.get('entityID')),
|
||||
event: 'edit-save.edit',
|
||||
url: Drupal.url('quickedit/entity/' + entityModel.get('entityID')),
|
||||
event: 'quickedit-save.quickedit',
|
||||
progress: { type: 'none' },
|
||||
error: function () {
|
||||
$el.off('edit-save.edit');
|
||||
// Let the Drupal.edit.EntityModel Backbone model's error() method
|
||||
// handle errors.
|
||||
$el.off('quickedit-save.quickedit');
|
||||
// Let the Drupal.quickedit.EntityModel Backbone model's error()=
|
||||
// method handle errors.
|
||||
options.error.call(entityModel);
|
||||
}
|
||||
});
|
||||
// Entity saved successfully.
|
||||
entitySaverAjax.commands.editEntitySaved = function (ajax, response, status) {
|
||||
entitySaverAjax.commands.quickeditEntitySaved = function (ajax, response, status) {
|
||||
// Clean up.
|
||||
$(ajax.element).off('edit-save.edit');
|
||||
$(ajax.element).off('quickedit-save.quickedit');
|
||||
// All fields have been moved from TempStore to permanent storage, update
|
||||
// the "inTempStore" attribute on FieldModels, on the EntityModel and
|
||||
// clear EntityModel's "fieldInTempStore" attribute.
|
||||
|
@ -394,9 +394,9 @@
|
|||
options.success.call(entityModel);
|
||||
}
|
||||
};
|
||||
// Trigger the AJAX request, which will will return the editEntitySaved AJAX
|
||||
// command to which we then react.
|
||||
$el.trigger('edit-save.edit');
|
||||
// Trigger the AJAX request, which will will return the
|
||||
// quickeditEntitySaved AJAX command to which we then react.
|
||||
$el.trigger('quickedit-save.quickedit');
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -514,7 +514,7 @@
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
destroy: function (options) {
|
||||
Drupal.edit.BaseModel.prototype.destroy.call(this, options);
|
||||
Drupal.quickedit.BaseModel.prototype.destroy.call(this, options);
|
||||
|
||||
this.stopListening();
|
||||
|
||||
|
@ -594,9 +594,9 @@
|
|||
* Indicates whether the 'from' state comes before the 'to' state.
|
||||
*
|
||||
* @param String from
|
||||
* One of Drupal.edit.EntityModel.states.
|
||||
* One of Drupal.quickedit.EntityModel.states.
|
||||
* @param String to
|
||||
* One of Drupal.edit.EntityModel.states.
|
||||
* One of Drupal.quickedit.EntityModel.states.
|
||||
* @return Boolean
|
||||
*/
|
||||
followsStateSequence: function (from, to) {
|
||||
|
@ -605,8 +605,8 @@
|
|||
|
||||
});
|
||||
|
||||
Drupal.edit.EntityCollection = Backbone.Collection.extend({
|
||||
model: Drupal.edit.EntityModel
|
||||
Drupal.quickedit.EntityCollection = Backbone.Collection.extend({
|
||||
model: Drupal.quickedit.EntityModel
|
||||
});
|
||||
|
||||
}(_, jQuery, Backbone, Drupal));
|
|
@ -10,7 +10,7 @@
|
|||
/**
|
||||
* State of an in-place editable field in the DOM.
|
||||
*/
|
||||
Drupal.edit.FieldModel = Drupal.edit.BaseModel.extend({
|
||||
Drupal.quickedit.FieldModel = Drupal.quickedit.BaseModel.extend({
|
||||
|
||||
defaults: {
|
||||
// The DOM element that represents this field. It may seem bizarre to have
|
||||
|
@ -25,10 +25,10 @@
|
|||
// the form "<entity type>/<id>/<field name>/<language>/<view mode>[entity instance ID]",
|
||||
// e.g. "node/1/field_tags/und/full[0]".
|
||||
id: null,
|
||||
// A Drupal.edit.EntityModel. Its "fields" attribute, which is a
|
||||
// A Drupal.quickedit.EntityModel. Its "fields" attribute, which is a
|
||||
// FieldCollection, is automatically updated to include this FieldModel.
|
||||
entity: null,
|
||||
// This field's metadata as returned by the EditController::metadata().
|
||||
// This field's metadata as returned by the QuickEditController::metadata().
|
||||
metadata: null,
|
||||
// Callback function for validating changes between states. Receives the
|
||||
// previous state, new state, context, and a callback
|
||||
|
@ -43,7 +43,7 @@
|
|||
// during the life of a FieldModel instance.
|
||||
|
||||
// In-place editing state of this field. Defaults to the initial state.
|
||||
// Possible values: @see Drupal.edit.FieldModel.states.
|
||||
// Possible values: @see Drupal.quickedit.FieldModel.states.
|
||||
state: 'inactive',
|
||||
// The field is currently in the 'changed' state or one of the following
|
||||
// states in which the field is still changed.
|
||||
|
@ -52,8 +52,8 @@
|
|||
// purposes: so that FieldDecorationView.renderChanged() can react to it.
|
||||
inTempStore: false,
|
||||
// The full HTML representation of this field (with the element that has
|
||||
// the data-edit-field-id as the outer element). Used to propagate changes
|
||||
// from this field instance to other instances of the same field.
|
||||
// the data-quickedit-field-id as the outer element). Used to propagate
|
||||
// changes from this field instance to other instances of the same field.
|
||||
html: null,
|
||||
// An object containing the full HTML representations (values) of other view
|
||||
// modes (keys) of this field, for other instances of this field displayed
|
||||
|
@ -74,8 +74,8 @@
|
|||
// Automatically generate the logical field ID.
|
||||
this.set('logicalFieldID', this.get('fieldID').split('/').slice(0, 4).join('/'));
|
||||
|
||||
// Call Drupal.edit.BaseModel's initialize() method.
|
||||
Drupal.edit.BaseModel.prototype.initialize.call(this, options);
|
||||
// Call Drupal.quickedit.BaseModel's initialize() method.
|
||||
Drupal.quickedit.BaseModel.prototype.initialize.call(this, options);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,7 @@
|
|||
if (this.get('state') !== 'inactive') {
|
||||
throw new Error("FieldModel cannot be destroyed if it is not inactive state.");
|
||||
}
|
||||
Drupal.edit.BaseModel.prototype.destroy.call(this, options);
|
||||
Drupal.quickedit.BaseModel.prototype.destroy.call(this, options);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -143,7 +143,7 @@
|
|||
findOtherViewModes: function () {
|
||||
var currentField = this;
|
||||
var otherViewModes = [];
|
||||
Drupal.edit.collections.fields
|
||||
Drupal.quickedit.collections.fields
|
||||
// Find all instances of fields that display the same logical field (same
|
||||
// entity, same field, just a different instance and maybe a different
|
||||
// view mode).
|
||||
|
@ -242,9 +242,9 @@
|
|||
* Indicates whether the 'from' state comes before the 'to' state.
|
||||
*
|
||||
* @param String from
|
||||
* One of Drupal.edit.FieldModel.states.
|
||||
* One of Drupal.quickedit.FieldModel.states.
|
||||
* @param String to
|
||||
* One of Drupal.edit.FieldModel.states.
|
||||
* One of Drupal.quickedit.FieldModel.states.
|
||||
* @return Boolean
|
||||
*/
|
||||
followsStateSequence: function (from, to) {
|
||||
|
@ -253,8 +253,8 @@
|
|||
|
||||
});
|
||||
|
||||
Drupal.edit.FieldCollection = Backbone.Collection.extend({
|
||||
model: Drupal.edit.FieldModel
|
||||
Drupal.quickedit.FieldCollection = Backbone.Collection.extend({
|
||||
model: Drupal.quickedit.FieldModel
|
||||
});
|
||||
|
||||
}(_, Backbone, Drupal));
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* @file
|
||||
* Attaches behavior for the Edit module.
|
||||
* Attaches behavior for the Quick Edit module.
|
||||
*
|
||||
* Everything happens asynchronously, to allow for:
|
||||
* - dynamically rendered contextual links
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
var options = $.extend(drupalSettings.edit,
|
||||
var options = $.extend(drupalSettings.quickedit,
|
||||
// Merge strings on top of drupalSettings so that they are not mutable.
|
||||
{
|
||||
strings: {
|
||||
|
@ -63,20 +63,20 @@
|
|||
*/
|
||||
var entityInstancesTracker = {};
|
||||
|
||||
Drupal.behaviors.edit = {
|
||||
Drupal.behaviors.quickedit = {
|
||||
attach: function (context) {
|
||||
// Initialize the Edit app once per page load.
|
||||
$('body').once('edit-init', initEdit);
|
||||
// Initialize the Quick Edit app once per page load.
|
||||
$('body').once('quickedit-init', initQuickEdit);
|
||||
|
||||
// Find all in-place editable fields, if any.
|
||||
var $fields = $(context).find('[data-edit-field-id]').once('edit');
|
||||
var $fields = $(context).find('[data-quickedit-field-id]').once('quickedit');
|
||||
if ($fields.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Process each entity element: identical entities that appear multiple
|
||||
// times will get a numeric identifier, starting at 0.
|
||||
$(context).find('[data-edit-entity-id]').once('edit').each(function (index, entityElement) {
|
||||
$(context).find('[data-quickedit-entity-id]').once('quickedit').each(function (index, entityElement) {
|
||||
processEntity(entityElement);
|
||||
});
|
||||
|
||||
|
@ -114,14 +114,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
Drupal.edit = {
|
||||
// A Drupal.edit.AppView instance.
|
||||
Drupal.quickedit = {
|
||||
// A Drupal.quickedit.AppView instance.
|
||||
app: null,
|
||||
|
||||
collections: {
|
||||
// All in-place editable entities (Drupal.edit.EntityModel) on the page.
|
||||
// All in-place editable entities (Drupal.quickedit.EntityModel) on the
|
||||
// page.
|
||||
entities: null,
|
||||
// All in-place editable fields (Drupal.edit.FieldModel) on the page.
|
||||
// All in-place editable fields (Drupal.quickedit.FieldModel) on the page.
|
||||
fields: null
|
||||
},
|
||||
|
||||
|
@ -142,11 +143,11 @@
|
|||
return (key === undefined) ? metadata : metadata[key];
|
||||
},
|
||||
_prefixFieldID: function (fieldID) {
|
||||
return 'Drupal.edit.metadata.' + fieldID;
|
||||
return 'Drupal.quickedit.metadata.' + fieldID;
|
||||
},
|
||||
_unprefixFieldID: function (fieldID) {
|
||||
// Strip "Drupal.edit.metadata.", which is 21 characters long.
|
||||
return fieldID.substring(21);
|
||||
// Strip "Drupal.quickedit.metadata.", which is 26 characters long.
|
||||
return fieldID.substring(26);
|
||||
},
|
||||
intersection: function (fieldIDs) {
|
||||
var prefixedFieldIDs = _.map(fieldIDs, this._prefixFieldID);
|
||||
|
@ -156,15 +157,15 @@
|
|||
}
|
||||
};
|
||||
|
||||
// Clear the Edit metadata cache whenever the current user's set of permissions
|
||||
// changes.
|
||||
var permissionsHashKey = Drupal.edit.metadata._prefixFieldID('permissionsHash');
|
||||
// Clear the Quick Edit metadata cache whenever the current user's set of
|
||||
// permissions changes.
|
||||
var permissionsHashKey = Drupal.quickedit.metadata._prefixFieldID('permissionsHash');
|
||||
var permissionsHashValue = storage.getItem(permissionsHashKey);
|
||||
var permissionsHash = drupalSettings.user.permissionsHash;
|
||||
if (permissionsHashValue !== permissionsHash) {
|
||||
if (typeof permissionsHash === 'string') {
|
||||
_.chain(storage).keys().each(function (key) {
|
||||
if (key.substring(0, 21) === 'Drupal.edit.metadata.') {
|
||||
if (key.substring(0, 26) === 'Drupal.quickedit.metadata.') {
|
||||
storage.removeItem(key);
|
||||
}
|
||||
});
|
||||
|
@ -173,20 +174,20 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Detect contextual links on entities annotated by Edit; queue these to be
|
||||
* processed.
|
||||
* Detect contextual links on entities annotated by Quick Edit; queue these to
|
||||
* be processed.
|
||||
*/
|
||||
$(document).on('drupalContextualLinkAdded', function (event, data) {
|
||||
if (data.$region.is('[data-edit-entity-id]')) {
|
||||
if (data.$region.is('[data-quickedit-entity-id]')) {
|
||||
// If the contextual link is cached on the client side, an entity instance
|
||||
// will not yet have been assigned. So assign one.
|
||||
if (!data.$region.is('[data-edit-entity-instance-id]')) {
|
||||
data.$region.once('edit');
|
||||
if (!data.$region.is('[data-quickedit-entity-instance-id]')) {
|
||||
data.$region.once('quickedit');
|
||||
processEntity(data.$region.get(0));
|
||||
}
|
||||
var contextualLink = {
|
||||
entityID: data.$region.attr('data-edit-entity-id'),
|
||||
entityInstanceID: data.$region.attr('data-edit-entity-instance-id'),
|
||||
entityID: data.$region.attr('data-quickedit-entity-id'),
|
||||
entityInstanceID: data.$region.attr('data-quickedit-entity-instance-id'),
|
||||
el: data.$el[0],
|
||||
region: data.$region[0]
|
||||
};
|
||||
|
@ -211,22 +212,22 @@
|
|||
}
|
||||
|
||||
/**
|
||||
* Initialize the Edit app.
|
||||
* Initialize the Quick Edit app.
|
||||
*
|
||||
* @param DOM bodyElement
|
||||
* This document's body element.
|
||||
*/
|
||||
function initEdit(bodyElement) {
|
||||
Drupal.edit.collections.entities = new Drupal.edit.EntityCollection();
|
||||
Drupal.edit.collections.fields = new Drupal.edit.FieldCollection();
|
||||
function initQuickEdit(bodyElement) {
|
||||
Drupal.quickedit.collections.entities = new Drupal.quickedit.EntityCollection();
|
||||
Drupal.quickedit.collections.fields = new Drupal.quickedit.FieldCollection();
|
||||
|
||||
// Instantiate AppModel (application state) and AppView, which is the
|
||||
// controller of the whole in-place editing experience.
|
||||
Drupal.edit.app = new Drupal.edit.AppView({
|
||||
Drupal.quickedit.app = new Drupal.quickedit.AppView({
|
||||
el: bodyElement,
|
||||
model: new Drupal.edit.AppModel(),
|
||||
entitiesCollection: Drupal.edit.collections.entities,
|
||||
fieldsCollection: Drupal.edit.collections.fields
|
||||
model: new Drupal.quickedit.AppModel(),
|
||||
entitiesCollection: Drupal.quickedit.collections.entities,
|
||||
fieldsCollection: Drupal.quickedit.collections.fields
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -234,11 +235,11 @@
|
|||
* Assigns the entity an instance ID.
|
||||
*
|
||||
* @param DOM entityElement.
|
||||
* A Drupal Entity API entity's DOM element with a data-edit-entity-id
|
||||
* A Drupal Entity API entity's DOM element with a data-quickedit-entity-id
|
||||
* attribute.
|
||||
*/
|
||||
function processEntity(entityElement) {
|
||||
var entityID = entityElement.getAttribute('data-edit-entity-id');
|
||||
var entityID = entityElement.getAttribute('data-quickedit-entity-id');
|
||||
if (!entityInstancesTracker.hasOwnProperty(entityID)) {
|
||||
entityInstancesTracker[entityID] = 0;
|
||||
}
|
||||
|
@ -248,22 +249,24 @@
|
|||
|
||||
// Set the calculated entity instance ID for this element.
|
||||
var entityInstanceID = entityInstancesTracker[entityID];
|
||||
entityElement.setAttribute('data-edit-entity-instance-id', entityInstanceID);
|
||||
entityElement.setAttribute('data-quickedit-entity-instance-id', entityInstanceID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the field's metadata; queue or initialize it (if EntityModel exists).
|
||||
*
|
||||
* @param DOM fieldElement
|
||||
* A Drupal Field API field's DOM element with a data-edit-field-id attribute.
|
||||
* A Drupal Field API field's DOM element with a data-quickedit-field-id
|
||||
* attribute.
|
||||
*/
|
||||
function processField(fieldElement) {
|
||||
var metadata = Drupal.edit.metadata;
|
||||
var fieldID = fieldElement.getAttribute('data-edit-field-id');
|
||||
var metadata = Drupal.quickedit.metadata;
|
||||
var fieldID = fieldElement.getAttribute('data-quickedit-field-id');
|
||||
var entityID = extractEntityID(fieldID);
|
||||
// Figure out the instance ID by looking at the ancestor [data-edit-entity-id]
|
||||
// element's data-edit-entity-instance-id attribute.
|
||||
var entityElementSelector = '[data-edit-entity-id="' + entityID + '"]';
|
||||
// Figure out the instance ID by looking at the ancestor
|
||||
// [data-quickedit-entity-id] element's data-quickedit-entity-instance-id
|
||||
// attribute.
|
||||
var entityElementSelector = '[data-quickedit-entity-id="' + entityID + '"]';
|
||||
var entityElement = $(fieldElement).closest(entityElementSelector);
|
||||
// In the case of a full entity view page, the entity title is rendered
|
||||
// outside of "the entity DOM node": it's rendered as the page title. So in
|
||||
|
@ -273,7 +276,7 @@
|
|||
}
|
||||
var entityInstanceID = entityElement
|
||||
.get(0)
|
||||
.getAttribute('data-edit-entity-instance-id');
|
||||
.getAttribute('data-quickedit-entity-instance-id');
|
||||
|
||||
// Early-return if metadata for this field is missing.
|
||||
if (!metadata.has(fieldID)) {
|
||||
|
@ -292,7 +295,7 @@
|
|||
|
||||
// If an EntityModel for this field already exists (and hence also a "Quick
|
||||
// edit" contextual link), then initialize it immediately.
|
||||
if (Drupal.edit.collections.entities.findWhere({ entityID: entityID, entityInstanceID: entityInstanceID })) {
|
||||
if (Drupal.quickedit.collections.entities.findWhere({ entityID: entityID, entityInstanceID: entityInstanceID })) {
|
||||
initializeField(fieldElement, fieldID, entityID, entityInstanceID);
|
||||
}
|
||||
// Otherwise: queue the field. It is now available to be set up when its
|
||||
|
@ -315,25 +318,25 @@
|
|||
* The field's entity's instance ID.
|
||||
*/
|
||||
function initializeField(fieldElement, fieldID, entityID, entityInstanceID) {
|
||||
var entity = Drupal.edit.collections.entities.findWhere({
|
||||
var entity = Drupal.quickedit.collections.entities.findWhere({
|
||||
entityID: entityID,
|
||||
entityInstanceID: entityInstanceID
|
||||
});
|
||||
|
||||
$(fieldElement).addClass('edit-field');
|
||||
$(fieldElement).addClass('quickedit-field');
|
||||
|
||||
// The FieldModel stores the state of an in-place editable entity field.
|
||||
var field = new Drupal.edit.FieldModel({
|
||||
var field = new Drupal.quickedit.FieldModel({
|
||||
el: fieldElement,
|
||||
fieldID: fieldID,
|
||||
id: fieldID + '[' + entity.get('entityInstanceID') + ']',
|
||||
entity: entity,
|
||||
metadata: Drupal.edit.metadata.get(fieldID),
|
||||
acceptStateChange: _.bind(Drupal.edit.app.acceptEditorStateChange, Drupal.edit.app)
|
||||
metadata: Drupal.quickedit.metadata.get(fieldID),
|
||||
acceptStateChange: _.bind(Drupal.quickedit.app.acceptEditorStateChange, Drupal.quickedit.app)
|
||||
});
|
||||
|
||||
// Track all fields on the page.
|
||||
Drupal.edit.collections.fields.add(field);
|
||||
Drupal.quickedit.collections.fields.add(field);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,11 +354,11 @@
|
|||
var fieldElementsWithoutMetadata = _.pluck(fieldsMetadataQueue, 'el');
|
||||
var entityIDs = _.uniq(_.pluck(fieldsMetadataQueue, 'entityID'), true);
|
||||
// Ensure we only request entityIDs for which we don't have metadata yet.
|
||||
entityIDs = _.difference(entityIDs, Drupal.edit.metadata.intersection(entityIDs));
|
||||
entityIDs = _.difference(entityIDs, Drupal.quickedit.metadata.intersection(entityIDs));
|
||||
fieldsMetadataQueue = [];
|
||||
|
||||
$.ajax({
|
||||
url: Drupal.url('edit/metadata'),
|
||||
url: Drupal.url('quickedit/metadata'),
|
||||
type: 'POST',
|
||||
data: {
|
||||
'fields[]': fieldIDs,
|
||||
|
@ -365,7 +368,7 @@
|
|||
success: function (results) {
|
||||
// Store the metadata.
|
||||
_.each(results, function (fieldMetadata, fieldID) {
|
||||
Drupal.edit.metadata.add(fieldID, fieldMetadata);
|
||||
Drupal.quickedit.metadata.add(fieldID, fieldMetadata);
|
||||
});
|
||||
|
||||
callback(fieldElementsWithoutMetadata);
|
||||
|
@ -385,10 +388,10 @@
|
|||
* have been inserted into the DOM. i.e. they may still be loading.
|
||||
*/
|
||||
function loadMissingEditors(callback) {
|
||||
var loadedEditors = _.keys(Drupal.edit.editors);
|
||||
var loadedEditors = _.keys(Drupal.quickedit.editors);
|
||||
var missingEditors = [];
|
||||
Drupal.edit.collections.fields.each(function (fieldModel) {
|
||||
var metadata = Drupal.edit.metadata.get(fieldModel.get('fieldID'));
|
||||
Drupal.quickedit.collections.fields.each(function (fieldModel) {
|
||||
var metadata = Drupal.quickedit.metadata.get(fieldModel.get('fieldID'));
|
||||
if (metadata.access && _.indexOf(loadedEditors, metadata.editor) === -1) {
|
||||
missingEditors.push(metadata.editor);
|
||||
}
|
||||
|
@ -400,13 +403,13 @@
|
|||
|
||||
// @todo Simplify this once https://drupal.org/node/1533366 lands.
|
||||
// @see https://drupal.org/node/2029999.
|
||||
var id = 'edit-load-editors';
|
||||
var id = 'quickedit-load-editors';
|
||||
// Create a temporary element to be able to use Drupal.ajax.
|
||||
var $el = $('<div id="' + id + '" class="element-hidden"></div>').appendTo('body');
|
||||
// Create a Drupal.ajax instance to load the form.
|
||||
var loadEditorsAjax = new Drupal.ajax(id, $el, {
|
||||
url: Drupal.url('edit/attachments'),
|
||||
event: 'edit-internal.edit',
|
||||
url: Drupal.url('quickedit/attachments'),
|
||||
event: 'quickedit-internal.quickedit',
|
||||
submit: { 'editors[]': missingEditors },
|
||||
// No progress indicator.
|
||||
progress: { type: null }
|
||||
|
@ -417,12 +420,12 @@
|
|||
loadEditorsAjax.commands.insert = function (ajax, response, status) {
|
||||
_.defer(callback);
|
||||
realInsert(ajax, response, status);
|
||||
$el.off('edit-internal.edit');
|
||||
$el.off('quickedit-internal.quickedit');
|
||||
$el.remove();
|
||||
};
|
||||
// Trigger the AJAX request, which will should return AJAX commands to insert
|
||||
// any missing attachments.
|
||||
$el.trigger('edit-internal.edit');
|
||||
$el.trigger('quickedit-internal.quickedit');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,11 +433,11 @@
|
|||
*
|
||||
* @param Object contextualLink
|
||||
* An object with the following properties:
|
||||
* - String entityID: an Edit entity identifier, e.g. "node/1" or
|
||||
* - String entityID: a Quick Edit entity identifier, e.g. "node/1" or
|
||||
* "custom_block/5".
|
||||
* - String entityInstanceID: an Edit entity instance identifier, e.g. 0, 1
|
||||
* or n (depending on whether it's the first, second, or n+1st instance of
|
||||
* this entity).
|
||||
* - String entityInstanceID: a Quick Edit entity instance identifier,
|
||||
* e.g. 0, 1 or n (depending on whether it's the first, second, or n+1st
|
||||
* instance of this entity).
|
||||
* - DOM el: element pointing to the contextual links placeholder for this
|
||||
* entity.
|
||||
* - DOM region: element pointing to the contextual region for this entity.
|
||||
|
@ -446,7 +449,7 @@
|
|||
* Returns false otherwise.
|
||||
*/
|
||||
function initializeEntityContextualLink(contextualLink) {
|
||||
var metadata = Drupal.edit.metadata;
|
||||
var metadata = Drupal.quickedit.metadata;
|
||||
// Check if the user has permission to edit at least one of them.
|
||||
function hasFieldWithPermission(fieldIDs) {
|
||||
for (var i = 0; i < fieldIDs.length; i++) {
|
||||
|
@ -478,17 +481,17 @@
|
|||
// the current user may edit in-place; instantiate EntityModel,
|
||||
// EntityDecorationView and ContextualLinkView.
|
||||
else if (hasFieldWithPermission(fieldIDs)) {
|
||||
var entityModel = new Drupal.edit.EntityModel({
|
||||
var entityModel = new Drupal.quickedit.EntityModel({
|
||||
el: contextualLink.region,
|
||||
entityID: contextualLink.entityID,
|
||||
entityInstanceID: contextualLink.entityInstanceID,
|
||||
id: contextualLink.entityID + '[' + contextualLink.entityInstanceID + ']',
|
||||
label: Drupal.edit.metadata.get(contextualLink.entityID, 'label')
|
||||
label: Drupal.quickedit.metadata.get(contextualLink.entityID, 'label')
|
||||
});
|
||||
Drupal.edit.collections.entities.add(entityModel);
|
||||
Drupal.quickedit.collections.entities.add(entityModel);
|
||||
// Create an EntityDecorationView associated with the root DOM node of the
|
||||
// entity.
|
||||
var entityDecorationView = new Drupal.edit.EntityDecorationView({
|
||||
var entityDecorationView = new Drupal.quickedit.EntityDecorationView({
|
||||
el: contextualLink.region,
|
||||
model: entityModel
|
||||
});
|
||||
|
@ -504,10 +507,10 @@
|
|||
// to get a one-time use version of the function.
|
||||
var initContextualLink = _.once(function () {
|
||||
var $links = $(contextualLink.el).find('.contextual-links');
|
||||
var contextualLinkView = new Drupal.edit.ContextualLinkView($.extend({
|
||||
el: $('<li class="quick-edit"><a href="" role="button" aria-pressed="false"></a></li>').prependTo($links),
|
||||
var contextualLinkView = new Drupal.quickedit.ContextualLinkView($.extend({
|
||||
el: $('<li class="quickedit"><a href="" role="button" aria-pressed="false"></a></li>').prependTo($links),
|
||||
model: entityModel,
|
||||
appModel: Drupal.edit.app.model
|
||||
appModel: Drupal.quickedit.app.model
|
||||
}, options));
|
||||
entityModel.set('contextualLinkView', contextualLinkView);
|
||||
});
|
||||
|
@ -543,9 +546,9 @@
|
|||
* The context within which to delete.
|
||||
*/
|
||||
function deleteContainedModelsAndQueues($context) {
|
||||
$context.find('[data-edit-entity-id]').addBack('[data-edit-entity-id]').each(function (index, entityElement) {
|
||||
$context.find('[data-quickedit-entity-id]').addBack('[data-quickedit-entity-id]').each(function (index, entityElement) {
|
||||
// Delete entity model.
|
||||
var entityModel = Drupal.edit.collections.entities.findWhere({el: entityElement});
|
||||
var entityModel = Drupal.quickedit.collections.entities.findWhere({el: entityElement});
|
||||
if (entityModel) {
|
||||
var contextualLinkView = entityModel.get('contextualLinkView');
|
||||
contextualLinkView.undelegateEvents();
|
||||
|
@ -563,9 +566,9 @@
|
|||
contextualLinksQueue = _.filter(contextualLinksQueue, hasOtherRegion);
|
||||
});
|
||||
|
||||
$context.find('[data-edit-field-id]').addBack('[data-edit-field-id]').each(function (index, fieldElement) {
|
||||
$context.find('[data-quickedit-field-id]').addBack('[data-quickedit-field-id]').each(function (index, fieldElement) {
|
||||
// Delete field models.
|
||||
Drupal.edit.collections.fields.chain()
|
||||
Drupal.quickedit.collections.fields.chain()
|
||||
.filter(function (fieldModel) { return fieldModel.get('el') === fieldElement; })
|
||||
.invoke('destroy');
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* @file
|
||||
* Provides overridable theme functions for all of Edit's client-side HTML.
|
||||
* Provides overridable theme functions for all of Quick Edit's client-side HTML.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
@ -8,7 +8,7 @@
|
|||
"use strict";
|
||||
|
||||
/**
|
||||
* Theme function for a "backstage" for the Edit module.
|
||||
* Theme function for a "backstage" for the Quick Edit module.
|
||||
*
|
||||
* @param Object settings
|
||||
* An object with the following keys:
|
||||
|
@ -16,14 +16,14 @@
|
|||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editBackstage = function (settings) {
|
||||
Drupal.theme.quickeditBackstage = function (settings) {
|
||||
var html = '';
|
||||
html += '<div id="' + settings.id + '" />';
|
||||
return html;
|
||||
};
|
||||
|
||||
/**
|
||||
* Theme function for a toolbar container of the Edit module.
|
||||
* Theme function for a toolbar container of the Quick Edit module.
|
||||
*
|
||||
* @param Object settings
|
||||
* An object with the following keys:
|
||||
|
@ -31,21 +31,21 @@
|
|||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editEntityToolbar = function (settings) {
|
||||
Drupal.theme.quickeditEntityToolbar = function (settings) {
|
||||
var html = '';
|
||||
html += '<div id="' + settings.id + '" class="edit edit-toolbar-container clearfix">';
|
||||
html += '<i class="edit-toolbar-pointer"></i>';
|
||||
html += '<div class="edit-toolbar-content">';
|
||||
html += '<div class="edit-toolbar edit-toolbar-entity clearfix icon icon-pencil">';
|
||||
html += '<div class="edit-toolbar-label" />';
|
||||
html += '<div id="' + settings.id + '" class="quickedit quickedit-toolbar-container clearfix">';
|
||||
html += '<i class="quickedit-toolbar-pointer"></i>';
|
||||
html += '<div class="quickedit-toolbar-content">';
|
||||
html += '<div class="quickedit-toolbar quickedit-toolbar-entity clearfix icon icon-pencil">';
|
||||
html += '<div class="quickedit-toolbar-label" />';
|
||||
html += '</div>';
|
||||
html += '<div class="edit-toolbar edit-toolbar-field clearfix" />';
|
||||
html += '</div><div class="edit-toolbar-lining"></div></div>';
|
||||
html += '<div class="quickedit-toolbar quickedit-toolbar-field clearfix" />';
|
||||
html += '</div><div class="quickedit-toolbar-lining"></div></div>';
|
||||
return html;
|
||||
};
|
||||
|
||||
/**
|
||||
* Theme function for a toolbar container of the Edit module.
|
||||
* Theme function for a toolbar container of the Quick Edit module.
|
||||
*
|
||||
* @param Object settings
|
||||
* An object with the following keys:
|
||||
|
@ -54,7 +54,7 @@
|
|||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editEntityToolbarLabel = function (settings) {
|
||||
Drupal.theme.quickeditEntityToolbarLabel = function (settings) {
|
||||
return '<span class="field">' + settings.fieldLabel + '</span>' + settings.entityLabel;
|
||||
};
|
||||
|
||||
|
@ -64,12 +64,12 @@
|
|||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editEntityToolbarFence = function () {
|
||||
return '<div id="edit-toolbar-fence" />';
|
||||
Drupal.theme.quickeditEntityToolbarFence = function () {
|
||||
return '<div id="quickedit-toolbar-fence" />';
|
||||
};
|
||||
|
||||
/**
|
||||
* Theme function for a toolbar container of the Edit module.
|
||||
* Theme function for a toolbar container of the Quick Edit module.
|
||||
*
|
||||
* @param settings
|
||||
* An object with the following keys:
|
||||
|
@ -77,38 +77,38 @@
|
|||
* @return
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editFieldToolbar = function (settings) {
|
||||
Drupal.theme.quickeditFieldToolbar = function (settings) {
|
||||
return '<div id="' + settings.id + '" />';
|
||||
};
|
||||
|
||||
/**
|
||||
* Theme function for a toolbar toolgroup of the Edit module.
|
||||
* Theme function for a toolbar toolgroup of the Quick Edit module.
|
||||
*
|
||||
* @param Object settings
|
||||
* An object with the following keys:
|
||||
* - String id: (optional) the id of the toolgroup
|
||||
* - String classes: the class of the toolgroup.
|
||||
* - Array buttons: @see Drupal.theme.prototype.editButtons().
|
||||
* - Array buttons: @see Drupal.theme.quickeditButtons().
|
||||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editToolgroup = function (settings) {
|
||||
Drupal.theme.quickeditToolgroup = function (settings) {
|
||||
// Classes.
|
||||
var classes = (settings.classes || []);
|
||||
classes.unshift('edit-toolgroup');
|
||||
classes.unshift('quickedit-toolgroup');
|
||||
var html = '';
|
||||
html += '<div class="' + classes.join(' ') + '"';
|
||||
if (settings.id) {
|
||||
html += ' id="' + settings.id + '"';
|
||||
}
|
||||
html += '>';
|
||||
html += Drupal.theme('editButtons', { buttons: settings.buttons });
|
||||
html += Drupal.theme('quickeditButtons', { buttons: settings.buttons });
|
||||
html += '</div>';
|
||||
return html;
|
||||
};
|
||||
|
||||
/**
|
||||
* Theme function for buttons of the Edit module.
|
||||
* Theme function for buttons of the Quick Edit module.
|
||||
*
|
||||
* Can be used for the buttons both in the toolbar toolgroups and in the modal.
|
||||
*
|
||||
|
@ -121,7 +121,7 @@
|
|||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editButtons = function (settings) {
|
||||
Drupal.theme.quickeditButtons = function (settings) {
|
||||
var html = '';
|
||||
for (var i = 0; i < settings.buttons.length; i++) {
|
||||
var button = settings.buttons[i];
|
||||
|
@ -144,7 +144,7 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* Theme function for a form container of the Edit module.
|
||||
* Theme function for a form container of the Quick Edit module.
|
||||
*
|
||||
* @param Object settings
|
||||
* An object with the following keys:
|
||||
|
@ -153,10 +153,10 @@
|
|||
* @return String
|
||||
* The corresponding HTML.
|
||||
*/
|
||||
Drupal.theme.editFormContainer = function (settings) {
|
||||
Drupal.theme.quickeditFormContainer = function (settings) {
|
||||
var html = '';
|
||||
html += '<div id="' + settings.id + '" class="edit-form-container">';
|
||||
html += ' <div class="edit-form">';
|
||||
html += '<div id="' + settings.id + '" class="quickedit-form-container">';
|
||||
html += ' <div class="quickedit-form">';
|
||||
html += ' <div class="placeholder">';
|
||||
html += settings.loadingMsg;
|
||||
html += ' </div>';
|
|
@ -1,16 +1,16 @@
|
|||
/**
|
||||
* @file
|
||||
* Provides utility functions for Edit.
|
||||
* Provides utility functions for Quick Edit.
|
||||
*/
|
||||
|
||||
(function ($, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.util = Drupal.edit.util || {};
|
||||
Drupal.quickedit.util = Drupal.quickedit.util || {};
|
||||
|
||||
Drupal.edit.util.constants = {};
|
||||
Drupal.edit.util.constants.transitionEnd = "transitionEnd.edit webkitTransitionEnd.edit transitionend.edit msTransitionEnd.edit oTransitionEnd.edit";
|
||||
Drupal.quickedit.util.constants = {};
|
||||
Drupal.quickedit.util.constants.transitionEnd = "transitionEnd.quickedit webkitTransitionEnd.quickedit transitionend.quickedit msTransitionEnd.quickedit oTransitionEnd.quickedit";
|
||||
|
||||
/**
|
||||
* Converts a field id into a formatted url path.
|
||||
|
@ -19,9 +19,9 @@
|
|||
* The id of an editable field. For example, 'node/1/body/und/full'.
|
||||
* @param String urlFormat
|
||||
* The Controller route for field processing. For example,
|
||||
* '/edit/form/%21entity_type/%21id/%21field_name/%21langcode/%21view_mode'.
|
||||
* '/quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode'.
|
||||
*/
|
||||
Drupal.edit.util.buildUrl = function (id, urlFormat) {
|
||||
Drupal.quickedit.util.buildUrl = function (id, urlFormat) {
|
||||
var parts = id.split('/');
|
||||
return Drupal.formatString(decodeURIComponent(urlFormat), {
|
||||
'!entity_type': parts[0],
|
||||
|
@ -40,11 +40,11 @@
|
|||
* @param String message
|
||||
* The message to use in the modal dialog.
|
||||
*/
|
||||
Drupal.edit.util.networkErrorModal = function (title, message) {
|
||||
Drupal.quickedit.util.networkErrorModal = function (title, message) {
|
||||
var $message = $('<div>' + message + '</div>');
|
||||
var networkErrorModal = Drupal.dialog($message.get(0), {
|
||||
title: title,
|
||||
dialogClass: 'edit-network-error',
|
||||
dialogClass: 'quickedit-network-error',
|
||||
buttons: [
|
||||
{
|
||||
text: Drupal.t('OK'),
|
||||
|
@ -64,7 +64,7 @@
|
|||
networkErrorModal.showModal();
|
||||
};
|
||||
|
||||
Drupal.edit.util.form = {
|
||||
Drupal.quickedit.util.form = {
|
||||
|
||||
/**
|
||||
* Loads a form, calls a callback to insert.
|
||||
|
@ -93,35 +93,35 @@
|
|||
|
||||
// Create a Drupal.ajax instance to load the form.
|
||||
var formLoaderAjax = new Drupal.ajax(fieldID, $el, {
|
||||
url: Drupal.edit.util.buildUrl(fieldID, Drupal.url('edit/form/!entity_type/!id/!field_name/!langcode/!view_mode')),
|
||||
event: 'edit-internal.edit',
|
||||
url: Drupal.quickedit.util.buildUrl(fieldID, Drupal.url('quickedit/form/!entity_type/!id/!field_name/!langcode/!view_mode')),
|
||||
event: 'quickedit-internal.quickedit',
|
||||
submit: {
|
||||
nocssjs: options.nocssjs,
|
||||
reset: options.reset
|
||||
},
|
||||
progress: { type: null }, // No progress indicator.
|
||||
error: function (xhr, url) {
|
||||
$el.off('edit-internal.edit');
|
||||
$el.off('quickedit-internal.quickedit');
|
||||
|
||||
// Show a modal to inform the user of the network error.
|
||||
var fieldLabel = Drupal.edit.metadata.get(fieldID, 'label');
|
||||
var fieldLabel = Drupal.quickedit.metadata.get(fieldID, 'label');
|
||||
var message = Drupal.t('Could not load the form for <q>@field-label</q>, either due to a website problem or a network connection problem.<br>Please try again.', { '@field-label': fieldLabel });
|
||||
Drupal.edit.util.networkErrorModal(Drupal.t('Sorry!'), message);
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Sorry!'), message);
|
||||
|
||||
// Change the state back to "candidate", to allow the user to start
|
||||
// in-place editing of the field again.
|
||||
var fieldModel = Drupal.edit.app.model.get('activeField');
|
||||
var fieldModel = Drupal.quickedit.app.model.get('activeField');
|
||||
fieldModel.set('state', 'candidate');
|
||||
}
|
||||
});
|
||||
// Implement a scoped editFieldForm AJAX command: calls the callback.
|
||||
formLoaderAjax.commands.editFieldForm = function (ajax, response, status) {
|
||||
// Implement a scoped quickeditFieldForm AJAX command: calls the callback.
|
||||
formLoaderAjax.commands.quickeditFieldForm = function (ajax, response, status) {
|
||||
callback(response.data, ajax);
|
||||
$el.off('edit-internal.edit');
|
||||
$el.off('quickedit-internal.quickedit');
|
||||
formLoaderAjax = null;
|
||||
};
|
||||
// This will ensure our scoped editFieldForm AJAX command gets called.
|
||||
$el.trigger('edit-internal.edit');
|
||||
// This will ensure our scoped quickeditFieldForm AJAX command gets called.
|
||||
$el.trigger('quickedit-internal.quickedit');
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -141,7 +141,7 @@
|
|||
var settings = {
|
||||
url: $submit.closest('form').attr('action'),
|
||||
setClick: true,
|
||||
event: 'click.edit',
|
||||
event: 'click.quickedit',
|
||||
progress: { type: null },
|
||||
submit: {
|
||||
nocssjs: options.nocssjs,
|
||||
|
@ -165,10 +165,11 @@
|
|||
* Cleans up the Drupal.ajax instance that is used to save the form.
|
||||
*
|
||||
* @param Drupal.ajax ajax
|
||||
* A Drupal.ajax that was returned by Drupal.edit.form.ajaxifySaving().
|
||||
* A Drupal.ajax instance that was returned by
|
||||
* Drupal.quickedit.form.ajaxifySaving().
|
||||
*/
|
||||
unajaxifySaving: function (ajax) {
|
||||
$(ajax.element).off('click.edit');
|
||||
$(ajax.element).off('click.quickedit');
|
||||
}
|
||||
|
||||
};
|
|
@ -2,7 +2,7 @@
|
|||
* @file
|
||||
* A Backbone View that controls the overall "in-place editing application".
|
||||
*
|
||||
* @see Drupal.edit.AppModel
|
||||
* @see Drupal.quickedit.AppModel
|
||||
*/
|
||||
|
||||
(function ($, _, Backbone, Drupal) {
|
||||
|
@ -14,23 +14,24 @@
|
|||
// edited fields if in-place editing has been canceled and one or more of the
|
||||
// entity's fields were saved to TempStore: one of them may have been changed to
|
||||
// the empty value and hence may have been rerendered as the empty string, which
|
||||
// makes it impossible for Edit to know where to restore the original HTML.
|
||||
// makes it impossible for Quick Edit to know where to restore the original
|
||||
// HTML.
|
||||
var reload = false;
|
||||
|
||||
Drupal.edit.AppView = Backbone.View.extend({
|
||||
Drupal.quickedit.AppView = Backbone.View.extend({
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @param Object options
|
||||
* An object with the following keys:
|
||||
* - Drupal.edit.AppModel model: the application state model
|
||||
* - Drupal.edit.EntityCollection entitiesCollection: all on-page entities
|
||||
* - Drupal.edit.FieldCollection fieldsCollection: all on-page fields
|
||||
* - Drupal.quickedit.AppModel model: the application state model
|
||||
* - Drupal.quickedit.EntityCollection entitiesCollection: all on-page entities
|
||||
* - Drupal.quickedit.FieldCollection fieldsCollection: all on-page fields
|
||||
*/
|
||||
initialize: function (options) {
|
||||
// AppView's configuration for handling states.
|
||||
// @see Drupal.edit.FieldModel.states
|
||||
// @see Drupal.quickedit.FieldModel.states
|
||||
this.activeFieldStates = ['activating', 'active'];
|
||||
this.singleFieldStates = ['highlighted', 'activating', 'active'];
|
||||
this.changedFieldStates = ['changed', 'saving', 'saved', 'invalid'];
|
||||
|
@ -56,10 +57,10 @@
|
|||
/**
|
||||
* Handles setup/teardown and state changes when the active entity changes.
|
||||
*
|
||||
* @param Drupal.edit.EntityModel entityModel
|
||||
* @param Drupal.quickedit.EntityModel entityModel
|
||||
* An instance of the EntityModel class.
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.EntityModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.EntityModel.states.
|
||||
*/
|
||||
appStateChange: function (entityModel, state) {
|
||||
var app = this;
|
||||
|
@ -68,7 +69,7 @@
|
|||
case 'launching':
|
||||
reload = false;
|
||||
// First, create an entity toolbar view.
|
||||
entityToolbarView = new Drupal.edit.EntityToolbarView({
|
||||
entityToolbarView = new Drupal.quickedit.EntityToolbarView({
|
||||
model: entityModel,
|
||||
appModel: this.model
|
||||
});
|
||||
|
@ -117,7 +118,7 @@
|
|||
* The new state.
|
||||
* @param null|Object context
|
||||
* The context that is trying to trigger the state change.
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* The fieldModel to which this change applies.
|
||||
*/
|
||||
acceptEditorStateChange: function (from, to, context, fieldModel) {
|
||||
|
@ -135,7 +136,7 @@
|
|||
// In general, enforce the states sequence. Disallow going back from a
|
||||
// "later" state to an "earlier" state, except in explicitly allowed
|
||||
// cases.
|
||||
if (!Drupal.edit.FieldModel.followsStateSequence(from, to)) {
|
||||
if (!Drupal.quickedit.FieldModel.followsStateSequence(from, to)) {
|
||||
accept = false;
|
||||
// Allow: activating/active -> candidate.
|
||||
// Necessary to stop editing a field.
|
||||
|
@ -244,7 +245,7 @@
|
|||
*
|
||||
* Must happen before the fieldModel's state is changed to 'candidate'.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* The field for which an in-place editor must be set up.
|
||||
*/
|
||||
setupEditor: function (fieldModel) {
|
||||
|
@ -255,8 +256,8 @@
|
|||
var fieldToolbarRoot = entityToolbarView.getToolbarRoot();
|
||||
// Create in-place editor.
|
||||
var editorName = fieldModel.get('metadata').editor;
|
||||
var editorModel = new Drupal.edit.EditorModel();
|
||||
var editorView = new Drupal.edit.editors[editorName]({
|
||||
var editorModel = new Drupal.quickedit.EditorModel();
|
||||
var editorView = new Drupal.quickedit.editors[editorName]({
|
||||
el: $(fieldModel.get('el')),
|
||||
model: editorModel,
|
||||
fieldModel: fieldModel
|
||||
|
@ -265,7 +266,7 @@
|
|||
// Create in-place editor's toolbar for this field — stored inside the
|
||||
// entity toolbar, the entity toolbar will position itself appropriately
|
||||
// above (or below) the edited element.
|
||||
var toolbarView = new Drupal.edit.FieldToolbarView({
|
||||
var toolbarView = new Drupal.quickedit.FieldToolbarView({
|
||||
el: fieldToolbarRoot,
|
||||
model: fieldModel,
|
||||
$editedElement: $(editorView.getEditedElement()),
|
||||
|
@ -275,7 +276,7 @@
|
|||
|
||||
// Create decoration for edited element: padding if necessary, sets classes
|
||||
// on the element to style it according to the current state.
|
||||
var decorationView = new Drupal.edit.FieldDecorationView({
|
||||
var decorationView = new Drupal.quickedit.FieldDecorationView({
|
||||
el: $(editorView.getEditedElement()),
|
||||
model: fieldModel,
|
||||
editorView: editorView
|
||||
|
@ -293,7 +294,7 @@
|
|||
*
|
||||
* Must happen after the fieldModel's state is changed to 'inactive'.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* The field for which an in-place editor must be torn down.
|
||||
*/
|
||||
teardownEditor: function (fieldModel) {
|
||||
|
@ -353,7 +354,7 @@
|
|||
var $unsavedChanges = $('<div>' + Drupal.t('You have unsaved changes') + '</div>');
|
||||
discardDialog = Drupal.dialog($unsavedChanges.get(0), {
|
||||
title: Drupal.t('Discard changes?'),
|
||||
dialogClass: 'edit-discard-modal',
|
||||
dialogClass: 'quickedit-discard-modal',
|
||||
resizable: false,
|
||||
buttons: [
|
||||
{
|
||||
|
@ -390,9 +391,9 @@
|
|||
/**
|
||||
* Reacts to field state changes; tracks global state.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.FieldModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.FieldModel.states.
|
||||
*/
|
||||
editorStateChange: function (fieldModel, state) {
|
||||
var from = fieldModel.previous('state');
|
||||
|
@ -422,7 +423,7 @@
|
|||
/**
|
||||
* Render an updated field (a field whose 'html' attribute changed).
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* The FieldModel whose 'html' attribute changed.
|
||||
* @param String html
|
||||
* The updated 'html' attribute.
|
||||
|
@ -484,7 +485,7 @@
|
|||
/**
|
||||
* Propagates the changes to an updated field to all instances of that field.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel updatedField
|
||||
* @param Drupal.quickedit.FieldModel updatedField
|
||||
* The FieldModel whose 'html' attribute changed.
|
||||
* @param String html
|
||||
* The updated 'html' attribute.
|
||||
|
@ -494,7 +495,7 @@
|
|||
* occurred because of the propagation of changes to another instance of
|
||||
* this field.
|
||||
*
|
||||
* @see Drupal.edit.AppView.renderUpdatedField()
|
||||
* @see Drupal.quickedit.AppView.renderUpdatedField()
|
||||
*/
|
||||
propagateUpdatedField: function (updatedField, html, options) {
|
||||
// Don't propagate field updates that themselves were caused by propagation.
|
||||
|
@ -503,7 +504,7 @@
|
|||
}
|
||||
|
||||
var htmlForOtherViewModes = updatedField.get('htmlForOtherViewModes');
|
||||
Drupal.edit.collections.fields
|
||||
Drupal.quickedit.collections.fields
|
||||
// Find all instances of fields that display the same logical field (same
|
||||
// entity, same field, just a different instance and maybe a different
|
||||
// view mode).
|
||||
|
@ -537,11 +538,11 @@
|
|||
*
|
||||
* This happens when a field was modified, saved and hence rerendered.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* A field that was just added to the collection of fields.
|
||||
*/
|
||||
rerenderedFieldToCandidate: function (fieldModel) {
|
||||
var activeEntity = Drupal.edit.collections.entities.findWhere({isActive: true});
|
||||
var activeEntity = Drupal.quickedit.collections.entities.findWhere({isActive: true});
|
||||
|
||||
// Early-return if there is no active entity.
|
||||
if (!activeEntity) {
|
||||
|
@ -559,7 +560,7 @@
|
|||
* EntityModel Collection change handler, called on change:isActive, enforces
|
||||
* a single active entity.
|
||||
*
|
||||
* @param Drupal.edit.EntityModel
|
||||
* @param Drupal.quickedit.EntityModel
|
||||
* The entityModel instance whose active state has changed.
|
||||
*/
|
||||
enforceSingleActiveEntity: function (changedEntityModel) {
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.ContextualLinkView = Backbone.View.extend({
|
||||
Drupal.quickedit.ContextualLinkView = Backbone.View.extend({
|
||||
|
||||
events: function () {
|
||||
// Prevents delay and simulated mouse events.
|
||||
|
@ -29,8 +29,8 @@
|
|||
*
|
||||
* @param Object options
|
||||
* An object with the following keys:
|
||||
* - Drupal.edit.EntityModel model: the associated entity's model
|
||||
* - Drupal.edit.AppModel appModel: the application state model
|
||||
* - Drupal.quickedit.EntityModel model: the associated entity's model
|
||||
* - Drupal.quickedit.AppModel appModel: the application state model
|
||||
* - strings: the strings for the "Quick edit" link
|
||||
*/
|
||||
initialize: function (options) {
|
|
@ -13,12 +13,12 @@
|
|||
* Specific in-place editor implementations should subclass (extend) this View
|
||||
* and override whichever method they deem necessary to override.
|
||||
*
|
||||
* Look at Drupal.edit.editors.form and Drupal.edit.editors.plain_text for
|
||||
* examples.
|
||||
* Look at Drupal.quickedit.editors.form and
|
||||
* Drupal.quickedit.editors.plain_text for examples.
|
||||
*
|
||||
* @see Drupal.edit.EditorModel
|
||||
* @see Drupal.quickedit.EditorModel
|
||||
*/
|
||||
Drupal.edit.EditorView = Backbone.View.extend({
|
||||
Drupal.quickedit.EditorView = Backbone.View.extend({
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -29,14 +29,14 @@
|
|||
*
|
||||
* If you override this method, you should call this method (the parent
|
||||
* class' initialize()) first, like this:
|
||||
* Drupal.edit.EditorView.prototype.initialize.call(this, options);
|
||||
* Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
|
||||
*
|
||||
* For an example, @see Drupal.edit.editors.plain_text.
|
||||
* For an example, @see Drupal.quickedit.editors.plain_text.
|
||||
*
|
||||
* @param Object options
|
||||
* An object with the following keys:
|
||||
* - Drupal.edit.EditorModel model: the in-place editor state model
|
||||
* - Drupal.edit.FieldModel fieldModel: the field model
|
||||
* - Drupal.quickedit.EditorModel model: the in-place editor state model
|
||||
* - Drupal.quickedit.FieldModel fieldModel: the field model
|
||||
*/
|
||||
initialize: function (options) {
|
||||
this.fieldModel = options.fieldModel;
|
||||
|
@ -58,12 +58,12 @@
|
|||
*
|
||||
* For some single cardinality fields, it may be necessary or useful to
|
||||
* not in-place edit (and hence decorate) the DOM element with the
|
||||
* data-edit-field-id attribute (which is the field's wrapper), but a specific
|
||||
* element within the field's wrapper.
|
||||
* data-quickedit-field-id attribute (which is the field's wrapper), but a
|
||||
* specific element within the field's wrapper.
|
||||
* e.g. using a WYSIWYG editor on a body field should happen on the DOM
|
||||
* element containing the text itself, not on the field wrapper.
|
||||
*
|
||||
* For example, @see Drupal.edit.editors.plain_text.
|
||||
* For example, @see Drupal.quickedit.editors.plain_text.
|
||||
*
|
||||
* @return jQuery
|
||||
* A jQuery-wrapped DOM element.
|
||||
|
@ -73,25 +73,26 @@
|
|||
},
|
||||
|
||||
/**
|
||||
* Returns 3 Edit UI settings that depend on the in-place editor:
|
||||
* Returns 3 Quick Edit UI settings that depend on the in-place editor:
|
||||
* - Boolean padding: indicates whether padding should be applied to the
|
||||
* edited element, to guarantee legibility of text.
|
||||
* - Boolean unifiedToolbar: provides the in-place editor with the ability to
|
||||
* insert its own toolbar UI into Edit's tightly integrated toolbar.
|
||||
* - Boolean fullWidthToolbar: indicates whether Edit's tightly integrated
|
||||
* toolbar should consume the full width of the element, rather than being
|
||||
* just long enough to accommodate a label.
|
||||
* - Boolean unifiedToolbar: provides the in-place editor with the ability
|
||||
* to insert its own toolbar UI into Quick Edit's tightly integrated
|
||||
* toolbar.
|
||||
* - Boolean fullWidthToolbar: indicates whether Quick Edit's tightly
|
||||
* integrated toolbar should consume the full width of the element,
|
||||
* rather than being just long enough to accommodate a label.
|
||||
*/
|
||||
getEditUISettings: function () {
|
||||
getQuickEditUISettings: function () {
|
||||
return { padding: false, unifiedToolbar: false, fullWidthToolbar: false, popup: false };
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines the actions to take given a change of state.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel fieldModel
|
||||
* @param Drupal.quickedit.FieldModel fieldModel
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.FieldModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.FieldModel.states.
|
||||
*/
|
||||
stateChange: function (fieldModel, state) {
|
||||
var from = fieldModel.previous('state');
|
||||
|
@ -178,7 +179,7 @@
|
|||
save: function () {
|
||||
var fieldModel = this.fieldModel;
|
||||
var editorModel = this.model;
|
||||
var backstageId = 'edit_backstage-' + this.fieldModel.id.replace(/[\/\[\]\_\s]/g, '-');
|
||||
var backstageId = 'quickedit_backstage-' + this.fieldModel.id.replace(/[\/\[\]\_\s]/g, '-');
|
||||
|
||||
function fillAndSubmitForm(value) {
|
||||
var $form = $('#' + backstageId).find('form');
|
||||
|
@ -188,7 +189,7 @@
|
|||
// Don't mess with the node summary.
|
||||
.not('[name$="\\[summary\\]"]').val(value);
|
||||
// Submit the form.
|
||||
$form.find('.edit-form-submit').trigger('click.edit');
|
||||
$form.find('.quickedit-form-submit').trigger('click.quickedit');
|
||||
}
|
||||
|
||||
var formOptions = {
|
||||
|
@ -206,11 +207,11 @@
|
|||
};
|
||||
|
||||
var self = this;
|
||||
Drupal.edit.util.form.load(formOptions, function (form, ajax) {
|
||||
Drupal.quickedit.util.form.load(formOptions, function (form, ajax) {
|
||||
// Create a backstage area for storing forms that are hidden from view
|
||||
// (hence "backstage" — since the editing doesn't happen in the form, it
|
||||
// happens "directly" in the content, the form is only used for saving).
|
||||
var $backstage = $(Drupal.theme('editBackstage', { id: backstageId })).appendTo('body');
|
||||
var $backstage = $(Drupal.theme('quickeditBackstage', { id: backstageId })).appendTo('body');
|
||||
// Hidden forms are stuffed into the backstage container for this field.
|
||||
var $form = $(form).appendTo($backstage);
|
||||
// Disable the browser's HTML5 validation; we only care about server-
|
||||
|
@ -218,17 +219,17 @@
|
|||
// because browsers don't like to set HTML5 validation errors on hidden
|
||||
// forms.)
|
||||
$form.prop('novalidate', true);
|
||||
var $submit = $form.find('.edit-form-submit');
|
||||
self.formSaveAjax = Drupal.edit.util.form.ajaxifySaving(formOptions, $submit);
|
||||
var $submit = $form.find('.quickedit-form-submit');
|
||||
self.formSaveAjax = Drupal.quickedit.util.form.ajaxifySaving(formOptions, $submit);
|
||||
|
||||
function removeHiddenForm() {
|
||||
Drupal.edit.util.form.unajaxifySaving(self.formSaveAjax);
|
||||
Drupal.quickedit.util.form.unajaxifySaving(self.formSaveAjax);
|
||||
delete self.formSaveAjax;
|
||||
$backstage.remove();
|
||||
}
|
||||
|
||||
// Successfully saved.
|
||||
self.formSaveAjax.commands.editFieldFormSaved = function (ajax, response, status) {
|
||||
self.formSaveAjax.commands.quickeditFieldFormSaved = function (ajax, response, status) {
|
||||
removeHiddenForm();
|
||||
// First, transition the state to 'saved'.
|
||||
fieldModel.set('state', 'saved');
|
||||
|
@ -242,18 +243,19 @@
|
|||
};
|
||||
|
||||
// Unsuccessfully saved; validation errors.
|
||||
self.formSaveAjax.commands.editFieldFormValidationErrors = function (ajax, response, status) {
|
||||
self.formSaveAjax.commands.quickeditFieldFormValidationErrors = function (ajax, response, status) {
|
||||
removeHiddenForm();
|
||||
editorModel.set('validationErrors', response.data);
|
||||
fieldModel.set('state', 'invalid');
|
||||
};
|
||||
|
||||
// The editFieldForm AJAX command is only called upon loading the form
|
||||
// for the first time, and when there are validation errors in the form;
|
||||
// Form API then marks which form items have errors. This is useful for
|
||||
// the form-based in-place editor, but pointless for any other: the form
|
||||
// itself won't be visible at all anyway! So, we just ignore it.
|
||||
self.formSaveAjax.commands.editFieldForm = function () {};
|
||||
// The quickeditFieldForm AJAX command is only called upon loading the
|
||||
// form for the first time, and when there are validation errors in the
|
||||
// form; Form API then marks which form items have errors. This is
|
||||
// useful for the form-based in-place editor, but pointless for any
|
||||
// other: the form itself won't be visible at all anyway! So, we just
|
||||
// ignore it.
|
||||
self.formSaveAjax.commands.quickeditFieldForm = function () {};
|
||||
|
||||
fillAndSubmitForm(editorModel.get('currentValue'));
|
||||
});
|
||||
|
@ -265,10 +267,10 @@
|
|||
* Should be called when the state is changed to 'invalid'.
|
||||
*/
|
||||
showValidationErrors: function () {
|
||||
var $errors = $('<div class="edit-validation-errors"></div>')
|
||||
var $errors = $('<div class="quickedit-validation-errors"></div>')
|
||||
.append(this.model.get('validationErrors'));
|
||||
this.getEditedElement()
|
||||
.addClass('edit-validation-error')
|
||||
.addClass('quickedit-validation-error')
|
||||
.after($errors);
|
||||
},
|
||||
|
||||
|
@ -282,8 +284,8 @@
|
|||
*/
|
||||
removeValidationErrors: function () {
|
||||
this.getEditedElement()
|
||||
.removeClass('edit-validation-error')
|
||||
.next('.edit-validation-errors')
|
||||
.removeClass('quickedit-validation-error')
|
||||
.next('.quickedit-validation-errors')
|
||||
.remove();
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.EntityDecorationView = Backbone.View.extend({
|
||||
Drupal.quickedit.EntityDecorationView = Backbone.View.extend({
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -22,7 +22,7 @@
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
render: function () {
|
||||
this.$el.toggleClass('edit-entity-active', this.model.get('isActive'));
|
||||
this.$el.toggleClass('quickedit-entity-active', this.model.get('isActive'));
|
||||
},
|
||||
|
||||
/**
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.EntityToolbarView = Backbone.View.extend({
|
||||
Drupal.quickedit.EntityToolbarView = Backbone.View.extend({
|
||||
|
||||
_fieldToolbarRoot: null,
|
||||
|
||||
|
@ -37,11 +37,11 @@
|
|||
|
||||
// Reposition the entity toolbar as the viewport and the position within the
|
||||
// viewport changes.
|
||||
$(window).on('resize.edit scroll.edit', debounce($.proxy(this.windowChangeHandler, this), 150));
|
||||
$(window).on('resize.quickedit scroll.quickedit', debounce($.proxy(this.windowChangeHandler, this), 150));
|
||||
|
||||
// Adjust the fence placement within which the entity toolbar may be
|
||||
// positioned.
|
||||
$(document).on('drupalViewportOffsetChange.edit', function (event, offsets) {
|
||||
$(document).on('drupalViewportOffsetChange.quickedit', function (event, offsets) {
|
||||
if (that.$fence) {
|
||||
that.$fence.css(offsets);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
|||
// Set the entity toolbar DOM element as the el for this view.
|
||||
var $toolbar = this.buildToolbarEl();
|
||||
this.setElement($toolbar);
|
||||
this._fieldToolbarRoot = $toolbar.find('.edit-toolbar-field').get(0);
|
||||
this._fieldToolbarRoot = $toolbar.find('.quickedit-toolbar-field').get(0);
|
||||
|
||||
// Initial render.
|
||||
this.render();
|
||||
|
@ -63,13 +63,13 @@
|
|||
if (this.model.get('isActive')) {
|
||||
// If the toolbar container doesn't exist, create it.
|
||||
var $body = $('body');
|
||||
if ($body.children('#edit-entity-toolbar').length === 0) {
|
||||
if ($body.children('#quickedit-entity-toolbar').length === 0) {
|
||||
$body.append(this.$el);
|
||||
}
|
||||
// The fence will define a area on the screen that the entity toolbar
|
||||
// will be position within.
|
||||
if ($body.children('#edit-toolbar-fence').length === 0) {
|
||||
this.$fence = $(Drupal.theme('editEntityToolbarFence'))
|
||||
if ($body.children('#quickedit-toolbar-fence').length === 0) {
|
||||
this.$fence = $(Drupal.theme('quickeditEntityToolbarFence'))
|
||||
.css(Drupal.displace())
|
||||
.appendTo($body);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@
|
|||
}
|
||||
|
||||
// The save button text and state varies with the state of the entity model.
|
||||
var $button = this.$el.find('.edit-button.action-save');
|
||||
var $button = this.$el.find('.quickedit-button.action-save');
|
||||
var isDirty = this.model.get('isDirty');
|
||||
// Adjust the save button according to the state of the model.
|
||||
switch (this.model.get('state')) {
|
||||
|
@ -121,8 +121,8 @@
|
|||
this.$fence.remove();
|
||||
|
||||
// Stop listening to additional events.
|
||||
$(window).off('resize.edit scroll.edit');
|
||||
$(document).off('drupalViewportOffsetChange.edit');
|
||||
$(window).off('resize.quickedit scroll.quickedit');
|
||||
$(document).off('drupalViewportOffsetChange.quickedit');
|
||||
|
||||
Backbone.View.prototype.remove.call(this);
|
||||
},
|
||||
|
@ -139,9 +139,9 @@
|
|||
/**
|
||||
* Determines the actions to take given a change of state.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel model
|
||||
* @param Drupal.quickedit.FieldModel model
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.FieldModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.FieldModel.states.
|
||||
*/
|
||||
fieldStateChange: function (model, state) {
|
||||
switch (state) {
|
||||
|
@ -186,19 +186,19 @@
|
|||
break;
|
||||
case 1:
|
||||
// Position against a form container.
|
||||
activeField = Drupal.edit.app.model.get('activeField');
|
||||
of = activeField && activeField.editorView && activeField.editorView.$formContainer && activeField.editorView.$formContainer.find('.edit-form');
|
||||
activeField = Drupal.quickedit.app.model.get('activeField');
|
||||
of = activeField && activeField.editorView && activeField.editorView.$formContainer && activeField.editorView.$formContainer.find('.quickedit-form');
|
||||
break;
|
||||
case 2:
|
||||
// Position against an active field.
|
||||
of = activeField && activeField.editorView && activeField.editorView.getEditedElement();
|
||||
if (activeField && activeField.editorView && activeField.editorView.getEditUISettings().padding) {
|
||||
if (activeField && activeField.editorView && activeField.editorView.getQuickEditUISettings().padding) {
|
||||
horizontalPadding = 5;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// Position against a highlighted field.
|
||||
highlightedField = Drupal.edit.app.model.get('highlightedField');
|
||||
highlightedField = Drupal.quickedit.app.model.get('highlightedField');
|
||||
of = highlightedField && highlightedField.editorView && highlightedField.editorView.getEditedElement();
|
||||
delay = 250;
|
||||
break;
|
||||
|
@ -234,13 +234,13 @@
|
|||
function refinePosition(view, suggested, info) {
|
||||
// Determine if the pointer should be on the top or bottom.
|
||||
var isBelow = suggested.top > info.target.top;
|
||||
info.element.element.toggleClass('edit-toolbar-pointer-top', isBelow);
|
||||
info.element.element.toggleClass('quickedit-toolbar-pointer-top', isBelow);
|
||||
// Don't position the toolbar past the first or last editable field if
|
||||
// the entity is the target.
|
||||
if (view.$entity[0] === info.target.element[0]) {
|
||||
// Get the first or last field according to whether the toolbar is above
|
||||
// or below the entity.
|
||||
var $field = view.$entity.find('.edit-editable').eq((isBelow) ? -1 : 0);
|
||||
var $field = view.$entity.find('.quickedit-editable').eq((isBelow) ? -1 : 0);
|
||||
if ($field.length > 0) {
|
||||
suggested.top = (isBelow) ? ($field.offset().top + $field.outerHeight(true)) : $field.offset().top - info.element.element.outerHeight(true);
|
||||
}
|
||||
|
@ -339,27 +339,27 @@
|
|||
* Builds the entity toolbar HTML; attaches to DOM; sets starting position.
|
||||
*/
|
||||
buildToolbarEl: function () {
|
||||
var $toolbar = $(Drupal.theme('editEntityToolbar', {
|
||||
id: 'edit-entity-toolbar'
|
||||
var $toolbar = $(Drupal.theme('quickeditEntityToolbar', {
|
||||
id: 'quickedit-entity-toolbar'
|
||||
}));
|
||||
|
||||
$toolbar
|
||||
.find('.edit-toolbar-entity')
|
||||
.find('.quickedit-toolbar-entity')
|
||||
// Append the "ops" toolgroup into the toolbar.
|
||||
.prepend(Drupal.theme('editToolgroup', {
|
||||
.prepend(Drupal.theme('quickeditToolgroup', {
|
||||
classes: ['ops'],
|
||||
buttons: [
|
||||
{
|
||||
label: Drupal.t('Save'),
|
||||
type: 'submit',
|
||||
classes: 'action-save edit-button icon',
|
||||
classes: 'action-save quickedit-button icon',
|
||||
attributes: {
|
||||
'aria-hidden': true
|
||||
}
|
||||
},
|
||||
{
|
||||
label: Drupal.t('Close'),
|
||||
classes: 'action-cancel edit-button icon icon-close icon-only'
|
||||
classes: 'action-cancel quickedit-button icon icon-close icon-only'
|
||||
}
|
||||
]
|
||||
}));
|
||||
|
@ -394,20 +394,20 @@
|
|||
var entityLabel = this.model.get('label');
|
||||
|
||||
// Label of an active field, if it exists.
|
||||
var activeField = Drupal.edit.app.model.get('activeField');
|
||||
var activeField = Drupal.quickedit.app.model.get('activeField');
|
||||
var activeFieldLabel = activeField && activeField.get('metadata').label;
|
||||
// Label of a highlighted field, if it exists.
|
||||
var highlightedField = Drupal.edit.app.model.get('highlightedField');
|
||||
var highlightedField = Drupal.quickedit.app.model.get('highlightedField');
|
||||
var highlightedFieldLabel = highlightedField && highlightedField.get('metadata').label;
|
||||
// The label is constructed in a priority order.
|
||||
if (activeFieldLabel) {
|
||||
label = Drupal.theme('editEntityToolbarLabel', {
|
||||
label = Drupal.theme('quickeditEntityToolbarLabel', {
|
||||
entityLabel: entityLabel,
|
||||
fieldLabel: activeFieldLabel
|
||||
});
|
||||
}
|
||||
else if (highlightedFieldLabel) {
|
||||
label = Drupal.theme('editEntityToolbarLabel', {
|
||||
label = Drupal.theme('quickeditEntityToolbarLabel', {
|
||||
entityLabel: entityLabel,
|
||||
fieldLabel: highlightedFieldLabel
|
||||
});
|
||||
|
@ -417,7 +417,7 @@
|
|||
}
|
||||
|
||||
this.$el
|
||||
.find('.edit-toolbar-label')
|
||||
.find('.quickedit-toolbar-label')
|
||||
.html(label);
|
||||
},
|
||||
|
||||
|
@ -456,7 +456,7 @@
|
|||
* The toolgroup DOM element.
|
||||
*/
|
||||
_find: function (toolgroup) {
|
||||
return this.$el.find('.edit-toolbar .edit-toolgroup.' + toolgroup);
|
||||
return this.$el.find('.quickedit-toolbar .quickedit-toolgroup.' + toolgroup);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -466,7 +466,7 @@
|
|||
* A toolgroup name.
|
||||
*/
|
||||
show: function (toolgroup) {
|
||||
this.$el.removeClass('edit-animate-invisible');
|
||||
this.$el.removeClass('quickedit-animate-invisible');
|
||||
}
|
||||
|
||||
});
|
|
@ -7,16 +7,16 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.FieldDecorationView = Backbone.View.extend({
|
||||
Drupal.quickedit.FieldDecorationView = Backbone.View.extend({
|
||||
|
||||
_widthAttributeIsEmpty: null,
|
||||
|
||||
events: {
|
||||
'mouseenter.edit': 'onMouseEnter',
|
||||
'mouseleave.edit': 'onMouseLeave',
|
||||
'mouseenter.quickedit': 'onMouseEnter',
|
||||
'mouseleave.quickedit': 'onMouseLeave',
|
||||
'click': 'onClick',
|
||||
'tabIn.edit': 'onMouseEnter',
|
||||
'tabOut.edit': 'onMouseLeave'
|
||||
'tabIn.quickedit': 'onMouseEnter',
|
||||
'tabOut.quickedit': 'onMouseLeave'
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@
|
|||
*
|
||||
* @param Object options
|
||||
* An object with the following keys:
|
||||
* - Drupal.edit.EditorView editorView: the editor object view.
|
||||
* - Drupal.quickedit.EditorView editorView: the editor object view.
|
||||
*/
|
||||
initialize: function (options) {
|
||||
this.editorView = options.editorView;
|
||||
|
@ -46,9 +46,9 @@
|
|||
/**
|
||||
* Determines the actions to take given a change of state.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel model
|
||||
* @param Drupal.quickedit.FieldModel model
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.FieldModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.FieldModel.states.
|
||||
*/
|
||||
stateChange: function (model, state) {
|
||||
var from = model.previous('state');
|
||||
|
@ -80,7 +80,7 @@
|
|||
if (from !== 'activating') {
|
||||
this.prepareEdit();
|
||||
}
|
||||
if (this.editorView.getEditUISettings().padding) {
|
||||
if (this.editorView.getQuickEditUISettings().padding) {
|
||||
this._pad();
|
||||
}
|
||||
break;
|
||||
|
@ -102,7 +102,7 @@
|
|||
* changed and stored before by the user (i.e. remotely, stored in TempStore).
|
||||
*/
|
||||
renderChanged: function () {
|
||||
this.$el.toggleClass('edit-changed', this.model.get('isChanged') || this.model.get('inTempStore'));
|
||||
this.$el.toggleClass('quickedit-changed', this.model.get('isChanged') || this.model.get('inTempStore'));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -142,14 +142,14 @@
|
|||
* Adds classes used to indicate an elements editable state.
|
||||
*/
|
||||
decorate: function () {
|
||||
this.$el.addClass('edit-candidate edit-editable');
|
||||
this.$el.addClass('quickedit-candidate quickedit-editable');
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes classes used to indicate an elements editable state.
|
||||
*/
|
||||
undecorate: function () {
|
||||
this.$el.removeClass('edit-candidate edit-editable edit-highlighted edit-editing');
|
||||
this.$el.removeClass('quickedit-candidate quickedit-editable quickedit-highlighted quickedit-editing');
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -159,26 +159,26 @@
|
|||
// Animations.
|
||||
var that = this;
|
||||
// Use a timeout to grab the next available animation frame.
|
||||
that.$el.addClass('edit-highlighted');
|
||||
that.$el.addClass('quickedit-highlighted');
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the class that indicates that an element is highlighted.
|
||||
*/
|
||||
stopHighlight: function () {
|
||||
this.$el.removeClass('edit-highlighted');
|
||||
this.$el.removeClass('quickedit-highlighted');
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the class that indicates that an element as editable.
|
||||
*/
|
||||
prepareEdit: function () {
|
||||
this.$el.addClass('edit-editing');
|
||||
this.$el.addClass('quickedit-editing');
|
||||
|
||||
// Allow the field to be styled differently while editing in a pop-up
|
||||
// in-place editor.
|
||||
if (this.editorView.getEditUISettings().popup) {
|
||||
this.$el.addClass('edit-editor-is-popup');
|
||||
if (this.editorView.getQuickEditUISettings().popup) {
|
||||
this.$el.addClass('quickedit-editor-is-popup');
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -189,15 +189,15 @@
|
|||
* again available to be edited.
|
||||
*/
|
||||
stopEdit: function () {
|
||||
this.$el.removeClass('edit-highlighted edit-editing');
|
||||
this.$el.removeClass('quickedit-highlighted quickedit-editing');
|
||||
|
||||
// Done editing in a pop-up in-place editor; remove the class.
|
||||
if (this.editorView.getEditUISettings().popup) {
|
||||
this.$el.removeClass('edit-editor-is-popup');
|
||||
if (this.editorView.getQuickEditUISettings().popup) {
|
||||
this.$el.removeClass('quickedit-editor-is-popup');
|
||||
}
|
||||
|
||||
// Make the other editors show up again.
|
||||
$('.edit-candidate').addClass('edit-editable');
|
||||
$('.quickedit-candidate').addClass('quickedit-editable');
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -205,7 +205,7 @@
|
|||
*/
|
||||
_pad: function () {
|
||||
// Early return if the element has already been padded.
|
||||
if (this.$el.data('edit-padded')) {
|
||||
if (this.$el.data('quickedit-padded')) {
|
||||
return;
|
||||
}
|
||||
var self = this;
|
||||
|
@ -217,7 +217,7 @@
|
|||
if (this.$el[0].style.width === "") {
|
||||
this._widthAttributeIsEmpty = true;
|
||||
this.$el
|
||||
.addClass('edit-animate-disable-width')
|
||||
.addClass('quickedit-animate-disable-width')
|
||||
.css('width', this.$el.width())
|
||||
.css('background-color', this._getBgColor(this.$el));
|
||||
}
|
||||
|
@ -226,7 +226,7 @@
|
|||
var posProp = this._getPositionProperties(this.$el);
|
||||
setTimeout(function () {
|
||||
// Re-enable width animations (padding changes affect width too!).
|
||||
self.$el.removeClass('edit-animate-disable-width');
|
||||
self.$el.removeClass('quickedit-animate-disable-width');
|
||||
|
||||
// Pad the editable.
|
||||
self.$el
|
||||
|
@ -240,7 +240,7 @@
|
|||
'padding-bottom': posProp['padding-bottom'] + 5 + 'px',
|
||||
'margin-bottom': posProp['margin-bottom'] - 10 + 'px'
|
||||
})
|
||||
.data('edit-padded', true);
|
||||
.data('quickedit-padded', true);
|
||||
}, 0);
|
||||
},
|
||||
|
||||
|
@ -249,7 +249,7 @@
|
|||
*/
|
||||
_unpad: function () {
|
||||
// Early return if the element has not been padded.
|
||||
if (!this.$el.data('edit-padded')) {
|
||||
if (!this.$el.data('quickedit-padded')) {
|
||||
return;
|
||||
}
|
||||
var self = this;
|
||||
|
@ -257,7 +257,7 @@
|
|||
// 1) Set the empty width again.
|
||||
if (this._widthAttributeIsEmpty) {
|
||||
this.$el
|
||||
.addClass('edit-animate-disable-width')
|
||||
.addClass('quickedit-animate-disable-width')
|
||||
.css('width', '')
|
||||
.css('background-color', '');
|
||||
}
|
||||
|
@ -267,7 +267,7 @@
|
|||
var posProp = this._getPositionProperties(this.$el);
|
||||
setTimeout(function () {
|
||||
// Re-enable width animations (padding changes affect width too!).
|
||||
self.$el.removeClass('edit-animate-disable-width');
|
||||
self.$el.removeClass('quickedit-animate-disable-width');
|
||||
|
||||
// Unpad the editable.
|
||||
self.$el
|
||||
|
@ -286,7 +286,7 @@
|
|||
// done outside the timed out function above so that we don't get numerous
|
||||
// queued functions that will remove padding before the data marker has
|
||||
// been removed.
|
||||
this.$el.removeData('edit-padded');
|
||||
this.$el.removeData('quickedit-padded');
|
||||
},
|
||||
|
||||
/**
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
Drupal.edit.FieldToolbarView = Backbone.View.extend({
|
||||
Drupal.quickedit.FieldToolbarView = Backbone.View.extend({
|
||||
|
||||
// The edited element, as indicated by EditorView.getEditedElement().
|
||||
$editedElement: null,
|
||||
|
@ -26,7 +26,7 @@
|
|||
this.$root = this.$el;
|
||||
|
||||
// Generate a DOM-compatible ID for the form container DOM element.
|
||||
this._id = 'edit-toolbar-for-' + this.model.id.replace(/[\/\[\]]/g, '_');
|
||||
this._id = 'quickedit-toolbar-for-' + this.model.id.replace(/[\/\[\]]/g, '_');
|
||||
|
||||
this.listenTo(this.model, 'change:state', this.stateChange);
|
||||
},
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
render: function () {
|
||||
// Render toolbar and set it as the view's element.
|
||||
this.setElement($(Drupal.theme('editFieldToolbar', {
|
||||
this.setElement($(Drupal.theme('quickeditFieldToolbar', {
|
||||
id: this._id
|
||||
})));
|
||||
|
||||
|
@ -49,9 +49,9 @@
|
|||
/**
|
||||
* Determines the actions to take given a change of state.
|
||||
*
|
||||
* @param Drupal.edit.FieldModel model
|
||||
* @param Drupal.quickedit.FieldModel model
|
||||
* @param String state
|
||||
* The state of the associated field. One of Drupal.edit.FieldModel.states.
|
||||
* The state of the associated field. One of Drupal.quickedit.FieldModel.states.
|
||||
*/
|
||||
stateChange: function (model, state) {
|
||||
var from = model.previous('state');
|
||||
|
@ -73,11 +73,11 @@
|
|||
case 'activating':
|
||||
this.render();
|
||||
|
||||
if (this.editorView.getEditUISettings().fullWidthToolbar) {
|
||||
this.$el.addClass('edit-toolbar-fullwidth');
|
||||
if (this.editorView.getQuickEditUISettings().fullWidthToolbar) {
|
||||
this.$el.addClass('quickedit-toolbar-fullwidth');
|
||||
}
|
||||
|
||||
if (this.editorView.getEditUISettings().unifiedToolbar) {
|
||||
if (this.editorView.getQuickEditUISettings().unifiedToolbar) {
|
||||
this.insertWYSIWYGToolGroups();
|
||||
}
|
||||
break;
|
||||
|
@ -99,14 +99,14 @@
|
|||
*/
|
||||
insertWYSIWYGToolGroups: function () {
|
||||
this.$el
|
||||
.append(Drupal.theme('editToolgroup', {
|
||||
.append(Drupal.theme('quickeditToolgroup', {
|
||||
id: this.getFloatedWysiwygToolgroupId(),
|
||||
classes: ['wysiwyg-floated', 'edit-animate-slow', 'edit-animate-invisible', 'edit-animate-delay-veryfast'],
|
||||
classes: ['wysiwyg-floated', 'quickedit-animate-slow', 'quickedit-animate-invisible', 'quickedit-animate-delay-veryfast'],
|
||||
buttons: []
|
||||
}))
|
||||
.append(Drupal.theme('editToolgroup', {
|
||||
.append(Drupal.theme('quickeditToolgroup', {
|
||||
id: this.getMainWysiwygToolgroupId(),
|
||||
classes: ['wysiwyg-main', 'edit-animate-slow', 'edit-animate-invisible', 'edit-animate-delay-veryfast'],
|
||||
classes: ['wysiwyg-main', 'quickedit-animate-slow', 'quickedit-animate-invisible', 'quickedit-animate-delay-veryfast'],
|
||||
buttons: []
|
||||
}));
|
||||
|
||||
|
@ -124,7 +124,7 @@
|
|||
* A string that can be used as the ID for this toolbar's container.
|
||||
*/
|
||||
getId: function () {
|
||||
return 'edit-toolbar-for-' + this._id;
|
||||
return 'quickedit-toolbar-for-' + this._id;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -136,7 +136,7 @@
|
|||
* A string that can be used as the ID.
|
||||
*/
|
||||
getFloatedWysiwygToolgroupId: function () {
|
||||
return 'edit-wysiwyg-floated-toolgroup-for-' + this._id;
|
||||
return 'quickedit-wysiwyg-floated-toolgroup-for-' + this._id;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -148,7 +148,7 @@
|
|||
* A string that can be used as the ID.
|
||||
*/
|
||||
getMainWysiwygToolgroupId: function () {
|
||||
return 'edit-wysiwyg-main-toolgroup-for-' + this._id;
|
||||
return 'quickedit-wysiwyg-main-toolgroup-for-' + this._id;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -159,7 +159,7 @@
|
|||
* @return jQuery
|
||||
*/
|
||||
_find: function (toolgroup) {
|
||||
return this.$el.find('.edit-toolgroup.' + toolgroup);
|
||||
return this.$el.find('.quickedit-toolgroup.' + toolgroup);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -172,14 +172,14 @@
|
|||
var $group = this._find(toolgroup);
|
||||
// Attach a transitionEnd event handler to the toolbar group so that update
|
||||
// events can be triggered after the animations have ended.
|
||||
$group.on(Drupal.edit.util.constants.transitionEnd, function (event) {
|
||||
$group.off(Drupal.edit.util.constants.transitionEnd);
|
||||
$group.on(Drupal.quickedit.util.constants.transitionEnd, function (event) {
|
||||
$group.off(Drupal.quickedit.util.constants.transitionEnd);
|
||||
});
|
||||
// The call to remove the class and start the animation must be started in
|
||||
// the next animation frame or the event handler attached above won't be
|
||||
// triggered.
|
||||
window.setTimeout(function () {
|
||||
$group.removeClass('edit-animate-invisible');
|
||||
$group.removeClass('quickedit-animate-invisible');
|
||||
}, 0);
|
||||
}
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Access\EditEntityAccessCheck.
|
||||
* Contains \Drupal\quickedit\Access\EditEntityAccessCheck.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Access;
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Routing\Access\AccessInterface;
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Access\EditEntityFieldAccessCheck.
|
||||
* Contains \Drupal\quickedit\Access\EditEntityFieldAccessCheck.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Access;
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Routing\Access\AccessInterface;
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Access\EditEntityFieldAccessCheckInterface.
|
||||
* Contains \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Access;
|
||||
namespace Drupal\quickedit\Access;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Ajax\BaseCommand.
|
||||
* Contains \Drupal\quickedit\Ajax\BaseCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Ajax;
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* Base AJAX command that only exists simplify Edit's actual AJAX commands.
|
||||
* Base command that only exists to simplify Quick Edit's actual AJAX commands.
|
||||
*/
|
||||
class BaseCommand implements CommandInterface {
|
||||
|
||||
|
@ -31,6 +31,8 @@ class BaseCommand implements CommandInterface {
|
|||
/**
|
||||
* Constructs a BaseCommand object.
|
||||
*
|
||||
* @param string $command
|
||||
* The name of the command.
|
||||
* @param string $data
|
||||
* The data to pass on to the client side.
|
||||
*/
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Ajax\EntitySavedCommand.
|
||||
* Contains \Drupal\quickedit\Ajax\EntitySavedCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
/**
|
||||
* AJAX command to indicate the entity was loaded from TempStore and saved into
|
||||
|
@ -22,7 +20,7 @@ class EntitySavedCommand extends BaseCommand {
|
|||
* The data to pass on to the client side.
|
||||
*/
|
||||
public function __construct($data) {
|
||||
parent::__construct('editEntitySaved', $data);
|
||||
parent::__construct('quickeditEntitySaved', $data);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,15 +2,14 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Ajax\FieldFormCommand.
|
||||
* Contains \Drupal\quickedit\Ajax\FieldFormCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
/**
|
||||
* AJAX command for passing a rendered field form to Edit's JavaScript app.
|
||||
* AJAX command for passing a rendered field form to Quick Edit's JavaScript
|
||||
* app.
|
||||
*/
|
||||
class FieldFormCommand extends BaseCommand {
|
||||
|
||||
|
@ -21,7 +20,7 @@ class FieldFormCommand extends BaseCommand {
|
|||
* The data to pass on to the client side.
|
||||
*/
|
||||
public function __construct($data) {
|
||||
parent::__construct('editFieldForm', $data);
|
||||
parent::__construct('quickeditFieldForm', $data);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,16 +2,14 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Ajax\FieldFormSavedCommand.
|
||||
* Contains \Drupal\quickedit\Ajax\FieldFormSavedCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
/**
|
||||
* AJAX command to indicate a field was saved into TempStore without validation
|
||||
* errors and pass the rerendered field to Edit's JavaScript app.
|
||||
* errors and pass the rerendered field to Quick Edit's JavaScript app.
|
||||
*/
|
||||
class FieldFormSavedCommand extends BaseCommand {
|
||||
|
||||
|
@ -32,7 +30,7 @@ class FieldFormSavedCommand extends BaseCommand {
|
|||
* instances of the same field on the user's page. Keyed by view mode.
|
||||
*/
|
||||
public function __construct($data, $other_view_modes = array()) {
|
||||
parent::__construct('editFieldFormSaved', $data);
|
||||
parent::__construct('quickeditFieldFormSaved', $data);
|
||||
|
||||
$this->other_view_modes = $other_view_modes;
|
||||
}
|
|
@ -2,12 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Ajax\FieldFormValidationErrorsCommand.
|
||||
* Contains \Drupal\quickedit\Ajax\FieldFormValidationErrorsCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
/**
|
||||
* AJAX command to indicate a field form was attempted to be saved but failed
|
||||
|
@ -22,7 +20,7 @@ class FieldFormValidationErrorsCommand extends BaseCommand {
|
|||
* The data to pass on to the client side.
|
||||
*/
|
||||
public function __construct($data) {
|
||||
parent::__construct('editFieldFormValidationErrors', $data);
|
||||
parent::__construct('quickeditFieldFormValidationErrors', $data);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Annotation\InPlaceEditor.
|
||||
* Contains \Drupal\quickedit\Annotation\InPlaceEditor.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Annotation;
|
||||
namespace Drupal\quickedit\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\EditorSelector.
|
||||
* Contains \Drupal\quickedit\EditorSelector.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit;
|
||||
namespace Drupal\quickedit;
|
||||
|
||||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Component\Utility\NestedArray;
|
||||
|
@ -13,7 +13,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
use Drupal\Core\Field\FormatterPluginManager;
|
||||
|
||||
/**
|
||||
* Selects an in-place editor (an Editor plugin) for a field.
|
||||
* Selects an in-place editor (an InPlaceEditor plugin) for a field.
|
||||
*/
|
||||
class EditorSelector implements EditorSelectorInterface {
|
||||
|
||||
|
@ -74,7 +74,7 @@ class EditorSelector implements EditorSelectorInterface {
|
|||
// 'form' editor, since that can work for any field. Formatter definitions
|
||||
// can use 'disabled' to explicitly opt out of in-place editing.
|
||||
$formatter_info = $this->formatterManager->getDefinition($formatter_type);
|
||||
$editor_id = $formatter_info['edit']['editor'];
|
||||
$editor_id = $formatter_info['quickedit']['editor'];
|
||||
if ($editor_id === 'disabled') {
|
||||
return;
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\EditorSelectorInterface.
|
||||
* Contains \Drupal\quickedit\EditorSelectorInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit;
|
||||
namespace Drupal\quickedit;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
||||
|
@ -15,7 +15,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
interface EditorSelectorInterface {
|
||||
|
||||
/**
|
||||
* Returns the in-place editor (an Editor plugin) to use for a field.
|
||||
* Returns the in-place editor (an InPlaceEditor plugin) to use for a field.
|
||||
*
|
||||
* @param string $formatter_type
|
||||
* The field's formatter type name.
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Form\EditFieldForm.
|
||||
* Contains \Drupal\quickedit\Form\QuickEditFieldForm.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Form;
|
||||
namespace Drupal\quickedit\Form;
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
@ -21,7 +21,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
/**
|
||||
* Builds and process a form for editing a single entity field.
|
||||
*/
|
||||
class EditFieldForm extends FormBase {
|
||||
class QuickEditFieldForm extends FormBase {
|
||||
|
||||
/**
|
||||
* Stores the tempstore factory.
|
||||
|
@ -75,7 +75,7 @@ class EditFieldForm extends FormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'edit_field_form';
|
||||
return 'quickedit_field_form';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +104,7 @@ class EditFieldForm extends FormBase {
|
|||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
'#attributes' => array('class' => array('edit-form-submit')),
|
||||
'#attributes' => array('class' => array('quickedit-form-submit')),
|
||||
);
|
||||
|
||||
// Simplify it for optimal in-place use.
|
||||
|
@ -168,7 +168,7 @@ class EditFieldForm extends FormBase {
|
|||
$form_state['entity'] = $this->buildEntity($form, $form_state);
|
||||
|
||||
// Store entity in tempstore with its UUID as tempstore key.
|
||||
$this->tempStoreFactory->get('edit')->set($form_state['entity']->uuid(), $form_state['entity']);
|
||||
$this->tempStoreFactory->get('quickedit')->set($form_state['entity']->uuid(), $form_state['entity']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -201,8 +201,10 @@ class EditFieldForm extends FormBase {
|
|||
* outside the form.
|
||||
* - Adjusts textarea elements to fit their content.
|
||||
*
|
||||
* @param array $form
|
||||
* An associative array containing the structure of the form.
|
||||
* @param array &$form
|
||||
* A reference to an associative array containing the structure of the form.
|
||||
* @param array &$form_state
|
||||
* A reference to a keyed array containing the current state of the form.
|
||||
*/
|
||||
protected function simplify(array &$form, array &$form_state) {
|
||||
$field_name = $form_state['field_name'];
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\MetadataGenerator.
|
||||
* Contains \Drupal\quickedit\MetadataGenerator.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit;
|
||||
namespace Drupal\quickedit;
|
||||
|
||||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Component\Utility\String;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\edit\Access\EditEntityFieldAccessCheckInterface;
|
||||
use Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface;
|
||||
use Drupal\entity\Entity\EntityViewDisplay;
|
||||
|
||||
/**
|
||||
|
@ -22,14 +22,14 @@ class MetadataGenerator implements MetadataGeneratorInterface {
|
|||
/**
|
||||
* An object that checks if a user has access to edit a given entity field.
|
||||
*
|
||||
* @var \Drupal\edit\Access\EditEntityFieldAccessCheckInterface
|
||||
* @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
|
||||
*/
|
||||
protected $accessChecker;
|
||||
|
||||
/**
|
||||
* An object that determines which editor to attach to a given field.
|
||||
*
|
||||
* @var \Drupal\edit\EditorSelectorInterface
|
||||
* @var \Drupal\quickedit\EditorSelectorInterface
|
||||
*/
|
||||
protected $editorSelector;
|
||||
|
||||
|
@ -43,9 +43,9 @@ class MetadataGenerator implements MetadataGeneratorInterface {
|
|||
/**
|
||||
* Constructs a new MetadataGenerator.
|
||||
*
|
||||
* @param \Drupal\edit\Access\EditEntityFieldAccessCheckInterface $access_checker
|
||||
* @param \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface $access_checker
|
||||
* An object that checks if a user has access to edit a given field.
|
||||
* @param \Drupal\edit\EditorSelectorInterface $editor_selector
|
||||
* @param \Drupal\quickedit\EditorSelectorInterface $editor_selector
|
||||
* An object that determines which editor to attach to a given field.
|
||||
* @param \Drupal\Component\Plugin\PluginManagerInterface
|
||||
* The manager for editor plugins.
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\MetadataGeneratorInterface.
|
||||
* Contains \Drupal\quickedit\MetadataGeneratorInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit;
|
||||
namespace Drupal\quickedit;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Plugin\InPlaceEditor\FormEditor.
|
||||
* Contains \Drupal\quickedit\Plugin\InPlaceEditor\FormEditor.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Plugin\InPlaceEditor;
|
||||
namespace Drupal\quickedit\Plugin\InPlaceEditor;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\edit\Plugin\InPlaceEditorBase;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorBase;
|
||||
|
||||
/**
|
||||
* Defines the form in-place editor.
|
||||
|
@ -32,7 +32,7 @@ class FormEditor extends InPlaceEditorBase {
|
|||
public function getAttachments() {
|
||||
return array(
|
||||
'library' => array(
|
||||
'edit/edit.inPlaceEditor.form',
|
||||
'quickedit/quickedit.inPlaceEditor.form',
|
||||
),
|
||||
);
|
||||
}
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Plugin\InPlaceEditor\PlainTextEditor.
|
||||
* Contains \Drupal\quickedit\Plugin\InPlaceEditor\PlainTextEditor.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Plugin\InPlaceEditor;
|
||||
namespace Drupal\quickedit\Plugin\InPlaceEditor;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\edit\Plugin\InPlaceEditorBase;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorBase;
|
||||
|
||||
/**
|
||||
* Defines the plain text in-place editor.
|
||||
|
@ -47,7 +47,7 @@ class PlainTextEditor extends InPlaceEditorBase {
|
|||
public function getAttachments() {
|
||||
return array(
|
||||
'library' => array(
|
||||
'edit/edit.inPlaceEditor.plainText',
|
||||
'quickedit/quickedit.inPlaceEditor.plainText',
|
||||
),
|
||||
);
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Plugin\InPlaceEditorBase.
|
||||
* Contains \Drupal\quickedit\Plugin\InPlaceEditorBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Plugin;
|
||||
namespace Drupal\quickedit\Plugin;
|
||||
|
||||
use Drupal\Core\Plugin\PluginBase;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Plugin\InPlaceEditorInterface.
|
||||
* Contains \Drupal\quickedit\Plugin\InPlaceEditorInterface.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Plugin;
|
||||
namespace Drupal\quickedit\Plugin;
|
||||
|
||||
use Drupal\Component\Plugin\PluginInspectionInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
|
@ -29,7 +29,7 @@ interface InPlaceEditorInterface extends PluginInspectionInterface {
|
|||
/**
|
||||
* Generates metadata that is needed specifically for this editor.
|
||||
*
|
||||
* Will only be called by \Drupal\edit\MetadataGeneratorInterface::generate()
|
||||
* Will only be called by \Drupal\quickedit\MetadataGeneratorInterface::generate()
|
||||
* when the passed in field instance & item values will use this editor.
|
||||
*
|
||||
* @param \Drupal\Core\Field\FieldItemListInterface $items
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Plugin\InPlaceEditorManager.
|
||||
* Contains \Drupal\quickedit\Plugin\InPlaceEditorManager.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Plugin;
|
||||
namespace Drupal\quickedit\Plugin;
|
||||
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
|
@ -13,9 +13,9 @@ use Drupal\Core\Language\LanguageManagerInterface;
|
|||
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||
|
||||
/**
|
||||
* Editor manager.
|
||||
* In-place editor manager.
|
||||
*
|
||||
* The form editor must always be available.
|
||||
* The 'form' in-place editor must always be available.
|
||||
*/
|
||||
class InPlaceEditorManager extends DefaultPluginManager {
|
||||
|
||||
|
@ -33,9 +33,9 @@ class InPlaceEditorManager extends DefaultPluginManager {
|
|||
* The module handler to invoke the alter hook with.
|
||||
*/
|
||||
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
|
||||
parent::__construct('Plugin/InPlaceEditor', $namespaces, $module_handler, 'Drupal\edit\Annotation\InPlaceEditor');
|
||||
$this->alterInfo('edit_editor');
|
||||
$this->setCacheBackend($cache_backend, $language_manager, 'edit:editor');
|
||||
parent::__construct('Plugin/InPlaceEditor', $namespaces, $module_handler, 'Drupal\quickedit\Annotation\InPlaceEditor');
|
||||
$this->alterInfo('quickedit_editor');
|
||||
$this->setCacheBackend($cache_backend, $language_manager, 'quickedit:editor');
|
||||
}
|
||||
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\EditController.
|
||||
* Contains \Drupal\quickedit\QuickEditController.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit;
|
||||
namespace Drupal\quickedit;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
@ -15,16 +15,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\field\FieldInfo;
|
||||
use Drupal\edit\Ajax\FieldFormCommand;
|
||||
use Drupal\edit\Ajax\FieldFormSavedCommand;
|
||||
use Drupal\edit\Ajax\FieldFormValidationErrorsCommand;
|
||||
use Drupal\edit\Ajax\EntitySavedCommand;
|
||||
use Drupal\quickedit\Ajax\FieldFormCommand;
|
||||
use Drupal\quickedit\Ajax\FieldFormSavedCommand;
|
||||
use Drupal\quickedit\Ajax\FieldFormValidationErrorsCommand;
|
||||
use Drupal\quickedit\Ajax\EntitySavedCommand;
|
||||
use Drupal\user\TempStoreFactory;
|
||||
|
||||
/**
|
||||
* Returns responses for Edit module routes.
|
||||
* Returns responses for Quick Edit module routes.
|
||||
*/
|
||||
class EditController extends ControllerBase {
|
||||
class QuickEditController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* The TempStore factory.
|
||||
|
@ -36,14 +36,14 @@ class EditController extends ControllerBase {
|
|||
/**
|
||||
* The in-place editing metadata generator.
|
||||
*
|
||||
* @var \Drupal\edit\MetadataGeneratorInterface
|
||||
* @var \Drupal\quickedit\MetadataGeneratorInterface
|
||||
*/
|
||||
protected $metadataGenerator;
|
||||
|
||||
/**
|
||||
* The in-place editor selector.
|
||||
*
|
||||
* @var \Drupal\edit\EditorSelectorInterface
|
||||
* @var \Drupal\quickedit\EditorSelectorInterface
|
||||
*/
|
||||
protected $editorSelector;
|
||||
|
||||
|
@ -55,13 +55,13 @@ class EditController extends ControllerBase {
|
|||
protected $fieldInfo;
|
||||
|
||||
/**
|
||||
* Constructs a new EditController.
|
||||
* Constructs a new QuickEditController.
|
||||
*
|
||||
* @param \Drupal\user\TempStoreFactory $temp_store_factory
|
||||
* The TempStore factory.
|
||||
* @param \Drupal\edit\MetadataGeneratorInterface $metadata_generator
|
||||
* @param \Drupal\quickedit\MetadataGeneratorInterface $metadata_generator
|
||||
* The in-place editing metadata generator.
|
||||
* @param \Drupal\edit\EditorSelectorInterface $editor_selector
|
||||
* @param \Drupal\quickedit\EditorSelectorInterface $editor_selector
|
||||
* The in-place editor selector.
|
||||
* @param \Drupal\field\FieldInfo $field_info
|
||||
* The field info service.
|
||||
|
@ -79,8 +79,8 @@ class EditController extends ControllerBase {
|
|||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('user.tempstore'),
|
||||
$container->get('edit.metadata.generator'),
|
||||
$container->get('edit.editor.selector'),
|
||||
$container->get('quickedit.metadata.generator'),
|
||||
$container->get('quickedit.editor.selector'),
|
||||
$container->get('field.info')
|
||||
);
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ class EditController extends ControllerBase {
|
|||
/**
|
||||
* Returns the metadata for a set of fields.
|
||||
*
|
||||
* Given a list of field edit IDs as POST parameters, run access checks on the
|
||||
* entity and field level to determine whether the current user may edit them.
|
||||
* Also retrieves other metadata.
|
||||
* Given a list of field quick edit IDs as POST parameters, run access checks
|
||||
* on the entity and field level to determine whether the current user may
|
||||
* edit them. Also retrieves other metadata.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\JsonResponse
|
||||
* The JSON response.
|
||||
|
@ -181,12 +181,12 @@ class EditController extends ControllerBase {
|
|||
|
||||
// Replace entity with TempStore copy if available and not resetting, init
|
||||
// TempStore copy otherwise.
|
||||
$tempstore_entity = $this->tempStoreFactory->get('edit')->get($entity->uuid());
|
||||
$tempstore_entity = $this->tempStoreFactory->get('quickedit')->get($entity->uuid());
|
||||
if ($tempstore_entity && $request->request->get('reset') !== 'true') {
|
||||
$entity = $tempstore_entity;
|
||||
}
|
||||
else {
|
||||
$this->tempStoreFactory->get('edit')->set($entity->uuid(), $entity);
|
||||
$this->tempStoreFactory->get('quickedit')->set($entity->uuid(), $entity);
|
||||
}
|
||||
|
||||
$form_state = array(
|
||||
|
@ -196,12 +196,12 @@ class EditController extends ControllerBase {
|
|||
'args' => array($entity, $field_name),
|
||||
),
|
||||
);
|
||||
$form = $this->formBuilder()->buildForm('Drupal\edit\Form\EditFieldForm', $form_state);
|
||||
$form = $this->formBuilder()->buildForm('Drupal\quickedit\Form\QuickEditFieldForm', $form_state);
|
||||
|
||||
if (!empty($form_state['executed'])) {
|
||||
// The form submission saved the entity in TempStore. Return the
|
||||
// updated view of the field from the TempStore copy.
|
||||
$entity = $this->tempStoreFactory->get('edit')->get($entity->uuid());
|
||||
$entity = $this->tempStoreFactory->get('quickedit')->get($entity->uuid());
|
||||
|
||||
// Closure to render the field given a view mode.
|
||||
$render_field_in_view_mode = function ($view_mode_id) use ($entity, $field_name, $langcode) {
|
||||
|
@ -257,12 +257,12 @@ class EditController extends ControllerBase {
|
|||
* The name of the language for which the field is being edited.
|
||||
* @param string $view_mode_id
|
||||
* The view mode the field should be rerendered in. Either an Entity Display
|
||||
* view mode ID, or a custom one. See hook_edit_render_field().
|
||||
* view mode ID, or a custom one. See hook_quickedit_render_field().
|
||||
*
|
||||
* @return string
|
||||
* Rendered HTML.
|
||||
*
|
||||
* @see hook_edit_render_field()
|
||||
* @see hook_quickedit_render_field()
|
||||
*/
|
||||
protected function renderField(EntityInterface $entity, $field_name, $langcode, $view_mode_id) {
|
||||
$entity_view_mode_ids = array_keys($this->entityManager()->getViewModes($entity->getEntityTypeId()));
|
||||
|
@ -276,7 +276,7 @@ class EditController extends ControllerBase {
|
|||
$mode_id_parts = explode('-', $view_mode_id, 2);
|
||||
$module = reset($mode_id_parts);
|
||||
$args = array($entity, $field_name, $view_mode_id, $langcode);
|
||||
$output = $this->moduleHandler()->invoke($module, 'edit_render_field', $args);
|
||||
$output = $this->moduleHandler()->invoke($module, 'quickedit_render_field', $args);
|
||||
}
|
||||
|
||||
return drupal_render($output);
|
||||
|
@ -294,7 +294,7 @@ class EditController extends ControllerBase {
|
|||
public function entitySave(EntityInterface $entity) {
|
||||
// Take the entity from TempStore and save in entity storage. fieldForm()
|
||||
// ensures that the TempStore copy exists ahead.
|
||||
$tempstore = $this->tempStoreFactory->get('edit');
|
||||
$tempstore = $this->tempStoreFactory->get('quickedit');
|
||||
$tempstore->get($entity->uuid())->save();
|
||||
$tempstore->delete($entity->uuid());
|
||||
|
|
@ -2,19 +2,19 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Tests\EditorSelectionTest.
|
||||
* Contains \Drupal\quickedit\Tests\EditorSelectionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests;
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\edit\Plugin\InPlaceEditorManager;
|
||||
use Drupal\edit\EditorSelector;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorManager;
|
||||
use Drupal\quickedit\EditorSelector;
|
||||
|
||||
/**
|
||||
* Test in-place field editor selection.
|
||||
*/
|
||||
class EditorSelectionTest extends EditTestBase {
|
||||
class EditorSelectionTest extends QuickEditTestBase {
|
||||
|
||||
/**
|
||||
* The manager for editor plugins.
|
||||
|
@ -26,7 +26,7 @@ class EditorSelectionTest extends EditTestBase {
|
|||
/**
|
||||
* The editor selector object to be tested.
|
||||
*
|
||||
* @var \Drupal\edit\EditorSelectorInterface
|
||||
* @var \Drupal\quickedit\EditorSelectorInterface
|
||||
*/
|
||||
protected $editorSelector;
|
||||
|
||||
|
@ -34,19 +34,19 @@ class EditorSelectionTest extends EditTestBase {
|
|||
return array(
|
||||
'name' => 'In-place field editor selection',
|
||||
'description' => 'Tests in-place field editor selection.',
|
||||
'group' => 'Edit',
|
||||
'group' => 'Quick Edit',
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the in-place editor that Edit selects.
|
||||
* Returns the in-place editor that Quick Edit selects.
|
||||
*/
|
||||
protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
|
||||
$entity = entity_load('entity_test', $entity_id, TRUE);
|
||||
|
@ -110,8 +110,8 @@ class EditorSelectionTest extends EditTestBase {
|
|||
*/
|
||||
public function testTextWysiwyg() {
|
||||
// Enable edit_test module so that the 'wysiwyg' editor becomes available.
|
||||
$this->enableModules(array('edit_test'));
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->enableModules(array('quickedit_test'));
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
|
||||
|
||||
$field_name = 'field_textarea';
|
|
@ -5,18 +5,18 @@
|
|||
* Contains \Drupal\edit\Tests\MetadataGeneratorTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests;
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\edit\EditorSelector;
|
||||
use Drupal\edit\MetadataGenerator;
|
||||
use Drupal\edit\Plugin\InPlaceEditorManager;
|
||||
use Drupal\edit_test\MockEditEntityFieldAccessCheck;
|
||||
use Drupal\quickedit\EditorSelector;
|
||||
use Drupal\quickedit\MetadataGenerator;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorManager;
|
||||
use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
|
||||
|
||||
/**
|
||||
* Test in-place field editing metadata.
|
||||
*/
|
||||
class MetadataGeneratorTest extends EditTestBase {
|
||||
class MetadataGeneratorTest extends QuickEditTestBase {
|
||||
|
||||
/**
|
||||
* The manager for editor plugins.
|
||||
|
@ -28,21 +28,21 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
/**
|
||||
* The metadata generator object to be tested.
|
||||
*
|
||||
* @var \Drupal\edit\MetadataGeneratorInterface.php
|
||||
* @var \Drupal\quickedit\MetadataGeneratorInterface.php
|
||||
*/
|
||||
protected $metadataGenerator;
|
||||
|
||||
/**
|
||||
* The editor selector object to be used by the metadata generator object.
|
||||
*
|
||||
* @var \Drupal\edit\EditorSelectorInterface
|
||||
* @var \Drupal\quickedit\EditorSelectorInterface
|
||||
*/
|
||||
protected $editorSelector;
|
||||
|
||||
/**
|
||||
* The access checker object to be used by the metadata generator object.
|
||||
*
|
||||
* @var \Drupal\edit\Access\EditEntityFieldAccessCheckInterface
|
||||
* @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
|
||||
*/
|
||||
protected $accessChecker;
|
||||
|
||||
|
@ -50,14 +50,14 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
return array(
|
||||
'name' => 'In-place field editing metadata',
|
||||
'description' => 'Tests in-place field editing metadata generation.',
|
||||
'group' => 'Edit',
|
||||
'group' => 'Quick Edit',
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->accessChecker = new MockEditEntityFieldAccessCheck();
|
||||
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
|
||||
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
|
||||
|
@ -132,12 +132,12 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
$this->enableModules(array('user', 'filter'));
|
||||
|
||||
// Enable edit_test module so that the WYSIWYG editor becomes available.
|
||||
$this->enableModules(array('edit_test'));
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->enableModules(array('quickedit_test'));
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
|
||||
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
|
||||
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
|
||||
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
|
||||
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
|
||||
|
||||
|
@ -186,7 +186,7 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
'format' => 'full_html'
|
||||
),
|
||||
);
|
||||
$this->assertEqual($expected, $metadata, 'The correct metadata (including custom metadata) is generated.');
|
||||
$this->assertEqual($expected, $metadata); //, 'The correct metadata (including custom metadata) is generated.');
|
||||
}
|
||||
|
||||
}
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Tests\EditAutocompleteTermTest.
|
||||
* Contains \Drupal\quickedit\Tests\QuickEditAutocompleteTermTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests;
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Json;
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
|
@ -15,14 +15,14 @@ use Drupal\simpletest\WebTestBase;
|
|||
/**
|
||||
* Tests using in-place editing for an autocomplete entity reference widget.
|
||||
*/
|
||||
class EditAutocompleteTermTest extends WebTestBase {
|
||||
class QuickEditAutocompleteTermTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'taxonomy', 'edit');
|
||||
public static $modules = array('node', 'taxonomy', 'quickedit');
|
||||
|
||||
/**
|
||||
* Stores the node used for the tests.
|
||||
|
@ -63,7 +63,7 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
return array(
|
||||
'name' => 'In-place editing of autocomplete tags',
|
||||
'description' => 'Tests in-place editing of autocomplete tags.',
|
||||
'group' => 'Edit',
|
||||
'group' => 'Quick Edit',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -75,8 +75,8 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
));
|
||||
// Create the vocabulary for the tag field.
|
||||
$this->vocabulary = entity_create('taxonomy_vocabulary', array(
|
||||
'name' => 'edit testing tags',
|
||||
'vid' => 'edit_testing_tags',
|
||||
'name' => 'quickedit testing tags',
|
||||
'vid' => 'quickedit_testing_tags',
|
||||
));
|
||||
$this->vocabulary->save();
|
||||
$this->field_name = 'field_' . $this->vocabulary->id();
|
||||
|
@ -135,14 +135,14 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests Edit autocomplete term behavior.
|
||||
* Tests Quick Edit autocomplete term behavior.
|
||||
*/
|
||||
public function testAutocompleteEdit() {
|
||||
public function testAutocompleteQuickEdit() {
|
||||
$this->drupalLogin($this->editor_user);
|
||||
|
||||
$edit_uri = 'edit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full';
|
||||
$quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full';
|
||||
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost($edit_uri, 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
|
||||
$ajax_commands = Json::decode($response);
|
||||
|
||||
// Prepare form values for submission. drupalPostAJAX() is not suitable for
|
||||
|
@ -152,7 +152,7 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
|
||||
if ($form_tokens_found) {
|
||||
$post = array(
|
||||
'form_id' => 'edit_field_form',
|
||||
'form_id' => 'quickedit_field_form',
|
||||
'form_token' => $token_match[1],
|
||||
'form_build_id' => $build_id_match[1],
|
||||
$this->field_name => implode(', ', array($this->term1->getName(), 'new term', $this->term2->getName())),
|
||||
|
@ -160,7 +160,7 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
);
|
||||
|
||||
// Submit field form and check response. Should render back all the terms.
|
||||
$response = $this->drupalPost($edit_uri, 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->drupalSetContent($ajax_commands[0]['data']);
|
||||
|
@ -170,9 +170,9 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
$this->assertNoLink('new term');
|
||||
|
||||
// Load the form again, which should now get it back from TempStore.
|
||||
$edit_uri = 'edit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full';
|
||||
$quickedit_uri = 'quickedit/form/node/'. $this->node->id() . '/' . $this->field_name . '/und/full';
|
||||
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost($edit_uri, 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost($quickedit_uri, 'application/vnd.drupal-ajax', $post);
|
||||
$ajax_commands = Json::decode($response);
|
||||
|
||||
// The AjaxResponse's first command is an InsertCommand which contains
|
||||
|
@ -184,7 +184,7 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
|
||||
// Save the entity.
|
||||
$post = array('nocssjs' => 'true');
|
||||
$response = $this->drupalPost('edit/entity/node/' . $this->node->id(), 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/entity/node/' . $this->node->id(), 'application/json', $post);
|
||||
$this->assertResponse(200);
|
||||
|
||||
// The full node display should now link to all entities, with the new
|
|
@ -2,34 +2,34 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Tests\EditLoadingTest.
|
||||
* Contains \Drupal\quickedit\Tests\QuickEditLoadingTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests;
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Component\Utility\Json;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\edit\Ajax\MetadataCommand;
|
||||
use Drupal\quickedit\Ajax\MetadataCommand;
|
||||
use Drupal\Core\Ajax\AppendCommand;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
/**
|
||||
* Tests loading of Edit and lazy-loading of in-place editors.
|
||||
* Tests loading of Quick Edit and lazy-loading of in-place editors.
|
||||
*/
|
||||
class EditLoadingTest extends WebTestBase {
|
||||
class QuickEditLoadingTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contextual', 'edit', 'filter', 'node');
|
||||
public static $modules = array('contextual', 'quickedit', 'filter', 'node');
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'In-place editing loading',
|
||||
'description' => 'Tests loading of in-place editing functionality and lazy loading of its in-place editors.',
|
||||
'group' => 'Edit',
|
||||
'group' => 'Quick Edit',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Test the loading of Edit when a user doesn't have access to it.
|
||||
* Test the loading of Quick Edit when a user doesn't have access to it.
|
||||
*/
|
||||
public function testUserWithoutPermission() {
|
||||
$this->drupalLogin($this->author_user);
|
||||
|
@ -79,53 +79,53 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Library and in-place editors.
|
||||
$settings = $this->drupalGetSettings();
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/edit.js']), 'Edit library not loaded.');
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/editors/formEditor.js']), "'form' in-place editor not loaded.");
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/quickedit/js/quickedit.js']), 'Quick Edit library not loaded.');
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/quickedit/js/editors/formEditor.js']), "'form' in-place editor not loaded.");
|
||||
|
||||
// HTML annotation must always exist (to not break the render cache).
|
||||
$this->assertRaw('data-edit-entity-id="node/1"');
|
||||
$this->assertRaw('data-edit-field-id="node/1/body/und/full"');
|
||||
$this->assertRaw('data-quickedit-entity-id="node/1"');
|
||||
$this->assertRaw('data-quickedit-field-id="node/1/body/und/full"');
|
||||
|
||||
// Retrieving the metadata should result in an empty 403 response.
|
||||
$post = array('fields[0]' => 'node/1/body/und/full');
|
||||
$response = $this->drupalPost('edit/metadata', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/metadata', 'application/json', $post);
|
||||
$this->assertIdentical('{}', $response);
|
||||
$this->assertResponse(403);
|
||||
|
||||
// Edit's JavaScript would never hit these endpoints if the metadata was
|
||||
// empty as above, but we need to make sure that malicious users aren't able
|
||||
// to use any of the other endpoints either.
|
||||
// Quick Edit's JavaScript would never hit these endpoints if the metadata
|
||||
// was empty as above, but we need to make sure that malicious users aren't
|
||||
// able to use any of the other endpoints either.
|
||||
$post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/attachments', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/attachments', 'application/vnd.drupal-ajax', $post);
|
||||
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
|
||||
// $this->assertIdentical('[]', $response);
|
||||
$this->assertResponse(403);
|
||||
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
|
||||
// $this->assertIdentical('[]', $response);
|
||||
$this->assertResponse(403);
|
||||
$edit = array();
|
||||
$edit['form_id'] = 'edit_field_form';
|
||||
$edit['form_id'] = 'quickedit_field_form';
|
||||
$edit['form_token'] = 'xIOzMjuc-PULKsRn_KxFn7xzNk5Bx7XKXLfQfw1qOnA';
|
||||
$edit['form_build_id'] = 'form-kVmovBpyX-SJfTT5kY0pjTV35TV-znor--a64dEnMR8';
|
||||
$edit['body[0][summary]'] = '';
|
||||
$edit['body[0][value]'] = '<p>Malicious content.</p>';
|
||||
$edit['body[0][format]'] = 'filtered_html';
|
||||
$edit['op'] = t('Save');
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $edit);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $edit);
|
||||
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
|
||||
// $this->assertIdentical('[]', $response);
|
||||
$this->assertResponse(403);
|
||||
$post = array('nocssjs' => 'true');
|
||||
$response = $this->drupalPost('edit/entity/' . 'node/1', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post);
|
||||
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
|
||||
// $this->assertIdentical('[]', $response);
|
||||
$this->assertResponse(403);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the loading of Edit when a user does have access to it.
|
||||
* Tests the loading of Quick Edit when a user does have access to it.
|
||||
*
|
||||
* Also ensures lazy loading of in-place editors works.
|
||||
*/
|
||||
|
@ -135,12 +135,12 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Library and in-place editors.
|
||||
$settings = $this->drupalGetSettings();
|
||||
$this->assertTrue(isset($settings['ajaxPageState']['js']['core/modules/edit/js/edit.js']), 'Edit library loaded.');
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/editors/formEditor.js']), "'form' in-place editor not loaded.");
|
||||
$this->assertTrue(isset($settings['ajaxPageState']['js']['core/modules/quickedit/js/quickedit.js']), 'Quick Edit library loaded.');
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/quickedit/js/editors/formEditor.js']), "'form' in-place editor not loaded.");
|
||||
|
||||
// HTML annotation must always exist (to not break the render cache).
|
||||
$this->assertRaw('data-edit-entity-id="node/1"');
|
||||
$this->assertRaw('data-edit-field-id="node/1/body/und/full"');
|
||||
$this->assertRaw('data-quickedit-entity-id="node/1"');
|
||||
$this->assertRaw('data-quickedit-field-id="node/1/body/und/full"');
|
||||
|
||||
// There should be only one revision so far.
|
||||
$revisions = node_revision_list(node_load(1));
|
||||
|
@ -150,7 +150,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
// Retrieving the metadata should result in a 200 JSON response.
|
||||
$htmlPageDrupalSettings = $this->drupalSettings;
|
||||
$post = array('fields[0]' => 'node/1/body/und/full');
|
||||
$response = $this->drupalPost('edit/metadata', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/metadata', 'application/json', $post);
|
||||
$this->assertResponse(200);
|
||||
$expected = array(
|
||||
'node/1/body/und/full' => array(
|
||||
|
@ -169,25 +169,25 @@ class EditLoadingTest extends WebTestBase {
|
|||
// 1. a settings command with useless metadata: AjaxController is dumb
|
||||
// 2. an insert command that loads the required in-place editors
|
||||
$post = array('editors[0]' => 'form') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/attachments', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/attachments', 'application/vnd.drupal-ajax', $post);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(2, count($ajax_commands), 'The attachments HTTP request results in two AJAX commands.');
|
||||
// First command: settings.
|
||||
$this->assertIdentical('settings', $ajax_commands[0]['command'], 'The first AJAX command is a settings command.');
|
||||
// Second command: insert libraries into DOM.
|
||||
$this->assertIdentical('insert', $ajax_commands[1]['command'], 'The second AJAX command is an append command.');
|
||||
$command = new AppendCommand('body', '<script src="' . file_create_url('core/modules/edit/js/editors/formEditor.js') . '?v=' . \Drupal::VERSION . '"></script>' . "\n");
|
||||
$command = new AppendCommand('body', '<script src="' . file_create_url('core/modules/quickedit/js/editors/formEditor.js') . '?v=' . \Drupal::VERSION . '"></script>' . "\n");
|
||||
$this->assertIdentical($command->render(), $ajax_commands[1], 'The append command contains the expected data.');
|
||||
|
||||
// Retrieving the form for this field should result in a 200 response,
|
||||
// containing only an editFieldForm command.
|
||||
// containing only a quickeditFieldForm command.
|
||||
$post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The editFieldForm command contains a form.');
|
||||
$this->assertIdentical('quickeditFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
|
||||
// Prepare form values for submission. drupalPostAjaxForm() is not suitable
|
||||
// for handling pages with JSON responses, so we need our own solution here.
|
||||
|
@ -202,7 +202,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
'op' => t('Save'),
|
||||
);
|
||||
$post = array(
|
||||
'form_id' => 'edit_field_form',
|
||||
'form_id' => 'quickedit_field_form',
|
||||
'form_token' => $token_match[1],
|
||||
'form_build_id' => $build_id_match[1],
|
||||
);
|
||||
|
@ -210,11 +210,11 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Submit field form and check response. This should store the updated
|
||||
// entity in TempStore on the server.
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldFormSaved command.');
|
||||
$this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldFormSaved command.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['data'], 'Fine thanks.'), 'Form value saved and printed back.');
|
||||
$this->assertIdentical($ajax_commands[0]['other_view_modes'], array(), 'Field was not rendered in any other view mode.');
|
||||
|
||||
|
@ -224,11 +224,11 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Save the entity by moving the TempStore values to entity storage.
|
||||
$post = array('nocssjs' => 'true');
|
||||
$response = $this->drupalPost('edit/entity/' . 'node/1', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The entity submission HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editEntitySaved', $ajax_commands[0]['command'], 'The first AJAX command is an editEntitySaved command.');
|
||||
$this->assertIdentical('quickeditEntitySaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditEntitySaved command.');
|
||||
$this->assertIdentical($ajax_commands[0]['data']['entity_type'], 'node', 'Saved entity is of type node.');
|
||||
$this->assertIdentical($ajax_commands[0]['data']['entity_id'], '1', 'Entity id is 1.');
|
||||
|
||||
|
@ -251,35 +251,35 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Retrieve field form.
|
||||
$post = array('nocssjs' => 'true', 'reset' => 'true');
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The editFieldForm command contains a form.');
|
||||
$this->assertIdentical('quickeditFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
|
||||
// Submit field form.
|
||||
preg_match('/\sname="form_token" value="([^"]+)"/', $ajax_commands[0]['data'], $token_match);
|
||||
preg_match('/\sname="form_build_id" value="([^"]+)"/', $ajax_commands[0]['data'], $build_id_match);
|
||||
$edit['body[0][value]'] = '<p>kthxbye</p>';
|
||||
$post = array(
|
||||
'form_id' => 'edit_field_form',
|
||||
'form_id' => 'quickedit_field_form',
|
||||
'form_token' => $token_match[1],
|
||||
'form_build_id' => $build_id_match[1],
|
||||
);
|
||||
$post += $edit + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
|
||||
// $this->assertIdentical('[]', $response);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldFormSaved command.');
|
||||
$this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is an quickeditFieldFormSaved command.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['data'], 'kthxbye'), 'Form value saved and printed back.');
|
||||
|
||||
// Save the entity.
|
||||
$post = array('nocssjs' => 'true');
|
||||
$response = $this->drupalPost('edit/entity/' . 'node/1', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post);
|
||||
// @todo Uncomment the below once https://drupal.org/node/2063303 is fixed.
|
||||
// $this->assertIdentical('[]', $response);
|
||||
$this->assertResponse(200);
|
||||
|
@ -288,12 +288,12 @@ class EditLoadingTest extends WebTestBase {
|
|||
$revisions = node_revision_list(node_load(1));
|
||||
$this->assertIdentical(2, count($revisions), 'The node has two revisions.');
|
||||
$this->assertIdentical($original_log, $revisions[1]->log, 'The first revision log message is unchanged.');
|
||||
$this->assertIdentical('Updated the <em class="placeholder">Body</em> field through in-place editing.', $revisions[2]->log, 'The second revision log message was correctly generated by Edit module.');
|
||||
$this->assertIdentical('Updated the <em class="placeholder">Body</em> field through in-place editing.', $revisions[2]->log, 'The second revision log message was correctly generated by Quick Edit module.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the loading of Edit for the title base field.
|
||||
* Tests the loading of Quick Edit for the title base field.
|
||||
*/
|
||||
public function testTitleBaseField() {
|
||||
$this->drupalLogin($this->editor_user);
|
||||
|
@ -302,7 +302,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
// Retrieving the metadata should result in a 200 JSON response.
|
||||
$htmlPageDrupalSettings = $this->drupalSettings;
|
||||
$post = array('fields[0]' => 'node/1/title/und/full');
|
||||
$response = $this->drupalPost('edit/metadata', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/metadata', 'application/json', $post);
|
||||
$this->assertResponse(200);
|
||||
$expected = array(
|
||||
'node/1/title/und/full' => array(
|
||||
|
@ -318,14 +318,14 @@ class EditLoadingTest extends WebTestBase {
|
|||
$this->drupalSettings = $htmlPageDrupalSettings;
|
||||
|
||||
// Retrieving the form for this field should result in a 200 response,
|
||||
// containing only an editFieldForm command.
|
||||
// containing only a quickeditFieldForm command.
|
||||
$post = array('nocssjs' => 'true', 'reset' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/title/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/title/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The editFieldForm command contains a form.');
|
||||
$this->assertIdentical('quickeditFieldForm', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldForm command.');
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
|
||||
// Prepare form values for submission. drupalPostAjaxForm() is not suitable
|
||||
// for handling pages with JSON responses, so we need our own solution
|
||||
|
@ -339,7 +339,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
'op' => t('Save'),
|
||||
);
|
||||
$post = array(
|
||||
'form_id' => 'edit_field_form',
|
||||
'form_id' => 'quickedit_field_form',
|
||||
'form_token' => $token_match[1],
|
||||
'form_build_id' => $build_id_match[1],
|
||||
);
|
||||
|
@ -347,11 +347,11 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Submit field form and check response. This should store the
|
||||
// updated entity in TempStore on the server.
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/title/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/title/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldFormSaved command.');
|
||||
$this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldFormSaved command.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['data'], 'Obligatory question'), 'Form value saved and printed back.');
|
||||
|
||||
// Ensure the text on the original node did not change yet.
|
||||
|
@ -360,11 +360,11 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Save the entity by moving the TempStore values to entity storage.
|
||||
$post = array('nocssjs' => 'true');
|
||||
$response = $this->drupalPost('edit/entity/' . 'node/1', 'application/json', $post);
|
||||
$response = $this->drupalPost('quickedit/entity/' . 'node/1', 'application/json', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The entity submission HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editEntitySaved', $ajax_commands[0]['command'], 'The first AJAX command is an editEntitySaved command.');
|
||||
$this->assertIdentical('quickeditEntitySaved', $ajax_commands[0]['command'], 'The first AJAX command is n quickeditEntitySaved command.');
|
||||
$this->assertIdentical($ajax_commands[0]['data']['entity_type'], 'node', 'Saved entity is of type node.');
|
||||
$this->assertIdentical($ajax_commands[0]['data']['entity_id'], '1', 'Entity id is 1.');
|
||||
|
||||
|
@ -375,20 +375,22 @@ class EditLoadingTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests that Edit doesn't make pseudo fields or computed fields editable.
|
||||
* Tests that Quick Edit doesn't make pseudo fields or computed fields
|
||||
* editable.
|
||||
*/
|
||||
public function testPseudoFields() {
|
||||
\Drupal::moduleHandler()->install(array('edit_test'));
|
||||
\Drupal::moduleHandler()->install(array('quickedit_test'));
|
||||
|
||||
$this->drupalLogin($this->author_user);
|
||||
$this->drupalGet('node/1');
|
||||
|
||||
// Check that the data- attribute is not added.
|
||||
$this->assertNoRaw('data-edit-field-id="node/1/edit_test_pseudo_field/und/default"');
|
||||
$this->assertNoRaw('data-quickedit-field-id="node/1/quickedit_test_pseudo_field/und/default"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Edit doesn't make fields rendered with display options editable.
|
||||
* Tests that Quick Edit doesn't make fields rendered with display options
|
||||
* editable.
|
||||
*/
|
||||
public function testDisplayOptions() {
|
||||
$node = entity_load('node', '1');
|
||||
|
@ -397,16 +399,16 @@ class EditLoadingTest extends WebTestBase {
|
|||
);
|
||||
$build = $node->body->view($display_settings);
|
||||
$output = drupal_render($build);
|
||||
$this->assertFalse(strpos($output, 'data-edit-field-id'), 'data-edit-field-id attribute not added when rendering field using dynamic display options.');
|
||||
$this->assertFalse(strpos($output, 'data-quickedit-field-id'), 'data-quickedit-field-id attribute not added when rendering field using dynamic display options.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Edit works with custom render pipelines.
|
||||
* Tests that Quick Edit works with custom render pipelines.
|
||||
*/
|
||||
public function testCustomPipeline() {
|
||||
\Drupal::moduleHandler()->install(array('edit_test'));
|
||||
\Drupal::moduleHandler()->install(array('quickedit_test'));
|
||||
|
||||
$custom_render_url = 'edit/form/node/1/body/und/edit_test-custom-render-data';
|
||||
$custom_render_url = 'quickedit/form/node/1/body/und/quickedit_test-custom-render-data';
|
||||
$this->drupalLogin($this->editor_user);
|
||||
|
||||
// Request editing to render results with the custom render pipeline.
|
||||
|
@ -421,7 +423,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
if ($form_tokens_found) {
|
||||
$post = array(
|
||||
'form_id' => 'edit_field_form',
|
||||
'form_id' => 'quickedit_field_form',
|
||||
'form_token' => $token_match[1],
|
||||
'form_build_id' => $build_id_match[1],
|
||||
'body[0][summary]' => '',
|
||||
|
@ -439,22 +441,23 @@ class EditLoadingTest extends WebTestBase {
|
|||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(1, count($ajax_commands), 'The field form HTTP request results in one AJAX command.');
|
||||
$this->assertIdentical('editFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is an editFieldFormSaved command.');
|
||||
$this->assertIdentical('quickeditFieldFormSaved', $ajax_commands[0]['command'], 'The first AJAX command is a quickeditFieldFormSaved command.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['data'], 'Fine thanks.'), 'Form value saved and printed back.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['data'], '<div class="edit-test-wrapper">') !== FALSE, 'Custom render pipeline used to render the value.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['data'], '<div class="quickedit-test-wrapper">') !== FALSE, 'Custom render pipeline used to render the value.');
|
||||
$this->assertIdentical(array_keys($ajax_commands[0]['other_view_modes']), array('full'), 'Field was also rendered in the "full" view mode.');
|
||||
$this->assertTrue(strpos($ajax_commands[0]['other_view_modes']['full'], 'Fine thanks.'), '"full" version of field contains the form value.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests Edit on a node that was concurrently edited on the full node form.
|
||||
* Tests Quick Edit on a node that was concurrently edited on the full node
|
||||
* form.
|
||||
*/
|
||||
public function testConcurrentEdit() {
|
||||
$this->drupalLogin($this->editor_user);
|
||||
|
||||
$post = array('nocssjs' => 'true') + $this->getAjaxPageStatePostData();
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
|
||||
|
@ -465,7 +468,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
if ($form_tokens_found) {
|
||||
$post = array(
|
||||
'form_id' => 'edit_field_form',
|
||||
'form_id' => 'quickedit_field_form',
|
||||
'form_token' => $token_match[1],
|
||||
'form_build_id' => $build_id_match[1],
|
||||
'body[0][summary]' => '',
|
||||
|
@ -481,11 +484,11 @@ class EditLoadingTest extends WebTestBase {
|
|||
|
||||
// Submit field form and check response. Should throw a validation error
|
||||
// because the node was changed in the meantime.
|
||||
$response = $this->drupalPost('edit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$response = $this->drupalPost('quickedit/form/' . 'node/1/body/und/full', 'application/vnd.drupal-ajax', $post);
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical(2, count($ajax_commands), 'The field form HTTP request results in two AJAX commands.');
|
||||
$this->assertIdentical('editFieldFormValidationErrors', $ajax_commands[1]['command'], 'The second AJAX command is an editFieldFormValidationErrors command.');
|
||||
$this->assertIdentical('quickeditFieldFormValidationErrors', $ajax_commands[1]['command'], 'The second AJAX command is a quickeditFieldFormValidationErrors command.');
|
||||
$this->assertTrue(strpos($ajax_commands[1]['data'], t('The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.')), 'Error message returned to user.');
|
||||
}
|
||||
}
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Tests\EditTestBase.
|
||||
* Contains \Drupal\quickedit\Tests\QuickEditTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests;
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\simpletest\DrupalUnitTestBase;
|
||||
|
||||
/**
|
||||
* Parent class for Edit tests.
|
||||
* Parent class for Quick Edit tests.
|
||||
*/
|
||||
class EditTestBase extends DrupalUnitTestBase {
|
||||
class QuickEditTestBase extends DrupalUnitTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'entity', 'entity_test', 'field', 'field_test', 'filter', 'user', 'text', 'edit');
|
||||
public static $modules = array('system', 'entity', 'entity_test', 'field', 'field_test', 'filter', 'user', 'text', 'quickedit');
|
||||
|
||||
/**
|
||||
* Sets the default field storage backend for fields created during tests.
|
|
@ -20,12 +20,12 @@
|
|||
* An array of metadata on existing in-place editors, as collected by the
|
||||
* annotation discovery mechanism.
|
||||
*
|
||||
* @see \Drupal\edit\Annotation\InPlaceEditor
|
||||
* @see \Drupal\edit\Plugin\EditorManager
|
||||
* @see \Drupal\quickedit\Annotation\InPlaceEditor
|
||||
* @see \Drupal\quickedit\Plugin\EditorManager
|
||||
*/
|
||||
function hook_edit_editor_alter(&$editors) {
|
||||
function hook_quickedit_editor_alter(&$editors) {
|
||||
// Cleanly override editor.module's in-place editor plugin.
|
||||
$editors['editor']['class'] = 'Drupal\advanced_editor\Plugin\edit\editor\AdvancedEditor';
|
||||
$editors['editor']['class'] = 'Drupal\advanced_editor\Plugin\quickedit\editor\AdvancedEditor';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -69,7 +69,7 @@ function hook_edit_editor_alter(&$editors) {
|
|||
*
|
||||
* @see \Drupal\Core\Field\FieldItemListInterface::view()
|
||||
*/
|
||||
function hook_edit_render_field(Drupal\Core\Entity\EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
|
||||
function hook_quickedit_render_field(Drupal\Core\Entity\EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
|
||||
return array(
|
||||
'#prefix' => '<div class="example-markup">',
|
||||
'field' => $entity->getTranslation($langcode)->get($field_name)->view($view_mode_id),
|
|
@ -1,4 +1,4 @@
|
|||
name: Edit
|
||||
name: Quick Edit
|
||||
type: module
|
||||
description: 'In-place content editing.'
|
||||
package: Core
|
|
@ -1,8 +1,8 @@
|
|||
edit:
|
||||
quickedit:
|
||||
version: VERSION
|
||||
js:
|
||||
# Core.
|
||||
js/edit.js: { scope: footer }
|
||||
js/quickedit.js: { scope: footer }
|
||||
js/util.js: { scope: footer }
|
||||
# Models.
|
||||
js/models/BaseModel.js: { scope: footer }
|
||||
|
@ -22,10 +22,10 @@ edit:
|
|||
js/theme.js: { scope: footer }
|
||||
css:
|
||||
component:
|
||||
css/edit.module.css: {}
|
||||
css/quickedit.module.css: {}
|
||||
theme:
|
||||
css/edit.theme.css: {}
|
||||
css/edit.icons.css: {}
|
||||
css/quickedit.theme.css: {}
|
||||
css/quickedit.icons.css: {}
|
||||
dependencies:
|
||||
- core/jquery
|
||||
- core/jquery.once
|
||||
|
@ -41,16 +41,16 @@ edit:
|
|||
- core/drupalSettings
|
||||
- core/drupal.dialog
|
||||
|
||||
edit.inPlaceEditor.form:
|
||||
quickedit.inPlaceEditor.form:
|
||||
version: VERSION
|
||||
js:
|
||||
js/editors/formEditor.js: { scope: footer }
|
||||
dependencies:
|
||||
- edit/edit
|
||||
- quickedit/quickedit
|
||||
|
||||
edit.inPlaceEditor.plainText:
|
||||
quickedit.inPlaceEditor.plainText:
|
||||
version: VERSION
|
||||
js:
|
||||
js/editors/plainTextEditor.js: { scope: footer }
|
||||
dependencies:
|
||||
- edit/edit
|
||||
- quickedit/quickedit
|
|
@ -4,8 +4,8 @@
|
|||
* @file
|
||||
* Provides in-place content editing functionality for fields.
|
||||
*
|
||||
* The Edit module makes content editable in-place. Rather than having to visit
|
||||
* a separate page to edit content, it may be edited in-place.
|
||||
* The Quick Edit module makes content editable in-place. Rather than having to
|
||||
* visit a separate page to edit content, it may be edited in-place.
|
||||
*
|
||||
* Technically, this module adds classes and data- attributes to fields and
|
||||
* entities, enabling them for in-place editing.
|
||||
|
@ -17,7 +17,7 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
|||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function edit_permission() {
|
||||
function quickedit_permission() {
|
||||
return array(
|
||||
'access in-place editing' => array(
|
||||
'title' => t('Access in-place editing'),
|
||||
|
@ -28,10 +28,10 @@ function edit_permission() {
|
|||
/**
|
||||
* Implements hook_page_build().
|
||||
*
|
||||
* Adds the edit library to the page for any user who has the 'access in-place
|
||||
* editing' permission.
|
||||
* Adds the quickedit library to the page for any user who has the 'access
|
||||
* in-place editing' permission.
|
||||
*/
|
||||
function edit_page_build(&$page) {
|
||||
function quickedit_page_build(&$page) {
|
||||
if (!\Drupal::currentUser()->hasPermission('access in-place editing')) {
|
||||
return;
|
||||
}
|
||||
|
@ -41,14 +41,14 @@ function edit_page_build(&$page) {
|
|||
return;
|
||||
}
|
||||
|
||||
$page['#attached']['library'][] = 'edit/edit';
|
||||
$page['#attached']['library'][] = 'quickedit/quickedit';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_library_alter().
|
||||
*
|
||||
* Includes additional stylesheets defined by the admin theme to allow it to
|
||||
* customize the Edit toolbar appearance.
|
||||
* customize the Quick Edit toolbar appearance.
|
||||
*
|
||||
* An admin theme can specify CSS files to make the front-end administration
|
||||
* experience of in-place editing match the administration experience in the
|
||||
|
@ -57,13 +57,17 @@ function edit_page_build(&$page) {
|
|||
* The CSS files can be specified via the "edit_stylesheets" property in the
|
||||
* .info.yml file:
|
||||
* @code
|
||||
* edit_stylesheets:
|
||||
* - css/edit.css
|
||||
* quickedit_stylesheets:
|
||||
* - css/quickedit.css
|
||||
* @endcode
|
||||
*
|
||||
* The library needs to be dynamically enhanced, because an admin theme normally
|
||||
* does not participate in the front-end.
|
||||
*
|
||||
* @param array &$library
|
||||
* The JavaScript/CSS library that is being altered.
|
||||
* @param string $name
|
||||
* The name of the library.
|
||||
* @param string $theme
|
||||
* (optional) Internal use only. A base theme name for which to retrieve the
|
||||
* 'edit_stylesheets' property.
|
||||
|
@ -71,8 +75,8 @@ function edit_page_build(&$page) {
|
|||
* @todo Remove this in favor of the 'stylesheets-additional' property proposed
|
||||
* in https://drupal.org/node/1209958
|
||||
*/
|
||||
function edit_library_alter(array &$library, $name, $theme = NULL) {
|
||||
if ($name == 'edit/edit') {
|
||||
function quickedit_library_alter(array &$library, $name, $theme = NULL) {
|
||||
if ($name == 'quickedit/quickedit') {
|
||||
// Retrieve the admin theme.
|
||||
if (!isset($theme)) {
|
||||
$theme = Drupal::config('system.theme')->get('admin');
|
||||
|
@ -81,10 +85,10 @@ function edit_library_alter(array &$library, $name, $theme = NULL) {
|
|||
$info = system_get_info('theme', $theme);
|
||||
// Recurse to process base theme(s) first.
|
||||
if (isset($info['base theme'])) {
|
||||
edit_library_alter($library, $name, $info['base theme']);
|
||||
quickedit_library_alter($library, $name, $info['base theme']);
|
||||
}
|
||||
if (isset($info['edit_stylesheets']) && is_array($info['edit_stylesheets'])) {
|
||||
foreach ($info['edit_stylesheets'] as $path) {
|
||||
if (isset($info['quickedit_stylesheets']) && is_array($info['quickedit_stylesheets'])) {
|
||||
foreach ($info['quickedit_stylesheets'] as $path) {
|
||||
$library['css'][$theme_path . '/' . $path] = array(
|
||||
'group' => CSS_AGGREGATE_THEME,
|
||||
'weight' => CSS_THEME,
|
||||
|
@ -98,17 +102,17 @@ function edit_library_alter(array &$library, $name, $theme = NULL) {
|
|||
/**
|
||||
* Implements hook_field_formatter_info_alter().
|
||||
*
|
||||
* Edit extends the @FieldFormatter annotation with the following keys:
|
||||
* - edit: currently only contains one subkey 'editor' which indicates which
|
||||
* in-place editor should be used. Possible values are 'form', 'plain_text',
|
||||
* 'disabled' or another in-place editor other than the ones Edit module
|
||||
* provides.
|
||||
* Quick Edit extends the @FieldFormatter annotation with the following keys:
|
||||
* - quickedit: currently only contains one subkey 'editor' which indicates
|
||||
* which in-place editor should be used. Possible values are 'form',
|
||||
* 'plain_text', 'disabled' or another in-place editor other than the ones
|
||||
* Quick Edit module provides.
|
||||
*/
|
||||
function edit_field_formatter_info_alter(&$info) {
|
||||
function quickedit_field_formatter_info_alter(&$info) {
|
||||
foreach ($info as $key => $settings) {
|
||||
// Set in-place editor to 'form' if none is supplied.
|
||||
if (empty($settings['edit'])) {
|
||||
$info[$key]['edit'] = array('editor' => 'form');
|
||||
if (empty($settings['quickedit'])) {
|
||||
$info[$key]['quickedit'] = array('editor' => 'form');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -116,14 +120,14 @@ function edit_field_formatter_info_alter(&$info) {
|
|||
/**
|
||||
* Implements hook_preprocess_HOOK() for field templates.
|
||||
*/
|
||||
function edit_preprocess_field(&$variables) {
|
||||
function quickedit_preprocess_field(&$variables) {
|
||||
$element = $variables['element'];
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
$entity = $element['#object'];
|
||||
|
||||
// Edit module only supports view modes, not dynamically defined "display
|
||||
// options" (which \Drupal\Core\Field\FieldItemListInterface::view() always
|
||||
// names the "_custom" view mode).
|
||||
// Quick Edit module only supports view modes, not dynamically defined
|
||||
// "display options" (which \Drupal\Core\Field\FieldItemListInterface::view()
|
||||
// always names the "_custom" view mode).
|
||||
// @see \Drupal\Core\Field\FieldItemListInterface::view()
|
||||
// @see https://drupal.org/node/2120335
|
||||
if ($element['#view_mode'] === '_custom') {
|
||||
|
@ -134,14 +138,14 @@ function edit_preprocess_field(&$variables) {
|
|||
// fields") and computed fields are not editable.
|
||||
$definition = $entity->getFieldDefinition($element['#field_name']);
|
||||
if ($definition && !$definition->isComputed()) {
|
||||
$variables['attributes']['data-edit-field-id'] = $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
|
||||
$variables['attributes']['data-quickedit-field-id'] = $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function edit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
$build['#attributes']['data-edit-entity-id'] = $entity->getEntityTypeId() . '/' . $entity->id();
|
||||
function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
$build['#attributes']['data-quickedit-entity-id'] = $entity->getEntityTypeId() . '/' . $entity->id();
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
quickedit.metadata:
|
||||
path: '/quickedit/metadata'
|
||||
defaults:
|
||||
_controller: '\Drupal\quickedit\QuickEditController::metadata'
|
||||
options:
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
|
||||
quickedit.attachments:
|
||||
path: '/quickedit/attachments'
|
||||
defaults:
|
||||
_controller: '\Drupal\quickedit\QuickEditController::attachments'
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
|
||||
quickedit.field_form:
|
||||
path: '/quickedit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}'
|
||||
defaults:
|
||||
_controller: '\Drupal\quickedit\QuickEditController::fieldForm'
|
||||
options:
|
||||
_access_mode: 'ALL'
|
||||
_theme: ajax_base_page
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
_access_quickedit_entity_field: 'TRUE'
|
||||
|
||||
quickedit.entity_save:
|
||||
path: '/quickedit/entity/{entity_type}/{entity}'
|
||||
defaults:
|
||||
_controller: '\Drupal\quickedit\QuickEditController::entitySave'
|
||||
requirements:
|
||||
_permission: 'access in-place editing'
|
||||
_access_quickedit_entity: 'TRUE'
|
|
@ -0,0 +1,20 @@
|
|||
services:
|
||||
plugin.manager.quickedit.editor:
|
||||
class: Drupal\quickedit\Plugin\InPlaceEditorManager
|
||||
parent: default_plugin_manager
|
||||
access_check.quickedit.entity_field:
|
||||
class: Drupal\quickedit\Access\EditEntityFieldAccessCheck
|
||||
arguments: ['@entity.manager']
|
||||
tags:
|
||||
- { name: access_check, applies_to: _access_quickedit_entity_field }
|
||||
access_check.quickedit.entity:
|
||||
class: Drupal\quickedit\Access\EditEntityAccessCheck
|
||||
arguments: ['@entity.manager']
|
||||
tags:
|
||||
- { name: access_check, applies_to: _access_quickedit_entity }
|
||||
quickedit.editor.selector:
|
||||
class: Drupal\quickedit\EditorSelector
|
||||
arguments: ['@plugin.manager.quickedit.editor', '@plugin.manager.field.formatter']
|
||||
quickedit.metadata.generator:
|
||||
class: Drupal\quickedit\MetadataGenerator
|
||||
arguments: ['@access_check.quickedit.entity_field', '@quickedit.editor.selector', '@plugin.manager.quickedit.editor']
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Tests\Access\EditEntityAccessCheckTest.
|
||||
* Contains \Drupal\quickedit\Tests\Access\EditEntityAccessCheckTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests\Access;
|
||||
namespace Drupal\quickedit\Tests\Access;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Drupal\Core\Access\AccessCheckInterface;
|
||||
use Drupal\edit\Access\EditEntityAccessCheck;
|
||||
use Drupal\quickedit\Access\EditEntityAccessCheck;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
|
@ -18,16 +18,16 @@ use Drupal\Core\Entity\EntityInterface;
|
|||
* Tests the edit entity access controller.
|
||||
*
|
||||
* @group Drupal
|
||||
* @group Edit
|
||||
* @group QuickEdit
|
||||
*
|
||||
* @see \Drupal\edit\Access\EditEntityAccessCheck
|
||||
* @see \Drupal\quickedit\Access\EditEntityAccessCheck
|
||||
*/
|
||||
class EditEntityAccessCheckTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The tested access checker.
|
||||
*
|
||||
* @var \Drupal\edit\Access\EditEntityAccessCheck
|
||||
* @var \Drupal\quickedit\Access\EditEntityAccessCheck
|
||||
*/
|
||||
protected $editAccessCheck;
|
||||
|
||||
|
@ -49,7 +49,7 @@ class EditEntityAccessCheckTest extends UnitTestCase {
|
|||
return array(
|
||||
'name' => 'Edit entity access check test',
|
||||
'description' => 'Unit test of edit entity access check.',
|
||||
'group' => 'Edit'
|
||||
'group' => 'Quick Edit'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ class EditEntityAccessCheckTest extends UnitTestCase {
|
|||
/**
|
||||
* Provides test data for testAccess().
|
||||
*
|
||||
* @see \Drupal\edit\Tests\edit\Access\EditEntityAccessCheckTest::testAccess()
|
||||
* @see \Drupal\quickedit\Tests\quickedit\Access\EditEntityAccessCheckTest::testAccess()
|
||||
*/
|
||||
public function providerTestAccess() {
|
||||
$editable_entity = $this->getMockBuilder('Drupal\entity_test\Entity\EntityTest')
|
||||
|
@ -103,7 +103,7 @@ class EditEntityAccessCheckTest extends UnitTestCase {
|
|||
* @dataProvider providerTestAccess
|
||||
*/
|
||||
public function testAccess(EntityInterface $entity, $expected_result) {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity' => 'TRUE'));
|
||||
$request = new Request();
|
||||
|
||||
// Prepare the request to be valid.
|
||||
|
@ -119,7 +119,7 @@ class EditEntityAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with an undefined entity type.
|
||||
*/
|
||||
public function testAccessWithUndefinedEntityType() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'non_valid');
|
||||
|
||||
|
@ -136,7 +136,7 @@ class EditEntityAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with a non existing entity.
|
||||
*/
|
||||
public function testAccessWithNotExistingEntity() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'entity_test');
|
||||
$request->attributes->set('entity', 1);
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit\Tests\Access\EditEntityFieldAccessCheckTest.
|
||||
* Contains \Drupal\quickedit\Tests\Access\EditEntityFieldAccessCheckTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit\Tests\Access;
|
||||
namespace Drupal\quickedit\Tests\Access;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Drupal\Core\Access\AccessCheckInterface;
|
||||
use Drupal\edit\Access\EditEntityFieldAccessCheck;
|
||||
use Drupal\quickedit\Access\EditEntityFieldAccessCheck;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\field\FieldConfigInterface;
|
||||
use Drupal\Core\Language\Language;
|
||||
|
@ -20,16 +20,16 @@ use Drupal\Core\Entity\EntityInterface;
|
|||
* Tests the edit entity field access controller.
|
||||
*
|
||||
* @group Drupal
|
||||
* @group Edit
|
||||
* @group QuickEdit
|
||||
*
|
||||
* @see \Drupal\edit\Access\EditEntityFieldAccessCheck
|
||||
* @see \Drupal\quickedit\Access\EditEntityFieldAccessCheck
|
||||
*/
|
||||
class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The tested access checker.
|
||||
*
|
||||
* @var \Drupal\edit\Access\EditEntityFieldAccessCheck
|
||||
* @var \Drupal\quickedit\Access\EditEntityFieldAccessCheck
|
||||
*/
|
||||
protected $editAccessCheck;
|
||||
|
||||
|
@ -51,7 +51,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
return array(
|
||||
'name' => 'Edit entity field access check test',
|
||||
'description' => 'Unit test of edit entity field access check.',
|
||||
'group' => 'Edit'
|
||||
'group' => 'Quick Edit'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
/**
|
||||
* Provides test data for testAccess().
|
||||
*
|
||||
* @see \Drupal\edit\Tests\edit\Access\EditEntityFieldAccessCheckTest::testAccess()
|
||||
* @see \Drupal\edit\Tests\quickedit\Access\EditEntityFieldAccessCheckTest::testAccess()
|
||||
*/
|
||||
public function providerTestAccess() {
|
||||
$editable_entity = $this->createMockEntity();
|
||||
|
@ -118,7 +118,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
* @dataProvider providerTestAccess
|
||||
*/
|
||||
public function testAccess(EntityInterface $entity, FieldConfigInterface $field = NULL, $expected_result) {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
|
||||
$entity_with_field = clone $entity;
|
||||
|
@ -146,7 +146,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with an undefined entity type.
|
||||
*/
|
||||
public function testAccessWithUndefinedEntityType() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'non_valid');
|
||||
|
||||
|
@ -163,7 +163,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with a non existing entity.
|
||||
*/
|
||||
public function testAccessWithNotExistingEntity() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'entity_test');
|
||||
$request->attributes->set('entity', 1);
|
||||
|
@ -186,7 +186,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with a forgotten passed field_name.
|
||||
*/
|
||||
public function testAccessWithNotPassedFieldName() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'entity_test');
|
||||
$request->attributes->set('entity', $this->createMockEntity());
|
||||
|
@ -199,7 +199,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with a non existing field.
|
||||
*/
|
||||
public function testAccessWithNonExistingField() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'entity_test');
|
||||
$request->attributes->set('entity', $this->createMockEntity());
|
||||
|
@ -213,7 +213,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
* Tests the access method with a forgotten passed language.
|
||||
*/
|
||||
public function testAccessWithNotPassedLanguage() {
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'entity_test');
|
||||
$request->attributes->set('entity', $this->createMockEntity());
|
||||
|
@ -233,7 +233,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
->with('xx-lolspeak')
|
||||
->will($this->returnValue(FALSE));
|
||||
|
||||
$route = new Route('/edit/form/test_entity/1/body/und/full', array(), array('_access_edit_entity_field' => 'TRUE'));
|
||||
$route = new Route('/quickedit/form/test_entity/1/body/und/full', array(), array('_access_quickedit_entity_field' => 'TRUE'));
|
||||
$request = new Request();
|
||||
$request->attributes->set('entity_type', 'entity_test');
|
||||
$request->attributes->set('entity', $entity);
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit_test\MockEditEntityFieldAccessCheck.
|
||||
* Contains \Drupal\quickedit_test\MockEditEntityFieldAccessCheck.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit_test;
|
||||
namespace Drupal\quickedit_test;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\edit\Access\EditEntityFieldAccessCheckInterface;
|
||||
use Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface;
|
||||
|
||||
/**
|
||||
* Access check for editing entity fields.
|
|
@ -2,13 +2,13 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\edit_test\Plugin\InPlaceEditor\WysiwygEditor.
|
||||
* Contains \Drupal\quickedit_test\Plugin\InPlaceEditor\WysiwygEditor.
|
||||
*/
|
||||
|
||||
namespace Drupal\edit_test\Plugin\InPlaceEditor;
|
||||
namespace Drupal\quickedit_test\Plugin\InPlaceEditor;
|
||||
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\edit\Plugin\InPlaceEditorBase;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorBase;
|
||||
|
||||
/**
|
||||
* Defines the 'wysiwyg' in-place editor.
|
||||
|
@ -55,7 +55,7 @@ class WysiwygEditor extends InPlaceEditorBase {
|
|||
public function getAttachments() {
|
||||
return array(
|
||||
'library' => array(
|
||||
'edit_test/not-existing-wysiwyg',
|
||||
'quickedit_test/not-existing-wysiwyg',
|
||||
),
|
||||
);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
name: 'Quick Edit test'
|
||||
type: module
|
||||
description: 'Support module for the Quick Edit module tests.'
|
||||
core: 8.x
|
||||
package: Testing
|
||||
version: VERSION
|
||||
hidden: true
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for the Edit tests.
|
||||
* Helper module for the Quick Edit tests.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Language\Language;
|
||||
|
@ -12,12 +12,12 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
|||
/**
|
||||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function edit_test_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
function quickedit_test_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'article') {
|
||||
$build['pseudo'] = array(
|
||||
'#theme' => 'field',
|
||||
'#title' => 'My pseudo field',
|
||||
'#field_name' => 'edit_test_pseudo_field',
|
||||
'#field_name' => 'quickedit_test_pseudo_field',
|
||||
'#label_display' => 'Label',
|
||||
'#entity_type' => $entity->getEntityTypeId(),
|
||||
'#bundle' => $entity->bundle(),
|
||||
|
@ -39,12 +39,12 @@ function edit_test_entity_view_alter(&$build, EntityInterface $entity, EntityVie
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements hook_edit_render_field().
|
||||
* Implements hook_quickedit_render_field().
|
||||
*/
|
||||
function edit_test_edit_render_field(EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
|
||||
function quickedit_test_quickedit_render_field(EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
|
||||
$entity = \Drupal::entityManager()->getTranslationFromContext($entity, $langcode);
|
||||
return array(
|
||||
'#prefix' => '<div class="edit-test-wrapper">',
|
||||
'#prefix' => '<div class="quickedit-test-wrapper">',
|
||||
'field' => $entity->get($field_name)->view($view_mode_id),
|
||||
'#suffix' => '</div>',
|
||||
);
|
|
@ -21,7 +21,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
* "text_long",
|
||||
* "text_with_summary",
|
||||
* },
|
||||
* edit = {
|
||||
* quickedit = {
|
||||
* "editor" = "plain_text"
|
||||
* }
|
||||
* )
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Drupal\text\Plugin\Field\FieldFormatter;
|
|||
* field_types = {
|
||||
* "text_with_summary"
|
||||
* },
|
||||
* edit = {
|
||||
* quickedit = {
|
||||
* "editor" = "form"
|
||||
* }
|
||||
* )
|
||||
|
|
|
@ -25,7 +25,7 @@ use Drupal\Core\Field\FieldItemListInterface;
|
|||
* "text_long",
|
||||
* "text_with_summary"
|
||||
* },
|
||||
* edit = {
|
||||
* quickedit = {
|
||||
* "editor" = "form"
|
||||
* }
|
||||
* )
|
||||
|
|
|
@ -16,7 +16,7 @@ dependencies:
|
|||
- contact
|
||||
- datetime
|
||||
- custom_block
|
||||
- edit
|
||||
- quickedit
|
||||
- editor
|
||||
- entity_reference
|
||||
- help
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
/**
|
||||
* @file
|
||||
* Override Edit's entity toolbar style on the Drupal front-end.
|
||||
* Override Quick Edit's entity toolbar style on the Drupal front-end.
|
||||
*
|
||||
* I.e. loaded by Edit on the front-end, despite this being a back-end theme.
|
||||
* I.e. loaded by Quick Edit on the front-end, despite this being a back-end theme.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Seven style guide prescribes softer corners.
|
||||
*/
|
||||
.edit-toolbar-container > .edit-toolbar-content,
|
||||
.edit-toolbar-container > .edit-toolbar-lining {
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-content,
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-lining {
|
||||
border-radius: 4px;
|
||||
}
|
||||
.edit-button {
|
||||
.quickedit-button {
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity toolbar's "save" button must be styled like a Seven primary button.
|
||||
*/
|
||||
.edit-button.action-save,
|
||||
.edit-button.action-saving {
|
||||
.quickedit-button.action-save,
|
||||
.quickedit-button.action-saving {
|
||||
border-color: #1e5c90;
|
||||
background-image: -webkit-linear-gradient(top, #007bc6, #0071b8);
|
||||
background-image: -moz-linear-gradient(top, #007bc6, #0071b8);
|
||||
|
@ -32,10 +32,10 @@
|
|||
-webkit-font-smoothing: antialiased;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.edit-button.action-save:focus,
|
||||
.edit-button.action-save:hover,
|
||||
.edit-button.action-saving:focus
|
||||
.edit-button.action-saving:hover {
|
||||
.quickedit-button.action-save:focus,
|
||||
.quickedit-button.action-save:hover,
|
||||
.quickedit-button.action-saving:focus
|
||||
.quickedit-button.action-saving:hover {
|
||||
background-color: #2369a6;
|
||||
background-image: -webkit-linear-gradient(top, #0c97ed, #1f86c7);
|
||||
background-image: -moz-linear-gradient(top, #0c97ed, #1f86c7);
|
||||
|
@ -44,12 +44,12 @@
|
|||
border-color: #1e5c90;
|
||||
color: #fff;
|
||||
}
|
||||
.edit-button.action-save:hover,
|
||||
.edit-button.action-saving:hover {
|
||||
.quickedit-button.action-save:hover,
|
||||
.quickedit-button.action-saving:hover {
|
||||
box-shadow: 0 1px 2px hsla(203, 10%, 10%, 0.25);
|
||||
}
|
||||
.edit-button.action-save:active,
|
||||
.edit-button.action-saving:active {
|
||||
.quickedit-button.action-save:active,
|
||||
.quickedit-button.action-saving:active {
|
||||
background-image: -webkit-linear-gradient(top, #08639b, #0071b8);
|
||||
background-image: -moz-linear-gradient(top, #08639b, #0071b8);
|
||||
background-image: -o-linear-gradient(top, #08639b, #0071b8);
|
||||
|
@ -62,6 +62,6 @@
|
|||
* The entity toolbar's "save" button's top margin shifts both buttons 2px down,
|
||||
* so we must compensate for that to achieve vertically centered positioning.
|
||||
*/
|
||||
.edit .icon-close:before {
|
||||
.quickedit .icon-close:before {
|
||||
top: 8px;
|
||||
}
|
|
@ -14,8 +14,8 @@ stylesheets:
|
|||
stylesheets-override:
|
||||
- vertical-tabs.css
|
||||
- jquery.ui.theme.css
|
||||
edit_stylesheets:
|
||||
- edit.css
|
||||
quickedit_stylesheets:
|
||||
- quickedit.css
|
||||
regions:
|
||||
content: Content
|
||||
help: Help
|
||||
|
|
Loading…
Reference in New Issue