Sha256: 982797075d4dbdfe7ca7b8efdeae0745b2ec4ee6f7e81ffc8ddf1a3fd6adb848
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
export default function() { if ( $('.sortable').length > 0 ) { // Initialize sortable item $('.sortable') .sortable({ placeholder: "ui-state-highlight", update: function () { $.post( $(this).data('update-url'), $(this).sortable('serialize') ) } }) // Check if sortable item needs handles $('.sortable').each( function() { if ( $(this).find('.sortable--handle').length > 0 ) { $(this).sortable('option', 'handle', '.sortable--handle') } else { $(this).addClass('sortable--no-handle') } }) $('.sortable--disabled').sortable('disable') } $(document).on( 'click', '.sortable--toggle', function( event ) { event.preventDefault() let id = '#' + $( this ).data( 'repeater-id' ) if ( $( id ).hasClass('sortable--disabled') ) { $( id ).sortable('enable') } else { $( id ).sortable('disable') } $( id ).toggleClass('sortable--disabled') $( id ).toggleClass('sortable--enabled') $( this ).children('.sortable--toggle-text').toggle() }) }
Version data entries
3 entries across 3 versions & 1 rubygems