Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
prompt for unload for backspace key
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiefu committed Apr 2, 2014
1 parent 0d118ef commit 56e153f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,27 @@
selected: 'design',
remoteHtml: '',
ready: function() {
document.addEventListener('keydown',
this.KeydownAndPromptForUnload.bind(this, window));
},
designWindowLoaded: function() {
this.$.frame.style.display = null;
window.designWindow = this.$.frame.contentWindow;
designWindow.addEventListener('designer-ready', this.designerReady.bind(this));
designWindow.addEventListener('design-change', this.designChange.bind(this));
designWindow.document.addEventListener('keydown',
this.KeydownAndPromptForUnload.bind(this, designWindow));
},
KeydownAndPromptForUnload: function(w, e) {
// backspace
if (e.keyCode == 8) {
w.onbeforeunload = function() {
return ' ';
}
setTimeout(function() {
w.onbeforeunload = null;
}, 0);
}
},
loadAction: function() {
this.$.loadFile.fileName = "test.html";
Expand Down

0 comments on commit 56e153f

Please sign in to comment.