Ticket #27403: 27403.9.diff
File 27403.9.diff, 11.6 KB (added by , 9 years ago) |
---|
-
src/wp-admin/js/customize-controls.js
diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js index e354d0d..498c678 100644
5091 5091 5092 5092 $( '.collapse-sidebar' ).on( 'click', function() { 5093 5093 api.state( 'paneVisible' ).set( ! api.state( 'paneVisible' ).get() ); 5094 api.previewer.send( 'collapse-sidebar', ! api.state( 'paneVisible' ).get() ); 5094 5095 }); 5095 5096 5096 5097 api.state( 'paneVisible' ).bind( function( paneVisible ) { -
src/wp-includes/css/customize-preview.css
diff --git src/wp-includes/css/customize-preview.css src/wp-includes/css/customize-preview.css index 75251ea..2cc88be 100644
10 10 -webkit-box-shadow: none; 11 11 box-shadow: none; 12 12 } 13 14 .customize-partial-icon { 15 position: relative; 16 float: left; 17 width: 0; 18 height: 0; 19 padding: 0; 20 margin: 0; 21 border: 0; 22 } 23 24 .customize-partial-icon:active { 25 padding: 0; 26 border: 0; 27 } 28 29 .customize-partial-icon:before { 30 position: absolute; 31 left: -36px; 32 fill: #fff; 33 width: 30px; 34 height: 30px; 35 font-size: 18px; 36 font-family: genericons; 37 content: '\f411'; 38 z-index: 5; 39 background-color: #0085ba; 40 border-radius: 50%; 41 border: 2px solid #fff; 42 box-shadow: 0 2px 1px rgba(46,68,83,0.15); 43 text-align: center; 44 display: flex; 45 flex-direction: row; 46 justify-content: center; 47 align-items: center; 48 cursor: pointer; 49 padding: 0; 50 animation-delay: 0.8s; 51 animation-fill-mode: both; 52 animation-duration: .75s; 53 opacity: 0; 54 pointer-events: none; 55 } 56 57 body.customize-partial-icons-shown .customize-partial-icon:before { 58 animation-name: bounce-appear; 59 pointer-events: auto; 60 } 61 body.customize-partial-icons-hidden .customize-partial-icon:before { 62 animation-name: bounce-disappear; 63 pointer-events: none; 64 } 65 66 .page-sidebar-collapsed .customize-partial-icon:before, 67 .customize-partial-icon--hidden:before { 68 visibility: hidden; 69 } 70 71 .customize-partial-icon--left-margin:before { 72 left: 0; 73 } 74 75 .customize-partial-icon svg { 76 width: 18px; 77 height: 18px; 78 } 79 80 @keyframes bounce-appear { 81 from, 20%, 40%, 60%, 80%, to { 82 animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); 83 } 84 0% { 85 opacity: 0; 86 transform: scale3d(.3, .3, .3); 87 } 88 20% { 89 transform: scale3d(1.1, 1.1, 1.1); 90 } 91 40% { 92 transform: scale3d(.9, .9, .9); 93 } 94 60% { 95 opacity: 1; 96 transform: scale3d(1.03, 1.03, 1.03); 97 } 98 80% { 99 transform: scale3d(.97, .97, .97); 100 } 101 to { 102 opacity: 1; 103 transform: scale3d(1, 1, 1); 104 } 105 } 106 107 @keyframes bounce-disappear { 108 from, 20%, 40%, 60%, 80%, to { 109 animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000); 110 } 111 0% { 112 opacity: 1; 113 transform: scale3d(1, 1, 1); 114 } 115 20% { 116 transform: scale3d(.97, .97, .97); 117 } 118 40% { 119 opacity: 1; 120 transform: scale3d(1.03, 1.03, 1.03); 121 } 122 60% { 123 transform: scale3d(.9, .9, .9); 124 } 125 80% { 126 transform: scale3d(1.1, 1.1, 1.1); 127 } 128 to { 129 opacity: 0; 130 transform: scale3d(.3, .3, .3); 131 } 132 } -
src/wp-includes/customize/class-wp-customize-selective-refresh.php
diff --git src/wp-includes/customize/class-wp-customize-selective-refresh.php src/wp-includes/customize/class-wp-customize-selective-refresh.php index 6864eba..2342aef 100644
final class WP_Customize_Selective_Refresh { 184 184 'renderQueryVar' => self::RENDER_QUERY_VAR, 185 185 'l10n' => array( 186 186 'shiftClickToEdit' => __( 'Shift-click to edit this element.' ), 187 'clickEditMenu' => __( 'Click to edit this menu.' ), 188 'clickEditWidget' => __( 'Click to edit this widget.' ), 189 'clickEditTitle' => __( 'Click to edit the site title.' ), 190 'clickEditMisc' => __( 'Click to edit this element.' ), 187 191 /* translators: %s: document.write() */ 188 192 'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ), 189 193 ), -
src/wp-includes/js/customize-preview-widgets.js
diff --git src/wp-includes/js/customize-preview-widgets.js src/wp-includes/js/customize-preview-widgets.js index 967d56a..6c05e89 100644
wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function( 357 357 widgetPartial = new self.WidgetPartial( partialId, { 358 358 params: {} 359 359 } ); 360 api.selectiveRefresh.partial.add( widgetPartial.id, widgetPartial );361 360 } 362 361 363 362 // Make sure that there is a container element for the widget in the sidebar, if at least a placeholder. … … wp.customize.widgetsPreview = wp.customize.WidgetCustomizerPreview = (function( 400 399 wasInserted = true; 401 400 } ); 402 401 402 api.selectiveRefresh.partial.add( widgetPartial.id, widgetPartial ); 403 403 404 if ( wasInserted ) { 404 405 sidebarPartial.reflowWidgets(); 405 406 } -
src/wp-includes/js/customize-selective-refresh.js
diff --git src/wp-includes/js/customize-selective-refresh.js src/wp-includes/js/customize-selective-refresh.js index 427a7c3..ba319fc 100644
wp.customize.selectiveRefresh = ( function( $, api ) { 18 18 19 19 _.extend( self, api.Events ); 20 20 21 // Extend jQuery to notice element removal and call the 'destroyed' event 22 $.event.special.destroyed = { 23 remove: function( o ) { 24 if ( o.handler ) { 25 o.handler(); 26 } 27 } 28 }; 29 21 30 /** 22 31 * A Customizer Partial. 23 32 * … … wp.customize.selectiveRefresh = ( function( $, api ) { 42 51 43 52 id: null, 44 53 45 54 /** 46 55 * Constructor. 47 56 * 48 57 * @since 4.5.0 … … wp.customize.selectiveRefresh = ( function( $, api ) { 84 93 var partial = this; 85 94 _.each( _.pluck( partial.placements(), 'container' ), function( container ) { 86 95 $( container ).attr( 'title', self.data.l10n.shiftClickToEdit ); 96 partial.createEditIconForElement( container ); 87 97 } ); 88 98 $( document ).on( 'click', partial.params.selector, function( e ) { 89 99 if ( ! e.shiftKey ) { … … wp.customize.selectiveRefresh = ( function( $, api ) { 99 109 }, 100 110 101 111 /** 112 * Create and show the edit icon for this element. 113 */ 114 createEditIconForElement: function( element ) { 115 var partial = this; 116 var $icon = this.createEditIcon(); 117 var $element = $( element ); 118 $element.before( $icon ); 119 partial.positionEditIcon( $element, $icon ); 120 $icon.on( 'click', function( evt ) { 121 partial.showControl(); 122 } ); 123 $element.on( 'destroyed', function() { 124 $icon.remove(); 125 partial.editIcon = null; 126 } ); 127 api.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { 128 partial.refreshEditIcon( placement.container ); 129 } ); 130 api.selectiveRefresh.bind( 'partial-content-moved', function( placement ) { 131 partial.refreshEditIcon( placement.container ); 132 } ); 133 // TODO: this should be somewhere global 134 api.preview.bind( 'collapse-sidebar', function( collapsed ) { 135 $( document.body ).toggleClass( 'page-sidebar-collapsed' ); 136 } ); 137 partial.editIcon = $icon; 138 }, 139 140 hideEditIcon: function() { 141 var partial = this; 142 if ( partial.editIcon ) { 143 partial.editIcon.addClass( 'customize-partial-icon--hidden' ); 144 } 145 }, 146 147 showEditIcon: function() { 148 var partial = this; 149 if ( partial.editIcon ) { 150 partial.editIcon.removeClass( 'customize-partial-icon--hidden' ); 151 } 152 }, 153 154 refreshEditIcon: function( element ) { 155 var partial = this; 156 if ( ! partial.editIcon ) { 157 this.createEditIconForElement( element ); 158 } 159 }, 160 161 positionEditIcon: function( $element, $icon ) { 162 var partial = this; 163 if ( $element.css( 'position' ) === 'absolute' ) { 164 $icon.css( partial.getCalculatedCssForEditIcon( $element ) ); 165 partial.whenPageChanges( function() { 166 $icon.css( partial.getCalculatedCssForEditIcon( $element ) ); 167 } ); 168 } 169 if ( ! $element.is( ':visible' ) || $element.css( 'display' ) === 'none' ) { 170 $icon.addClass( 'customize-partial-icon--hidden' ); 171 } 172 var left = $element.offset().left; 173 if ( left < 1 ) { 174 $icon.addClass( 'customize-partial-icon--left-margin' ); 175 } 176 }, 177 178 whenPageChanges: function( callback ) { 179 var debouncedCallaback = _.debounce( function() { 180 // Timeout allows any page animations to finish 181 setTimeout( callback, 100 ); 182 }, 350 ); 183 // When window is resized 184 $( window ).resize( debouncedCallaback ); 185 // When any customizer setting changes 186 api.bind( 'change', debouncedCallaback ); 187 var $document = $( window.document ); 188 // After scroll in case there are fixed position elements 189 $document.on( 'scroll', debouncedCallaback ); 190 // After page click (eg: hamburger menus) 191 $document.on( 'click', debouncedCallaback ); 192 }, 193 194 getCalculatedCssForEditIcon: function( $target ) { 195 var hiddenIconPos = ( 'rtl' === window.document.dir ) ? { right: -1000, left: 'auto' } : { left: -1000, right: 'auto' }; 196 if ( ! $target.is( ':visible' ) ) { 197 return hiddenIconPos; 198 } 199 var top = $target.css( 'top' ); 200 var left = $target.css( 'left' ); 201 return { top: top, left: left, right: 'auto' }; 202 }, 203 204 getIconClassName: function() { 205 var partial = this; 206 var cleanId = partial.id.replace( /\]/g, '' ).replace( /\[/g, '-' ); 207 return 'customize-partial-icon-' + cleanId; 208 }, 209 210 getIconTitle: function() { 211 var l10n = self.data.l10n; 212 switch ( this.getType() ) { 213 case 'widget': 214 return l10n.clickEditWidget; 215 case 'blogname': 216 return l10n.clickEditTitle; 217 case 'blogdescription': 218 return l10n.clickEditTitle; 219 case 'nav_menu': 220 return l10n.clickEditMenu; 221 default: 222 return l10n.clickEditMisc; 223 } 224 }, 225 226 getType: function() { 227 var partial = this; 228 var settingId = partial.params.primarySetting || _.first( partial.settings() ) || 'unknown'; 229 if ( partial.params.type ) { 230 return partial.params.type; 231 } 232 if ( settingId.match( /^nav_menu_instance/ ) ) { 233 return 'nav_menu'; 234 } 235 if ( settingId.match( /^widget_/ ) ) { 236 return 'widget'; 237 } 238 return settingId; 239 }, 240 241 createEditIcon: function() { 242 var iconTitle = this.getIconTitle(); 243 return $( '<button aria-label="' + iconTitle + '" title="' + iconTitle + '" type="button" class="customize-partial-icon ' + this.getIconClassName() + '"/>' ); 244 }, 245 246 /** 102 247 * Find all placements for this partial int he document. 103 248 * 104 249 * @since 4.5.0 … … wp.customize.selectiveRefresh = ( function( $, api ) { 179 324 if ( ! settingId ) { 180 325 settingId = _.first( partial.settings() ); 181 326 } 327 if ( this.getType() === 'nav_menu' ) { 328 var menuSlug = partial.params.navMenuArgs.theme_location; 329 if ( menuSlug ) { 330 settingId = 'nav_menu_locations[' + menuSlug + ']'; 331 } 332 } 182 333 api.preview.send( 'focus-control-for-setting', settingId ); 183 334 }, 184 335 … … wp.customize.selectiveRefresh = ( function( $, api ) { 855 1006 } ); 856 1007 857 1008 api.preview.bind( 'active', function() { 1009 var body = $( document.body ); 858 1010 859 1011 // Make all partials ready. 860 1012 self.partial.each( function( partial ) { … … wp.customize.selectiveRefresh = ( function( $, api ) { 865 1017 self.partial.bind( 'add', function( partial ) { 866 1018 partial.deferred.ready.resolve(); 867 1019 } ); 1020 1021 body.on( 'click', function( event ) { 1022 if ( $( event.target ).is( '.customize-partial-icon, :input, a[href]' ) ) { 1023 return; 1024 } 1025 if ( body.hasClass( 'customize-partial-icons-shown' ) ) { 1026 body.removeClass( 'customize-partial-icons-shown' ); 1027 body.addClass( 'customize-partial-icons-hidden' ); 1028 } else { 1029 body.addClass( 'customize-partial-icons-shown' ); 1030 body.removeClass( 'customize-partial-icons-hidden' ); 1031 } 1032 } ); 868 1033 } ); 869 1034 870 1035 } );