Make cancel mean cancel. Props mdawaffe. see #5886
git-svn-id: http://svn.automattic.com/wordpress/trunk@7176 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b214271fd3
commit
589993b783
|
@ -4,16 +4,18 @@ jQuery(function($) {
|
||||||
var increment = 1;
|
var increment = 1;
|
||||||
|
|
||||||
// Open or close widget control form
|
// Open or close widget control form
|
||||||
var toggleWidget = function( li ) {
|
var toggleWidget = function( li, disableFields ) {
|
||||||
var width = li.find('input.widget-width').val();
|
var width = li.find('input.widget-width').val();
|
||||||
|
|
||||||
// it seems IE chokes on these animations because of the positioning/floating
|
// it seems IE chokes on these animations because of the positioning/floating
|
||||||
var widgetAnim = $.browser.msie ? function() {
|
var widgetAnim = $.browser.msie ? function() {
|
||||||
var t = $(this);
|
var t = $(this);
|
||||||
if ( t.is(':visible') ) {
|
if ( t.is(':visible') ) {
|
||||||
|
if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); }
|
||||||
li.css( 'marginLeft', 0 );
|
li.css( 'marginLeft', 0 );
|
||||||
t.siblings('h4').children('a').text( widgetsL10n.edit );
|
t.siblings('h4').children('a').text( widgetsL10n.edit );
|
||||||
} else {
|
} else {
|
||||||
|
t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open
|
||||||
if ( width > 250 )
|
if ( width > 250 )
|
||||||
li.css( 'marginLeft', ( width - 250 ) * -1 );
|
li.css( 'marginLeft', ( width - 250 ) * -1 );
|
||||||
t.siblings('h4').children('a').text( widgetsL10n.cancel );
|
t.siblings('h4').children('a').text( widgetsL10n.cancel );
|
||||||
|
@ -23,10 +25,12 @@ jQuery(function($) {
|
||||||
var t = $(this);
|
var t = $(this);
|
||||||
|
|
||||||
if ( t.is(':visible') ) {
|
if ( t.is(':visible') ) {
|
||||||
|
if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); }
|
||||||
if ( width > 250 )
|
if ( width > 250 )
|
||||||
li.animate( { marginLeft: 0 } );
|
li.animate( { marginLeft: 0 } );
|
||||||
t.siblings('h4').children('a').text( widgetsL10n.edit );
|
t.siblings('h4').children('a').text( widgetsL10n.edit );
|
||||||
} else {
|
} else {
|
||||||
|
t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open
|
||||||
if ( width > 250 )
|
if ( width > 250 )
|
||||||
li.animate( { marginLeft: ( width - 250 ) * -1 } );
|
li.animate( { marginLeft: ( width - 250 ) * -1 } );
|
||||||
t.siblings('h4').children('a').text( widgetsL10n.cancel );
|
t.siblings('h4').children('a').text( widgetsL10n.cancel );
|
||||||
|
@ -37,20 +41,20 @@ jQuery(function($) {
|
||||||
return li.children('div.widget-control').each( widgetAnim ).end();
|
return li.children('div.widget-control').each( widgetAnim ).end();
|
||||||
};
|
};
|
||||||
|
|
||||||
// onclick for edit links
|
// onclick for edit/cancel links
|
||||||
var editClick = function() {
|
var editClick = function() {
|
||||||
var q = wpAjax.unserialize( this.href );
|
var q = wpAjax.unserialize( this.href );
|
||||||
// if link is in available widgets list, make sure it points to the current sidebar
|
// if link is in available widgets list, make sure it points to the current sidebar
|
||||||
if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) {
|
if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || q.add ) {
|
||||||
var w = q.edit || q.add;
|
var w = q.edit || q.add;
|
||||||
toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first') ).blur();
|
toggleWidget( $('#current-sidebar .widget-control-list input[@name^="widget-id"][@value=' + w + ']').parents('li:first'), false ).blur();
|
||||||
return false;
|
return false;
|
||||||
} else if ( q.sidebar ) { // otherwise, redirect to correct page
|
} else if ( q.sidebar ) { // otherwise, redirect to correct page
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If link is in current widgets list, just open the form
|
// If link is in current widgets list, just open the form
|
||||||
toggleWidget( $(this).parents('li:first') ).blur();
|
toggleWidget( $(this).parents('li:first'), true ).blur();
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -92,7 +96,7 @@ jQuery(function($) {
|
||||||
|
|
||||||
// onclick for save links
|
// onclick for save links
|
||||||
$('a.widget-control-save', context).click( function() {
|
$('a.widget-control-save', context).click( function() {
|
||||||
toggleWidget( $(this).parents('li:first') ).blur()
|
toggleWidget( $(this).parents('li:first'), false ).blur()
|
||||||
return false;
|
return false;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,7 @@ class WP_Scripts {
|
||||||
'saveText' => attribute_escape(__('Save »')),
|
'saveText' => attribute_escape(__('Save »')),
|
||||||
'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.")
|
'confirmText' => __("Are you sure you want to delete the file '%title%'?\nClick ok to delete or cancel to go back.")
|
||||||
) );
|
) );
|
||||||
$this->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080109' );
|
$this->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080305' );
|
||||||
$this->localize( 'admin-widgets', 'widgetsL10n', array(
|
$this->localize( 'admin-widgets', 'widgetsL10n', array(
|
||||||
'add' => __('Add'),
|
'add' => __('Add'),
|
||||||
'edit' => __('Edit'),
|
'edit' => __('Edit'),
|
||||||
|
|
|
@ -608,6 +608,7 @@ function wp_widget_text_control($widget_args) {
|
||||||
foreach ( $this_sidebar as $_widget_id ) {
|
foreach ( $this_sidebar as $_widget_id ) {
|
||||||
if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
if ( 'wp_widget_text' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
||||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||||
|
if ( !in_array( "text-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
|
||||||
unset($options[$widget_number]);
|
unset($options[$widget_number]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -743,6 +744,7 @@ function wp_widget_categories_control( $widget_args ) {
|
||||||
foreach ( $this_sidebar as $_widget_id ) {
|
foreach ( $this_sidebar as $_widget_id ) {
|
||||||
if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
if ( 'wp_widget_categories' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
||||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||||
|
if ( !in_array( "categories-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
|
||||||
unset($options[$widget_number]);
|
unset($options[$widget_number]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1162,6 +1164,7 @@ function wp_widget_rss_control($widget_args) {
|
||||||
foreach ( $this_sidebar as $_widget_id ) {
|
foreach ( $this_sidebar as $_widget_id ) {
|
||||||
if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
if ( 'wp_widget_rss' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
||||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||||
|
if ( !in_array( "rss-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
|
||||||
unset($options[$widget_number]);
|
unset($options[$widget_number]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1450,6 +1453,7 @@ function widget_many_control( $widget_args = 1 ) {
|
||||||
// since widget ids aren't necessarily persistent across multiple updates
|
// since widget ids aren't necessarily persistent across multiple updates
|
||||||
if ( 'widget_many' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
if ( 'widget_many' == $wp_registered_widgets[$_widget_id]['callback'] && isset($wp_registered_widgets[$_widget_id]['params'][0]['number']) ) {
|
||||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||||
|
if ( !in_array( "many-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed. "many-$widget_number" is "{id_base}-{widget_number}
|
||||||
unset($options[$widget_number]);
|
unset($options[$widget_number]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue