Version 1
[yaffs-website] / web / modules / contrib / entity_browser / js / entity_browser.modal_selection.js
diff --git a/web/modules/contrib/entity_browser/js/entity_browser.modal_selection.js b/web/modules/contrib/entity_browser/js/entity_browser.modal_selection.js
new file mode 100644 (file)
index 0000000..6783b42
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * @file entity_browser.modal_selection.js
+ *
+ * Propagates selected entities from modal display.
+ */
+
+(function (drupalSettings) {
+
+  'use strict';
+
+  // We need to access parent window, get it's jquery and find correct modal
+  // element to trigger event on.
+  parent.jQuery(parent.document)
+    .find(':input[data-uuid*=' + drupalSettings.entity_browser.modal.uuid + ']')
+    .trigger('entities-selected', [drupalSettings.entity_browser.modal.uuid, drupalSettings.entity_browser.modal.entities])
+    .unbind('entities-selected').show();
+
+  // This is a silly solution, but works fo now. We should close the modal
+  // via ajax commands.
+  parent.jQuery(parent.document).find('.entity-browser-modal-iframe').parents('.ui-dialog').eq(0).find('.ui-dialog-titlebar-close').click();
+
+}(drupalSettings));