Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(examples): refactor js example execution so it works on docsite #…
- Loading branch information
1 parent
8c0c38f
commit ffe429f
Showing
11 changed files
with
17,454 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { auroMenuResetExample } from './partials/reset'; | ||
import { auroMenuMatchWordExample } from './partials/matchWord'; | ||
import { auroMenuCustomEventExample } from './partials/customEvent'; | ||
|
||
export function initMenuIndexExamples(initCount) { | ||
initCount = initCount || 0; | ||
|
||
try { | ||
auroMenuResetExample(); | ||
auroMenuMatchWordExample(); | ||
auroMenuCustomEventExample(); | ||
} catch { | ||
if (initCount <= 20) { | ||
// setTimeout handles issue where content is sometimes loaded after the functions get called | ||
setTimeout(() => { | ||
initMenuIndexExamples(initCount + 1); | ||
}, 100); | ||
} | ||
} | ||
} |
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,51 @@ | ||
function auroMenuResetExample() { | ||
const resetExampleBtnElem = document.querySelector('#resetExampleBtn'); | ||
const resetExampleElem = document.querySelector('#resetExample'); | ||
|
||
if (resetExampleElem && resetExampleBtnElem) { | ||
resetExampleBtnElem.addEventListener('click', () => { | ||
resetExampleElem.value = undefined; | ||
}); | ||
} | ||
} | ||
|
||
function updateMatch() { | ||
let matchWordMenu = document.querySelector('#matchWordMenu'); | ||
|
||
matchWordMenu.matchWord = matchWordInput.value; | ||
} | ||
|
||
function auroMenuMatchWordExample() { | ||
let matchWordInput = document.querySelector('#matchWordInput'); | ||
|
||
matchWordInput.addEventListener('keyup', updateMatch); | ||
} | ||
|
||
function auroMenuCustomEventExample() { | ||
let menuCustomEventEl = document.querySelector('auro-menu#customEvent'); | ||
|
||
if (menuCustomEventEl) { | ||
menuCustomEventEl.addEventListener('mycustomevent', () => { | ||
console.warn('My Custom Event Fired'); | ||
alert(`My Custom Event Fired`); | ||
}); | ||
} | ||
} | ||
|
||
function initMenuIndexExamples(initCount) { | ||
initCount = initCount || 0; | ||
|
||
try { | ||
auroMenuResetExample(); | ||
auroMenuMatchWordExample(); | ||
auroMenuCustomEventExample(); | ||
} catch { | ||
if (initCount <= 20) { | ||
// setTimeout handles issue where content is sometimes loaded after the functions get called | ||
setTimeout(() => { | ||
initMenuIndexExamples(initCount + 1); | ||
}, 100); | ||
} | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
let matchWordInput; | ||
let matchWordMenu; | ||
|
||
function matchWords() { | ||
matchWordInput = document.querySelector('#matchWordInput'); | ||
matchWordMenu = document.querySelector('#matchWordMenu'); | ||
function updateMatch() { | ||
let matchWordMenu = document.querySelector('#matchWordMenu'); | ||
|
||
matchWordInput.addEventListener('keyup', updateMatch); | ||
matchWordMenu.matchWord = matchWordInput.value; | ||
} | ||
|
||
function updateMatch() { | ||
matchWordMenu.matchWord = matchWordInput.value; | ||
export function auroMenuMatchWordExample() { | ||
let matchWordInput = document.querySelector('#matchWordInput'); | ||
|
||
matchWordInput.addEventListener('keyup', updateMatch); | ||
} |
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
Oops, something went wrong.