liqd/adhocracy — pull request #579 by xi (2013-10-07 19:31:29+00:00)
Title: form overlays

When an overlays only contains a single form this allows us to

- close the overlay on cancel
- reload the whole page (without overlay) on submit

To use it, use `rel="#overlay-form"` instead of `rel="#overlay-url"` on the trigger.

The heavy work is done by `adhocracy.ajax_submit` which submits a form via ajax (hence the name). When the submit was successful a callback is executed. When there were errors it replaces the form by the one which was returned in the ajax request and which contains the error messages. To extract the form from the return data I assumed that the returned document has a similar structure to the current document and that selectors are applicable (creating an unique selector was actually harder that I had first thought).

As submitting via ajax takes a while I added an animation to the submit button for instead feedback. I edited a gif I found on the net. Hope we do not violate anyone's copyright.

Finally I had to make this work with overlay links introduced in #553. My first idea was to add an additional class to overlay triggers with the described behavior. But there was no way to include that information in overlay urls. So instead I **changed the overlay link API**. An overlay link now contains the query parameter `overlay_type` instead of `overlay_target`. It should be easy to add additional overlay types in the future.

This was successfully tested in chromium, firefox and IE9.