From 82be75124d3a692373d16f7135ae0a66068743ed Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 13 Oct 2008 23:09:15 +0000 Subject: [PATCH] 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 --- wp-admin/includes/widgets.php | 2 +- wp-admin/js/widgets.js | 14 ++++++++++++++ wp-includes/script-loader.php | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index b87d58aefc..70a139e38b 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -305,7 +305,7 @@ function wp_widget_control( $sidebar_args ) { - + diff --git a/wp-admin/js/widgets.js b/wp-admin/js/widgets.js index b42812f3f6..2119eb8d80 100644 --- a/wp-admin/js/widgets.js +++ b/wp-admin/js/widgets.js @@ -1,6 +1,18 @@ jQuery(function($) { $('.noscript-action').remove(); + var reminded = false; + var lameWidgetReminder = function() { + if ( reminded ) + return; + window.onbeforeunload = function () { return widgetsL10n.lamerReminder }; + $('div.wrap:first').prepend( '' ).children( ':first' ).slideDown(); + $('#current-widgets .submit input[name=save-widgets]').css( 'background-color', '#ffffe0' ).click( function() { + window.onbeforeunload = null; + } ); + reminded = true; + }; + var increment = 1; // Open or close widget control form @@ -84,6 +96,7 @@ jQuery(function($) { var n = parseInt( $('#widget-count').text(), 10 ) + 1; $('#widget-count').text( n.toString() ) + lameWidgetReminder(); return false; }; @@ -96,6 +109,7 @@ jQuery(function($) { // onclick for save links $('a.widget-control-save', context).click( function() { + lameWidgetReminder(); toggleWidget( $(this).parents('li:first'), false ).blur() return false; } ); diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php index bb84b67d14..c413dafc72 100644 --- a/wp-includes/script-loader.php +++ b/wp-includes/script-loader.php @@ -222,11 +222,13 @@ function wp_default_scripts( &$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.") ) ); - $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( 'add' => __('Add'), 'edit' => __('Edit'), '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' );