| @@ -79,8 +79,9 @@ | ||
| 79 | 79 | </div> |
| 80 | 80 | <table class="ticket-fields wpsc-setting-tbl"> |
| 81 | 81 | <thead> |
| 82 | 82 | <tr> |
| 83 | + <th style="width: 30px;"><?php esc_attr_e( 'Sort', 'supportcandy' ); ?></th> | |
| 83 | 84 | <th><?php esc_attr_e( 'Field', 'supportcandy' ); ?></th> |
| 84 | 85 | <th><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></th> |
| 85 | 86 | <th><?php esc_attr_e( 'Type', 'supportcandy' ); ?></th> |
| 86 | 87 | <th><?php esc_attr_e( 'Auto Fill', 'supportcandy' ); ?></th> |
| @@ -94,9 +95,10 @@ | ||
| 94 | 95 | if ( $cf->field != 'ticket' ) { |
| 95 | 96 | continue; |
| 96 | 97 | } |
| 97 | 98 | ?> |
| 98 | - <tr> | |
| 99 | + <tr data-id="<?php echo esc_attr( $cf->id ); ?>"> | |
| 100 | + <td class="sort-handle"><?php WPSC_Icons::get( 'sort' ); ?></td> | |
| 99 | 101 | <td><?php echo esc_attr( $cf->name ); ?></td> |
| 100 | 102 | <td><?php echo esc_attr( $cf->extra_info ); ?></td> |
| 101 | 103 | <td><?php echo esc_attr( $custom_fields_types[ $cf->type::$slug ]['label'] ); ?></td> |
| 102 | 104 | <td><?php echo esc_attr( $cf->is_auto_fill ? __( 'Yes', 'supportcandy' ) : __( 'No', 'supportcandy' ) ); ?></td> |
| @@ -120,11 +122,13 @@ | ||
| 120 | 122 | </table> |
| 121 | 123 | <script> |
| 122 | 124 | jQuery('table.ticket-fields').DataTable({ |
| 123 | 125 | ordering: false, |
| 126 | + autoWidth: false, | |
| 124 | 127 | pageLength: 20, |
| 125 | 128 | bLengthChange: false, |
| 126 | - columnDefs: [ | |
| 129 | + columnDefs: [ | |
| 130 | + { targets: 0, width: '30px', searchable: false }, | |
| 127 | 131 | { targets: -1, searchable: false }, |
| 128 | 132 | { targets: '_all', className: 'dt-left' } |
| 129 | 133 | ], |
| 130 | 134 | layout: { |
| @@ -140,8 +144,37 @@ | ||
| 140 | 144 | ], |
| 141 | 145 | }, |
| 142 | 146 | }, |
| 143 | 147 | language: supportcandy.translations.datatables |
| 148 | + }); | |
| 149 | + | |
| 150 | + jQuery(function() { | |
| 151 | + // Enable sorting with jQuery UI. | |
| 152 | + jQuery('table.ticket-fields tbody').sortable({ | |
| 153 | + handle: '.sort-handle', | |
| 154 | + helper: function(e, tr) { | |
| 155 | + var $originals = tr.children(); | |
| 156 | + var $helper = tr.clone(); | |
| 157 | + $helper.children().each(function(index) { | |
| 158 | + jQuery(this).width($originals.eq(index).width()); | |
| 159 | + }); | |
| 160 | + return $helper; | |
| 161 | + }, | |
| 162 | + update: function(event, ui) { | |
| 163 | + var ids = jQuery(this).sortable('toArray', { attribute: 'data-id' }); | |
| 164 | + jQuery.post( | |
| 165 | + supportcandy.ajax_url, | |
| 166 | + { | |
| 167 | + action: 'wpsc_set_custom_field_load_order', | |
| 168 | + _ajax_nonce: '<?php echo esc_attr( wp_create_nonce( 'wpsc_set_custom_field_load_order' ) ); ?>', | |
| 169 | + ids: ids | |
| 170 | + }, | |
| 171 | + function(response) { | |
| 172 | + | |
| 173 | + } | |
| 174 | + ); | |
| 175 | + } | |
| 176 | + }); | |
| 144 | 177 | }); |
| 145 | 178 | </script> |
| 146 | 179 | </div> |
| 147 | 180 | <?php |