diff --git a/css/customize-snapshots.css b/css/customize-snapshots.css index 53c8ee3a..ccdb2469 100644 --- a/css/customize-snapshots.css +++ b/css/customize-snapshots.css @@ -1,10 +1,10 @@ -#snapshot-preview-link, #snapshot-edit-link { +#snapshot-preview-link, #snapshot-toggle-button { float: right; margin-top: 13px; margin-right: 4px; color: #656a6f; } -#snapshot-edit-link{ +#snapshot-toggle-button{ display: block; } @@ -53,4 +53,70 @@ margin-top: 6px; margin-right: 6px; } +} + +#customize-snapshot-control select, +#customize-snapshot-control input[type="text"] { + min-width: 10%; + width: auto; +} + +#customize-snapshot-control{ + padding: 5px; +} + +#customize-snapshot-control input[type="text"].error { + border-color: #dc3232 !important; + -webkit-box-shadow: 0 0 2px rgba( 204, 0, 0, 0.8 ); + box-shadow: 0 0 2px rgba( 204, 0, 0, 0.8 ); +} + +#customize-schedule-box{ + background: #fff !important; + margin-bottom: 10px; + padding-bottom: 10px; +} + +#customize-schedule-box .accordion-section-title{ + background: #fff; + color: #555; + border-left: none; + border-right: none; + border-bottom: none; + cursor: default; +} + +#customize-schedule-box .accordion-section-title:after{ + z-index: -1; +} +#customize-schedule-box a{ + position: absolute; + top: 4px; + right: 1px; + width: 20px; + height: 20px; + cursor: pointer; + -webkit-box-shadow: none; + box-shadow: none; + -webkit-appearance: none; + background: transparent; + color: #555; + border: none; + padding: 10px; +} + +#customize-schedule-box span{ + font-size: 13px; + line-height: 24px; +} +#customize-schedule-box .customize-snapshot-control{ + padding: 5px; +} +#customize-schedule-box .accordion-section-title{ + padding: 10px; +} +.in-sub-panel #customize-schedule-box { + left: -100%; + width: 100%; + position: relative; } \ No newline at end of file diff --git a/js/customize-snapshots.js b/js/customize-snapshots.js index 946b2430..a0fed96b 100644 --- a/js/customize-snapshots.js +++ b/js/customize-snapshots.js @@ -159,8 +159,9 @@ component.addButtons = function() { var header = $( '#customize-header-actions' ), publishButton = header.find( '#save' ), - snapshotEditLinkTemplate = wp.template( 'snapshot-edit-link' ), - snapshotButton, submitButton, data, setPreviewLinkHref, snapshotEditLinkEl; + snapshotDropDownToggleTemplate = wp.template( 'snapshot-toggle-button' ), + snapshotScheduleBoxTemplate = wp.template( 'snapshot-schedule-accordion' ), + snapshotScheduleBox, snapshotButton, submitButton, data, setPreviewLinkHref, snapshotDropDownToggle, snapshotEditLink; // Save/update button. snapshotButton = wp.template( 'snapshot-save' ); @@ -174,19 +175,34 @@ snapshotButton.prop( 'disabled', true ); snapshotButton.insertAfter( publishButton ); - snapshotEditLinkEl = $( $.trim( snapshotEditLinkTemplate( component.data ) ) ); - snapshotEditLinkEl.insertAfter( snapshotButton ); + snapshotDropDownToggle = $( $.trim( snapshotDropDownToggleTemplate( {} ) ) ); + snapshotEditLink = snapshotDropDownToggle.find( 'a' ); + + snapshotDropDownToggle.click( function( e ) { + var customizeInfo = $( '#customize-info' ); + if ( ! snapshotScheduleBox ) { + snapshotScheduleBox = $( $.trim( snapshotScheduleBoxTemplate( component.data ) ) ); + snapshotScheduleBox.insertBefore( customizeInfo ); + } else { + + // Todo need to update in case of dynamic section. + snapshotScheduleBox.slideToggle(); + } + e.preventDefault(); + } ); + + snapshotDropDownToggle.insertAfter( snapshotButton ); if ( ! component.data.editLink ) { - snapshotEditLinkEl.hide(); + snapshotDropDownToggle.hide(); } api.state.bind( 'change', function() { - snapshotEditLinkEl.toggle( api.state( 'snapshot-saved' ).get() && api.state( 'snapshot-exists' ).get() ); + snapshotDropDownToggle.toggle( api.state( 'snapshot-saved' ).get() && api.state( 'snapshot-exists' ).get() ); } ); api.state( 'snapshot-saved' ).bind( function( saved ) { snapshotButton.prop( 'disabled', saved ); if ( saved ) { - snapshotEditLinkEl.attr( 'href', component.data.editLink ); + snapshotEditLink.attr( 'href', component.data.editLink ); } } ); @@ -205,7 +221,7 @@ buttonText = component.data.i18n.updateButton; permsMsg = component.data.i18n.permsMsg.update; if ( component.data.editLink ) { - snapshotEditLinkEl.attr( 'href', component.data.editLink ); + snapshotEditLink.attr( 'href', component.data.editLink ); } } else { buttonText = component.data.i18n.saveButton; diff --git a/php/class-customize-snapshot-manager.php b/php/class-customize-snapshot-manager.php index b8bd4ebb..ab29e932 100644 --- a/php/class-customize-snapshot-manager.php +++ b/php/class-customize-snapshot-manager.php @@ -1058,6 +1058,7 @@ public function replace_customize_link( $wp_admin_bar ) { * Underscore (JS) templates for dialog windows. */ public function render_templates() { + $data = $this->data_json(); ?> - + + get_month_choices(); + // Type / width pairs. + $exported['date_inputs'] = array( + 'month' => null, + 'day' => 2, + 'year' => 4, + 'hour' => 2, + 'min' => 2, + ); + return $exported; + } + + /** + * Generate options for the month Select. + * + * Based on touch_time(). + * + * @see touch_time() + * + * @return array + */ + public function get_month_choices() { + global $wp_locale; + $months = array(); + for ( $i = 1; $i < 13; $i = $i + 1 ) { + $month_number = zeroise( $i, 2 ); + $month_text = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); + + /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ + $months[ $i ]['text'] = sprintf( __( '%1$s-%2$s', 'customize-snapshots' ), $month_number, $month_text ); + $months[ $i ]['value'] = $month_number; + } + return $months; + } }