Ticket #42022: 42022.3.diff
File 42022.3.diff, 37.9 KB (added by , 7 years ago) |
---|
-
src/wp-admin/css/customize-controls.css
diff --git src/wp-admin/css/customize-controls.css src/wp-admin/css/customize-controls.css index 09302a8a34..73ed81c775 100644
body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 148 148 } 149 149 150 150 #customize-controls .date-input:invalid { 151 border-color: red; 152 } 153 154 .date-time-fields .month-field { 155 width: 79px; 156 } 157 158 .date-time-fields .day-field, 159 .date-time-fields .hour-field, 160 .date-time-fields .minute-field { 161 width: 46px; 162 } 163 164 .date-time-fields .year-field { 165 width: 60px; 166 } 167 168 .date-time-fields .am-pm-field { 169 width: 53px; 151 border-color: #dc3232; 170 152 } 171 153 172 154 #customize-control-changeset_status label { … … body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 200 182 201 183 .customize-copy-preview-link:before, 202 184 .customize-copy-preview-link:after { 203 content: '';185 content: ""; 204 186 height: 28px; 205 187 position: absolute; 206 188 background: #ffffff; … … body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 225 207 border-left: none; 226 208 border-right: none; 227 209 text-indent: -999px; 228 color: white;210 color: #fff; 229 211 } 230 212 231 213 #customize-control-changeset_preview_link label { … … body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 233 215 display: block; 234 216 } 235 217 236 #customize-control-changeset_preview_link a .preview-control-element{218 #customize-control-changeset_preview_link a { 237 219 display: inline-block; 238 220 position: absolute; 239 221 white-space: nowrap; … … body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 244 226 text-decoration: none; 245 227 } 246 228 247 #customize-control-changeset_preview_link a. preview-control-element.disabled,248 #customize-control-changeset_preview_link a. preview-control-element.disabled:active,249 #customize-control-changeset_preview_link a. preview-control-element.disabled:focus,250 #customize-control-changeset_preview_link a. preview-control-element.disabled:visited {229 #customize-control-changeset_preview_link a.disabled, 230 #customize-control-changeset_preview_link a.disabled:active, 231 #customize-control-changeset_preview_link a.disabled:focus, 232 #customize-control-changeset_preview_link a.disabled:visited { 251 233 color: black; 252 234 opacity: 0.4; 253 235 cursor: default; … … body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 268 250 padding-bottom:10px; 269 251 } 270 252 271 . date-time-fields label,272 . date-time-fields .date-time-separator {253 .customize-control.customize-control-date_time .date-time-fields .date-input, 254 .customize-control.customize-control-date_time .date-time-fields .date-time-separator { 273 255 float: left; 274 margin-right:5px; 256 margin-right: 5px; 257 } 258 259 .date-time-fields .date-input.month { 260 width: 79px; 261 margin: 0; 262 } 263 264 .date-time-fields .date-input.day, 265 .date-time-fields .date-input.hour, 266 .date-time-fields .date-input.minute { 267 width: 46px; 268 } 269 270 .date-time-fields .date-input.year { 271 width: 60px; 272 } 273 274 .date-time-fields .date-input.meridian { 275 width: 53px; 276 margin: 0; 275 277 } 276 278 277 279 .date-time-fields .date-time-separator { … … body.outer-section-open .wp-full-overlay.expanded .wp-full-overlay-main { 279 281 } 280 282 281 283 .date-time-fields .time-row { 282 padding-top: 12px;284 margin-top: 12px; 283 285 } 284 286 285 287 .date-time-fields .date-timezone { … … p.customize-section-description { 1010 1012 } 1011 1013 1012 1014 .customize-control-dropdown-pages .new-content-item .create-item-input.invalid { 1013 border: 1px solid # f00;1015 border: 1px solid #dc3232; 1014 1016 } 1015 1017 1016 1018 .customize-control-dropdown-pages .add-new-toggle { … … p.customize-section-description { 1136 1138 margin-bottom: 0; 1137 1139 } 1138 1140 #customize-control-show_on_front.has-error .customize-control-notifications-container { 1139 margin-top: 12px;1141 margin-top: 12px; 1140 1142 } 1141 1143 1142 1144 /** … … p.customize-section-description { 1321 1323 content: ''; 1322 1324 position: absolute; 1323 1325 height: auto; 1324 top: 0; left: 0; bottom: 0; right: 0; 1326 top: 0; 1327 left: 0; 1328 bottom: 0; 1329 right: 0; 1325 1330 border: 4px solid #00a0d2; 1326 1331 border-radius: 2px; 1327 1332 } … … body.adding-widget .add-new-widget:before, 2659 2664 height: 39px; 2660 2665 } 2661 2666 2662 .date-time-fields . month-field{2667 .date-time-fields .date-input.month { 2663 2668 width: 79px; 2664 2669 } 2665 2670 2666 .date-time-fields .da y-field,2667 .date-time-fields . hour-field,2668 .date-time-fields . minute-field{2671 .date-time-fields .date-input.day, 2672 .date-time-fields .date-input.hour, 2673 .date-time-fields .date-input.minute { 2669 2674 width: 55px; 2670 2675 } 2671 2676 2672 .date-time-fields . year-field{2677 .date-time-fields .date-input.year { 2673 2678 width: 80px; 2674 2679 } 2675 2680 2681 .date-time-fields .date-time-separator, 2676 2682 .date-time-fields .date-timezone { 2677 2683 line-height: 3.2; 2678 2684 } 2685 2679 2686 .wp-core-ui.wp-customizer .button { 2680 2687 margin-top: 12px; 2681 2688 } -
src/wp-admin/css/customize-nav-menus.css
diff --git src/wp-admin/css/customize-nav-menus.css src/wp-admin/css/customize-nav-menus.css index f9d8f81703..36138ca2a3 100644
132 132 133 133 .customize-control input.menu-name-field { 134 134 width: 100%; /* Override the 98% default for customizer inputs, to align with the size of menu items. */ 135 margin: 12px 0;136 135 } 137 136 138 137 .wp-customizer .menu-item .item-edit { -
src/wp-admin/js/customize-controls.js
diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js index 70dff7403d..e7ad7597b5 100644
4908 4908 */ 4909 4909 api.DateTimeControl = api.Control.extend({ 4910 4910 4911 dateInputs: {},4912 inputElements: {},4913 invalidDate: false,4914 4915 4911 /** 4916 4912 * Initialize behaviors. 4917 4913 * … … 4921 4917 ready: function ready() { 4922 4918 var control = this; 4923 4919 4924 _.bindAll( control, 'populateSetting', 'updateDaysForMonth', 'updateMinutesForHour' ); 4920 control.inputElements = {}; 4921 control.invalidDate = false; 4925 4922 4926 control.dateInputs = control.container.find( '.date-input' );4923 _.bindAll( control, 'populateSetting', 'updateDaysForMonth', 'updateMinutesForHour', 'populateDateInputs' ); 4927 4924 4928 4925 // @todo This needs https://core.trac.wordpress.org/ticket/37964 4929 4926 if ( ! control.setting ) { 4930 4927 control.setting = new api.Value(); 4931 4928 } 4932 4929 4930 // @todo Should this be? Default should be on client. The default value should be in the setting itself. 4933 4931 if ( ! control.setting.get() && control.params.defaultValue ) { 4934 4932 control.setting.set( control.params.defaultValue ); 4935 4933 } 4936 4934 4937 control. dateInputs.each( function() {4935 control.container.find( '.date-input' ).each( function() { 4938 4936 var input = $( this ), component, element; 4939 4937 component = input.data( 'component' ); 4940 4938 element = new api.Element( input ); 4941 element.validate = function( value ) { 4942 return _.contains( [ 'am', 'pm' ], value ) ? value : parseInt( value, 10 ); 4943 }; 4939 if ( 'meridian' === component ) { 4940 element.validate = function( value ) { 4941 if ( 'am' !== value && 'pm' !== value ) { 4942 return null; 4943 } 4944 return value; 4945 }; 4946 } else { 4947 element.validate = function( value ) { 4948 var val = parseInt( value, 10 ); 4949 if ( isNaN( val ) ) { 4950 return null; 4951 } 4952 return val; 4953 }; 4954 } 4955 element.bind( control.populateSetting ); 4944 4956 control.inputElements[ component ] = element; 4945 4957 control.elements.push( element ); 4946 4958 } ); 4947 4959 4948 control.dateInputs.on( 'input', control.populateSetting );4949 4960 control.inputElements.month.bind( control.updateDaysForMonth ); 4950 4961 control.inputElements.year.bind( control.updateDaysForMonth ); 4951 4962 control.inputElements.hour.bind( control.updateMinutesForHour ); 4952 4963 control.populateDateInputs(); 4964 control.setting.bind( control.populateDateInputs ); 4953 4965 }, 4954 4966 4955 4967 /** … … 4984 4996 4985 4997 if ( twelveHourFormat ) { 4986 4998 date.hour = parseInt( date.hour, 10 ); 4987 date. ampm= date.hour >= midDayHour ? 'pm' : 'am';4999 date.meridian = date.hour >= midDayHour ? 'pm' : 'am'; 4988 5000 date.hour = date.hour % midDayHour ? String( date.hour % midDayHour ) : String( midDayHour ); 4989 5001 delete date.second; 4990 5002 } … … 5004 5016 control.invalidDate = false; 5005 5017 5006 5018 _.each( [ 'day', 'hour', 'year', 'minute' ], function( component ) { 5007 var element, el, max, min, maxLength,value;5019 var element, el, max, min, value; 5008 5020 5009 5021 if ( ! control.invalidDate ) { 5010 5022 element = control.inputElements[ component ]; 5011 5023 el = element.element.get( 0 ); 5012 5024 max = parseInt( element.element.attr( 'max' ), 10 ); 5013 5025 min = parseInt( element.element.attr( 'min' ), 10 ); 5014 maxLength = parseInt( element.element.attr( 'maxlength' ), 10 );5015 5026 value = element(); 5016 control.invalidDate = value > max || value < min || String( value ).length > maxLength;5027 control.invalidDate = value > max || value < min; 5017 5028 errorMessage = control.invalidDate ? api.l10n.invalid + ' ' + component : ''; 5018 5029 5019 5030 el.setCustomValidity( errorMessage ); 5020 _.result( el, 'reportValidity' ); 5031 if ( ! control.section() || api.section.has( control.section() ) && api.section( control.section() ).expanded() ) { 5032 _.result( el, 'reportValidity' ); 5033 } 5021 5034 } 5022 5035 } ); 5023 5036 … … 5056 5069 updateMinutesForHour: function updateMinutesForHour() { 5057 5070 var control = this, maxHours = 24, minuteEl; 5058 5071 5059 if ( control.inputElements. ampm) {5072 if ( control.inputElements.meridian ) { 5060 5073 return; 5061 5074 } 5062 5075 … … 5065 5078 if ( maxHours === control.inputElements.hour() ) { 5066 5079 control.inputElements.minute( 0 ); 5067 5080 minuteEl.data( 'default-max', minuteEl.attr( 'max' ) ); 5068 minuteEl.data( 'default-maxlength', minuteEl.attr( 'maxlength' ) );5069 5081 minuteEl.attr( 'max', '0' ); 5070 5082 } else if ( minuteEl.data( 'default-max' ) ) { 5071 5083 minuteEl.attr( 'max', minuteEl.data( 'default-max' ) ); 5072 minuteEl.attr( 'maxlength', minuteEl.data( 'maxlength' ) );5073 5084 } 5074 5085 }, 5075 5086 … … 5121 5132 return value; 5122 5133 }; 5123 5134 5124 hourInTwentyFourHourFormat = control.inputElements. ampm ? control.convertHourToTwentyFourHourFormat( control.inputElements.hour(), control.inputElements.ampm() ) : control.inputElements.hour();5135 hourInTwentyFourHourFormat = control.inputElements.meridian ? control.convertHourToTwentyFourHourFormat( control.inputElements.hour(), control.inputElements.meridian() ) : control.inputElements.hour(); 5125 5136 dateFormat = [ 'year', '-', 'month', '-', 'day', ' ', pad( hourInTwentyFourHourFormat, 2 ), ':', 'minute', ':', '00' ]; 5126 5137 5127 5138 _.each( dateFormat, function( component ) { … … 5146 5157 * Convert hour in twelve hour format to twenty four hour format. 5147 5158 * 5148 5159 * @since 4.9.0 5149 * @param {string} hourInTwelveHourFormat Hour in twelve hour format.5150 * @param {string} ampm am/pm5151 * @return {string} Hour in twenty four hour format.5160 * @param {string} hourInTwelveHourFormat - Hour in twelve hour format. 5161 * @param {string} meridian - Either 'am' or 'pm'. 5162 * @returns {string} Hour in twenty four hour format. 5152 5163 */ 5153 convertHourToTwentyFourHourFormat: function convertHour( hourInTwelveHourFormat, ampm) {5164 convertHourToTwentyFourHourFormat: function convertHour( hourInTwelveHourFormat, meridian ) { 5154 5165 var hourInTwentyFourHourFormat, hour, midDayHour = 12; 5155 5166 5156 5167 hour = parseInt( hourInTwelveHourFormat, 10 ); 5168 if ( isNaN( hour ) ) { 5169 return ''; 5170 } 5157 5171 5158 if ( 'pm' === ampm&& hour < midDayHour ) {5172 if ( 'pm' === meridian && hour < midDayHour ) { 5159 5173 hourInTwentyFourHourFormat = hour + midDayHour; 5160 } else if ( 'am' === ampm&& midDayHour === hour ) {5174 } else if ( 'am' === meridian && midDayHour === hour ) { 5161 5175 hourInTwentyFourHourFormat = hour - midDayHour; 5162 5176 } else { 5163 5177 hourInTwentyFourHourFormat = hour; … … 5224 5238 */ 5225 5239 api.PreviewLinkControl = api.Control.extend({ 5226 5240 5227 previewElements: {},5228 5229 5241 /** 5230 5242 * Override the templateSelector before embedding the control into the page. 5231 5243 * … … 5245 5257 * @returns {void} 5246 5258 */ 5247 5259 ready: function ready() { 5248 var control = this, element, component, node, link, input, button;5260 var control = this, element, component, node, url, input, button; 5249 5261 5250 5262 _.bindAll( control, 'updatePreviewLink' ); 5251 5263 … … 5253 5265 control.setting = new api.Value(); 5254 5266 } 5255 5267 5268 control.previewElements = {}; 5269 5256 5270 control.container.find( '.preview-control-element' ).each( function() { 5257 5271 node = $( this ); 5258 5272 component = node.data( 'component' ); … … 5261 5275 control.elements.push( element ); 5262 5276 } ); 5263 5277 5264 link = control.previewElements.link;5278 url = control.previewElements.url; 5265 5279 input = control.previewElements.input; 5266 5280 button = control.previewElements.button; 5267 5281 5268 5282 input.link( control.setting ); 5269 link.link( control.setting );5283 url.link( control.setting ); 5270 5284 5271 link.bind( function( value ) { 5272 link.element.attr( 'href', value ); 5273 link.element.attr( 'target', api.settings.changeset.uuid ); 5285 url.bind( function( value ) { 5286 url.element.parent().attr( { 5287 href: value, 5288 target: api.settings.changeset.uuid 5289 } ); 5274 5290 } ); 5275 5291 5276 5292 api.bind( 'ready', control.updatePreviewLink ); 5277 api.bind( 'change', control.updatePreviewLink );5278 5293 api.state( 'saved' ).bind( control.updatePreviewLink ); 5294 api.state( 'changesetStatus' ).bind( control.updatePreviewLink ); 5279 5295 5280 5296 button.element.on( 'click', function( event ) { 5281 5297 event.preventDefault(); … … 5286 5302 } 5287 5303 } ); 5288 5304 5289 link.element.on( 'click', function( event ) {5290 if ( link.element.hasClass( 'disabled' ) ) {5305 url.element.parent().on( 'click', function( event ) { 5306 if ( $( this ).hasClass( 'disabled' ) ) { 5291 5307 event.preventDefault(); 5292 5308 } 5293 5309 } ); … … 5308 5324 updatePreviewLink: function updatePreviewLink() { 5309 5325 var control = this, unsavedDirtyValues; 5310 5326 5311 unsavedDirtyValues = ! _.isEmpty( api.dirtyValues( { 5312 unsaved: true 5313 } ) ); 5327 unsavedDirtyValues = ! api.state( 'saved' ).get() || '' === api.state( 'changesetStatus' ).get() || 'auto-draft' === api.state( 'changesetStatus' ).get(); 5314 5328 5315 5329 control.toggleSaveNotification( unsavedDirtyValues ); 5316 control.previewElements. link.element.toggleClass( 'disabled', unsavedDirtyValues );5330 control.previewElements.url.element.parent().toggleClass( 'disabled', unsavedDirtyValues ); 5317 5331 control.previewElements.button.element.prop( 'disabled', unsavedDirtyValues ); 5318 5332 control.setting.set( api.previewer.getFrontendPreviewUrl() ); 5319 5333 }, … … 6485 6499 } ); 6486 6500 } ); 6487 6501 6488 /** 6489 * Find all invalid setting less controls with notification type error. 6490 */ 6502 // Find all invalid setting less controls with notification type error. 6491 6503 api.control.each( function( control ) { 6492 6504 if ( ! control.setting || ! control.setting.id && control.active.get() ) { 6493 6505 control.notifications.each( function( notification ) { … … 7833 7845 }); 7834 7846 })(); 7835 7847 7836 /** 7837 * Publish settings section and controls. 7838 */ 7848 // Publish settings section and controls. 7839 7849 api.control( 'changeset_status', 'changeset_scheduled_date', function( statusControl, dateControl ) { 7840 7850 $.when( statusControl.deferred.embedded, dateControl.deferred.embedded ).done( function() { 7841 7851 var radioNodes, statusElement, toggleDateControl, publishWhenTime, pollInterval, updateTimeArrivedPoller, timeArrivedPollingInterval = 1000; -
src/wp-includes/class-wp-customize-manager.php
diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php index 95dfa794af..7305a8d6e0 100644
final class WP_Customize_Manager { 3562 3562 </ul> 3563 3563 </script> 3564 3564 <script type="text/html" id="tmpl-customize-preview-link-control" > 3565 <span class="customize-control-title"> 3566 <label><?php esc_html_e( 'Share Preview Link' ); ?></label> 3567 </span> 3568 <span class="description customize-control-description"><?php esc_html_e( 'See how changes would look live on your website, and share the preview with people who can\'t access the Customizer.' ); ?></span> 3565 <# var elementPrefix = _.uniqueId( 'el' ) + '-' #> 3566 <p class="customize-control-title"> 3567 <?php esc_html_e( 'Share Preview Link' ); ?> 3568 </p> 3569 <p class="description customize-control-description"><?php esc_html_e( 'See how changes would look live on your website, and share the preview with people who can\'t access the Customizer.' ); ?></p> 3569 3570 <div class="customize-control-notifications-container"></div> 3570 3571 <div class="preview-link-wrapper"> 3571 <label> 3572 <span class="screen-reader-text"><?php esc_html_e( 'Preview Link' ); ?></span> 3573 <a class="preview-control-element" data-component="link" href="" target=""></a> 3574 <input readonly class="preview-control-element" data-component="input" value="test" > 3575 <button class="customize-copy-preview-link preview-control-element button button-secondary" data-component="button" data-copy-text="<?php esc_attr_e( 'Copy' ); ?>" data-copied-text="<?php esc_attr_e( 'Copied' ); ?>" ><?php esc_html_e( 'Copy' ); ?></button> 3576 </label> 3572 <label for="{{ elementPrefix }}customize-preview-link-input" class="screen-reader-text"><?php esc_html_e( 'Preview Link' ); ?></label> 3573 <a href="" target=""> 3574 <span class="preview-control-element" data-component="url"></span> 3575 <span class="screen-reader-text"><?php _e( '(opens in a new window)' ); ?></span> 3576 </a> 3577 <input id="{{ elementPrefix }}customize-preview-link-input" readonly class="preview-control-element" data-component="input"> 3578 <button class="customize-copy-preview-link preview-control-element button button-secondary" data-component="button" data-copy-text="<?php esc_attr_e( 'Copy' ); ?>" data-copied-text="<?php esc_attr_e( 'Copied' ); ?>" ><?php esc_html_e( 'Copy' ); ?></button> 3577 3579 </div> 3578 3580 </script> 3579 3581 <?php … … final class WP_Customize_Manager { 4171 4173 } else { 4172 4174 $initial_date = current_time( 'mysql', false ); 4173 4175 } 4176 4174 4177 $this->add_control( new WP_Customize_Date_Time_Control( $this, 'changeset_scheduled_date', array( 4175 4178 'section' => 'publish_settings', 4176 4179 'settings' => array(), -
src/wp-includes/class-wp-customize-nav-menus.php
diff --git src/wp-includes/class-wp-customize-nav-menus.php src/wp-includes/class-wp-customize-nav-menus.php index b2f91ceb5c..06228b2b74 100644
final class WP_Customize_Nav_Menus { 674 674 ) ) ); 675 675 676 676 $this->manager->add_control( 'new_menu_name', array( 677 'label' => '',677 'label' => __( 'New menu name' ), 678 678 'section' => 'add_menu', 679 679 'type' => 'text', 680 680 'settings' => array(), 681 681 'input_attrs' => array( 682 682 'class' => 'menu-name-field', 683 'placeholder' => __( 'New menu name' ),684 683 ), 685 684 ) ); 686 685 … … final class WP_Customize_Nav_Menus { 1017 1016 <?php $post_type_obj = get_post_type_object( $available_item_type['object'] ); ?> 1018 1017 <?php if ( current_user_can( $post_type_obj->cap->create_posts ) && current_user_can( $post_type_obj->cap->publish_posts ) ) : ?> 1019 1018 <div class="new-content-item"> 1020 <input type="text" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>"> 1019 <label for="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="screen-reader-text"><?php echo esc_html( $post_type_obj->labels->add_new_item ); ?></label> 1020 <input type="text" id="<?php echo esc_attr( 'create-item-input-' . $available_item_type['object'] ); ?>" class="create-item-input" placeholder="<?php echo esc_attr( $post_type_obj->labels->add_new_item ); ?>"> 1021 1021 <button type="button" class="button add-content"><?php _e( 'Add' ); ?></button> 1022 1022 </div> 1023 1023 <?php endif; ?> -
src/wp-includes/customize/class-wp-customize-date-time-control.php
diff --git src/wp-includes/customize/class-wp-customize-date-time-control.php src/wp-includes/customize/class-wp-customize-date-time-control.php index abcdc58833..b7acb81689 100644
class WP_Customize_Date_Time_Control extends WP_Customize_Control { 101 101 ?> 102 102 103 103 <# _.defaults( data, <?php echo wp_json_encode( $data ); ?> ); #> 104 <# var idPrefix = _.uniqueId( 'el' ) + '-'; #> 104 105 105 106 <span class="customize-control-title"> 106 <label>{{ data.label }}</label>107 {{ data.label }} 107 108 </span> 108 109 <div class="customize-control-notifications-container"></div> 109 110 <span class="description customize-control-description">{{ data.description }}</span> 110 111 <div class="date-time-fields"> 111 < divclass="day-row">112 < span class="title-day"><?php esc_html_e( 'Day' ); ?></span>112 <fieldset class="day-row"> 113 <legend class="title-day"><?php esc_html_e( 'Date' ); ?></legend> 113 114 <div class="day-fields clear"> 114 <label class="month-field"> 115 <span class="screen-reader-text"><?php esc_html_e( 'Month' ); ?></span> 116 <select class="date-input month" data-component="month"> 117 <# _.each( data.month_choices, function( choice ) { 118 if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) { 119 text = choice.text; 120 value = choice.value; 121 } 122 #> 123 <option value="{{ value }}" > 124 {{ text }} 125 </option> 126 <# } ); #> 127 </select> 128 </label> 129 <label class="day-field"> 130 <span class="screen-reader-text"><?php esc_html_e( 'Day' ); ?></span> 131 <input type="number" size="2" maxlength="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31"" /> 132 </label> 115 <label for="{{ idPrefix }}date-time-month" class="screen-reader-text"><?php esc_html_e( 'Month' ); ?></label> 116 <select id="{{ idPrefix }}date-time-month" class="date-input month" data-component="month"> 117 <# _.each( data.month_choices, function( choice ) { 118 if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) { 119 text = choice.text; 120 value = choice.value; 121 } 122 #> 123 <option value="{{ value }}" > 124 {{ text }} 125 </option> 126 <# } ); #> 127 </select> 128 <label for="{{ idPrefix }}date-time-day" class="screen-reader-text"><?php esc_html_e( 'Day' ); ?></label> 129 <input id="{{ idPrefix }}date-time-day" type="number" size="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31" /> 133 130 <span class="time-special-char date-time-separator">,</span> 134 <label class="year-field"> 135 <span class="screen-reader-text"><?php esc_html_e( 'Year' ); ?></span> 136 <# var maxYearLength = String( data.maxYear ).length; #> 137 <input type="number" size="4" maxlength="{{ maxYearLength }}" autocomplete="off" class="date-input year" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}" /> 138 </label> 131 <label for="{{ idPrefix }}date-time-year" class="screen-reader-text"><?php esc_html_e( 'Year' ); ?></label> 132 <input id="{{ idPrefix }}date-time-year" type="number" size="4" autocomplete="off" class="date-input year" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}"> 139 133 </div> 140 </ div>141 < divclass="time-row clear">142 < span class="title-time"><?php esc_html_e( 'Time' ); ?></span>134 </fieldset> 135 <fieldset class="time-row clear"> 136 <legend class="title-time"><?php esc_html_e( 'Time' ); ?></legend> 143 137 <div class="time-fields clear"> 144 <label class="hour-field"> 145 <span class="screen-reader-text"><?php esc_html_e( 'Hour' ); ?></span> 146 <# var maxHour = data.twelveHourFormat ? 12 : 24; #> 147 <input type="number" size="2" maxlength="2" autocomplete="off" class="date-input hour" data-component="hour" min="1" max="{{ maxHour }}"" /> 148 </label> 138 <label for="{{ idPrefix }}date-time-hour" class="screen-reader-text"><?php esc_html_e( 'Hour' ); ?></label> 139 <# var maxHour = data.twelveHourFormat ? 12 : 24; #> 140 <input id="{{ idPrefix }}date-time-hour" type="number" size="2" autocomplete="off" class="date-input hour" data-component="hour" min="1" max="{{ maxHour }}"> 149 141 <span class="time-special-char date-time-separator">:</span> 150 <label class="minute-field"> 151 <span class="screen-reader-text"><?php esc_html_e( 'Minute' ); ?></span> 152 <input type="number" size="2" maxlength="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59" /> 153 </label> 142 <label for="{{ idPrefix }}date-time-minute" class="screen-reader-text"><?php esc_html_e( 'Minute' ); ?></label> 143 <input id="{{ idPrefix }}date-time-minute" type="number" size="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59"> 154 144 <# if ( data.twelveHourFormat ) { #> 155 <label class="am-pm-field"> 156 <span class="screen-reader-text"><?php esc_html_e( 'AM / PM' ); ?></span> 157 <select class="date-input" data-component="ampm"> 145 <label for="{{ idPrefix }}date-time-meridian" class="screen-reader-text"><?php esc_html_e( 'Meridian' ); ?></label> 146 <select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian"> 158 147 <option value="am"><?php esc_html_e( 'AM' ); ?></option> 159 148 <option value="pm"><?php esc_html_e( 'PM' ); ?></option> 160 149 </select> 161 </label>162 150 <# } #> 163 151 <abbr class="date-timezone" aria-label="<?php esc_attr_e( 'Timezone' ); ?>" title="<?php echo esc_attr( $timezone_info['description'] ); ?>"><?php echo esc_html( $timezone_info['abbr'] ); ?></abbr> 164 152 </div> 165 </ div>153 </fieldset> 166 154 </div> 167 155 <?php 168 156 } -
tests/qunit/index.html
diff --git tests/qunit/index.html tests/qunit/index.html index 5ed4c7a02d..813da74529 100644
874 874 </script> 875 875 <script type="text/html" id="tmpl-customize-control-date_time-content"> 876 876 877 <# _.defaults( data, {"settings":[],"type":"date_time","priority":10,"active":true,"section":"","content":"<li id=\"customize-control-temp\" class=\"customize-control customize-control-date_time\">\n\t\t\t\t\t<\/li>","label":"","description":"","instanceNumber":69,"maxYear":9999,"minYear":1000,"allowPastDate":true,"twelveHourFormat":true,"defaultValue":null,"month_choices":{"1":{"text":"1-Jan","value":1},"2":{"text":"2-Feb","value":2},"3":{"text":"3-Mar","value":3},"4":{"text":"4-Apr","value":4},"5":{"text":"5-May","value":5},"6":{"text":"6-Jun","value":6},"7":{"text":"7-Jul","value":7},"8":{"text":"8-Aug","value":8},"9":{"text":"9-Sep","value":9},"10":{"text":"10-Oct","value":10},"11":{"text":"11-Nov","value":11},"12":{"text":"12-Dec","value":12}}} ); #> 877 <# _.defaults( data, {"settings":[],"type":"date_time","priority":10,"active":true,"section":"","content":"<li id=\"customize-control-temp\" class=\"customize-control customize-control-date_time\">\n\t\t\t\t\t<\/li>","label":"","description":"","instanceNumber":73,"maxYear":9999,"minYear":1000,"allowPastDate":true,"twelveHourFormat":true,"defaultValue":null,"month_choices":{"1":{"text":"1-Jan","value":1},"2":{"text":"2-Feb","value":2},"3":{"text":"3-Mar","value":3},"4":{"text":"4-Apr","value":4},"5":{"text":"5-May","value":5},"6":{"text":"6-Jun","value":6},"7":{"text":"7-Jul","value":7},"8":{"text":"8-Aug","value":8},"9":{"text":"9-Sep","value":9},"10":{"text":"10-Oct","value":10},"11":{"text":"11-Nov","value":11},"12":{"text":"12-Dec","value":12}}} ); #> 878 <# var idPrefix = _.uniqueId( 'el' ) + '-'; #> 878 879 879 880 <span class="customize-control-title"> 880 <label>{{ data.label }}</label>881 {{ data.label }} 881 882 </span> 882 883 <div class="customize-control-notifications-container"></div> 883 884 <span class="description customize-control-description">{{ data.description }}</span> 884 885 <div class="date-time-fields"> 885 < divclass="day-row">886 < span class="title-day">Day</span>886 <fieldset class="day-row"> 887 <legend class="title-day">Date</legend> 887 888 <div class="day-fields clear"> 888 <label class="month-field"> 889 <span class="screen-reader-text">Month</span> 890 <select class="date-input month" data-component="month"> 891 <# _.each( data.month_choices, function( choice ) { 892 if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) { 893 text = choice.text; 894 value = choice.value; 895 } 896 #> 897 <option value="{{ value }}" > 898 {{ text }} 899 </option> 900 <# } ); #> 901 </select> 902 </label> 903 <label class="day-field"> 904 <span class="screen-reader-text">Day</span> 905 <input type="number" size="2" maxlength="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31"" /> 906 </label> 889 <label for="{{ idPrefix }}date-time-month" class="screen-reader-text">Month</label> 890 <select id="{{ idPrefix }}date-time-month" class="date-input month" data-component="month"> 891 <# _.each( data.month_choices, function( choice ) { 892 if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) { 893 text = choice.text; 894 value = choice.value; 895 } 896 #> 897 <option value="{{ value }}" > 898 {{ text }} 899 </option> 900 <# } ); #> 901 </select> 902 <label for="{{ idPrefix }}date-time-day" class="screen-reader-text">Day</label> 903 <input id="{{ idPrefix }}date-time-day" type="number" size="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31" /> 907 904 <span class="time-special-char date-time-separator">,</span> 908 <label class="year-field"> 909 <span class="screen-reader-text">Year</span> 910 <# var maxYearLength = String( data.maxYear ).length; #> 911 <input type="number" size="4" maxlength="{{ maxYearLength }}" autocomplete="off" class="date-input year" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}" /> 912 </label> 905 <label for="{{ idPrefix }}date-time-year" class="screen-reader-text">Year</label> 906 <input id="{{ idPrefix }}date-time-year" type="number" size="4" autocomplete="off" class="date-input year" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}"> 913 907 </div> 914 </ div>915 < divclass="time-row clear">916 < span class="title-time">Time</span>908 </fieldset> 909 <fieldset class="time-row clear"> 910 <legend class="title-time">Time</legend> 917 911 <div class="time-fields clear"> 918 <label class="hour-field"> 919 <span class="screen-reader-text">Hour</span> 920 <# var maxHour = data.twelveHourFormat ? 12 : 24; #> 921 <input type="number" size="2" maxlength="2" autocomplete="off" class="date-input hour" data-component="hour" min="1" max="{{ maxHour }}"" /> 922 </label> 912 <label for="{{ idPrefix }}date-time-hour" class="screen-reader-text">Hour</label> 913 <# var maxHour = data.twelveHourFormat ? 12 : 24; #> 914 <input id="{{ idPrefix }}date-time-hour" type="number" size="2" autocomplete="off" class="date-input hour" data-component="hour" min="1" max="{{ maxHour }}"> 923 915 <span class="time-special-char date-time-separator">:</span> 924 <label class="minute-field"> 925 <span class="screen-reader-text">Minute</span> 926 <input type="number" size="2" maxlength="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59" /> 927 </label> 916 <label for="{{ idPrefix }}date-time-minute" class="screen-reader-text">Minute</label> 917 <input id="{{ idPrefix }}date-time-minute" type="number" size="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59"> 928 918 <# if ( data.twelveHourFormat ) { #> 929 <label class="am-pm-field"> 930 <span class="screen-reader-text">AM / PM</span> 931 <select class="date-input" data-component="ampm"> 932 <option value="am">AM</option> 933 <option value="pm">PM</option> 934 </select> 935 </label> 936 <# } #> 937 <abbr class="date-timezone" aria-label="Timezone" title="Timezone is Asia/Kolkata (IST), currently UTC+5:30.">IST</abbr> 919 <label for="{{ idPrefix }}date-time-meridian" class="screen-reader-text">Meridian</label> 920 <select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian"> 921 <option value="am">AM</option> 922 <option value="pm">PM</option> 923 </select> 924 <# } #> 925 <abbr class="date-timezone" aria-label="Timezone" title="Timezone is America/Los Angeles (PDT), currently UTC-7.">PDT</abbr> 938 926 </div> 939 </ div>927 </fieldset> 940 928 </div> 941 929 </script> 942 930 <script type="text/html" id="tmpl-customize-preview-link-control" > 943 < span class="customize-control-title">944 < label>Share Preview Link</label>945 </span>946 < span class="description customize-control-description">See how changes would look live on your website, and share the preview with people who can't access the Customizer.</span>931 <# var elementPrefix = _.uniqueId( 'el' ) + '-' #> 932 <p class="customize-control-title"> 933 Share Preview Link </p> 934 <p class="description customize-control-description">See how changes would look live on your website, and share the preview with people who can't access the Customizer.</p> 947 935 <div class="customize-control-notifications-container"></div> 948 936 <div class="preview-link-wrapper"> 949 <label> 950 <span class="screen-reader-text">Preview Link</span> 951 <a class="preview-control-element" data-component="link" href="" target=""></a> 952 <input readonly class="preview-control-element" data-component="input" value="test" > 953 <button class="customize-copy-preview-link preview-control-element button button-secondary" data-component="button" data-copy-text="Copy" data-copied-text="Copied" >Copy</button> 954 </label> 937 <label for="{{ elementPrefix }}customize-preview-link-input" class="screen-reader-text">Preview Link</label> 938 <a href="" target=""> 939 <span class="preview-control-element" data-component="url"></span> 940 <span class="screen-reader-text">(opens in a new window)</span> 941 </a> 942 <input id="{{ elementPrefix }}customize-preview-link-input" readonly class="preview-control-element" data-component="input"> 943 <button class="customize-copy-preview-link preview-control-element button button-secondary" data-component="button" data-copy-text="Copy" data-copied-text="Copied" >Copy</button> 955 944 </div> 956 945 </script> 957 946 <script type="text/html" id="tmpl-media-modal"> -
tests/qunit/wp-admin/js/customize-controls.js
diff --git tests/qunit/wp-admin/js/customize-controls.js tests/qunit/wp-admin/js/customize-controls.js index aaa8c069cc..fa7888cf70 100644
jQuery( window ).load( function (){ 702 702 test( 'Test DateTimeControl creation and its methods', function( assert ) { 703 703 var control, controlId = 'date_time', section, sectionId = 'fixture-section', 704 704 datetime = '2599-08-06 18:12:13', dateTimeArray, dateTimeArrayInampm, timeString, 705 day, year, month, minute, ampm, hour;705 day, year, month, minute, meridian, hour; 706 706 707 707 section = wp.customize.section( sectionId ); 708 708 … … jQuery( window ).load( function (){ 728 728 year = control.inputElements.year; 729 729 minute = control.inputElements.minute; 730 730 hour = control.inputElements.hour; 731 ampm = control.inputElements.ampm;731 meridian = control.inputElements.meridian; 732 732 733 733 year( '23' ); 734 734 assert.equal( typeof year(), 'number', 'Should always return integer' ); 735 735 736 month( '8' ); 736 737 month( 'test' ); 737 assert. notOk(month(), 'Should not accept text' );738 assert.equal( 8, month(), 'Should not accept text' ); 738 739 739 740 // Test control.parseDateTime(); 740 741 dateTimeArray = control.parseDateTime( datetime ); … … jQuery( window ).load( function (){ 753 754 month: '08', 754 755 hour: '6', 755 756 minute: '12', 756 ampm: 'pm',757 meridian: 'pm', 757 758 day: '06' 758 759 } ); 759 760 … … jQuery( window ).load( function (){ 762 763 day( '18' ); 763 764 hour( '3' ); 764 765 minute( '44' ); 765 ampm( 'am' );766 meridian( 'am' ); 766 767 767 768 // Test control.convertInputDateToString(). 768 769 timeString = control.convertInputDateToString(); 769 770 assert.equal( timeString, '2010-12-18 03:44:00' ); 770 771 771 ampm( 'pm' );772 meridian( 'pm' ); 772 773 timeString = control.convertInputDateToString(); 773 774 assert.equal( timeString, '2010-12-18 15:44:00' ); 774 775 … … jQuery( window ).load( function (){ 796 797 assert.notOk( control.notifications.has( 'not_future_date' ) ); 797 798 798 799 // Test control.populateDateInputs(); 800 control.setting._value = '2000-12-30 12:34:56'; 799 801 control.populateDateInputs(); 800 control.dateInputs.each( function() { 801 var node = jQuery( this ); 802 assert.equal( node.val(), control.inputElements[ node.data( 'component' ) ].get() ); 803 } ); 802 assert.equal( '2000', control.inputElements.year.get() ); 803 assert.equal( '12', control.inputElements.month.get() ); 804 assert.equal( '30', control.inputElements.day.get() ); 805 assert.equal( '12', control.inputElements.hour.get() ); 806 assert.equal( '34', control.inputElements.minute.get() ); 807 assert.equal( 'pm', control.inputElements.meridian.get() ); 804 808 805 809 // Test control.validateInputs(); 806 810 hour( 33 ); … … jQuery( window ).load( function (){ 818 822 year( 2018 ); 819 823 hour( 4 ); 820 824 minute( 20 ); 821 ampm( 'pm' );825 meridian( 'pm' ); 822 826 control.populateSetting(); 823 827 assert.equal( control.setting(), '2018-11-02 16:20:00' ); 824 828 … … jQuery( window ).load( function (){ 836 840 year( 2318 ); 837 841 hour( 4 ); 838 842 minute( 20 ); 839 ampm( 'pm' );843 meridian( 'pm' ); 840 844 assert.ok( control.isFutureDate() ); 841 845 842 846 year( 2016 ); … … jQuery( window ).load( function (){ 848 852 */ 849 853 hour( 24 ); 850 854 minute( 32 ); 851 control.inputElements. ampm= false; // Because it works only when the time is twenty four hour format.855 control.inputElements.meridian = false; // Because it works only when the time is twenty four hour format. 852 856 control.updateMinutesForHour(); 853 857 assert.deepEqual( minute(), 0 ); 854 858 … … jQuery( window ).load( function (){ 910 914 control.setting.set( newLink ); 911 915 912 916 assert.equal( control.previewElements.input(), newLink ); 913 assert.equal( control.previewElements. link(), newLink );914 assert.equal( control.previewElements. link.element.attr( 'href' ), newLink );915 assert.equal( control.previewElements. link.element.attr( 'target' ), wp.customize.settings.changeset.uuid );917 assert.equal( control.previewElements.url(), newLink ); 918 assert.equal( control.previewElements.url.element.parent().attr( 'href' ), newLink ); 919 assert.equal( control.previewElements.url.element.parent().attr( 'target' ), wp.customize.settings.changeset.uuid ); 916 920 917 921 // Test control.toggleSaveNotification(). 918 922 control.toggleSaveNotification( true );