Manual JS conversion in content template
This commit is contained in:
parent
de37721c40
commit
7ccb804231
1 changed files with 32 additions and 29 deletions
|
@ -39,49 +39,52 @@
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
!(function () {
|
!(function () {
|
||||||
var ui = new L.U.UI(document.querySelector('header'));
|
const ui = new L.U.UI(document.querySelector('header'))
|
||||||
var xhr = new L.U.Xhr(ui);
|
const xhr = new L.U.Xhr(ui)
|
||||||
var login = document.querySelector('a.login');
|
const login = document.querySelector('a.login')
|
||||||
if (login) {
|
if (login) {
|
||||||
L.DomEvent.on(login, 'click', function (e) {
|
L.DomEvent.on(login, 'click', function (e) {
|
||||||
L.DomEvent.stop(e);
|
L.DomEvent.stop(e)
|
||||||
xhr.login({
|
xhr.login({
|
||||||
"login_required": this.getAttribute('href'),
|
login_required: this.getAttribute('href'),
|
||||||
"redirect": "/"
|
redirect: '/',
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
var 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);
|
L.DomEvent.stop(e)
|
||||||
xhr.logout(this.getAttribute('href'));
|
xhr.logout(this.getAttribute('href'))
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
var getMore = function (e) {
|
const getMore = function (e) {
|
||||||
L.DomEvent.stop(e);
|
L.DomEvent.stop(e)
|
||||||
xhr._ajax({
|
xhr._ajax({
|
||||||
uri: this.href,
|
uri: this.href,
|
||||||
verb: 'GET',
|
verb: 'GET',
|
||||||
callback: function (data) {
|
callback: function (data) {
|
||||||
var container = this.parentNode;
|
const container = this.parentNode
|
||||||
container.innerHTML = data;
|
container.innerHTML = data
|
||||||
Array.prototype.forEach.call(container.querySelectorAll('script'), function (item) {
|
Array.prototype.forEach.call(
|
||||||
eval(item.firstChild.textContent);
|
container.querySelectorAll('script'),
|
||||||
});
|
function (item) {
|
||||||
var more = document.querySelector('.more_button');
|
eval(item.firstChild.textContent)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
const more = document.querySelector('.more_button')
|
||||||
if (more) {
|
if (more) {
|
||||||
L.DomEvent.on(more, 'click', getMore, more);
|
L.DomEvent.on(more, 'click', getMore, more)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
context: this
|
context: this,
|
||||||
});
|
})
|
||||||
};
|
|
||||||
var more = document.querySelector('.more_button');
|
|
||||||
if (more) {
|
|
||||||
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