From e280013c8aa571481fa2a7691f5905bb884f40b2 Mon Sep 17 00:00:00 2001 From: Maria Knabe Date: Fri, 10 Jul 2015 16:48:06 -0500 Subject: [PATCH] add option to set a breakpoint to determine when the tabs switch to an accordion --- bootstrap-tabcollapse.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bootstrap-tabcollapse.js b/bootstrap-tabcollapse.js index 76e1279..91689d4 100644 --- a/bootstrap-tabcollapse.js +++ b/bootstrap-tabcollapse.js @@ -42,10 +42,20 @@ }; TabCollapse.prototype.checkState = function(){ - if (this.$tabs.is(':visible') && this._accordionVisible){ + var openTabs = this.$tabs.is(':visible'); + var openAccordion = this.$accordion.is(':visible'); + + if (this.options.breakpoint && this.options.breakpoint > 0) { + var windowWidth = window.innerWidth; + + openTabs = windowWidth >= this.options.breakpoint; + openAccordion = windowWidth < this.options.breakpoint; + } + + if (openTabs && this._accordionVisible){ this.showTabs(); this._accordionVisible = false; - } else if (this.$accordion.is(':visible') && !this._accordionVisible){ + } else if (openAccordion && !this._accordionVisible){ this.showAccordion(); this._accordionVisible = true; }