Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the services navigation child drop links to work on any link field #260

Open
andybroomfield opened this issue May 24, 2024 · 1 comment

Comments

@andybroomfield
Copy link
Contributor

Currently these work for common tasks, landing child page and sublanding topic list builder.
Be handy to be able to use them on any link field.
Details TBC.

@andybroomfield
Copy link
Contributor Author

Just noting the following

  Drupal.behaviors.uriDrop = {
    attach: function attach(context, settings) {
      var linkRow = $(".js-form-type-entity-autocomplete").closest("tr");
      linkRow.each(function() {
        this.addEventListener('dragover', function (event) {
          var row = $(event.target).closest('tr');
          var url = $("input[data-drupal-selector$=uri]", row);
          if (url.val() == '') {
            event.preventDefault();
            event.dataTransfer.dropEffect = "move";
          }
        });
        this.addEventListener('drop', function(event) {
          var row = $(event.target).closest('tr');
          var url = $("input[data-drupal-selector$=uri]", row);
          if (url.val() == '') {
            event.preventDefault();
            var title = $("input[data-drupal-selector$=title]", row);
            title.val(dragChild.getAttribute('data-localgov-title'));
            url.val(dragChild.getAttribute('data-localgov-url'));
            $(dragChild).remove();
          }
        });
      });
    }
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant