Namespacing for controllers and views

This commit is contained in:
Max Lynch
2013-09-23 00:07:41 -05:00
parent 63e268f171
commit c77128eeae
8 changed files with 339 additions and 329 deletions

View File

@ -20,7 +20,7 @@
<script src="../../js/events.js"></script> <script src="../../js/events.js"></script>
<script src="../../js/gestures.js"></script> <script src="../../js/gestures.js"></script>
<script src="../../js/controllers/sideMenuViewController.js"></script> <script src="../../js/controllers/sideMenuController.js"></script>
<script src="js/toderp.js"></script> <script src="js/toderp.js"></script>
<style> <style>

View File

@ -1,5 +1,8 @@
(function(ionic) { (function(ionic) {
NavController = function(opts) {
ionic.controllers = ionic.controllers || {};
ionic.controllers.NavController = function(opts) {
var _this = this; var _this = this;
this.navBar = opts.navBar; this.navBar = opts.navBar;
@ -12,9 +15,9 @@
this.navBar.shouldGoBack = function() { this.navBar.shouldGoBack = function() {
_this.pop(); _this.pop();
} }
}; };
NavController.prototype = { ionic.controllers.NavController.prototype = {
getControllers: function() { getControllers: function() {
return this.controllers; return this.controllers;
}, },
@ -101,5 +104,5 @@
} }
}, },
}; };
})(ionic = window.ionic || {}); })(ionic = window.ionic || {});

View File

@ -1,6 +1,8 @@
(function(ionic) { (function(ionic) {
SideMenuController = function(options) { ionic.controllers = ionic.controllers || {};
ionic.controllers.SideMenuController = function(options) {
var _this = this; var _this = this;
@ -29,9 +31,9 @@
_this._handleDrag(e); _this._handleDrag(e);
}, this.center); }, this.center);
*/ */
}; };
SideMenuController.prototype = { ionic.controllers.SideMenuController.prototype = {
toggleLeft: function() { toggleLeft: function() {
var openAmount = this.getOpenAmount(); var openAmount = this.getOpenAmount();
if(openAmount > 0) { if(openAmount > 0) {
@ -186,6 +188,6 @@
this._lastX = e.gesture.touches[0].pageX; this._lastX = e.gesture.touches[0].pageX;
} }
}; };
})(ionic = window.ionic || {}); })(ionic = window.ionic || {});

View File

@ -1,6 +1,8 @@
(function(ionic) { (function(ionic) {
TabBarController = function(options) { ionic.controllers = ionic.controllers || {};
ionic.controllers.TabBarController = function(options) {
this.tabBar = options.tabBar; this.tabBar = options.tabBar;
this._bindEvents(); this._bindEvents();
@ -20,7 +22,7 @@ TabBarController = function(options) {
this.setSelectedController(0); this.setSelectedController(0);
}; };
TabBarController.prototype = { ionic.controllers.TabBarController.prototype = {
// Start listening for events on our tab bar // Start listening for events on our tab bar
_bindEvents: function() { _bindEvents: function() {
var _this = this; var _this = this;

View File

@ -1,12 +1,11 @@
(function(ionic) { (function(ionic) {
ionic.ui.NavBar = function(opts) {
NavBar = function(opts) {
this.el = opts.el; this.el = opts.el;
this._titleEl = this.el.querySelector('.title'); this._titleEl = this.el.querySelector('.title');
}; };
NavBar.prototype = { ionic.ui.NavBar.prototype = {
shouldGoBack: function() {}, shouldGoBack: function() {},
setTitle: function(title) { setTitle: function(title) {
@ -38,5 +37,5 @@
this._currentBackButton.parentNode.removeChild(this._currentBackButton); this._currentBackButton.parentNode.removeChild(this._currentBackButton);
} }
} }
}; };
})(ionic = window.ionic || {}); })(ionic = window.ionic || {});

View File

@ -1,11 +1,14 @@
(function(ionic) { (function(ionic) {
SideMenu = function(opts) {
ionic.ui = ionic.ui || {};
ionic.ui.SideMenu = function(opts) {
this.el = opts.el; this.el = opts.el;
this.width = opts.width; this.width = opts.width;
this.isEnabled = opts.isEnabled || true; this.isEnabled = opts.isEnabled || true;
}; };
SideMenu.prototype = { ionic.ui.SideMenu.prototype = {
getFullWidth: function() { getFullWidth: function() {
return this.width; return this.width;
}, },
@ -18,5 +21,5 @@
pushDown: function() { pushDown: function() {
this.el.style.zIndex = -1; this.el.style.zIndex = -1;
} }
}; };
})(ionic = window.ionic || {}); })(ionic = window.ionic || {});

View File

@ -1,11 +1,13 @@
(function(ionic) { (function(ionic) {
TabBarItem = function(el) { ionic.ui = ionic.ui || {};
ionic.ui.TabBarItem = function(el) {
this.el = el; this.el = el;
this._buildItem(); this._buildItem();
}; };
TabBarItem.prototype = { ionic.ui.TabBarItem.prototype = {
// Factory for creating an item from a given javascript object // Factory for creating an item from a given javascript object
create: function(itemData) { create: function(itemData) {
var item = document.createElement('a'); var item = document.createElement('a');
@ -74,7 +76,7 @@ TabBarItem.prototype = {
} }
}; };
TabBar = function(opts) { ionic.ui.TabBar = function(opts) {
this.el = opts.el; this.el = opts.el;
this.items = []; this.items = [];
@ -82,7 +84,7 @@ TabBar = function(opts) {
this._buildItems(); this._buildItems();
}; };
TabBar.prototype = { ionic.ui.TabBar.prototype = {
// get all the items for the TabBar // get all the items for the TabBar
getItems: function() { getItems: function() {
return this.items; return this.items;

View File

@ -134,14 +134,13 @@
</section> </section>
<script src="../../js/ionic-events.js"></script> <script src="../../js/events.js"></script>
<script src="../../js/ionic-gestures.js"></script> <script src="../../js/gestures.js"></script>
<script src="../../js/controllers/ionic-tabcontroller.js"></script> <script src="../../js/controllers/tabBarController.js"></script>
<script> <script>
// Grab the sections // Grab the sections
var tab = document.getElementById('tab-bar'); var tab = document.getElementById('tab-bar');
var controller = new ion.controllers.TabController({ var controller = new ionic.controllers.TabController({
tab: tab tab: tab
}); });
</script> </script>