From 565b050003da9fb4f7fa876851def5ea97f2ea74 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 1 Nov 2013 15:47:04 -0500 Subject: [PATCH 1/7] Fixed nav controller scoping and isVisible --- dist/js/ionic-angular.js | 91 +++++++++++------------- js/ext/angular/src/directive/ionicNav.js | 91 +++++++++++------------- 2 files changed, 86 insertions(+), 96 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 3a798ffed3..4bc247a16c 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -642,6 +642,31 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges }) .directive('navContent', ['Gesture', '$animate', '$compile', function(Gesture, $animate, $compile) { + + var animatePushedController = function(childScope, clone, $element) { + var title = angular.element($element.parent().parent().parent()[0].querySelector('.title')); + var newTitle = angular.element(title.clone()); + + $compile(newTitle)(childScope); + title.after(newTitle); + + clone.addClass(childScope.slideAnimation); + + $animate.addClass(newTitle, childScope.slideTitleAnimation, function() { + $animate.removeClass(newTitle, childScope.slideTitleAnimation, function() { + newTitle.scope().$destroy(); + newTitle.remove(); + }); + }); + + var title = $element.parent().parent().parent()[0].querySelector('.title'); + $animate.enter(clone, $element.parent(), $element); + $animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() { + $animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() { + }); + }); + }; + return { restrict: 'ECA', require: '^navs', @@ -650,6 +675,20 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges return function($scope, $element, $attr, navCtrl) { var lastParent, lastIndex, childScope, childElement; + + $scope.title = $attr.title; + $scope.slideAnimation = $attr.slideAnimation || ''; + $scope.slideTitleAnimation = $attr.slideTitleAnimation || ''; + + if($attr.navBar === "false") { + navCtrl.hideNavBar(); + } else { + navCtrl.showNavBar(); + } + + // Push this controller onto the stack + $scope.pushController($scope, $element); + $scope.$watch('isVisible', function(value) { // Taken from ngIf if(childElement) { @@ -661,58 +700,14 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges childScope = undefined; } + // Check if this is visible, and if so, create it and show it if(value) { - childScope = $scope; + childScope = $scope.$new(); + transclude(childScope, function(clone) { childElement = clone; - childScope.title = $attr.title; - childScope.slideAnimation = $attr.slideAnimation || ''; - childScope.slideTitleAnimation = $attr.slideTitleAnimation || ''; - - if($attr.navBar === "false") { - navCtrl.hideNavBar(); - } else { - navCtrl.showNavBar(); - } - - childScope.pushController(childScope, $element); - - var title = angular.element($element.parent().parent().parent()[0].querySelector('.title')); - var newTitle = angular.element(title.clone()); - - $compile(newTitle)(childScope); - - title.after(newTitle); - - console.log(newTitle); - - clone.addClass(childScope.slideAnimation); - - $animate.addClass(newTitle, childScope.slideTitleAnimation, function() { - $animate.removeClass(newTitle, childScope.slideTitleAnimation, function() { - newTitle.scope().$destroy(); - newTitle.remove(); - }); - }); - - /* - Gesture.on('drag', function(e) { - //navCtrl.handleDrag(e); - console.log('Content drag', e); - }, childElement[0]); - - Gesture.on('release', function(e) { - //navCtrl._endDrag(e); - }, childElement[0]); - */ - - var title = $element.parent().parent().parent()[0].querySelector('.title'); - $animate.enter(clone, $element.parent(), $element); - $animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() { - $animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() { - }); - }); + animatePushedController(childScope, clone, $element); }); } }); diff --git a/js/ext/angular/src/directive/ionicNav.js b/js/ext/angular/src/directive/ionicNav.js index 8b13cc26a4..5f231c996c 100644 --- a/js/ext/angular/src/directive/ionicNav.js +++ b/js/ext/angular/src/directive/ionicNav.js @@ -97,6 +97,31 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges }) .directive('navContent', ['Gesture', '$animate', '$compile', function(Gesture, $animate, $compile) { + + var animatePushedController = function(childScope, clone, $element) { + var title = angular.element($element.parent().parent().parent()[0].querySelector('.title')); + var newTitle = angular.element(title.clone()); + + $compile(newTitle)(childScope); + title.after(newTitle); + + clone.addClass(childScope.slideAnimation); + + $animate.addClass(newTitle, childScope.slideTitleAnimation, function() { + $animate.removeClass(newTitle, childScope.slideTitleAnimation, function() { + newTitle.scope().$destroy(); + newTitle.remove(); + }); + }); + + var title = $element.parent().parent().parent()[0].querySelector('.title'); + $animate.enter(clone, $element.parent(), $element); + $animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() { + $animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() { + }); + }); + }; + return { restrict: 'ECA', require: '^navs', @@ -105,6 +130,20 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges return function($scope, $element, $attr, navCtrl) { var lastParent, lastIndex, childScope, childElement; + + $scope.title = $attr.title; + $scope.slideAnimation = $attr.slideAnimation || ''; + $scope.slideTitleAnimation = $attr.slideTitleAnimation || ''; + + if($attr.navBar === "false") { + navCtrl.hideNavBar(); + } else { + navCtrl.showNavBar(); + } + + // Push this controller onto the stack + $scope.pushController($scope, $element); + $scope.$watch('isVisible', function(value) { // Taken from ngIf if(childElement) { @@ -116,58 +155,14 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges childScope = undefined; } + // Check if this is visible, and if so, create it and show it if(value) { - childScope = $scope; + childScope = $scope.$new(); + transclude(childScope, function(clone) { childElement = clone; - childScope.title = $attr.title; - childScope.slideAnimation = $attr.slideAnimation || ''; - childScope.slideTitleAnimation = $attr.slideTitleAnimation || ''; - - if($attr.navBar === "false") { - navCtrl.hideNavBar(); - } else { - navCtrl.showNavBar(); - } - - childScope.pushController(childScope, $element); - - var title = angular.element($element.parent().parent().parent()[0].querySelector('.title')); - var newTitle = angular.element(title.clone()); - - $compile(newTitle)(childScope); - - title.after(newTitle); - - console.log(newTitle); - - clone.addClass(childScope.slideAnimation); - - $animate.addClass(newTitle, childScope.slideTitleAnimation, function() { - $animate.removeClass(newTitle, childScope.slideTitleAnimation, function() { - newTitle.scope().$destroy(); - newTitle.remove(); - }); - }); - - /* - Gesture.on('drag', function(e) { - //navCtrl.handleDrag(e); - console.log('Content drag', e); - }, childElement[0]); - - Gesture.on('release', function(e) { - //navCtrl._endDrag(e); - }, childElement[0]); - */ - - var title = $element.parent().parent().parent()[0].querySelector('.title'); - $animate.enter(clone, $element.parent(), $element); - $animate.addClass(angular.element(title), childScope.slideTitleAnimation, function() { - $animate.removeClass(angular.element(title), childScope.slideTitleAnimation, function() { - }); - }); + animatePushedController(childScope, clone, $element); }); } }); From b91f0096e766f0f8f17554d49193694ccea317c7 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 1 Nov 2013 15:52:04 -0500 Subject: [PATCH 2/7] GITHUB! --- js/ext/angular/src/directive/ionicNav.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/js/ext/angular/src/directive/ionicNav.js b/js/ext/angular/src/directive/ionicNav.js index 7a5b5f85f0..5f231c996c 100644 --- a/js/ext/angular/src/directive/ionicNav.js +++ b/js/ext/angular/src/directive/ionicNav.js @@ -40,6 +40,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges */ this.pushFromTemplate = function(templateUrl) { var childScope = $scope.$new(); + childScope.isVisible = true; // Load the given template TemplateLoader.load(templateUrl).then(function(templateString) { @@ -122,14 +123,13 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges }; return { - restrict: 'CA', + restrict: 'ECA', require: '^navs', transclude: 'element', compile: function(element, attr, transclude) { return function($scope, $element, $attr, navCtrl) { var lastParent, lastIndex, childScope, childElement; -<<<<<<< HEAD $scope.title = $attr.title; $scope.slideAnimation = $attr.slideAnimation || ''; @@ -143,9 +143,6 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges // Push this controller onto the stack $scope.pushController($scope, $element); -======= - $scope.isVisible = true; ->>>>>>> e8bd9a5dee77d29b746115546a51b1a4a3d46246 $scope.$watch('isVisible', function(value) { // Taken from ngIf @@ -161,10 +158,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges // Check if this is visible, and if so, create it and show it if(value) { childScope = $scope.$new(); -<<<<<<< HEAD -======= ->>>>>>> e8bd9a5dee77d29b746115546a51b1a4a3d46246 transclude(childScope, function(clone) { childElement = clone; From 40b5a83cb80e7e3fa27c035eba44bd007fd6aa38 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 1 Nov 2013 15:54:14 -0500 Subject: [PATCH 3/7] Other title slides in nicely --- dist/js/ionic-angular.js | 5 +++-- js/ext/angular/src/directive/ionicNav.js | 5 +++-- js/ext/angular/test/nav.html | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 4bc247a16c..1abf9887fe 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -652,8 +652,8 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges clone.addClass(childScope.slideAnimation); - $animate.addClass(newTitle, childScope.slideTitleAnimation, function() { - $animate.removeClass(newTitle, childScope.slideTitleAnimation, function() { + $animate.addClass(newTitle, childScope.slideTitleInAnimation, function() { + $animate.removeClass(newTitle, childScope.slideTitleInAnimation, function() { newTitle.scope().$destroy(); newTitle.remove(); }); @@ -679,6 +679,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges $scope.title = $attr.title; $scope.slideAnimation = $attr.slideAnimation || ''; $scope.slideTitleAnimation = $attr.slideTitleAnimation || ''; + $scope.slideTitleInAnimation = $attr.slideTitleInAnimation || ''; if($attr.navBar === "false") { navCtrl.hideNavBar(); diff --git a/js/ext/angular/src/directive/ionicNav.js b/js/ext/angular/src/directive/ionicNav.js index 5f231c996c..6a2526b0aa 100644 --- a/js/ext/angular/src/directive/ionicNav.js +++ b/js/ext/angular/src/directive/ionicNav.js @@ -107,8 +107,8 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges clone.addClass(childScope.slideAnimation); - $animate.addClass(newTitle, childScope.slideTitleAnimation, function() { - $animate.removeClass(newTitle, childScope.slideTitleAnimation, function() { + $animate.addClass(newTitle, childScope.slideTitleInAnimation, function() { + $animate.removeClass(newTitle, childScope.slideTitleInAnimation, function() { newTitle.scope().$destroy(); newTitle.remove(); }); @@ -134,6 +134,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges $scope.title = $attr.title; $scope.slideAnimation = $attr.slideAnimation || ''; $scope.slideTitleAnimation = $attr.slideTitleAnimation || ''; + $scope.slideTitleInAnimation = $attr.slideTitleInAnimation || ''; if($attr.navBar === "false") { navCtrl.hideNavBar(); diff --git a/js/ext/angular/test/nav.html b/js/ext/angular/test/nav.html index 46b8d6679c..8e14cc408e 100644 --- a/js/ext/angular/test/nav.html +++ b/js/ext/angular/test/nav.html @@ -39,7 +39,7 @@ - - - - + + + + + @@ -32,9 +32,10 @@ - + - + +