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.
Built from https://develop.svn.wordpress.org/trunk@27969


git-svn-id: http://core.svn.wordpress.org/trunk@27799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Dominik Schilling 2014-04-06 19:06:14 +00:00
parent 90e62bf6ac
commit 0c5d4db466
2 changed files with 6 additions and 2 deletions

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.

File diff suppressed because one or more lines are too long