Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
271 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
source/js/common/template-js-handles/header-donate-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ReactGA } from "../../common"; | ||
|
||
/** | ||
* Bind click handler to #donate-header-btn | ||
* ("Donate" button on primary nav) | ||
*/ | ||
export default () => { | ||
let donateHeaderBtn = document.getElementById(`donate-header-btn`); | ||
if (donateHeaderBtn) { | ||
donateHeaderBtn.addEventListener(`click`, () => { | ||
ReactGA.event({ | ||
category: `donate`, | ||
action: `donate button tap`, | ||
label: `${document.title} header` | ||
}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import bindFooterDonateButtonHandler from "./footer-donate-button"; | ||
import bindHeaderDonateButtonHanlder from "./header-donate-button.js"; | ||
import bindFooterDonateButtonHandler from "./footer-donate-button.js"; | ||
|
||
/** | ||
* Bind event handlers | ||
*/ | ||
export const bindCommonEventHandlers = () => { | ||
bindHeaderDonateButtonHanlder(); | ||
bindFooterDonateButtonHandler(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export { bindEventHandlers } from "./template-js-handler"; | ||
export { | ||
bindWindowEventHandlers, | ||
bindEventHandlers | ||
} from "./template-js-handler"; | ||
export { injectReactComponents } from "./inject-react"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { bindEventHandlers } from "./template-js-handler"; | ||
|
||
bindMozFestEventHandlers(); |
22 changes: 22 additions & 0 deletions
22
source/js/foundation/pages/mozfest/template-js-handler/footer-social-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ReactGA } from "../../../../common"; | ||
|
||
/** | ||
* Bind handler to social buttons on MozFest footer | ||
*/ | ||
export default () => { | ||
let footerSocialButtons = document.querySelectorAll( | ||
`body.mozfest footer a[data-platform]` | ||
); | ||
|
||
if (footerSocialButtons) { | ||
footerSocialButtons.forEach(button => { | ||
button.addEventListener(`click`, () => { | ||
ReactGA.event({ | ||
category: `social`, | ||
action: `social button tap`, | ||
label: `${button.dataset.platform} footer button tap` | ||
}); | ||
}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
source/js/foundation/pages/mozfest/template-js-handler/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import homepageBannerHandler from "./home-banner.js"; | ||
import primaryButtonHandler from "./primary-button.js"; | ||
import footerSocialButtonHandler from "./footer-social-button.js"; | ||
|
||
/** | ||
* Bind event handlers to MozFest specific elements | ||
*/ | ||
export const bindEventHandlers = () => { | ||
footerSocialButtonHandler(); | ||
homepageBannerHandler(); | ||
primaryButtonHandler(); | ||
}; |
22 changes: 22 additions & 0 deletions
22
source/js/foundation/pages/mozfest/template-js-handler/primary-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ReactGA } from "../../../../common"; | ||
|
||
/** | ||
* Bind handler to primary buttons on MozFest | ||
*/ | ||
export default () => { | ||
let cmsPrimaryButtons = document.querySelectorAll( | ||
`body.mozfest .cms a.btn.btn-primary` | ||
); | ||
|
||
if (cmsPrimaryButtons) { | ||
cmsPrimaryButtons.forEach(button => { | ||
button.addEventListener(`click`, () => { | ||
ReactGA.event({ | ||
category: `CTA`, | ||
action: `button tap`, | ||
label: button.innerText | ||
}); | ||
}); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
source/js/foundation/template-js-handler/global/sticky-cta.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
source/js/foundation/template-js-handler/window/sticky-cta.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** | ||
* Bind handler to window for sticky CTA button to work on mobile | ||
*/ | ||
export default () => { | ||
let lastKnownScrollPosition = 0; | ||
let ticking = false; | ||
let elBurgerWrapper = document.querySelector(`.wrapper-burger`); | ||
|
||
let adjustNavbar = scrollPosition => { | ||
if (scrollPosition > 0) { | ||
elBurgerWrapper.classList.add(`scrolled`); | ||
} else { | ||
elBurgerWrapper.classList.remove(`scrolled`); | ||
} | ||
}; | ||
|
||
let elCtaAnchor = document.querySelector(`#cta-anchor`); | ||
let elStickyButton = document.querySelector( | ||
`.narrow-sticky-button-container` | ||
); | ||
let noopCtaButton = () => {}; | ||
let adjustCtaButton = noopCtaButton; | ||
|
||
if (elCtaAnchor && elStickyButton) { | ||
let getAnchorPosition = () => { | ||
return ( | ||
elCtaAnchor.getBoundingClientRect().top + | ||
window.scrollY - | ||
window.innerHeight | ||
); | ||
}; | ||
|
||
let ctaAnchorPosition = getAnchorPosition(); | ||
|
||
window.addEventListener(`resize`, () => { | ||
ctaAnchorPosition = getAnchorPosition(); | ||
}); | ||
|
||
let scrollCtaButton = scrollPosition => { | ||
if (scrollPosition > ctaAnchorPosition) { | ||
elStickyButton.classList.add(`hidden`); | ||
adjustCtaButton = noopCtaButton; | ||
} | ||
}; | ||
|
||
let initCtaButton = scrollPosition => { | ||
if (scrollPosition <= ctaAnchorPosition) { | ||
elStickyButton.classList.remove(`hidden`); | ||
adjustCtaButton = scrollCtaButton; | ||
} | ||
}; | ||
|
||
adjustCtaButton = initCtaButton; | ||
} | ||
|
||
let onScroll = () => { | ||
lastKnownScrollPosition = window.scrollY; | ||
|
||
if (!ticking) { | ||
window.requestAnimationFrame(() => { | ||
adjustNavbar(lastKnownScrollPosition); | ||
adjustCtaButton(lastKnownScrollPosition); | ||
ticking = false; | ||
}); | ||
} | ||
|
||
ticking = true; | ||
}; | ||
|
||
window.addEventListener(`scroll`, onScroll); | ||
|
||
// Call once to get scroll position on initial page load. | ||
onScroll(); | ||
}; |
31 changes: 31 additions & 0 deletions
31
source/js/foundation/template-js-handler/window/sticky-share-button-group.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Bind scroll handler to window to toggle sticky share buttons on blog page | ||
*/ | ||
export default () => { | ||
let blogPageStickyButtons = document.querySelector( | ||
`#view-blog .blog-sticky-side .share-button-group` | ||
); | ||
let blogPageFullButtons = document.querySelector( | ||
`#view-blog .blog-body .share-button-group` | ||
); | ||
|
||
if (blogPageStickyButtons && blogPageFullButtons) { | ||
const isInViewport = element => { | ||
let box = element.getBoundingClientRect(); | ||
|
||
return box.top <= window.innerHeight && box.top + box.height >= 0; | ||
}; | ||
|
||
const toggleStickyButtons = () => { | ||
if (isInViewport(blogPageFullButtons)) { | ||
blogPageStickyButtons.classList.add(`faded`); | ||
} else { | ||
blogPageStickyButtons.classList.remove(`faded`); | ||
} | ||
}; | ||
|
||
window.addEventListener(`scroll`, toggleStickyButtons); | ||
|
||
toggleStickyButtons(); | ||
} | ||
}; |
Oops, something went wrong.