Changeset 20802
- Timestamp:
- 05/16/2012 05:55:54 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/js/theme.dev.js
r20730 r20802 16 16 details.toggle(); 17 17 event.preventDefault(); 18 }); 19 }); 20 21 /** 22 * Theme Customizer 23 * 24 * Ensures the themes page is refreshed if the customizer switches the theme. 25 */ 26 jQuery( function($) { 27 var Loader, activated; 28 29 if ( typeof wp === 'undefined' || ! wp.customize || ! ( Loader = wp.customize.Loader ) ) 30 return; 31 32 // Strip the current URL of its query string and hash, add activated query string. 33 activated = window.location.href.replace(/[#?].*$/, '') + '?activated=true'; 34 35 // When an instance of the customizer is loaded... 36 Loader.bind( 'open', function() { 37 38 // If the customizer triggers a theme switched event, 39 // load the activated page when the customizer is closed. 40 Loader.messenger.bind( 'switched', function() { 41 42 Loader.unbind( 'close', Loader.overlay.hide ); 43 Loader.bind( 'close', function() { 44 window.location = activated; 45 }); 46 }); 18 47 }); 19 48 }); -
trunk/wp-includes/class-wp-customize.php
r20794 r20802 143 143 144 144 do_action( 'stop_previewing_theme', $this ); 145 } 146 147 /** 148 * Checks if the current theme is active. 149 * 150 * @since 3.4.0 151 */ 152 public function is_current_theme_active() { 153 return $this->get_stylesheet() == $this->original_stylesheet; 145 154 } 146 155 -
trunk/wp-includes/customize-controls.php
r20793 r20802 77 77 <div id="customize-footer-actions" class="wp-full-overlay-footer"> 78 78 <?php 79 $save_text = $this-> get_stylesheet() == $this->original_stylesheet? __('Save') : __('Save and Activate');79 $save_text = $this->is_current_theme_active() ? __('Save') : __('Save and Activate'); 80 80 submit_button( $save_text, 'primary', 'save', false ); 81 81 ?> … … 94 94 95 95 $settings = array( 96 'theme' => $this->get_stylesheet(), 97 'preview' => esc_url( home_url( '/' ) ), 96 'theme' => array( 97 'stylesheet' => $this->get_stylesheet(), 98 'active' => $this->is_current_theme_active(), 99 ), 100 'url' => array( 101 'preview' => esc_url( home_url( '/' ) ), 102 'parent' => esc_url( admin_url() ), 103 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ), 104 ), 98 105 'settings' => array(), 99 106 'controls' => array(), 100 'parent' => esc_url( admin_url() ),101 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),102 107 ); 103 108 -
trunk/wp-includes/js/customize-controls.dev.js
r20798 r20802 393 393 $( function() { 394 394 api.settings = window._wpCustomizeSettings; 395 api.l10n = window._wpCustomizeControlsL10n; 396 395 397 if ( ! api.settings ) 396 398 return; … … 409 411 container: '#customize-preview', 410 412 form: '#customize-controls', 411 url: api.settings. preview413 url: api.settings.url.preview 412 414 }, { 413 415 query: function() { 414 416 return { 415 417 customize: 'on', 416 theme: api.settings.theme ,418 theme: api.settings.theme.stylesheet, 417 419 customized: JSON.stringify( api.get() ) 418 420 }; … … 426 428 nonce: this.nonce 427 429 }), 428 request = $.post( api.settings.ajax, query ); 430 request = $.post( api.settings.url.ajax, query ); 431 432 api.trigger( 'save', request ); 429 433 430 434 body.addClass('saving'); … … 473 477 474 478 // Create a potential postMessage connection with the parent frame. 475 parent = new api.Messenger( api.settings. parent );479 parent = new api.Messenger( api.settings.url.parent ); 476 480 477 481 // If we receive a 'back' event, we're inside an iframe. 478 482 // Send any clicks to the 'Return' link to the parent page. 479 483 parent.bind( 'back', function( text ) { 480 $('.back').text( text ).click( function( event ) { 484 var back = $('.back'); 485 486 if ( text ) 487 back.text( text ); 488 489 back.on( 'click.back', function( event ) { 481 490 event.preventDefault(); 482 491 parent.send( 'close' ); 483 492 }); 484 493 }); 494 495 // If the current theme isn't active, it will be activated on save, 496 // rendering the previous page 497 api.bind( 'save', function( request ) { 498 request.done( function() { 499 parent.send( 'saved' ); 500 501 if ( ! api.settings.theme.active ) { 502 parent.send( 'switched' ); 503 $('#save').val( api.l10n.save ); 504 } 505 506 api.settings.theme.active = true; 507 }); 508 } ); 485 509 486 510 // Initialize the connection with the parent frame. -
trunk/wp-includes/js/customize-loader.dev.js
r20743 r20802 6 6 Loader; 7 7 8 Loader = {8 Loader = $.extend( {}, api.Events, { 9 9 supports: { 10 10 history: !! ( window.history && history.pushState ), … … 16 16 this.window = $( window ); 17 17 this.element = $( '<div id="customize-container" class="wp-full-overlay" />' ).appendTo( this.body ); 18 19 this.bind( 'open', this.overlay.show ); 20 this.bind( 'close', this.overlay.hide ); 18 21 19 22 $('#wpbody').on( 'click', '.load-customize', function( event ) { … … 31 34 this.window.on( 'hashchange', Loader.hashchange ); 32 35 }, 36 33 37 popstate: function( e ) { 34 38 var state = e.originalEvent.state; … … 38 42 Loader.close(); 39 43 }, 44 40 45 hashchange: function( e ) { 41 46 var hash = window.location.toString().split('#')[1]; … … 47 52 Loader.close(); 48 53 }, 54 49 55 open: function( src ) { 56 var hash; 57 50 58 if ( this.active ) 51 59 return; 60 52 61 this.active = true; 53 62 this.body.addClass('customize-loading'); … … 61 70 // Wait for the connection from the iframe before sending any postMessage events. 62 71 this.messenger.bind( 'ready', function() { 63 Loader.messenger.send( 'back', wpCustomizeLoaderL10n.back );72 Loader.messenger.send( 'back', wpCustomizeLoaderL10n.back || '' ); 64 73 }); 65 74 … … 73 82 }); 74 83 75 this.element.fadeIn( 200, function() { 76 var hash = src.split('?')[1]; 84 hash = src.split('?')[1]; 77 85 78 Loader.body.addClass( 'customize-active full-overlay-active' ); 86 // Ensure we don't call pushState if the user hit the forward button. 87 if ( Loader.supports.history && window.location.href !== src ) 88 history.pushState( { customize: src }, '', src ); 89 else if ( ! Loader.supports.history && Loader.supports.hashchange && hash ) 90 window.location.hash = hash; 79 91 80 // Ensure we don't call pushState if the user hit the forward button. 81 if ( Loader.supports.history && window.location.href !== src ) 82 history.pushState( { customize: src }, '', src ); 83 else if ( ! Loader.supports.history && Loader.supports.hashchange && hash ) 84 window.location.hash = hash; 85 }); 92 this.trigger( 'open' ); 86 93 }, 94 95 opened: function() { 96 Loader.body.addClass( 'customize-active full-overlay-active' ); 97 }, 98 87 99 close: function() { 88 100 if ( ! this.active ) … … 90 102 this.active = false; 91 103 92 this.element.fadeOut( 200, function() { 93 Loader.iframe.remove(); 94 Loader.messenger.destroy(); 95 Loader.iframe = null; 96 Loader.messenger = null; 97 Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' ); 98 }); 104 this.trigger( 'close' ); 99 105 }, 106 107 closed: function() { 108 Loader.iframe.remove(); 109 Loader.messenger.destroy(); 110 Loader.iframe = null; 111 Loader.messenger = null; 112 Loader.body.removeClass( 'customize-active full-overlay-active' ).removeClass( 'customize-loading' ); 113 }, 114 100 115 loaded: function() { 101 116 Loader.body.removeClass('customize-loading'); 117 }, 118 119 overlay: { 120 show: function() { 121 this.element.fadeIn( 200, Loader.opened ); 122 }, 123 124 hide: function() { 125 this.element.fadeOut( 200, Loader.closed ); 126 } 102 127 } 103 } ;128 }); 104 129 105 130 $( function() { -
trunk/wp-includes/js/customize-preview.dev.js
r20798 r20802 35 35 this.body.on( 'click.preview', 'a', function( event ) { 36 36 event.preventDefault(); 37 self.send( 'url', $(this). attr('href') );37 self.send( 'url', $(this).prop('href') ); 38 38 }); 39 39 … … 72 72 var value = api( args.shift() ); 73 73 if ( value ) 74 value. apply( value, args );74 value.set.apply( value, args ); 75 75 }); 76 76 -
trunk/wp-includes/script-loader.php
r20732 r20802 300 300 $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery', 'json2' ), false, 1 ); 301 301 $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); 302 $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 ); 302 303 $scripts->add( 'customize-controls', "/wp-includes/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 ); 303 $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 ); 304 $scripts->localize( 'customize-controls', '_wpCustomizeControlsL10n', array( 305 'save' => __( 'Save' ), 306 ) ); 304 307 305 308 if ( is_admin() ) { -
trunk/wp-includes/theme.php
r20772 r20802 1590 1590 */ 1591 1591 function _wp_customize_loader_localize() { 1592 wp_localize_script( 'customize-loader', 'wpCustomizeLoaderL10n', array( 1593 'back' => sprintf( __( '← Return to %s' ), get_admin_page_title() ), 1594 'url' => admin_url( 'admin.php' ), 1595 ) ); 1592 $l10n = array( 'url' => admin_url( 'admin.php' ) ); 1593 1594 if ( is_admin() ) 1595 $l10n[ 'back' ] = sprintf( __( '← Return to %s' ), get_admin_page_title() ); 1596 1597 wp_localize_script( 'customize-loader', 'wpCustomizeLoaderL10n', $l10n ); 1596 1598 } 1597 1599 add_action( 'admin_enqueue_scripts', '_wp_customize_loader_localize' );
Note: See TracChangeset
for help on using the changeset viewer.