Files
typecho/admin/custom-fields-js.php
T
2013-11-25 10:39:02 +08:00

37 lines
1.4 KiB
PHP

<script>
$(document).ready(function () {
// 自定义字段
$('#custom-field-expand').click(function() {
$(this).parent().toggleClass('fold');
});
function attachDeleteEvent (el) {
$('button.btn-xs', el).click(function () {
if (confirm('<?php _e('确认要删除此字段吗?'); ?>')) {
$(this).parents('tr').fadeOut(function () {
$(this).remove();
});
}
});
}
$('#custom-field table tbody tr').each(function () {
attachDeleteEvent(this);
});
$('#custom-field button.operate-add').click(function () {
var html = '<tr><td><input type="text" name="fieldNames[]" placeholder="<?php _e('字段名称'); ?>" class="text-s w-100"></td>'
+ '<td><select name="fieldTypes[]" id="">'
+ '<option value="str"><?php _e('字符'); ?></option>'
+ '<option value="int"><?php _e('整数'); ?></option>'
+ '<option value="float"><?php _e('小数'); ?></option>'
+ '</select></td>'
+ '<td><textarea name="fieldValues[]" placeholder="<?php _e('字段值'); ?>" class="text-s w-100" rows="2"></textarea></td>'
+ '<td><button type="button" class="btn-xs"><?php _e('删除'); ?></button></td></tr>',
el = $(html).hide().appendTo('#custom-field table tbody').fadeIn();
attachDeleteEvent(el);
});
});
</script>