Sha256: 115807026403c87c592e957439e25b8059f2cbccbb2ce2d5fb5df03d1c98e257

Contents?: true

Size: 881 Bytes

Versions: 3

Compression:

Stored size: 881 Bytes

Contents

/**
 * comment_ajax.js:
 *
 * Copyright (C) 2013 by MATSUOKA Kohei <kohei@machu.jp>
 * You can distribute it under GPL2 or any later version.
 */

$(function() {
	$(document).on('submit', 'form.comment', function(e) {
		e.preventDefault();
		var form = $(this);
		$('<input type="hidden">').attr('name', 'comment').appendTo(form);
		$(':submit', form).attr('disabled', 'disabled');
		$('div.button input', form).hide();
		$('div.button', form).append('<div id="loading-button"><img src="theme/loading.gif">')
		$.post(form.attr('action'), form.serialize(), function(data) {
			$('#loading-button').remove();
			$('div.button input', form).show();
			form[0].reset();
			$(':submit', form).removeAttr('disabled');
			// $(data) is a diary HTML of the day
			$('div.comment:first', form.parents('div.day'))
				.after($('div.comment', $(data)))
				.remove();
		}, 'html');
	});
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tdiary-4.1.1 js/comment_ajax.js
tdiary-4.1.0 js/comment_ajax.js
tdiary-4.1.0.20141126 js/comment_ajax.js