editor: only warn about quitting if the session has been modified, disable warning if session has been saved

This commit is contained in:
jean-emmanuel 2019-01-04 12:16:29 +01:00
parent e69982dee9
commit ad6eeee08b
2 changed files with 7 additions and 4 deletions

View file

@ -51,9 +51,10 @@ var Editor = class Editor {
this.idClipboard = null
this.enabled = false
this.enabledOnce = false
this.unsavedSession = false
window.onbeforeunload = ()=>{
if (this.enabledOnce) return true
if (this.unsavedSession) return true
}
@ -250,8 +251,6 @@ var Editor = class Editor {
EDITING = true
this.enabled = 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')
@ -747,6 +746,8 @@ var Editor = class Editor {
pushHistory(indexes) {
this.unsavedSession = true
if (this.historyState > -1) {
this.history.splice(0, this.historyState + 1)
this.historyState = -1

View file

@ -87,6 +87,7 @@ var SessionManager = class SessionManager {
container.classList.add('show')
this.lock = false
this.allowRemoteSave = false
editor.unsavedSession = false
if (callback) callback()
}, 25)
@ -103,6 +104,7 @@ var SessionManager = class SessionManager {
icon: 'save',
message: locales('session_savesuccess')
})
editor.unsavedSession = false
} else {