Browse Source

Add support to rtl with dir

codeClimate
Yotam Berkowitz 8 years ago
parent
commit
510adfc282
2 changed files with 15 additions and 8 deletions
  1. +1
    -2
      lib/timeline/Core.js
  2. +14
    -6
      lib/timeline/Timeline.js

+ 1
- 2
lib/timeline/Core.js View File

@ -277,8 +277,7 @@ Core.prototype.setOptions = function (options) {
'start', 'end', 'clickToUse', 'dataAttributes', 'hiddenDates',
'locale', 'locales', 'moment', 'rtl', 'zoomKey', 'horizontalScroll', 'verticalScroll'
];
util.selectiveExtend(fields, this.options, options);
util.selectiveExtend(fields, this.options, options);
if (this.options.rtl) {
this.dom.container.style.direction = "rtl";

+ 14
- 6
lib/timeline/Timeline.js View File

@ -57,9 +57,17 @@ function Timeline (container, items, groups, options) {
minHeight: null
};
this.options = util.deepExtend({}, this.defaultOptions);
if (options) {
this.options.rtl = options.rtl
}
if (!options || (options && typeof options.rtl == "undefined")) {
if (container.dir) {
this.options.rtl = container.dir == "rtl";
} else if (document.dir) {
this.options.rtl = document.dir == "rtl";
}
} else {
this.options.rtl = options.rtl;
}
// Create the DOM, props, and emitter
this._create(container);
@ -91,17 +99,17 @@ function Timeline (container, items, groups, options) {
};
// range
this.range = new Range(this.body);
this.range = new Range(this.body, this.options);
this.components.push(this.range);
this.body.range = this.range;
// time axis
this.timeAxis = new TimeAxis(this.body);
this.timeAxis = new TimeAxis(this.body, this.options);
this.timeAxis2 = null; // used in case of orientation option 'both'
this.components.push(this.timeAxis);
// current time bar
this.currentTime = new CurrentTime(this.body);
this.currentTime = new CurrentTime(this.body, this.options);
this.components.push(this.currentTime);
// item set

Loading…
Cancel
Save