docs: Adds Dialogs Fiddle example (#20473)

This commit is contained in:
Yaser 2019-11-01 05:04:24 +11:00 committed by Shelley Vohr
parent 2bbf32a18b
commit b060cbf4ec
12 changed files with 773 additions and 0 deletions

View file

@ -0,0 +1,18 @@
const { ipcRenderer, shell } = require('electron')
const links = document.querySelectorAll('a[href]')
const errorBtn = document.getElementById('error-dialog')
errorBtn.addEventListener('click', event => {
ipcRenderer.send('open-error-dialog')
})
Array.prototype.forEach.call(links, (link) => {
const url = link.getAttribute('href')
if (url.indexOf('http') === 0) {
link.addEventListener('click', (e) => {
e.preventDefault()
shell.openExternal(url)
})
}
})