3 * Provides JavaScript additions to entity embed dialog.
5 * This file provides popup windows for previewing embedded entities from the
9 (function ($, Drupal) {
14 * Attach behaviors to links for entities.
16 Drupal.behaviors.entityEmbedPreviewEntities = {
17 attach: function (context) {
18 $(context).find('form.entity-embed-dialog .form-item-entity a').on('click', Drupal.entityEmbedDialog.openInNewWindow);
20 detach: function (context) {
21 $(context).find('form.entity-embed-dialog .form-item-entity a').off('click', Drupal.entityEmbedDialog.openInNewWindow);
26 * Behaviors for the entityEmbedDialog iframe.
28 Drupal.behaviors.entityEmbedDialog = {
29 attach: function (context, settings) {
30 $('body').once('js-entity-embed-dialog').on('entityBrowserIFrameAppend', function () {
31 $('.entity-select-dialog').trigger('resize');
32 // Hide the next button, the click is triggered by Drupal.entityEmbedDialog.selectionCompleted.
33 $('#drupal-modal').parent().find('.js-button-next').addClass('visually-hidden');
39 * Entity Embed dialog utility functions.
41 Drupal.entityEmbedDialog = Drupal.entityEmbedDialog || {
43 * Open links to entities within forms in a new window.
45 openInNewWindow: function (event) {
46 event.preventDefault();
47 $(this).attr('target', '_blank');
48 window.open(this.href, 'entityPreview', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1');
50 selectionCompleted: function(event, uuid, entities) {
51 $('.entity-select-dialog .js-button-next').click();