Loading js/gutenberg.es6.js +28 −2 Original line number Diff line number Diff line Loading @@ -666,16 +666,42 @@ * @type {{attach(): (undefined)}} */ Drupal.behaviors.gutenbergMediaLibrary = { attach() { attach(context) { const $form = $('#media-entity-browser-modal .media-library-add-form'); const $context = $(context); const $dialog = $context.closest('.ui-dialog-content'); if (!$form.length) { return; } // Storing initial buttons to recover them when needed. Drupal.gutenbergMediaLibraryButtons = Drupal.gutenbergMediaLibraryButtons || $dialog.dialog('option', 'buttons'); // Altering new media entity form buttons. $form .find('[data-drupal-selector="edit-save-insert"]') .css('display', 'none'); const saveAndSelectButton = $form.find('[data-drupal-selector="edit-save-select"]'); if (saveAndSelectButton.length) { // Hide button. saveAndSelectButton.css({ display: 'none' }); // Move button to buttonpane. let buttons = []; buttons.push({ text: saveAndSelectButton.html() || saveAndSelectButton.attr('value'), class: saveAndSelectButton.attr('class'), click: function click(e) { saveAndSelectButton.trigger('mousedown').trigger('mouseup').trigger('click'); e.preventDefault(); } }); $dialog.dialog('option', 'buttons', buttons); } else { $dialog.dialog('option', 'buttons', Drupal.gutenbergMediaLibraryButtons); } }, }; Loading js/gutenberg.js +25 −1 Original line number Diff line number Diff line Loading @@ -572,14 +572,38 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a }; Drupal.behaviors.gutenbergMediaLibrary = { attach: function attach() { attach: function attach(context) { var $form = $('#media-entity-browser-modal .media-library-add-form'); var $context = $(context); var $dialog = $context.closest('.ui-dialog-content'); if (!$form.length) { return; } Drupal.gutenbergMediaLibraryButtons = Drupal.gutenbergMediaLibraryButtons || $dialog.dialog('option', 'buttons'); $form.find('[data-drupal-selector="edit-save-insert"]').css('display', 'none'); var saveAndSelectButton = $form.find('[data-drupal-selector="edit-save-select"]'); if (saveAndSelectButton.length) { saveAndSelectButton.css({ display: 'none' }); var buttons = []; buttons.push({ text: saveAndSelectButton.html() || saveAndSelectButton.attr('value'), class: saveAndSelectButton.attr('class'), click: function click(e) { saveAndSelectButton.trigger('mousedown').trigger('mouseup').trigger('click'); e.preventDefault(); } }); $dialog.dialog('option', 'buttons', buttons); } else { $dialog.dialog('option', 'buttons', Drupal.gutenbergMediaLibraryButtons); } } }; Loading Loading
js/gutenberg.es6.js +28 −2 Original line number Diff line number Diff line Loading @@ -666,16 +666,42 @@ * @type {{attach(): (undefined)}} */ Drupal.behaviors.gutenbergMediaLibrary = { attach() { attach(context) { const $form = $('#media-entity-browser-modal .media-library-add-form'); const $context = $(context); const $dialog = $context.closest('.ui-dialog-content'); if (!$form.length) { return; } // Storing initial buttons to recover them when needed. Drupal.gutenbergMediaLibraryButtons = Drupal.gutenbergMediaLibraryButtons || $dialog.dialog('option', 'buttons'); // Altering new media entity form buttons. $form .find('[data-drupal-selector="edit-save-insert"]') .css('display', 'none'); const saveAndSelectButton = $form.find('[data-drupal-selector="edit-save-select"]'); if (saveAndSelectButton.length) { // Hide button. saveAndSelectButton.css({ display: 'none' }); // Move button to buttonpane. let buttons = []; buttons.push({ text: saveAndSelectButton.html() || saveAndSelectButton.attr('value'), class: saveAndSelectButton.attr('class'), click: function click(e) { saveAndSelectButton.trigger('mousedown').trigger('mouseup').trigger('click'); e.preventDefault(); } }); $dialog.dialog('option', 'buttons', buttons); } else { $dialog.dialog('option', 'buttons', Drupal.gutenbergMediaLibraryButtons); } }, }; Loading
js/gutenberg.js +25 −1 Original line number Diff line number Diff line Loading @@ -572,14 +572,38 @@ function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, a }; Drupal.behaviors.gutenbergMediaLibrary = { attach: function attach() { attach: function attach(context) { var $form = $('#media-entity-browser-modal .media-library-add-form'); var $context = $(context); var $dialog = $context.closest('.ui-dialog-content'); if (!$form.length) { return; } Drupal.gutenbergMediaLibraryButtons = Drupal.gutenbergMediaLibraryButtons || $dialog.dialog('option', 'buttons'); $form.find('[data-drupal-selector="edit-save-insert"]').css('display', 'none'); var saveAndSelectButton = $form.find('[data-drupal-selector="edit-save-select"]'); if (saveAndSelectButton.length) { saveAndSelectButton.css({ display: 'none' }); var buttons = []; buttons.push({ text: saveAndSelectButton.html() || saveAndSelectButton.attr('value'), class: saveAndSelectButton.attr('class'), click: function click(e) { saveAndSelectButton.trigger('mousedown').trigger('mouseup').trigger('click'); e.preventDefault(); } }); $dialog.dialog('option', 'buttons', buttons); } else { $dialog.dialog('option', 'buttons', Drupal.gutenbergMediaLibraryButtons); } } }; Loading