snikch/jquery.dirtyforms — pull request #23 by NightOwl888 (2012-04-23 13:41:52+00:00)
Title: Bug Fixes, TinyMCE Workaround, 1 New Feature, Removed Functions From Global NS, Documentation Updates

I broke all of this into separate commits so if you wish you can pick and choose.

Fixes:

1. Fix for issue #22, message not showing in IE9. It turned out the logic seems correct in bindFn(), it just needed to ensure the datatype was string before returning to the browser in beforeunloadBindFn().
2. The state of checkboxes, radio buttons, and multi-select lists wasn't being checked properly, so they were being ignored. A function named elementValue() was added to encapsulate the logic of returning the correct value to track whether the element is dirty.
3. Copyright notice states that it must be included, but when minified, it disappeared. Added correct comment opening tag to preserve the comment when compressed.

TinyMCE Workaround:

The :tinymce selector appears to be broken (in jquery.tinymce.js). When no textareas with the appropriate class are on the form, it throws an exception rather than silently returning an empty collection. A wrapper method named formHasTinyMCE() was added to ensure a dirty state (rather than an error) is returned from the tinymce helper in this case.

New Feature:

The isDeciding() method was added to allow the calling code to check whether it has made a decision so it won't accidentally do it again. This came in handy for the "X" button and ESC key in jQueryUI dialog, which cannot be directly bound to, but instead you have to resort to a catch-all 'dialogclose' event, which is called whether a decision was made or not.

Spring Cleaning:

Made all functions under the section titled "Private Properties and Methods" private. This was accomplished by making them into function variables with local scope (using var before the function name). There might be a better way than that, but it did the trick.

This change was made to ensure that we don't see unpredictable issues when code that uses one of the same function names is used elsewhere in the page.

Note that this is a breaking change for anything that is currently using the following methods from outside of the library:

decidingCancel
decidingContinue
dirtylog

There are other methods included as well, but as they are undocumented I am not including them in this list.

Any code calling these must be migrated to the following namespaced accessor methods:

$.DirtyForms.decidingCancel
$.DirtyForms.decidingContinue
$.DirtyForms.dirtylog

Note that

Documentation:

Updated documentation to incude new features, some previously undocumented features, a spelling error, as well as provided a sample on how to use with jQueryUI (it took some head scratching to figure out with the current document).