@glitchr/transparent 1.0.24 → 1.0.26
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/css/index.css +28 -0
- package/src/index.js +1 -1
- package/src/js/transparent.js +213 -97
- package/src/css/index.scss +0 -22
- package/src/images/error.svg +0 -12
package/package.json
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
img[data-src] { transition:all 0.25s ease !important; }
|
|
3
|
+
img[data-src]:not(.loaded) {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
visibility: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.lazybox.loading { animation: blink 2s infinite; }
|
|
9
|
+
@keyframes blink {
|
|
10
|
+
0% { background-color: transparent;}
|
|
11
|
+
25% { background-color: #EFEFEFAA;}
|
|
12
|
+
50% { background-color: transparent;}
|
|
13
|
+
75% { background-color: #EFEFEFAA;}
|
|
14
|
+
100% { background-color: transparent;}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.error
|
|
18
|
+
{
|
|
19
|
+
display:flex;
|
|
20
|
+
justify-content:center;
|
|
21
|
+
align-items:center;
|
|
22
|
+
|
|
23
|
+
width:100vw;
|
|
24
|
+
height: 100vh;
|
|
25
|
+
|
|
26
|
+
background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAWgAAAFoBAMAAACIy3zmAAAAGFBMVEWtDQ3xUknv7u7////X1tbsQjnvrKnveHJd2TvEAAAP2ElEQVR42tSdzVfaTBuHh1Z022hHt0hQt09nFLcUabslVGBrper2UR/033/zAQjJJLl/85HknUXP4ZziXHNxz/dMwmSSRDdJxh9F9/zx6f39+dnzTk7e3x8fR8OuH/0Xixkxe3/Ll7L3+P7Mp9PA416cgvDDdOq9P/71ZQOhfdn9+eTFiNkUFePtvmnQvjx/ep5OuZebQuUnb8MGQUtx/s5DmSUp9P0e6m4I9PmzMijUuv/6ogHQ/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mqF4A0PANeEeq9yUADbd6jlS/5kCnx9Orj8smqD5IU+VNAlbpogmqjzBo0QTVbQlCdxug+jcM3QDVEobuntateqIBfcn/17wZ7CYMwwBUTCucpy3jHiO4xxMfMBBcKVrgTJHomYHo76/VgGkMaOy4yW71BT89pbZj0ciqgQFN7uXCqh+QAR1bNbCgIWoBmSMLmry3kVSdIBc6oupnNnS8Wt1CNnS8U73jQ5dzdZwrTAfvQ1+fp09hpCvM+j5VDTR5cSOiuo1e0PQOI6F65AkNEXYgc/SELjtM6M1eB72hoR96ibr2hw6+RH1EAWhyX/RT3QIRaD2wAVXvUAYaiQdEeZVoIWj9RqwgfNUJiEFD3wZSvUMxaHKL4ao+f+4oAo20A8JU3QEQhR4G+MtNsjaO0Pcn13MItLqnmAe6DsPlEsBfgzBUf6A4tDakaq1Yc5I4NLFaz1gVWhyaNu8pxmzXADSxx8w4XUUemlZCSKpfsDFojVPbiOpzJ2wEGle2AdUL1I1CU6hnzuOobhiaQO2oug26cWgC9cxtSjIBoN2pXVQvwDmvFzTmVkz1AkwgaONKXat6j6S8blvTW+FApRKq90jMS7sEXIZDt+npruokQx0UGs3WeqrurI0ODF29jqmP6u9XMDQ0TpRlq06Or2BwaOyt6mWrG5pRR4IGM62XfUV18klMJAldFtBeXof9V/UrYFTo8rFf1GBfqF6OWIkkocvATLbWuqpeZuxEktBVkx2WtlMH1Wfk+NBV2Mtv6z6qTg8ZGu9EktDV9+P5k7LXhKtStT1kgEYmkSR02doneVGB2/SEnlZBtzi8/9zo/xl09WT0eLzZFEVRIXeL4rDJNAj88q/wC/Pgux3UJv26AAAAAElFTkSuQmCC");
|
|
27
|
+
background-size:90%;
|
|
28
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './js/transparent.js';
|
|
2
|
-
import './css/index.
|
|
2
|
+
import './css/index.css';
|
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
|
|
|
@@ -161,6 +161,7 @@
|
|
|
161
161
|
"disable": false,
|
|
162
162
|
"global_code": true,
|
|
163
163
|
"debug": true,
|
|
164
|
+
"lazyload": true,
|
|
164
165
|
"response_text": {},
|
|
165
166
|
"response_limit": 25,
|
|
166
167
|
"throttle": 1000,
|
|
@@ -210,6 +211,12 @@
|
|
|
210
211
|
dispatchEvent(new Event('transparent:'+Transparent.state.ACTIVE));
|
|
211
212
|
}
|
|
212
213
|
|
|
214
|
+
window.addEventListener("DOMContentLoaded", function()
|
|
215
|
+
{
|
|
216
|
+
Transparent.loader = $($(document).find(Settings.loader)[0] ?? Transparent.html);
|
|
217
|
+
Transparent.lazyLoad();
|
|
218
|
+
});
|
|
219
|
+
|
|
213
220
|
Transparent.isRescueMode = function() { return rescueMode; }
|
|
214
221
|
Transparent.getData = function(uuid)
|
|
215
222
|
{
|
|
@@ -260,7 +267,7 @@
|
|
|
260
267
|
|
|
261
268
|
function isDomEntity(entity)
|
|
262
269
|
{
|
|
263
|
-
return
|
|
270
|
+
return typeof entity === 'object' && entity.nodeType !== undefined;
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
Transparent.setResponse = function(uuid, responseText, scrollableXY = [], exceptionRaised = false)
|
|
@@ -412,14 +419,16 @@
|
|
|
412
419
|
Transparent.configure({'x-ajax-request': true});
|
|
413
420
|
Transparent.configure(options);
|
|
414
421
|
|
|
415
|
-
if(isReady) return this;
|
|
416
422
|
isReady = true;
|
|
417
423
|
|
|
418
424
|
dispatchEvent(new Event('transparent:'+Transparent.state.READY));
|
|
419
425
|
Transparent.html.addClass(Transparent.state.READY);
|
|
420
426
|
|
|
421
427
|
Transparent.addLayout();
|
|
428
|
+
Transparent.lazyLoad();
|
|
429
|
+
|
|
422
430
|
Transparent.scrollToHash(location.hash, {}, function() {
|
|
431
|
+
|
|
423
432
|
Transparent.activeOut(() => Transparent.html.removeClass(Transparent.state.FIRST));
|
|
424
433
|
});
|
|
425
434
|
|
|
@@ -894,18 +903,23 @@
|
|
|
894
903
|
console.error("Rescue mode.. called");
|
|
895
904
|
rescueMode = true;
|
|
896
905
|
|
|
906
|
+
var head = $(dom).find("head").html();
|
|
897
907
|
var body = $(dom).find("body").html();
|
|
898
|
-
if(body == "undefined") {
|
|
899
908
|
|
|
909
|
+
if(head == undefined || body == "undefined") {
|
|
910
|
+
|
|
900
911
|
$(Settings.identifier).html("<div class='error'></div>");
|
|
912
|
+
|
|
901
913
|
setTimeout(function() { window.location.reload(); }, Transparent.parseDuration(Settings["rescue_reload"]));
|
|
902
914
|
|
|
903
915
|
} else {
|
|
904
916
|
|
|
905
|
-
document.
|
|
906
|
-
|
|
917
|
+
document.head.innerHTML = $(dom).find("head").html();
|
|
918
|
+
document.body.innerHTML = $(dom).find("body").html();
|
|
919
|
+
Transparent.evalScript($("head")[0]);
|
|
920
|
+
Transparent.evalScript($("body")[0]);
|
|
907
921
|
}
|
|
908
|
-
|
|
922
|
+
|
|
909
923
|
Transparent.activeOut();
|
|
910
924
|
}
|
|
911
925
|
|
|
@@ -1026,6 +1040,104 @@
|
|
|
1026
1040
|
}, new Set());
|
|
1027
1041
|
}
|
|
1028
1042
|
|
|
1043
|
+
Transparent.lazyLoad = function (lazyloadImages = undefined)
|
|
1044
|
+
{
|
|
1045
|
+
lazyloadImages = lazyloadImages || document.querySelectorAll("img[data-src]:not(.loaded)");
|
|
1046
|
+
if ("IntersectionObserver" in window) {
|
|
1047
|
+
|
|
1048
|
+
var imageObserver = new IntersectionObserver(function (entries, observer) {
|
|
1049
|
+
entries.forEach(function (entry) {
|
|
1050
|
+
if (entry.isIntersecting) {
|
|
1051
|
+
var image = entry.target;
|
|
1052
|
+
var lazybox = image.closest(".lazybox");
|
|
1053
|
+
|
|
1054
|
+
image.onload = function() {
|
|
1055
|
+
this.classList.add("loaded");
|
|
1056
|
+
this.classList.remove("loading");
|
|
1057
|
+
if(lazybox) lazybox.classList.add("loaded");
|
|
1058
|
+
if(lazybox) lazybox.classList.remove("loading");
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
if(lazybox) lazybox.classList.add("loading");
|
|
1062
|
+
image.classList.add("loading");
|
|
1063
|
+
image.src = image.dataset.src;
|
|
1064
|
+
|
|
1065
|
+
imageObserver.unobserve(image);
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
lazyloadImages.forEach(function (image) {
|
|
1071
|
+
imageObserver.observe(image);
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
} else {
|
|
1075
|
+
|
|
1076
|
+
var lazyloadThrottleTimeout;
|
|
1077
|
+
|
|
1078
|
+
function lazyload() {
|
|
1079
|
+
if (lazyloadThrottleTimeout) {
|
|
1080
|
+
clearTimeout(lazyloadThrottleTimeout);
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
lazyloadThrottleTimeout = setTimeout(function () {
|
|
1084
|
+
var scrollTop = window.pageYOffset;
|
|
1085
|
+
lazyloadImages.forEach(function (img) {
|
|
1086
|
+
if (img.offsetTop < (window.innerHeight + scrollTop)) {
|
|
1087
|
+
img.src = img.dataset.src;
|
|
1088
|
+
img.classList.add('loaded');
|
|
1089
|
+
}
|
|
1090
|
+
});
|
|
1091
|
+
if (lazyloadImages.length == 0) {
|
|
1092
|
+
document.removeEventListener("scroll", lazyload);
|
|
1093
|
+
window.removeEventListener("resize", lazyload);
|
|
1094
|
+
window.removeEventListener("orientationChange", lazyload);
|
|
1095
|
+
}
|
|
1096
|
+
}, 20);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
document.addEventListener("scroll", lazyload);
|
|
1100
|
+
window.addEventListener("resize", lazyload);
|
|
1101
|
+
window.addEventListener("orientationChange", lazyload);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
Transparent.loadImages = function()
|
|
1106
|
+
{
|
|
1107
|
+
function loadImg (src, timeout = 500) {
|
|
1108
|
+
var imgPromise = new Promise((resolve, reject) => {
|
|
1109
|
+
|
|
1110
|
+
let img = new Image()
|
|
1111
|
+
img.onload = () => {
|
|
1112
|
+
resolve({
|
|
1113
|
+
src: src,
|
|
1114
|
+
width: img.naturalWidth,
|
|
1115
|
+
height: img.naturalHeight
|
|
1116
|
+
})
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
img.onerror = reject
|
|
1120
|
+
img.src = src
|
|
1121
|
+
})
|
|
1122
|
+
|
|
1123
|
+
var timer = new Promise((resolve, reject) => { setTimeout(reject, timeout) })
|
|
1124
|
+
return Promise.race([imgPromise, timer])
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function loadImgAll (imgList, timeout = 500) {
|
|
1128
|
+
return new Promise((resolve, reject) => {
|
|
1129
|
+
Promise.all(imgList
|
|
1130
|
+
.map(src => loadImg(src, timeout))
|
|
1131
|
+
.map(p => p.catch(e => false))
|
|
1132
|
+
).then(results => resolve(results.filter(r => r)))
|
|
1133
|
+
})
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
return new Promise((resolve, reject) => {
|
|
1137
|
+
loadImgAll(Array.from(Transparent.findImages(document.documentElement))).then(resolve, reject)
|
|
1138
|
+
})
|
|
1139
|
+
}
|
|
1140
|
+
|
|
1029
1141
|
Transparent.transferAttributes = function(dom) {
|
|
1030
1142
|
|
|
1031
1143
|
var html = $(dom).find("html");
|
|
@@ -1034,37 +1146,27 @@
|
|
|
1034
1146
|
$("html").removeAttr(attr.name);
|
|
1035
1147
|
});
|
|
1036
1148
|
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
$(
|
|
1040
|
-
|
|
1041
|
-
$("html").attr(attr.name, attr.value);
|
|
1042
|
-
});
|
|
1043
|
-
}
|
|
1149
|
+
$($(html)[0].attributes).each(function(i, attr) {
|
|
1150
|
+
if(attr.name == "class") return;
|
|
1151
|
+
$("html").attr(attr.name, attr.value);
|
|
1152
|
+
});
|
|
1044
1153
|
|
|
1045
1154
|
var head = $(dom).find("head");
|
|
1046
1155
|
$($("head")[0].attributes).each(function(i, attr) {
|
|
1047
1156
|
$("head").removeAttr(attr.name);
|
|
1048
1157
|
});
|
|
1049
1158
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
$("head").attr(attr.name, attr.value);
|
|
1054
|
-
});
|
|
1055
|
-
}
|
|
1159
|
+
$($(head)[0].attributes).each(function(i, attr) {
|
|
1160
|
+
$("head").attr(attr.name, attr.value);
|
|
1161
|
+
});
|
|
1056
1162
|
|
|
1057
1163
|
var body = $(dom).find("body");
|
|
1058
1164
|
$($("body")[0].attributes).each(function(i, attr) {
|
|
1059
1165
|
$("body").removeAttr(attr.name);
|
|
1060
1166
|
});
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
$($(body)[0].attributes).each(function(i, attr) {
|
|
1065
|
-
$("body").attr(attr.name, attr.value);
|
|
1066
|
-
});
|
|
1067
|
-
}
|
|
1167
|
+
$($(body)[0].attributes).each(function(i, attr) {
|
|
1168
|
+
$("body").attr(attr.name, attr.value);
|
|
1169
|
+
});
|
|
1068
1170
|
}
|
|
1069
1171
|
|
|
1070
1172
|
Transparent.onLoad = function(uuid, dom, callback = null, scrollTo = false) {
|
|
@@ -1076,19 +1178,14 @@
|
|
|
1076
1178
|
// Transfert attributes
|
|
1077
1179
|
Transparent.transferAttributes(dom);
|
|
1078
1180
|
|
|
1079
|
-
// Replace head..
|
|
1181
|
+
// Replace head.. (@TODO keep ordering, by adding after.. last node probed)
|
|
1080
1182
|
var head = $(dom).find("head");
|
|
1081
1183
|
$("head").children().each(function() {
|
|
1082
1184
|
|
|
1083
1185
|
var el = this;
|
|
1084
1186
|
var found = false;
|
|
1085
1187
|
|
|
1086
|
-
head.children().each(function() {
|
|
1087
|
-
|
|
1088
|
-
found = this.isEqualNode(el);
|
|
1089
|
-
return !found;
|
|
1090
|
-
});
|
|
1091
|
-
|
|
1188
|
+
head.children().each(function() { found |= this.isEqualNode(el); });
|
|
1092
1189
|
if(!found) this.remove();
|
|
1093
1190
|
});
|
|
1094
1191
|
|
|
@@ -1105,6 +1202,30 @@
|
|
|
1105
1202
|
}
|
|
1106
1203
|
});
|
|
1107
1204
|
|
|
1205
|
+
// Replace body end (@TODO keep ordering, by adding after.. last node probed)
|
|
1206
|
+
var bodyScript = $(dom).find("body > script");
|
|
1207
|
+
$("body").find("script").each(function() {
|
|
1208
|
+
|
|
1209
|
+
var el = this;
|
|
1210
|
+
var found = false;
|
|
1211
|
+
|
|
1212
|
+
bodyScript.each(function() { found |= this.isEqualNode(el); });
|
|
1213
|
+
if(!found) this.remove();
|
|
1214
|
+
});
|
|
1215
|
+
|
|
1216
|
+
bodyScript.each(function() {
|
|
1217
|
+
|
|
1218
|
+
var el = this;
|
|
1219
|
+
var found = false;
|
|
1220
|
+
|
|
1221
|
+
$("body").find("script").each(function() { found |= this.isEqualNode(el); });
|
|
1222
|
+
if(!found) {
|
|
1223
|
+
|
|
1224
|
+
if(this.tagName != "SCRIPT" || Settings["global_code"] == true) $("body").append(this.cloneNode(true));
|
|
1225
|
+
else $("body").append(this);
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
|
|
1108
1229
|
// Replace canvases..
|
|
1109
1230
|
Transparent.replaceCanvases(dom);
|
|
1110
1231
|
|
|
@@ -1165,19 +1286,21 @@
|
|
|
1165
1286
|
}
|
|
1166
1287
|
|
|
1167
1288
|
$('head').append(function() {
|
|
1289
|
+
$('body').append(function() {
|
|
1168
1290
|
|
|
1169
|
-
|
|
1291
|
+
$(Settings.identifier).append(function() {
|
|
1170
1292
|
|
|
1171
|
-
|
|
1293
|
+
setTimeout(function() {
|
|
1172
1294
|
|
|
1173
|
-
|
|
1174
|
-
|
|
1295
|
+
// Callback if needed, or any other actions
|
|
1296
|
+
callback();
|
|
1175
1297
|
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1298
|
+
// Trigger onload event
|
|
1299
|
+
dispatchEvent(new Event('transparent:load'));
|
|
1300
|
+
dispatchEvent(new Event('load'));
|
|
1179
1301
|
|
|
1180
|
-
|
|
1302
|
+
}.bind(this), 1);
|
|
1303
|
+
});
|
|
1181
1304
|
});
|
|
1182
1305
|
});
|
|
1183
1306
|
}
|
|
@@ -1304,8 +1427,7 @@
|
|
|
1304
1427
|
|
|
1305
1428
|
var form = target != undefined && target.tagName == "FORM" ? target : undefined;
|
|
1306
1429
|
if (form) {
|
|
1307
|
-
|
|
1308
|
-
data = new FormData(form);
|
|
1430
|
+
data = $(form).serialize();
|
|
1309
1431
|
$(form).find(':submit').attr('disabled', 'disabled');
|
|
1310
1432
|
}
|
|
1311
1433
|
|
|
@@ -1354,7 +1476,7 @@
|
|
|
1354
1476
|
|
|
1355
1477
|
dispatchEvent(new Event('transparent:onbeforeunload'));
|
|
1356
1478
|
dispatchEvent(new Event('onbeforeunload'));
|
|
1357
|
-
|
|
1479
|
+
|
|
1358
1480
|
$(Transparent.html).prop("user-scroll", true);
|
|
1359
1481
|
$(Transparent.html).stop();
|
|
1360
1482
|
|
|
@@ -1399,6 +1521,7 @@
|
|
|
1399
1521
|
if(!Transparent.hasResponse(uuid))
|
|
1400
1522
|
Transparent.setResponse(uuid, responseText);
|
|
1401
1523
|
}
|
|
1524
|
+
|
|
1402
1525
|
var dom = new DOMParser().parseFromString(responseText, "text/html");
|
|
1403
1526
|
if(request && request.getResponseHeader("Content-Type") == "application/json") {
|
|
1404
1527
|
|
|
@@ -1426,9 +1549,8 @@
|
|
|
1426
1549
|
|
|
1427
1550
|
// From here the page is valid..
|
|
1428
1551
|
// so the new page is added to history..
|
|
1429
|
-
|
|
1430
1552
|
if(xhr)
|
|
1431
|
-
history.pushState({uuid: uuid, status:status, method: method, data: data
|
|
1553
|
+
history.pushState({uuid: uuid, status:status, method: method, data: data, href: responseURL}, '', responseURL);
|
|
1432
1554
|
|
|
1433
1555
|
var dom = new DOMParser().parseFromString(responseText, "text/html");
|
|
1434
1556
|
if(status != 200) // Blatant error received..
|
|
@@ -1437,7 +1559,6 @@
|
|
|
1437
1559
|
// Page not recognized.. just go there.. no POST information transmitted..
|
|
1438
1560
|
if(!Transparent.isPage(dom))
|
|
1439
1561
|
return window.location.href = url;
|
|
1440
|
-
// return Transparent.rescue(dom);
|
|
1441
1562
|
|
|
1442
1563
|
// Layout not compatible.. needs to be reloaded (exception when POST is detected..)
|
|
1443
1564
|
if(!Transparent.isCompatiblePage(dom, method, data))
|
|
@@ -1477,7 +1598,7 @@
|
|
|
1477
1598
|
return window.location.reload();
|
|
1478
1599
|
|
|
1479
1600
|
return Transparent.onLoad(uuid, dom, function() {
|
|
1480
|
-
|
|
1601
|
+
|
|
1481
1602
|
Transparent.activeOut(function() {
|
|
1482
1603
|
|
|
1483
1604
|
Transparent.html
|
|
@@ -1509,8 +1630,6 @@
|
|
|
1509
1630
|
url: url.href,
|
|
1510
1631
|
type: type,
|
|
1511
1632
|
data: data,
|
|
1512
|
-
contentType: false,
|
|
1513
|
-
processData: false,
|
|
1514
1633
|
dataType: 'html',
|
|
1515
1634
|
headers: Settings["headers"] || {},
|
|
1516
1635
|
xhr: function () { return xhr; },
|
|
@@ -1527,9 +1646,6 @@
|
|
|
1527
1646
|
if (href != location.origin + location.pathname + location.hash)
|
|
1528
1647
|
history.replaceState({uuid: uuidv4(), status: history.state ? history.state.status : 200, data:{}, method: history.state ? history.state.method : "GET", href: location.origin + location.pathname + location.hash}, '', location.origin + location.pathname + location.hash);
|
|
1529
1648
|
|
|
1530
|
-
window.addEventListener("DOMContentLoaded", function() { Transparent.loader = $($(document).find(Settings.loader)[0] ?? Transparent.html); }, true);
|
|
1531
|
-
window.addEventListener("load",function() { Transparent.ready(); });
|
|
1532
|
-
|
|
1533
1649
|
// Overload onpopstate
|
|
1534
1650
|
if(Settings.disable) {
|
|
1535
1651
|
|
package/src/css/index.scss
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
@keyframes blinkOpacity {
|
|
3
|
-
0% { opacity: 1; }
|
|
4
|
-
25% { opacity: 0; }
|
|
5
|
-
50% { opacity: 1; }
|
|
6
|
-
75% { opacity: 0; }
|
|
7
|
-
100% { opacity: 1; }
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.error
|
|
11
|
-
{
|
|
12
|
-
animation: blink 5s infinite;
|
|
13
|
-
|
|
14
|
-
width:100vw;
|
|
15
|
-
height: 100vh;
|
|
16
|
-
|
|
17
|
-
background-image:url("../images/error.svg");
|
|
18
|
-
background-position: center;
|
|
19
|
-
background-repeat: no-repeat;
|
|
20
|
-
|
|
21
|
-
animation: blinkOpacity 2s infinite;
|
|
22
|
-
}
|
package/src/images/error.svg
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<svg width="256" height="256" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
|
3
|
-
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
|
|
4
|
-
<g>
|
|
5
|
-
<title>Layer 1</title>
|
|
6
|
-
<g stroke="null" id="svg_1">
|
|
7
|
-
<rect stroke="null" id="svg_2" x="0" y="0" opacity="0.3" fill="rgba(105,77,255,0)" height="256.17189" width="256.265636"/>
|
|
8
|
-
<path stroke="null" id="svg_3" fill="#fff" d="m128.132818,21.347657a106.777348,106.738287 0 1 0 106.777348,106.738287a106.777348,106.738287 0 0 0 -106.777348,-106.738287z"/>
|
|
9
|
-
<path stroke="null" id="svg_4" fill="#dd1e1e" d="m128.132818,32.021486a96.099614,96.064459 0 1 0 96.099614,96.064459a96.099614,96.064459 0 0 0 -96.099614,-96.064459zm55.524221,130.220711l-21.35547,21.347657l-34.168751,-34.156252l-34.168751,34.156252l-21.35547,-21.347657l34.168751,-34.156252l-34.168751,-34.156252l21.35547,-21.347657l34.168751,34.156252l34.168751,-34.156252l21.35547,21.347657l-34.168751,34.156252l34.168751,34.156252z"/>
|
|
10
|
-
</g>
|
|
11
|
-
</g>
|
|
12
|
-
</svg>
|