From 64b7f9987fe28cc30ecd4ffd4dcd87660c37f964 Mon Sep 17 00:00:00 2001 From: ballenjr Date: Wed, 31 Aug 2016 11:58:54 -0700 Subject: [PATCH 1/8] Nav Controller As discussed on Gitter --- src/js/components/navbars.js | 180 +++++++++++++++++++++++++---------- 1 file changed, 130 insertions(+), 50 deletions(-) diff --git a/src/js/components/navbars.js b/src/js/components/navbars.js index a5d83ab..f324285 100644 --- a/src/js/components/navbars.js +++ b/src/js/components/navbars.js @@ -1,83 +1,84 @@ -/** - * @module mobile-angular-ui.components.navbars +/** + * @module mobile-angular-ui.components.navbars * @description - * + * * Bootstrap default navbars are awesome for responsive websites, but are not the * best with a small screen. Also fixed positioning is yet not an option to create * navbars standing in top or bottom of the screen. - * + * * Mobile Angular Ui offers an alternative to bootstrap navbars that is more * suitable for mobile. - * + * * It uses scrollable areas to avoid scroll issues. In the following figure you can * see the difference between fixed navbars and navbars with absolute positioning. - * + * *
* *
- * + * * Here is the basic markup to achieve this. - * + * * ``` html *
* - * + * * - * + * *
* *
*
* ``` - * + * * As you can notice the base class is `.navbar-app` while the positioning is * obtained adding either `.navbar-absolute-top` or `.navbar-absolute-bottom` * class. - * + * * ### Mobile Navbar Layout - * + * * Top navbar in mobile design most of the times follows a clear pattern: a * centered title surrounded by one or two action buttons, the _back_ or the * _menu_ buttons are two common examples. - * + * * Twitter Bootstrap ships with a different arrangement of components for navbars * since they are supposed to host an horizontal navigation menu. - * + * * `.navbar-app` is specifically designed to support this different type of * `.interaction and arrangement. - * + * * Consider the following example: - * + * * ``` html * + * * ``` - * + * * `.navbar-brand-center` is a specialization of BS3's `.navbar-brand`. It will * render the title centered and below the two button groups. Note that `.navbar- * brand-center` will position the title with absolute positioning ensuring that * it will never cover the buttons, which would cause interaction problems. - * + * */ (function() { @@ -85,33 +86,60 @@ var module = angular.module('mobile-angular-ui.components.navbars', []); - /** - * @directive navbarAbsoluteTop - * @restrict C - * @description - * - * Setup absolute positioned top navbar. - * - * ``` html - * - * ``` - */ + var global; - /** - * @directive navbarAbsoluteBottom - * @restrict C - * @description - * - * Setup absolute positioned bottom navbar. - * - * ``` html - * - * ``` - */ + /** + * @directive navController + * @restrict C + * @description + * + * Directive to bind controller to navbar + * + * ``` html + * + * ``` + */ + module.directive("navController", function() { + return { + restrict: "A", + controller: function() { + this.registerController = function(name, ctrl) { + this[name] = ctrl; + } + }, + link: function(scope){} + } + }); + + /** + * @directive navbarAbsoluteTop + * @restrict C + * @description + * + * Setup absolute positioned top navbar. + * + * ``` html + * + * ``` + */ + + /** + * @directive navbarAbsoluteBottom + * @restrict C + * @description + * + * Setup absolute positioned bottom navbar. + * + * ``` html + * + * ``` + */ angular.forEach(['top', 'bottom'], function(side) { var directiveName = 'navbarAbsolute' + side.charAt(0).toUpperCase() + side.slice(1); module.directive(directiveName, [ @@ -119,14 +147,66 @@ function($rootElement) { return { restrict: 'C', - link: function(scope) { + require: "navController", + link: function(scope, elem, attr, ctrl) { $rootElement.addClass('has-navbar-' + side); - scope.$on('$destroy', function() { + scope.$on('$destroy', function(){ $rootElement.removeClass('has-navbar-' + side); }); + if (!global) global = ctrl; + global.registerController(side, new (function() { + this.hide = function() { + $rootElement.removeClass("has-navbar-" + side); + elem.addClass("ng-hide"); + }; + this.show = function() { + elem.removeClass("ng-hide"); + $rootElement.addClass("has-navbar-" + side); + }; + this.slideout = function() { + $rootElement.removeClass("has-navbar-" + side); + elem.addClass("ng-hide"); + }; + this.slidein = function() { + elem.removeClass("ng-hide"); + $rootElement.addClass("has-navbar-" + side); + }; + })()); } }; } ]); }); + + /** + * @directive [hide|show|slidein|slideout][Top|Bottom|Both][Nav] + * @restrict C + * @description + * + * Toggle each(or both) nabar(s) with or without animations + * + * ``` html + * + * + * + * ``` + */ + angular.forEach(['Top', 'Bottom', 'Both'], function(nav) { + angular.forEach(['hide', 'show', 'slidein', 'slideout'], function(method) { + var name = method + nav + "Nav"; + module.directive(name, function() { + return { + restrict: "C", + link: function(scope, elem, attr) { + if (global) + if (nav == 'Both') { + global['bottom'][method](); + global['top'][method](); + } else + global[nav.toLowerCase()][method](); + } + } + }); + }); + }); })(); From d35a584c2f0e3f23bb706f7e512f806a7c58d044 Mon Sep 17 00:00:00 2001 From: ballenjr Date: Wed, 31 Aug 2016 12:14:35 -0700 Subject: [PATCH 2/8] Formatting --- src/js/components/navbars.js | 88 ++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/src/js/components/navbars.js b/src/js/components/navbars.js index f324285..6c022e1 100644 --- a/src/js/components/navbars.js +++ b/src/js/components/navbars.js @@ -1,84 +1,84 @@ -/** - * @module mobile-angular-ui.components.navbars +/** + * @module mobile-angular-ui.components.navbars * @description - * + * * Bootstrap default navbars are awesome for responsive websites, but are not the * best with a small screen. Also fixed positioning is yet not an option to create * navbars standing in top or bottom of the screen. - * + * * Mobile Angular Ui offers an alternative to bootstrap navbars that is more * suitable for mobile. - * + * * It uses scrollable areas to avoid scroll issues. In the following figure you can * see the difference between fixed navbars and navbars with absolute positioning. - * + * *
* *
- * + * * Here is the basic markup to achieve this. - * + * * ``` html *
* - * + * * - * + * *
* *
*
* ``` - * + * * As you can notice the base class is `.navbar-app` while the positioning is * obtained adding either `.navbar-absolute-top` or `.navbar-absolute-bottom` * class. - * + * * ### Mobile Navbar Layout - * + * * Top navbar in mobile design most of the times follows a clear pattern: a * centered title surrounded by one or two action buttons, the _back_ or the * _menu_ buttons are two common examples. - * + * * Twitter Bootstrap ships with a different arrangement of components for navbars * since they are supposed to host an horizontal navigation menu. - * + * * `.navbar-app` is specifically designed to support this different type of * `.interaction and arrangement. - * + * * Consider the following example: - * + * * ``` html * - * + * * ``` - * + * * `.navbar-brand-center` is a specialization of BS3's `.navbar-brand`. It will * render the title centered and below the two button groups. Note that `.navbar- * brand-center` will position the title with absolute positioning ensuring that * it will never cover the buttons, which would cause interaction problems. - * + * */ (function() { @@ -88,18 +88,18 @@ var global; - /** + /** * @directive navController * @restrict C * @description * * Directive to bind controller to navbar - * + * * ``` html * - * ``` + * ``` */ module.directive("navController", function() { return { @@ -107,38 +107,38 @@ controller: function() { this.registerController = function(name, ctrl) { this[name] = ctrl; - } + }; }, link: function(scope){} - } + }; }); - /** + /** * @directive navbarAbsoluteTop * @restrict C * @description * * Setup absolute positioned top navbar. - * + * * ``` html * - * ``` + * ``` */ - /** + /** * @directive navbarAbsoluteBottom * @restrict C * @description - * + * * Setup absolute positioned bottom navbar. - * + * * ``` html * - * ``` + * ``` */ angular.forEach(['top', 'bottom'], function(side) { var directiveName = 'navbarAbsolute' + side.charAt(0).toUpperCase() + side.slice(1); @@ -150,7 +150,7 @@ require: "navController", link: function(scope, elem, attr, ctrl) { $rootElement.addClass('has-navbar-' + side); - scope.$on('$destroy', function(){ + scope.$on('$destroy', function() { $rootElement.removeClass('has-navbar-' + side); }); if (!global) global = ctrl; @@ -178,18 +178,18 @@ ]); }); - /** + /** * @directive [hide|show|slidein|slideout][Top|Bottom|Both][Nav] * @restrict C * @description - * + * * Toggle each(or both) nabar(s) with or without animations - * + * * ``` html * * * - * ``` + * ``` */ angular.forEach(['Top', 'Bottom', 'Both'], function(nav) { angular.forEach(['hide', 'show', 'slidein', 'slideout'], function(method) { @@ -199,13 +199,13 @@ restrict: "C", link: function(scope, elem, attr) { if (global) - if (nav == 'Both') { - global['bottom'][method](); - global['top'][method](); + if (nav === 'Both') { + global.bottom[method](); + global.top[method](); } else global[nav.toLowerCase()][method](); } - } + }; }); }); }); From b207c092bcd3cd5a3f7d2abe09c750cf271c9951 Mon Sep 17 00:00:00 2001 From: ballenjr Date: Wed, 31 Aug 2016 12:24:54 -0700 Subject: [PATCH 3/8] Missed some formatting --- src/js/components/navbars.js | 60 ++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/src/js/components/navbars.js b/src/js/components/navbars.js index 6c022e1..f407d92 100644 --- a/src/js/components/navbars.js +++ b/src/js/components/navbars.js @@ -12,23 +12,23 @@ * It uses scrollable areas to avoid scroll issues. In the following figure you can * see the difference between fixed navbars and navbars with absolute positioning. * - *
- * + *
+ * *
* * Here is the basic markup to achieve this. * * ``` html - *
- *