mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
refactor(tabs): dont show icon if no icon defined
This commit is contained in:
10
js/ext/angular/src/directive/ionicTabBar.js
vendored
10
js/ext/angular/src/directive/ionicTabBar.js
vendored
@@ -244,13 +244,13 @@ function($scope, $ionicViewService, $rootScope, $element) {
|
||||
replace: true,
|
||||
require: ['^ionTabs', '^ionTab'],
|
||||
template:
|
||||
'<div ng-class="{active: isTabActive(), \'has-badge\':badge}" ' +
|
||||
'<a ng-class="{active: isTabActive(), \'has-badge\':badge}" ' +
|
||||
'ng-click="selectTab()" class="tab-item">' +
|
||||
'<span class="badge {{badgeStyle}}" ng-show="badge">{{badge}}</span>' +
|
||||
'<i class="icon {{iconOn}}" ng-show="isTabActive()"></i>' +
|
||||
'<i class="icon {{iconOff}}" ng-hide="isTabActive()"></i>' +
|
||||
'<span class="badge {{badgeStyle}}" ng-if="badge">{{badge}}</span>' +
|
||||
'<i class="icon {{iconOn}}" ng-if="iconOn && isTabActive()"></i>' +
|
||||
'<i class="icon {{iconOff}}" ng-if="iconOff && !isTabActive()"></i>' +
|
||||
'<span class="tab-title" ng-bind-html="title"></span>' +
|
||||
'</div>',
|
||||
'</a>',
|
||||
scope: {
|
||||
title: '@',
|
||||
icon: '@',
|
||||
|
||||
@@ -369,8 +369,8 @@ describe('tabs', function() {
|
||||
return element;
|
||||
}
|
||||
|
||||
// These next two are REALLY specific unit tests,
|
||||
// but also are really really vital pieces of code
|
||||
// These next two are REALLY specific unit tests,
|
||||
// but also are really really vital pieces of code
|
||||
it('.isTabActive should be correct', function() {
|
||||
var el = setup();
|
||||
expect(el.isolateScope().isTabActive()).toBe(false);
|
||||
@@ -397,9 +397,12 @@ describe('tabs', function() {
|
||||
expect(tabsCtrl.select).toHaveBeenCalledWith(tabCtrl.$scope, true);
|
||||
});
|
||||
|
||||
it('should have title', function() {
|
||||
it('should have title and only title', function() {
|
||||
var el = setup('title="<b>hi, {{name}}!</b>"');
|
||||
expect(el.find('.tab-title').html()).toBe('<b>hi, !</b>');
|
||||
expect(el.find('.icon.on').length).toBe(0);
|
||||
expect(el.find('.icon.off').length).toBe(0);
|
||||
|
||||
el.scope().$apply('name = "joe"');
|
||||
expect(el.find('.tab-title').html()).toBe('<b>hi, joe!</b>');
|
||||
});
|
||||
@@ -409,17 +412,19 @@ describe('tabs', function() {
|
||||
el.isolateScope().isTabActive = function() { return true; };
|
||||
el.isolateScope().$apply();
|
||||
expect(el.hasClass('active')).toBe(true);
|
||||
expect(el.find('.icon.on').hasClass('ng-hide')).toBe(false);
|
||||
expect(el.find('.icon.off').hasClass('ng-hide')).toBe(true);
|
||||
expect(el.find('.icon.on').length).toBe(1);
|
||||
expect(el.find('.icon.off').length).toBe(0);
|
||||
|
||||
el.isolateScope().isTabActive = function() { return false; };
|
||||
el.isolateScope().$apply();
|
||||
expect(el.hasClass('active')).toBe(false);
|
||||
expect(el.find('.icon.on').hasClass('ng-hide')).toBe(true);
|
||||
expect(el.find('.icon.off').hasClass('ng-hide')).toBe(false);
|
||||
expect(el.find('.icon.on').length).toBe(0);
|
||||
expect(el.find('.icon.off').length).toBe(1);
|
||||
});
|
||||
it('shouldnt has-badge without badge', function() {
|
||||
expect(setup().hasClass('has-badge')).toBe(false);
|
||||
var el = setup();
|
||||
expect(el.hasClass('has-badge')).toBe(false);
|
||||
expect(el.find('.badge').length).toBe(0);
|
||||
});
|
||||
it('should have badge', function() {
|
||||
var el = setup('badge="\'badger\'" badge-style="super-style"');
|
||||
|
||||
Reference in New Issue
Block a user