mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: add partials/footer/js.tpl
add ajaxify.coldLoad which gets called from partials/footer/js.tpl
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
|
||||
ajaxify = window.ajaxify || {};
|
||||
|
||||
$(document).ready(function () {
|
||||
var location = document.location || window.location;
|
||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||
(function () {
|
||||
var apiXHR = null;
|
||||
var ajaxifyTimer;
|
||||
|
||||
@@ -22,22 +20,6 @@ $(document).ready(function () {
|
||||
Benchpress = _Benchpress;
|
||||
});
|
||||
|
||||
$(window).on('popstate', function (ev) {
|
||||
ev = ev.originalEvent;
|
||||
|
||||
if (ev !== null && ev.state) {
|
||||
if (ev.state.url === null && ev.state.returnPath !== undefined) {
|
||||
window.history.replaceState({
|
||||
url: ev.state.returnPath,
|
||||
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
||||
} else if (ev.state.url !== undefined) {
|
||||
ajaxify.go(ev.state.url, function () {
|
||||
$(window).trigger('action:popstate', { url: ev.state.url });
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ajaxify.count = 0;
|
||||
ajaxify.currentPage = null;
|
||||
|
||||
@@ -102,6 +84,14 @@ $(document).ready(function () {
|
||||
return true;
|
||||
};
|
||||
|
||||
// this function is called just once from footer on page load
|
||||
ajaxify.coldLoad = function () {
|
||||
var url = ajaxify.start(window.location.pathname.slice(1) + window.location.search + window.location.hash);
|
||||
ajaxify.updateHistory(url, true);
|
||||
ajaxify.end(url, app.template);
|
||||
$(window).trigger('action:ajaxify.coldLoad');
|
||||
};
|
||||
|
||||
ajaxify.isCold = function () {
|
||||
return ajaxify.count <= 1;
|
||||
};
|
||||
@@ -334,11 +324,35 @@ $(document).ready(function () {
|
||||
});
|
||||
};
|
||||
|
||||
require(['translator', 'benchpress'], function (translator, Benchpress) {
|
||||
translator.translate('[[error:no-connection]]');
|
||||
Benchpress.registerLoader(ajaxify.loadTemplate);
|
||||
});
|
||||
}());
|
||||
|
||||
$(document).ready(function () {
|
||||
$(window).on('popstate', function (ev) {
|
||||
ev = ev.originalEvent;
|
||||
|
||||
if (ev !== null && ev.state) {
|
||||
if (ev.state.url === null && ev.state.returnPath !== undefined) {
|
||||
window.history.replaceState({
|
||||
url: ev.state.returnPath,
|
||||
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
||||
} else if (ev.state.url !== undefined) {
|
||||
ajaxify.go(ev.state.url, function () {
|
||||
$(window).trigger('action:popstate', { url: ev.state.url });
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function ajaxifyAnchors() {
|
||||
function hrefEmpty(href) {
|
||||
return href === undefined || href === '' || href === 'javascript:;';
|
||||
}
|
||||
|
||||
var location = document.location || window.location;
|
||||
var rootUrl = location.protocol + '//' + (location.hostname || location.host) + (location.port ? ':' + location.port : '');
|
||||
var contentEl = document.getElementById('content');
|
||||
|
||||
// Enhancing all anchors to ajaxify...
|
||||
@@ -412,13 +426,11 @@ $(document).ready(function () {
|
||||
return;
|
||||
}
|
||||
|
||||
translator.translate('[[global:unsaved-changes]]', function (text) {
|
||||
bootbox.confirm(text, function (navigate) {
|
||||
if (navigate) {
|
||||
app.flags._unsaved = false;
|
||||
process.call(_self);
|
||||
}
|
||||
});
|
||||
bootbox.confirm('[[global:unsaved-changes]]', function (navigate) {
|
||||
if (navigate) {
|
||||
app.flags._unsaved = false;
|
||||
process.call(_self);
|
||||
}
|
||||
});
|
||||
return e.preventDefault();
|
||||
}
|
||||
@@ -427,14 +439,8 @@ $(document).ready(function () {
|
||||
});
|
||||
}
|
||||
|
||||
require(['benchpress'], function (Benchpress) {
|
||||
Benchpress.registerLoader(ajaxify.loadTemplate);
|
||||
});
|
||||
|
||||
if (window.history && window.history.pushState) {
|
||||
// Progressive Enhancement, ajaxify available only to modern browsers
|
||||
ajaxifyAnchors();
|
||||
}
|
||||
|
||||
app.load();
|
||||
});
|
||||
|
||||
@@ -37,14 +37,14 @@ app.cacheBuster = null;
|
||||
locale: config.userLang,
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
ajaxify.parseData();
|
||||
app.load();
|
||||
});
|
||||
|
||||
app.load = function () {
|
||||
overrides.overrideTimeago();
|
||||
|
||||
var url = ajaxify.start(window.location.pathname.slice(1) + window.location.search + window.location.hash);
|
||||
ajaxify.updateHistory(url, true);
|
||||
ajaxify.parseData();
|
||||
ajaxify.end(url, app.template);
|
||||
|
||||
handleStatusChange();
|
||||
|
||||
if (config.searchEnabled) {
|
||||
|
||||
@@ -8,5 +8,12 @@
|
||||
<div id="footer" class="container" style="padding-top: 50px; display:none;">
|
||||
<footer class="footer">Copyright © 2015 <a target="_blank" href="https://nodebb.org">NodeBB</a> by <a target="_blank" href="https://github.com/psychobunny">psychobunny</a>, <a href="https://github.com/julianlam" target="_blank">julianlam</a>, <a href="https://github.com/barisusakli" target="_blank">barisusakli</a> from <a target="_blank" href="http://www.designcreateplay.com">designcreateplay</a></footer>
|
||||
</div>
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', function () {
|
||||
$(document).ready(function () {
|
||||
ajaxify.coldLoad();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
19
src/views/partials/footer/js.tpl
Normal file
19
src/views/partials/footer/js.tpl
Normal file
@@ -0,0 +1,19 @@
|
||||
<script defer src="{relative_path}/assets/nodebb.min.js?{config.cache-buster}"></script>
|
||||
|
||||
{{{each scripts}}}
|
||||
<script defer type="text/javascript" src="{scripts.src}"></script>
|
||||
{{{end}}}
|
||||
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', function () {
|
||||
require(['forum/footer']);
|
||||
|
||||
<!-- IF useCustomJS -->
|
||||
{{customJS}}
|
||||
<!-- ENDIF useCustomJS -->
|
||||
|
||||
$(document).ready(function () {
|
||||
ajaxify.coldLoad();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user