| 1 |
"use strict"; |
| 2 |
|
| 3 |
; |
| 4 |
(function ($, window, document, undefined) { |
| 5 |
'use strict'; |
| 6 |
|
| 7 |
var spendingGoalInputSelector = 'input[name="merchant[spending_goal]"]'; |
| 8 |
var discountInputSelector = 'input[name="merchant[discount_amount]"]'; |
| 9 |
var discountTypeSelector = 'select[name="merchant[discount_type]"]'; |
| 10 |
var beforeInputSelector = '.merchant-module-page-setting-field-before-input'; |
| 11 |
var setDiscountType = function setDiscountType() { |
| 12 |
var type = $(discountTypeSelector).val(); |
| 13 |
if (type === 'percent') { |
| 14 |
$(discountInputSelector).parent().find(beforeInputSelector).text('%'); |
| 15 |
} else { |
| 16 |
$(discountInputSelector).parent().find(beforeInputSelector).text(merchantSpendingGoal.currencySymbol); |
| 17 |
} |
| 18 |
}; |
| 19 |
$(document).ready(function () { |
| 20 |
$(spendingGoalInputSelector).before('<span class="merchant-module-page-setting-field-before-input">' + merchantSpendingGoal.currencySymbol + '</span>'); |
| 21 |
$(discountInputSelector).before('<span class="merchant-module-page-setting-field-before-input"></span>'); |
| 22 |
setDiscountType(); |
| 23 |
$(discountTypeSelector).on('change', function () { |
| 24 |
return setDiscountType(); |
| 25 |
}); |
| 26 |
}); |
| 27 |
})(jQuery, window, document); |