jejacks0n/mercury — pull request #112 by nreckart (2011-12-12 21:17:58+00:00)
Title: Add support for toolbar buttons that exit/navigate away from the editor

I need the ability to add a menu toolbar to the editor that essentially provides links to quickly navigate to other areas of the application, thus exiting the editor.

My first attempt was to just use the existing button behaviors feature. The custom button handler would just set the browser location; however, this always resulted in a "Are you sure you want to leave. There are unsaved changes" alert being displayed even when no changes were actually made to page content. This occurs because Mercury.Region.execCommand sets ``Mercury.changes = true``.

The changes in this pull request are my solution to the problem. If there's a better way to get the behavior I need, that'd be great.

Basically, I've created an additional 'exit' button type. It behaves in much the same way as modal and panel buttons, but instead of loading a view element, it simply sets the browser location, via the new Mercury.PageEditor.exit method, based on the the URL specified or returned by the given function.

I added an additional, navigation, section to the mercury.js config. I know....bloat. I'm just not sure, yet, how to handle configuring the navigation stuff outside of the main config.

I also added support for specifying that a toolbar is enabled by default; otherwise, the primary toolbar is the only one enabled when no regions are selected (at least I believe that's how it works). This is done with ``_enabled: true`` in the toolbar config block.

As always, I'm open to and would appreciate suggestions for a better solution.