Moved hacking controllers and views

They are now official files.
This commit is contained in:
Max Lynch
2013-09-22 23:51:49 -05:00
parent 6cf5797f4e
commit 86f3efde15
9 changed files with 0 additions and 127 deletions

View File

@ -1,2 +0,0 @@
(function(window, document, ionic) {
})(this, document, ionic = this.ionic || {});

View File

@ -1,122 +0,0 @@
(function(window, document, ionic) {
TabBarController = function(options) {
this.tabBar = options.tabBar;
this._bindEvents();
this.controllers = [];
var controllers = options.controllers || [];
for(var i = 0; i < controllers.length; i++) {
this.addController(controllers[i]);
}
// Bind or set our tabWillChange callback
this.controllerWillChange = options.controllerWillChange || function(controller) {};
this.controllerChanged = options.controllerChanged || function(controller) {};
this.setSelectedController(0);
};
TabBarController.prototype = {
// Start listening for events on our tab bar
_bindEvents: function() {
var _this = this;
this.tabBar.tryTabSelect = function(index) {
_this.setSelectedController(index);
};
},
selectController: function(index) {
var shouldChange = true;
// Check if we should switch to this tab. This lets the app
// cancel tab switches if the context isn't right, for example.
if(this.controllerWillChange) {
if(this.controllerWillChange(this.controllers[index], index) === false) {
shouldChange = false;
}
}
if(shouldChange) {
this.setSelectedController(index);
this.controllerChanged && this.controllerChanged(this.selectedController, this.selectedIndex);
}
},
// Force the selection of a controller at the given index
setSelectedController: function(index) {
if(index >= this.controllers.length) {
return;
}
this.selectedController = this.controllers[index];
this.selectedIndex = index;
this._showController(index);
this.tabBar.setSelectedItem(index);
},
_showController: function(index) {
var c;
for(var i = 0, j = this.controllers.length; i < j; i ++) {
c = this.controllers[i];
//c.detach && c.detach();
c.isVisible = false;
c.visibilityChanged && c.visibilityChanged();
}
c = this.controllers[index];
//c.attach && c.attach();
c.isVisible = true;
c.visibilityChanged && c.visibilityChanged();
},
_clearSelected: function() {
this.selectedController = null;
this.selectedIndex = -1;
},
// Return the tab at the given index
getController: function(index) {
return this.controllers[index];
},
// Return the current tab list
getControllers: function() {
return this.controllers;
},
// Get the currently selected tab
getSelectedController: function() {
return this.selectedController;
},
// Add a tab
addController: function(controller) {
this.controllers.push(controller);
this.tabBar.addItem({
title: controller.title,
icon: controller.icon
});
// If we don't have a selected controller yet, select the first one.
if(!this.selectedController) {
this.setSelectedController(0);
}
},
// Set the tabs and select the first
setControllers: function(controllers) {
this.controllers = controllers;
this._clearSelected();
this.selectController(0);
},
}
})(this, document, ion = this.ionic || {});

View File

@ -1,3 +0,0 @@
(function(window, document, ion) {
});