diff --git a/layout/sidebar/sidebar.pixy b/layout/sidebar/sidebar.pixy index 949cae9c..7d3590fc 100644 --- a/layout/sidebar/sidebar.pixy +++ b/layout/sidebar/sidebar.pixy @@ -84,7 +84,7 @@ component SidebarButton(name string, target string, icon string) span.sidebar-text= name component SidebarButtonNoAJAX(name string, target string, icon string) - a.sidebar-link(href=target, aria-label=name, data-bubble="true") + a.sidebar-link(href=target, aria-label=name, data-bubble="true", data-ajax="false") .sidebar-button Icon(icon) span.sidebar-text= name \ No newline at end of file diff --git a/pages/login/login.pixy b/pages/login/login.pixy index 3e10b49e..9dd819be 100644 --- a/pages/login/login.pixy +++ b/pages/login/login.pixy @@ -1,9 +1,9 @@ component Login(target string) .login-buttons.mountable - a.login-button.login-button-google(href="/auth/google", target=target) + a.login-button.login-button-google(href="/auth/google", target=target, data-ajax="false") Icon("google") span Sign in via Google - a.login-button.login-button-facebook(href="/auth/facebook", target=target) + a.login-button.login-button-facebook(href="/auth/facebook", target=target, data-ajax="false") Icon("facebook") span Sign in via Facebook \ No newline at end of file diff --git a/pages/settings/settings.pixy b/pages/settings/settings.pixy index 8d3de3ad..5b488fec 100644 --- a/pages/settings/settings.pixy +++ b/pages/settings/settings.pixy @@ -246,7 +246,7 @@ component SettingsAccounts(user *arn.User) .widget-section.social-account label(for="google") Google: - a#google.button.social-account-button(href="/auth/google") + a#google.button.social-account-button(href="/auth/google", data-ajax="false") if user.Accounts.Google.ID != "" Icon("check") span Connected @@ -257,7 +257,7 @@ component SettingsAccounts(user *arn.User) .widget-section.social-account label(for="facebook") Facebook: - a#facebook.button.social-account-button(href="/auth/facebook") + a#facebook.button.social-account-button(href="/auth/facebook", data-ajax="false") if user.Accounts.Facebook.ID != "" Icon("check") span Connected diff --git a/scripts/Application.ts b/scripts/Application.ts index bd677c52..3223113d 100644 --- a/scripts/Application.ts +++ b/scripts/Application.ts @@ -6,7 +6,6 @@ class LoadOptions { } export class Application { - ajaxClass: string fadeOutClass: string activeLinkClass: string content: HTMLElement @@ -18,7 +17,6 @@ export class Application { constructor() { this.currentPath = window.location.pathname this.originalPath = window.location.pathname - this.ajaxClass = "ajax" this.activeLinkClass = "active" this.fadeOutClass = "fade-out" } @@ -150,10 +148,25 @@ export class Application { element = document.body } - let links = element.querySelectorAll("." + this.ajaxClass) + let links = element.getElementsByTagName("a") for(let i = 0; i < links.length; i++) { - let link = links[i] as HTMLElement + let link = links[i] as HTMLAnchorElement + + // Don't ajaxify links to a different host + if(link.hostname !== window.location.hostname) { + if(!link.target) { + link.target = "_blank" + } + + continue + } + + // Don't ajaxify links with a target or links that disable ajax specifically + if(link.target.length > 0 || link.dataset.ajax === "false") { + continue + } + let self = this link.onclick = function(e) { @@ -179,9 +192,11 @@ export class Application { scrollToTop() { let parent : HTMLElement | null = this.content - while(parent = parent.parentElement) { - parent.scrollTop = 0 - } + Diff.mutations.queue(() => { + while(parent = parent.parentElement) { + parent.scrollTop = 0 + } + }) } emit(eventName: string) {