wip
This commit is contained in:
@@ -109,18 +109,35 @@ class WP_Widget_Archives extends WP_Widget {
|
||||
|
||||
<?php ob_start(); ?>
|
||||
<script>
|
||||
(function() {
|
||||
var dropdown = document.getElementById( "<?php echo esc_js( $dropdown_id ); ?>" );
|
||||
( ( dropdownId ) => {
|
||||
const dropdown = document.getElementById( dropdownId );
|
||||
function onSelectChange() {
|
||||
if ( dropdown.options[ dropdown.selectedIndex ].value !== '' ) {
|
||||
document.location.href = this.options[ this.selectedIndex ].value;
|
||||
setTimeout( () => {
|
||||
if ( 'escape' === dropdown.dataset.lastkey ) {
|
||||
return;
|
||||
}
|
||||
if ( dropdown.value ) {
|
||||
document.location.href = dropdown.value;
|
||||
}
|
||||
}, 250 );
|
||||
}
|
||||
function onKeyUp( event ) {
|
||||
if ( 'Escape' === event.key ) {
|
||||
dropdown.dataset.lastkey = 'escape';
|
||||
} else {
|
||||
delete dropdown.dataset.lastkey;
|
||||
}
|
||||
}
|
||||
dropdown.onchange = onSelectChange;
|
||||
})();
|
||||
function onClick() {
|
||||
delete dropdown.dataset.lastkey;
|
||||
}
|
||||
dropdown.addEventListener( 'keyup', onKeyUp );
|
||||
dropdown.addEventListener( 'click', onClick );
|
||||
dropdown.addEventListener( 'change', onSelectChange );
|
||||
})( <?php echo wp_json_encode( $dropdown_id, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
|
||||
</script>
|
||||
<?php
|
||||
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) );
|
||||
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
|
||||
} else {
|
||||
$format = current_theme_supports( 'html5', 'navigation-widgets' ) ? 'html5' : 'xhtml';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user