Sha256: f5dc89fff34a982ad26bf3c96d3258238165fd6dff3d8f66e7c26160ec3443e8

Contents?: true

Size: 928 Bytes

Versions: 13

Compression:

Stored size: 928 Bytes

Contents

(function() {
    function submit(preview) {
	$('.comment-form form').ajaxSubmit({
	    url: '/comments',
	    type: 'POST',
	    data: {
		preview: preview
	    },
	    resetForm: !preview,
	    beforeSubmit: function(values) {
		if (values[1].value && values[3].value) {
		    $('.comment-form .loading').show();
		    return true;
		}
		else {
		    alert('Please enter name and text!');
		    return false;
		}
	    },
	    success: function(data) {
		$('.comment-form .loading').hide();
		if (preview) {
		    $('.comment-form .preview').html(data);
		    $('.preview-header').show();
		}
		else {
		    $('.preview-header').hide();
		    $('.comment-form .preview').html('');
		    $('.comments').html(data);
		}
	    }
	});
    }

    $('.comment-form form').submit(function() {
	submit(false);
	return false;
    });

    $('.comment-form .preview-button').click(function() {
	submit(true);
	return false;
    });

})();

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
georgi-shinmun-0.3.1 example/assets/javascripts/comments.js
georgi-shinmun-0.3.10 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3.2 example/assets/javascripts/comments.js
georgi-shinmun-0.3.3 example/assets/javascripts/comments.js
georgi-shinmun-0.3.4 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3.5 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3.6 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3.7 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3.8 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3.9 example/assets/javascripts/3-comments.js
georgi-shinmun-0.3 example/assets/javascripts/comments.js
georgi-shinmun-0.4.1 example/assets/javascripts/3-comments.js
georgi-shinmun-0.4 example/assets/javascripts/3-comments.js