PageSourceSearch

https://www.turpravda.ua/forums/js/library/jquery.gardenhandleajaxform.js?v=2.1.5

js turpravda.ua collected 2026-09-26 07:23:59 UTC 2,668 bytes, 64 lines download raw bytes

1(function($) {
2   // This turns any form into a "post-in-place" form so it is ajaxed to save
3   // without a refresh. The form must be within an element with the "AjaxForm"
4   // class.
5   $.fn.handleAjaxForm = function(options) {
6      var handle = this;
7      $(this).find('form').each(function() {
8         options = $.extend({
9            frm:  this,
10            data: { 'DeliveryType' : 'ASSET', 'DeliveryMethod' : 'JSON' },
11            dataType: 'json',
12            beforeSubmit: function(frm_data, frm) {
13               options.frm = frm;
14              // Add a spinner
15              var btn = $(frm).find('input.Button:last');
16              if ($(btn).parent().find('span.Progress').length == 0) {
17                 $(btn).after('<span class="Progress">&#160;</span>');
18              }
19            },
20            success: function(json, status, $frm) {
21               json = $.postParseJson(json);
22               
23               if (json.FormSaved == true) {
24                  gdn.inform(json);
25                  if (json.RedirectUrl) {
26                     setTimeout("document.location='" + json.RedirectUrl + "';", 300);
27                  } else if(json.DeliveryType == 'ASSET') {
28                     $frm.parents($(handle).selector).html(json.Data);
29                  } else {
30                     // Remove the spinner if not redirecting...
31                     $('span.Progress').remove();
32                  }
33               } else {
34                  // Check to see if a target has been specified for the data.
35                  if(json.Target) {
36                     $(json.Target).html(json.Data);
37                  } else if(json.DeliveryType == 'MESSAGE') {
38                     gdn.inform(json.Data, false);
39                     $frm.find('span.Progress').remove();
40                  } else {
41                     $frm.parents($(handle).selector).html(json.Data);
42                  }
43               }
44               // If there are additional targets in the result then set them now.
45               if(json.Targets) {
46                  for(var i = 0; i < json.Targets.length; i++) {
47                     var item = json.Targets[i];
48                     if(item.Type == 'Text') {
49                        $(item.Target).text($.base64Decode(item.Data));
50                     } else {
51                        $(item.Target).html($.base64Decode(item.Data));
52                     }
53                  }
54               }
55               
56               // Re-attach the handler
57               $($(handle).selector).handleAjaxForm(options);
58             }
59         }, options || {});
60         
61         $(this).ajaxForm(options);
62      });
63   }
64})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.