diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index 4bfc252..a7a6655 100644
|
|
|
|
| 1128 | 1128 | }); |
| 1129 | 1129 | }); |
| 1130 | 1130 | |
| | 1131 | // Prompt user with AYS dialog if leaving the Customizer with unsaved changes |
| | 1132 | $( window ).on( 'beforeunload', function () { |
| | 1133 | if ( ! api.state( 'saved' )() ) { |
| | 1134 | return api.l10n.saveAlert; |
| | 1135 | } |
| | 1136 | } ); |
| | 1137 | |
| 1131 | 1138 | // Pass events through to the parent. |
| 1132 | | api.bind( 'saved', function() { |
| 1133 | | parent.send( 'saved' ); |
| 1134 | | }); |
| | 1139 | $.each( [ 'saved', 'change' ], function ( i, event ) { |
| | 1140 | api.bind( event, function() { |
| | 1141 | parent.send( event ); |
| | 1142 | }); |
| | 1143 | } ); |
| 1135 | 1144 | |
| 1136 | 1145 | // When activated, let the loader handle redirecting the page. |
| 1137 | 1146 | // If no loader exists, redirect the page ourselves (if a url exists). |
diff --git src/wp-includes/js/customize-loader.js src/wp-includes/js/customize-loader.js
index cccf71a..b99351d 100644
|
|
|
window.wp = window.wp || {}; |
| 63 | 63 | Loader.close(); |
| 64 | 64 | }, |
| 65 | 65 | |
| | 66 | beforeunload: function () { |
| | 67 | if ( ! Loader.saved() ) { |
| | 68 | return Loader.settings.l10n.saveAlert; |
| | 69 | } |
| | 70 | }, |
| | 71 | |
| 66 | 72 | open: function( src ) { |
| 67 | 73 | var hash; |
| 68 | 74 | |
| 69 | 75 | if ( this.active ) |
| 70 | 76 | return; |
| 71 | 77 | |
| | 78 | this.saved = new api.Value( true ); |
| | 79 | |
| 72 | 80 | // Load the full page on mobile devices. |
| 73 | 81 | if ( Loader.settings.browser.mobile ) |
| 74 | 82 | return window.location = src; |
| … |
… |
window.wp = window.wp || {}; |
| 100 | 108 | Loader.close(); |
| 101 | 109 | }); |
| 102 | 110 | |
| | 111 | // Prompt AYS dialog when navigating away |
| | 112 | $( window ).on( 'beforeunload', this.beforeunload ); |
| | 113 | |
| 103 | 114 | this.messenger.bind( 'activated', function( location ) { |
| 104 | 115 | if ( location ) |
| 105 | 116 | window.location = location; |
| 106 | 117 | }); |
| 107 | 118 | |
| | 119 | this.messenger.bind( 'saved', function () { |
| | 120 | Loader.saved( true ); |
| | 121 | } ); |
| | 122 | this.messenger.bind( 'change', function () { |
| | 123 | Loader.saved( false ); |
| | 124 | } ); |
| | 125 | |
| 108 | 126 | hash = src.split('?')[1]; |
| 109 | 127 | |
| 110 | 128 | // Ensure we don't call pushState if the user hit the forward button. |
| … |
… |
window.wp = window.wp || {}; |
| 137 | 155 | Loader.messenger.destroy(); |
| 138 | 156 | Loader.iframe = null; |
| 139 | 157 | Loader.messenger = null; |
| | 158 | Loader.saved = null; |
| 140 | 159 | Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' ); |
| | 160 | $( window ).off( 'beforeunload', Loader.beforeunload ); |
| 141 | 161 | }, |
| 142 | 162 | |
| 143 | 163 | loaded: function() { |
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
index df42718..c0d42b6 100644
|
|
|
function wp_default_scripts( &$scripts ) { |
| 381 | 381 | did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array( |
| 382 | 382 | 'activate' => __( 'Save & Activate' ), |
| 383 | 383 | 'save' => __( 'Save & Publish' ), |
| | 384 | 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
| 384 | 385 | 'saved' => __( 'Saved' ), |
| 385 | 386 | 'cancel' => __( 'Cancel' ), |
| 386 | 387 | 'close' => __( 'Close' ), |
diff --git src/wp-includes/theme.php src/wp-includes/theme.php
index 40acf6b..d882463 100644
|
|
|
function _wp_customize_loader_settings() { |
| 1874 | 1874 | 'url' => esc_url( admin_url( 'customize.php' ) ), |
| 1875 | 1875 | 'isCrossDomain' => $cross_domain, |
| 1876 | 1876 | 'browser' => $browser, |
| | 1877 | 'l10n' => array( |
| | 1878 | 'saveAlert' => __( 'The changes you made will be lost if you navigate away from this page.' ), |
| | 1879 | ), |
| 1877 | 1880 | ); |
| 1878 | 1881 | |
| 1879 | 1882 | $script = 'var _wpCustomizeLoaderSettings = ' . json_encode( $settings ) . ';'; |