Skip to content

Commit

Permalink
Satisfy linter
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Aug 12, 2019
1 parent 4312ec5 commit 6d87dcd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/core/core.tooltip.js
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
36 changes: 19 additions & 17 deletions src/helpers/helpers.rtl.js
@@ -1,57 +1,58 @@
'use strict';

var getRtlAdapter = function (rectX, width) {
var getRtlAdapter = function(rectX, width) {
return {
x: function (x) {
x: function(x) {
return rectX + rectX + width - x;
},
setWidth: function (w) {
setWidth: function(w) {
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) {
x: function(x) {
return x;
},
setWidth: function (w) {
width = w;
setWidth: function(w) { // eslint-disable-line no-unused-vars
},
textAlign: function(align) {
return align;
},
xPlus: function(x, value) {
return x + value;
},
leftForLtr: function(x, width) {
leftForLtr: function(x, _itemWidth) { // eslint-disable-line no-unused-vars
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'),
Expand All @@ -64,8 +65,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;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plugin.legend.js
Expand Up @@ -492,7 +492,7 @@ var Legend = Element.extend({
cursor.y += itemHeight;
}
});

helpers.rtl.restoreTextDirection(me.ctx, opts.textDirection);
}
},
Expand Down

0 comments on commit 6d87dcd

Please sign in to comment.