metatag.admin.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @file
  3. * Custom admin-side JS for the Metatag module.
  4. */
  5. (function ($) {
  6. 'use strict';
  7. Drupal.behaviors.metatagUIConfigListing = {
  8. attach: function (context) {
  9. // Hidden elements to be visible if JavaScript is enabled.
  10. $('.js-show').show();
  11. // Make the leaf arrow clickable.
  12. $('.metatag-config-label').hover(function(){
  13. $(this).css({'cursor': 'pointer'});
  14. })
  15. .click(function(){
  16. $(this).find('a.toggle-details', context).trigger('click');
  17. });
  18. // Show or hide the summary
  19. $('table.metatag-config-overview a.toggle-details', context).click(function(event) {
  20. $(this).parent('div').siblings('div.metatag-config-details').each(function() {
  21. if ($(this).hasClass('js-hide')) {
  22. $(this).slideDown('slow').removeClass('js-hide');
  23. }
  24. else {
  25. $(this).slideUp('slow').addClass('js-hide');
  26. }
  27. });
  28. // Change the expanded or collapsed state of the instance label.
  29. if ($(this).parent('div').hasClass('collapsed')) {
  30. $(this).parent('div').removeClass('collapsed').addClass('expanded');
  31. }
  32. else {
  33. $(this).parent('div').removeClass('expanded').addClass('collapsed');
  34. }
  35. // This event may be triggered by a parent element click - so we don't
  36. // want the click to bubble up otherwise we get recursive click events.
  37. event.stopPropagation();
  38. });
  39. }
  40. };
  41. })(jQuery);