@glitchr/transparent 1.0.53 → 1.0.55
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/images/error.svg +0 -0
- package/src/js/transparent.js +30 -9
package/package.json
CHANGED
package/src/images/error.svg
CHANGED
|
File without changes
|
package/src/js/transparent.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
// Modern browser: use passive event listeners where appropriate for better performance
|
|
2
|
+
jQuery.event.special.touchstart = { setup: function( _, ns, handle ) { this.addEventListener("touchstart", handle, { passive: !ns.includes("noPreventDefault") }); } };
|
|
3
|
+
jQuery.event.special.touchmove = { setup: function( _, ns, handle ) { this.addEventListener("touchmove", handle, { passive: !ns.includes("noPreventDefault") }); } };
|
|
4
|
+
jQuery.event.special.wheel = { setup: function( _, ns, handle ) { this.addEventListener("wheel", handle, { passive: true }); } };
|
|
5
|
+
jQuery.event.special.mousewheel = { setup: function( _, ns, handle ) { this.addEventListener("mousewheel", handle, { passive: true }); } };
|
|
6
|
+
|
|
7
|
+
// Transparent.js
|
|
1
8
|
(function (root, factory) {
|
|
2
9
|
|
|
3
10
|
if (typeof define === 'function' && define.amd) {
|
|
@@ -1431,6 +1438,7 @@
|
|
|
1431
1438
|
return elementsXY;
|
|
1432
1439
|
}
|
|
1433
1440
|
|
|
1441
|
+
var ajaxSemaphore = false;
|
|
1434
1442
|
var formSubmission = false;
|
|
1435
1443
|
function __main__(e) {
|
|
1436
1444
|
|
|
@@ -1489,15 +1497,21 @@
|
|
|
1489
1497
|
if ($(e.target).hasClass(Transparent.state.RELOAD)) return;
|
|
1490
1498
|
if ($(form).hasClass(Transparent.state.RELOAD)) return;
|
|
1491
1499
|
|
|
1492
|
-
if(e.type == "submit")
|
|
1500
|
+
if(e.type == "submit") // NB: This doesn't work if a button is generated afterward..
|
|
1493
1501
|
$(form).find(':submit').attr('disabled', 'disabled');
|
|
1494
1502
|
}
|
|
1495
1503
|
|
|
1496
1504
|
// Specific page exception
|
|
1497
|
-
for(i = 0; i < Settings.exceptions.length; i++) {
|
|
1498
|
-
|
|
1499
|
-
exception
|
|
1500
|
-
|
|
1505
|
+
for (let i = 0; i < Settings.exceptions.length; i++) {
|
|
1506
|
+
let exception = Settings.exceptions[i];
|
|
1507
|
+
if (exception instanceof RegExp) {
|
|
1508
|
+
if (exception.test(url.pathname)) return;
|
|
1509
|
+
} else {
|
|
1510
|
+
// Simple wildcard support: * matches any sequence of characters
|
|
1511
|
+
let pattern = exception.replace(/[.+^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '.*');
|
|
1512
|
+
let regex = new RegExp('^' + pattern + '$');
|
|
1513
|
+
if (regex.test(url.pathname)) return;
|
|
1514
|
+
}
|
|
1501
1515
|
}
|
|
1502
1516
|
|
|
1503
1517
|
// Ressources files rejected
|
|
@@ -1511,6 +1525,7 @@
|
|
|
1511
1525
|
|
|
1512
1526
|
e.preventDefault();
|
|
1513
1527
|
|
|
1528
|
+
if (ajaxSemaphore) return;
|
|
1514
1529
|
if (url == location) return;
|
|
1515
1530
|
|
|
1516
1531
|
if((e.type == Transparent.state.CLICK || e.type == Transparent.state.HASHCHANGE) && url.pathname == location.pathname && url.search == location.search && type != "POST") {
|
|
@@ -1530,8 +1545,9 @@
|
|
|
1530
1545
|
if(e.metaKey && e.shiftKey) return window.open(url, '_blank').focus(); // Safari not focusing..
|
|
1531
1546
|
if(e.metaKey || $(target).attr("target") == "_blank") return window.open(url, '_blank');
|
|
1532
1547
|
|
|
1533
|
-
|
|
1534
|
-
dispatchEvent(new Event('
|
|
1548
|
+
// right (still limited by browser policy):
|
|
1549
|
+
dispatchEvent(new Event('transparent:beforeunload'));
|
|
1550
|
+
dispatchEvent(new Event('beforeunload', { cancelable: true }));
|
|
1535
1551
|
|
|
1536
1552
|
$(Transparent.html).prop("user-scroll", true);
|
|
1537
1553
|
$(Transparent.html).stop();
|
|
@@ -1546,6 +1562,8 @@
|
|
|
1546
1562
|
|
|
1547
1563
|
function handleResponse(uuid, status = 200, method = null, data = null, xhr = null, request = null) {
|
|
1548
1564
|
|
|
1565
|
+
ajaxSemaphore = false;
|
|
1566
|
+
|
|
1549
1567
|
var responseURL;
|
|
1550
1568
|
responseURL = xhr !== null ? xhr.responseURL : url.href;
|
|
1551
1569
|
|
|
@@ -1587,6 +1605,7 @@
|
|
|
1587
1605
|
}
|
|
1588
1606
|
|
|
1589
1607
|
if(form) {
|
|
1608
|
+
|
|
1590
1609
|
$(form).find(':submit').removeAttr('disabled');
|
|
1591
1610
|
form.reset();
|
|
1592
1611
|
}
|
|
@@ -1697,6 +1716,8 @@
|
|
|
1697
1716
|
// Submit ajax request..
|
|
1698
1717
|
if(form) form.dispatchEvent(new SubmitEvent("submit", { submitter: formTrigger }));
|
|
1699
1718
|
var xhr = new XMLHttpRequest();
|
|
1719
|
+
|
|
1720
|
+
ajaxSemaphore = true;
|
|
1700
1721
|
return jQuery.ajax({
|
|
1701
1722
|
url: url.href,
|
|
1702
1723
|
type: type,
|
|
@@ -1765,6 +1786,8 @@
|
|
|
1765
1786
|
|
|
1766
1787
|
window.onbeforeunload = function(e) {
|
|
1767
1788
|
|
|
1789
|
+
if(Settings.debug) console.log("Transparent onbeforeunload event called..");
|
|
1790
|
+
|
|
1768
1791
|
if(formSubmission) return; // Do not display on form submission
|
|
1769
1792
|
if(Settings.disable) return;
|
|
1770
1793
|
|
|
@@ -1795,8 +1818,6 @@
|
|
|
1795
1818
|
|
|
1796
1819
|
var formDataBeforeKeys = Object.keys(formDataBefore);
|
|
1797
1820
|
var formDataAfterKeys = Object.keys(formDataAfter);
|
|
1798
|
-
var formDataBeforeEntries = Object.entries(formDataBefore);
|
|
1799
|
-
var formDataAfterEntries = Object.entries(formDataAfter);
|
|
1800
1821
|
function same(a, b) { return JSON.stringify(a) === JSON.stringify(b); }
|
|
1801
1822
|
function sameKeys(a, b) {
|
|
1802
1823
|
|