diff --git a/apps/common/main/lib/component/TabBar.js b/apps/common/main/lib/component/TabBar.js index 785530d4e7..ba7c42896b 100644 --- a/apps/common/main/lib/component/TabBar.js +++ b/apps/common/main/lib/component/TabBar.js @@ -528,43 +528,83 @@ define([ } var rightbound = this.$bar.width(), tab, right, left; - if (index == 'forward') { - for (var i = 0; i < this.tabs.length; i++) { - tab = this.tabs[i].$el; - right = Common.Utils.getPosition(tab).left + parseInt(tab.css('width')); - - if (right > rightbound) { - this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + (this.$bar.width() > 400 ? 20 : 5)); - this.checkInvisible(suppress); - break; + if (this.isRTL) { + if (index == 'forward') { + for (var i = this.tabs.length - 1; i >= 0; i--) { + tab = this.tabs[i].$el; + right = Common.Utils.getPosition(tab).left + parseInt(tab.css('width')); + + if (right > rightbound) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + (rightbound > 400 ? 20 : 5)); + this.checkInvisible(suppress); + break; + } + } } - } - } else if (index == 'backward') { - for (i = this.tabs.length; i-- > 0; ) { - tab = this.tabs[i].$el; - left = Common.Utils.getPosition(tab).left; - - if (left < 0) { - this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26); - this.checkInvisible(suppress); - break; + else if (index == 'backward') { + for (var i = 0; i < this.tabs.length; i++) { + tab = this.tabs[i].$el; + left = Common.Utils.getPosition(tab).left; + + if (left < 0) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26); + this.checkInvisible(suppress); + break; + } + } + } + else if (typeof index == 'number') { + tab = this.tabs[index].$el; + left = Common.Utils.getPosition(tab).left; + right = left + parseInt(tab.css('width')); + + if (right > rightbound) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20); + this.checkInvisible(suppress); + } else if (left < 0) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26); + this.checkInvisible(suppress); + } + } + } else { + if (index == 'forward') { + for (var i = 0; i < this.tabs.length; i++) { + tab = this.tabs[i].$el; + right = Common.Utils.getPosition(tab).left + parseInt(tab.css('width')); + + if (right > rightbound) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + (this.$bar.width() > 400 ? 20 : 5)); + this.checkInvisible(suppress); + break; + } + } + } else if (index == 'backward') { + for (i = this.tabs.length; i-- > 0; ) { + tab = this.tabs[i].$el; + left = Common.Utils.getPosition(tab).left; + + if (left < 0) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26); + this.checkInvisible(suppress); + break; + } + } + } else if (typeof index == 'number') { + tab = this.tabs[index].$el; + left = Common.Utils.getPosition(tab).left; + right = left + parseInt(tab.css('width')); + + if (left < 0) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26); + this.checkInvisible(suppress); + } else if (right > rightbound) { + this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20); + this.checkInvisible(suppress); + } } - } - } else if (typeof index == 'number') { - tab = this.tabs[index].$el; - left = Common.Utils.getPosition(tab).left; - right = left + parseInt(tab.css('width')); - - if (left < 0) { - this.$bar.scrollLeft(this.$bar.scrollLeft() + left - 26); - this.checkInvisible(suppress); - } else if (right > rightbound) { - this.$bar.scrollLeft(this.$bar.scrollLeft() + (right - rightbound) + 20); - this.checkInvisible(suppress); } } - } - }, + }, checkInvisible: function(suppress) { var result = {