Changeset 20488
- Timestamp:
- 04/16/2012 11:07:23 PM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/customize-loader.dev.js
r20476 r20488 7 7 8 8 Loader = { 9 supports: { 10 history: !! ( window.history && history.pushState ), 11 hashchange: ('onhashchange' in window) && (document.documentMode === undefined || document.documentMode > 7) 12 }, 13 9 14 initialize: function() { 10 this.body = $( document.body ).addClass('customize-support'); 11 this.element = $( '<div id="customize-container" class="wp-full-overlay" />' ).appendTo( this.body ); 15 this.body = $( document.body ).addClass('customize-support'); 16 this.window = $( window ); 17 this.element = $( '<div id="customize-container" class="wp-full-overlay" />' ).appendTo( this.body ); 12 18 13 19 $('#wpbody').on( 'click', '.load-customize', function( event ) { … … 17 23 Loader.open( $(this).attr('href') ); 18 24 }); 25 26 // Add navigation listeners. 27 if ( this.supports.history ) 28 this.window.on( 'popstate', Loader.popstate ); 29 30 if ( this.supports.hashchange ) 31 this.window.on( 'hashchange', Loader.hashchange ); 32 }, 33 popstate: function( e ) { 34 var state = e.originalEvent.state; 35 if ( state && state.customize ) 36 Loader.open( state.customize ); 37 else if ( Loader.active ) 38 Loader.close(); 39 }, 40 hashchange: function( e ) { 41 var hash = window.location.toString().split('#')[1]; 42 43 if ( hash && 0 === hash.indexOf( 'customize=on' ) ) 44 Loader.open( wpCustomizeLoaderL10n.url + '?' + hash ); 45 46 if ( ! hash ) 47 Loader.close(); 19 48 }, 20 49 open: function( src ) { 50 if ( this.active ) 51 return; 52 this.active = true; 53 21 54 this.iframe = $( '<iframe />', { src: src }).appendTo( this.element ); 22 55 … … 30 63 31 64 this.messenger.bind( 'close', function() { 32 Loader.close(); 65 if ( Loader.supports.history ) 66 history.back(); 67 else if ( Loader.supports.hashchange ) 68 window.location.hash = ''; 69 else 70 Loader.close(); 33 71 }); 34 72 35 73 this.element.fadeIn( 200, function() { 74 var hash = src.split('?')[1]; 75 36 76 Loader.body.addClass( 'customize-active full-overlay-active' ); 77 78 // Ensure we don't call pushState if the user hit the forward button. 79 if ( Loader.supports.history && window.location.href !== src ) 80 history.pushState( { customize: src }, '', src ); 81 else if ( Loader.supports.hashchange && hash ) 82 window.location.hash = hash; 37 83 }); 38 84 }, 39 85 close: function() { 86 if ( ! this.active ) 87 return; 88 this.active = false; 89 40 90 this.element.fadeOut( 200, function() { 41 91 Loader.iframe.remove(); … … 48 98 49 99 $( function() { 50 if ( !!window.postMessage )100 if ( window.postMessage ) 51 101 Loader.initialize(); 52 102 }); -
trunk/wp-includes/theme.php
r20477 r20488 1591 1591 wp_localize_script( 'customize-loader', 'wpCustomizeLoaderL10n', array( 1592 1592 'back' => sprintf( __( '← Return to %s' ), get_admin_page_title() ), 1593 'url' => admin_url( 'admin.php' ), 1593 1594 ) ); 1594 1595 }
Note: See TracChangeset
for help on using the changeset viewer.