Unverified Commit b3aa8684 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3101808 by idebr, Lendude: Do not warn users of unsaved changes to the...

Issue #3101808 by idebr, Lendude: Do not warn users of unsaved changes to the form when clicking links in the media library widget that open in a new window
parent 61fa1bf2
Loading
Loading
Loading
Loading
+0 −24
Original line number Diff line number Diff line
@@ -35,30 +35,6 @@
    });
  };

  /**
   * Warn users when clicking outgoing links from the library or widget.
   *
   * @type {Drupal~behavior}
   *
   * @prop {Drupal~behaviorAttach} attach
   *   Attaches behavior to links in the media library.
   */
  Drupal.behaviors.MediaLibraryWidgetWarn = {
    attach(context) {
      $('.js-media-library-item a[href]', context)
        .once('media-library-warn-link')
        .on('click', e => {
          const message = Drupal.t(
            'Unsaved changes to the form will be lost. Are you sure you want to leave?',
          );
          const confirmation = window.confirm(message);
          if (!confirmation) {
            e.preventDefault();
          }
        });
    },
  };

  /**
   * Load media library content through AJAX.
   *
+0 −12
Original line number Diff line number Diff line
@@ -16,18 +16,6 @@
    });
  };

  Drupal.behaviors.MediaLibraryWidgetWarn = {
    attach: function attach(context) {
      $('.js-media-library-item a[href]', context).once('media-library-warn-link').on('click', function (e) {
        var message = Drupal.t('Unsaved changes to the form will be lost. Are you sure you want to leave?');
        var confirmation = window.confirm(message);
        if (!confirmation) {
          e.preventDefault();
        }
      });
    }
  };

  Drupal.behaviors.MediaLibraryTabs = {
    attach: function attach(context) {
      var $menu = $('.js-media-library-menu');