30 lines
1.6 KiB
JavaScript
30 lines
1.6 KiB
JavaScript
(function($){
|
||
$(function(){
|
||
var $tbody = $('#yoone-sub-plans-body');
|
||
var $addBtn = $('#yoone-sub-plan-add');
|
||
|
||
if ($tbody.length && $addBtn.length) {
|
||
$addBtn.on('click', function(){
|
||
var row = [
|
||
'<tr class="yoone-sub-plan-row">',
|
||
'<td><input type="text" name="yoone_sub_plans[label][]" placeholder="',
|
||
(typeof yooneSubsI18n !== 'undefined' ? yooneSubsI18n.placeholderLabel : '例如:标准计划'),
|
||
'" /></td>',
|
||
'<td><select name="yoone_sub_plans[period][]">',
|
||
'<option value="month">', (typeof yooneSubsI18n !== 'undefined' ? yooneSubsI18n.month : '月'), '</option>',
|
||
'<option value="year">', (typeof yooneSubsI18n !== 'undefined' ? yooneSubsI18n.year : '年'), '</option>',
|
||
'</select></td>',
|
||
'<td><input type="text" name="yoone_sub_plans[price][]" placeholder="', (typeof yooneSubsI18n !== 'undefined' ? yooneSubsI18n.placeholderPrice : '留空表示用产品价'), '" /></td>',
|
||
'<td><input type="number" min="0" step="0.1" name="yoone_sub_plans[discount_percent][]" placeholder="', (typeof yooneSubsI18n !== 'undefined' ? yooneSubsI18n.placeholderDiscount : '如:10 表示9折'), '" /></td>',
|
||
'<td><button type="button" class="button yoone-sub-plan-remove">', (typeof yooneSubsI18n !== 'undefined' ? yooneSubsI18n.remove : '删除'), '</button></td>',
|
||
'</tr>'
|
||
].join('');
|
||
$tbody.append(row);
|
||
});
|
||
|
||
$tbody.on('click', '.yoone-sub-plan-remove', function(){
|
||
$(this).closest('tr').remove();
|
||
});
|
||
}
|
||
});
|
||
})(jQuery); |