We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 1 |
Paths | 2 |
Total Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | define(['jquery', 'routing'], ($, Routing) => { |
||
3 | attach(element, input) { |
||
4 | let $el = $(element), |
||
5 | $input = $(input); |
||
6 | |||
7 | $input.on('change', () => { |
||
8 | if ('' === $input.val()) { |
||
9 | $input |
||
10 | .closest('.form-group') |
||
11 | .removeClass('has-success has-error') |
||
12 | } |
||
13 | }); |
||
14 | |||
15 | $el.on('click', (e) => { |
||
16 | e.preventDefault(); |
||
17 | let original = $el.html(); |
||
18 | |||
19 | $el.html('<i class="fa fa-spin fa-refresh"></i>'); |
||
20 | |||
21 | $.ajax({ |
||
22 | 'url' : Routing.generate('_tax_number_validate'), |
||
23 | 'data': {'vat_number': $input.val()}, |
||
24 | 'method': 'POST' |
||
25 | }).done((result) => { |
||
26 | $input |
||
27 | .closest('.form-group') |
||
28 | .removeClass('has-success has-error') |
||
29 | .addClass(result.valid ? 'has-success' : 'has-error'); |
||
30 | }).always(() => { |
||
31 | $el.html(original); |
||
32 | }); |
||
33 | }); |
||
34 | } |
||
35 | }; |
||
36 | }); |
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code.
Further Reading: