Added missing modules, including some as submodules.
[yaffs-website] / web / modules / contrib / entity_embed / js / entity_embed.dialog.js
1 /**
2  * @file
3  * Provides JavaScript additions to entity embed dialog.
4  *
5  * This file provides popup windows for previewing embedded entities from the
6  * embed dialog.
7  */
8
9 (function ($, Drupal) {
10
11   "use strict";
12
13   /**
14    * Attach behaviors to links for entities.
15    */
16   Drupal.behaviors.entityEmbedPreviewEntities = {
17     attach: function (context) {
18       $(context).find('form.entity-embed-dialog .form-item-entity a').on('click', Drupal.entityEmbedDialog.openInNewWindow);
19     },
20     detach: function (context) {
21       $(context).find('form.entity-embed-dialog .form-item-entity a').off('click', Drupal.entityEmbedDialog.openInNewWindow);
22     }
23   };
24
25   /**
26    * Behaviors for the entityEmbedDialog iframe.
27    */
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');
34       });
35     }
36   };
37
38   /**
39    * Entity Embed dialog utility functions.
40    */
41   Drupal.entityEmbedDialog = Drupal.entityEmbedDialog || {
42     /**
43      * Open links to entities within forms in a new window.
44      */
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');
49     },
50     selectionCompleted: function(event, uuid, entities) {
51       $('.entity-select-dialog .js-button-next').click();
52     }
53   };
54
55 })(jQuery, Drupal);