Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions angular-ui-tab-scroll.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
.ui-tabs-scrollable .nav-tabs {
white-space: nowrap;
overflow: hidden;
height: 42px!important;
border-bottom: 0!important;
height: 42px;
border-bottom: 0;
}

.ui-tabs-scrollable .spacer:not(.hidden-buttons) {
Expand All @@ -19,39 +19,44 @@
margin-right: -25px;
}

.ui-tabs-scrollable .tab-content {
margin-top: -1px;
border-top: 1px solid #ddd;
}

.ui-tabs-scrollable .nav > li {
margin-right: -4px;
margin-right: -3px;
float: none;
display: inline-block;
height: 42px!important;
height: 42px;
border-bottom: 1px solid #ddd;
}

.ui-tabs-scrollable .spacer:not(.hidden-buttons) .nav > li:first-child.active a,
.ui-tabs-scrollable .spacer:not(.hidden-buttons) .nav > li:first-child a:hover {
border-top-left-radius: 0!important;
border-top-left-radius: 0;
border-left: 1px solid transparent;
}

.ui-tabs-scrollable .spacer:not(.hidden-buttons) .nav > li:last-child.active a,
.ui-tabs-scrollable .spacer:not(.hidden-buttons) .nav > li:last-child a:hover {
border-top-right-radius: 0!important;
border-top-right-radius: 0;
border-right: 1px solid transparent;
margin-right: -1px;
}

.ui-tabs-scrollable .nav-button {
position: absolute;
width: 25px;
height: 42px!important;
height: 42px;
line-height: 42px;
top: 0;
color: #428bca;
cursor: pointer;
text-align: center;
border: 1px solid #ddd;
border-radius: 0!important;
padding: 0!important;
border-radius: 0;
padding: 0;
background-color: #fff;
z-index: 10;
}
Expand All @@ -62,10 +67,20 @@

.ui-tabs-scrollable .left-nav-button {
left: 0;
border-top-left-radius: 4px!important;
border-top-left-radius: 4px;
}

.ui-tabs-scrollable .right-nav-button {
right: 0;
border-top-right-radius: 4px!important;
border-top-right-radius: 4px;
}

.right-nav-button:before{
font-family: 'Glyphicons Halflings';;
content: '\e080';
}

.left-nav-button:before{
font-family: 'Glyphicons Halflings';;
content: '\e079';
}
70 changes: 22 additions & 48 deletions angular-ui-tab-scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ angular.module('ui.tab.scroll', [])
//select the innermost child that isn't a span
//this way we cover getting <tab-heading> and <tab heading=''>
//but leave other markup out of it, unless it's a span (commonly an icon)
tooltipTextSelector: '*:not(:has("*:not(span)"))',

scrollLeftIcon: 'glyphicon glyphicon-chevron-left',
scrollRightIcon: 'glyphicon glyphicon-chevron-right'
tooltipTextSelector: '*:not(:has("*:not(span)"))'
};

var config = angular.extend({}, defaultConfig);
Expand All @@ -32,28 +29,20 @@ angular.module('ui.tab.scroll', [])
setTooltipTextSelector : function(value){
config.tooltipTextSelector = value;
},
setScrollLeftIcon : function(value){
config.scrollLeftIcon = value;
},
setScrollRightIcon : function(value){
config.scrollRightIcon = value;
},
$get: function(){
return {
showTooltips: config.showTooltips,
tooltipLeft: config.tooltipLeft,
tooltipRight: config.tooltipRight,
tooltipTextSelector: config.tooltipTextSelector,
scrollLeftIcon: config.scrollLeftIcon,
scrollRightIcon: config.scrollRightIcon
tooltipTextSelector: config.tooltipTextSelector
};
}
};
}
)
.directive('scrollableTabset', [
'scrollableTabsetConfig', '$window', '$interval', '$timeout',
function(scrollableTabsetConfig, $window, $interval, $timeout) {
'scrollableTabsetConfig', '$window', '$interval', '$timeout','$sce',
function(scrollableTabsetConfig, $window, $interval, $timeout, $sce) {

var timeoutId = null;

Expand Down Expand Up @@ -105,44 +94,32 @@ angular.module('ui.tab.scroll', [])
showTooltips: '=',
tooltipLeft: '=',
tooltipRight: '=',
tooltipTextSelector: '=',
scrollLeftIcon: '=',
scrollRightIcon: '='
tooltipTextSelector: '='
},

template: [
'<div class="ui-tabs-scrollable">',
'<button type="button" ng-hide="hideButtons" ng-disabled="disableLeft()" class="btn nav-button left-nav-button" tooltip-placement="{{tooltipLeftDirection()}}" tooltip-html-unsafe="{{tooltipLeftContent()}}">',
'<span class="{{scrollLeftIconClass()}}"></span>',
'</button>',
'<button type="button" ng-hide="hideButtons" ng-disabled="disableLeft()" class="btn nav-button left-nav-button" tooltip-placement="{{tooltipLeftDirection()}}" tooltip-html="tooltipLeftHtml"/>',
'<div class="spacer" ng-class="{\'hidden-buttons\': hideButtons}" ng-transclude></div>',
'<button type="button" ng-hide="hideButtons" ng-disabled="disableRight()" class="btn nav-button right-nav-button" tooltip-placement="{{tooltipRightDirection()}}" tooltip-html-unsafe="{{tooltipRightContent()}}">',
'<span class="{{scrollRightIconClass()}}"></span>',
'</button>',
'<button type="button" ng-hide="hideButtons" ng-disabled="disableRight()" class="btn nav-button right-nav-button" tooltip-placement="{{tooltipRightDirection()}}" tooltip-html="tooltipRightHtml"/>',
'</div>'
].join(''),

link: function($scope, $el) {

$scope.toTheLeftHTML = '';
$scope.toTheRightHTML = '';
$scope.tooltipRightHtml = '';
$scope.tooltipLeftHtml = '';
var toTheLeftHTML = '';
var toTheRightHTML = '';

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

$scope.disableLeft = function() {
return !$scope.toTheLeftHTML;
return !toTheLeftHTML;
};

$scope.disableRight = function() {
return !$scope.toTheRightHTML;
};

$scope.tooltipLeftContent = function() {
return showTooltips ? $scope.toTheLeftHTML : '';
};

$scope.tooltipRightContent = function() {
return showTooltips ? $scope.toTheRightHTML : '';
return !toTheRightHTML;
};

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

$scope.scrollLeftIconClass = function() {
return $scope.scrollLeftIcon ? $scope.scrollLeftIcon : scrollableTabsetConfig.scrollLeftIcon;
};

$scope.scrollRightIconClass = function() {
return $scope.scrollRightIcon ? $scope.scrollRightIcon : scrollableTabsetConfig.scrollRightIcon;
};


$scope.getSelector = function() {
return $scope.tooltipTextSelector ? $scope.tooltipTextSelector : scrollableTabsetConfig.tooltipTextSelector;
};
Expand All @@ -184,7 +152,8 @@ angular.module('ui.tab.scroll', [])

});

$scope.toTheLeftHTML = nodes.join('<br>');
toTheLeftHTML = nodes.join('<br>');
$scope.tooltipLeftHtml = showTooltips ? $sce.trustAsHtml(toTheLeftHTML) : '';
};

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

});

$scope.toTheRightHTML = nodes.join('<br>');
toTheRightHTML = nodes.join('<br>');
$scope.tooltipRightHtml = showTooltips ? $sce.trustAsHtml(toTheRightHTML) : '';
};

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

//hello my friend jake weary
$.fn.doRecalculate = function() {
init();
$scope.$apply();
};

$(window).on('resize', initAndApply);

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