Focus and blur styling (via JS) for the install screen language selector. Props jorbin. See #28577

git-svn-id: https://develop.svn.wordpress.org/trunk@29020 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2014-07-08 00:29:47 +00:00
parent 40be2934d4
commit 02a22f7dd4
6 changed files with 54 additions and 3 deletions

View File

@ -337,7 +337,6 @@ body.language-chooser {
height: 250px;
}
/* TODO:add focus style via JS */
.language-chooser fieldset.focus {
border-color: #5b9dd9;
-webkit-box-shadow: 0 0 2px rgba(30,140,190,0.8);
@ -355,9 +354,17 @@ body.language-chooser {
.language-chooser input:checked + label{
color:white;
background: #777;
}
.language-chooser .focus input:checked + label{
background: #0074A2;
}
.language-chooser label:hover {
background: #eee;
}
.language-chooser label{
display:block;
}
@ -373,3 +380,5 @@ body.language-chooser {
clip: rect(0 0 0 0);
border: 0;
}
}

View File

@ -2162,7 +2162,7 @@ endif;
function wp_install_language_form( $languages ) {
echo "<fieldset>\n";
echo "<legend class='screen-reader-text'>Select a default language</legend>\n";
echo '<input type="radio" checked="checked" class="screen-reader-input" name="language" id="language_default" value="">';
echo '<input type="radio" checked="checked" class="screen-reader-input language-chooser-input" name="language" id="language_default" value="">';
echo '<label for="language_default">English (United States)</label>';
echo "\n";
@ -2175,7 +2175,7 @@ function wp_install_language_form( $languages ) {
}
foreach ( $languages as $language ) {
echo '<input type="radio" name="language" class="' . esc_attr( $language['language'] ) . ' screen-reader-input" id="language_'. esc_attr( $language['language'] ) .'" value="' . esc_attr( $language['language'] ) . '">';
echo '<input type="radio" name="language" class="' . esc_attr( $language['language'] ) . ' screen-reader-input language-chooser-input" id="language_'. esc_attr( $language['language'] ) .'" value="' . esc_attr( $language['language'] ) . '">';
echo '<label for="language_' . esc_attr( $language['language'] ) . '">' . esc_html( $language['native_name'] ) . "</label>\n";
}
echo "</fieldset>\n";

View File

@ -281,5 +281,6 @@ if ( !wp_is_mobile() ) {
<script type="text/javascript">var t = document.getElementById('weblog_title'); if (t){ t.focus(); }</script>
<?php } ?>
<?php wp_print_scripts( 'user-profile' ); ?>
<?php wp_print_scripts( 'language-chooser' ); ?>
</body>
</html>

View File

@ -0,0 +1,39 @@
(function($){
if ( $('body').hasClass('language-chooser') === false ) {
return;
}
var mouseDown = 0,
$fieldset = $('fieldset');
// simple way to check if mousebutton is depressed while accounting for multiple mouse buttons being used independently
document.body.onmousedown = function() {
++mouseDown;
};
document.body.onmouseup = function() {
--mouseDown;
};
/*
we can't rely upon the focusout event
since clicking on a label triggers it
*/
function maybeRemoveFieldsetFocus(){
if (mouseDown) {
setTimeout( maybeRemoveFieldsetFocus, 50);
return;
}
if ( $(':focus').hasClass('language-chooser-input') !== true ) {
$fieldset.removeClass('focus');
}
}
$fieldset.focusin( function() {
$(this).addClass('focus');
});
$fieldset.focusout( function() {
setTimeout( maybeRemoveFieldsetFocus, 50);
});
})(jQuery);

View File

@ -319,5 +319,6 @@ el.select();
break;
}
?>
<?php wp_print_scripts( 'language-chooser' ); ?>
</body>
</html>

View File

@ -345,6 +345,7 @@ function wp_default_scripts( &$scripts ) {
) );
$scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 );
$scripts->add( 'language-chooser', "/wp-admin/js/language-chooser$suffix.js", array( 'jquery' ), false, 1 );
$scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );