Total Complexity | 9 |
Complexity/F | 1.13 |
Lines of Code | 47 |
Function Count | 8 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | (function ($) { |
||
2 | 'use strict'; |
||
3 | |||
4 | $.fn.extend({ |
||
5 | moveVendor(positionInput) { |
||
6 | const vendorRows = []; |
||
7 | const element = this; |
||
8 | |||
9 | element.api({ |
||
10 | method: 'PUT', |
||
11 | beforeSend(settings) { |
||
12 | /* eslint-disable-next-line no-param-reassign */ |
||
13 | settings.data = { |
||
14 | vendors: vendorRows, |
||
15 | _csrf_token: element.data('csrf-token'), |
||
16 | }; |
||
17 | |||
18 | return settings; |
||
19 | }, |
||
20 | onSuccess() { |
||
21 | window.location.reload(); |
||
22 | }, |
||
23 | }); |
||
24 | |||
25 | positionInput.on('input', (event) => { |
||
26 | const input = $(event.currentTarget); |
||
27 | const vendorId = input.data('id'); |
||
28 | const row = vendorRows.find(({ id }) => id === vendorId); |
||
29 | |||
30 | if (!row) { |
||
31 | vendorRows.push({ |
||
32 | id: vendorId, |
||
33 | position: input.val(), |
||
34 | }); |
||
35 | } else { |
||
36 | row.position = input.val(); |
||
37 | } |
||
38 | }); |
||
39 | } |
||
40 | }); |
||
41 | })(jQuery); |
||
42 | |||
43 | (function($) { |
||
44 | $(document).ready(function () { |
||
45 | $('.odiseo-update-vendors').moveVendor($('.odiseo-vendor-position')); |
||
46 | }); |
||
47 | })(jQuery); |
||
48 |