@@ -11,10 +11,7 @@ angular.module('ui.tab.scroll', [])
11
11
//select the innermost child that isn't a span
12
12
//this way we cover getting <tab-heading> and <tab heading=''>
13
13
//but leave other markup out of it, unless it's a span (commonly an icon)
14
- tooltipTextSelector : '*:not(:has("*:not(span)"))' ,
15
-
16
- scrollLeftIcon : 'glyphicon glyphicon-chevron-left' ,
17
- scrollRightIcon : 'glyphicon glyphicon-chevron-right'
14
+ tooltipTextSelector : '*:not(:has("*:not(span)"))'
18
15
} ;
19
16
20
17
var config = angular . extend ( { } , defaultConfig ) ;
@@ -32,28 +29,20 @@ angular.module('ui.tab.scroll', [])
32
29
setTooltipTextSelector : function ( value ) {
33
30
config . tooltipTextSelector = value ;
34
31
} ,
35
- setScrollLeftIcon : function ( value ) {
36
- config . scrollLeftIcon = value ;
37
- } ,
38
- setScrollRightIcon : function ( value ) {
39
- config . scrollRightIcon = value ;
40
- } ,
41
32
$get : function ( ) {
42
33
return {
43
34
showTooltips : config . showTooltips ,
44
35
tooltipLeft : config . tooltipLeft ,
45
36
tooltipRight : config . tooltipRight ,
46
- tooltipTextSelector : config . tooltipTextSelector ,
47
- scrollLeftIcon : config . scrollLeftIcon ,
48
- scrollRightIcon : config . scrollRightIcon
37
+ tooltipTextSelector : config . tooltipTextSelector
49
38
} ;
50
39
}
51
40
} ;
52
41
}
53
42
)
54
43
. directive ( 'scrollableTabset' , [
55
- 'scrollableTabsetConfig' , '$window' , '$interval' , '$timeout' ,
56
- function ( scrollableTabsetConfig , $window , $interval , $timeout ) {
44
+ 'scrollableTabsetConfig' , '$window' , '$interval' , '$timeout' , '$sce' ,
45
+ function ( scrollableTabsetConfig , $window , $interval , $timeout , $sce ) {
57
46
58
47
var timeoutId = null ;
59
48
@@ -105,44 +94,32 @@ angular.module('ui.tab.scroll', [])
105
94
showTooltips : '=' ,
106
95
tooltipLeft : '=' ,
107
96
tooltipRight : '=' ,
108
- tooltipTextSelector : '=' ,
109
- scrollLeftIcon : '=' ,
110
- scrollRightIcon : '='
97
+ tooltipTextSelector : '='
111
98
} ,
112
99
113
100
template : [
114
101
'<div class="ui-tabs-scrollable">' ,
115
- '<button type="button" ng-hide="hideButtons" ng-disabled="disableLeft()" class="btn nav-button left-nav-button" tooltip-placement="{{tooltipLeftDirection()}}" tooltip-html-unsafe="{{tooltipLeftContent()}}">' ,
116
- '<span class="{{scrollLeftIconClass()}}"></span>' ,
117
- '</button>' ,
102
+ '<button type="button" ng-hide="hideButtons" ng-disabled="disableLeft()" class="btn nav-button left-nav-button" tooltip-placement="{{tooltipLeftDirection()}}" tooltip-html="tooltipLeftHtml"/>' ,
118
103
'<div class="spacer" ng-class="{\'hidden-buttons\': hideButtons}" ng-transclude></div>' ,
119
- '<button type="button" ng-hide="hideButtons" ng-disabled="disableRight()" class="btn nav-button right-nav-button" tooltip-placement="{{tooltipRightDirection()}}" tooltip-html-unsafe="{{tooltipRightContent()}}">' ,
120
- '<span class="{{scrollRightIconClass()}}"></span>' ,
121
- '</button>' ,
104
+ '<button type="button" ng-hide="hideButtons" ng-disabled="disableRight()" class="btn nav-button right-nav-button" tooltip-placement="{{tooltipRightDirection()}}" tooltip-html="tooltipRightHtml"/>' ,
122
105
'</div>'
123
106
] . join ( '' ) ,
124
107
125
108
link : function ( $scope , $el ) {
126
109
127
- $scope . toTheLeftHTML = '' ;
128
- $scope . toTheRightHTML = '' ;
110
+ $scope . tooltipRightHtml = '' ;
111
+ $scope . tooltipLeftHtml = '' ;
112
+ var toTheLeftHTML = '' ;
113
+ var toTheRightHTML = '' ;
129
114
130
115
var showTooltips = angular . isDefined ( $scope . showTooltips ) ? $scope . showTooltips : scrollableTabsetConfig . showTooltips ;
131
116
132
117
$scope . disableLeft = function ( ) {
133
- return ! $scope . toTheLeftHTML ;
118
+ return ! toTheLeftHTML ;
134
119
} ;
135
120
136
121
$scope . disableRight = function ( ) {
137
- return ! $scope . toTheRightHTML ;
138
- } ;
139
-
140
- $scope . tooltipLeftContent = function ( ) {
141
- return showTooltips ? $scope . toTheLeftHTML : '' ;
142
- } ;
143
-
144
- $scope . tooltipRightContent = function ( ) {
145
- return showTooltips ? $scope . toTheRightHTML : '' ;
122
+ return ! toTheRightHTML ;
146
123
} ;
147
124
148
125
$scope . tooltipLeftDirection = function ( ) {
@@ -153,15 +130,6 @@ angular.module('ui.tab.scroll', [])
153
130
return $scope . tooltipRight ? $scope . tooltipRight : scrollableTabsetConfig . tooltipRight ;
154
131
} ;
155
132
156
- $scope . scrollLeftIconClass = function ( ) {
157
- return $scope . scrollLeftIcon ? $scope . scrollLeftIcon : scrollableTabsetConfig . scrollLeftIcon ;
158
- } ;
159
-
160
- $scope . scrollRightIconClass = function ( ) {
161
- return $scope . scrollRightIcon ? $scope . scrollRightIcon : scrollableTabsetConfig . scrollRightIcon ;
162
- } ;
163
-
164
-
165
133
$scope . getSelector = function ( ) {
166
134
return $scope . tooltipTextSelector ? $scope . tooltipTextSelector : scrollableTabsetConfig . tooltipTextSelector ;
167
135
} ;
@@ -184,7 +152,8 @@ angular.module('ui.tab.scroll', [])
184
152
185
153
} ) ;
186
154
187
- $scope . toTheLeftHTML = nodes . join ( '<br>' ) ;
155
+ toTheLeftHTML = nodes . join ( '<br>' ) ;
156
+ $scope . tooltipLeftHtml = showTooltips ? $sce . trustAsHtml ( toTheLeftHTML ) : '' ;
188
157
} ;
189
158
190
159
$scope . toTheRight = function ( ) {
@@ -206,7 +175,8 @@ angular.module('ui.tab.scroll', [])
206
175
207
176
} ) ;
208
177
209
- $scope . toTheRightHTML = nodes . join ( '<br>' ) ;
178
+ toTheRightHTML = nodes . join ( '<br>' ) ;
179
+ $scope . tooltipRightHtml = showTooltips ? $sce . trustAsHtml ( toTheRightHTML ) : '' ;
210
180
} ;
211
181
212
182
$scope . recalcSides = function ( ) {
@@ -246,7 +216,11 @@ angular.module('ui.tab.scroll', [])
246
216
$scope . $apply ( ) ;
247
217
} ;
248
218
249
- //hello my friend jake weary
219
+ $ . fn . doRecalculate = function ( ) {
220
+ init ( ) ;
221
+ $scope . $apply ( ) ;
222
+ } ;
223
+
250
224
$ ( window ) . on ( 'resize' , initAndApply ) ;
251
225
252
226
//we initialize by watching changes on the inner tabset's tabs collection
0 commit comments