use compress move js
This commit is contained in:
parent
d4543634e0
commit
444a4b9306
3 changed files with 110 additions and 105 deletions
|
@ -15,3 +15,40 @@ function getCookie(name) {
|
||||||
}
|
}
|
||||||
return cookieValue;
|
return cookieValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var restrictedElements = [];
|
||||||
|
function removeBehaviorsRestrictions(event) {
|
||||||
|
if (restrictedElements.length > 0) {
|
||||||
|
var rElements = restrictedElements;
|
||||||
|
restrictedElements = [];
|
||||||
|
rElements.forEach(function(video) {
|
||||||
|
if (video.autoplay && video.paused) {
|
||||||
|
video.load()
|
||||||
|
video.play()
|
||||||
|
if (video.paused) {
|
||||||
|
restrictedElements.push(video)
|
||||||
|
}
|
||||||
|
} else if (video.readyState < 4) {
|
||||||
|
video.load()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.querySelector('video')) {
|
||||||
|
let video = document.createElement('video');
|
||||||
|
video.muted = true
|
||||||
|
video.play();
|
||||||
|
if (video.paused) {
|
||||||
|
restrictedElements = document.querySelectorAll('video.gif')
|
||||||
|
window.addEventListener('keydown', removeBehaviorsRestrictions);
|
||||||
|
window.addEventListener('mousedown', removeBehaviorsRestrictions);
|
||||||
|
window.addEventListener('touchstart', removeBehaviorsRestrictions);
|
||||||
|
restrictedElements.forEach(video => {
|
||||||
|
if (!video.poster) {
|
||||||
|
video.poster = video.src.replace('.mp4', '.jpg')
|
||||||
|
video.muted = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
65
camp/static/js/slideshow.js
Normal file
65
camp/static/js/slideshow.js
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
var startSlide = 0;
|
||||||
|
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
||||||
|
startSlide = parseInt(document.location.hash.slice(1)) - 1
|
||||||
|
}
|
||||||
|
function loadSlideshow() {
|
||||||
|
$('a.original-link').bind('touchstart MSPointerDown pointerdown', function(event) {
|
||||||
|
event.stopPropagation()
|
||||||
|
});
|
||||||
|
$('a.original-link').on({
|
||||||
|
mousedown: function(event) {
|
||||||
|
event.stopPropagation()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
slider = $('.slider1').show().bxSlider({
|
||||||
|
startSlide: startSlide,
|
||||||
|
preloadImages: 'all',
|
||||||
|
adaptiveHeight : true,
|
||||||
|
pager : false,
|
||||||
|
});
|
||||||
|
|
||||||
|
var images = $('.slider1 img'), count = images.length;
|
||||||
|
images.on({load: function(event) {
|
||||||
|
setTimeout(function() {
|
||||||
|
slider.resize()
|
||||||
|
slider.redrawSlider()
|
||||||
|
}, 100)
|
||||||
|
}})
|
||||||
|
|
||||||
|
document.querySelectorAll('.select-image').forEach(function(a) {
|
||||||
|
a.onclick = function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
slider.goToSlide(parseInt(this.dataset.id) - 1)
|
||||||
|
document.location.hash = '#' + this.dataset.id;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
||||||
|
var slide = parseInt(document.location.hash.slice(1))
|
||||||
|
if (slide) {
|
||||||
|
slider.goToSlide(slide - 1)
|
||||||
|
slider.resize()
|
||||||
|
slider.redrawSlider()
|
||||||
|
setTimeout(function() {
|
||||||
|
slider.resize()
|
||||||
|
slider.redrawSlider()
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
$(document).keydown(function(e){
|
||||||
|
if (e.keyCode == 39) // Right arrow
|
||||||
|
{
|
||||||
|
slider && slider.goToNextSlide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else if (e.keyCode == 37) // left arrow
|
||||||
|
{
|
||||||
|
slider && slider.goToPrevSlide();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(document).ready(loadSlideshow);
|
|
@ -1,4 +1,4 @@
|
||||||
{% load available_content static %}
|
{% load available_content static compress sass_tags %}
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html class="no-js" lang="en">
|
<html class="no-js" lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -11,8 +11,11 @@
|
||||||
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
|
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans"/>
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}?20250201">
|
<link rel="stylesheet" type="text/css" href="{% static "css/foundation.css" %}?20250201">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/jquery.bxslider.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "css/jquery.bxslider.css" %}">
|
||||||
|
{% compress css file site %}
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/main.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "css/main.css" %}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static "css/app.css" %}">
|
<link rel="stylesheet" type="text/css" href="{% static "css/app.css" %}">
|
||||||
|
<link rel="stylesheet" href="{% sass_src 'css/site.scss' %}"></link>
|
||||||
|
{% endcompress %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
@ -45,115 +48,15 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% load static %}
|
{}
|
||||||
<script src="{% static "js/jquery.js" %}"></script>
|
<script src="{% static "js/jquery.js" %}"></script>
|
||||||
<script src="{% static "js/foundation.js" %}"></script>
|
<script src="{% static "js/foundation.js" %}"></script>
|
||||||
|
{% compress js file base %}
|
||||||
<script src="{% static "js/app.js" %}"></script>
|
<script src="{% static "js/app.js" %}"></script>
|
||||||
<script src="{% static "js/what-input.js" %}"></script>
|
<script src="{% static "js/what-input.js" %}"></script>
|
||||||
<script src="{% static "js/jquery.bxslider.js" %}?2"></script>
|
<script src="{% static "js/jquery.bxslider.js" %}?2"></script>
|
||||||
<script type="text/javascript">
|
<script src="{% static "js/slideshow.js" %}"></script>
|
||||||
var startSlide = 0;
|
{% endcompress %}
|
||||||
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
|
||||||
startSlide = parseInt(document.location.hash.slice(1)) - 1
|
|
||||||
}
|
|
||||||
function loadSlideshow() {
|
|
||||||
$('a.original-link').bind('touchstart MSPointerDown pointerdown', function(event) {
|
|
||||||
event.stopPropagation()
|
|
||||||
});
|
|
||||||
$('a.original-link').on({
|
|
||||||
mousedown: function(event) {
|
|
||||||
event.stopPropagation()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
slider = $('.slider1').show().bxSlider({
|
|
||||||
startSlide: startSlide,
|
|
||||||
preloadImages: 'all',
|
|
||||||
adaptiveHeight : true,
|
|
||||||
pager : false,
|
|
||||||
});
|
|
||||||
|
|
||||||
var images = $('.slider1 img'), count = images.length;
|
|
||||||
images.on({load: function(event) {
|
|
||||||
setTimeout(function() {
|
|
||||||
slider.resize()
|
|
||||||
slider.redrawSlider()
|
|
||||||
}, 100)
|
|
||||||
}})
|
|
||||||
|
|
||||||
document.querySelectorAll('.select-image').forEach(function(a) {
|
|
||||||
a.onclick = function(event) {
|
|
||||||
event.preventDefault();
|
|
||||||
slider.goToSlide(parseInt(this.dataset.id) - 1)
|
|
||||||
document.location.hash = '#' + this.dataset.id;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (document.querySelectorAll('.select-image').length && document.location.hash.length) {
|
|
||||||
var slide = parseInt(document.location.hash.slice(1))
|
|
||||||
if (slide) {
|
|
||||||
slider.goToSlide(slide - 1)
|
|
||||||
slider.resize()
|
|
||||||
slider.redrawSlider()
|
|
||||||
setTimeout(function() {
|
|
||||||
slider.resize()
|
|
||||||
slider.redrawSlider()
|
|
||||||
}, 2000)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$(document).keydown(function(e){
|
|
||||||
if (e.keyCode == 39) // Right arrow
|
|
||||||
{
|
|
||||||
slider && slider.goToNextSlide();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else if (e.keyCode == 37) // left arrow
|
|
||||||
{
|
|
||||||
slider && slider.goToPrevSlide();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
$(document).ready(loadSlideshow);
|
|
||||||
var restrictedElements = [];
|
|
||||||
function removeBehaviorsRestrictions(event) {
|
|
||||||
if (restrictedElements.length > 0) {
|
|
||||||
var rElements = restrictedElements;
|
|
||||||
restrictedElements = [];
|
|
||||||
rElements.forEach(function(video) {
|
|
||||||
if (video.autoplay && video.paused) {
|
|
||||||
video.load()
|
|
||||||
video.play()
|
|
||||||
if (video.paused) {
|
|
||||||
restrictedElements.push(video)
|
|
||||||
}
|
|
||||||
} else if (video.readyState < 4) {
|
|
||||||
video.load()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.querySelector('video')) {
|
|
||||||
let video = document.createElement('video');
|
|
||||||
video.muted = true
|
|
||||||
video.play();
|
|
||||||
if (video.paused) {
|
|
||||||
restrictedElements = document.querySelectorAll('video.gif')
|
|
||||||
window.addEventListener('keydown', removeBehaviorsRestrictions);
|
|
||||||
window.addEventListener('mousedown', removeBehaviorsRestrictions);
|
|
||||||
window.addEventListener('touchstart', removeBehaviorsRestrictions);
|
|
||||||
restrictedElements.forEach(video => {
|
|
||||||
if (!video.poster) {
|
|
||||||
video.poster = video.src.replace('.mp4', '.jpg')
|
|
||||||
video.muted = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% block end %}
|
{% block end %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue