diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
index 4bfc252..910bf43 100644
|
|
|
|
| 915 | 915 | |
| 916 | 916 | var previewer, parent, topFocus, |
| 917 | 917 | body = $( document.body ), |
| 918 | | overlay = body.children('.wp-full-overlay'); |
| | 918 | overlay = body.children( '.wp-full-overlay' ), |
| | 919 | backBtn = $( '.back' ), |
| | 920 | saveBtn = $( '#save' ), |
| | 921 | confirmClose = true; |
| 919 | 922 | |
| 920 | 923 | // Prevent the form from saving when enter is pressed on an input or select element. |
| 921 | 924 | $('#customize-controls').on( 'keydown', function( e ) { |
| … |
… |
|
| 1040 | 1043 | processing = state.create( 'processing' ); |
| 1041 | 1044 | |
| 1042 | 1045 | state.bind( 'change', function() { |
| 1043 | | var save = $('#save'), |
| 1044 | | back = $('.back'); |
| 1045 | | |
| 1046 | 1046 | if ( ! activated() ) { |
| 1047 | | save.val( api.l10n.activate ).prop( 'disabled', false ); |
| 1048 | | back.text( api.l10n.cancel ); |
| | 1047 | saveBtn.val( api.l10n.activate ).prop( 'disabled', false ); |
| | 1048 | backBtn.text( api.l10n.cancel ); |
| 1049 | 1049 | |
| 1050 | 1050 | } else if ( saved() ) { |
| 1051 | | save.val( api.l10n.saved ).prop( 'disabled', true ); |
| 1052 | | back.text( api.l10n.close ); |
| | 1051 | saveBtn.val( api.l10n.saved ).prop( 'disabled', true ); |
| | 1052 | backBtn.text( api.l10n.close ); |
| 1053 | 1053 | |
| 1054 | 1054 | } else { |
| 1055 | | save.val( api.l10n.save ).prop( 'disabled', false ); |
| 1056 | | back.text( api.l10n.cancel ); |
| | 1055 | saveBtn.val( api.l10n.save ).prop( 'disabled', false ); |
| | 1056 | backBtn.text( api.l10n.cancel ); |
| 1057 | 1057 | } |
| 1058 | 1058 | }); |
| 1059 | 1059 | |
| … |
… |
|
| 1081 | 1081 | }()); |
| 1082 | 1082 | |
| 1083 | 1083 | // Button bindings. |
| 1084 | | $('#save').click( function( event ) { |
| | 1084 | saveBtn.click( function( event ) { |
| 1085 | 1085 | previewer.save(); |
| 1086 | 1086 | event.preventDefault(); |
| 1087 | 1087 | }).keydown( function( event ) { |
| … |
… |
|
| 1092 | 1092 | event.preventDefault(); |
| 1093 | 1093 | }); |
| 1094 | 1094 | |
| 1095 | | $('.back').keydown( function( event ) { |
| | 1095 | backBtn.keydown( function( event ) { |
| 1096 | 1096 | if ( 9 === event.which ) // tab |
| 1097 | 1097 | return; |
| 1098 | 1098 | if ( 13 === event.which ) // enter |
| … |
… |
|
| 1122 | 1122 | // If we receive a 'back' event, we're inside an iframe. |
| 1123 | 1123 | // Send any clicks to the 'Return' link to the parent page. |
| 1124 | 1124 | parent.bind( 'back', function() { |
| 1125 | | $('.back').on( 'click.back', function( event ) { |
| | 1125 | backBtn.on( 'click.back', function( event ) { |
| 1126 | 1126 | event.preventDefault(); |
| 1127 | 1127 | parent.send( 'close' ); |
| 1128 | 1128 | }); |
| 1129 | 1129 | }); |
| 1130 | 1130 | |
| | 1131 | // Prevent AYS dialog when user manually clicks back button |
| | 1132 | backBtn.on( 'click', function () { |
| | 1133 | confirmClose = false; |
| | 1134 | } ); |
| | 1135 | |
| | 1136 | // Prompt user with AYS dialog if leaving the Customizer with unsaved changes |
| | 1137 | $( window ).on( 'beforeunload', function () { |
| | 1138 | if ( confirmClose && ! api.state( 'saved' )() ) { |
| | 1139 | return api.l10n.saveAlert; |
| | 1140 | } |
| | 1141 | } ); |
| | 1142 | |
| 1131 | 1143 | // Pass events through to the parent. |
| 1132 | | api.bind( 'saved', function() { |
| 1133 | | parent.send( 'saved' ); |
| 1134 | | }); |
| | 1144 | $.each( [ 'saved', 'change' ], function ( i, event ) { |
| | 1145 | api.bind( event, function() { |
| | 1146 | parent.send( event ); |
| | 1147 | }); |
| | 1148 | } ); |
| 1135 | 1149 | |
| 1136 | 1150 | // When activated, let the loader handle redirecting the page. |
| 1137 | 1151 | // If no loader exists, redirect the page ourselves (if a url exists). |
| … |
… |
|
| 1198 | 1212 | api.trigger( 'ready' ); |
| 1199 | 1213 | |
| 1200 | 1214 | // Make sure left column gets focus |
| 1201 | | topFocus = $('.back'); |
| | 1215 | topFocus = backBtn; |
| 1202 | 1216 | topFocus.focus(); |
| 1203 | 1217 | setTimeout(function () { |
| 1204 | 1218 | topFocus.focus(); |
diff --git src/wp-includes/js/customize-loader.js src/wp-includes/js/customize-loader.js
index cccf71a..437822f 100644
|
|
|
|
| 1 | | /* global _wpCustomizeLoaderSettings */ |
| | 1 | /* global _wpCustomizeLoaderSettings, confirm */ |
| 2 | 2 | window.wp = window.wp || {}; |
| 3 | 3 | |
| 4 | 4 | (function( exports, $ ){ |
| … |
… |
window.wp = window.wp || {}; |
| 36 | 36 | }); |
| 37 | 37 | |
| 38 | 38 | // Add navigation listeners. |
| 39 | | if ( $.support.history ) |
| | 39 | if ( $.support.history ) { |
| 40 | 40 | this.window.on( 'popstate', Loader.popstate ); |
| | 41 | } |
| 41 | 42 | |
| 42 | 43 | if ( $.support.hashchange ) { |
| 43 | 44 | this.window.on( 'hashchange', Loader.hashchange ); |
| … |
… |
window.wp = window.wp || {}; |
| 47 | 48 | |
| 48 | 49 | popstate: function( e ) { |
| 49 | 50 | var state = e.originalEvent.state; |
| 50 | | if ( state && state.customize ) |
| | 51 | if ( state && state.customize ) { |
| 51 | 52 | Loader.open( state.customize ); |
| 52 | | else if ( Loader.active ) |
| | 53 | } else if ( Loader.active ) { |
| 53 | 54 | Loader.close(); |
| | 55 | } |
| 54 | 56 | }, |
| 55 | 57 | |
| 56 | 58 | hashchange: function() { |
| 57 | 59 | var hash = window.location.toString().split('#')[1]; |
| 58 | 60 | |
| 59 | | if ( hash && 0 === hash.indexOf( 'wp_customize=on' ) ) |
| | 61 | if ( hash && 0 === hash.indexOf( 'wp_customize=on' ) ) { |
| 60 | 62 | Loader.open( Loader.settings.url + '?' + hash ); |
| | 63 | } |
| 61 | 64 | |
| 62 | | if ( ! hash && ! $.support.history ) |
| | 65 | if ( ! hash && ! $.support.history ){ |
| 63 | 66 | Loader.close(); |
| | 67 | } |
| | 68 | }, |
| | 69 | |
| | 70 | beforeunload: function () { |
| | 71 | if ( ! Loader.saved() ) { |
| | 72 | return Loader.settings.l10n.saveAlert; |
| | 73 | } |
| 64 | 74 | }, |
| 65 | 75 | |
| 66 | 76 | open: function( src ) { |
| 67 | | var hash; |
| 68 | 77 | |
| 69 | | if ( this.active ) |
| | 78 | if ( this.active ) { |
| 70 | 79 | return; |
| | 80 | } |
| 71 | 81 | |
| 72 | 82 | // Load the full page on mobile devices. |
| 73 | | if ( Loader.settings.browser.mobile ) |
| | 83 | if ( Loader.settings.browser.mobile ) { |
| 74 | 84 | return window.location = src; |
| | 85 | } |
| 75 | 86 | |
| 76 | 87 | this.active = true; |
| 77 | 88 | this.body.addClass('customize-loading'); |
| | 89 | this.confirmClose = true; |
| | 90 | |
| | 91 | // Dirty state of customizer in iframe |
| | 92 | this.saved = new api.Value( true ); |
| 78 | 93 | |
| 79 | 94 | this.iframe = $( '<iframe />', { src: src }).appendTo( this.element ); |
| 80 | 95 | this.iframe.one( 'load', this.loaded ); |
| … |
… |
window.wp = window.wp || {}; |
| 92 | 107 | }); |
| 93 | 108 | |
| 94 | 109 | this.messenger.bind( 'close', function() { |
| 95 | | if ( $.support.history ) |
| | 110 | // close event indicates user-elected closing, so AYS dialog shouldn't be shown |
| | 111 | Loader.confirmClose = false; |
| | 112 | |
| | 113 | if ( $.support.history ) { |
| 96 | 114 | history.back(); |
| 97 | | else if ( $.support.hashchange ) |
| | 115 | } else if ( $.support.hashchange ) { |
| 98 | 116 | window.location.hash = ''; |
| 99 | | else |
| | 117 | } else { |
| 100 | 118 | Loader.close(); |
| 101 | | }); |
| | 119 | } |
| | 120 | } ); |
| | 121 | |
| | 122 | // Prompt AYS dialog when navigating away |
| | 123 | $( window ).on( 'beforeunload', this.beforeunload ); |
| 102 | 124 | |
| 103 | 125 | this.messenger.bind( 'activated', function( location ) { |
| 104 | | if ( location ) |
| | 126 | if ( location ) { |
| 105 | 127 | window.location = location; |
| | 128 | } |
| 106 | 129 | }); |
| 107 | 130 | |
| 108 | | hash = src.split('?')[1]; |
| | 131 | this.messenger.bind( 'saved', function () { |
| | 132 | Loader.saved( true ); |
| | 133 | } ); |
| | 134 | this.messenger.bind( 'change', function () { |
| | 135 | Loader.saved( false ); |
| | 136 | } ); |
| | 137 | |
| | 138 | this.pushState( src ); |
| | 139 | |
| | 140 | this.trigger( 'open' ); |
| | 141 | }, |
| | 142 | |
| | 143 | pushState: function ( src ) { |
| | 144 | var hash; |
| 109 | 145 | |
| 110 | 146 | // Ensure we don't call pushState if the user hit the forward button. |
| 111 | | if ( $.support.history && window.location.href !== src ) |
| | 147 | if ( $.support.history && window.location.href !== src ) { |
| 112 | 148 | history.pushState( { customize: src }, '', src ); |
| 113 | | else if ( ! $.support.history && $.support.hashchange && hash ) |
| | 149 | } else if ( ! $.support.history && $.support.hashchange && hash ) { |
| | 150 | hash = src.split( '?' )[1]; |
| 114 | 151 | window.location.hash = 'wp_customize=on&' + hash; |
| 115 | | |
| 116 | | this.trigger( 'open' ); |
| | 152 | } |
| 117 | 153 | }, |
| 118 | 154 | |
| 119 | 155 | opened: function() { |
| … |
… |
window.wp = window.wp || {}; |
| 121 | 157 | }, |
| 122 | 158 | |
| 123 | 159 | close: function() { |
| 124 | | if ( ! this.active ) |
| | 160 | if ( ! this.active ) { |
| | 161 | return; |
| | 162 | } |
| | 163 | |
| | 164 | // Display AYS dialog if customizer is dirty |
| | 165 | if ( ! this.saved() && this.confirmClose && ! confirm( Loader.settings.l10n.saveAlert ) ) { |
| | 166 | // Go forward since Customizer is exited by history.back() |
| | 167 | history.forward(); |
| 125 | 168 | return; |
| | 169 | } |
| | 170 | |
| 126 | 171 | this.active = false; |
| 127 | 172 | |
| 128 | 173 | this.trigger( 'close' ); |
| 129 | 174 | |
| 130 | 175 | // Return focus to link that was originally clicked. |
| 131 | | if ( this.link ) |
| | 176 | if ( this.link ) { |
| 132 | 177 | this.link.focus(); |
| | 178 | } |
| 133 | 179 | }, |
| 134 | 180 | |
| 135 | 181 | closed: function() { |
| … |
… |
window.wp = window.wp || {}; |
| 137 | 183 | Loader.messenger.destroy(); |
| 138 | 184 | Loader.iframe = null; |
| 139 | 185 | Loader.messenger = null; |
| | 186 | Loader.saved = null; |
| 140 | 187 | Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' ); |
| | 188 | $( window ).off( 'beforeunload', Loader.beforeunload ); |
| 141 | 189 | }, |
| 142 | 190 | |
| 143 | 191 | 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 ) . ';'; |