Add save changes reminder to Widgets admin pending revamp in 2.8. Props mdawaffe. fixes #7863

git-svn-id: http://svn.automattic.com/wordpress/trunk@9140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-13 23:09:15 +00:00
parent 586e660529
commit 82be75124d
3 changed files with 18 additions and 2 deletions

View File

@ -305,7 +305,7 @@ function wp_widget_control( $sidebar_args ) {
<?php if ( $control ) : ?> <?php if ( $control ) : ?>
<a class="widget-action widget-control-save hide-if-no-js edit alignleft" href="#save:<?php echo $id_format; ?>"><?php _e('Change'); ?></a> <a class="widget-action widget-control-save hide-if-no-js edit alignleft" href="#save:<?php echo $id_format; ?>"><?php _e('Done'); ?></a>
<?php endif; ?> <?php endif; ?>

View File

@ -1,6 +1,18 @@
jQuery(function($) { jQuery(function($) {
$('.noscript-action').remove(); $('.noscript-action').remove();
var reminded = false;
var lameWidgetReminder = function() {
if ( reminded )
return;
window.onbeforeunload = function () { return widgetsL10n.lamerReminder };
$('div.wrap:first').prepend( '<div class="updated" style="display:none"><p>' + widgetsL10n.lameReminder + '</p></div>' ).children( ':first' ).slideDown();
$('#current-widgets .submit input[name=save-widgets]').css( 'background-color', '#ffffe0' ).click( function() {
window.onbeforeunload = null;
} );
reminded = true;
};
var increment = 1; var increment = 1;
// Open or close widget control form // Open or close widget control form
@ -84,6 +96,7 @@ jQuery(function($) {
var n = parseInt( $('#widget-count').text(), 10 ) + 1; var n = parseInt( $('#widget-count').text(), 10 ) + 1;
$('#widget-count').text( n.toString() ) $('#widget-count').text( n.toString() )
lameWidgetReminder();
return false; return false;
}; };
@ -96,6 +109,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() {
lameWidgetReminder();
toggleWidget( $(this).parents('li:first'), false ).blur() toggleWidget( $(this).parents('li:first'), false ).blur()
return false; return false;
} ); } );

View File

@ -222,11 +222,13 @@ function wp_default_scripts( &$scripts ) {
'saveText' => attribute_escape(__('Save &raquo;')), 'saveText' => attribute_escape(__('Save &raquo;')),
'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.")
) ); ) );
$scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20080503' ); $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081010' );
$scripts->localize( 'admin-widgets', 'widgetsL10n', array( $scripts->localize( 'admin-widgets', 'widgetsL10n', array(
'add' => __('Add'), 'add' => __('Add'),
'edit' => __('Edit'), 'edit' => __('Edit'),
'cancel' => __('Cancel'), 'cancel' => __('Cancel'),
'lameReminder' => __('Remember to click the "Save Changes" button at the bottom of the Current Widgets column after you\'re all done!'),
'lamerReminder' => __("You're about to leave without having saved your changes!")
)); ));
$scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20080423' ); $scripts->add( 'word-count', '/wp-admin/js/word-count.js', array( 'jquery' ), '20080423' );