@glitchr/transparent 1.0.33 → 1.0.35
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 +94 -81
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -910,7 +910,6 @@
|
|
|
910
910
|
var head = $(dom).find("head").html();
|
|
911
911
|
var body = $(dom).find("body").html();
|
|
912
912
|
|
|
913
|
-
console.log(head, body);
|
|
914
913
|
if(head == undefined || body == "undefined") {
|
|
915
914
|
|
|
916
915
|
$(Settings.identifier).html("<div class='error'></div>");
|
|
@@ -1180,125 +1179,139 @@
|
|
|
1180
1179
|
window.previousLocation = window.location.toString();
|
|
1181
1180
|
if(callback === null) callback = function() {};
|
|
1182
1181
|
|
|
1183
|
-
|
|
1184
|
-
|
|
1182
|
+
activeInRemainingTime = activeInRemainingTime - (Date.now() - activeInTime);
|
|
1183
|
+
setTimeout(function() {
|
|
1185
1184
|
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
$("head").children().each(function() {
|
|
1185
|
+
// Transfert attributes
|
|
1186
|
+
Transparent.transferAttributes(dom);
|
|
1189
1187
|
|
|
1190
|
-
|
|
1191
|
-
var
|
|
1188
|
+
// Replace head..
|
|
1189
|
+
var head = $(dom).find("head");
|
|
1190
|
+
$("head").children().each(function() {
|
|
1192
1191
|
|
|
1193
|
-
|
|
1192
|
+
var el = this;
|
|
1193
|
+
var found = false;
|
|
1194
1194
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1195
|
+
head.children().each(function() {
|
|
1196
|
+
|
|
1197
|
+
found = this.isEqualNode(el);
|
|
1198
|
+
return !found;
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
if(!found) this.remove();
|
|
1197
1202
|
});
|
|
1198
1203
|
|
|
1199
|
-
|
|
1200
|
-
});
|
|
1204
|
+
head.children().each(function() {
|
|
1201
1205
|
|
|
1202
|
-
|
|
1206
|
+
var el = this;
|
|
1207
|
+
var found = false;
|
|
1203
1208
|
|
|
1204
|
-
|
|
1205
|
-
|
|
1209
|
+
$("head").children().each(function() { found |= this.isEqualNode(el); });
|
|
1210
|
+
if(!found) {
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
if(this.tagName != "SCRIPT" || Settings["global_code"] == true) {
|
|
1214
|
+
|
|
1215
|
+
$("head").append(this.cloneNode(true));
|
|
1216
|
+
|
|
1217
|
+
} else {
|
|
1206
1218
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1219
|
+
$("head").append(this);
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
});
|
|
1209
1223
|
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
}
|
|
1213
|
-
});
|
|
1224
|
+
var bodyScript = $(dom).find("body > script");
|
|
1225
|
+
bodyScript.each(function() {
|
|
1214
1226
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1227
|
+
var el = this;
|
|
1228
|
+
var found = false;
|
|
1217
1229
|
|
|
1218
|
-
|
|
1219
|
-
|
|
1230
|
+
$("body").children().each(function() { found |= this.isEqualNode(el); });
|
|
1231
|
+
if(!found) {
|
|
1220
1232
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1233
|
+
if(this.tagName != "SCRIPT" || Settings["global_code"] == true) {
|
|
1234
|
+
$("body").append(this.cloneNode(true));
|
|
1235
|
+
} else {
|
|
1236
|
+
$("body").append(this);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
});
|
|
1224
1240
|
|
|
1225
|
-
|
|
1226
|
-
|
|
1241
|
+
// Replace canvases..
|
|
1242
|
+
Transparent.replaceCanvases(dom);
|
|
1227
1243
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1244
|
+
// Extract page block to be loaded
|
|
1245
|
+
var page = $(dom).find(Settings.identifier);
|
|
1246
|
+
if(dom == undefined || page == undefined) window.reload(); // Error a posteriori
|
|
1231
1247
|
|
|
1232
|
-
|
|
1248
|
+
var oldPage = $(Settings.identifier);
|
|
1233
1249
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1250
|
+
// Make sure name/layout keep the same after a page change (tolerance for POST or GET requests)
|
|
1251
|
+
if(oldPage.attr("data-layout") != undefined && page.attr("data-layout") != undefined) {
|
|
1236
1252
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1253
|
+
var switchLayout = Transparent.state.SWITCH.replace("X", page.attr("data-layout")).replace("Y", oldPage.attr("data-layout"));
|
|
1254
|
+
page.attr("data-layout-prev", oldPage.attr("data-layout"));
|
|
1255
|
+
}
|
|
1240
1256
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1257
|
+
var states = Object.values(Transparent.state);
|
|
1258
|
+
var htmlClass = Array.from(($(dom).find("html").attr("class") || "").split(" ")).filter(x => !states.includes(x));
|
|
1259
|
+
var oldHtmlClass = Array.from(($(Transparent.html).attr("class") || "").split(" "));
|
|
1260
|
+
var removeHtmlClass = oldHtmlClass.filter(x => !htmlClass.includes(x) && switchLayout != x && !states.includes(x));
|
|
1245
1261
|
|
|
1246
|
-
|
|
1247
|
-
|
|
1262
|
+
Transparent.html.removeClass(removeHtmlClass).addClass(htmlClass);
|
|
1263
|
+
$(page).insertBefore(oldPage);
|
|
1248
1264
|
|
|
1249
|
-
|
|
1265
|
+
oldPage.remove();
|
|
1250
1266
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1267
|
+
if(Settings["global_code"] == true) Transparent.evalScript($(page)[0]);
|
|
1268
|
+
document.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1269
|
+
window.dispatchEvent(new Event('DOMContentLoaded'));
|
|
1254
1270
|
|
|
1255
|
-
|
|
1271
|
+
Transparent.addLayout();
|
|
1256
1272
|
|
|
1257
|
-
|
|
1273
|
+
if(scrollTo) {
|
|
1258
1274
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1275
|
+
// Go back to top of the page..
|
|
1276
|
+
var scrollableElements = Transparent.getScrollableElement();
|
|
1277
|
+
var scrollableElementsXY = Transparent.getResponsePosition(uuid);
|
|
1262
1278
|
|
|
1263
|
-
|
|
1279
|
+
for(i = 0; i < scrollableElements.length; i++) {
|
|
1264
1280
|
|
|
1265
|
-
|
|
1266
|
-
|
|
1281
|
+
var el = scrollableElements[i];
|
|
1282
|
+
var positionXY = undefined;
|
|
1267
1283
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1284
|
+
if(scrollableElementsXY.length == scrollableElements.length)
|
|
1285
|
+
positionXY = scrollableElementsXY[i] || undefined;
|
|
1270
1286
|
|
|
1271
|
-
|
|
1287
|
+
if(el == window || el == document.documentElement) {
|
|
1272
1288
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1289
|
+
if(positionXY != undefined) Transparent.scrollTo({top:positionXY[0], left:positionXY[1], duration:0});
|
|
1290
|
+
else if (location.hash) Transparent.scrollToHash(location.hash, {duration:0});
|
|
1291
|
+
else Transparent.scrollTo({top:0, left:0, duration:0});
|
|
1276
1292
|
|
|
1277
|
-
|
|
1293
|
+
} else {
|
|
1278
1294
|
|
|
1279
|
-
|
|
1280
|
-
|
|
1295
|
+
if(positionXY != undefined) Transparent.scrollTo({top:positionXY[0], left:positionXY[1], duration:0}, el);
|
|
1296
|
+
else Transparent.scrollTo({top:0, left:0, duration:0}, el);
|
|
1297
|
+
}
|
|
1281
1298
|
}
|
|
1282
1299
|
}
|
|
1283
|
-
}
|
|
1284
|
-
|
|
1285
|
-
$('head').append(function() {
|
|
1286
1300
|
|
|
1287
|
-
$(
|
|
1301
|
+
$('head').append(function() {
|
|
1288
1302
|
|
|
1289
|
-
|
|
1290
|
-
setTimeout(function() {
|
|
1303
|
+
$(Settings.identifier).append(function() {
|
|
1291
1304
|
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
// Trigger onload event
|
|
1296
|
-
dispatchEvent(new Event('transparent:load'));
|
|
1297
|
-
dispatchEvent(new Event('load'));
|
|
1305
|
+
// Callback if needed, or any other actions
|
|
1306
|
+
callback();
|
|
1298
1307
|
|
|
1299
|
-
|
|
1308
|
+
// Trigger onload event
|
|
1309
|
+
dispatchEvent(new Event('transparent:load'));
|
|
1310
|
+
dispatchEvent(new Event('load'));
|
|
1311
|
+
});
|
|
1300
1312
|
});
|
|
1301
|
-
|
|
1313
|
+
|
|
1314
|
+
}.bind(this), activeInRemainingTime > 0 ? activeInRemainingTime : 1);
|
|
1302
1315
|
}
|
|
1303
1316
|
|
|
1304
1317
|
function uuidv4() {
|