mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
More tests and tab item building
This commit is contained in:
@ -1,7 +1,40 @@
|
||||
TabBarItem = function(el) {
|
||||
this.el = el;
|
||||
|
||||
this._buildItem();
|
||||
};
|
||||
TabBarItem.prototype = {
|
||||
_buildItem: function() {
|
||||
var child, children = Array.prototype.slice.call(this.el.children);
|
||||
|
||||
for(var i = 0, j = children.length; i < j; i++) {
|
||||
child = children[i];
|
||||
|
||||
// Test if this is a "i" tag with icon in the class name
|
||||
// TODO: This heuristic might not be sufficient
|
||||
if(child.tagName == 'i' && /icon/.test(child.className)) {
|
||||
this.icon = child;
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the title to the text content of the tab.
|
||||
this.title = child.innerText.trim();
|
||||
}
|
||||
},
|
||||
setIcon: function(iconClass) {
|
||||
var child, children = this.el.children;
|
||||
|
||||
var hasIcon = false;
|
||||
for(var i = 0, j = children.length; i < j; i++) {
|
||||
child = children[i];
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
getIcon: function() {
|
||||
|
||||
},
|
||||
|
||||
setSelected: function(isSelected) {
|
||||
this.isSelected = isSelected;
|
||||
if(isSelected) {
|
||||
@ -40,7 +73,7 @@ TabBar.prototype = {
|
||||
_buildItems: function() {
|
||||
this.items = [];
|
||||
|
||||
var items = this.el.children;
|
||||
var items = Array.prototype.slice.call(this.el.children);
|
||||
|
||||
for(var i = 0, j = items.length; i < j; i += 1) {
|
||||
this.items[i] = new TabBarItem(items[i]);
|
||||
|
||||
@ -4,7 +4,7 @@ describe('TabBarController', function() {
|
||||
beforeEach(function() {
|
||||
var tabEl = $('<div class="tabs"></div>');
|
||||
ctrl = new TabBarController({
|
||||
tabBar: new TabBar({ el: tabEl })
|
||||
tabBar: new TabBar({ el: tabEl.get(0) })
|
||||
});
|
||||
})
|
||||
|
||||
@ -56,7 +56,7 @@ describe('TabBarController', function() {
|
||||
it('Should allow cancelling Controller switch', function() {
|
||||
var tabEl = $('<div class="tabs"></div>');
|
||||
ctrl = new TabBarController({
|
||||
tabBar: new TabBar({ el: tabEl }),
|
||||
tabBar: new TabBar({ el: tabEl.get(0) }),
|
||||
controllerWillChange: function(Controller) { return false; }
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user