mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
ajaxify.go(relative_url); - use this to navigate to a page manually
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"socket" : {
|
|
||||||
"address" : "localhost",
|
|
||||||
"port" : "4567"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
var ajaxify = {};
|
||||||
|
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host) + (document.location.port ? ':'+document.location.port : ''),
|
var rootUrl = document.location.protocol + '//' + (document.location.hostname || document.location.host) + (document.location.port ? ':'+document.location.port : ''),
|
||||||
@@ -5,15 +8,7 @@
|
|||||||
|
|
||||||
var current_state = '';
|
var current_state = '';
|
||||||
|
|
||||||
|
ajaxify.go = function(url) {
|
||||||
$('document').ready(function() {
|
|
||||||
if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers
|
|
||||||
|
|
||||||
|
|
||||||
content = content || document.getElementById('content');
|
|
||||||
|
|
||||||
$('a').unbind('click').bind('click', function(ev) {
|
|
||||||
var url = this.href.replace(rootUrl +'/', '');
|
|
||||||
var tpl_url = (url === '') ? 'home' : url;
|
var tpl_url = (url === '') ? 'home' : url;
|
||||||
|
|
||||||
if (templates[tpl_url]) {
|
if (templates[tpl_url]) {
|
||||||
@@ -27,6 +22,22 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('document').ready(function() {
|
||||||
|
if (!window.history || !window.history.pushState) return; // no ajaxification for old browsers
|
||||||
|
|
||||||
|
|
||||||
|
content = content || document.getElementById('content');
|
||||||
|
|
||||||
|
$('a').unbind('click').bind('click', function(ev) {
|
||||||
|
var url = this.href.replace(rootUrl +'/', '');
|
||||||
|
|
||||||
|
if (ajaxify.go(url)) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user