mirror of
https://github.com/umap-project/umap.git
synced 2025-05-06 06:21:49 +02:00
Also run login javascript when page is loaded
This commit is contained in:
parent
2d111438c2
commit
d65b9f25c1
1 changed files with 46 additions and 44 deletions
|
@ -38,53 +38,55 @@
|
||||||
{% block bottom_js %}
|
{% block bottom_js %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
!(function () {
|
window.addEventListener('load', (event) => {
|
||||||
const ui = new L.U.UI(document.querySelector('header'))
|
!(function () {
|
||||||
const xhr = new L.U.Xhr(ui)
|
const ui = new L.U.UI(document.querySelector('header'))
|
||||||
const login = document.querySelector('a.login')
|
const xhr = new L.U.Xhr(ui)
|
||||||
if (login) {
|
const login = document.querySelector('a.login')
|
||||||
L.DomEvent.on(login, 'click', function (e) {
|
if (login) {
|
||||||
L.DomEvent.stop(e)
|
L.DomEvent.on(login, 'click', function (e) {
|
||||||
xhr.login({
|
L.DomEvent.stop(e)
|
||||||
login_required: this.getAttribute('href'),
|
xhr.login({
|
||||||
redirect: '/',
|
login_required: this.getAttribute('href'),
|
||||||
|
redirect: '/',
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
}
|
const logout = document.querySelector('a.logout')
|
||||||
const logout = document.querySelector('a.logout')
|
if (logout) {
|
||||||
if (logout) {
|
L.DomEvent.on(logout, 'click', function (e) {
|
||||||
L.DomEvent.on(logout, 'click', function (e) {
|
L.DomEvent.stop(e)
|
||||||
|
xhr.logout(this.getAttribute('href'))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const getMore = function (e) {
|
||||||
L.DomEvent.stop(e)
|
L.DomEvent.stop(e)
|
||||||
xhr.logout(this.getAttribute('href'))
|
xhr._ajax({
|
||||||
})
|
uri: this.href,
|
||||||
}
|
verb: 'GET',
|
||||||
const getMore = function (e) {
|
callback: function (data) {
|
||||||
L.DomEvent.stop(e)
|
const container = this.parentNode
|
||||||
xhr._ajax({
|
container.innerHTML = data
|
||||||
uri: this.href,
|
Array.prototype.forEach.call(
|
||||||
verb: 'GET',
|
container.querySelectorAll('script'),
|
||||||
callback: function (data) {
|
function (item) {
|
||||||
const container = this.parentNode
|
eval(item.firstChild.textContent)
|
||||||
container.innerHTML = data
|
}
|
||||||
Array.prototype.forEach.call(
|
)
|
||||||
container.querySelectorAll('script'),
|
const more = document.querySelector('.more_button')
|
||||||
function (item) {
|
if (more) {
|
||||||
eval(item.firstChild.textContent)
|
L.DomEvent.on(more, 'click', getMore, more)
|
||||||
}
|
}
|
||||||
)
|
},
|
||||||
const more = document.querySelector('.more_button')
|
context: this,
|
||||||
if (more) {
|
})
|
||||||
L.DomEvent.on(more, 'click', getMore, more)
|
}
|
||||||
}
|
const more = document.querySelector('.more_button')
|
||||||
},
|
if (more) {
|
||||||
context: this,
|
L.DomEvent.on(more, 'click', getMore, more)
|
||||||
})
|
}
|
||||||
}
|
})(this)
|
||||||
const more = document.querySelector('.more_button')
|
})
|
||||||
if (more) {
|
|
||||||
L.DomEvent.on(more, 'click', getMore, more)
|
|
||||||
}
|
|
||||||
})(this)
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock bottom_js %}
|
{% endblock bottom_js %}
|
||||||
{% block footer %}
|
{% block footer %}
|
||||||
|
|
Loading…
Reference in a new issue