Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pixie3 #72

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
29 changes: 29 additions & 0 deletions dirty.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = (I, self) ->
# TODO: May want to not stash this on I, possibly have a volatileAccessor?
self.attrAccessor "savedCommand"

self.extend
dirty: ->
self.savedCommand() != self.lastCommand()
lastCommand: ->
self.history().last()
markClean: ->
self.savedCommand self.lastCommand()

self.markClean()

# HACK: This assumes we're the only app in the page
# NOTE: Track `prompted` so in an iframe it's less likely to trigger twice
prompted = false
window.addEventListener "beforeunload", (e) ->
unless prompted
if self.dirty()
e.returnValue = "Your changes haven't yet been saved. If you leave now you will lose your work."
prompted = true

setTimeout ->
prompted = false

return e.returnValue

return self
34 changes: 0 additions & 34 deletions dirty.coffee.md

This file was deleted.

2 changes: 1 addition & 1 deletion download.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ Pixi Paint is [open source software](https://github.com/STRd6/pixel-editor).
> $(".content").eq(0).empty()
> .append($ "<h2>", text: "Live Demo")
> $(".content").eq(1).empty()
> .append($ "<iframe>", src: "http://danielx.net/pixel-editor", style: "border: none; border-top: 1px solid gray", width: 640, height: 640)
> .append($ "<iframe>", src: "https://danielx.net/pixel-editor/", style: "border: none; border-top: 1px solid gray", width: 768, height: 640)
Loading