Skip to content

Instantly share code, notes, and snippets.

@hamidazimy
Last active November 13, 2015 08:22
Show Gist options
  • Save hamidazimy/e4500d069a205c0ad003 to your computer and use it in GitHub Desktop.
Save hamidazimy/e4500d069a205c0ad003 to your computer and use it in GitHub Desktop.
Tiny script to add RTL support to JIRA (can be used everywhere with a little modification)
// ==UserScript==
// @name RTL Jira
// @namespace medianesh.com:9090
// @include http://medianesh.com:9090/*
// @version 0.2
// @grant none
// ==/UserScript==
function isRTL(text) {
if (text !== "") {
if ("اآبپتثجچحخدذرزژسشصضطظعغفقکگلمنوهیؤئيإأةك۰۱۲۳۴۵۶۷۸۹".indexOf(text[0]) > -1) {
return true;
}
}
return false;
}
if (jQuery !== undefined) {
jQuery(document).ready(function() {
jQuery('head').append('\
<style type="text/css">\
.rtl:before {\
content: "\u202B";\
}\
.rtl {\
direction: rtl;\
}\
.rtl:after {\
content: "\u200F";\
}\
body {\
font-family: vazir, "DejaVu Sans", Tahoma, sans-serif !important;\
}\
</style>\
');
setInterval(function() {
jQuery('textarea, input').each(function() {
if (isRTL(jQuery(this).val())) {
jQuery(this).addClass('rtl');
}
else {
jQuery(this).removeClass('rtl');
}
});
jQuery('.ghx-editable p, .editable-field p, .action-body p, .ghx-inner').not('.rtl').not('.ltr').each(function() {
console.log(jQuery(this).text());
if (isRTL(jQuery(this).text())) {
jQuery(this).addClass('rtl');
}
else {
jQuery(this).addClass('ltr');
}
});
}, 500);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment