Changeset 20476
- Timestamp:
- 04/16/2012 02:02:28 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin.dev.css
r20459 r20476 5314 5314 ------------------------------------------------------------------------------*/ 5315 5315 5316 .hide-if-no-customize, 5317 .customize-support .hide-if-customize { 5318 display: none !important; 5319 } 5320 5321 .hide-if-customize, 5322 .customize-support .hide-if-no-customize { 5323 display: block !important; 5324 } 5325 5316 5326 #customize-container { 5317 5327 display: none; -
trunk/wp-admin/includes/class-wp-themes-list-table.php
r20455 r20476 132 132 home_url( '/' ) ) ); 133 133 134 $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $title ) ) . '"135 . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';136 137 134 $actions = array(); 138 135 $actions[] = '<a href="' . $activate_link . '" class="activatelink" title="' 139 136 . esc_attr( sprintf( __( 'Activate “%s”' ), $title ) ) . '">' . __( 'Activate' ) . '</a>'; 140 $actions[] = '<a href="' . $preview_link . '" class="hide-if- js" title="'137 $actions[] = '<a href="' . $preview_link . '" class="hide-if-customize" title="' 141 138 . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '">' . __( 'Preview' ) . '</a>' 142 . '<a href="#" class="load-customize hide-if-no-js" ' . $customize_attributes . '>' . __( 'Customize' ) . '</a>'; 139 . '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="load-customize hide-if-no-customize">' 140 . __( 'Customize' ) . '</a>'; 143 141 if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) 144 142 $actions['delete'] = '<a class="submitdelete deletion" href="' . wp_nonce_url( "themes.php?action=delete&template=$stylesheet", 'delete-theme_' . $stylesheet ) … … 151 149 152 150 ?> 153 <a href="<?php echo $preview_link; ?>" class="load-customize screenshot" <?php echo $customize_attributes; ?>> 154 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> 155 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> 156 <?php endif; ?> 151 152 <a href="<?php echo $preview_link; ?>" class="screenshot hide-if-customize"> 153 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> 154 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> 155 <?php endif; ?> 157 156 </a> 157 <a <?php echo wp_customize_href( $template, $stylesheet ); ?> class="screenshot load-customize hide-if-no-customize"> 158 <?php if ( $screenshot = $theme->get_screenshot() ) : ?> 159 <img src="<?php echo esc_url( $screenshot ); ?>" alt="" /> 160 <?php endif; ?> 161 </a> 162 158 163 <h3><?php echo $title; ?></h3> 159 164 <div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div> -
trunk/wp-admin/includes/class-wp-upgrader.php
r20419 r20476 1508 1508 ), trailingslashit( get_home_url() ) ); 1509 1509 1510 $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $name ) ) . '"1511 . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';1512 1513 1510 $activate_link = add_query_arg( array( 1514 1511 'action' => 'activate', … … 1519 1516 1520 1517 $install_actions = array(); 1521 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if- js" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';1522 $install_actions['preview'] .= '<a href="#" class="hide-if-no-js load-customize" ' . $customize_attributes . '>' . __('Customize') . '</a>';1518 $install_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; 1519 $install_actions['preview'] .= '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="hide-if-no-customize load-customize>' . __('Customize') . '</a>'; 1523 1520 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; 1524 1521 … … 1575 1572 ), trailingslashit( get_home_url() ) ); 1576 1573 1577 $customize_attributes = 'title="' . esc_attr( sprintf( __( 'Customize “%s”' ), $name ) ) . '"1578 . data-customize-template="' . esc_attr( $template ) . '" data-customize-stylesheet="' . esc_attr( $stylesheet ) . '"';1579 1580 1574 $activate_link = add_query_arg( array( 1581 1575 'action' => 'activate', … … 1585 1579 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $template ); 1586 1580 1587 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if- js" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';1588 $update_actions['preview'] .= '<a href="#" class="hide-if-no-js load-customize" ' . $customize_attributes . '>' . __('Customize') . '</a>';1581 $update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr(sprintf(__('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>'; 1582 $update_actions['preview'] .= '<a ' . wp_customize_href( $template, $stylesheet ) . ' class="hide-if-no-customize load-customize">' . __('Customize') . '</a>'; 1589 1583 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>'; 1590 1584 -
trunk/wp-admin/themes.php
r20459 r20476 68 68 69 69 wp_enqueue_script( 'theme' ); 70 wp_ customize_loader();70 wp_enqueue_script( 'customize-loader' ); 71 71 72 72 endif; … … 123 123 124 124 <div class="theme-options"> 125 <a href="#" class="load-customize hide-if-no-js" data-customize-template="<?php echo esc_attr( $ct->get_template() ); ?>" data-customize-stylesheet="<?php echo esc_attr( $ct->get_stylesheet() ); ?>" title="<?php echo esc_attr( sprintf( __( 'Customize “%s”' ), $ct->get('Name') ) ); ?>"><?php _e( 'Customize' )?></a>125 <a <?php echo wp_customize_href( $ct->get_template(), $ct->get_stylesheet() ); ?> class="load-customize hide-if-no-customize" title="<?php echo esc_attr( sprintf( __( 'Customize “%s”' ), $ct->get('Name') ) ); ?>"><?php _e( 'Customize' )?></a> 126 126 <span><?php _e( 'Options:' )?></span> 127 127 <?php -
trunk/wp-admin/update.php
r20419 r20476 153 153 check_admin_referer('upgrade-theme_' . $theme); 154 154 155 wp_ customize_loader();155 wp_enqueue_script( 'customize-loader' ); 156 156 157 157 $title = __('Update Theme'); … … 205 205 wp_die($api); 206 206 207 wp_customize_loader();207 wp_enqueue_script( 'customize-loader' ); 208 208 209 209 $title = __('Install Themes'); … … 231 231 $file_upload = new File_Upload_Upgrader('themezip', 'package'); 232 232 233 wp_ customize_loader();233 wp_enqueue_script( 'customize-loader' ); 234 234 235 235 $title = __('Upload Theme'); -
trunk/wp-includes/css/customize-controls.dev.css
r20456 r20476 183 183 } 184 184 185 #customize-preview {186 position: fixed;187 left: 300px;188 right: 0;189 top: 0;190 bottom: 0;191 }192 193 185 #customize-preview iframe { 194 186 width: 100%; -
trunk/wp-includes/customize-controls.php
r20404 r20476 51 51 <input type="hidden" id="customize-stylesheet" name="stylesheet" value="<?php echo esc_attr( $theme['Stylesheet'] ); ?>" /> 52 52 53 <div id="customize-header-actions" class="customize-section wp-full-overlay-header"> </div> 53 <div id="customize-header-actions" class="customize-section wp-full-overlay-header"> 54 <a class="back" href="<?php echo esc_url( admin_url( 'themes.php' ) ); ?>"> 55 <?php printf( __( '← Return to %s' ), __('Manage Themes') ); ?> 56 </a> 57 </div> 54 58 55 59 <div id="customize-info" class="customize-section"> … … 80 84 submit_button( __( 'Save' ), 'primary', 'save', false ); 81 85 ?> 86 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>"> 87 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span> 88 <span class="collapse-sidebar-arrow"></span> 89 </a> 82 90 </div> 83 91 </form> … … 96 104 'controls' => array(), 97 105 'prefix' => WP_Customize_Setting::name_prefix, 106 'parent' => esc_url( admin_url() ), 98 107 ); 99 108 -
trunk/wp-includes/js/customize-base.dev.js
r20344 r20476 458 458 var message; 459 459 460 data = data || {}; 461 460 462 if ( ! this.url() ) 461 463 return; -
trunk/wp-includes/js/customize-controls.dev.js
r20344 r20476 217 217 */ 218 218 initialize: function( params, options ) { 219 var self = this; 220 219 221 $.extend( this, options || {} ); 220 222 … … 288 290 e.preventDefault(); 289 291 }); 292 293 // Create a potential postMessage connection with the parent frame. 294 this.parent = new api.Messenger( api.settings.parent ); 295 296 // If we receive a 'back' event, we're inside an iframe. 297 // Send any clicks to the 'Return' link to the parent page. 298 this.parent.bind( 'back', function( text ) { 299 self.form.find('.back').text( text ).click( function( event ) { 300 event.preventDefault(); 301 self.parent.send( 'close' ); 302 }); 303 }); 304 305 // Initialize the connection with the parent frame. 306 this.parent.send( 'ready' ); 290 307 }, 291 308 loader: function() { … … 338 355 339 356 // Initialize Previewer 340 var previewer = new api.Previewer({ 341 iframe: '#customize-preview iframe', 342 form: '#customize-controls', 343 url: api.settings.preview 344 }); 357 var body = $( document.body ), 358 previewer = new api.Previewer({ 359 iframe: '#customize-preview iframe', 360 form: '#customize-controls', 361 url: api.settings.preview 362 }); 345 363 346 364 $.each( api.settings.settings, function( id, data ) { … … 381 399 382 400 // Button bindings. 383 $('#save').click( function( ) {401 $('#save').click( function( event ) { 384 402 previewer.submit(); 385 return false; 403 event.preventDefault(); 404 }); 405 406 $('.collapse-sidebar').click( function( event ) { 407 body.toggleClass( 'collapsed' ); 408 event.preventDefault(); 386 409 }); 387 410 -
trunk/wp-includes/js/customize-loader.dev.js
r20419 r20476 3 3 4 4 (function( exports, $ ){ 5 var Loader = { 5 var api = wp.customize, 6 Loader; 7 8 Loader = { 6 9 initialize: function() { 7 this.body = $( document.body ); 8 this.element = $( '#customize-container' ); 9 this.base = $( '.admin-url', this.element ).val(); 10 this.body = $( document.body ).addClass('customize-support'); 11 this.element = $( '<div id="customize-container" class="wp-full-overlay" />' ).appendTo( this.body ); 10 12 11 this.element.on( 'click', '.close-full-overlay', function() { 12 Loader.close(); 13 return false; 13 $('#wpbody').on( 'click', '.load-customize', function( event ) { 14 event.preventDefault(); 15 16 // Load the theme. 17 Loader.open( $(this).attr('href') ); 18 }); 19 }, 20 open: function( src ) { 21 this.iframe = $( '<iframe />', { src: src }).appendTo( this.element ); 22 23 // Create a postMessage connection with the iframe. 24 this.messenger = new api.Messenger( src, this.iframe[0].contentWindow ); 25 26 // Wait for the connection from the iframe before sending any postMessage events. 27 this.messenger.bind( 'ready', function() { 28 Loader.messenger.send( 'back', wpCustomizeLoaderL10n.back ); 14 29 }); 15 30 16 this.element.on( 'click', '.collapse-sidebar', function() { 17 Loader.element.toggleClass('collapsed'); 18 return false; 31 this.messenger.bind( 'close', function() { 32 Loader.close(); 19 33 }); 20 },21 open: function( params ) {22 params.customize = 'on';23 24 this.iframe = $( '<iframe />', {25 src: this.base + '?' + jQuery.param( params )26 }).appendTo( this.element );27 34 28 35 this.element.fadeIn( 200, function() { … … 33 40 this.element.fadeOut( 200, function() { 34 41 Loader.iframe.remove(); 35 Loader.iframe = null; 42 Loader.iframe = null; 43 Loader.messenger = null; 36 44 Loader.body.removeClass( 'customize-active full-overlay-active' ); 37 45 }); … … 40 48 41 49 $( function() { 42 Loader.initialize(); 43 44 $('#wpbody').on( 'click', '.load-customize', function( event ) { 45 var load = $(this); 46 47 event.preventDefault(); 48 49 // Load the theme. 50 Loader.open({ 51 template: load.data('customizeTemplate'), 52 stylesheet: load.data('customizeStylesheet') 53 }); 54 }); 50 if ( !! window.postMessage ) 51 Loader.initialize(); 55 52 }); 56 53 57 54 // Expose the API to the world. 58 exports.CustomizeLoader = Loader;55 api.Loader = Loader; 59 56 })( wp, jQuery ); -
trunk/wp-includes/js/customize-preview.dev.js
r20259 r20476 14 14 var self = this; 15 15 16 $.extend( this, options || {} ); 17 18 api.Messenger.prototype.initialize.call( this, url ); 16 api.Messenger.prototype.initialize.call( this, url, null, options ); 19 17 20 18 this.body = $( document.body ); … … 30 28 event.preventDefault(); 31 29 }); 32 33 this.bind( 'url', function( url ) {34 this.url( url );35 this.refresh();36 });37 },38 refresh: function() {39 this.submit({40 target: this.iframe.prop('name'),41 action: this.url()42 });43 },44 submit: function( props ) {45 if ( props )46 this.form.prop( props );47 this.form.submit();48 if ( props )49 this.form.prop( this._formOriginalProps );50 30 } 51 31 }); -
trunk/wp-includes/script-loader.php
r20456 r20476 299 299 $scripts->add( 'hoverIntent', "/wp-includes/js/hoverIntent$suffix.js", array('jquery'), 'r6', 1 ); 300 300 301 $scripts->add( 'customize- loader', "/wp-includes/js/customize-loader$suffix.js", array( 'jquery' ), false, 1 );302 $scripts->add( 'customize- base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery-postmessage', 'json2' ), false, 1 );301 $scripts->add( 'customize-base', "/wp-includes/js/customize-base$suffix.js", array( 'jquery-postmessage', 'json2' ), false, 1 ); 302 $scripts->add( 'customize-loader', "/wp-includes/js/customize-loader$suffix.js", array( 'customize-base' ), false, 1 ); 303 303 $scripts->add( 'customize-controls', "/wp-includes/js/customize-controls$suffix.js", array( 'customize-base' ), false, 1 ); 304 $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 );304 $scripts->add( 'customize-preview', "/wp-includes/js/customize-preview$suffix.js", array( 'customize-base' ), false, 1 ); 305 305 306 306 if ( is_admin() ) { -
trunk/wp-includes/theme.php
r20419 r20476 1584 1584 1585 1585 /** 1586 * Includes the loading scripts for the theme customizer and 1587 * adds the action to print the customize container template. 1586 * Localizes the customize-loader script. 1588 1587 * 1589 1588 * @since 3.4.0 1590 1589 */ 1591 function wp_customize_loader() { 1592 wp_enqueue_script( 'customize-loader' ); 1593 add_action( 'admin_footer', '_wp_customize_loader_template' ); 1594 } 1595 1596 /** 1597 * Print the customize container template. 1590 function _wp_customize_loader_localize() { 1591 wp_localize_script( 'customize-loader', 'wpCustomizeLoaderL10n', array( 1592 'back' => sprintf( __( '← Return to %s' ), get_admin_page_title() ), 1593 ) ); 1594 } 1595 add_action( 'admin_enqueue_scripts', '_wp_customize_loader_localize' ); 1596 1597 /** 1598 * Returns a URL to load the theme customizer. 1598 1599 * 1599 1600 * @since 3.4.0 1600 1601 */ 1601 function _wp_customize_loader_template() { 1602 ?> 1603 <div id="customize-container" class="wp-full-overlay"> 1604 <input type="hidden" class="admin-url" value="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>" /> 1605 <a href="#" class="close-full-overlay"><?php printf( __( '← Return to %s' ), get_admin_page_title() ); ?></a> 1606 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>"> 1607 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span> 1608 <span class="collapse-sidebar-arrow"></span> 1609 </a> 1610 </div> 1611 <?php 1612 } 1602 function wp_customize_url( $template, $stylesheet = null ) { 1603 $stylesheet = isset( $stylesheet ) ? $stylesheet : $template; 1604 return admin_url( 'admin.php' ) . '?customize=on&template=' . $template . '&stylesheet=' . $stylesheet; 1605 } 1606 1607 /** 1608 * Prints an href attribute to load the theme customizer. 1609 * 1610 * @since 3.4.0 1611 */ 1612 function wp_customize_href( $template, $stylesheet = null ) { 1613 $link = wp_customize_url( $template, $stylesheet ); 1614 return 'href="' . esc_url( $link ) . '"'; 1615 }
Note: See TracChangeset
for help on using the changeset viewer.