Sha256: 0858b2fe8e9103d594ec7798492be94fa8601204a1231e1a193826c31945521f

Contents?: true

Size: 1.89 KB

Versions: 11

Compression:

Stored size: 1.89 KB

Contents

jQuery(document).ready(function($) {
	return function($) {
		function handleSuccess(json, statusText) {
			$('#spinner').hide();
			var base_url;

			if (! (json.error === undefined)) {
				$('#submit').attr('value', 'Start validation');
				$('#validation_result').html('').hide();
				$('#error').html(json.error).show();
			} else if (json.still_processing === 'yes') {
				if (! (json.base_url === undefined)) {
					base_url = json.base_url;
				}
				var keep_checking = function() {
					var url = base_url + '/admin_data/diagnostic/validate_model?still_processing=yes';
					url = url + '&tid=' + $('#tid').text();
					var fn = function(json) {
						if (json.still_processing === 'no') {
							clearInterval(refreshID);
							$('#submit').attr('value', 'Start validation');
							$('#validation_result').html('').hide();
							$('#validation_result').html('Validation result').show();
							$('#validate_model_rhs_data').html(json.data);
						} else {
							var processed_info = json.currently_processing_klass;
							var s = processed_info + ' ... ';
							$('#validation_result').html(s);
							$('#validate_model_rhs_data').html(json.data);
						}
					};

					$.getJSON(url, fn);
				};
				var refreshID = setInterval(keep_checking, 4000);
			} else {
				$('#validation_result').html('Validation result').show();
				$('#validate_model_rhs_data').html(json.data);
			}
		}

		function preSubmit(formData, jqForm, options) {
			$('html,body').animate({
				scrollTop: 0
			},
			0);
			$('#validate_model_rhs_data').html('');
			$('#validation_result').html('Processing .... This page will refersh itself periodically.').show();
			$('#error').hide();
			$('#spinner').show();
			$('#submit').attr('value', 'processing ...');
			return true;
		}

		var options = {
			beforeSubmit: preSubmit,
			success: handleSuccess,
			dataType: 'json'
		};

		$('#validate_model_form').ajaxForm(options);

	};
} (jQuery));


Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
admin_data-1.0.10 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.9 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.8 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.7 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.6 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.5 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.4 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.3 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.2 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.1 lib/js/validate_model/ajaxify_form.js
admin_data-1.0.0 lib/js/validate_model/ajaxify_form.js