|
@@ -115,23 +115,36 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
if(window === window.top) {
|
|
if(window === window.top) {
|
|
- window.location.href = '/mc?page=' + window.location.pathname;
|
|
|
|
|
|
+ window.location.href = '/mc' + window.location.pathname;
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
// Prevent variables from being global
|
|
// Prevent variables from being global
|
|
$(document).ready(function () {
|
|
$(document).ready(function () {
|
|
- $(document).on('click', 'a:not([href="#"])', function() {
|
|
|
|
- $.get(this.href, function(_data) {
|
|
|
|
|
|
+ function gotoTarget(target, pushState) {
|
|
|
|
+ $.get('/' + target, function(_data) {
|
|
var received = $(_data);
|
|
var received = $(_data);
|
|
// $('#main-sidenav').replaceWith($(_data).find('#main-sidenav'));
|
|
// $('#main-sidenav').replaceWith($(_data).find('#main-sidenav'));
|
|
var activeHref = $(_data).find('#main-sidenav').find('.nav-link.active').attr('href');
|
|
var activeHref = $(_data).find('#main-sidenav').find('.nav-link.active').attr('href');
|
|
$('#main-sidenav a.nav-link.active').removeClass('active');
|
|
$('#main-sidenav a.nav-link.active').removeClass('active');
|
|
- $('#main-sidenav a[href="' + activeHref + '"]').addClass('active');
|
|
|
|
|
|
+ $('#main-sidenav a[href="' + activeHref + '"]').addClass('active').focus();
|
|
$('#main-content').replaceWith($(_data).find('#main-content'));
|
|
$('#main-content').replaceWith($(_data).find('#main-content'));
|
|
$(window).scrollTop(0);
|
|
$(window).scrollTop(0);
|
|
|
|
+ if(pushState) {
|
|
|
|
+ window.top.history.pushState(target, null, '/mc/' + target);
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
+ }
|
|
|
|
+ $(document).on('click', 'a:not([href="#"])', function() {
|
|
|
|
+ var target = this.href;
|
|
|
|
+ if(target.indexOf('//') !== -1) {
|
|
|
|
+ target = target.split('//')[1];
|
|
|
|
+ if(target.indexOf('/') !== -1) {
|
|
|
|
+ target = target.substr(target.indexOf('/') + 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ gotoTarget(target, true);
|
|
return false;
|
|
return false;
|
|
});
|
|
});
|
|
$(document).on('submit', 'form[action="/post-to-api"]', function() {
|
|
$(document).on('submit', 'form[action="/post-to-api"]', function() {
|
|
@@ -141,6 +154,11 @@
|
|
});
|
|
});
|
|
return false;
|
|
return false;
|
|
});
|
|
});
|
|
|
|
+ window.top.addEventListener('popstate', function(event) {
|
|
|
|
+ if(!!event.state) {
|
|
|
|
+ gotoTarget(event.state, false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
|
|
|