x-team/wp-widget-customizer — pull request #37 by westonruter (2013-12-07 21:25:30+00:00)
Title: Add facility for previewing changes in realtime with postMessage

Making changes with Widget Customizer currently can be slow, and this is because each change results in a `refresh` of the preview window to see the change.

Re-ordering widgets should be possible completely with `postMessage`, as we can just rearrange the `.widget` elements. Likewise, widgets should be generally be deletable using `postMessage`. For adding or changing widgets, however, they may enqueue a script or style, or there may be some setup that expects the widget to be initialized once upon page load. So we cannot by default allow new widgets to be added or existing widgets to be changed, while using postMessage as the transport mechanism. However, there should be a facility in place for widgets to inform the customizer for how they *can* be updated in realtime. The Widget Customizer can come bundled with `postMessage` handlers for all widgets that come with Core.

If using `postMessage`, we can also update widgets before having to wait for the user to click the widget's **Save** button. As such, if a widget has a `postMessage` handler, then the Save button should be hidden or disabled with the label changed to something like "Auto-saved".

- [x] Update widgets with postMessage
- [ ] Allow updating of a widget without having to press Update? Will require opt-in, maybe some JS to detect when the widget control form is populated enough to be submitted. Filter for opting-in to `postMessage` should be segmented into opt-in for live editing of all fields, not just when hitting Update.
- [x] Insert new widgets into the preview when a new widget is added; will require dynamically binding to the newly-created values.
- [x] Allow widgets to be re-ordered with postMessage.
- [ ] Allow widgets to be assigned to other sidebars with postMessage.
- [ ] Fire event when widget is updated with postMessage so plugin and theme can reinitialize if needed (e.g. Masonry in TwentyThirteen)
- [x] A theme may need to opt-in to postMessage widget updating via `add_theme_support()`
- [ ] When removing the last widget from a sidebar so that none are left being rendered, must trigger a refresh