<commit_before>/**
 *
 * RESTful Forms Plug-in for jQuery
 * ================================
 * Proper RESTful submit treatment for HTML <form> tags.
 *
 * @license RESTful Forms
 * for jQuery 1.3+
 * (c) 2010 <NAME> (http://petr.vostrel.cz/)
 * under the MIT (MIT-LICENSE.TXT) and GPL (GPL-LICENSE.TXT) licenses.
 * http://jquery.vostrel.cz/restful-forms
 */

jQuery.restfulForms || (function($, document){

	var
		plugin=
		jQuery.restfulForms= {
			ajaxSettings: {

				async: false,
				cache: false

			},
			intercept: function(e){

				var
					form= e.target,
					method= form.method.toLowerCase()

				if ($(form).is('.restful')){
					$(form).trigger(method+'-submit', [form, method]);
					return false
				}

			},
			submit: function(e, form, method){

				$.ajax( $.extend({}, plugin.ajaxSettings, {
					url: form.action,
					type: method,
					data: $(form).serialize(),
					complete: function(xhr, status){
						console.log(xhr)
						$(form).trigger(method, [form, xhr.responseText, form.target, status]);
					}}) )

			},
			load: function(e, form, url, target){

				if (target.replace(plugin.TARGET_PATTERN,
					function(whole, element, partial, fragment){
						return $(element).load(fragment ? url+' '+fragment : url)
							.length || ''
					}))
					e.stopImmediatePropagation();

			},
			redirect: function(e, form, url, target){

				try{ window.top[target].location.href= url }
				catch(e){ window.location.href= url }

			},
			TARGET_PATTERN: /^([^<]+)(|\s*<\s*(.+))$/
		}
	
	$(document)
		.bind('submit', plugin.intercept)
		.bind('put-submit get-submit post-submit delete-submit', plugin.submit)
		.bind('put get post delete', plugin.load)
		.bind('put get post delete', plugin.redirect)

})(jQuery, document);
<commit_msg>Ajax settings can now be overriden on a case-to-case-basis by binding to "before" event and returning object of ajax settings.<commit_after>/**
 *
 * RESTful Forms Plug-in for jQuery
 * ================================
 * Proper RESTful submit treatment for HTML <form> tags.
 *
 * @license RESTful Forms
 * for jQuery 1.3+
 * (c) 2010 <NAME> (http://petr.vostrel.cz/)
 * under the MIT (MIT-LICENSE.TXT) and GPL (GPL-LICENSE.TXT) licenses.
 * http://jquery.vostrel.cz/restful-forms
 */

jQuery.restfulForms || (function($, document){

	var
		plugin=
		jQuery.restfulForms= {
			ajaxSettings: {

				async: false,
				cache: false

			},
			intercept: function(e){

				var
					form= e.target,
					method= form.method.toLowerCase()

				if ($(form).is('.restful')){
					$(form).trigger(method+'-submit', [form, method]);
					return false
				}

			},
			submit: function(e, form, method){

				$.ajax( $.extend({}, plugin.ajaxSettings, e.result || {}, {
					url: form.action,
					type: method,
					data: $(form).serialize(),
					complete: function(xhr, status){
						$(form).trigger(method, [form, xhr.responseText, form.target, status]);
					}}) )

			},
			load: function(e, form, url, target){

				if (target.replace(plugin.TARGET_PATTERN,
					function(whole, element, partial, fragment){
						return $(element).load(fragment ? url+' '+fragment : url)
							.length || ''
					}))
					e.stopImmediatePropagation();

			},
			redirect: function(e, form, url, target){

				try{ window.top[target].location.href= url }
				catch(e){ window.location.href= url }

			},
			TARGET_PATTERN: /^([^<]+)(|\s*<\s*(.+))$/
		}
	
	$(document)
		.bind('submit', plugin.intercept)
		.bind('put-submit get-submit post-submit delete-submit', plugin.submit)
		.bind('put get post delete', plugin.load)
		.bind('put get post delete', plugin.redirect)

})(jQuery, document);

{'fraction_non_alphanumeric': 0.18993952721275426, 'fraction_numerical': 0.003298515667949423, 'mean_word_length': 3.1731651376146788, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3078609', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1172, 'n_words': 281}