Changeset 41670
- Timestamp:
- 10/02/2017 04:11:50 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/customize-controls.css
r41667 r41670 174 174 175 175 #customize-controls .date-input:invalid { 176 border-color: red; 177 } 178 179 .date-time-fields .month-field { 180 width: 79px; 181 } 182 183 .date-time-fields .day-field, 184 .date-time-fields .hour-field, 185 .date-time-fields .minute-field { 186 width: 46px; 187 } 188 189 .date-time-fields .year-field { 190 width: 60px; 191 } 192 193 .date-time-fields .am-pm-field { 194 width: 53px; 176 border-color: #dc3232; 195 177 } 196 178 … … 226 208 .customize-copy-preview-link:before, 227 209 .customize-copy-preview-link:after { 228 content: '';210 content: ""; 229 211 height: 28px; 230 212 position: absolute; … … 251 233 border-right: none; 252 234 text-indent: -999px; 253 color: white;235 color: #fff; 254 236 } 255 237 … … 259 241 } 260 242 261 #customize-control-changeset_preview_link a .preview-control-element{243 #customize-control-changeset_preview_link a { 262 244 display: inline-block; 263 245 position: absolute; … … 270 252 } 271 253 272 #customize-control-changeset_preview_link a. preview-control-element.disabled,273 #customize-control-changeset_preview_link a. preview-control-element.disabled:active,274 #customize-control-changeset_preview_link a. preview-control-element.disabled:focus,275 #customize-control-changeset_preview_link a. preview-control-element.disabled:visited {254 #customize-control-changeset_preview_link a.disabled, 255 #customize-control-changeset_preview_link a.disabled:active, 256 #customize-control-changeset_preview_link a.disabled:focus, 257 #customize-control-changeset_preview_link a.disabled:visited { 276 258 color: black; 277 259 opacity: 0.4; … … 294 276 } 295 277 296 . date-time-fields label,297 . date-time-fields .date-time-separator {278 .customize-control.customize-control-date_time .date-time-fields .date-input, 279 .customize-control.customize-control-date_time .date-time-fields .date-time-separator { 298 280 float: left; 299 margin-right:5px; 281 margin-right: 5px; 282 } 283 284 .date-time-fields .date-input.month { 285 width: auto; 286 margin: 0; 287 } 288 289 .date-time-fields .date-input.day, 290 .date-time-fields .date-input.hour, 291 .date-time-fields .date-input.minute { 292 width: 46px; 293 } 294 295 .date-time-fields .date-input.year { 296 width: 60px; 297 } 298 299 .date-time-fields .date-input.meridian { 300 width: auto; 301 margin: 0; 300 302 } 301 303 … … 305 307 306 308 .date-time-fields .time-row { 307 padding-top: 12px;309 margin-top: 12px; 308 310 } 309 311 … … 1036 1038 1037 1039 .customize-control-dropdown-pages .new-content-item .create-item-input.invalid { 1038 border: 1px solid # f00;1040 border: 1px solid #dc3232; 1039 1041 } 1040 1042 … … 1199 1201 } 1200 1202 #customize-control-show_on_front.has-error .customize-control-notifications-container { 1201 margin-top: 12px;1203 margin-top: 12px; 1202 1204 } 1203 1205 … … 1384 1386 position: absolute; 1385 1387 height: auto; 1386 top: 0; left: 0; bottom: 0; right: 0; 1388 top: 0; 1389 left: 0; 1390 bottom: 0; 1391 right: 0; 1387 1392 border: 4px solid #00a0d2; 1388 1393 border-radius: 2px; … … 2686 2691 } 2687 2692 2688 .date-time-fields . month-field{2693 .date-time-fields .date-input.month { 2689 2694 width: 79px; 2690 2695 } 2691 2696 2692 .date-time-fields .da y-field,2693 .date-time-fields . hour-field,2694 .date-time-fields . minute-field{2697 .date-time-fields .date-input.day, 2698 .date-time-fields .date-input.hour, 2699 .date-time-fields .date-input.minute { 2695 2700 width: 55px; 2696 2701 } 2697 2702 2698 .date-time-fields . year-field{2703 .date-time-fields .date-input.year { 2699 2704 width: 80px; 2700 2705 } 2701 2706 2707 .date-time-fields .date-time-separator, 2702 2708 .date-time-fields .date-timezone { 2703 2709 line-height: 3.2; 2704 2710 } 2711 2705 2712 .wp-core-ui.wp-customizer .button { 2706 2713 margin-top: 12px; -
trunk/src/wp-admin/css/customize-nav-menus.css
r41062 r41670 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 -
trunk/src/wp-admin/js/customize-controls.js
r41667 r41670 4930 4930 api.DateTimeControl = api.Control.extend({ 4931 4931 4932 dateInputs: {},4933 inputElements: {},4934 invalidDate: false,4935 4936 4932 /** 4937 4933 * Initialize behaviors. … … 4943 4939 var control = this; 4944 4940 4945 _.bindAll( control, 'populateSetting', 'updateDaysForMonth', 'updateMinutesForHour' ); 4946 4947 control.dateInputs = control.container.find( '.date-input' ); 4941 control.inputElements = {}; 4942 control.invalidDate = false; 4943 4944 _.bindAll( control, 'populateSetting', 'updateDaysForMonth', 'updateMinutesForHour', 'populateDateInputs' ); 4948 4945 4949 4946 // @todo This needs https://core.trac.wordpress.org/ticket/37964 … … 4952 4949 } 4953 4950 4951 // @todo Should this be? Default should be on client. The default value should be in the setting itself. 4954 4952 if ( ! control.setting.get() && control.params.defaultValue ) { 4955 4953 control.setting.set( control.params.defaultValue ); 4956 4954 } 4957 4955 4958 control. dateInputs.each( function() {4956 control.container.find( '.date-input' ).each( function() { 4959 4957 var input = $( this ), component, element; 4960 4958 component = input.data( 'component' ); 4961 4959 element = new api.Element( input ); 4962 element.validate = function( value ) { 4963 return _.contains( [ 'am', 'pm' ], value ) ? value : parseInt( value, 10 ); 4964 }; 4960 if ( 'meridian' === component ) { 4961 element.validate = function( value ) { 4962 if ( 'am' !== value && 'pm' !== value ) { 4963 return null; 4964 } 4965 return value; 4966 }; 4967 } else { 4968 element.validate = function( value ) { 4969 var val = parseInt( value, 10 ); 4970 if ( isNaN( val ) ) { 4971 return null; 4972 } 4973 return val; 4974 }; 4975 } 4976 element.bind( control.populateSetting ); 4965 4977 control.inputElements[ component ] = element; 4966 4978 control.elements.push( element ); 4967 4979 } ); 4968 4980 4969 control.dateInputs.on( 'input', control.populateSetting );4970 4981 control.inputElements.month.bind( control.updateDaysForMonth ); 4971 4982 control.inputElements.year.bind( control.updateDaysForMonth ); 4972 control.inputElements.hour.bind( control.updateMinutesForHour ); 4983 if ( control.params.includeTime ) { 4984 control.inputElements.hour.bind( control.updateMinutesForHour ); 4985 } 4973 4986 control.populateDateInputs(); 4987 control.setting.bind( control.populateDateInputs ); 4974 4988 }, 4975 4989 … … 4978 4992 * 4979 4993 * @since 4.9.0 4980 * @param {string} datetime Date/Time string. Accepts Y-m-d H:i:s format.4981 * @param { boolean} twelveHourFormat If twelve hour format array is required.4994 * 4995 * @param {string} datetime - Date/Time string. Accepts Y-m-d[ H:i[:s]] format. 4982 4996 * @returns {object|null} Returns object containing date components or null if parse error. 4983 4997 */ 4984 parseDateTime: function parseDateTime( datetime , twelveHourFormat) {4985 var matches, date, midDayHour = 12;4998 parseDateTime: function parseDateTime( datetime ) { 4999 var control = this, matches, date, midDayHour = 12; 4986 5000 4987 5001 if ( datetime ) { 4988 matches = datetime.match( /^(\d\d\d\d)-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)$/ );5002 matches = datetime.match( /^(\d\d\d\d)-(\d\d)-(\d\d)(?: (\d\d):(\d\d)(?::(\d\d))?)?$/ ); 4989 5003 } 4990 5004 … … 4999 5013 month: matches.shift(), 5000 5014 day: matches.shift(), 5001 hour: matches.shift() ,5002 minute: matches.shift() ,5003 second: matches.shift() 5015 hour: matches.shift() || '00', 5016 minute: matches.shift() || '00', 5017 second: matches.shift() || '00' 5004 5018 }; 5005 5019 5006 if ( twelveHourFormat ) {5020 if ( control.params.includeTime && control.params.twelveHourFormat ) { 5007 5021 date.hour = parseInt( date.hour, 10 ); 5008 date. ampm= date.hour >= midDayHour ? 'pm' : 'am';5022 date.meridian = date.hour >= midDayHour ? 'pm' : 'am'; 5009 5023 date.hour = date.hour % midDayHour ? String( date.hour % midDayHour ) : String( midDayHour ); 5010 delete date.second; 5024 delete date.second; // @todo Why only if twelveHourFormat? 5011 5025 } 5012 5026 … … 5021 5035 */ 5022 5036 validateInputs: function validateInputs() { 5023 var control = this, errorMessage ;5037 var control = this, errorMessage, components; 5024 5038 5025 5039 control.invalidDate = false; 5026 5040 5027 _.each( [ 'day', 'hour', 'year', 'minute' ], function( component ) { 5028 var element, el, max, min, maxLength, value; 5041 components = [ 'year', 'day' ]; 5042 if ( control.params.includeTime ) { 5043 components.push( 'hour', 'minute' ); 5044 } 5045 5046 _.each( components, function( component ) { 5047 var element, el, max, min, value; 5029 5048 5030 5049 if ( ! control.invalidDate ) { … … 5033 5052 max = parseInt( element.element.attr( 'max' ), 10 ); 5034 5053 min = parseInt( element.element.attr( 'min' ), 10 ); 5035 maxLength = parseInt( element.element.attr( 'maxlength' ), 10 );5036 5054 value = element(); 5037 control.invalidDate = value > max || value < min || String( value ).length > maxLength;5055 control.invalidDate = value > max || value < min; 5038 5056 errorMessage = control.invalidDate ? api.l10n.invalid + ' ' + component : ''; 5039 5057 5040 5058 el.setCustomValidity( errorMessage ); 5041 _.result( el, 'reportValidity' ); 5059 if ( ! control.section() || api.section.has( control.section() ) && api.section( control.section() ).expanded() ) { 5060 _.result( el, 'reportValidity' ); 5061 } 5042 5062 } 5043 5063 } ); … … 5078 5098 var control = this, maxHours = 24, minuteEl; 5079 5099 5080 if ( control.inputElements. ampm) {5100 if ( control.inputElements.meridian ) { 5081 5101 return; 5082 5102 } … … 5087 5107 control.inputElements.minute( 0 ); 5088 5108 minuteEl.data( 'default-max', minuteEl.attr( 'max' ) ); 5089 minuteEl.data( 'default-maxlength', minuteEl.attr( 'maxlength' ) );5090 5109 minuteEl.attr( 'max', '0' ); 5091 5110 } else if ( minuteEl.data( 'default-max' ) ) { 5092 5111 minuteEl.attr( 'max', minuteEl.data( 'default-max' ) ); 5093 minuteEl.attr( 'maxlength', minuteEl.data( 'maxlength' ) );5094 5112 } 5095 5113 }, … … 5143 5161 }; 5144 5162 5145 hourInTwentyFourHourFormat = control.inputElements.ampm ? control.convertHourToTwentyFourHourFormat( control.inputElements.hour(), control.inputElements.ampm() ) : control.inputElements.hour(); 5146 dateFormat = [ 'year', '-', 'month', '-', 'day', ' ', pad( hourInTwentyFourHourFormat, 2 ), ':', 'minute', ':', '00' ]; 5163 dateFormat = [ 'year', '-', 'month', '-', 'day' ]; 5164 if ( control.params.includeTime ) { 5165 hourInTwentyFourHourFormat = control.inputElements.meridian ? control.convertHourToTwentyFourHourFormat( control.inputElements.hour(), control.inputElements.meridian() ) : control.inputElements.hour(); 5166 dateFormat = dateFormat.concat( [ ' ', pad( hourInTwentyFourHourFormat, 2 ), ':', 'minute', ':', '00' ] ); 5167 } 5147 5168 5148 5169 _.each( dateFormat, function( component ) { … … 5168 5189 * 5169 5190 * @since 4.9.0 5170 * @param {string} hourInTwelveHourFormat Hour in twelve hour format.5171 * @param {string} ampm am/pm5172 * @return {string} Hour in twenty four hour format.5173 */ 5174 convertHourToTwentyFourHourFormat: function convertHour( hourInTwelveHourFormat, ampm) {5191 * @param {string} hourInTwelveHourFormat - Hour in twelve hour format. 5192 * @param {string} meridian - Either 'am' or 'pm'. 5193 * @returns {string} Hour in twenty four hour format. 5194 */ 5195 convertHourToTwentyFourHourFormat: function convertHour( hourInTwelveHourFormat, meridian ) { 5175 5196 var hourInTwentyFourHourFormat, hour, midDayHour = 12; 5176 5197 5177 5198 hour = parseInt( hourInTwelveHourFormat, 10 ); 5178 5179 if ( 'pm' === ampm && hour < midDayHour ) { 5199 if ( isNaN( hour ) ) { 5200 return ''; 5201 } 5202 5203 if ( 'pm' === meridian && hour < midDayHour ) { 5180 5204 hourInTwentyFourHourFormat = hour + midDayHour; 5181 } else if ( 'am' === ampm&& midDayHour === hour ) {5205 } else if ( 'am' === meridian && midDayHour === hour ) { 5182 5206 hourInTwentyFourHourFormat = hour - midDayHour; 5183 5207 } else { … … 5197 5221 var control = this, parsed; 5198 5222 5199 parsed = control.parseDateTime( control.setting.get() , control.params.twelveHourFormat);5223 parsed = control.parseDateTime( control.setting.get() ); 5200 5224 5201 5225 if ( ! parsed ) { … … 5246 5270 api.PreviewLinkControl = api.Control.extend({ 5247 5271 5248 previewElements: {},5249 5250 5272 /** 5251 5273 * Override the templateSelector before embedding the control into the page. … … 5267 5289 */ 5268 5290 ready: function ready() { 5269 var control = this, element, component, node, link, input, button;5291 var control = this, element, component, node, url, input, button; 5270 5292 5271 5293 _.bindAll( control, 'updatePreviewLink' ); … … 5274 5296 control.setting = new api.Value(); 5275 5297 } 5298 5299 control.previewElements = {}; 5276 5300 5277 5301 control.container.find( '.preview-control-element' ).each( function() { … … 5283 5307 } ); 5284 5308 5285 link = control.previewElements.link;5309 url = control.previewElements.url; 5286 5310 input = control.previewElements.input; 5287 5311 button = control.previewElements.button; 5288 5312 5289 5313 input.link( control.setting ); 5290 link.link( control.setting ); 5291 5292 link.bind( function( value ) { 5293 link.element.attr( 'href', value ); 5294 link.element.attr( 'target', api.settings.changeset.uuid ); 5314 url.link( control.setting ); 5315 5316 url.bind( function( value ) { 5317 url.element.parent().attr( { 5318 href: value, 5319 target: api.settings.changeset.uuid 5320 } ); 5295 5321 } ); 5296 5322 5297 5323 api.bind( 'ready', control.updatePreviewLink ); 5298 api.bind( 'change', control.updatePreviewLink );5299 5324 api.state( 'saved' ).bind( control.updatePreviewLink ); 5325 api.state( 'changesetStatus' ).bind( control.updatePreviewLink ); 5300 5326 5301 5327 button.element.on( 'click', function( event ) { … … 5308 5334 } ); 5309 5335 5310 link.element.on( 'click', function( event ) {5311 if ( link.element.hasClass( 'disabled' ) ) {5336 url.element.parent().on( 'click', function( event ) { 5337 if ( $( this ).hasClass( 'disabled' ) ) { 5312 5338 event.preventDefault(); 5313 5339 } … … 5330 5356 var control = this, unsavedDirtyValues; 5331 5357 5332 unsavedDirtyValues = ! _.isEmpty( api.dirtyValues( { 5333 unsaved: true 5334 } ) ); 5358 unsavedDirtyValues = ! api.state( 'saved' ).get() || '' === api.state( 'changesetStatus' ).get() || 'auto-draft' === api.state( 'changesetStatus' ).get(); 5335 5359 5336 5360 control.toggleSaveNotification( unsavedDirtyValues ); 5337 control.previewElements. link.element.toggleClass( 'disabled', unsavedDirtyValues );5361 control.previewElements.url.element.parent().toggleClass( 'disabled', unsavedDirtyValues ); 5338 5362 control.previewElements.button.element.prop( 'disabled', unsavedDirtyValues ); 5339 5363 control.setting.set( api.previewer.getFrontendPreviewUrl() ); … … 6509 6533 } ); 6510 6534 6511 /** 6512 * Find all invalid setting less controls with notification type error. 6513 */ 6535 // Find all invalid setting less controls with notification type error. 6514 6536 api.control.each( function( control ) { 6515 6537 if ( ! control.setting || ! control.setting.id && control.active.get() ) { … … 7931 7953 })(); 7932 7954 7933 /** 7934 * Publish settings section and controls. 7935 */ 7955 // Publish settings section and controls. 7936 7956 api.control( 'changeset_status', 'changeset_scheduled_date', function( statusControl, dateControl ) { 7937 7957 $.when( statusControl.deferred.embedded, dateControl.deferred.embedded ).done( function() { -
trunk/src/wp-includes/class-wp-customize-manager.php
r41667 r41670 3623 3623 </script> 3624 3624 <script type="text/html" id="tmpl-customize-preview-link-control" > 3625 <span class="customize-control-title"> 3626 <label><?php esc_html_e( 'Share Preview Link' ); ?></label> 3627 </span> 3628 <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> 3625 <# var elementPrefix = _.uniqueId( 'el' ) + '-' #> 3626 <p class="customize-control-title"> 3627 <?php esc_html_e( 'Share Preview Link' ); ?> 3628 </p> 3629 <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> 3629 3630 <div class="customize-control-notifications-container"></div> 3630 3631 <div class="preview-link-wrapper"> 3631 <label> 3632 <span class="screen-reader-text"><?php esc_html_e( 'Preview Link' ); ?></span> 3633 <a class="preview-control-element" data-component="link" href="" target=""></a> 3634 <input readonly class="preview-control-element" data-component="input" value="test" > 3635 <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> 3636 </label> 3632 <label for="{{ elementPrefix }}customize-preview-link-input" class="screen-reader-text"><?php esc_html_e( 'Preview Link' ); ?></label> 3633 <a href="" target=""> 3634 <span class="preview-control-element" data-component="url"></span> 3635 <span class="screen-reader-text"><?php _e( '(opens in a new window)' ); ?></span> 3636 </a> 3637 <input id="{{ elementPrefix }}customize-preview-link-input" readonly class="preview-control-element" data-component="input"> 3638 <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> 3637 3639 </div> 3638 3640 </script> … … 4237 4239 $initial_date = current_time( 'mysql', false ); 4238 4240 } 4241 4239 4242 $this->add_control( new WP_Customize_Date_Time_Control( $this, 'changeset_scheduled_date', array( 4240 4243 'section' => 'publish_settings', … … 4244 4247 'min_year' => date( 'Y' ), 4245 4248 'allow_past_date' => false, 4249 'include_time' => true, 4246 4250 'twelve_hour_format' => false !== stripos( get_option( 'time_format' ), 'a' ), 4247 4251 'description' => __( 'Schedule your customization changes to publish ("go live") at a future date.' ), -
trunk/src/wp-includes/class-wp-customize-nav-menus.php
r41353 r41670 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', … … 681 681 'input_attrs' => array( 682 682 'class' => 'menu-name-field', 683 'placeholder' => __( 'New menu name' ),684 683 ), 685 684 ) ); … … 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> -
trunk/src/wp-includes/customize/class-wp-customize-date-time-control.php
r41626 r41670 50 50 51 51 /** 52 * Whether hours, minutes, and meridian should be shown. 53 * 54 * @since 4.9.0 55 * @var boolean 56 */ 57 public $include_time = true; 58 59 /** 52 60 * If set to false the control will appear in 24 hour format, 53 61 * the value will still be saved in Y-m-d H:i:s format. … … 84 92 $data['maxYear'] = intval( $this->max_year ); 85 93 $data['minYear'] = intval( $this->min_year ); 86 $data['allowPastDate'] = $this->allow_past_date ? true : false; 87 $data['twelveHourFormat'] = $this->twelve_hour_format ? true : false; 94 $data['allowPastDate'] = (bool) $this->allow_past_date; 95 $data['twelveHourFormat'] = (bool) $this->twelve_hour_format; 96 $data['includeTime'] = (bool) $this->include_time; 88 97 $data['defaultValue'] = $this->default_value; 89 98 … … 102 111 103 112 <# _.defaults( data, <?php echo wp_json_encode( $data ); ?> ); #> 113 <# var idPrefix = _.uniqueId( 'el' ) + '-'; #> 104 114 105 115 <span class="customize-control-title"> 106 <label>{{ data.label }}</label>116 {{ data.label }} 107 117 </span> 108 118 <div class="customize-control-notifications-container"></div> 109 119 <span class="description customize-control-description">{{ data.description }}</span> 110 120 <div class="date-time-fields"> 111 < divclass="day-row">112 < span class="title-day"><?php esc_html_e( 'Day' ); ?></span>121 <fieldset class="day-row"> 122 <legend class="title-day"><?php esc_html_e( 'Date' ); ?></legend> 113 123 <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 <# } ); #> 124 <label for="{{ idPrefix }}date-time-month" class="screen-reader-text"><?php esc_html_e( 'Month' ); ?></label> 125 <select id="{{ idPrefix }}date-time-month" class="date-input month" data-component="month"> 126 <# _.each( data.month_choices, function( choice ) { 127 if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) { 128 text = choice.text; 129 value = choice.value; 130 } 131 #> 132 <option value="{{ value }}" > 133 {{ text }} 134 </option> 135 <# } ); #> 136 </select> 137 <label for="{{ idPrefix }}date-time-day" class="screen-reader-text"><?php esc_html_e( 'Day' ); ?></label> 138 <input id="{{ idPrefix }}date-time-day" type="number" size="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31" /> 139 <span class="time-special-char date-time-separator">,</span> 140 <label for="{{ idPrefix }}date-time-year" class="screen-reader-text"><?php esc_html_e( 'Year' ); ?></label> 141 <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 }}"> 142 </div> 143 </fieldset> 144 <# if ( data.includeTime ) { #> 145 <fieldset class="time-row clear"> 146 <legend class="title-time"><?php esc_html_e( 'Time' ); ?></legend> 147 <div class="time-fields clear"> 148 <label for="{{ idPrefix }}date-time-hour" class="screen-reader-text"><?php esc_html_e( 'Hour' ); ?></label> 149 <# var maxHour = data.twelveHourFormat ? 12 : 24; #> 150 <input id="{{ idPrefix }}date-time-hour" type="number" size="2" autocomplete="off" class="date-input hour" data-component="hour" min="1" max="{{ maxHour }}"> 151 <span class="time-special-char date-time-separator">:</span> 152 <label for="{{ idPrefix }}date-time-minute" class="screen-reader-text"><?php esc_html_e( 'Minute' ); ?></label> 153 <input id="{{ idPrefix }}date-time-minute" type="number" size="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59"> 154 <# if ( data.twelveHourFormat ) { #> 155 <label for="{{ idPrefix }}date-time-meridian" class="screen-reader-text"><?php esc_html_e( 'Meridian' ); ?></label> 156 <select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian"> 157 <option value="am"><?php esc_html_e( 'AM' ); ?></option> 158 <option value="pm"><?php esc_html_e( 'PM' ); ?></option> 127 159 </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> 133 <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> 139 </div> 140 </div> 141 <div class="time-row clear"> 142 <span class="title-time"><?php esc_html_e( 'Time' ); ?></span> 143 <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> 149 <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> 154 <# 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"> 158 <option value="am"><?php esc_html_e( 'AM' ); ?></option> 159 <option value="pm"><?php esc_html_e( 'PM' ); ?></option> 160 </select> 161 </label> 162 <# } #> 163 <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 </div> 165 </div> 160 <# } #> 161 <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> 162 </div> 163 </fieldset> 164 <# } #> 166 165 </div> 167 166 <?php -
trunk/tests/qunit/index.html
r41626 r41670 873 873 <# } #> 874 874 </script> 875 <script type="text/html" id="tmpl-customize-control-date_time-content"> 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}}} ); #> 875 <script type="text/html" id="tmpl-customize-control-date_time-content"> 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":73,"maxYear":9999,"minYear":1000,"allowPastDate":true,"twelveHourFormat":true,"includeTime":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> 913 </div> 914 </div> 915 <div class="time-row clear"> 916 <span class="title-time">Time</span> 917 <div class="time-fields clear"> 918 <label class="hour-field"> 919 <span class="screen-reader-text">Hour</span> 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 }}"> 907 </div> 908 </fieldset> 909 <# if ( data.includeTime ) { #> 910 <fieldset class="time-row clear"> 911 <legend class="title-time">Time</legend> 912 <div class="time-fields clear"> 913 <label for="{{ idPrefix }}date-time-hour" class="screen-reader-text">Hour</label> 920 914 <# 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> 923 <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> 928 <# 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"> 915 <input id="{{ idPrefix }}date-time-hour" type="number" size="2" autocomplete="off" class="date-input hour" data-component="hour" min="1" max="{{ maxHour }}"> 916 <span class="time-special-char date-time-separator">:</span> 917 <label for="{{ idPrefix }}date-time-minute" class="screen-reader-text">Minute</label> 918 <input id="{{ idPrefix }}date-time-minute" type="number" size="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59"> 919 <# if ( data.twelveHourFormat ) { #> 920 <label for="{{ idPrefix }}date-time-meridian" class="screen-reader-text">Meridian</label> 921 <select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian"> 932 922 <option value="am">AM</option> 933 923 <option value="pm">PM</option> 934 924 </select> 935 </label>936 925 <# } #> 937 <abbr class="date-timezone" aria-label="Timezone" title="Timezone is Asia/Kolkata (IST), currently UTC+5:30.">IST</abbr> 938 </div> 939 </div> 926 <abbr class="date-timezone" aria-label="Timezone" title="Timezone is America/Los Angeles (PDT), currently UTC-7.">PDT</abbr> 927 </div> 928 </fieldset> 929 <# } #> 940 930 </div> 941 931 </script> 942 932 <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>933 <# var elementPrefix = _.uniqueId( 'el' ) + '-' #> 934 <p class="customize-control-title"> 935 Share Preview Link </p> 936 <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 937 <div class="customize-control-notifications-container"></div> 948 938 <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> 939 <label for="{{ elementPrefix }}customize-preview-link-input" class="screen-reader-text">Preview Link</label> 940 <a href="" target=""> 941 <span class="preview-control-element" data-component="url"></span> 942 <span class="screen-reader-text">(opens in a new window)</span> 943 </a> 944 <input id="{{ elementPrefix }}customize-preview-link-input" readonly class="preview-control-element" data-component="input"> 945 <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 946 </div> 956 947 </script> -
trunk/tests/qunit/wp-admin/js/customize-controls.js
r41626 r41670 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 ); … … 711 711 section: section.id, 712 712 type: 'date_time', 713 includeTime: true, 713 714 content: '<li id="customize-control-' + controlId + '" class="customize-control"></li>', 714 715 defaultValue: datetime … … 729 730 minute = control.inputElements.minute; 730 731 hour = control.inputElements.hour; 731 ampm = control.inputElements.ampm;732 meridian = control.inputElements.meridian; 732 733 733 734 year( '23' ); 734 735 assert.equal( typeof year(), 'number', 'Should always return integer' ); 735 736 737 month( '8' ); 736 738 month( 'test' ); 737 assert. notOk(month(), 'Should not accept text' );739 assert.equal( 8, month(), 'Should not accept text' ); 738 740 739 741 // Test control.parseDateTime(); 742 control.params.twelveHourFormat = false; 740 743 dateTimeArray = control.parseDateTime( datetime ); 741 744 assert.deepEqual( dateTimeArray, { … … 748 751 } ); 749 752 750 dateTimeArrayInampm = control.parseDateTime( datetime, true ); 753 control.params.twelveHourFormat = true; 754 dateTimeArrayInampm = control.parseDateTime( datetime ); 751 755 assert.deepEqual( dateTimeArrayInampm, { 752 756 year: '2599', … … 754 758 hour: '6', 755 759 minute: '12', 756 ampm: 'pm',760 meridian: 'pm', 757 761 day: '06' 758 762 } ); … … 763 767 hour( '3' ); 764 768 minute( '44' ); 765 ampm( 'am' );769 meridian( 'am' ); 766 770 767 771 // Test control.convertInputDateToString(). … … 769 773 assert.equal( timeString, '2010-12-18 03:44:00' ); 770 774 771 ampm( 'pm' );775 meridian( 'pm' ); 772 776 timeString = control.convertInputDateToString(); 773 777 assert.equal( timeString, '2010-12-18 15:44:00' ); 778 779 control.params.includeTime = false; 780 timeString = control.convertInputDateToString(); 781 assert.equal( timeString, '2010-12-18' ); 782 control.params.includeTime = true; 774 783 775 784 // Test control.updateDaysForMonth();. … … 797 806 798 807 // Test control.populateDateInputs(); 808 control.setting._value = '2000-12-30 12:34:56'; 799 809 control.populateDateInputs(); 800 control.dateInputs.each( function() { 801 var node = jQuery( this ); 802 assert.equal( node.val(), control.inputElements[ node.data( 'component' ) ].get() ); 803 } ); 810 assert.equal( '2000', control.inputElements.year.get() ); 811 assert.equal( '12', control.inputElements.month.get() ); 812 assert.equal( '30', control.inputElements.day.get() ); 813 assert.equal( '12', control.inputElements.hour.get() ); 814 assert.equal( '34', control.inputElements.minute.get() ); 815 assert.equal( 'pm', control.inputElements.meridian.get() ); 804 816 805 817 // Test control.validateInputs(); … … 819 831 hour( 4 ); 820 832 minute( 20 ); 821 ampm( 'pm' );833 meridian( 'pm' ); 822 834 control.populateSetting(); 823 835 assert.equal( control.setting(), '2018-11-02 16:20:00' ); … … 837 849 hour( 4 ); 838 850 minute( 20 ); 839 ampm( 'pm' );851 meridian( 'pm' ); 840 852 assert.ok( control.isFutureDate() ); 841 853 … … 849 861 hour( 24 ); 850 862 minute( 32 ); 851 control.inputElements. ampm= false; // Because it works only when the time is twenty four hour format.863 control.inputElements.meridian = false; // Because it works only when the time is twenty four hour format. 852 864 control.updateMinutesForHour(); 853 865 assert.deepEqual( minute(), 0 ); … … 911 923 912 924 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 );925 assert.equal( control.previewElements.url(), newLink ); 926 assert.equal( control.previewElements.url.element.parent().attr( 'href' ), newLink ); 927 assert.equal( control.previewElements.url.element.parent().attr( 'target' ), wp.customize.settings.changeset.uuid ); 916 928 917 929 // Test control.toggleSaveNotification().
Note: See TracChangeset
for help on using the changeset viewer.