Skip to content

Commit dea1de0

Browse files
committed
Keep angular-ui tab content wired to scope
Fixes Issue #28
1 parent e740dca commit dea1de0

16 files changed

+46
-134
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-bootstrap-scrolling-tabs",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"main": [
55
"./dist/scrolling-tabs.js",
66
"./dist/scrolling-tabs.css"

dist/scrolling-tabs.css

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* angular-bootstrap-scrolling-tabs
3-
* @version v1.1.0
3+
* @version v1.2.0
44
* @link https://github.com/mikejacobson/angular-bootstrap-scrolling-tabs
55
* @author Mike Jacobson <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -56,9 +56,3 @@
5656

5757
.scrtabs-tabs-fixed-container ul.nav-tabs > li {
5858
white-space: nowrap; }
59-
60-
.scrtabs-tab-content-outside-movable-container {
61-
clear: left; }
62-
63-
.scrtabs-tab-content-outside-movable-container .nav-tabs {
64-
display: none; }

dist/scrolling-tabs.js

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* angular-bootstrap-scrolling-tabs
3-
* @version v1.1.0
3+
* @version v1.2.0
44
* @link https://github.com/mikejacobson/angular-bootstrap-scrolling-tabs
55
* @author Mike Jacobson <[email protected]>
66
* @license MIT License, http://www.opensource.org/licenses/MIT
@@ -113,41 +113,15 @@
113113
var ehd = this,
114114
stc = ehd.stc,
115115
$tabsContainer = stc.$tabsContainer,
116-
tabContentCloneCssClass = 'scrtabs-tab-content-clone',
117-
$tabContentInMovableContainer = $tabsContainer.find('.scrtabs-tabs-movable-container .tab-content'),
118-
$currTcClone,
119-
$newTcClone;
120-
121-
// if the tabs won't be changing, we can just move the
122-
// the .tab-content outside the scrolling container right now
123-
if (!options.isWatchingTabs) {
124-
$tabContentInMovableContainer.show().appendTo($tabsContainer);
125-
return;
126-
}
116+
$movableContainer = $tabsContainer.find('.scrtabs-tabs-movable-container'),
117+
$tabContentInMovableContainer = $movableContainer.find('.tab-content'),
118+
uibTabsetController = $movableContainer.find('> div').eq(0).data('$uibTabsetController');
127119

128-
/* if we're watching the tabs for changes, we can't just
129-
* move the .tab-content outside the scrolling container because
130-
* that will break the angular-ui directive dependencies, and
131-
* an error will be thrown as soon as the tabs change;
132-
* so we leave the .tab-content where it is but hide it, then
133-
* make a clone and move the clone outside the scroll container,
134-
* which will be the visible .tab-content.
135-
*/
136-
137-
// create new clone
138-
$newTcClone = $tabContentInMovableContainer
139-
.clone()
140-
.addClass(tabContentCloneCssClass);
141-
142-
// get the current clone, if it exists
143-
$currTcClone = $tabsContainer.find('.' + tabContentCloneCssClass);
144-
145-
if ($currTcClone.length) { // already a clone there so replace it
146-
$currTcClone.replaceWith($newTcClone);
147-
} else {
148-
$tabsContainer.append($newTcClone);
149-
}
120+
$tabContentInMovableContainer.show().appendTo($tabsContainer);
150121

122+
if (uibTabsetController) {
123+
$tabContentInMovableContainer.data('$uibTabsetController', uibTabsetController);
124+
}
151125
};
152126

153127
p.refreshAllElementSizes = function () {
@@ -195,14 +169,6 @@
195169
return actionsTaken;
196170
};
197171

198-
p.removeTranscludedTabContentOutsideMovableContainer = function () {
199-
var ehd = this,
200-
stc = ehd.stc,
201-
$tabsContainer = stc.$tabsContainer;
202-
203-
$tabsContainer.find('.scrtabs-tab-content-outside-movable-container').remove();
204-
};
205-
206172
p.setElementReferences = function () {
207173
var ehd = this,
208174
stc = ehd.stc,
@@ -731,18 +697,9 @@
731697
isOnTabsRefresh: options.isWatchingTabs
732698
});
733699
}
734-
735-
736700
}, 100);
737701
};
738702

739-
p.removeTranscludedTabContentOutsideMovableContainer = function() {
740-
var stc = this,
741-
elementsHandler = stc.elementsHandler;
742-
743-
elementsHandler.removeTranscludedTabContentOutsideMovableContainer();
744-
};
745-
746703
/**
747704
* Handles control arrows classnames
748705
*
@@ -928,7 +885,6 @@
928885
}
929886

930887
if (!isWrappingAngularUITabset) {
931-
scrollingTabsControl.removeTranscludedTabContentOutsideMovableContainer();
932888
scrtc.hasTabContentOutsideMovableContainer = false;
933889
}
934890

@@ -962,7 +918,6 @@
962918
(attrs.watchTabs && attrs.watchTabs.toLowerCase() === 'true')) {
963919

964920
if (isWrappingAngularUITabset) {
965-
scrollingTabsControl.removeTranscludedTabContentOutsideMovableContainer();
966921
scrtc.hasTabContentOutsideMovableContainer = false;
967922
}
968923

dist/scrolling-tabs.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)