From 86f3efde15e1e192ccd7e6ff85ed80a3144024a3 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Sun, 22 Sep 2013 23:51:49 -0500 Subject: [PATCH] Moved hacking controllers and views They are now official files. --- hacking/ViewController.js | 2 - .../controllers/navController.js | 0 .../controllers/sideMenuController.js | 0 .../controllers/tabBarController.js | 0 js/controllers/tabBarViewController.js | 122 ------------------ js/views/ionic-segmented.js | 3 - hacking/NavBar.js => js/views/navBar.js | 0 hacking/SideMenu.js => js/views/sideMenu.js | 0 hacking/TabBar.js => js/views/tabBar.js | 0 9 files changed, 127 deletions(-) delete mode 100644 hacking/ViewController.js rename hacking/NavController.js => js/controllers/navController.js (100%) rename hacking/SideMenuController.js => js/controllers/sideMenuController.js (100%) rename hacking/TabBarController.js => js/controllers/tabBarController.js (100%) delete mode 100644 js/controllers/tabBarViewController.js delete mode 100644 js/views/ionic-segmented.js rename hacking/NavBar.js => js/views/navBar.js (100%) rename hacking/SideMenu.js => js/views/sideMenu.js (100%) rename hacking/TabBar.js => js/views/tabBar.js (100%) diff --git a/hacking/ViewController.js b/hacking/ViewController.js deleted file mode 100644 index 7e388387a9..0000000000 --- a/hacking/ViewController.js +++ /dev/null @@ -1,2 +0,0 @@ -(function(window, document, ionic) { -})(this, document, ionic = this.ionic || {}); diff --git a/hacking/NavController.js b/js/controllers/navController.js similarity index 100% rename from hacking/NavController.js rename to js/controllers/navController.js diff --git a/hacking/SideMenuController.js b/js/controllers/sideMenuController.js similarity index 100% rename from hacking/SideMenuController.js rename to js/controllers/sideMenuController.js diff --git a/hacking/TabBarController.js b/js/controllers/tabBarController.js similarity index 100% rename from hacking/TabBarController.js rename to js/controllers/tabBarController.js diff --git a/js/controllers/tabBarViewController.js b/js/controllers/tabBarViewController.js deleted file mode 100644 index 4d16eea3de..0000000000 --- a/js/controllers/tabBarViewController.js +++ /dev/null @@ -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 || {}); diff --git a/js/views/ionic-segmented.js b/js/views/ionic-segmented.js deleted file mode 100644 index fe9e8810bf..0000000000 --- a/js/views/ionic-segmented.js +++ /dev/null @@ -1,3 +0,0 @@ -(function(window, document, ion) { - -}); diff --git a/hacking/NavBar.js b/js/views/navBar.js similarity index 100% rename from hacking/NavBar.js rename to js/views/navBar.js diff --git a/hacking/SideMenu.js b/js/views/sideMenu.js similarity index 100% rename from hacking/SideMenu.js rename to js/views/sideMenu.js diff --git a/hacking/TabBar.js b/js/views/tabBar.js similarity index 100% rename from hacking/TabBar.js rename to js/views/tabBar.js