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