Skip to content

Commit 33e1eaf

Browse files
committed
template now do not require functions for icons
with this change, and the new css, there is no need any more to set the icons in code
1 parent 84a8159 commit 33e1eaf

File tree

1 file changed

+22
-48
lines changed

1 file changed

+22
-48
lines changed

angular-ui-tab-scroll.js

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ angular.module('ui.tab.scroll', [])
1111
//select the innermost child that isn't a span
1212
//this way we cover getting <tab-heading> and <tab heading=''>
1313
//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)"))'
1815
};
1916

2017
var config = angular.extend({}, defaultConfig);
@@ -32,28 +29,20 @@ angular.module('ui.tab.scroll', [])
3229
setTooltipTextSelector : function(value){
3330
config.tooltipTextSelector = value;
3431
},
35-
setScrollLeftIcon : function(value){
36-
config.scrollLeftIcon = value;
37-
},
38-
setScrollRightIcon : function(value){
39-
config.scrollRightIcon = value;
40-
},
4132
$get: function(){
4233
return {
4334
showTooltips: config.showTooltips,
4435
tooltipLeft: config.tooltipLeft,
4536
tooltipRight: config.tooltipRight,
46-
tooltipTextSelector: config.tooltipTextSelector,
47-
scrollLeftIcon: config.scrollLeftIcon,
48-
scrollRightIcon: config.scrollRightIcon
37+
tooltipTextSelector: config.tooltipTextSelector
4938
};
5039
}
5140
};
5241
}
5342
)
5443
.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) {
5746

5847
var timeoutId = null;
5948

@@ -105,44 +94,32 @@ angular.module('ui.tab.scroll', [])
10594
showTooltips: '=',
10695
tooltipLeft: '=',
10796
tooltipRight: '=',
108-
tooltipTextSelector: '=',
109-
scrollLeftIcon: '=',
110-
scrollRightIcon: '='
97+
tooltipTextSelector: '='
11198
},
11299

113100
template: [
114101
'<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"/>',
118103
'<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"/>',
122105
'</div>'
123106
].join(''),
124107

125108
link: function($scope, $el) {
126109

127-
$scope.toTheLeftHTML = '';
128-
$scope.toTheRightHTML = '';
110+
$scope.tooltipRightHtml = '';
111+
$scope.tooltipLeftHtml = '';
112+
var toTheLeftHTML = '';
113+
var toTheRightHTML = '';
129114

130115
var showTooltips = angular.isDefined($scope.showTooltips)? $scope.showTooltips : scrollableTabsetConfig.showTooltips;
131116

132117
$scope.disableLeft = function() {
133-
return !$scope.toTheLeftHTML;
118+
return !toTheLeftHTML;
134119
};
135120

136121
$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;
146123
};
147124

148125
$scope.tooltipLeftDirection = function() {
@@ -153,15 +130,6 @@ angular.module('ui.tab.scroll', [])
153130
return $scope.tooltipRight ? $scope.tooltipRight : scrollableTabsetConfig.tooltipRight;
154131
};
155132

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-
165133
$scope.getSelector = function() {
166134
return $scope.tooltipTextSelector ? $scope.tooltipTextSelector : scrollableTabsetConfig.tooltipTextSelector;
167135
};
@@ -184,7 +152,8 @@ angular.module('ui.tab.scroll', [])
184152

185153
});
186154

187-
$scope.toTheLeftHTML = nodes.join('<br>');
155+
toTheLeftHTML = nodes.join('<br>');
156+
$scope.tooltipLeftHtml = showTooltips ? $sce.trustAsHtml(toTheLeftHTML) : '';
188157
};
189158

190159
$scope.toTheRight = function() {
@@ -206,7 +175,8 @@ angular.module('ui.tab.scroll', [])
206175

207176
});
208177

209-
$scope.toTheRightHTML = nodes.join('<br>');
178+
toTheRightHTML = nodes.join('<br>');
179+
$scope.tooltipRightHtml = showTooltips ? $sce.trustAsHtml(toTheRightHTML) : '';
210180
};
211181

212182
$scope.recalcSides = function() {
@@ -246,7 +216,11 @@ angular.module('ui.tab.scroll', [])
246216
$scope.$apply();
247217
};
248218

249-
//hello my friend jake weary
219+
$.fn.doRecalculate = function() {
220+
init();
221+
$scope.$apply();
222+
};
223+
250224
$(window).on('resize', initAndApply);
251225

252226
//we initialize by watching changes on the inner tabset's tabs collection

0 commit comments

Comments
 (0)