diff --git a/src/core/core.tooltip.js b/src/core/core.tooltip.js index 845a578c071..97f7f16df75 100644 --- a/src/core/core.tooltip.js +++ b/src/core/core.tooltip.js @@ -789,7 +789,7 @@ var exports = Element.extend({ var drawColorBoxes = vm.displayColors; var xLinePadding = 0; var colorX = drawColorBoxes ? getAlignedX(vm, 'left') : 0; - + var rtlHelper = getRtlHelper(vm.rtl, vm.x, vm.width); var fillLineOfText = function(line) { @@ -862,7 +862,7 @@ var exports = Element.extend({ var footer = vm.footer; var length = footer.length; var footerFontSize, i; - + if (length) { var rtlHelper = getRtlHelper(vm.rtl, vm.x, vm.width); diff --git a/src/helpers/helpers.rtl.js b/src/helpers/helpers.rtl.js index 3be26990014..dc94c1304ed 100644 --- a/src/helpers/helpers.rtl.js +++ b/src/helpers/helpers.rtl.js @@ -1,6 +1,6 @@ 'use strict'; -var getRtlAdapter = function (rectX, width) { +var getRtlAdapter = function(rectX, width) { return { x: function (x) { return rectX + rectX + width - x; @@ -9,19 +9,21 @@ var getRtlAdapter = function (rectX, width) { width = w; }, textAlign: function(align) { - if (align === 'center') return align; + if (align === 'center') { + return align; + } return align === 'right' ? 'left' : 'right'; }, xPlus: function(x, value) { return x - value; }, - leftForLtr: function(x, width) { - return x - width; + leftForLtr: function(x, itemWidth) { + return x - itemWidth; }, }; }; -var getLtrAdapter = function () { +var getLtrAdapter = function() { return { x: function (x) { return x; @@ -35,23 +37,23 @@ var getLtrAdapter = function () { xPlus: function(x, value) { return x + value; }, - leftForLtr: function(x, width) { + leftForLtr: function(x, _itemWidth) { return x; }, }; }; -var getAdapter = function (rtl, rectX, width) { +var getAdapter = function(rtl, rectX, width) { if (rtl) { return getRtlAdapter(rectX, width); - } else { - return getLtrAdapter(); } -} + + return getLtrAdapter(); +}; var overrideTextDirection = function(ctx, direction) { delete ctx.prevTextDirection; - + if (direction === 'ltr' || direction === 'rtl') { var original = [ ctx.canvas.style.getPropertyValue('direction'), @@ -64,8 +66,9 @@ var overrideTextDirection = function(ctx, direction) { }; var restoreTextDirection = function(ctx) { - if (ctx.prevTextDirection === undefined) + if (ctx.prevTextDirection === undefined) { return; + } var original = ctx.prevTextDirection; delete ctx.prevTextDirection; diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index 878c1a830f8..9d28df30b6f 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -492,7 +492,7 @@ var Legend = Element.extend({ cursor.y += itemHeight; } }); - + helpers.rtl.restoreTextDirection(me.ctx, opts.textDirection); } },