|
1 | | -App.Actions.PACKAGE.enable_unlimited = function (elm, source_elm) { |
2 | | - $(elm).data('checked', true); |
3 | | - $(elm).data('prev_value', $(elm).val()); // save prev value in order to restore if needed |
4 | | - $(elm).val(Alpine.store('globals').UNLIM_TRANSLATED_VALUE); |
5 | | - $(elm).attr('disabled', true); |
6 | | - $(source_elm).css('opacity', '1'); |
7 | | -}; |
8 | | - |
9 | | -App.Actions.PACKAGE.disable_unlimited = function (elm, source_elm) { |
10 | | - $(elm).data('checked', false); |
11 | | - if ($(elm).data('prev_value') && $(elm).data('prev_value').trim() != '') { |
12 | | - var prev_value = $(elm).data('prev_value').trim(); |
13 | | - $(elm).val(prev_value); |
14 | | - if (Alpine.store('globals').isUnlimitedValue(prev_value)) { |
15 | | - $(elm).val('0'); |
16 | | - } |
17 | | - } else { |
18 | | - if (Alpine.store('globals').isUnlimitedValue($(elm).val())) { |
19 | | - $(elm).val('0'); |
20 | | - } |
21 | | - } |
22 | | - $(elm).attr('disabled', false); |
23 | | - $(source_elm).css('opacity', '0.5'); |
24 | | -}; |
25 | | - |
26 | | -// |
27 | | -App.Actions.PACKAGE.toggle_unlimited_feature = function (evt) { |
28 | | - var elm = $(evt.target); |
29 | | - var ref = elm.prev('.form-control'); |
30 | | - if (!$(ref).data('checked')) { |
31 | | - App.Actions.PACKAGE.enable_unlimited(ref, elm); |
32 | | - } else { |
33 | | - App.Actions.PACKAGE.disable_unlimited(ref, elm); |
34 | | - } |
35 | | -}; |
36 | | - |
37 | | -App.Listeners.PACKAGE.checkbox_unlimited_feature = function () { |
38 | | - $('.unlim-trigger').on('click', App.Actions.PACKAGE.toggle_unlimited_feature); |
39 | | -}; |
40 | | - |
41 | | -App.Listeners.PACKAGE.init = function () { |
42 | | - $('.unlim-trigger').each(function (i, elm) { |
43 | | - var ref = $(elm).prev('.form-control'); |
44 | | - if (Alpine.store('globals').isUnlimitedValue($(ref).val())) { |
45 | | - App.Actions.PACKAGE.enable_unlimited(ref, elm); |
46 | | - } else { |
47 | | - $(ref).data('prev_value', $(ref).val()); |
48 | | - App.Actions.PACKAGE.disable_unlimited(ref, elm); |
49 | | - } |
50 | | - }); |
51 | | -}; |
52 | | - |
53 | | -// |
54 | | -// Page entry point |
55 | | -// Trigger listeners |
56 | | -App.Listeners.PACKAGE.init(); |
57 | | -App.Listeners.PACKAGE.checkbox_unlimited_feature(); |
58 | 1 | $('form[name="v_add_package"]').on('submit', function () { |
59 | 2 | $('input:disabled').each(function (i, elm) { |
60 | 3 | $(elm).attr('disabled', false); |
|
0 commit comments