editor: ask for confirmation when closing or refreshing a the page if the editor has been enabled at least once (issue #165)

This commit is contained in:
jean-emmanuel 2018-02-25 10:02:10 +01:00
parent d9ed3d4853
commit fc88b086c3
3 changed files with 28 additions and 2 deletions

View file

@ -13,12 +13,19 @@ var Editor = class Editor {
this.defaults[k] = widgets[k].defaults()
}
this.enabledOnce = false
window.onbeforeunload = ()=>{
if (this.enabledOnce) return true
}
}
enable() {
EDITING = true
this.enabledOnce = true
DOM.get('.editor-root')[0].setAttribute('data-widget', DOM.get('.root-container')[0].getAttribute('data-widget'))
DOM.get('.editor-root')[0].classList.remove('disabled')
DOM.get('.disable-editor')[0].classList.remove('on')