<commit_before>// Sortable fields

// Sortable field sets can be nested multiple times, but need to follow this hierarchy:
// <div class="sortable-field-set">
//   <div class="sortable-field">
//     <div class="sortable-field-set__handle"></div>
//     <div class="sortable-field-set__position">
//       <input type="hidden">
//     </div>
//   </div>
// </div>

$(document).on('turbolinks:load app:block-slot-after-insert', function() {
  var $fieldSets = $('.sortable-field-set');

  $fieldSets.each(function() {
    var $fieldSet = $(this);

    $fieldSet.sortable({
      items: '> .sortable-field',
      containment: $fieldSet,
      // tolerance: 'pointer',
      placeholder: 'sortable-placeholder',
      handle: '.sortable-field-set__handle',
      forcePlaceholderSize: true
    });

    $fieldSet.on('sortupdate.sortableFieldSets', function() {
      calculatePositions( $fieldSet );
    });

    $(document).one('turbolinks:before-cache', function() {<commit_msg>Always run the calculatePositions javascript for ordering sortable fields<commit_after>// Sortable fields

// Sortable field sets can be nested multiple times, but need to follow this hierarchy:
// <div class="sortable-field-set">
//   <div class="sortable-field">
//     <div class="sortable-field-set__handle"></div>
//     <div class="sortable-field-set__position">
//       <input type="hidden">
//     </div>
//   </div>
// </div>

$(document).on('turbolinks:load app:block-slot-after-insert', function() {
  var $fieldSets = $('.sortable-field-set');

  $fieldSets.each(function() {
    var $fieldSet = $(this);

    $fieldSet.sortable({
      items: '> .sortable-field',
      containment: $fieldSet,
      // tolerance: 'pointer',
      placeholder: 'sortable-placeholder',
      handle: '.sortable-field-set__handle',
      forcePlaceholderSize: true
    });

    calculatePositions( $fieldSet );

    $fieldSet.on('sortupdate.sortableFieldSets', function() {
      calculatePositions( $fieldSet );
    });

    $(document).one('turbolinks:before-cache', function() {
{'fraction_non_alphanumeric': 0.17137293086660174, 'fraction_numerical': 0.0, 'mean_word_length': 3.3446088794926006, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3633628', 'n_tokens_mistral': 642, 'n_tokens_neox': 632, 'n_words': 128}