/** * Theme Browsing * * Controls visibility of theme details on manage and install themes pages. */ jQuery( function($) { $('#availablethemes').on( 'click', '.theme-detail', function (event) { var theme = $(this).closest('.available-theme'), details = theme.find('.themedetaildiv'); if ( ! details.length ) { details = theme.find('.install-theme-info .theme-details'); details = details.clone().addClass('themedetaildiv').appendTo( theme ).hide(); } details.toggle(); event.preventDefault(); }); }); /** * Theme Customizer * * Ensures the themes page is refreshed if the customizer switches the theme. */ jQuery( function($) { var Loader, activated; if ( typeof wp === 'undefined' || ! wp.customize || ! ( Loader = wp.customize.Loader ) ) return; // Strip the current URL of its query string and hash, add activated query string. activated = window.location.href.replace(/[#?].*$/, '') + '?activated=true'; // When an instance of the customizer is loaded... Loader.bind( 'open', function() { // If the customizer triggers a theme switched event, // load the activated page when the customizer is closed. Loader.messenger.bind( 'switched', function() { Loader.unbind( 'close', Loader.overlay.hide ); Loader.bind( 'close', function() { window.location = activated; }); }); }); }); /** * Theme Install * * Displays theme previews on theme install pages. */ jQuery( function($) { if( ! window.postMessage ) return; var preview = $('#theme-installer'), info = preview.find('.install-theme-info'), panel = preview.find('.wp-full-overlay-main'), body = $( document.body ); preview.on( 'click', '.close-full-overlay', function( event ) { preview.fadeOut( 200, function() { panel.empty(); body.removeClass('theme-installer-active full-overlay-active'); }); event.preventDefault(); }); preview.on( 'click', '.collapse-sidebar', function( event ) { preview.toggleClass('collapsed'); event.preventDefault(); }); $('#availablethemes').on( 'click', '.install-theme-preview', function( event ) { var src; info.html( $(this).closest('.installable-theme').find('.install-theme-info').html() ); src = info.find( '.theme-preview-url' ).val(); panel.html( '