Correctly load and initialize Alpine.js
This commit is contained in:
parent
b9e557e6b8
commit
b2e5fbbe9d
9 changed files with 42 additions and 39 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
* Fix cross-site scripting vulnerability in search output
|
* Fix cross-site scripting vulnerability in search output
|
||||||
* Fix new choices being added to an existing poll at the wrong position
|
* Fix new choices being added to an existing poll at the wrong position
|
||||||
* Fix errors in the client-side code filtering the referrers
|
* Fix errors in the client-side code filtering the referrers
|
||||||
|
* Correctly load and initialize Alpine.js
|
||||||
|
|
||||||
## 2024 January 7
|
## 2024 January 7
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Setup drag&drop for image uploads
|
// Setup drag&drop for image uploads
|
||||||
(function() {
|
document.addEventListener("alpine:init", () => {
|
||||||
const dropElement = document.querySelector('.av-upload-drop');
|
const dropElement = document.querySelector('.av-upload-drop');
|
||||||
const parent = location.href.lastIndexOf('/layout/images/') > -1 ? 'layout' : 'site';
|
const parent = location.href.lastIndexOf('/layout/images/') > -1 ? 'layout' : 'site';
|
||||||
const uploadUrl = '<% site.images.href upload %>?parent=' + parent;
|
const uploadUrl = '<% site.images.href upload %>?parent=' + parent;
|
||||||
|
|
@ -84,5 +84,5 @@
|
||||||
error: restoreDrop,
|
error: restoreDrop,
|
||||||
abort: restoreDrop
|
abort: restoreDrop
|
||||||
});
|
});
|
||||||
})();
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
document.addEventListener("alpine:init", () => {
|
||||||
// Group related <option> elements by inserting additional <optgroup> elements.
|
// Group related <option> elements by inserting additional <optgroup> elements.
|
||||||
const dom = window;
|
const dom = window;
|
||||||
const groups = [];
|
const groups = [];
|
||||||
|
|
@ -246,7 +246,7 @@
|
||||||
// Correct the selected index
|
// Correct the selected index
|
||||||
timeZone.selectedIndex = Array.from(timeZone.options).indexOf(timeZone.querySelector('option[selected]'));
|
timeZone.selectedIndex = Array.from(timeZone.options).indexOf(timeZone.querySelector('option[selected]'));
|
||||||
});
|
});
|
||||||
})();
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% #meta %>
|
<% #meta %>
|
||||||
|
|
@ -1135,7 +1135,7 @@ a.gs-title:hover {
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
document.addEventListener("alpine:init", () => {
|
||||||
const query = new Antville.Query();
|
const query = new Antville.Query();
|
||||||
const spamFilter = new Antville.Filter(JSON.parse('<% site.spamfilter %>'));
|
const spamFilter = new Antville.Filter(JSON.parse('<% site.spamfilter %>'));
|
||||||
const searchFilter = new Antville.Filter(query.filter);
|
const searchFilter = new Antville.Filter(query.filter);
|
||||||
|
|
@ -1249,7 +1249,7 @@ a.gs-title:hover {
|
||||||
});
|
});
|
||||||
|
|
||||||
sortedRows.forEach(function(row) { table.appendChild(row); });
|
sortedRows.forEach(function(row) { table.appendChild(row); });
|
||||||
})();
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% #referrer %>
|
<% #referrer %>
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
document.addEventListener("alpine:init", () => {
|
||||||
// Setup skin editor
|
// Setup skin editor
|
||||||
let mode = 'application/x-helma-skin';
|
let mode = 'application/x-helma-skin';
|
||||||
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
tabSize: 3,
|
tabSize: 3,
|
||||||
viewportMargin: Infinity
|
viewportMargin: Infinity
|
||||||
});
|
});
|
||||||
})();
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% #compare %>
|
<% #compare %>
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@
|
||||||
background-color: #f2fae3;
|
background-color: #f2fae3;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script src='<% site.href main.js %>'></script>
|
|
||||||
<script src='<% root.static ../../scripts/editor.min.js %>'></script>
|
<script src='<% root.static ../../scripts/editor.min.js %>'></script>
|
||||||
|
<script defer src='<% site.href main.js %>'></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<span class='uk-margin-right uk-float-right'>
|
<span class='uk-margin-right uk-float-right'>
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ else
|
||||||
<% #editor %>
|
<% #editor %>
|
||||||
<script>
|
<script>
|
||||||
// Load additonal scripts and styles for UIkit’s HTML editor plugin
|
// Load additonal scripts and styles for UIkit’s HTML editor plugin
|
||||||
(function() {
|
document.addEventListener("alpine:init", () => {
|
||||||
const _form = document.querySelector('#av-story-form');
|
const _form = document.querySelector('#av-story-form');
|
||||||
|
|
||||||
if (!_form) return;
|
if (!_form) return;
|
||||||
|
|
@ -296,5 +296,5 @@ else
|
||||||
|
|
||||||
scheduler();
|
scheduler();
|
||||||
}
|
}
|
||||||
})();
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -23,35 +23,37 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Load additional script for Collage jQuery plugin
|
// Load additional script for Collage jQuery plugin
|
||||||
if ('<% tag.type parent %>' === 'Image') {
|
document.addEventListener("alpine:init", () => {
|
||||||
const script = document.createElement('script');
|
if ('<% tag.type parent %>' === 'Image') {
|
||||||
|
const script = document.createElement('script');
|
||||||
|
|
||||||
script.onload = function() {
|
script.onload = function() {
|
||||||
$(function() {
|
$(function() {
|
||||||
let resizeTimer = null;
|
let resizeTimer = null;
|
||||||
|
|
||||||
const collage = () => {
|
const collage = () => {
|
||||||
$('.av-collage').removeWhitespace().collagePlus({
|
$('.av-collage').removeWhitespace().collagePlus({
|
||||||
allowPartialLastRow: true,
|
allowPartialLastRow: true,
|
||||||
fadeSpeed: 'slow'
|
fadeSpeed: 'slow'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$('.av-collage').collageCaption();
|
||||||
|
|
||||||
|
$(window).bind('resize', function() {
|
||||||
|
$('.av-tagged-image').css('opacity', 0);
|
||||||
|
if (resizeTimer) clearTimeout(resizeTimer);
|
||||||
|
resizeTimer = setTimeout(collage, 200);
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
$('.av-collage').collageCaption();
|
collage();
|
||||||
|
|
||||||
$(window).bind('resize', function() {
|
|
||||||
$('.av-tagged-image').css('opacity', 0);
|
|
||||||
if (resizeTimer) clearTimeout(resizeTimer);
|
|
||||||
resizeTimer = setTimeout(collage, 200);
|
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
collage();
|
script.src = '<% root.static ../../scripts/gallery.min.js %>';
|
||||||
});
|
document.head.appendChild(script);
|
||||||
};
|
}
|
||||||
|
});
|
||||||
script.src = '<% root.static ../../scripts/gallery.min.js %>';
|
|
||||||
document.head.appendChild(script);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<% #simple %>
|
<% #simple %>
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Load additional script for Google’s custom search
|
// Load additional script for Google’s custom search
|
||||||
(function() {
|
document.addEventListener("alpine:init", () => {
|
||||||
var cx = '008141500676255803966:bw4l-wnuz44';
|
var cx = '008141500676255803966:bw4l-wnuz44';
|
||||||
var gcse = document.createElement('script');
|
var gcse = document.createElement('script');
|
||||||
gcse.type = 'text/javascript';
|
gcse.type = 'text/javascript';
|
||||||
gcse.async = true;
|
gcse.async = true;
|
||||||
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
|
gcse.src = (document.location.protocol === 'https:' ? 'https:' : 'http:') +
|
||||||
'//www.google.com/cse/cse.js?cx=' + cx;
|
'//www.google.com/cse/cse.js?cx=' + cx;
|
||||||
var s = document.getElementsByTagName('script')[0];
|
var s = document.getElementsByTagName('script')[0];
|
||||||
s.parentNode.insertBefore(gcse, s);
|
s.parentNode.insertBefore(gcse, s);
|
||||||
})();
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,6 @@ require('uikit/dist/js/components/form-password');
|
||||||
require('uikit/dist/js/components/tooltip');
|
require('uikit/dist/js/components/tooltip');
|
||||||
require('uikit/dist/js/components/upload');
|
require('uikit/dist/js/components/upload');
|
||||||
|
|
||||||
Alpine.start();
|
|
||||||
|
|
||||||
const Antville = window.Antville = {};
|
const Antville = window.Antville = {};
|
||||||
|
|
||||||
Antville.hash = require('js-md5/src/md5');
|
Antville.hash = require('js-md5/src/md5');
|
||||||
|
|
@ -263,3 +261,5 @@ Antville.http = (method, url, options) => {
|
||||||
httpClient.send(_data);
|
httpClient.send(_data);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Alpine.start();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue