@glitchr/transparent 1.0.48 → 1.0.49
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 +10 -6
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -1457,7 +1457,7 @@
|
|
|
1457
1457
|
|
|
1458
1458
|
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)
|
|
1459
1459
|
if(formAmbiguity) formInput = $(form).find(":input, [name^='"+form.name+"\[']");
|
|
1460
|
-
else $("form[name='"+form.name+"'] :input, [name^='"+form.name+"\[']");
|
|
1460
|
+
else formInput = $("form[name='"+form.name+"'] :input, [name^='"+form.name+"\[']");
|
|
1461
1461
|
|
|
1462
1462
|
formInput.each(function() {
|
|
1463
1463
|
|
|
@@ -1718,7 +1718,7 @@
|
|
|
1718
1718
|
window.onhashchange = __main__;
|
|
1719
1719
|
|
|
1720
1720
|
var formDataBefore = {};
|
|
1721
|
-
$(window).on("
|
|
1721
|
+
$(window).on("load", function() {
|
|
1722
1722
|
|
|
1723
1723
|
formDataBefore = {};
|
|
1724
1724
|
$("form").each(function() {
|
|
@@ -1748,6 +1748,8 @@
|
|
|
1748
1748
|
if(formSubmission) return; // Do not display on form submission
|
|
1749
1749
|
if(Settings.disable) return;
|
|
1750
1750
|
|
|
1751
|
+
if(e.currentTarget == window) return;
|
|
1752
|
+
|
|
1751
1753
|
var preventDefault = false;
|
|
1752
1754
|
var formDataAfter = [];
|
|
1753
1755
|
$("form").each(function() {
|
|
@@ -1775,15 +1777,15 @@
|
|
|
1775
1777
|
var formDataAfterKeys = Object.keys(formDataAfter);
|
|
1776
1778
|
var formDataBeforeEntries = Object.entries(formDataBefore);
|
|
1777
1779
|
var formDataAfterEntries = Object.entries(formDataAfter);
|
|
1778
|
-
function
|
|
1779
|
-
function
|
|
1780
|
+
function same(a, b) { return JSON.stringify(a) === JSON.stringify(b); }
|
|
1781
|
+
function sameKeys(a, b) {
|
|
1780
1782
|
|
|
1781
1783
|
var aKeys = Object.keys(a).sort();
|
|
1782
1784
|
var bKeys = Object.keys(b).sort();
|
|
1783
1785
|
return JSON.stringify(aKeys) === JSON.stringify(bKeys);
|
|
1784
1786
|
}
|
|
1785
1787
|
|
|
1786
|
-
if(!
|
|
1788
|
+
if(!sameKeys(formDataBeforeKeys, formDataAfterKeys)) preventDefault = true;
|
|
1787
1789
|
else {
|
|
1788
1790
|
|
|
1789
1791
|
for (var [fieldName,fieldValueAfter] of Object.entries(formDataAfter)) {
|
|
@@ -1794,7 +1796,9 @@
|
|
|
1794
1796
|
if(!fieldValueAfter instanceof File) preventDefault = true;
|
|
1795
1797
|
else if (fieldValueBefore.size != fieldValueAfter.size) preventDefault = true;
|
|
1796
1798
|
|
|
1797
|
-
} else if(fieldValueBefore != fieldValueAfter)
|
|
1799
|
+
} else if(fieldValueBefore != fieldValueAfter) {
|
|
1800
|
+
preventDefault = true;
|
|
1801
|
+
}
|
|
1798
1802
|
}
|
|
1799
1803
|
}
|
|
1800
1804
|
|