Widgets: Trigger jQuery events for widget updates.

* `widget-added` when a widget is added to a sidebar
* `widget-updated` when a widget is updated
A jQuery object of the widget is passed along to the event handler. Same events are used in the Widget Customizer, see [27909].

fixes #19675.

git-svn-id: https://develop.svn.wordpress.org/trunk@27969 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2014-04-06 19:05:03 +00:00
parent 8708a44d4a
commit ab8f7f7afd

View File

@ -170,6 +170,7 @@ wpWidgets = {
wpWidgets.save( $widget, 0, 0, 1 );
$widget.find('input.add_new').val('');
$( document ).trigger( 'widget-added', [ $widget ] );
}
$sidebar = $widget.parent();
@ -374,8 +375,9 @@ wpWidgets = {
} else {
$('.spinner').hide();
if ( r && r.length > 2 ) {
$( 'div.widget-content', widget ).html(r);
$( 'div.widget-content', widget ).html( r );
wpWidgets.appendTitle( widget );
$( document ).trigger( 'widget-updated', [ widget ] );
}
}
if ( order ) {
@ -440,6 +442,8 @@ wpWidgets = {
// No longer "new" widget
widget.find( 'input.add_new' ).val('');
$( document ).trigger( 'widget-added', [ widget ] );
/*
* Check if any part of the sidebar is visible in the viewport. If it is, don't scroll.
* Otherwise, scroll up to so the sidebar is in view.