1
1
angular . module ( 'ui.tab.scroll' , [ ] )
2
+ . provider ( 'scrollableTabsetConfig' , function ( ) {
3
+
4
+ //the default options
5
+ var defaultConfig = {
6
+ showTooltips : true ,
7
+
8
+ tooltipLeft : 'bottom' ,
9
+ tooltipRight : 'bottom' ,
10
+
11
+ //select the innermost child that isn't a span
12
+ //this way we cover getting <tab-heading> and <tab heading=''>
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'
18
+ } ;
19
+
20
+ var config = angular . extend ( { } , defaultConfig ) ;
21
+
22
+ return {
23
+ setShowTooltips : function ( value ) {
24
+ config . showTooltips = value ;
25
+ } ,
26
+ setTooltipLeft : function ( value ) {
27
+ config . tooltipLeft = value ;
28
+ } ,
29
+ setTooltipRight : function ( value ) {
30
+ config . tooltipRight = value ;
31
+ } ,
32
+ setTooltipTextSelector : function ( value ) {
33
+ config . tooltipTextSelector = value ;
34
+ } ,
35
+ setScrollLeftIcon : function ( value ) {
36
+ config . scrollLeftIcon = value ;
37
+ } ,
38
+ setScrollRightIcon : function ( value ) {
39
+ config . scrollRightIcon = value ;
40
+ } ,
41
+ $get : function ( ) {
42
+ return {
43
+ showTooltips : config . showTooltips ,
44
+ tooltipLeft : config . tooltipLeft ,
45
+ tooltipRight : config . tooltipRight ,
46
+ tooltipTextSelector : config . tooltipTextSelector ,
47
+ scrollLeftIcon : config . scrollLeftIcon ,
48
+ scrollRightIcon : config . scrollRightIcon
49
+ } ;
50
+ }
51
+ } ;
52
+ }
53
+ )
2
54
. directive ( 'scrollableTabset' , [
3
- '$window' , '$interval' , '$timeout' ,
4
- function ( $window , $interval , $timeout ) {
55
+ 'scrollableTabsetConfig' , ' $window', '$interval' , '$timeout' ,
56
+ function ( scrollableTabsetConfig , $window , $interval , $timeout ) {
5
57
6
58
var timeoutId = null ;
7
59
@@ -75,6 +127,8 @@ angular.module('ui.tab.scroll', [])
75
127
$scope . toTheLeftHTML = '' ;
76
128
$scope . toTheRightHTML = '' ;
77
129
130
+ var showTooltips = angular . isDefined ( $scope . showTooltips ) ? $scope . showTooltips : scrollableTabsetConfig . showTooltips ;
131
+
78
132
$scope . disableLeft = function ( ) {
79
133
return ! $scope . toTheLeftHTML ;
80
134
} ;
@@ -84,36 +138,32 @@ angular.module('ui.tab.scroll', [])
84
138
} ;
85
139
86
140
$scope . tooltipLeftContent = function ( ) {
87
- return $scope . showTooltips ? $scope . toTheLeftHTML : '' ;
141
+ return showTooltips ? $scope . toTheLeftHTML : '' ;
88
142
} ;
89
143
90
144
$scope . tooltipRightContent = function ( ) {
91
- return $scope . showTooltips ? $scope . toTheRightHTML : '' ;
145
+ return showTooltips ? $scope . toTheRightHTML : '' ;
92
146
} ;
93
147
94
148
$scope . tooltipLeftDirection = function ( ) {
95
- return $scope . tooltipLeft ? $scope . tooltipLeft : 'bottom' ;
149
+ return $scope . tooltipLeft ? $scope . tooltipLeft : scrollableTabsetConfig . tooltipLeft ;
96
150
} ;
97
151
98
152
$scope . tooltipRightDirection = function ( ) {
99
- return $scope . tooltipRight ? $scope . tooltipRight : 'bottom' ;
153
+ return $scope . tooltipRight ? $scope . tooltipRight : scrollableTabsetConfig . tooltipRight ;
100
154
} ;
101
155
102
156
$scope . scrollLeftIconClass = function ( ) {
103
- return $scope . scrollLeftIcon ? $scope . scrollLeftIcon : 'glyphicon glyphicon-chevron-left' ;
157
+ return $scope . scrollLeftIcon ? $scope . scrollLeftIcon : scrollableTabsetConfig . scrollLeftIcon ;
104
158
} ;
105
159
106
160
$scope . scrollRightIconClass = function ( ) {
107
- return $scope . scrollRightIcon ? $scope . scrollRightIcon : 'glyphicon glyphicon-chevron-right' ;
161
+ return $scope . scrollRightIcon ? $scope . scrollRightIcon : scrollableTabsetConfig . scrollRightIcon ;
108
162
} ;
109
163
110
- //select the innermost child that isn't a span
111
- //this way we cover getting <tab-heading> and <tab heading=''>
112
- //but leave other markup out of it, unless it's a span (commonly an icon)
113
- var selector = '*:not(:has("*:not(span)"))' ;
114
164
115
165
$scope . getSelector = function ( ) {
116
- return $scope . tooltipTextSelector ? $scope . tooltipTextSelector : selector ;
166
+ return $scope . tooltipTextSelector ? $scope . tooltipTextSelector : scrollableTabsetConfig . tooltipTextSelector ;
117
167
} ;
118
168
119
169
$scope . toTheLeft = function ( ) {
0 commit comments