Set caret-clone position based on rtl class

This commit is contained in:
scossar 2018-01-17 12:09:27 -08:00
parent b652791a20
commit d0c467babc
2 changed files with 4 additions and 8 deletions

View File

@ -56,9 +56,3 @@ float: left !important;
.rtl .dashboard-right {
float: left !important;
}
// Right and left will be flipped by the r2 gem
.rtl #caret-clone[style] {
right: auto !important;
left: -7000px !important;
}

View File

@ -45,7 +45,7 @@ $.fn.caretPosition = function(options) {
};
styles = getStyles(textarea[0]);
clone = $("<div id='caret-clone'><p></p></div>").appendTo("body");
clone = $("<div><p></p></div>").appendTo("body");
p = clone.find("p");
clone.width(textarea.width());
clone.height(textarea.height());
@ -54,6 +54,7 @@ $.fn.caretPosition = function(options) {
return styles.getPropertyValue(prop);
};
const isRTL = $('html').hasClass('rtl');
clone.css({
border: "1px solid black",
padding: important("padding"),
@ -62,7 +63,8 @@ $.fn.caretPosition = function(options) {
"overflow-y": "auto",
"word-wrap": "break-word",
position: "absolute",
left: "-7000px"
left: isRTL ? "auto" : "-7000px",
right: isRTL ? "-7000px" : "auto"
});
p.css({