@glitchr/transparent 1.0.43 → 1.0.44
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 +1 -1
- package/src/js/transparent.js +18 -11
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -522,10 +522,6 @@
|
|
|
522
522
|
|
|
523
523
|
if(el.target && el.target.tagName == "FORM") {
|
|
524
524
|
|
|
525
|
-
// Action must be prevented here
|
|
526
|
-
// This is specific to form submission
|
|
527
|
-
el.preventDefault();
|
|
528
|
-
|
|
529
525
|
var href = el.target.getAttribute("action");
|
|
530
526
|
if(!href) href = location.pathname + href;
|
|
531
527
|
|
|
@@ -1416,6 +1412,7 @@
|
|
|
1416
1412
|
return elementsXY;
|
|
1417
1413
|
}
|
|
1418
1414
|
|
|
1415
|
+
var formSubmission = false;
|
|
1419
1416
|
function __main__(e) {
|
|
1420
1417
|
|
|
1421
1418
|
// Disable transparent JS (e.g. during development..)
|
|
@@ -1434,7 +1431,15 @@
|
|
|
1434
1431
|
var target = Transparent.isElement(link[2]) ? link[2] : undefined;
|
|
1435
1432
|
var data = Transparent.isElement(link[2]) ? undefined : link[2];
|
|
1436
1433
|
|
|
1434
|
+
// Wait for transparent window event to be triggered
|
|
1435
|
+
if (!isReady) return;
|
|
1436
|
+
|
|
1437
|
+
if (e.type != Transparent.state.POPSTATE &&
|
|
1438
|
+
e.type != Transparent.state.HASHCHANGE && !$(this).find(Settings.identifier).length) return;
|
|
1439
|
+
|
|
1437
1440
|
var form = target != undefined && target.tagName == "FORM" ? target : undefined;
|
|
1441
|
+
formSubmission = false;
|
|
1442
|
+
|
|
1438
1443
|
if (form) {
|
|
1439
1444
|
|
|
1440
1445
|
data = new FormData();
|
|
@@ -1453,14 +1458,15 @@
|
|
|
1453
1458
|
} else data.append(this.name, this.value);
|
|
1454
1459
|
});
|
|
1455
1460
|
|
|
1456
|
-
|
|
1457
|
-
|
|
1461
|
+
// Force page reload
|
|
1462
|
+
formSubmission = true; // mark as form submission
|
|
1458
1463
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1464
|
+
if ($(e.target).hasClass(Transparent.state.RELOAD)) return;
|
|
1465
|
+
if ($(form).hasClass(Transparent.state.RELOAD)) return;
|
|
1461
1466
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1467
|
+
if(e.type == "submit")
|
|
1468
|
+
$(form).find(':submit').attr('disabled', 'disabled');
|
|
1469
|
+
}
|
|
1464
1470
|
|
|
1465
1471
|
// Specific page exception
|
|
1466
1472
|
for(i = 0; i < Settings.exceptions.length; i++) {
|
|
@@ -1712,8 +1718,9 @@
|
|
|
1712
1718
|
});
|
|
1713
1719
|
});
|
|
1714
1720
|
|
|
1715
|
-
window.onbeforeunload = function() {
|
|
1721
|
+
window.onbeforeunload = function(e) {
|
|
1716
1722
|
|
|
1723
|
+
if(formSubmission) return; // Do not display on form submission
|
|
1717
1724
|
if(Settings.disable) return;
|
|
1718
1725
|
|
|
1719
1726
|
var preventDefault = false;
|