@glitchr/transparent 1.0.19 → 1.0.21
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 +65 -63
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -15,36 +15,36 @@
|
|
|
15
15
|
if(!newHash) newHash = "";
|
|
16
16
|
if (newHash !== "" && (''+newHash).charAt(0) !== '#')
|
|
17
17
|
newHash = '#' + newHash;
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
var oldURL = location.origin+location.pathname+location.hash;
|
|
20
20
|
var newURL = location.origin+location.pathname+newHash;
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
var fallback = $(newHash).length === 0;
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
var hashElement = $(newHash)[0] ?? undefined;
|
|
25
25
|
if (hashElement !== undefined) // Update hash only if element is displayed
|
|
26
26
|
fallback |= window.getComputedStyle(hashElement)["display"] == "none";
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
if((skipIfEmptyIdentifier && !newHash) || fallback){
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
dispatchEvent(new HashChangeEvent("hashfallback", {oldURL:oldURL, newURL:newURL}));
|
|
31
31
|
newHash = "";
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
oldURL = location.origin+location.pathname+location.hash;
|
|
34
34
|
newURL = location.origin+location.pathname+newHash;
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
if(oldURL == newURL) return false;
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
var state = Object.assign({}, history.state, {href: newURL});
|
|
40
40
|
history.replaceState(state, '', newURL);
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
if(triggerHashChange)
|
|
43
43
|
dispatchEvent(new HashChangeEvent("hashchange", {oldURL:oldURL, newURL:newURL}));
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
return true;
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
$.fn.serializeObject = function() {
|
|
49
49
|
var o = {};
|
|
50
50
|
var a = this.serializeArray();
|
|
@@ -60,98 +60,98 @@
|
|
|
60
60
|
});
|
|
61
61
|
return o;
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
$.fn.isScrollable = function()
|
|
65
65
|
{
|
|
66
66
|
for (let el of $(this).isScrollableX())
|
|
67
67
|
if(el) return true;
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
for (let el of $(this).isScrollableY())
|
|
70
70
|
if(el) return true;
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
return false;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
$.fn.isScrollableX = function() {
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
return $(this).map(function(i) {
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
var el = this[i] === window ? document.documentElement : this[i];
|
|
80
80
|
var isDom = el == document.documentElement;
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
var hasScrollableContent = el.scrollWidth > el.clientWidth;
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
var overflowStyle = window.getComputedStyle(el).overflowX;
|
|
85
85
|
var isOverflowScroll = overflowStyle.indexOf('scroll') !== -1;
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
return hasScrollableContent && (isOverflowScroll || isDom);
|
|
88
|
-
|
|
88
|
+
|
|
89
89
|
}.bind(this));
|
|
90
90
|
}
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
$.fn.isScrollableY = function() {
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
return $(this).map(function(i) {
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
var el = this[i] === window ? document.documentElement : this[i];
|
|
97
97
|
var isDom = el == document.documentElement;
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
var hasScrollableContent = el.scrollHeight > el.clientHeight;
|
|
100
|
-
|
|
100
|
+
|
|
101
101
|
var overflowStyle = window.getComputedStyle(el).overflowY;
|
|
102
102
|
var isOverflowScroll = overflowStyle.indexOf('scroll') !== -1;
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
return hasScrollableContent && (isOverflowScroll || isDom);
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
}.bind(this));
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
$.fn.closestScrollable = function()
|
|
110
110
|
{
|
|
111
111
|
return $(this).map((i) => {
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
var target = this[i] === window ? document.documentElement : this[i];
|
|
114
114
|
if (target === undefined) target = document.documentElement;
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
while (target !== document.documentElement) {
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
if($(target).isScrollable()) return target;
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
if(target.parentElement === undefined) return undefined;
|
|
121
121
|
if(target.parentElement === null) return null;
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
target = target.parentElement;
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
|
|
126
126
|
return $(target).isScrollable() ? target : undefined;
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
$.fn.repaint = function(duration = 1000, reiteration=5) {
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
var time = 0;
|
|
133
133
|
var interval = undefined;
|
|
134
134
|
var fn = function () {
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
$(this).each(function (_, el) {
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
var displayBak = el.style.display;
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
el.style.display = "none";
|
|
141
141
|
el.style.display = displayBak;
|
|
142
142
|
el.offsetHeight;
|
|
143
143
|
});
|
|
144
|
-
|
|
144
|
+
|
|
145
145
|
if (time > duration) clearInterval(interval);
|
|
146
146
|
time += duration/reiteration;
|
|
147
|
-
|
|
147
|
+
|
|
148
148
|
}.bind(this);
|
|
149
|
-
|
|
149
|
+
|
|
150
150
|
fn();
|
|
151
151
|
if(reiteration > 0)
|
|
152
152
|
interval = setInterval(fn, duration/reiteration);
|
|
153
153
|
};
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
var Transparent = window.Transparent = {};
|
|
156
156
|
Transparent.version = '0.1.0';
|
|
157
157
|
|
|
@@ -905,16 +905,16 @@
|
|
|
905
905
|
|
|
906
906
|
var body = $(dom).find("body").html();
|
|
907
907
|
if(body == "undefined") {
|
|
908
|
-
|
|
908
|
+
|
|
909
909
|
$(Settings.identifier).html("<div class='error'></div>");
|
|
910
910
|
setTimeout(function() { window.location.reload(); }, Transparent.parseDuration(Settings["rescue_reload"]));
|
|
911
911
|
|
|
912
912
|
} else {
|
|
913
|
-
|
|
913
|
+
|
|
914
914
|
document.documentElement.innerHTML = dom.documentElement === undefined ? dom : dom.documentElement.innerHTML;
|
|
915
|
-
Transparent.transferAttributes(dom);
|
|
915
|
+
Transparent.transferAttributes(dom);
|
|
916
916
|
}
|
|
917
|
-
|
|
917
|
+
|
|
918
918
|
Transparent.activeOut();
|
|
919
919
|
}
|
|
920
920
|
|
|
@@ -1040,27 +1040,28 @@
|
|
|
1040
1040
|
lazyloadImages = lazyloadImages || document.querySelectorAll("img[data-src]:not(.loaded)");
|
|
1041
1041
|
if ("IntersectionObserver" in window) {
|
|
1042
1042
|
|
|
1043
|
+
let options = { root:null, rootMargin: "100%" };
|
|
1043
1044
|
var imageObserver = new IntersectionObserver(function (entries, observer) {
|
|
1044
1045
|
entries.forEach(function (entry) {
|
|
1045
1046
|
if (entry.isIntersecting) {
|
|
1046
1047
|
var image = entry.target;
|
|
1047
1048
|
var lazybox = image.closest(".lazybox");
|
|
1048
1049
|
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1050
|
+
image.onload = function() {
|
|
1051
|
+
this.classList.add("loaded");
|
|
1052
|
+
this.classList.remove("loading");
|
|
1053
|
+
if(lazybox) lazybox.classList.add("loaded");
|
|
1054
|
+
if(lazybox) lazybox.classList.remove("loading");
|
|
1055
|
+
};
|
|
1055
1056
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1057
|
+
if(lazybox) lazybox.classList.add("loading");
|
|
1058
|
+
image.classList.add("loading");
|
|
1059
|
+
image.src = image.dataset.src;
|
|
1059
1060
|
|
|
1060
1061
|
imageObserver.unobserve(image);
|
|
1061
1062
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
1063
|
+
});
|
|
1064
|
+
}, options);
|
|
1064
1065
|
|
|
1065
1066
|
lazyloadImages.forEach(function (image) {
|
|
1066
1067
|
imageObserver.observe(image);
|
|
@@ -1461,7 +1462,7 @@
|
|
|
1461
1462
|
|
|
1462
1463
|
dispatchEvent(new Event('transparent:onbeforeunload'));
|
|
1463
1464
|
dispatchEvent(new Event('onbeforeunload'));
|
|
1464
|
-
|
|
1465
|
+
|
|
1465
1466
|
$(Transparent.html).prop("user-scroll", true);
|
|
1466
1467
|
$(Transparent.html).stop();
|
|
1467
1468
|
|
|
@@ -1533,7 +1534,7 @@
|
|
|
1533
1534
|
|
|
1534
1535
|
// From here the page is valid..
|
|
1535
1536
|
// so the new page is added to history..
|
|
1536
|
-
|
|
1537
|
+
|
|
1537
1538
|
if(xhr)
|
|
1538
1539
|
history.pushState({uuid: uuid, status:status, method: method, data: data instanceof FormData ? "" : data, href: responseURL}, '', responseURL);
|
|
1539
1540
|
|
|
@@ -1543,7 +1544,8 @@
|
|
|
1543
1544
|
|
|
1544
1545
|
// Page not recognized.. just go there.. no POST information transmitted..
|
|
1545
1546
|
if(!Transparent.isPage(dom))
|
|
1546
|
-
return
|
|
1547
|
+
return window.location.href = url;
|
|
1548
|
+
// return Transparent.rescue(dom);
|
|
1547
1549
|
|
|
1548
1550
|
// Layout not compatible.. needs to be reloaded (exception when POST is detected..)
|
|
1549
1551
|
if(!Transparent.isCompatiblePage(dom, method, data))
|
|
@@ -1583,7 +1585,7 @@
|
|
|
1583
1585
|
return window.location.reload();
|
|
1584
1586
|
|
|
1585
1587
|
return Transparent.onLoad(uuid, dom, function() {
|
|
1586
|
-
|
|
1588
|
+
|
|
1587
1589
|
Transparent.activeOut(function() {
|
|
1588
1590
|
|
|
1589
1591
|
Transparent.html
|