Node.js based forum software built for the modern web
feat: add partials/footer/js.tpl
Barış Soner Uşaklı94da9fe55e25
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex 0f8668858a..db5c034ccf 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -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 browsersajaxifyAnchors();}-- app.load();});diff --git a/public/src/app.js b/public/src/app.jsindex 82439c270f..c40bc607ef 100644--- a/public/src/app.js+++ b/public/src/app.js@@ -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) {diff --git a/src/views/admin/footer.tpl b/src/views/admin/footer.tplindex 1f6d36eb70..1593e636c3 100644--- a/src/views/admin/footer.tpl+++ b/src/views/admin/footer.tpl@@ -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>diff --git a/src/views/partials/footer/js.tpl b/src/views/partials/footer/js.tplnew file mode 100644index 0000000000..1f5cbc50a8--- /dev/null+++ b/src/views/partials/footer/js.tpl@@ -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>\ No newline at end of file