mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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;
|
||||
|
||||
// Open or close widget control form
|
||||
var toggleWidget = function( li ) {
|
||||
var toggleWidget = function( li, disableFields ) {
|
||||
var width = li.find('input.widget-width').val();
|
||||
|
||||
// it seems IE chokes on these animations because of the positioning/floating
|
||||
var widgetAnim = $.browser.msie ? function() {
|
||||
var t = $(this);
|
||||
if ( t.is(':visible') ) {
|
||||
if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); }
|
||||
li.css( 'marginLeft', 0 );
|
||||
t.siblings('h4').children('a').text( widgetsL10n.edit );
|
||||
} else {
|
||||
t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open
|
||||
if ( width > 250 )
|
||||
li.css( 'marginLeft', ( width - 250 ) * -1 );
|
||||
t.siblings('h4').children('a').text( widgetsL10n.cancel );
|
||||
@ -23,10 +25,12 @@ jQuery(function($) {
|
||||
var t = $(this);
|
||||
|
||||
if ( t.is(':visible') ) {
|
||||
if ( disableFields ) { t.find( ':enabled' ).not( '[name="widget-id[]"]' ).attr( 'disabled', 'disabled' ); }
|
||||
if ( width > 250 )
|
||||
li.animate( { marginLeft: 0 } );
|
||||
t.siblings('h4').children('a').text( widgetsL10n.edit );
|
||||
} else {
|
||||
t.find( ':disabled' ).attr( 'disabled', '' ); // always enable on open
|
||||
if ( width > 250 )
|
||||
li.animate( { marginLeft: ( width - 250 ) * -1 } );
|
||||
t.siblings('h4').children('a').text( widgetsL10n.cancel );
|
||||
@ -37,20 +41,20 @@ jQuery(function($) {
|
||||
return li.children('div.widget-control').each( widgetAnim ).end();
|
||||
};
|
||||
|
||||
// onclick for edit links
|
||||
// onclick for edit/cancel links
|
||||
var editClick = function() {
|
||||
var q = wpAjax.unserialize( this.href );
|
||||
// if link is in available widgets list, make sure it points to the current sidebar
|
||||
if ( ( q.sidebar && q.sidebar == $('#sidebar').val() ) || 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;
|
||||
} else if ( q.sidebar ) { // otherwise, redirect to correct page
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
@ -92,7 +96,7 @@ jQuery(function($) {
|
||||
|
||||
// onclick for save links
|
||||
$('a.widget-control-save', context).click( function() {
|
||||
toggleWidget( $(this).parents('li:first') ).blur()
|
||||
toggleWidget( $(this).parents('li:first'), false ).blur()
|
||||
return false;
|
||||
} );
|
||||
|
||||
|
@ -172,7 +172,7 @@ class WP_Scripts {
|
||||
'saveText' => attribute_escape(__('Save »')),
|
||||
'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(
|
||||
'add' => __('Add'),
|
||||
'edit' => __('Edit'),
|
||||
|
@ -608,7 +608,8 @@ function wp_widget_text_control($widget_args) {
|
||||
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']) ) {
|
||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||
unset($options[$widget_number]);
|
||||
if ( !in_array( "text-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
|
||||
unset($options[$widget_number]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -743,7 +744,8 @@ function wp_widget_categories_control( $widget_args ) {
|
||||
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']) ) {
|
||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||
unset($options[$widget_number]);
|
||||
if ( !in_array( "categories-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
|
||||
unset($options[$widget_number]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1162,7 +1164,8 @@ function wp_widget_rss_control($widget_args) {
|
||||
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']) ) {
|
||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||
unset($options[$widget_number]);
|
||||
if ( !in_array( "rss-$widget_number", $_POST['widget-id'] ) ) // the widget has been removed.
|
||||
unset($options[$widget_number]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1450,7 +1453,8 @@ function widget_many_control( $widget_args = 1 ) {
|
||||
// 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']) ) {
|
||||
$widget_number = $wp_registered_widgets[$_widget_id]['params'][0]['number'];
|
||||
unset($options[$widget_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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user