1/** 2 * @file vandoorn_media.sort.js 3 */ 4 5(function ($, Drupal, once) { 6 7 "use strict"; 8 Drupal.behaviors.mediaFieldSort = { 9 attach: function (context, settings) { 10 $(once('sortable', '.entity-type--media.sortable tbody')).each(function() { 11 let sort_options = { 12 group: { 13 name: "media", 14 pull: false, 15 put: false 16 }, 17 onSort: function(event) { 18 let $form_field = $(this.el).closest('.field--type-entity-reference'); 19 let class_list = $form_field.attr('class').split(/\s+/); 20 let field_name = ''; 21 $.each(class_list, function(index, item) { 22 if (item.substring(0, 12) == 'field--name-') { 23 field_name = item.substring(12); 24 } 25 }); 26 let list = ''; 27 $(this.el).find('.rendered-entity').each(function() { 28 list += $(this).attr('data-entity-id') + ' '; 29 }); 30 $form_field.find('[data-drupal-selector^="edit-' + field_name + '-target-id"]').val(list); 31 } 32 }; 33 Sortable.create(this, sort_options); 34 }); 35 } 36 }; 37 38})(jQuery, Drupal, once);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.