@glitchr/transparent 1.0.50 → 1.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glitchr/transparent",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Transparent SPA Application",
5
5
  "main": "src/index.js",
6
6
  "access": "public",
@@ -1454,6 +1454,7 @@
1454
1454
  e.type != Transparent.state.HASHCHANGE && !$(this).find(Settings.identifier).length) return;
1455
1455
 
1456
1456
  var form = target != undefined && target.tagName == "FORM" ? target : undefined;
1457
+ var formTrigger = undefined;
1457
1458
  formSubmission = false;
1458
1459
 
1459
1460
  if (form) {
@@ -1464,7 +1465,7 @@
1464
1465
  var formInput = undefined; // In case of form ambiguity (two form with same name, restrict the data to the target form, if not extends it to each element with standard name)
1465
1466
  if(formAmbiguity) formInput = $(form).find(":input, [name^='"+form.name+"\[']");
1466
1467
  else formInput = $("form[name='"+form.name+"'] :input, [name^='"+form.name+"\[']");
1467
-
1468
+
1468
1469
  formInput.each(function() {
1469
1470
 
1470
1471
  if(this.tagName == "BUTTON") {
@@ -1481,7 +1482,7 @@
1481
1482
 
1482
1483
  // Force page reload
1483
1484
  formSubmission = true; // mark as form submission
1484
-
1485
+ formTrigger = e.target;
1485
1486
  if ($(e.target).hasClass(Transparent.state.RELOAD)) return;
1486
1487
  if ($(form).hasClass(Transparent.state.RELOAD)) return;
1487
1488
 
@@ -1600,11 +1601,22 @@
1600
1601
  }
1601
1602
 
1602
1603
  // Invalid html page returned
1603
- if(!responseText.includes("<html") || !responseText.includes("<body") || !responseText.includes("<head"))
1604
- return Transparent.rescue(dom);
1604
+ if(request && request.getResponseHeader("Content-Type") == "text/html") {
1605
+
1606
+ if (!responseText.includes("<html") && !responseText.includes("<body") && !responseText.includes("<head"))
1607
+ return Transparent.rescue(dom);
1608
+ }
1605
1609
 
1606
- if(status != 200) // Blatant error received..
1610
+ if(status == 302) {
1611
+
1612
+ if(responseURL) location.href = responseURL;
1613
+ else location.reload();
1614
+
1615
+ } else if(status != 200) {
1616
+
1617
+ // Blatant error received..
1607
1618
  return Transparent.rescue(dom);
1619
+ }
1608
1620
 
1609
1621
  // From here the page is valid..
1610
1622
  // so the new page is added to history..
@@ -1680,8 +1692,7 @@
1680
1692
  $(Transparent.html).prop("user-scroll", false); // make sure to avoid page jump during transition (cancelled in activeIn callback)
1681
1693
 
1682
1694
  // Submit ajax request..
1683
- if(form) form.dispatchEvent(new Event("submit"));
1684
-
1695
+ if(form) form.dispatchEvent(new SubmitEvent("submit", { submitter: formTrigger }));
1685
1696
  var xhr = new XMLHttpRequest();
1686
1697
  return jQuery.ajax({
1687
1698
  url: url.href,