Fixed some missing dynload attributes and also support fragments.
This commit is contained in:
parent
493ad2cb9b
commit
f2871aeffb
2 changed files with 18 additions and 4 deletions
|
@ -211,7 +211,7 @@ if($reqPath === '/') {
|
||||||
</div>
|
</div>
|
||||||
<div class="index-feature">
|
<div class="index-feature">
|
||||||
<div class="index-feature-header">
|
<div class="index-feature-header">
|
||||||
<a href="/projects" class="index-feature-header-link"></a>
|
<a href="/projects" class="index-feature-header-link" data-fm-dynload=""></a>
|
||||||
<div class="index-feature-header-title">Projects</div>
|
<div class="index-feature-header-title">Projects</div>
|
||||||
<div class="index-feature-header-more">More</div>
|
<div class="index-feature-header-more">More</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -230,7 +230,7 @@ foreach($projInfo as $proj):
|
||||||
$links[] = ['class' => 'forum', 'text' => 'Discussion', 'url' => $proj->forum];
|
$links[] = ['class' => 'forum', 'text' => 'Discussion', 'url' => $proj->forum];
|
||||||
?>
|
?>
|
||||||
<div class="index-project" style="background-color: #<?=str_pad(dechex($proj->colour), 6, '0', STR_PAD_LEFT);?>;">
|
<div class="index-project" style="background-color: #<?=str_pad(dechex($proj->colour), 6, '0', STR_PAD_LEFT);?>;">
|
||||||
<a href="/projects#<?=$proj->name_clean;?>" class="index-project-anchor"></a>
|
<a href="/projects#<?=$proj->name_clean;?>" class="index-project-anchor" data-fm-dynload=""></a>
|
||||||
<div class="index-project-content">
|
<div class="index-project-content">
|
||||||
<div class="index-project-name"><?=$proj->name;?></div>
|
<div class="index-project-name"><?=$proj->name;?></div>
|
||||||
<div class="index-project-summary"><?=$proj->summary;?></div>
|
<div class="index-project-summary"><?=$proj->summary;?></div>
|
||||||
|
@ -249,7 +249,7 @@ foreach($projInfo as $proj):
|
||||||
</div>
|
</div>
|
||||||
<div class="index-feature">
|
<div class="index-feature">
|
||||||
<div class="index-feature-header">
|
<div class="index-feature-header">
|
||||||
<a href="/contact" class="index-feature-header-link"></a>
|
<a href="/contact" class="index-feature-header-link" data-fm-dynload=""></a>
|
||||||
<div class="index-feature-header-title">Contact</div>
|
<div class="index-feature-header-title">Contact</div>
|
||||||
<div class="index-feature-header-more">More</div>
|
<div class="index-feature-header-more">More</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -108,6 +108,9 @@ window.fm = (function() {
|
||||||
var dynload = document.querySelectorAll('[data-fm-dynload]');
|
var dynload = document.querySelectorAll('[data-fm-dynload]');
|
||||||
for(var i = 0; i < dynload.length; ++i)
|
for(var i = 0; i < dynload.length; ++i)
|
||||||
(function(dc){
|
(function(dc){
|
||||||
|
var url = new URL(dc.href),
|
||||||
|
hash = url.hash.substring(1);
|
||||||
|
url.hash = '';
|
||||||
dc.removeAttribute('data-fm-dynload');
|
dc.removeAttribute('data-fm-dynload');
|
||||||
dc.addEventListener('click', function(ev) {
|
dc.addEventListener('click', function(ev) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -125,11 +128,22 @@ window.fm = (function() {
|
||||||
var title = ((obj.components || {}).header || {}).title || '';
|
var title = ((obj.components || {}).header || {}).title || '';
|
||||||
history.pushState(obj, title, dc.href);
|
history.pushState(obj, title, dc.href);
|
||||||
fm.dynloadApply(obj);
|
fm.dynloadApply(obj);
|
||||||
|
if(hash) {
|
||||||
|
var targetEl = document.getElementById(hash);
|
||||||
|
if(targetEl) {
|
||||||
|
setTimeout(function() {
|
||||||
|
window.scrollTo({
|
||||||
|
top: targetEl.getBoundingClientRect().top,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
xhr.onerror = function(ev) {
|
xhr.onerror = function(ev) {
|
||||||
location.assign(dc.href);
|
location.assign(dc.href);
|
||||||
};
|
};
|
||||||
xhr.open('GET', dc.href);
|
xhr.open('GET', url);
|
||||||
xhr.setRequestHeader('Accept', 'application/x-fdynload+json');
|
xhr.setRequestHeader('Accept', 'application/x-fdynload+json');
|
||||||
xhr.send();
|
xhr.send();
|
||||||
}, true);
|
}, true);
|
||||||
|
|
Loading…
Reference in a new issue