PageSourceSearch

https://kaedusoft.com/wp-content/themes/masterstudy/assets/js/ajax.submit.js?ver=1791599026

js kaedusoft.com collected 2026-10-10 02:24:10 UTC 21,437 bytes, 520 lines download raw bytes

1"use strict";
2
3function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
5!function (e) {
6  "use strict";
7
8  "function" == typeof define && define.amd ? define(["jquery"], e) : e("undefined" != typeof jQuery ? jQuery : window.Zepto);
9}(function (e) {
10  "use strict";
11
12  function t(t) {
13    var r = t.data;
14    t.isDefaultPrevented() || (t.preventDefault(), e(t.target).ajaxSubmit(r));
15  }
16
17  function r(t) {
18    var r = t.target,
19        a = e(r);
20
21    if (!a.is("[type=submit],[type=image]")) {
22      var n = a.closest("[type=submit]");
23      if (0 === n.length) return;
24      r = n[0];
25    }
26
27    var i = this;
28    if (i.clk = r, "image" == r.type) if (void 0 !== t.offsetX) i.clk_x = t.offsetX, i.clk_y = t.offsetY;else if ("function" == typeof e.fn.offset) {
29      var o = a.offset();
30      i.clk_x = t.pageX - o.left, i.clk_y = t.pageY - o.top;
31    } else i.clk_x = t.pageX - r.offsetLeft, i.clk_y = t.pageY - r.offsetTop;
32    setTimeout(function () {
33      i.clk = i.clk_x = i.clk_y = null;
34    }, 100);
35  }
36
37  function a() {
38    if (e.fn.ajaxSubmit.debug) {
39      var t = "[jquery.form] " + Array.prototype.join.call(arguments, "");
40      window.console && window.console.log ? window.console.log(t) : window.opera && window.opera.postError && window.opera.postError(t);
41    }
42  }
43
44  var n = {};
45  n.fileapi = void 0 !== e("<input type='file'/>").get(0).files, n.formdata = void 0 !== window.FormData;
46  var i = !!e.fn.prop;
47  e.fn.attr2 = function () {
48    if (!i) return this.attr.apply(this, arguments);
49    var e = this.prop.apply(this, arguments);
50    return e && e.jquery || "string" == typeof e ? e : this.attr.apply(this, arguments);
51  }, e.fn.ajaxSubmit = function (t) {
52    function r(r) {
53      var a,
54          n,
55          i = e.param(r, t.traditional).split("&"),
56          o = i.length,
57          s = [];
58
59      for (a = 0; o > a; a++) {
60        i[a] = i[a].replace(/\+/g, " "), n = i[a].split("="), s.push([decodeURIComponent(n[0]), decodeURIComponent(n[1])]);
61      }
62
63      return s;
64    }
65
66    function o(a) {
67      for (var n = new FormData(), i = 0; i < a.length; i++) {
68        n.append(a[i].name, a[i].value);
69      }
70
71      if (t.extraData) {
72        var o = r(t.extraData);
73
74        for (i = 0; i < o.length; i++) {
75          o[i] && n.append(o[i][0], o[i][1]);
76        }
77      }
78
79      t.data = null;
80      var s = e.extend(!0, {}, e.ajaxSettings, t, {
81        contentType: !1,
82        processData: !1,
83        cache: !1,
84        type: u || "POST"
85      });
86      t.uploadProgress && (s.xhr = function () {
87        var r = e.ajaxSettings.xhr();
88        return r.upload && r.upload.addEventListener("progress", function (e) {
89          var r = 0,
90              a = e.loaded || e.position,
91              n = e.total;
92          e.lengthComputable && (r = Math.ceil(a / n * 100)), t.uploadProgress(e, a, n, r);
93        }, !1), r;
94      }), s.data = null;
95      var c = s.beforeSend;
96      return s.beforeSend = function (e, r) {
97        t.formData ? r.data = t.formData : r.data = n, c && c.call(this, e, r);
98      }, e.ajax(s);
99    }
100
101    function s(r) {
102      function n(e) {
103        var t = null;
104
105        try {
106          e.contentWindow && (t = e.contentWindow.document);
107        } catch (r) {
108          a("cannot get iframe.contentWindow document: " + r);
109        }
110
111        if (t) return t;
112
113        try {
114          t = e.contentDocument ? e.contentDocument : e.document;
115        } catch (r) {
116          a("cannot get iframe.contentDocument: " + r), t = e.document;
117        }
118
119        return t;
120      }
121
122      function o() {
123        function t() {
124          try {
125            var e = n(g).readyState;
126            a("state = " + e), e && "uninitialized" == e.toLowerCase() && setTimeout(t, 50);
127          } catch (r) {
128            a("Server abort: ", r, " (", r.name, ")"), s(k), j && clearTimeout(j), j = void 0;
129          }
130        }
131
132        var r = f.attr2("target"),
133            i = f.attr2("action"),
134            o = "multipart/form-data",
135            c = f.attr("enctype") || f.attr("encoding") || o;
136        w.setAttribute("target", p), (!u || /post/i.test(u)) && w.setAttribute("method", "POST"), i != m.url && w.setAttribute("action", m.url), m.skipEncodingOverride || u && !/post/i.test(u) || f.attr({
137          encoding: "multipart/form-data",
138          enctype: "multipart/form-data"
139        }), m.timeout && (j = setTimeout(function () {
140          T = !0, s(D);
141        }, m.timeout));
142        var l = [];
143
144        try {
145          if (m.extraData) for (var d in m.extraData) {
146            m.extraData.hasOwnProperty(d) && (e.isPlainObject(m.extraData[d]) && m.extraData[d].hasOwnProperty("name") && m.extraData[d].hasOwnProperty("value") ? l.push(e('<input type="hidden" name="' + m.extraData[d].name + '">').val(m.extraData[d].value).appendTo(w)[0]) : l.push(e('<input type="hidden" name="' + d + '">').val(m.extraData[d]).appendTo(w)[0]));
147          }
148          m.iframeTarget || v.appendTo("body"), g.attachEvent ? g.attachEvent("onload", s) : g.addEventListener("load", s, !1), setTimeout(t, 15);
149
150          try {
151            w.submit();
152          } catch (h) {
153            var x = document.createElement("form").submit;
154            x.apply(w);
155          }
156        } finally {
157          w.setAttribute("action", i), w.setAttribute("enctype", c), r ? w.setAttribute("target", r) : f.removeAttr("target"), e(l).remove();
158        }
159      }
160
161      function s(t) {
162        if (!x.aborted && !F) {
163          if (M = n(g), M || (a("cannot access response document"), t = k), t === D && x) return x.abort("timeout"), void S.reject(x, "timeout");
164          if (t == k && x) return x.abort("server abort"), void S.reject(x, "error", "server abort");
165
166          if (M && M.location.href != m.iframeSrc || T) {
167            g.detachEvent ? g.detachEvent("onload", s) : g.removeEventListener("load", s, !1);
168            var r,
169                i = "success";
170
171            try {
172              if (T) throw "timeout";
173              var o = "xml" == m.dataType || M.XMLDocument || e.isXMLDoc(M);
174              if (a("isXml=" + o), !o && window.opera && (null === M.body || !M.body.innerHTML) && --O) return a("requeing onLoad callback, DOM not available"), void setTimeout(s, 250);
175              var u = M.body ? M.body : M.documentElement;
176              x.responseText = u ? u.innerHTML : null, x.responseXML = M.XMLDocument ? M.XMLDocument : M, o && (m.dataType = "xml"), x.getResponseHeader = function (e) {
177                var t = {
178                  "content-type": m.dataType
179                };
180                return t[e.toLowerCase()];
181              }, u && (x.status = Number(u.getAttribute("status")) || x.status, x.statusText = u.getAttribute("statusText") || x.statusText);
182              var c = (m.dataType || "").toLowerCase(),
183                  l = /(json|script|text)/.test(c);
184
185              if (l || m.textarea) {
186                var f = M.getElementsByTagName("textarea")[0];
187                if (f) x.responseText = f.value, x.status = Number(f.getAttribute("status")) || x.status, x.statusText = f.getAttribute("statusText") || x.statusText;else if (l) {
188                  var p = M.getElementsByTagName("pre")[0],
189                      h = M.getElementsByTagName("body")[0];
190                  p ? x.responseText = p.textContent ? p.textContent : p.innerText : h && (x.responseText = h.textContent ? h.textContent : h.innerText);
191                }
192              } else "xml" == c && !x.responseXML && x.responseText && (x.responseXML = X(x.responseText));
193
194              try {
195                E = _(x, c, m);
196              } catch (y) {
197                i = "parsererror", x.error = r = y || i;
198              }
199            } catch (y) {
200              a("error caught: ", y), i = "error", x.error = r = y || i;
201            }
202
203            x.aborted && (a("upload aborted"), i = null), x.status && (i = x.status >= 200 && x.status < 300 || 304 === x.status ? "success" : "error"), "success" === i ? (m.success && m.success.call(m.context, E, "success", x), S.resolve(x.responseText, "success", x), d && e.event.trigger("ajaxSuccess", [x, m])) : i && (void 0 === r && (r = x.statusText), m.error && m.error.call(m.context, x, i, r), S.reject(x, "error", r), d && e.event.trigger("ajaxError", [x, m, r])), d && e.event.trigger("ajaxComplete", [x, m]), d && ! --e.active && e.event.trigger("ajaxStop"), m.complete && m.complete.call(m.context, x, i), F = !0, m.timeout && clearTimeout(j), setTimeout(function () {
204              m.iframeTarget ? v.attr("src", m.iframeSrc) : v.remove(), x.responseXML = null;
205            }, 100);
206          }
207        }
208      }
209
210      var c,
211          l,
212          m,
213          d,
214          p,
215          v,
216          g,
217          x,
218          y,
219          b,
220          T,
221          j,
222          w = f[0],
223          S = e.Deferred();
224      if (S.abort = function (e) {
225        x.abort(e);
226      }, r) for (l = 0; l < h.length; l++) {
227        c = e(h[l]), i ? c.prop("disabled", !1) : c.removeAttr("disabled");
228      }
229      if (m = e.extend(!0, {}, e.ajaxSettings, t), m.context = m.context || m, p = "jqFormIO" + new Date().getTime(), m.iframeTarget ? (v = e(m.iframeTarget), b = v.attr2("name"), b ? p = b : v.attr2("name", p)) : (v = e('<iframe name="' + p + '" src="' + m.iframeSrc + '" />'), v.css({
230        position: "absolute",
231        top: "-1000px",
232        left: "-1000px"
233      })), g = v[0], x = {
234        aborted: 0,
235        responseText: null,
236        responseXML: null,
237        status: 0,
238        statusText: "n/a",
239        getAllResponseHeaders: function getAllResponseHeaders() {},
240        getResponseHeader: function getResponseHeader() {},
241        setRequestHeader: function setRequestHeader() {},
242        abort: function abort(t) {
243          var r = "timeout" === t ? "timeout" : "aborted";
244          a("aborting upload... " + r), this.aborted = 1;
245
246          try {
247            g.contentWindow.document.execCommand && g.contentWindow.document.execCommand("Stop");
248          } catch (n) {}
249
250          v.attr("src", m.iframeSrc), x.error = r, m.error && m.error.call(m.context, x, r, t), d && e.event.trigger("ajaxError", [x, m, r]), m.complete && m.complete.call(m.context, x, r);
251        }
252      }, d = m.global, d && 0 === e.active++ && e.event.trigger("ajaxStart"), d && e.event.trigger("ajaxSend", [x, m]), m.beforeSend && m.beforeSend.c
252all(m.context, x, m) === !1) return m.global && e.active--, S.reject(), S;
253      if (x.aborted) return S.reject(), S;
254      y = w.clk, y && (b = y.name, b && !y.disabled && (m.extraData = m.extraData || {}, m.extraData[b] = y.value, "image" == y.type && (m.extraData[b + ".x"] = w.clk_x, m.extraData[b + ".y"] = w.clk_y)));
255      var D = 1,
256          k = 2,
257          A = e("meta[name=csrf-token]").attr("content"),
258          L = e("meta[name=csrf-param]").attr("content");
259      L && A && (m.extraData = m.extraData || {}, m.extraData[L] = A), m.forceSync ? o() : setTimeout(o, 10);
260
261      var E,
262          M,
263          F,
264          O = 50,
265          X = e.parseXML || function (e, t) {
266        return window.ActiveXObject ? (t = new ActiveXObject("Microsoft.XMLDOM"), t.async = "false", t.loadXML(e)) : t = new DOMParser().parseFromString(e, "text/xml"), t && t.documentElement && "parsererror" != t.documentElement.nodeName ? t : null;
267      },
268          C = e.parseJSON || function (e) {
269        return window.eval("(" + e + ")");
270      },
271          _ = function _(t, r, a) {
272        var n = t.getResponseHeader("content-type") || "",
273            i = "xml" === r || !r && n.indexOf("xml") >= 0,
274            o = i ? t.responseXML : t.responseText;
275        return i && "parsererror" === o.documentElement.nodeName && e.error && e.error("parsererror"), a && a.dataFilter && (o = a.dataFilter(o, r)), "string" == typeof o && ("json" === r || !r && n.indexOf("json") >= 0 ? o = C(o) : ("script" === r || !r && n.indexOf("javascript") >= 0) && e.globalEval(o)), o;
276      };
277
278      return S;
279    }
280
281    if (!this.length) return a("ajaxSubmit: skipping submit process - no element selected"), this;
282    var u,
283        c,
284        l,
285        f = this;
286    "function" == typeof t ? t = {
287      success: t
288    } : void 0 === t && (t = {}), u = t.type || this.attr2("method"), c = t.url || this.attr2("action"), l = "string" == typeof c ? e.trim(c) : "", l = l || window.location.href || "", l && (l = (l.match(/^([^#]+)/) || [])[1]), t = e.extend(!0, {
289      url: l,
290      success: e.ajaxSettings.success,
291      type: u || e.ajaxSettings.type,
292      iframeSrc: /^https/i.test(window.location.href || "") ? "javascript:false" : "about:blank"
293    }, t);
294    var m = {};
295    if (this.trigger("form-pre-serialize", [this, t, m]), m.veto) return a("ajaxSubmit: submit vetoed via form-pre-serialize trigger"), this;
296    if (t.beforeSerialize && t.beforeSerialize(this, t) === !1) return a("ajaxSubmit: submit aborted via beforeSerialize callback"), this;
297    var d = t.traditional;
298    void 0 === d && (d = e.ajaxSettings.traditional);
299    var p,
300        h = [],
301        v = this.formToArray(t.semantic, h);
302    if (t.data && (t.extraData = t.data, p = e.param(t.data, d)), t.beforeSubmit && t.beforeSubmit(v, this, t) === !1) return a("ajaxSubmit: submit aborted via beforeSubmit callback"), this;
303    if (this.trigger("form-submit-validate", [v, this, t, m]), m.veto) return a("ajaxSubmit: submit vetoed via form-submit-validate trigger"), this;
304    var g = e.param(v, d);
305    p && (g = g ? g + "&" + p : p), "GET" == t.type.toUpperCase() ? (t.url += (t.url.indexOf("?") >= 0 ? "&" : "?") + g, t.data = null) : t.data = g;
306    var x = [];
307
308    if (t.resetForm && x.push(function () {
309      f.resetForm();
310    }), t.clearForm && x.push(function () {
311      f.clearForm(t.includeHidden);
312    }), !t.dataType && t.target) {
313      var y = t.success || function () {};
314
315      x.push(function (r) {
316        var a = t.replaceTarget ? "replaceWith" : "html";
317        e(t.target)[a](r).each(y, arguments);
318      });
319    } else t.success && x.push(t.success);
320
321    if (t.success = function (e, r, a) {
322      for (var n = t.context || this, i = 0, o = x.length; o > i; i++) {
323        x[i].apply(n, [e, r, a || f, f]);
324      }
325    }, t.error) {
326      var b = t.error;
327
328      t.error = function (e, r, a) {
329        var n = t.context || this;
330        b.apply(n, [e, r, a, f]);
331      };
332    }
333
334    if (t.complete) {
335      var T = t.complete;
336
337      t.complete = function (e, r) {
338        var a = t.context || this;
339        T.apply(a, [e, r, f]);
340      };
341    }
342
343    var j = e("input[type=file]:enabled", this).filter(function () {
344      return "" !== e(this).val();
345    }),
346        w = j.length > 0,
347        S = "multipart/form-data",
348        D = f.attr("enctype") == S || f.attr("encoding") == S,
349        k = n.fileapi && n.formdata;
350    a("fileAPI :" + k);
351    var A,
352        L = (w || D) && !k;
353    t.iframe !== !1 && (t.iframe || L) ? t.closeKeepAlive ? e.get(t.closeKeepAlive, function () {
354      A = s(v);
355    }) : A = s(v) : A = (w || D) && k ? o(v) : e.ajax(t), f.removeData("jqxhr").data("jqxhr", A);
356
357    for (var E = 0; E < h.length; E++) {
358      h[E] = null;
359    }
360
361    return this.trigger("form-submit-notify", [this, t]), this;
362  }, e.fn.ajaxForm = function (n) {
363    if (n = n || {}, n.delegation = n.delegation && e.isFunction(e.fn.on), !n.delegation && 0 === this.length) {
364      var i = {
365        s: this.selector,
366        c: this.context
367      };
368      return !e.isReady && i.s ? (a("DOM not ready, queuing ajaxForm"), e(function () {
369        e(i.s, i.c).ajaxForm(n);
370      }), this) : (a("terminating; zero elements found by selector" + (e.isReady ? "" : " (DOM not ready)")), this);
371    }
372
373    return n.delegation ? (e(document).off("submit.form-plugin", this.selector, t).off("click.form-plugin", this.selector, r).on("submit.form-plugin", this.selector, n, t).on("click.form-plugin", this.selector, n, r), this) : this.ajaxFormUnbind().bind("submit.form-plugin", n, t).bind("click.form-plugin", n, r);
374  }, e.fn.ajaxFormUnbind = function () {
375    return this.unbind("submit.form-plugin click.form-plugin");
376  }, e.fn.formToArray = function (t, r) {
377    var a = [];
378    if (0 === this.length) return a;
379    var i,
380        o = this[0],
381        s = this.attr("id"),
382        u = t ? o.getElementsByTagName("*") : o.elements;
383    if (u && !/MSIE [678]/.test(navigator.userAgent) && (u = e(u).get()), s && (i = e(':input[form="' + s + '"]').get(), i.length && (u = (u || []).concat(i))), !u || !u.length) return a;
384    var c, l, f, m, d, p, h;
385
386    for (c = 0, p = u.length; p > c; c++) {
387      if (d = u[c], f = d.name, f && !d.disabled) if (t && o.clk && "image" == d.type) o.clk == d && (a.push({
388        name: f,
389        value: e(d).val(),
390        type: d.type
391      }), a.push({
392        name: f + ".x",
393        value: o.clk_x
394      }, {
395        name: f + ".y",
396        value: o.clk_y
397      }));else if (m = e.fieldValue(d, !0), m && m.constructor == Array) for (r && r.push(d), l = 0, h = m.length; h > l; l++) {
398        a.push({
399          name: f,
400          value: m[l]
401        });
402      } else if (n.fileapi && "file" == d.type) {
403        r && r.push(d);
404        var v = d.files;
405        if (v.length) for (l = 0; l < v.length; l++) {
406          a.push({
407            name: f,
408            value: v[l],
409            type: d.type
410          });
411        } else a.push({
412          name: f,
413          value: "",
414          type: d.type
415        });
416      } else null !== m && "undefined" != typeof m && (r && r.push(d), a.push({
417        name: f,
418        value: m,
419        type: d.type,
420        required: d.required
421      }));
422    }
423
424    if (!t && o.clk) {
425      var g = e(o.clk),
426          x = g[0];
427      f = x.name, f && !x.disabled && "image" == x.type && (a.push({
428        name: f,
429        value: g.val()
430      }), a.push({
431        name: f + ".x",
432        value: o.clk_x
433      }, {
434        name: f + ".y",
435        value: o.clk_y
436      }));
437    }
438
439    return a;
440  }
440, e.fn.formSerialize = function (t) {
441    return e.param(this.formToArray(t));
442  }, e.fn.fieldSerialize = function (t) {
443    var r = [];
444    return this.each(function () {
445      var a = this.name;
446
447      if (a) {
448        var n = e.fieldValue(this, t);
449        if (n && n.constructor == Array) for (var i = 0, o = n.length; o > i; i++) {
450          r.push({
451            name: a,
452            value: n[i]
453          });
454        } else null !== n && "undefined" != typeof n && r.push({
455          name: this.name,
456          value: n
457        });
458      }
459    }), e.param(r);
460  }, e.fn.fieldValue = function (t) {
461    for (var r = [], a = 0, n = this.length; n > a; a++) {
462      var i = this[a],
463          o = e.fieldValue(i, t);
464      null === o || "undefined" == typeof o || o.constructor == Array && !o.length || (o.constructor == Array ? e.merge(r, o) : r.push(o));
465    }
466
467    return r;
468  }, e.fieldValue = function (t, r) {
469    var a = t.name,
470        n = t.type,
471        i = t.tagName.toLowerCase();
472    if (void 0 === r && (r = !0), r && (!a || t.disabled || "reset" == n || "button" == n || ("checkbox" == n || "radio" == n) && !t.checked || ("submit" == n || "image" == n) && t.form && t.form.clk != t || "select" == i && -1 == t.selectedIndex)) return null;
473
474    if ("select" == i) {
475      var o = t.selectedIndex;
476      if (0 > o) return null;
477
478      for (var s = [], u = t.options, c = "select-one" == n, l = c ? o + 1 : u.length, f = c ? o : 0; l > f; f++) {
479        var m = u[f];
480
481        if (m.selected) {
482          var d = m.value;
483          if (d || (d = m.attributes && m.attributes.value && !m.attributes.value.specified ? m.text : m.value), c) return d;
484          s.push(d);
485        }
486      }
487
488      return s;
489    }
490
491    return e(t).val();
492  }, e.fn.clearForm = function (t) {
493    return this.each(function () {
494      e("input,select,textarea", this).clearFields(t);
495    });
496  }, e.fn.clearFields = e.fn.clearInputs = function (t) {
497    var r = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i;
498    return this.each(function () {
499      var a = this.type,
500          n = this.tagName.toLowerCase();
501      r.test(a) || "textarea" == n ? this.value = "" : "checkbox" == a || "radio" == a ? this.checked = !1 : "select" == n ? this.selectedIndex = -1 : "file" == a ? /MSIE/.test(navigator.userAgent) ? e(this).replaceWith(e(this).clone(!0)) : e(this).val("") : t && (t === !0 && /hidden/.test(a) || "string" == typeof t && e(this).is(t)) && (this.value = "");
502    });
503  }, e.fn.resetForm = function () {
504    return this.each(function () {
505      ("function" == typeof this.reset || "object" == _typeof(this.reset) && !this.reset.nodeType) && this.reset();
506    });
507  }, e.fn.enable = function (e) {
508    return void 0 === e && (e = !0), this.each(function () {
509      this.disabled = !e;
510    });
511  }, e.fn.selected = function (t) {
512    return void 0 === t && (t = !0), this.each(function () {
513      var r = this.type;
514      if ("checkbox" == r || "radio" == r) this.checked = t;else if ("option" == this.tagName.toLowerCase()) {
515        var a = e(this).parent("select");
516        t && a[0] && "select-one" == a[0].type && a.find("option").selected(!1), this.selected = t;
517      }
518    });
519  }, e.fn.ajaxSubmit.debug = !1;
520});

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.