diff -u b/paragraphs.libraries.yml b/paragraphs.libraries.yml --- b/paragraphs.libraries.yml +++ b/paragraphs.libraries.yml @@ -28 +28 @@ - js/paragraphs.js: {} + js/paragraphs.admin.js: {} only in patch2: unchanged: --- /dev/null +++ b/js/paragraphs.admin.js @@ -0,0 +1,32 @@ +(function ($, Drupal, drupalSettings) { + /** + * For body tag, adds tabs for selecting how the content will be displayed. + * + * @type {Drupal~behavior} + */ + Drupal.behaviors.bodyTabs = { + attach: function (context, settings) { + $('ul.paragraphs-tabs', context).each(function () { + var $this = $(this); + $this.parent().tabs({ + activate: function( event, ui ) { + if (ui.newTab.attr('id') == 'content') { + $('.paragraphs-content').show(); + $('.paragraphs-behavior').hide(); + } + else { + $('.paragraphs-content').hide(); + $('.paragraphs-nested.paragraphs-subform > .paragraphs-content').show(); + $('.paragraphs-behavior').show(); + } + }, + create: function( event, ui ) { + $('.paragraphs-content').show(); + $('.paragraphs-behavior').hide(); + } + }); + }); + } + }; + +})(jQuery, Drupal, drupalSettings);