i18n: write code ltr even for rtl languages #492

This commit is contained in:
Sören Weber 2023-02-25 00:05:38 +01:00
parent c0a1c9cbcb
commit 27bb276909
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
2 changed files with 5 additions and 6 deletions

View file

@ -548,10 +548,11 @@ pre {
position: relative; position: relative;
} }
pre.pre-code, /* pre:has( code ), */
pre:has( code ){ /* the :has() operator isn't available in FF yet, so we patch this by JS */
/* the :has() operator isn't available in FF yet, so we patch this by JS */ pre.pre-code {
direction: ltr; direction: ltr;
text-align: left;
} }
pre code { pre code {

View file

@ -368,13 +368,11 @@ function initCodeClipboard(){
clip.on( 'success', function( e ){ clip.on( 'success', function( e ){
e.clearSelection(); e.clearSelection();
var inPre = e.trigger.parentNode.tagName.toLowerCase() == 'pre';
e.trigger.setAttribute( 'aria-label', window.T_Copied_to_clipboard ); e.trigger.setAttribute( 'aria-label', window.T_Copied_to_clipboard );
e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (inPre ? 'w' : 's'+(isRtl?'e':'w')) ); e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (inPre ? 'w' : 's'+(isRtl?'e':'w')) );
}); });
clip.on( 'error', function( e ){ clip.on( 'error', function( e ){
var inPre = e.trigger.parentNode.tagName.toLowerCase() == 'pre';
e.trigger.setAttribute( 'aria-label', fallbackMessage(e.action) ); e.trigger.setAttribute( 'aria-label', fallbackMessage(e.action) );
e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (inPre ? 'w' : 's'+(isRtl?'e':'w')) ); e.trigger.classList.add( 'tooltipped', 'tooltipped-' + (inPre ? 'w' : 's'+(isRtl?'e':'w')) );
var f = function(){ var f = function(){
@ -388,7 +386,7 @@ function initCodeClipboard(){
code.classList.add( 'copy-to-clipboard-code' ); code.classList.add( 'copy-to-clipboard-code' );
if( inPre ){ if( inPre ){
code.classList.add( 'copy-to-clipboard' ); code.classList.add( 'copy-to-clipboard' );
code.classList.add( 'pre-code' ); code.parentNode.classList.add( 'pre-code' );
} }
else{ else{
var clone = code.cloneNode( true ); var clone = code.cloneNode( true );