Ticket #20337: 20337.2.patch
File 20337.2.patch, 2.0 KB (added by , 12 years ago) |
---|
-
wp-includes/js/customize-loader.dev.js
10 10 11 11 this.element.on( 'click', '.close-full-overlay', function() { 12 12 Loader.close(); 13 window.location.hash = ''; 13 14 return false; 14 15 }); 15 16 … … 17 18 Loader.element.toggleClass('collapsed'); 18 19 return false; 19 20 }); 21 22 Loader.checkHashParams(); 20 23 }, 24 getHashParams: function() { 25 var hash = window.location.toString().split(/[#?]/)[1]; 26 var hashParams = {}; 27 28 if ( ! hash ) 29 return hashParams; 30 31 var parts = hash.replace('customize/', '').split(/[=&]/); 32 for ( var i = 0; i < parts.length; i += 2 ) { 33 hashParams[ parts[i] ] = decodeURIComponent( parts[i + 1] ); 34 } 35 36 return hashParams; 37 }, 38 checkHashParams: function() { 39 var params = Loader.getHashParams(); 40 41 if ( params.template && params.stylesheet ) { 42 // Load the theme. 43 Loader.open({ 44 template: params.template, 45 stylesheet: params.stylesheet 46 }); 47 } else { 48 if ( Loader.iframe ) 49 Loader.close(); 50 } 51 }, 21 52 open: function( params ) { 53 if ( -1 == window.location.hash.indexOf( '#customize' ) ) 54 window.location.hash = 'customize/template=' + params.template + '&stylesheet=' + params.stylesheet; 55 22 56 params.customize = 'on'; 23 57 24 58 this.iframe = $( '<iframe />', { … … 31 65 }, 32 66 close: function() { 33 67 this.element.fadeOut( 200, function() { 34 Loader.iframe.remove(); 68 if ( Loader.iframe ) 69 Loader.iframe.remove(); 35 70 Loader.iframe = null; 36 71 Loader.body.removeClass( 'customize-active full-overlay-active' ); 37 72 }); … … 41 76 $( function() { 42 77 Loader.initialize(); 43 78 79 window.onhashchange = function() { 80 Loader.checkHashParams(); 81 } 82 44 83 $('#current-theme, #availablethemes').on( 'click', '.load-customize', function( event ) { 45 84 var load = $(this); 46 85