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