meemoo/iframework — pull request #109 by piatra (2013-04-08 10:53:21+00:00)
Title: Prevent accidental navigation from page

Finding out when the user swiped for back/forward proved too difficult (I even started a bounty of stackoverflow http://stackoverflow.com/questions/15829172/stop-chrome-back-forward-two-finger-swipe)

My proposed fix:
I used the history API so that every time you move a component it switches to a "unsaved" state. Makes it really obvious that you have unfinished work.
Also when this happens I push in the history the same URL.
What happens is that if the user clicks back he remains on the page (!only if there is the "unsaved" hash in the URL). I also had to use localStorage to make sure I don't push the same url more than once making it impossible to go back.
If you save (both locally & on github) everything goes back to normal.

Let me know what you think. This pull req is just a proof of concept.

Sidenote: I didn't understand how you used Grunt to build your scripts since you don't have an explicit Gruntfile so I forced the debug mode in index.html