chart.js
2 months ago
chart.min.js
2 months ago
digital-files-chooser.js
2 months ago
fusewp.js
2 months ago
index.php
2 months ago
license.js
2 months ago
login-redirect.js
2 months ago
reports.js
2 months ago
reports.min.js
2 months ago
tax-rate-repeater.js
2 months ago
tax-rate-repeater.js
64 lines
| 1 | (function ($) { |
| 2 | |
| 3 | $(function () { |
| 4 | |
| 5 | var tax_rate_row_tmpl = wp.template('ppress-tax-rate-row'); |
| 6 | var empty_state_tmpl = wp.template('ppress-tax-rate-empty-row'); |
| 7 | |
| 8 | var country_state_select_tmpl = wp.template('ppress-tax-rate-state-select'); |
| 9 | var country_state_input_tmpl = wp.template('ppress-tax-rate-state-input'); |
| 10 | |
| 11 | $(document).on('click', '.ppress_add_tax_rate', function (e) { |
| 12 | e.preventDefault(); |
| 13 | |
| 14 | $('.ppress-tax-rate-row--is-empty').remove(); |
| 15 | |
| 16 | var index = 0, |
| 17 | cache = $('.ppress-tax-rates-wrap table tbody tr').not('.ppress-tax-rate-row--is-empty'); |
| 18 | |
| 19 | if (cache.length > 0) { |
| 20 | index = cache.last().data('row-index') + 1; |
| 21 | } |
| 22 | |
| 23 | $('.ppress-tax-rates-wrap table tbody').append( |
| 24 | tax_rate_row_tmpl({ |
| 25 | 'index': index |
| 26 | }) |
| 27 | ); |
| 28 | }); |
| 29 | |
| 30 | $(document).on('click', '.ppress-tax-rate-table-actions .ppress-tax-rate-icon', function (e) { |
| 31 | e.preventDefault(); |
| 32 | $(this).parents('.ppress-tax-rate-table-actions').parent().remove(); |
| 33 | |
| 34 | if ($('.ppress-tax-rates-wrap table tbody tr').length === 0) { |
| 35 | |
| 36 | $('.ppress-tax-rates-wrap table tbody').append(empty_state_tmpl()); |
| 37 | } |
| 38 | }); |
| 39 | |
| 40 | $(document).on('change', '.ppress-tax-rate-table-country select', function () { |
| 41 | |
| 42 | var val = $(this).val(), |
| 43 | parent = $(this).parent().parent(), |
| 44 | field; |
| 45 | |
| 46 | if (val in ppress_countries_states) { |
| 47 | |
| 48 | field = country_state_select_tmpl({ |
| 49 | index: parent.data('row-index'), |
| 50 | options: ppress_countries_states[val] |
| 51 | }); |
| 52 | |
| 53 | } else { |
| 54 | |
| 55 | field = country_state_input_tmpl({ |
| 56 | index: parent.data('row-index') |
| 57 | }); |
| 58 | } |
| 59 | |
| 60 | parent.find('.ppress-tax-rate-table-state').html(field); |
| 61 | |
| 62 | }); |
| 63 | }); |
| 64 | })(jQuery); |