acf-qtranslate
acf-qtranslate copied to clipboard
Arabic Content RTL vs LTR text
trafficstars
I ran into a pretty obscure issue with this combined with qtranslate. Attempting to get the text aligned right to left instead of left to right. When it comes to the textareas and input fields this is a simple CSS fix, but when it comes to the WYSIWYG editors, they are switched back and forth by (if i understand correctly) replacing an iframe and its content. I was running into some issues accesing that content to edit it so i had to change your plugin a bit. My changes are below, hopefully they make sense:
jQuery(function($) {
$('body').on('click', '.wp-switch-editor[data-language]', function() {
var parent = $(this).parent('.multi-language-field'), language = $(this).data('language');
// start of changes
if(language == 'ar'){
var $iframe = parent.find('iframe').contents();
$iframe.find('p').css({'direction': 'rtl'});
parent.find('iframe').contents($iframe.html());
} else {
var $iframe = parent.find('iframe').contents();
$iframe.find('p').css({'direction': 'ltr'});
parent.find('iframe').contents($iframe.html());
}
// end of changes
parent.find('.current-language').removeClass('current-language');
parent.find('[data-language="' + language + '"]').addClass('current-language');
parent.find('input[data-language="' + language + '"], textarea[data-language="' + language + '"]').focus();
});
$('body').on('focusin', '.multi-language-field input, .multi-language-field textarea', function() {
$(this).parent('.multi-language-field').addClass('focused');
});
$('body').on('focusout', '.multi-language-field input, .multi-language-field textarea', function() {
$(this).parent('.multi-language-field').removeClass('focused');
});
});